Author: hbelusca
Date: Sun Dec 28 15:28:00 2014
New Revision: 65861

URL: http://svn.reactos.org/svn/reactos?rev=65861&view=rev
Log:
[WIN32K]
Split init code into GDI part and USER part. Don't use Eng* functions to 
initialize the InputIdleEvent.
Part 2/x

Modified:
    trunk/reactos/win32ss/gdi/ntgdi/init.c
    trunk/reactos/win32ss/user/ntuser/main.c

Modified: trunk/reactos/win32ss/gdi/ntgdi/init.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/init.c?rev=65861&r1=65860&r2=65861&view=diff
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/init.c      [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/init.c      [iso-8859-1] Sun Dec 28 
15:28:00 2014
@@ -12,6 +12,67 @@
 #include <debug.h>
 #include <kdros.h>
 
+BOOL NTAPI GDI_CleanupForProcess(struct _EPROCESS *Process);
+
+NTSTATUS
+GdiProcessCreate(PEPROCESS Process)
+{
+    PPROCESSINFO ppiCurrent = PsGetProcessWin32Process(Process);
+    ASSERT(ppiCurrent);
+
+    InitializeListHead(&ppiCurrent->PrivateFontListHead);
+    ExInitializeFastMutex(&ppiCurrent->PrivateFontListLock);
+
+    InitializeListHead(&ppiCurrent->GDIBrushAttrFreeList);
+    InitializeListHead(&ppiCurrent->GDIDcAttrFreeList);
+
+    /* Map the GDI handle table to user land */
+    Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(Process);
+    Process->Peb->GdiDCAttributeList = GDI_BATCH_LIMIT;
+
+    /* Create pools for GDI object attributes */
+    ppiCurrent->pPoolDcAttr = GdiPoolCreate(sizeof(DC_ATTR), 'acdG');
+    ppiCurrent->pPoolBrushAttr = GdiPoolCreate(sizeof(BRUSH_ATTR), 'arbG');
+    ppiCurrent->pPoolRgnAttr = GdiPoolCreate(sizeof(RGN_ATTR), 'agrG');
+    ASSERT(ppiCurrent->pPoolDcAttr);
+    ASSERT(ppiCurrent->pPoolBrushAttr);
+    ASSERT(ppiCurrent->pPoolRgnAttr);
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+GdiProcessDestroy(PEPROCESS Process)
+{
+    PPROCESSINFO ppiCurrent = PsGetProcessWin32Process(Process);
+    ASSERT(ppiCurrent);
+    ASSERT(ppiCurrent->peProcess == Process);
+
+    /* And GDI ones too */
+    GDI_CleanupForProcess(Process);
+
+    /* So we can now free the pools */
+    GdiPoolDestroy(ppiCurrent->pPoolDcAttr);
+    GdiPoolDestroy(ppiCurrent->pPoolBrushAttr);
+    GdiPoolDestroy(ppiCurrent->pPoolRgnAttr);
+
+    return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+GdiThreadCreate(PETHREAD Thread)
+{
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+GdiThreadDestroy(PETHREAD Thread)
+{
+    return STATUS_SUCCESS;
+}
+
+
 /*
  * @implemented
  */

Modified: trunk/reactos/win32ss/user/ntuser/main.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/main.c?rev=65861&r1=65860&r2=65861&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/main.c    [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/main.c    [iso-8859-1] Sun Dec 28 
15:28:00 2014
@@ -15,11 +15,14 @@
 
 HANDLE hModuleWin;
 
-PGDI_HANDLE_TABLE NTAPI GDIOBJ_iAllocHandleTable(OUT PVOID *SectionObject);
-BOOL NTAPI GDI_CleanupForProcess (struct _EPROCESS *Process);
-
 NTSTATUS DestroyProcessCallback(PEPROCESS Process);
 NTSTATUS NTAPI DestroyThreadCallback(PETHREAD Thread);
+
+// TODO: Should be moved to some GDI header
+NTSTATUS GdiProcessCreate(PEPROCESS Process);
+NTSTATUS GdiProcessDestroy(PEPROCESS Process);
+NTSTATUS GdiThreadCreate(PETHREAD Thread);
+NTSTATUS GdiThreadDestroy(PETHREAD Thread);
 
 HANDLE GlobalUserHeap = NULL;
 PVOID GlobalUserHeapSection = NULL;
@@ -77,7 +80,7 @@
         return STATUS_NO_MEMORY;
     }
 
-    TRACE_CH(UserProcess,"Allocated ppi 0x%p for PID:0x%lx\n",
+    TRACE_CH(UserProcess, "Allocated ppi 0x%p for PID:0x%lx\n",
              ppiCurrent, HandleToUlong(Process->UniqueProcessId));
 
     RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
@@ -104,7 +107,8 @@
 {
     if (ppiCurrent->InputIdleEvent)
     {
-       EngDeleteEvent((PEVENT)ppiCurrent->InputIdleEvent);
+        /* Free the allocated memory */
+        ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
     }
 
     /* Close the startup desktop */
@@ -121,6 +125,109 @@
 
     /* Free the PROCESSINFO */
     ExFreePoolWithTag(ppiCurrent, USERTAG_PROCESSINFO);
+}
+
+NTSTATUS
+UserProcessCreate(PEPROCESS Process)
+{
+    PPROCESSINFO ppiCurrent = PsGetProcessWin32Process(Process);
+    ASSERT(ppiCurrent);
+
+    InitializeListHead(&ppiCurrent->DriverObjListHead);
+    ExInitializeFastMutex(&ppiCurrent->DriverObjListLock);
+
+    ppiCurrent->KeyboardLayout = W32kGetDefaultKeyLayout();
+    {
+        PKEVENT Event;
+
+        /* Allocate memory for the event structure */
+        Event = ExAllocatePoolWithTag(NonPagedPool,
+                                      sizeof(*Event),
+                                      USERTAG_EVENT);
+        if (Event)
+        {
+            /* Initialize the kernel event */
+            KeInitializeEvent(Event,
+                              SynchronizationEvent,
+                              FALSE);
+        }
+        else
+        {
+            /* Out of memory */
+            DPRINT("CreateEvent() failed\n");
+            KeBugCheck(0);
+        }
+
+        /* Set the event */
+        ppiCurrent->InputIdleEvent = Event;
+        KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, 
FALSE);
+    }
+
+    ppiCurrent->peProcess = Process;
+
+    /* Setup process flags */
+    ppiCurrent->W32PF_flags = W32PF_PROCESSCONNECTED;
+    if ( Process->Peb->ProcessParameters &&
+         Process->Peb->ProcessParameters->WindowFlags & STARTF_SCRNSAVER )
+    {
+        ppiScrnSaver = ppiCurrent;
+        ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
+    }
+
+    // FIXME: check if this process is allowed.
+    ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting 
application it will get toggled off.
+
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UserProcessDestroy(PEPROCESS Process)
+{
+    PPROCESSINFO ppiCurrent = PsGetProcessWin32Process(Process);
+    ASSERT(ppiCurrent);
+
+    if (ppiScrnSaver == ppiCurrent)
+        ppiScrnSaver = NULL;
+
+    /* Destroy user objects */
+    UserDestroyObjectsForOwner(gHandleTable, ppiCurrent);
+
+    TRACE_CH(UserProcess, "Freeing ppi 0x%p\n", ppiCurrent);
+#if DBG
+    if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
+    {
+        TRACE_CH(UserObj, "Dumping user handles at the end of the process %s 
(Info %p).\n",
+            ppiCurrent->peProcess->ImageFileName, ppiCurrent);
+        DbgUserDumpHandleTable();
+    }
+#endif
+
+    /* Remove it from the list of GUI apps */
+    co_IntGraphicsCheck(FALSE);
+
+    /*
+     * Deregister logon application automatically
+     */
+    if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
+        gpidLogon = 0;
+
+    /* Close the current window station */
+    UserSetProcessWindowStation(NULL);
+
+    if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
+
+    if (ppiCurrent->hdeskStartup)
+    {
+        ZwClose(ppiCurrent->hdeskStartup);
+        ppiCurrent->hdeskStartup = NULL;
+    }
+
+#ifdef NEW_CURSORICON
+    /* Clean up the process icon cache */
+    IntCleanupCurIconCache(ppiCurrent);
+#endif
+
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS
@@ -131,7 +238,6 @@
     SIZE_T ViewSize = 0;
     LARGE_INTEGER Offset;
     PVOID UserBase = NULL;
-    PRTL_USER_PROCESS_PARAMETERS pParams = Process->Peb->ProcessParameters;
 
     /* We might be called with an already allocated win32 process */
     ppiCurrent = PsGetProcessWin32Process(Process);
@@ -171,7 +277,7 @@
                                 PAGE_EXECUTE_READ); /* would prefer 
PAGE_READONLY, but thanks to RTL heaps... */
     if (!NT_SUCCESS(Status))
     {
-        TRACE_CH(UserProcess,"Failed to map the global heap! 0x%x\n", Status);
+        TRACE_CH(UserProcess, "Failed to map the global heap! 0x%x\n", Status);
         goto error;
     }
     ppiCurrent->HeapMappings.Next = NULL;
@@ -179,49 +285,21 @@
     ppiCurrent->HeapMappings.UserMapping = UserBase;
     ppiCurrent->HeapMappings.Count = 1;
 
-    InitializeListHead(&ppiCurrent->GDIBrushAttrFreeList);
-    InitializeListHead(&ppiCurrent->GDIDcAttrFreeList);
-
-    InitializeListHead(&ppiCurrent->PrivateFontListHead);
-    ExInitializeFastMutex(&ppiCurrent->PrivateFontListLock);
-
-    InitializeListHead(&ppiCurrent->DriverObjListHead);
-    ExInitializeFastMutex(&ppiCurrent->DriverObjListLock);
-
-    ppiCurrent->KeyboardLayout = W32kGetDefaultKeyLayout();
-    if (!EngCreateEvent((PEVENT *)&ppiCurrent->InputIdleEvent))
-    {
-        KeBugCheck(0);
-    }
-
-    KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
-
-    /* Map the gdi handle table to user land */
-    Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(Process);
-    Process->Peb->GdiDCAttributeList = GDI_BATCH_LIMIT;
-    pParams = Process->Peb->ProcessParameters;
-
-    ppiCurrent->peProcess = Process;
-    /* Setup process flags */
-    ppiCurrent->W32PF_flags = W32PF_THREADCONNECTED;
-
-    if ( pParams &&
-         pParams->WindowFlags & STARTF_SCRNSAVER )
-    {
-       ppiScrnSaver = ppiCurrent;
-       ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
-    }
-
-    // FIXME: check if this process is allowed.
-    ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting 
application it will get toggled off.
-
-    /* Create pools for GDI object attributes */
-    ppiCurrent->pPoolDcAttr = GdiPoolCreate(sizeof(DC_ATTR), 'acdG');
-    ppiCurrent->pPoolBrushAttr = GdiPoolCreate(sizeof(BRUSH_ATTR), 'arbG');
-    ppiCurrent->pPoolRgnAttr = GdiPoolCreate(sizeof(RGN_ATTR), 'agrG');
-    ASSERT(ppiCurrent->pPoolDcAttr);
-    ASSERT(ppiCurrent->pPoolBrushAttr);
-    ASSERT(ppiCurrent->pPoolRgnAttr);
+    /* Initialize USER process info */
+    Status = UserProcessCreate(Process);
+    if (!NT_SUCCESS(Status))
+    {
+        ERR_CH(UserProcess, "UserProcessCreate failed, Status 0x%08lx\n", 
Status);
+        goto error;
+    }
+
+    /* Initialize GDI process info */
+    Status = GdiProcessCreate(Process);
+    if (!NT_SUCCESS(Status))
+    {
+        ERR_CH(UserProcess, "GdiProcessCreate failed, Status 0x%08lx\n", 
Status);
+        goto error;
+    }
 
     /* Add the process to the global list */
     ppiCurrent->ppiNext = gppiList;
@@ -230,7 +308,7 @@
     return STATUS_SUCCESS;
 
 error:
-    ERR_CH(UserProcess,"CreateProcessCallback failed! Freeing ppi 0x%p for 
PID:0x%lx\n",
+    ERR_CH(UserProcess, "CreateProcessCallback failed! Freeing ppi 0x%p for 
PID:0x%lx\n",
            ppiCurrent, HandleToUlong(Process->UniqueProcessId));
     DestroyProcessCallback(Process);
     return Status;
@@ -244,67 +322,25 @@
     /* Get the Win32 Process */
     ppiCurrent = PsGetProcessWin32Process(Process);
     ASSERT(ppiCurrent);
+    ASSERT(ppiCurrent->peProcess == Process);
 
     TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
     ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
-
-    if (ppiScrnSaver == ppiCurrent)
-        ppiScrnSaver = NULL;
-
-    /* Destroy user objects */
-    UserDestroyObjectsForOwner(gHandleTable, ppiCurrent);
-
-    TRACE_CH(UserProcess,"Freeing ppi 0x%p\n", ppiCurrent);
-#if DBG
-    if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
-    {
-        TRACE_CH(UserObj, "Dumping user handles at the end of the process %s 
(Info %p).\n",
-            ppiCurrent->peProcess->ImageFileName, ppiCurrent);
-        DbgUserDumpHandleTable();
-    }
-#endif
-
-    /* And GDI ones too */
-    GDI_CleanupForProcess(Process);
-
-    /* So we can now free the pools */
-    GdiPoolDestroy(ppiCurrent->pPoolDcAttr);
-    GdiPoolDestroy(ppiCurrent->pPoolBrushAttr);
-    GdiPoolDestroy(ppiCurrent->pPoolRgnAttr);
-
-    /* Remove it from the list of GUI apps */
-    co_IntGraphicsCheck(FALSE);
-
-    /*
-     * Deregister logon application automatically
-     */
-    if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
-        gpidLogon = 0;
-
-    /* Close the current window station */
-    UserSetProcessWindowStation(NULL);
-
-    if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
 
     /* Remove it from the list */
     pppi = &gppiList;
     while (*pppi != NULL && *pppi != ppiCurrent)
+    {
         pppi = &(*pppi)->ppiNext;
-
+    }
     ASSERT(*pppi == ppiCurrent);
-
     *pppi = ppiCurrent->ppiNext;
 
-    if (ppiCurrent->hdeskStartup)
-    {
-        ZwClose(ppiCurrent->hdeskStartup);
-        ppiCurrent->hdeskStartup = NULL;
-    }
-
-#ifdef NEW_CURSORICON
-    /* Clean up the process icon cache */
-    IntCleanupCurIconCache(ppiCurrent);
-#endif
+    /* Cleanup GDI info */
+    GdiProcessDestroy(Process);
+
+    /* Cleanup USER info */
+    UserProcessDestroy(Process);
 
     /* The process is dying */
     PsSetProcessWin32Process(Process, NULL, ppiCurrent);
@@ -325,7 +361,7 @@
 
     ASSERT(Process->Peb);
 
-    TRACE_CH(UserProcess,"Win32kProcessCallback -->\n");
+    TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
 
     UserEnterExclusive();
 
@@ -340,7 +376,7 @@
 
     UserLeave();
 
-    TRACE_CH(UserProcess,"<-- Win32kProcessCallback\n");
+    TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
 
     return Status;
 }
@@ -374,7 +410,7 @@
         return STATUS_NO_MEMORY;
     }
 
-    TRACE_CH(UserThread,"Allocated pti 0x%p for TID:0x%lx\n",
+    TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
              ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
 
     RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
@@ -394,14 +430,14 @@
 } while(0)
 
 /*
-  Called from IntDereferenceThreadInfo.
+ * Called from IntDereferenceThreadInfo
  */
 VOID
 UserDeleteW32Thread(PTHREADINFO pti)
 {
    PPROCESSINFO ppi = pti->ppi;
 
-   TRACE_CH(UserThread,"UserDeleteW32Thread pti 0x%p\n",pti);
+   TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
 
    /* Free the message queue */
    if (pti->MessageQueue)
@@ -414,6 +450,18 @@
    ExFreePoolWithTag(pti, USERTAG_THREADINFO);
 
    IntDereferenceProcessInfo(ppi);
+}
+
+NTSTATUS
+UserThreadCreate(PETHREAD Thread)
+{
+    return STATUS_SUCCESS;
+}
+
+NTSTATUS
+UserThreadDestroy(PETHREAD Thread)
+{
+    return STATUS_SUCCESS;
 }
 
 NTSTATUS NTAPI
@@ -447,6 +495,9 @@
     IntReferenceProcessInfo(ptiCurrent->ppi);
     pTeb->Win32ThreadInfo = ptiCurrent;
     ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
+
+    /* Mark the process as having threads */
+    ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
 
     InitializeListHead(&ptiCurrent->WindowListHead);
     InitializeListHead(&ptiCurrent->W32CallbackListHead);
@@ -468,18 +519,18 @@
                             NULL, SynchronizationEvent, FALSE);
     if (!NT_SUCCESS(Status))
     {
-       ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
-       goto error;
+        ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
+        goto error;
     }
     Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0,
                                        *ExEventObjectType, KernelMode,
                                        (PVOID*)&ptiCurrent->pEventQueueServer, 
NULL);
     if (!NT_SUCCESS(Status))
     {
-       ERR_CH(UserThread, "Failed referencing the event object, Status 
0x%08x.\n", Status);
-       ZwClose(ptiCurrent->hEventQueueClient);
-       ptiCurrent->hEventQueueClient = NULL;
-       goto error;
+        ERR_CH(UserThread, "Failed referencing the event object, Status 
0x%08x.\n", Status);
+        ZwClose(ptiCurrent->hEventQueueClient);
+        ptiCurrent->hEventQueueClient = NULL;
+        goto error;
     }
 
     KeQueryTickCount(&LargeTickCount);
@@ -488,7 +539,7 @@
     ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
     if (ptiCurrent->MessageQueue == NULL)
     {
-        ERR_CH(UserThread,"Failed to allocate message loop\n");
+        ERR_CH(UserThread, "Failed to allocate message loop\n");
         Status = STATUS_NO_MEMORY;
         goto error;
     }
@@ -509,7 +560,7 @@
 
     /* Initialize the CLIENTINFO */
     pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
-    RtlZeroMemory(pci, sizeof(CLIENTINFO));
+    RtlZeroMemory(pci, sizeof(*pci));
     pci->ppi = ptiCurrent->ppi;
     pci->fsHooks = ptiCurrent->fsHooks;
     pci->dwTIFlags = ptiCurrent->TIF_flags;
@@ -562,7 +613,7 @@
         if (!UserSetProcessWindowStation(hWinSta))
         {
             Status = STATUS_UNSUCCESSFUL;
-            ERR_CH(UserThread,"Failed to set initial process winsta\n");
+            ERR_CH(UserThread, "Failed to set initial process winsta\n");
             goto error;
         }
 
@@ -570,7 +621,7 @@
         Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
         if (!NT_SUCCESS(Status))
         {
-            ERR_CH(UserThread,"Failed to validate initial desktop handle\n");
+            ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
             goto error;
         }
 
@@ -583,7 +634,7 @@
     {
         if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
         {
-            ERR_CH(UserThread,"Failed to set thread desktop\n");
+            ERR_CH(UserThread, "Failed to set thread desktop\n");
             Status = STATUS_UNSUCCESSFUL;
             goto error;
         }
@@ -595,7 +646,7 @@
     if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | 
W32PF_APPSTARTING)) &&
          (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
     {
-       ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
+        ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
     }
     ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
 
@@ -603,25 +654,25 @@
     if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
     {
         /* Callback to User32 Client Thread Setup */
-        TRACE_CH(UserThread,"Call co_IntClientThreadSetup...\n");
+        TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
         Status = co_IntClientThreadSetup();
         if (!NT_SUCCESS(Status))
         {
-            ERR_CH(UserThread,"ClientThreadSetup failed with Status 
0x%08lx\n", Status);
+            ERR_CH(UserThread, "ClientThreadSetup failed with Status 
0x%08lx\n", Status);
             goto error;
         }
-        TRACE_CH(UserThread,"co_IntClientThreadSetup succeeded!\n");
+        TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
     }
     else
     {
-        TRACE_CH(UserThread,"co_IntClientThreadSetup cannot be called...\n");
-    }
-
-    TRACE_CH(UserThread,"UserCreateW32Thread pti 0x%p\n", ptiCurrent);
+        TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
+    }
+
+    TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
     return STATUS_SUCCESS;
 
 error:
-    ERR_CH(UserThread,"CreateThreadCallback failed! Freeing pti 0x%p for 
TID:0x%lx\n",
+    ERR_CH(UserThread, "CreateThreadCallback failed! Freeing pti 0x%p for 
TID:0x%lx\n",
            ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
     DestroyThreadCallback(Thread);
     return Status;
@@ -643,7 +694,7 @@
     ptiCurrent = PsGetThreadWin32Thread(Thread);
     ASSERT(ptiCurrent);
 
-    TRACE_CH(UserThread,"Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, 
Thread);
+    TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, 
Thread);
 
     ptiCurrent->TIF_flags |= TIF_INCLEANUP;
     ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
@@ -705,10 +756,10 @@
         if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && 
!ptiCurrent->ptiSibling &&
             ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
         {
-           TRACE_CH(UserThread,"DestroyProcessClasses\n");
-          /* no process windows should exist at this point, or the function 
will assert! */
-           DestroyProcessClasses(ppiCurrent);
-           ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
+            TRACE_CH(UserThread, "DestroyProcessClasses\n");
+            /* no process windows should exist at this point, or the function 
will assert! */
+            DestroyProcessClasses(ppiCurrent);
+            ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
         }
 
         IntBlockInput(ptiCurrent, FALSE);
@@ -719,7 +770,7 @@
         while (psle)
         {
             PUSER_REFERENCE_ENTRY ref = CONTAINING_RECORD(psle, 
USER_REFERENCE_ENTRY, Entry);
-            TRACE_CH(UserThread,"thread clean: remove reference obj 
0x%p\n",ref->obj);
+            TRACE_CH(UserThread, "thread clean: remove reference obj 
0x%p\n",ref->obj);
             UserDereferenceObject(ref->obj);
 
             psle = PopEntryList(&ptiCurrent->ReferencesList);
@@ -757,10 +808,10 @@
           ptiLastInput = gptiForeground;
        else
           ptiLastInput = ppiCurrent->ptiList;
-       ERR_CH(UserThread,"DTI: ptiLastInput is Cleared!!\n");
+       ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
     }
 */
-    TRACE_CH(UserThread,"Freeing pti 0x%p\n", ptiCurrent);
+    TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
 
     IntSetThreadDesktop(NULL, TRUE);
 
@@ -902,14 +953,14 @@
     }
 
     /* Allocate global server info structure */
-    gpsi = UserHeapAlloc(sizeof(SERVERINFO));
+    gpsi = UserHeapAlloc(sizeof(*gpsi));
     if (!gpsi)
     {
         DPRINT1("Failed allocate server info structure!\n");
         return STATUS_UNSUCCESSFUL;
     }
 
-    RtlZeroMemory(gpsi, sizeof(SERVERINFO));
+    RtlZeroMemory(gpsi, sizeof(*gpsi));
     DPRINT("Global Server Data -> %p\n", gpsi);
 
     NT_ROF(InitGdiHandleTable());


Reply via email to