41 GdiDbgPreServiceHook(ulSyscallId, pulArguments);
49 ulResult = GdiDbgPostServiceHook(ulSyscallId, ulResult);
72 if (ppiCurrent ==
NULL)
74 ERR_CH(UserProcess,
"Failed to allocate ppi for PID:0x%lx\n",
79 TRACE_CH(UserProcess,
"Allocated ppi 0x%p for PID:0x%lx\n",
87 *W32Process = ppiCurrent;
98 if (ppiCurrent->InputIdleEvent)
105 if (ppiCurrent->rpdeskStartup)
111 TRACE_PPI(ppiCurrent, UserObj,
"Dumping user handles now that process info %p is gets freed.\n", ppiCurrent);
146 DPRINT(
"CreateEvent() failed\n");
151 ppiCurrent->InputIdleEvent =
Event;
155 ppiCurrent->peProcess =
Process;
160 if (
Process->Peb->ProcessParameters &&
193 TRACE_CH(UserProcess,
"Freeing ppi 0x%p\n", ppiCurrent);
197 TRACE_CH(UserObj,
"Dumping user handles at the end of the process %s (Info %p).\n",
198 ppiCurrent->peProcess->ImageFileName, ppiCurrent);
209 if (
gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
238 if (ppiCurrent !=
NULL)
250 ERR_CH(UserProcess,
"Failed to allocate ppi for PID:0x%lx\n",
266 TRACE_CH(UserProcess,
"Failed to map the global heap! 0x%x\n",
Status);
270 TRACE_CH(UserProcess,
"InitProcessCallback -- We have KernelMapping 0x%p and UserMapping 0x%p with delta = 0x%x\n",
277 ERR_CH(UserProcess,
"UserProcessCreate failed, Status 0x%08lx\n",
Status);
285 ERR_CH(UserProcess,
"GdiProcessCreate failed, Status 0x%08lx\n",
Status);
296 ERR_CH(UserProcess,
"InitProcessCallback failed! Freeing ppi 0x%p for PID:0x%lx\n",
312 TRACE_CH(UserProcess,
"Destroying ppi 0x%p\n", ppiCurrent);
317 while (*pppi !=
NULL && *pppi != ppiCurrent)
321 ASSERT(*pppi == ppiCurrent);
332 ppiCurrent->peProcess =
NULL;
349 TRACE_CH(UserProcess,
"Win32kProcessCallback -->\n");
364 TRACE_CH(UserProcess,
"<-- Win32kProcessCallback\n");
387 if (ptiCurrent ==
NULL)
389 ERR_CH(UserThread,
"Failed to allocate pti for TID:0x%lx\n",
394 TRACE_CH(UserThread,
"Allocated pti 0x%p for TID:0x%lx\n",
403 *W32Thread = ptiCurrent;
415 TRACE_CH(UserThread,
"UserDeleteW32Thread pti 0x%p\n",pti);
477 ERR_CH(UserThread,
"Failed to allocate pti for TID:0x%lx\n",
483 ptiCurrent->pEThread =
Thread;
488 ptiCurrent->
pcti = &ptiCurrent->
cti;
511 ERR_CH(UserThread,
"Event creation failed, Status 0x%08x.\n",
Status);
519 ERR_CH(UserThread,
"Failed referencing the event object, Status 0x%08x.\n",
Status);
530 ERR_CH(UserThread,
"Failed to allocate message loop\n");
549 pci->
ppi = ptiCurrent->
ppi;
592 HWINSTA hWinSta =
NULL;
622 ERR_CH(UserThread,
"Failed to assign default desktop and winsta to process\n");
629 ERR_CH(UserThread,
"Failed to set initial process winsta\n");
637 ERR_CH(UserThread,
"Failed to validate initial desktop handle\n");
652 ERR_CH(UserThread,
"Failed to set thread desktop\n");
678 TRACE_CH(UserThread,
"Call co_IntClientThreadSetup...\n");
682 ERR_CH(UserThread,
"ClientThreadSetup failed with Status 0x%08lx\n",
Status);
685 TRACE_CH(UserThread,
"co_IntClientThreadSetup succeeded!\n");
689 TRACE_CH(UserThread,
"co_IntClientThreadSetup cannot be called...\n");
692 TRACE_CH(UserThread,
"UserCreateW32Thread pti 0x%p\n", ptiCurrent);
696 ERR_CH(UserThread,
"InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
723 TRACE_CH(UserThread,
"Destroying pti 0x%p eThread 0x%p\n", ptiCurrent,
Thread);
728 ppiCurrent = ptiCurrent->
ppi;
735 for (pwl =
gpwlList; pwl; pwl = pwlNext)
738 if (pwl->
pti == ptiCurrent)
766 if (ptiCurrent->
pDeskInfo->ppiShellProcess == ppiCurrent)
770 TRACE_CH(UserProcess,
"Shell process is exiting (%lu)\n", ExitCode);
789 DPRINT1(
"Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
795 if (ppiCurrent && ppiCurrent->
ptiList == ptiCurrent && !ptiCurrent->
ptiSibling &&
798 TRACE_CH(UserThread,
"DestroyProcessClasses\n");
801 ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
812 TRACE_CH(UserThread,
"thread clean: remove reference obj 0x%p\n",
ref->obj);
827 while (*ppti !=
NULL && *ppti != ptiCurrent)
829 ppti = &((*ppti)->ptiSibling);
833 ASSERT(*ppti == ptiCurrent);
864 TRACE_CH(UserThread,
"Freeing pti 0x%p\n", ptiCurrent);
927 if (!NT_SUCCESS(Status)) \
929 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
935#define USERLOCK_AND_ROF(x) \
937 UserEnterExclusive(); \
940 if (!NT_SUCCESS(Status)) \
942 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
975 DPRINT1(
"Adding system services failed!\n");
1006#if DBG && defined(KDBG)
1013 &GlobalUserHeapBase,
1017 DPRINT1(
"Failed to initialize the global heap!\n");
1032 DPRINT1(
"Failed allocate server info structure!\n");
#define ERR_CH(ch, fmt,...)
#define TRACE_CH(ch, fmt,...)
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
VOID ResetCsrProcess(VOID)
VOID ResetCsrApiPort(VOID)
void FASTCALL DceFreeThreadDCE(PTHREADINFO)
NTSTATUS NTAPI InitDcImpl(VOID)
#define NT_SUCCESS(StatCode)
DRIVER_INITIALIZE DriverEntry
#define __drv_freesMem(kind)
#define EngGetTickCount32()
NTSTATUS NTAPI InitBrushImpl(VOID)
#define ExAllocatePoolWithTag(hernya, size, tag)
NTSTATUS ExInitializeResourceLite(PULONG res)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define InitializeListHead(ListHead)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
VOID FASTCALL FreeFontSupport(VOID)
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
BOOLEAN NTAPI DbgGdiKdbgCliCallback(IN PCHAR pszCommand, IN ULONG argc, IN PCH argv[])
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
BOOL FASTCALL co_IntGraphicsCheck(BOOL Create)
enum _PSW32THREADCALLOUTTYPE PSW32THREADCALLOUTTYPE
@ PsW32ThreadCalloutInitialize
#define TIF_DONTATTACHQUEUE
#define TIF_GUITHREADINITIALIZED
ULONG RtlGetExpWinVer(_In_ PVOID BaseAddress)
struct _CLIENTINFO * PCLIENTINFO
#define TIF_ALLOWFOREGROUNDACTIVATE
VOID FASTCALL CreateStockObjects(VOID)
VOID FASTCALL CreateSysColorObjects(VOID)
static DRIVER_UNLOAD DriverUnload
NTSTATUS NTAPI KdSystemDebugControl(_In_ SYSDBG_COMMAND Command, _In_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Inout_ PULONG ReturnLength, _In_ KPROCESSOR_MODE PreviousMode)
NTSTATUS NTAPI InitLDEVImpl(VOID)
#define ExFreePoolWithTag(_P, _T)
#define _Function_class_(x)
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
NTSTATUS NTAPI MsqInitializeImpl(VOID)
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
POBJECT_TYPE ExEventObjectType
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
NTSTATUS NTAPI PsSetProcessWin32Process(_Inout_ PEPROCESS Process, _In_opt_ PVOID Win32Process, _In_opt_ PVOID OldWin32Process)
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
PVOID NTAPI PsSetThreadWin32Thread(_Inout_ PETHREAD Thread, _In_ PVOID Win32Thread, _In_ PVOID OldWin32Thread)
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
VOID NTAPI PsEstablishWin32Callouts(IN PWIN32_CALLOUTS_FPNS CalloutData)
#define STATUS_ALREADY_WIN32
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
PPROCESSINFO ppiUahServer
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
PWINSTATION_OBJECT InputWindowStation
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
NTSTATUS NTAPI InitWindowStationImpl(VOID)
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
PPROCESSINFO gppiInputProvider
NTSTATUS NTAPI InitUserImpl(VOID)
VOID FASTCALL UserLeave(VOID)
VOID FASTCALL UserEnterExclusive(VOID)
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
void DbgUserDumpHandleTable()
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
NTSTATUS NTAPI InitPDEVImpl(VOID)
BOOLEAN NTAPI KeAddSystemServiceTable(IN PULONG_PTR Base, IN PULONG Count OPTIONAL, IN ULONG Limit, IN PUCHAR Number, IN ULONG Index)
static GENERIC_MAPPING UserMapping
base of all file and directory entries
struct _PROCESSINFO * ppi
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
LIST_ENTRY DriverObjListHead
struct _DESKTOP * rpdeskStartup
FAST_MUTEX DriverObjListLock
UNICODE_STRING DesktopInfo
ULONG Win32ClientInfo[31]
PPEB ProcessEnvironmentBlock
struct _DESKTOPINFO * pDeskInfo
LIST_ENTRY PostedMessagesListHead
struct _CLIENTINFO * pClientInfo
PKEVENT pEventQueueServer
LIST_ENTRY W32CallbackListHead
struct tagIMC * spDefaultImc
struct tagKL * KeyboardLayout
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
struct _CLIENTTHREADINFO * pcti
SINGLE_LIST_ENTRY ReferencesList
LIST_ENTRY SentMessagesListHead
LIST_ENTRY WindowListHead
struct _USER_MESSAGE_QUEUE * MessageQueue
PKWIN32_POWEREVENT_CALLOUT PowerEventCallout
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
PKWIN32_PROCESS_CALLOUT ProcessCallout
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
PKWIN32_POWERSTATE_CALLOUT PowerStateCallout
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
PKWIN32_THREAD_CALLOUT ThreadCallout
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
struct tagWINDOWLIST * pNextList
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
TW_UINT32 TW_UINT16 TW_UINT16 MSG
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_UNSUCCESSFUL
#define STARTF_SCREENSAVER
#define STARTF_INHERITDESKTOP
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
PVOID GlobalUserHeapSection
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
#define IntDereferenceThreadInfo(pti)
#define W32PF_APPSTARTING
#define IntReferenceProcessInfo(ppi)
#define W32PF_ALLOWFOREGROUNDACTIVATE
#define IntReferenceThreadInfo(pti)
#define IntDereferenceProcessInfo(ppi)
struct tagUSERSTARTUPINFO USERSTARTUPINFO
#define W32PF_CLASSESREGISTERED
#define W32PF_SCREENSAVER
#define W32PF_PROCESSCONNECTED
#define W32PF_THREADCONNECTED
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
BOOL DbgInitDebugChannels()
#define TRACE_PPI(ppi, ch, fmt,...)
NTSTATUS NTAPI InitDeviceImpl(VOID)
NTSTATUS NTAPI InitGdiHandleTable(void)
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
NTSTATUS NTAPI InitPaletteImpl(VOID)
VOID FASTCALL IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID)
void FASTCALL DestroyProcessClasses(PPROCESSINFO Process)
BOOL NTAPI UserCloseClipboard(VOID)
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
NTSTATUS NTAPI InitDesktopImpl(VOID)
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
PTHREADINFO gptiForeground
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
VOID FASTCALL IntFreeImeHotKeys(VOID)
PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
NTSTATUS NTAPI InitKeyboardImpl(VOID)
ULONG Win32kNumberOfSysCalls
NTSTATUS ExitProcessCallback(PEPROCESS Process)
VOID UserDeleteW32Thread(PTHREADINFO pti)
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
#define USERLOCK_AND_ROF(x)
NTSTATUS UserThreadCreate(PETHREAD Thread)
NTSTATUS InitProcessCallback(PEPROCESS Process)
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
NTSTATUS UserThreadDestroy(PETHREAD Thread)
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
NTSTATUS GdiThreadDestroy(PETHREAD Thread)
PPROCESSINFO ppiScrnSaver
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
NTSTATUS GdiProcessCreate(PEPROCESS Process)
NTSTATUS GdiThreadCreate(PETHREAD Thread)
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
NTSTATUS UserProcessDestroy(PEPROCESS Process)
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
NTSTATUS UserProcessCreate(PEPROCESS Process)
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
BOOL FASTCALL UserDereferenceObject(PVOID Object)
PUSER_HANDLE_TABLE gHandleTable
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
NTSTATUS NTAPI IntWin32PowerManagementCleanup(VOID)
Cleanup procedure that frees all the allocated resources by the power manager. It is triggered during...
NTSTATUS NTAPI IntHandlePowerState(_In_ PWIN32_POWERSTATE_PARAMETERS pWin32PwrStateParams)
Handles an incoming power state callout from the NT power manager.
NTSTATUS NTAPI IntHandlePowerEvent(_In_ PWIN32_POWEREVENT_PARAMETERS pWin32PwrEventParams)
Handles an incoming power event callout from the NT power manager.
NTSTATUS NTAPI InitTimerImpl(VOID)
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
NTSTATUS NTAPI InitDCEImpl(VOID)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
#define ObDereferenceObject
#define ObReferenceObject
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)