mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 21:25:05 +00:00
[WIN32K]
Split init code into GDI part and USER part. Don't use Eng* functions to initialize the InputIdleEvent. Part 2/x svn path=/trunk/; revision=65861
This commit is contained in:
parent
14cce518d3
commit
3b73052bf8
|
@ -12,6 +12,67 @@
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <kdros.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
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,12 +15,15 @@
|
||||||
|
|
||||||
HANDLE hModuleWin;
|
HANDLE hModuleWin;
|
||||||
|
|
||||||
PGDI_HANDLE_TABLE NTAPI GDIOBJ_iAllocHandleTable(OUT PVOID *SectionObject);
|
|
||||||
BOOL NTAPI GDI_CleanupForProcess (struct _EPROCESS *Process);
|
|
||||||
|
|
||||||
NTSTATUS DestroyProcessCallback(PEPROCESS Process);
|
NTSTATUS DestroyProcessCallback(PEPROCESS Process);
|
||||||
NTSTATUS NTAPI DestroyThreadCallback(PETHREAD Thread);
|
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;
|
HANDLE GlobalUserHeap = NULL;
|
||||||
PVOID GlobalUserHeapSection = NULL;
|
PVOID GlobalUserHeapSection = NULL;
|
||||||
|
|
||||||
|
@ -77,7 +80,7 @@ AllocW32Process(IN PEPROCESS Process,
|
||||||
return STATUS_NO_MEMORY;
|
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));
|
ppiCurrent, HandleToUlong(Process->UniqueProcessId));
|
||||||
|
|
||||||
RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
|
RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
|
||||||
|
@ -104,7 +107,8 @@ UserDeleteW32Process(PPROCESSINFO ppiCurrent)
|
||||||
{
|
{
|
||||||
if (ppiCurrent->InputIdleEvent)
|
if (ppiCurrent->InputIdleEvent)
|
||||||
{
|
{
|
||||||
EngDeleteEvent((PEVENT)ppiCurrent->InputIdleEvent);
|
/* Free the allocated memory */
|
||||||
|
ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the startup desktop */
|
/* Close the startup desktop */
|
||||||
|
@ -123,6 +127,109 @@ UserDeleteW32Process(PPROCESSINFO ppiCurrent)
|
||||||
ExFreePoolWithTag(ppiCurrent, USERTAG_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
|
NTSTATUS
|
||||||
CreateProcessCallback(PEPROCESS Process)
|
CreateProcessCallback(PEPROCESS Process)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +238,6 @@ CreateProcessCallback(PEPROCESS Process)
|
||||||
SIZE_T ViewSize = 0;
|
SIZE_T ViewSize = 0;
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
PVOID UserBase = NULL;
|
PVOID UserBase = NULL;
|
||||||
PRTL_USER_PROCESS_PARAMETERS pParams = Process->Peb->ProcessParameters;
|
|
||||||
|
|
||||||
/* We might be called with an already allocated win32 process */
|
/* We might be called with an already allocated win32 process */
|
||||||
ppiCurrent = PsGetProcessWin32Process(Process);
|
ppiCurrent = PsGetProcessWin32Process(Process);
|
||||||
|
@ -171,7 +277,7 @@ CreateProcessCallback(PEPROCESS Process)
|
||||||
PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */
|
PAGE_EXECUTE_READ); /* would prefer PAGE_READONLY, but thanks to RTL heaps... */
|
||||||
if (!NT_SUCCESS(Status))
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
ppiCurrent->HeapMappings.Next = NULL;
|
ppiCurrent->HeapMappings.Next = NULL;
|
||||||
|
@ -179,50 +285,22 @@ CreateProcessCallback(PEPROCESS Process)
|
||||||
ppiCurrent->HeapMappings.UserMapping = UserBase;
|
ppiCurrent->HeapMappings.UserMapping = UserBase;
|
||||||
ppiCurrent->HeapMappings.Count = 1;
|
ppiCurrent->HeapMappings.Count = 1;
|
||||||
|
|
||||||
InitializeListHead(&ppiCurrent->GDIBrushAttrFreeList);
|
/* Initialize USER process info */
|
||||||
InitializeListHead(&ppiCurrent->GDIDcAttrFreeList);
|
Status = UserProcessCreate(Process);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
InitializeListHead(&ppiCurrent->PrivateFontListHead);
|
|
||||||
ExInitializeFastMutex(&ppiCurrent->PrivateFontListLock);
|
|
||||||
|
|
||||||
InitializeListHead(&ppiCurrent->DriverObjListHead);
|
|
||||||
ExInitializeFastMutex(&ppiCurrent->DriverObjListLock);
|
|
||||||
|
|
||||||
ppiCurrent->KeyboardLayout = W32kGetDefaultKeyLayout();
|
|
||||||
if (!EngCreateEvent((PEVENT *)&ppiCurrent->InputIdleEvent))
|
|
||||||
{
|
{
|
||||||
KeBugCheck(0);
|
ERR_CH(UserProcess, "UserProcessCreate failed, Status 0x%08lx\n", Status);
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
|
/* Initialize GDI process info */
|
||||||
|
Status = GdiProcessCreate(Process);
|
||||||
/* Map the gdi handle table to user land */
|
if (!NT_SUCCESS(Status))
|
||||||
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;
|
ERR_CH(UserProcess, "GdiProcessCreate failed, Status 0x%08lx\n", Status);
|
||||||
ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
/* Add the process to the global list */
|
/* Add the process to the global list */
|
||||||
ppiCurrent->ppiNext = gppiList;
|
ppiCurrent->ppiNext = gppiList;
|
||||||
gppiList = ppiCurrent;
|
gppiList = ppiCurrent;
|
||||||
|
@ -230,7 +308,7 @@ CreateProcessCallback(PEPROCESS Process)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
error:
|
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));
|
ppiCurrent, HandleToUlong(Process->UniqueProcessId));
|
||||||
DestroyProcessCallback(Process);
|
DestroyProcessCallback(Process);
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -244,67 +322,25 @@ DestroyProcessCallback(PEPROCESS Process)
|
||||||
/* Get the Win32 Process */
|
/* Get the Win32 Process */
|
||||||
ppiCurrent = PsGetProcessWin32Process(Process);
|
ppiCurrent = PsGetProcessWin32Process(Process);
|
||||||
ASSERT(ppiCurrent);
|
ASSERT(ppiCurrent);
|
||||||
|
ASSERT(ppiCurrent->peProcess == Process);
|
||||||
|
|
||||||
TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
|
TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
|
||||||
ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
|
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 */
|
/* Remove it from the list */
|
||||||
pppi = &gppiList;
|
pppi = &gppiList;
|
||||||
while (*pppi != NULL && *pppi != ppiCurrent)
|
while (*pppi != NULL && *pppi != ppiCurrent)
|
||||||
|
{
|
||||||
pppi = &(*pppi)->ppiNext;
|
pppi = &(*pppi)->ppiNext;
|
||||||
|
}
|
||||||
ASSERT(*pppi == ppiCurrent);
|
ASSERT(*pppi == ppiCurrent);
|
||||||
|
|
||||||
*pppi = ppiCurrent->ppiNext;
|
*pppi = ppiCurrent->ppiNext;
|
||||||
|
|
||||||
if (ppiCurrent->hdeskStartup)
|
/* Cleanup GDI info */
|
||||||
{
|
GdiProcessDestroy(Process);
|
||||||
ZwClose(ppiCurrent->hdeskStartup);
|
|
||||||
ppiCurrent->hdeskStartup = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NEW_CURSORICON
|
/* Cleanup USER info */
|
||||||
/* Clean up the process icon cache */
|
UserProcessDestroy(Process);
|
||||||
IntCleanupCurIconCache(ppiCurrent);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The process is dying */
|
/* The process is dying */
|
||||||
PsSetProcessWin32Process(Process, NULL, ppiCurrent);
|
PsSetProcessWin32Process(Process, NULL, ppiCurrent);
|
||||||
|
@ -325,7 +361,7 @@ Win32kProcessCallback(PEPROCESS Process,
|
||||||
|
|
||||||
ASSERT(Process->Peb);
|
ASSERT(Process->Peb);
|
||||||
|
|
||||||
TRACE_CH(UserProcess,"Win32kProcessCallback -->\n");
|
TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
|
||||||
|
|
||||||
UserEnterExclusive();
|
UserEnterExclusive();
|
||||||
|
|
||||||
|
@ -340,7 +376,7 @@ Win32kProcessCallback(PEPROCESS Process,
|
||||||
|
|
||||||
UserLeave();
|
UserLeave();
|
||||||
|
|
||||||
TRACE_CH(UserProcess,"<-- Win32kProcessCallback\n");
|
TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -374,7 +410,7 @@ AllocW32Thread(IN PETHREAD Thread,
|
||||||
return STATUS_NO_MEMORY;
|
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));
|
ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
|
||||||
|
|
||||||
RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
|
RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
|
||||||
|
@ -394,14 +430,14 @@ do { \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called from IntDereferenceThreadInfo.
|
* Called from IntDereferenceThreadInfo
|
||||||
*/
|
*/
|
||||||
VOID
|
VOID
|
||||||
UserDeleteW32Thread(PTHREADINFO pti)
|
UserDeleteW32Thread(PTHREADINFO pti)
|
||||||
{
|
{
|
||||||
PPROCESSINFO ppi = pti->ppi;
|
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 */
|
/* Free the message queue */
|
||||||
if (pti->MessageQueue)
|
if (pti->MessageQueue)
|
||||||
|
@ -416,6 +452,18 @@ UserDeleteW32Thread(PTHREADINFO pti)
|
||||||
IntDereferenceProcessInfo(ppi);
|
IntDereferenceProcessInfo(ppi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
UserThreadCreate(PETHREAD Thread)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
UserThreadDestroy(PETHREAD Thread)
|
||||||
|
{
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
CreateThreadCallback(PETHREAD Thread)
|
CreateThreadCallback(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
|
@ -448,6 +496,9 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
pTeb->Win32ThreadInfo = ptiCurrent;
|
pTeb->Win32ThreadInfo = ptiCurrent;
|
||||||
ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
|
ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
|
||||||
|
|
||||||
|
/* Mark the process as having threads */
|
||||||
|
ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
|
||||||
|
|
||||||
InitializeListHead(&ptiCurrent->WindowListHead);
|
InitializeListHead(&ptiCurrent->WindowListHead);
|
||||||
InitializeListHead(&ptiCurrent->W32CallbackListHead);
|
InitializeListHead(&ptiCurrent->W32CallbackListHead);
|
||||||
InitializeListHead(&ptiCurrent->PostedMessagesListHead);
|
InitializeListHead(&ptiCurrent->PostedMessagesListHead);
|
||||||
|
@ -468,18 +519,18 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
NULL, SynchronizationEvent, FALSE);
|
NULL, SynchronizationEvent, FALSE);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
|
ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0,
|
Status = ObReferenceObjectByHandle(ptiCurrent->hEventQueueClient, 0,
|
||||||
*ExEventObjectType, KernelMode,
|
*ExEventObjectType, KernelMode,
|
||||||
(PVOID*)&ptiCurrent->pEventQueueServer, NULL);
|
(PVOID*)&ptiCurrent->pEventQueueServer, NULL);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
|
ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
|
||||||
ZwClose(ptiCurrent->hEventQueueClient);
|
ZwClose(ptiCurrent->hEventQueueClient);
|
||||||
ptiCurrent->hEventQueueClient = NULL;
|
ptiCurrent->hEventQueueClient = NULL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeQueryTickCount(&LargeTickCount);
|
KeQueryTickCount(&LargeTickCount);
|
||||||
|
@ -488,7 +539,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
|
ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
|
||||||
if (ptiCurrent->MessageQueue == NULL)
|
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;
|
Status = STATUS_NO_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -509,7 +560,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
|
|
||||||
/* Initialize the CLIENTINFO */
|
/* Initialize the CLIENTINFO */
|
||||||
pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
|
pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
|
||||||
RtlZeroMemory(pci, sizeof(CLIENTINFO));
|
RtlZeroMemory(pci, sizeof(*pci));
|
||||||
pci->ppi = ptiCurrent->ppi;
|
pci->ppi = ptiCurrent->ppi;
|
||||||
pci->fsHooks = ptiCurrent->fsHooks;
|
pci->fsHooks = ptiCurrent->fsHooks;
|
||||||
pci->dwTIFlags = ptiCurrent->TIF_flags;
|
pci->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
|
@ -562,7 +613,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
if (!UserSetProcessWindowStation(hWinSta))
|
if (!UserSetProcessWindowStation(hWinSta))
|
||||||
{
|
{
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,7 +621,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
|
Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
|
||||||
if (!NT_SUCCESS(Status))
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,7 +634,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
{
|
{
|
||||||
if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
|
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;
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -595,7 +646,7 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
|
if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
|
||||||
(gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
|
(gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
|
||||||
{
|
{
|
||||||
ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
|
ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
|
||||||
}
|
}
|
||||||
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
|
|
||||||
|
@ -603,25 +654,25 @@ CreateThreadCallback(PETHREAD Thread)
|
||||||
if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
|
if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
|
||||||
{
|
{
|
||||||
/* Callback to User32 Client Thread Setup */
|
/* Callback to User32 Client Thread Setup */
|
||||||
TRACE_CH(UserThread,"Call co_IntClientThreadSetup...\n");
|
TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
|
||||||
Status = co_IntClientThreadSetup();
|
Status = co_IntClientThreadSetup();
|
||||||
if (!NT_SUCCESS(Status))
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
TRACE_CH(UserThread,"co_IntClientThreadSetup succeeded!\n");
|
TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TRACE_CH(UserThread,"co_IntClientThreadSetup cannot be called...\n");
|
TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE_CH(UserThread,"UserCreateW32Thread pti 0x%p\n", ptiCurrent);
|
TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
error:
|
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));
|
ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
|
||||||
DestroyThreadCallback(Thread);
|
DestroyThreadCallback(Thread);
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -643,7 +694,7 @@ DestroyThreadCallback(PETHREAD Thread)
|
||||||
ptiCurrent = PsGetThreadWin32Thread(Thread);
|
ptiCurrent = PsGetThreadWin32Thread(Thread);
|
||||||
ASSERT(ptiCurrent);
|
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->TIF_flags |= TIF_INCLEANUP;
|
||||||
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
|
||||||
|
@ -705,10 +756,10 @@ DestroyThreadCallback(PETHREAD Thread)
|
||||||
if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
|
if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
|
||||||
ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
|
ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
|
||||||
{
|
{
|
||||||
TRACE_CH(UserThread,"DestroyProcessClasses\n");
|
TRACE_CH(UserThread, "DestroyProcessClasses\n");
|
||||||
/* no process windows should exist at this point, or the function will assert! */
|
/* no process windows should exist at this point, or the function will assert! */
|
||||||
DestroyProcessClasses(ppiCurrent);
|
DestroyProcessClasses(ppiCurrent);
|
||||||
ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
|
ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntBlockInput(ptiCurrent, FALSE);
|
IntBlockInput(ptiCurrent, FALSE);
|
||||||
|
@ -719,7 +770,7 @@ DestroyThreadCallback(PETHREAD Thread)
|
||||||
while (psle)
|
while (psle)
|
||||||
{
|
{
|
||||||
PUSER_REFERENCE_ENTRY ref = CONTAINING_RECORD(psle, USER_REFERENCE_ENTRY, Entry);
|
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);
|
UserDereferenceObject(ref->obj);
|
||||||
|
|
||||||
psle = PopEntryList(&ptiCurrent->ReferencesList);
|
psle = PopEntryList(&ptiCurrent->ReferencesList);
|
||||||
|
@ -757,10 +808,10 @@ DestroyThreadCallback(PETHREAD Thread)
|
||||||
ptiLastInput = gptiForeground;
|
ptiLastInput = gptiForeground;
|
||||||
else
|
else
|
||||||
ptiLastInput = ppiCurrent->ptiList;
|
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);
|
IntSetThreadDesktop(NULL, TRUE);
|
||||||
|
|
||||||
|
@ -902,14 +953,14 @@ DriverEntry(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate global server info structure */
|
/* Allocate global server info structure */
|
||||||
gpsi = UserHeapAlloc(sizeof(SERVERINFO));
|
gpsi = UserHeapAlloc(sizeof(*gpsi));
|
||||||
if (!gpsi)
|
if (!gpsi)
|
||||||
{
|
{
|
||||||
DPRINT1("Failed allocate server info structure!\n");
|
DPRINT1("Failed allocate server info structure!\n");
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(gpsi, sizeof(SERVERINFO));
|
RtlZeroMemory(gpsi, sizeof(*gpsi));
|
||||||
DPRINT("Global Server Data -> %p\n", gpsi);
|
DPRINT("Global Server Data -> %p\n", gpsi);
|
||||||
|
|
||||||
NT_ROF(InitGdiHandleTable());
|
NT_ROF(InitGdiHandleTable());
|
||||||
|
|
Loading…
Reference in a new issue