[Win32k]
[reactos.git] / reactos / win32ss / user / ntuser / callback.c
index fbad4a2..2f3ea96 100644 (file)
@@ -51,13 +51,19 @@ IntCbFreeMemory(PVOID Data)
    PINT_CALLBACK_HEADER Mem;
    PTHREADINFO W32Thread;
 
+   W32Thread = PsGetCurrentThreadWin32Thread();
+   ASSERT(W32Thread);
+
+   if (W32Thread->TIF_flags & TIF_INCLEANUP)
+   {
+      ERR("CbFM Thread is already in cleanup\n");
+      return;
+   }
+
    ASSERT(Data);
 
    Mem = ((PINT_CALLBACK_HEADER)Data - 1);
 
-   W32Thread = PsGetCurrentThreadWin32Thread();
-   ASSERT(W32Thread);
-
    /* Remove the memory block from the thread's callback list */
    RemoveEntryList(&Mem->ListEntry);
 
@@ -340,8 +346,9 @@ co_IntCallWindowProc(WNDPROC Proc,
                                &ResultLength);
    if (!NT_SUCCESS(Status))
    {
+      ERR("Error Callback to User space Status %lx\n",Status);
       UserEnterCo();
-      return -1;
+      return 0;
    }
 
    _SEH2_TRY
@@ -424,7 +431,7 @@ co_IntCallWindowProc(WNDPROC Proc,
 }
 
 HMENU APIENTRY
-co_IntLoadSysMenuTemplate()
+co_IntLoadSysMenuTemplate(VOID)
 {
    LRESULT Result = 0;
    NTSTATUS Status;
@@ -640,7 +647,13 @@ co_IntCallHookProc(INT HookId,
    Common->offPfn = offPfn;
    Common->Ansi = Ansi;
    RtlZeroMemory(&Common->ModuleName, sizeof(Common->ModuleName));
-   RtlCopyMemory(&Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
+   if (ModuleName->Buffer && ModuleName->Length)
+   {
+      RtlCopyMemory(&Common->ModuleName, ModuleName->Buffer, ModuleName->Length);
+      // If ModuleName->Buffer NULL while in destroy,
+      //    this will make User32:Hook.c complain about not loading the library module.
+      // Fix symptom for CORE-10549.
+   }
    Extra = (PCHAR) Common + sizeof(HOOKPROC_CALLBACK_ARGUMENTS);
 
    switch(HookId)
@@ -731,7 +744,7 @@ co_IntCallHookProc(INT HookId,
 
    if (!NT_SUCCESS(Status))
    {
-      ERR("Failure to make Callback! Status 0x%x",Status);
+      ERR("Failure to make Callback! Status 0x%x\n",Status);
       goto Fault_Exit;
    }