ReactOS  0.4.12-dev-919-gfc3b8d5
main.c File Reference
#include <win32k.h>
#include <napi.h>
#include <debug.h>
#include <kdros.h>
Include dependency graph for main.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NT_ROF(x)
 

Functions

NTSTATUS ExitProcessCallback (PEPROCESS Process)
 
NTSTATUS NTAPI ExitThreadCallback (PETHREAD Thread)
 
NTSTATUS GdiProcessCreate (PEPROCESS Process)
 
NTSTATUS GdiProcessDestroy (PEPROCESS Process)
 
NTSTATUS GdiThreadCreate (PETHREAD Thread)
 
NTSTATUS GdiThreadDestroy (PETHREAD Thread)
 
NTSTATUS AllocW32Process (IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
 
VOID UserDeleteW32Process (_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
 
NTSTATUS UserProcessCreate (PEPROCESS Process)
 
NTSTATUS UserProcessDestroy (PEPROCESS Process)
 
NTSTATUS InitProcessCallback (PEPROCESS Process)
 
NTSTATUS APIENTRY Win32kProcessCallback (PEPROCESS Process, BOOLEAN Initialize)
 
NTSTATUS AllocW32Thread (IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
 
VOID UserDeleteW32Thread (PTHREADINFO pti)
 
NTSTATUS UserThreadCreate (PETHREAD Thread)
 
NTSTATUS UserThreadDestroy (PETHREAD Thread)
 
NTSTATUS NTAPI InitThreadCallback (PETHREAD Thread)
 
VOID UserDisplayNotifyShutdown (PPROCESSINFO ppiCurrent)
 
NTSTATUS APIENTRY Win32kThreadCallback (PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
 
 _Function_class_ (DRIVER_UNLOAD)
 
INIT_FUNCTION NTSTATUS APIENTRY DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

HANDLE hModuleWin
 
PSERVERINFO gpsi = NULL
 
SHORT gusLanguageID
 
PPROCESSINFO ppiScrnSaver
 
PPROCESSINFO gppiList = NULL
 
ULONG_PTR Win32kSSDT []
 
UCHAR Win32kSSPT []
 
ULONG Win32kNumberOfSysCalls
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file main.c.

◆ NT_ROF

#define NT_ROF (   x)
Value:
{ \
Status = (x); \
if (!NT_SUCCESS(Status)) \
{ \
DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
return Status; \
} \
}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24

Definition at line 882 of file main.c.

Function Documentation

◆ _Function_class_()

_Function_class_ ( DRIVER_UNLOAD  )

Definition at line 871 of file main.c.

874 {
875  // TODO: Do more cleanup!
876 
877  ResetCsrApiPort();
878  ResetCsrProcess();
879 }
VOID ResetCsrProcess(VOID)
Definition: csr.c:29
VOID ResetCsrApiPort(VOID)
Definition: csr.c:58

◆ AllocW32Process()

NTSTATUS AllocW32Process ( IN PEPROCESS  Process,
OUT PPROCESSINFO W32Process 
)

Definition at line 58 of file main.c.

60 {
61  PPROCESSINFO ppiCurrent;
62 
63  TRACE_CH(UserProcess, "In AllocW32Process(0x%p)\n", Process);
64 
65  /* Check that we were not called with an already existing Win32 process info */
66  ppiCurrent = PsGetProcessWin32Process(Process);
67  if (ppiCurrent) return STATUS_SUCCESS;
68 
69  /* Allocate a new Win32 process info */
71  sizeof(*ppiCurrent),
73  if (ppiCurrent == NULL)
74  {
75  ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
76  HandleToUlong(Process->UniqueProcessId));
77  return STATUS_NO_MEMORY;
78  }
79 
80  TRACE_CH(UserProcess, "Allocated ppi 0x%p for PID:0x%lx\n",
81  ppiCurrent, HandleToUlong(Process->UniqueProcessId));
82 
83  RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
84 
86  IntReferenceProcessInfo(ppiCurrent);
87 
88  *W32Process = ppiCurrent;
89  return STATUS_SUCCESS;
90 }
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
#define HandleToUlong(h)
Definition: basetsd.h:79
#define USERTAG_PROCESSINFO
Definition: tags.h:259
NTSTATUS NTAPI PsSetProcessWin32Process(_Inout_ PEPROCESS Process, _In_opt_ PVOID Win32Process, _In_opt_ PVOID OldWin32Process)
Definition: process.c:1257
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:177
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define ERR_CH(ch, fmt,...)
Definition: debug.h:104
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by InitProcessCallback().

◆ AllocW32Thread()

NTSTATUS AllocW32Thread ( IN PETHREAD  Thread,
OUT PTHREADINFO W32Thread 
)

Definition at line 365 of file main.c.

367 {
368  PTHREADINFO ptiCurrent;
369 
370  TRACE_CH(UserThread, "In AllocW32Thread(0x%p)\n", Thread);
371 
372  /* Check that we were not called with an already existing Win32 thread info */
373  ptiCurrent = PsGetThreadWin32Thread(Thread);
374  NT_ASSERT(ptiCurrent == NULL);
375 
376  /* Allocate a new Win32 thread info */
377  ptiCurrent = ExAllocatePoolWithTag(NonPagedPool,
378  sizeof(*ptiCurrent),
380  if (ptiCurrent == NULL)
381  {
382  ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
384  return STATUS_NO_MEMORY;
385  }
386 
387  TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
388  ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
389 
390  RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
391 
392  PsSetThreadWin32Thread(Thread, ptiCurrent, NULL);
394  IntReferenceThreadInfo(ptiCurrent);
395 
396  *W32Thread = ptiCurrent;
397  return STATUS_SUCCESS;
398 }
PVOID NTAPI PsSetThreadWin32Thread(_Inout_ PETHREAD Thread, _In_ PVOID Win32Thread, _In_ PVOID OldWin32Thread)
Definition: thread.c:909
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
Definition: thread.c:795
#define HandleToUlong(h)
Definition: basetsd.h:79
#define USERTAG_THREADINFO
Definition: tags.h:283
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceThreadInfo(pti)
Definition: win32.h:162
CLIENT_ID Cid
Definition: pstypes.h:1059
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
HANDLE UniqueThread
Definition: compat.h:475
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define ERR_CH(ch, fmt,...)
Definition: debug.h:104
#define ObReferenceObject
Definition: obfuncs.h:204
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define NT_ASSERT
Definition: rtlfuncs.h:3312

Referenced by InitThreadCallback().

◆ DriverEntry()

INIT_FUNCTION NTSTATUS APIENTRY DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 898 of file main.c.

901 {
903  BOOLEAN Result;
904  WIN32_CALLOUTS_FPNS CalloutData = {0};
905  PVOID GlobalUserHeapBase = NULL;
906 
907  /*
908  * Register user mode call interface
909  * (system service table index = 1)
910  */
912  NULL,
914  Win32kSSPT,
915  1);
916  if (Result == FALSE)
917  {
918  DPRINT1("Adding system services failed!\n");
919  return STATUS_UNSUCCESSFUL;
920  }
921 
923  DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
924 
926 
927  /* Register Object Manager Callbacks */
929  CalloutData.ThreadCallout = Win32kThreadCallback;
930  // CalloutData.GlobalAtomTableCallout = NULL;
931  // CalloutData.PowerEventCallout = NULL;
932  // CalloutData.PowerStateCallout = NULL;
933  // CalloutData.JobCallout = NULL;
940  // CalloutData.WindowStationCloseProcedure = NULL;
943  // CalloutData.WindowStationOpenProcedure = NULL;
944 
945  /* Register our per-process and per-thread structures. */
946  PsEstablishWin32Callouts(&CalloutData);
947 
948  /* Register service hook callbacks */
949 #if DBG && defined(KDBG)
950  KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
951  KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
952 #endif
953 
954  /* Create the global USER heap */
956  &GlobalUserHeapBase,
957  1 * 1024 * 1024); /* FIXME: 1 MB for now... */
958  if (GlobalUserHeap == NULL)
959  {
960  DPRINT1("Failed to initialize the global heap!\n");
961  return STATUS_UNSUCCESSFUL;
962  }
963 
964  /* Allocate global server info structure */
965  gpsi = UserHeapAlloc(sizeof(*gpsi));
966  if (!gpsi)
967  {
968  DPRINT1("Failed allocate server info structure!\n");
969  return STATUS_UNSUCCESSFUL;
970  }
971 
972  RtlZeroMemory(gpsi, sizeof(*gpsi));
973  DPRINT("Global Server Data -> %p\n", gpsi);
974 
977 
978  /* Create stock objects, ie. precreated objects commonly
979  used by win32 applications */
982 
984  NT_ROF(InitPDEVImpl());
985  NT_ROF(InitLDEVImpl());
987  NT_ROF(InitDcImpl());
988  NT_ROF(InitUserImpl());
995  NT_ROF(InitDCEImpl());
996 
998 
999  /* Initialize FreeType library */
1000  if (!InitFontSupport())
1001  {
1002  DPRINT1("Unable to initialize font support\n");
1003  return Status;
1004  }
1005 
1006  return STATUS_SUCCESS;
1007 }
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:846
INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl(VOID)
Definition: keyboard.c:31
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:202
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1625
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1620
INIT_FUNCTION NTSTATUS NTAPI InitGdiHandleTable(void)
Definition: gdiobj.c:257
BOOLEAN NTAPI KeAddSystemServiceTable(IN PULONG_PTR Base, IN PULONG Count OPTIONAL, IN ULONG Limit, IN PUCHAR Number, IN ULONG Index)
Definition: procobj.c:905
LONG NTSTATUS
Definition: precomp.h:26
#define NT_ROF(x)
Definition: main.c:882
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
Definition: desktop.c:178
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1615
ULONG Win32kNumberOfSysCalls
Definition: napi.h:22
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
Definition: gdibatch.c:445
PSERVERINFO gpsi
Definition: main.c:27
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1623
INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:63
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
Definition: winsta.c:136
INIT_FUNCTION NTSTATUS NTAPI InitBrushImpl(VOID)
Definition: engbrush.c:31
BOOL FASTCALL InitFontSupport(VOID)
Definition: freetype.c:615
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1627
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
INIT_FUNCTION NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
VOID FASTCALL CreateStockObjects(VOID)
Definition: stockobj.c:247
INIT_FUNCTION NTSTATUS NTAPI InitWindowStationImpl(VOID)
Definition: winsta.c:34
INIT_FUNCTION NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:77
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
Definition: winsta.c:106
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_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
Definition: wsk.h:426
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
void DPRINT(...)
Definition: polytest.cpp:61
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1622
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:335
INIT_FUNCTION NTSTATUS NTAPI MsqInitializeImpl(VOID)
Definition: msgqueue.c:30
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1624
INIT_FUNCTION NTSTATUS NTAPI InitDcImpl(VOID)
Definition: dclife.c:53
NTSTATUS NTAPI KdSystemDebugControl(IN SYSDBG_COMMAND Command, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
Definition: kdmain.c:489
SHORT gusLanguageID
Definition: main.c:29
INIT_FUNCTION NTSTATUS NTAPI InitLDEVImpl(VOID)
Definition: ldevobj.c:30
INIT_FUNCTION NTSTATUS NTAPI InitDeviceImpl(VOID)
Definition: device.c:24
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3320
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
INIT_FUNCTION NTSTATUS NTAPI InitPDEVImpl(VOID)
Definition: pdevobj.c:21
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1621
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
Definition: winsta.c:201
PVOID GlobalUserHeapSection
Definition: usrheap.c:26
Status
Definition: gdiplustypes.h:24
ULONG_PTR Win32kSSDT[]
Definition: napi.h:9
SHORT FASTCALL UserGetLanguageID(VOID)
Definition: misc.c:96
UCHAR Win32kSSPT[]
Definition: napi.h:15
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition: main.c:690
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:147
static DRIVER_UNLOAD DriverUnload
Definition: kbdclass.c:17
HANDLE GlobalUserHeap
Definition: usrheap.c:25
HANDLE hModuleWin
Definition: main.c:16
INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID)
Definition: input.c:364
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:215
VOID NTAPI PsEstablishWin32Callouts(IN PWIN32_CALLOUTS_FPNS CalloutData)
Definition: win32.c:112
INIT_FUNCTION NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:236
INIT_FUNCTION NTSTATUS NTAPI InitTimerImpl(VOID)
Definition: timer.c:598
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:177
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1628
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1614
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ ExitProcessCallback()

NTSTATUS ExitProcessCallback ( PEPROCESS  Process)

Definition at line 296 of file main.c.

297 {
298  PPROCESSINFO ppiCurrent, *pppi;
299 
300  /* Get the Win32 Process */
301  ppiCurrent = PsGetProcessWin32Process(Process);
302  ASSERT(ppiCurrent);
303  ASSERT(ppiCurrent->peProcess == Process);
304 
305  TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
306  ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
307 
308  /* Remove it from the list */
309  pppi = &gppiList;
310  while (*pppi != NULL && *pppi != ppiCurrent)
311  {
312  pppi = &(*pppi)->ppiNext;
313  }
314  ASSERT(*pppi == ppiCurrent);
315  *pppi = ppiCurrent->ppiNext;
316 
317  /* Cleanup GDI info */
319 
320  /* Cleanup USER info */
322 
323  /* The process is dying */
324  PsSetProcessWin32Process(Process, NULL, ppiCurrent);
325  ppiCurrent->peProcess = NULL;
326 
327  /* Finally, dereference */
328  IntDereferenceProcessInfo(ppiCurrent);
329 
330  return STATUS_SUCCESS;
331 }
PPROCESSINFO ppiNext
Definition: win32.h:252
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
NTSTATUS NTAPI PsSetProcessWin32Process(_Inout_ PEPROCESS Process, _In_opt_ PVOID Win32Process, _In_opt_ PVOID OldWin32Process)
Definition: process.c:1257
#define W32PF_TERMINATED
Definition: win32.h:16
PPROCESSINFO gppiList
Definition: main.c:31
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:47
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:175
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:182

Referenced by InitProcessCallback(), and Win32kProcessCallback().

◆ ExitThreadCallback()

NTSTATUS NTAPI ExitThreadCallback ( PETHREAD  Thread)

Definition at line 680 of file main.c.

681 {
682  PTHREADINFO *ppti;
683  PSINGLE_LIST_ENTRY psle;
684  PPROCESSINFO ppiCurrent;
686  PTHREADINFO ptiCurrent;
687 
688  Process = Thread->ThreadsProcess;
689 
690  /* Get the Win32 Thread */
691  ptiCurrent = PsGetThreadWin32Thread(Thread);
692  ASSERT(ptiCurrent);
693 
694  TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
695 
696  ptiCurrent->TIF_flags |= TIF_INCLEANUP;
697  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
698 
699  ppiCurrent = ptiCurrent->ppi;
700  ASSERT(ppiCurrent);
701 
702  IsRemoveAttachThread(ptiCurrent);
703 
704  ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
705  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
706 
708 
709  /* Decrement thread count and check if its 0 */
710  ppiCurrent->cThreads--;
711 
712  if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
713  {
714  /* Do now some process cleanup that requires a valid win32 thread */
715  if (ptiCurrent->ppi->cThreads == 0)
716  {
717  /* Check if we have registered the user api hook */
718  if (ptiCurrent->ppi == ppiUahServer)
719  {
720  /* Unregister the api hook */
722  }
723 
724  /* Notify logon application to restart shell if needed */
725  if (ptiCurrent->pDeskInfo)
726  {
727  if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
728  {
730 
731  TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
732 
736  ExitCode);
737 
738  ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
739  }
740  }
741  }
742 
743  DceFreeThreadDCE(ptiCurrent);
744  DestroyTimersForThread(ptiCurrent);
746  UnregisterThreadHotKeys(ptiCurrent);
747 
748  if (!UserDestroyObjectsForOwner(gHandleTable, ptiCurrent))
749  {
750  DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
751  ASSERT(FALSE);
752  return STATUS_UNSUCCESSFUL;
753  }
754 
755  if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
756  ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
757  {
758  TRACE_CH(UserThread, "DestroyProcessClasses\n");
759  /* no process windows should exist at this point, or the function will assert! */
760  DestroyProcessClasses(ppiCurrent);
761  ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
762  }
763 
764  IntBlockInput(ptiCurrent, FALSE);
765  IntCleanupThreadCallbacks(ptiCurrent);
766 
767  /* cleanup user object references stack */
768  psle = PopEntryList(&ptiCurrent->ReferencesList);
769  while (psle)
770  {
772  TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
774 
775  psle = PopEntryList(&ptiCurrent->ReferencesList);
776  }
777  }
778 
779  if (ptiCurrent->cEnterCount)
780  {
782  ptiCurrent->cEnterCount = 0;
783  }
784 
785  /* Find the THREADINFO in the PROCESSINFO's list */
786  ppti = &ppiCurrent->ptiList;
787  while (*ppti != NULL && *ppti != ptiCurrent)
788  {
789  ppti = &((*ppti)->ptiSibling);
790  }
791 
792  /* we must have found it */
793  ASSERT(*ppti == ptiCurrent);
794 
795  /* Remove it from the list */
796  *ppti = ptiCurrent->ptiSibling;
797 
798  if (ptiCurrent->KeyboardLayout)
800 
801  if (gptiForeground == ptiCurrent)
802  {
803 // IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
804 // IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
805 
807  }
808 
809  /* Restore display mode when we are the last thread, and we changed the display mode */
810  if (ppiCurrent->cThreads == 0)
811  UserDisplayNotifyShutdown(ppiCurrent);
812 
813 
814  // Fixes CORE-6384 & CORE-7030.
815 /* if (ptiLastInput == ptiCurrent)
816  {
817  if (!ppiCurrent->ptiList)
818  ptiLastInput = gptiForeground;
819  else
820  ptiLastInput = ppiCurrent->ptiList;
821  ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
822  }
823 */
824  TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
825 
827 
828  if (ptiCurrent->hEventQueueClient != NULL)
829  {
832  }
833  ptiCurrent->hEventQueueClient = NULL;
834 
835  /* The thread is dying */
836  PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
837 
838  /* Dereference the THREADINFO */
839  IntDereferenceThreadInfo(ptiCurrent);
840 
841  return STATUS_SUCCESS;
842 }
PVOID NTAPI PsSetThreadWin32Thread(_Inout_ PETHREAD Thread, _In_ PVOID Win32Thread, _In_ PVOID OldWin32Thread)
Definition: thread.c:909
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
Definition: thread.c:795
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
#define TRUE
Definition: types.h:120
void FASTCALL DestroyProcessClasses(PPROCESSINFO Process)
Definition: class.c:300
Definition: ntbasedef.h:635
PTHREADINFO ptiSibling
Definition: win32.h:115
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:246
FLONG TIF_flags
Definition: win32.h:94
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
Definition: timer.c:553
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
Definition: send.c:47
PPROCESSINFO ppi
Definition: win32.h:87
PTHREADINFO gptiForeground
Definition: focus.c:14
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
Definition: process.c:1053
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:527
void FASTCALL DceFreeThreadDCE(PTHREADINFO)
Definition: windc.c:779
Definition: object.h:3
smooth NULL
Definition: ftsmooth.c:416
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:264
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
INT cThreads
Definition: win32.h:253
HWND hwndSAS
Definition: winsta.c:24
PKEVENT pEventQueueServer
Definition: win32.h:124
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
PPROCESSINFO ppiUahServer
Definition: hook.c:25
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:379
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
struct tagKL * KeyboardLayout
Definition: win32.h:89
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:121
HANDLE hEventQueueClient
Definition: win32.h:122
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define W32PF_CLASSESREGISTERED
Definition: win32.h:17
VOID FASTCALL IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
Definition: callback.c:75
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3181
#define DPRINT1
Definition: precomp.h:8
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:720
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:151
#define IO_NO_INCREMENT
Definition: iotypes.h:565
PTHREADINFO ptiList
Definition: win32.h:247
BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO pti)
Definition: input.c:441
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
return STATUS_SUCCESS
Definition: btrfs.c:2725
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define IntDereferenceThreadInfo(pti)
Definition: win32.h:167
INT cEnterCount
Definition: win32.h:129
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:887
#define TIF_INCLEANUP
Definition: ntuser.h:240
base of all file and directory entries
Definition: entries.h:82
#define LN_SHELL_EXITED
Definition: undocuser.h:114
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
Definition: hook.c:207

Referenced by InitThreadCallback(), and Win32kThreadCallback().

◆ GdiProcessCreate()

NTSTATUS GdiProcessCreate ( PEPROCESS  Process)

Definition at line 18 of file init.c.

19 {
21  ASSERT(ppiCurrent);
22 
25  ppiCurrent->PrivateMemFontHandleCount = 0;
27 
28  InitializeListHead(&ppiCurrent->GDIBrushAttrFreeList);
29  InitializeListHead(&ppiCurrent->GDIDcAttrFreeList);
30 
31  /* Map the GDI handle table to user land */
32  Process->Peb->GdiSharedHandleTable = GDI_MapHandleTable(Process);
33  Process->Peb->GdiDCAttributeList = GDI_BATCH_LIMIT;
34 
35  /* Create pools for GDI object attributes */
36  ppiCurrent->pPoolDcAttr = GdiPoolCreate(sizeof(DC_ATTR), 'acdG');
37  ppiCurrent->pPoolBrushAttr = GdiPoolCreate(sizeof(BRUSH_ATTR), 'arbG');
38  ppiCurrent->pPoolRgnAttr = GdiPoolCreate(sizeof(RGN_ATTR), 'agrG');
39  ASSERT(ppiCurrent->pPoolDcAttr);
40  ASSERT(ppiCurrent->pPoolBrushAttr);
41  ASSERT(ppiCurrent->pPoolRgnAttr);
42 
43  return STATUS_SUCCESS;
44 }
struct _GDI_POOL * pPoolBrushAttr
Definition: win32.h:283
UINT PrivateMemFontHandleCount
Definition: win32.h:277
PVOID NTAPI GDI_MapHandleTable(PEPROCESS pProcess)
Definition: gdiobj.c:1513
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
#define GDI_BATCH_LIMIT
Definition: ntgdityp.h:198
PGDI_POOL NTAPI GdiPoolCreate(ULONG cjAllocSize, ULONG ulTag)
Definition: gdipool.c:316
struct _GDI_POOL * pPoolDcAttr
Definition: win32.h:282
FAST_MUTEX PrivateFontListLock
Definition: win32.h:274
LIST_ENTRY PrivateMemFontListHead
Definition: win32.h:276
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _GDI_POOL * pPoolRgnAttr
Definition: win32.h:284
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2725
LIST_ENTRY PrivateFontListHead
Definition: win32.h:275

Referenced by InitProcessCallback().

◆ GdiProcessDestroy()

NTSTATUS GdiProcessDestroy ( PEPROCESS  Process)

Definition at line 47 of file init.c.

48 {
50  ASSERT(ppiCurrent);
51  ASSERT(ppiCurrent->peProcess == Process);
52 
54 
55  /* And GDI ones too */
57 
58  /* So we can now free the pools */
59  GdiPoolDestroy(ppiCurrent->pPoolDcAttr);
60  GdiPoolDestroy(ppiCurrent->pPoolBrushAttr);
61  GdiPoolDestroy(ppiCurrent->pPoolRgnAttr);
62 
63  return STATUS_SUCCESS;
64 }
struct _GDI_POOL * pPoolBrushAttr
Definition: win32.h:283
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
BOOL NTAPI GDI_CleanupForProcess(struct _EPROCESS *Process)
Definition: gdiobj.c:1543
VOID FASTCALL IntGdiCleanupPrivateFontsForProcess(VOID)
Definition: freetype.c:1596
struct _GDI_POOL * pPoolDcAttr
Definition: win32.h:282
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
struct _GDI_POOL * pPoolRgnAttr
Definition: win32.h:284
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2725
VOID NTAPI GdiPoolDestroy(PGDI_POOL pPool)
Definition: gdipool.c:343

Referenced by ExitProcessCallback().

◆ GdiThreadCreate()

NTSTATUS GdiThreadCreate ( PETHREAD  Thread)

Definition at line 68 of file init.c.

69 {
70  return STATUS_SUCCESS;
71 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ GdiThreadDestroy()

NTSTATUS GdiThreadDestroy ( PETHREAD  Thread)

Definition at line 74 of file init.c.

75 {
76  return STATUS_SUCCESS;
77 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ InitProcessCallback()

NTSTATUS InitProcessCallback ( PEPROCESS  Process)

Definition at line 223 of file main.c.

224 {
226  PPROCESSINFO ppiCurrent;
227  PVOID KernelMapping = NULL, UserMapping = NULL;
228 
229  /* We might be called with an already allocated win32 process */
230  ppiCurrent = PsGetProcessWin32Process(Process);
231  if (ppiCurrent != NULL)
232  {
233  /* There is no more to do for us (this is a success code!) */
234  return STATUS_ALREADY_WIN32;
235  }
236  // if (ppiCurrent->W32PF_flags & W32PF_PROCESSCONNECTED)
237  // return STATUS_ALREADY_WIN32;
238 
239  /* Allocate a new Win32 process info */
240  Status = AllocW32Process(Process, &ppiCurrent);
241  if (!NT_SUCCESS(Status))
242  {
243  ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
244  HandleToUlong(Process->UniqueProcessId));
245  return Status;
246  }
247 
248 #if DBG
250 #if defined(KDBG)
251  KdRosRegisterCliCallback(DbgGdiKdbgCliCallback);
252 #endif
253 #endif
254 
255  /* Map the global user heap into the process */
256  Status = MapGlobalUserHeap(Process, &KernelMapping, &UserMapping);
257  if (!NT_SUCCESS(Status))
258  {
259  TRACE_CH(UserProcess, "Failed to map the global heap! 0x%x\n", Status);
260  goto error;
261  }
262 
263  TRACE_CH(UserProcess, "InitProcessCallback -- We have KernelMapping 0x%p and UserMapping 0x%p with delta = 0x%x\n",
264  KernelMapping, UserMapping, (ULONG_PTR)KernelMapping - (ULONG_PTR)UserMapping);
265 
266  /* Initialize USER process info */
268  if (!NT_SUCCESS(Status))
269  {
270  ERR_CH(UserProcess, "UserProcessCreate failed, Status 0x%08lx\n", Status);
271  goto error;
272  }
273 
274  /* Initialize GDI process info */
276  if (!NT_SUCCESS(Status))
277  {
278  ERR_CH(UserProcess, "GdiProcessCreate failed, Status 0x%08lx\n", Status);
279  goto error;
280  }
281 
282  /* Add the process to the global list */
283  ppiCurrent->ppiNext = gppiList;
284  gppiList = ppiCurrent;
285 
286  return STATUS_SUCCESS;
287 
288 error:
289  ERR_CH(UserProcess, "InitProcessCallback failed! Freeing ppi 0x%p for PID:0x%lx\n",
290  ppiCurrent, HandleToUlong(Process->UniqueProcessId));
292  return Status;
293 }
#define error(str)
Definition: mkdosfs.c:1605
PPROCESSINFO ppiNext
Definition: win32.h:252
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
Definition: main.c:58
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
NTSTATUS ExitProcessCallback(PEPROCESS Process)
Definition: main.c:296
uint32_t ULONG_PTR
Definition: typedefs.h:63
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
Definition: usrheap.c:262
static GENERIC_MAPPING UserMapping
Definition: samrpc.c:48
PPROCESSINFO gppiList
Definition: main.c:31
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI DbgGdiKdbgCliCallback(IN PCHAR pszCommand, IN ULONG argc, IN PCH argv[])
Definition: gdikdbgext.c:324
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS UserProcessCreate(PEPROCESS Process)
Definition: main.c:122
BOOL DbgInitDebugChannels()
NTSTATUS GdiProcessCreate(PEPROCESS Process)
Definition: init.c:18
Status
Definition: gdiplustypes.h:24
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:141
#define ERR_CH(ch, fmt,...)
Definition: debug.h:104
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2725

Referenced by Win32kProcessCallback().

◆ InitThreadCallback()

NTSTATUS NTAPI InitThreadCallback ( PETHREAD  Thread)

Definition at line 438 of file main.c.

439 {
441  PCLIENTINFO pci;
442  PTHREADINFO ptiCurrent;
443  int i;
445  PTEB pTeb;
446  LARGE_INTEGER LargeTickCount;
447  PRTL_USER_PROCESS_PARAMETERS ProcessParams;
448 
449  Process = Thread->ThreadsProcess;
450 
451  pTeb = NtCurrentTeb();
452  ASSERT(pTeb);
453 
454  ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
455 
456  /* Allocate a new Win32 thread info */
457  Status = AllocW32Thread(Thread, &ptiCurrent);
458  if (!NT_SUCCESS(Status))
459  {
460  ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
462  return Status;
463  }
464 
465  /* Initialize the THREADINFO */
466  ptiCurrent->pEThread = Thread;
467  ptiCurrent->ppi = PsGetProcessWin32Process(Process);
468  IntReferenceProcessInfo(ptiCurrent->ppi);
469  pTeb->Win32ThreadInfo = ptiCurrent;
470  ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
471 
472  /* Mark the process as having threads */
473  ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
474 
475  InitializeListHead(&ptiCurrent->WindowListHead);
479  InitializeListHead(&ptiCurrent->PtiLink);
480  for (i = 0; i < NB_HOOKS; i++)
481  {
482  InitializeListHead(&ptiCurrent->aphkStart[i]);
483  }
484  ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
485  ptiCurrent->ppi->ptiList = ptiCurrent;
486  ptiCurrent->ppi->cThreads++;
487 
488  ptiCurrent->hEventQueueClient = NULL;
489  Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
491  if (!NT_SUCCESS(Status))
492  {
493  ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
494  goto error;
495  }
498  (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
499  if (!NT_SUCCESS(Status))
500  {
501  ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
503  ptiCurrent->hEventQueueClient = NULL;
504  goto error;
505  }
506 
507  KeQueryTickCount(&LargeTickCount);
508  ptiCurrent->timeLast = LargeTickCount.u.LowPart;
509 
510  ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
511  if (ptiCurrent->MessageQueue == NULL)
512  {
513  ERR_CH(UserThread, "Failed to allocate message loop\n");
515  goto error;
516  }
517 
518  ptiCurrent->KeyboardLayout = W32kGetDefaultKeyLayout();
519  if (ptiCurrent->KeyboardLayout)
520  UserReferenceObject(ptiCurrent->KeyboardLayout);
521 
522  ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
523 
524  // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
525 
526  /* CSRSS threads have some special features */
527  if (Process == gpepCSRSS || !gpepCSRSS)
529 
530  ptiCurrent->pcti = &ptiCurrent->cti;
531 
532  /* Initialize the CLIENTINFO */
533  pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
534  RtlZeroMemory(pci, sizeof(*pci));
535  pci->ppi = ptiCurrent->ppi;
536  pci->fsHooks = ptiCurrent->fsHooks;
537  pci->dwTIFlags = ptiCurrent->TIF_flags;
538  if (ptiCurrent->KeyboardLayout)
539  {
540  pci->hKL = ptiCurrent->KeyboardLayout->hkl;
541  pci->CodePage = ptiCurrent->KeyboardLayout->CodePage;
542  }
543 
544  /* Need to pass the user Startup Information to the current process. */
545  if ( ProcessParams )
546  {
547  if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
548  {
549  if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
550  {
551  ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
552  ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
553  ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
554  ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
555  ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
556  ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
557  ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
558  }
559  }
560  }
561 
562  /*
563  * Assign a default window station and desktop to the process.
564  * Do not try to open a desktop or window station before the very first
565  * (interactive) window station has been created by Winlogon.
566  */
567  if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
568  ptiCurrent->ppi->hdeskStartup == NULL &&
570  {
571  HWINSTA hWinSta = NULL;
572  HDESK hDesk = NULL;
573  UNICODE_STRING DesktopPath;
574  PDESKTOP pdesk;
575 
576  /*
577  * Inherit the thread desktop and process window station (if not yet inherited)
578  * from the process startup info structure. See documentation of CreateProcess().
579  */
581  if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
582  {
583  Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
584  }
585  if (!NT_SUCCESS(Status))
586  {
587  RtlInitUnicodeString(&DesktopPath, NULL);
588  }
589 
591  &DesktopPath,
592  !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
593  &hWinSta,
594  &hDesk);
595 
596  if (DesktopPath.Buffer)
597  ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
598 
599  if (!NT_SUCCESS(Status))
600  {
601  ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
602  goto error;
603  }
604 
605  if (!UserSetProcessWindowStation(hWinSta))
606  {
608  ERR_CH(UserThread, "Failed to set initial process winsta\n");
609  goto error;
610  }
611 
612  /* Validate the new desktop */
613  Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
614  if (!NT_SUCCESS(Status))
615  {
616  ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
617  goto error;
618  }
619 
620  /* Store the parsed desktop as the initial desktop */
621  ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
622  ASSERT(Process->UniqueProcessId != gpidLogon);
623  ptiCurrent->ppi->hdeskStartup = hDesk;
624  ptiCurrent->ppi->rpdeskStartup = pdesk;
625  }
626 
627  if (ptiCurrent->ppi->hdeskStartup != NULL)
628  {
629  if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
630  {
631  ERR_CH(UserThread, "Failed to set thread desktop\n");
633  goto error;
634  }
635  }
636 
637  /* Mark the thread as fully initialized */
638  ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
639 
640  if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
641  (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
642  {
643  ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
644  }
645  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
646 
647  /* Last things to do only if we are not a SYSTEM or CSRSS thread */
648  if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
649  {
650  /* Callback to User32 Client Thread Setup */
651  TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
653  if (!NT_SUCCESS(Status))
654  {
655  ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
656  goto error;
657  }
658  TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
659  }
660  else
661  {
662  TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
663  }
664 
665  TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
666  return STATUS_SUCCESS;
667 
668 error:
669  ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
670  ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
672  return Status;
673 }
ULONG fsHooks
Definition: ntuser.h:296
USERSTARTUPINFO usi
Definition: win32.h:269
ULONG Win32ClientInfo[31]
Definition: compat.h:496
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
#define error(str)
Definition: mkdosfs.c:1605
PVOID Win32ThreadInfo
Definition: compat.h:495
LIST_ENTRY WindowListHead
Definition: win32.h:149
PTHREADINFO ptiSibling
Definition: win32.h:115
#define TAG_STRING
Definition: oslist.c:24
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:246
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
FLONG TIF_flags
Definition: win32.h:94
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
PEPROCESS gpepCSRSS
Definition: csr.c:15
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
LIST_ENTRY PtiLink
Definition: win32.h:125
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1526
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:242
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
PPROCESSINFO ppi
Definition: win32.h:87
PTHREADINFO gptiForeground
Definition: focus.c:14
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
Definition: glfuncs.h:248
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
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)
Definition: obref.c:496
HDESK hdeskStartup
Definition: win32.h:254
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:659
#define TIF_CSRSSTHREAD
Definition: ntuser.h:243
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:365
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:162
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:177
LIST_ENTRY W32CallbackListHead
Definition: win32.h:150
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:264
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:245
INT cThreads
Definition: win32.h:253
ULONG fsHooks
Definition: win32.h:116
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2430
CLIENT_ID Cid
Definition: pstypes.h:1059
struct _DESKTOP * rpdeskStartup
Definition: win32.h:249
PKEVENT pEventQueueServer
Definition: win32.h:124
unsigned short WORD
Definition: ntddk_ex.h:93
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
HKL hKL
Definition: ntuser.h:307
HANDLE UniqueThread
Definition: compat.h:475
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
LONG timeLast
Definition: win32.h:101
struct _CLIENTINFO * PCLIENTINFO
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1346
#define NB_HOOKS
Definition: ntuser.h:130
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
Definition: win32.h:137
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1838
CLIENTTHREADINFO cti
Definition: win32.h:138
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:680
struct tagKL * KeyboardLayout
Definition: win32.h:89
Status
Definition: gdiplustypes.h:24
HANDLE hEventQueueClient
Definition: win32.h:122
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
Definition: compat.h:484
USHORT CodePage
Definition: ntuser.h:308
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:131
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3181
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
struct tagUSERSTARTUPINFO USERSTARTUPINFO
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:343
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:535
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1200
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID)
Definition: callback.c:948
#define W32PF_APPSTARTING
Definition: win32.h:10
#define ERR_CH(ch, fmt,...)
Definition: debug.h:104
WORD wShowWindow
Definition: win32.h:214
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
struct _LARGE_INTEGER::@2192 u
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
PTHREADINFO ptiList
Definition: win32.h:247
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
struct _PROCESSINFO * ppi
Definition: ntuser.h:314
return STATUS_SUCCESS
Definition: btrfs.c:2725
DWORD dwTIFlags
Definition: ntuser.h:292
#define TIF_INCLEANUP
Definition: ntuser.h:240
#define W32PF_THREADCONNECTED
Definition: win32.h:18
HANDLE gpidLogon
Definition: simplecall.c:15
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697

Referenced by Win32kThreadCallback().

◆ UserDeleteW32Process()

VOID UserDeleteW32Process ( _Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO  ppiCurrent)

Definition at line 96 of file main.c.

98 {
99  if (ppiCurrent->InputIdleEvent)
100  {
101  /* Free the allocated memory */
102  ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
103  }
104 
105  /* Close the startup desktop */
106  if (ppiCurrent->rpdeskStartup)
107  ObDereferenceObject(ppiCurrent->rpdeskStartup);
108 
109 #if DBG
110  if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
111  {
112  TRACE_PPI(ppiCurrent, UserObj, "Dumping user handles now that process info %p is gets freed.\n", ppiCurrent);
114  }
115 #endif
116 
117  /* Free the PROCESSINFO */
119 }
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define USERTAG_EVENT
Definition: tags.h:229
#define USERTAG_PROCESSINFO
Definition: tags.h:259
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
Definition: win32kdebug.h:164
#define TRACE_PPI(ppi, ch, fmt,...)
Definition: win32kdebug.h:181
void DbgUserDumpHandleTable()
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ UserDeleteW32Thread()

VOID UserDeleteW32Thread ( PTHREADINFO  pti)

Definition at line 404 of file main.c.

405 {
406  PPROCESSINFO ppi = pti->ppi;
407 
408  TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
409 
410  /* Free the message queue */
411  if (pti->MessageQueue)
412  {
414  }
415 
417 
418  ObDereferenceObject(pti->pEThread);
419 
421 
423 }
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
#define USERTAG_THREADINFO
Definition: tags.h:283
PPROCESSINFO ppi
Definition: win32.h:87
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
Definition: msgqueue.c:2457
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
Definition: msgqueue.c:2255
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:182

◆ UserDisplayNotifyShutdown()

VOID UserDisplayNotifyShutdown ( PPROCESSINFO  ppiCurrent)

Definition at line 887 of file display.c.

889 {
890  if (ppiCurrent == gpFullscreen)
891  {
893  if (gpFullscreen)
894  ERR("Failed to restore display mode!\n");
895  }
896 }
static PPROCESSINFO gpFullscreen
Definition: display.c:13
smooth NULL
Definition: ftsmooth.c:416
LONG APIENTRY UserChangeDisplaySettings(PUNICODE_STRING pustrDevice, LPDEVMODEW pdm, DWORD flags, LPVOID lParam)
Definition: display.c:689
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by ExitThreadCallback().

◆ UserProcessCreate()

NTSTATUS UserProcessCreate ( PEPROCESS  Process)

Definition at line 122 of file main.c.

123 {
125  ASSERT(ppiCurrent);
126 
129 
130  {
131  PKEVENT Event;
132 
133  /* Allocate memory for the event structure */
135  sizeof(*Event),
136  USERTAG_EVENT);
137  if (Event)
138  {
139  /* Initialize the kernel event */
142  FALSE);
143  }
144  else
145  {
146  /* Out of memory */
147  DPRINT("CreateEvent() failed\n");
148  KeBugCheck(0);
149  }
150 
151  /* Set the event */
152  ppiCurrent->InputIdleEvent = Event;
153  KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
154  }
155 
156  ppiCurrent->peProcess = Process;
157  ppiCurrent->W32Pid = HandleToUlong(PsGetProcessId(Process));
158 
159  /* Setup process flags */
160  ppiCurrent->W32PF_flags |= W32PF_PROCESSCONNECTED;
161  if (Process->Peb->ProcessParameters &&
162  (Process->Peb->ProcessParameters->WindowFlags & STARTF_SCREENSAVER))
163  {
164  ppiScrnSaver = ppiCurrent;
165  ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
166  }
167 
168  // FIXME: check if this process is allowed.
169  ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting application will get it toggled off.
170 
171  return STATUS_SUCCESS;
172 }
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
#define HandleToUlong(h)
Definition: basetsd.h:79
#define USERTAG_EVENT
Definition: tags.h:229
#define W32PF_PROCESSCONNECTED
Definition: win32.h:19
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LIST_ENTRY DriverObjListHead
Definition: win32.h:280
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define STARTF_SCREENSAVER
Definition: undocuser.h:163
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
Definition: process.c:1063
FAST_MUTEX DriverObjListLock
Definition: win32.h:279
return STATUS_SUCCESS
Definition: btrfs.c:2725
#define W32PF_SCREENSAVER
Definition: win32.h:26

Referenced by InitProcessCallback().

◆ UserProcessDestroy()

NTSTATUS UserProcessDestroy ( PEPROCESS  Process)

Definition at line 175 of file main.c.

176 {
178  ASSERT(ppiCurrent);
179 
180  if (ppiScrnSaver == ppiCurrent)
181  ppiScrnSaver = NULL;
182 
183  /* Destroy user objects */
185 
186  TRACE_CH(UserProcess, "Freeing ppi 0x%p\n", ppiCurrent);
187 #if DBG
188  if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
189  {
190  TRACE_CH(UserObj, "Dumping user handles at the end of the process %s (Info %p).\n",
191  ppiCurrent->peProcess->ImageFileName, ppiCurrent);
193  }
194 #endif
195 
196  /* Remove it from the list of GUI apps */
198 
199  /*
200  * Deregister logon application automatically
201  */
202  if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
203  gpidLogon = 0;
204 
205  /* Close the current window station */
207 
208  if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
209 
210  if (ppiCurrent->hdeskStartup)
211  {
212  ZwClose(ppiCurrent->hdeskStartup);
213  ppiCurrent->hdeskStartup = NULL;
214  }
215 
216  /* Clean up the process icon cache */
217  IntCleanupCurIconCache(ppiCurrent);
218 
219  return STATUS_SUCCESS;
220 }
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
HDESK hdeskStartup
Definition: win32.h:254
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1346
BOOL FASTCALL co_IntGraphicsCheck(BOOL Create)
Definition: guicheck.c:52
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
Definition: win32kdebug.h:164
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
Definition: cursoricon.c:391
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:720
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
void DbgUserDumpHandleTable()
return STATUS_SUCCESS
Definition: btrfs.c:2725
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
HANDLE gpidLogon
Definition: simplecall.c:15

Referenced by ExitProcessCallback().

◆ UserThreadCreate()

NTSTATUS UserThreadCreate ( PETHREAD  Thread)

Definition at line 426 of file main.c.

427 {
428  return STATUS_SUCCESS;
429 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ UserThreadDestroy()

NTSTATUS UserThreadDestroy ( PETHREAD  Thread)

Definition at line 432 of file main.c.

433 {
434  return STATUS_SUCCESS;
435 }
return STATUS_SUCCESS
Definition: btrfs.c:2725

◆ Win32kProcessCallback()

NTSTATUS APIENTRY Win32kProcessCallback ( PEPROCESS  Process,
BOOLEAN  Initialize 
)

Definition at line 335 of file main.c.

337 {
339 
340  ASSERT(Process->Peb);
341 
342  TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
343 
345 
346  if (Initialize)
347  {
349  }
350  else
351  {
353  }
354 
355  UserLeave();
356 
357  TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
358 
359  return Status;
360 }
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:223
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS ExitProcessCallback(PEPROCESS Process)
Definition: main.c:296
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static BOOL Initialize(LPCWSTR lpDriverPath)
Definition: main.c:4
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

Referenced by DriverEntry().

◆ Win32kThreadCallback()

NTSTATUS APIENTRY Win32kThreadCallback ( PETHREAD  Thread,
PSW32THREADCALLOUTTYPE  Type 
)

Definition at line 846 of file main.c.

848 {
850 
851  ASSERT(NtCurrentTeb());
852 
854 
856  {
859  }
860  else // if (Type == PsW32ThreadCalloutExit)
861  {
864  }
865 
866  UserLeave();
867 
868  return Status;
869 }
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
Definition: thread.c:795
Type
Definition: Type.h:6
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:438
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:680
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420

Referenced by DriverEntry().

Variable Documentation

◆ gppiList

PPROCESSINFO gppiList = NULL

Definition at line 31 of file main.c.

Referenced by ExitProcessCallback(), and InitProcessCallback().

◆ gpsi

PSERVERINFO gpsi = NULL

Definition at line 27 of file main.c.

Referenced by alloc_user_entry(), co_IntInitializeDesktopGraphics(), co_IntSendActivateMessages(), co_IntSendMessageTimeout(), co_IntSetCaretPos(), co_IntSetupOBM(), co_IntSetWndIcons(), co_IntShellHookNotify(), co_MsqInsertMouseMessage(), co_MsqSendMessage(), co_UserCreateWindowEx(), co_UserDestroyWindow(), co_UserShowCaret(), co_WinPosSetWindowPos(), CreateSysColorObjects(), DefWndControlColor(), DefWndGetIcon(), DefWndHandleSetCursor(), DefWndSetIcon(), DrawFocusRect(), DriverEntry(), EnumerateCallback(), free_user_entry(), GetLastInputInfo(), GetSysColor(), GetSysColorBrush(), GetSystemMetrics(), InitMetrics(), InitUserAtoms(), IntCoalesceMouseMove(), IntCreateClass(), IntCreateDesktop(), IntCreateWindow(), IntDeactivateWindow(), IntDefWindowProc(), IntDrawState(), IntFlashWindowEx(), IntGetSysColor(), IntGetSysColorBrush(), IntGetWindowContextHelpId(), IntGrayString(), IntImmProcessKey(), IntIsFontRenderingEnabled(), IntIsGhostWindow(), IntLastInputTick(), IntNotifyWinEvent(), IntRealChildWindowFromPoint(), IntRemoveEvent(), IntSetCaretBlinkTime(), IntSetSrvEventMask(), IntSetSysColors(), IntTranslateKbdMessage(), IsDialogMessageW(), IsWinEventHookInstalled(), LoadSystemCursors(), LoadUserApiHook(), MENU_AdjustMenuItemRect(), MENU_CalcItemSize(), MENU_DrawMenuItem(), MENU_DrawScrollArrows(), MENU_EnsureMenuItemVisible(), MENU_InitPopup(), MouseSafetyOnDrawEnd(), NC_IconForWindow(), NotifyWinEvent(), NtUserCallHwnd(), NtUserCallHwndParam(), NtUserCallNoParam(), NtUserCallOneParam(), NtUserCreateCaret(), NtUserGetCaretBlinkTime(), NtUserGetClassName(), NtUserGetComboBoxInfo(), NtUserGetCursorInfo(), NtUserGetListBoxInfo(), NtUserInitializeClientPfnArrays(), NtUserMessageCall(), NtUserNotifyWinEvent(), NtUserProcessConnect(), PostTimerMessages(), ProcessKeyEvent(), RealGetSystemMetrics(), RegisterControlAtoms(), SpiGetSet(), SpiUpdatePerUserSystemParameters(), SystemTimerProc(), UITOOLS_DrawCheckedRect(), UpdatePerUserImmEnabling(), UserAttachThreadInput(), UserChangeDisplaySettings(), UserClipCursor(), UserDrawWindowFrame(), UserGetSystemMetrics(), UserInitialize(), UserPaintCaption(), UserPostMessage(), UserPostThreadMessage(), UserRegisterUserApiHook(), UserSendMouseInput(), UserSendNotifyMessage(), UserSetCursor(), UserSetCursorPos(), UserShowCursor(), UserUnregisterUserApiHook(), and UserUpdateMonitorSize().

◆ gusLanguageID

◆ hModuleWin

HANDLE hModuleWin

Definition at line 16 of file main.c.

Referenced by DriverEntry(), and UserRegisterSystemClasses().

◆ ppiScrnSaver

◆ Win32kNumberOfSysCalls

ULONG Win32kNumberOfSysCalls

Definition at line 22 of file napi.h.

Referenced by DriverEntry().

◆ Win32kSSDT

ULONG_PTR Win32kSSDT[]

Definition at line 9 of file napi.h.

Referenced by DriverEntry().

◆ Win32kSSPT

UCHAR Win32kSSPT[]

Definition at line 15 of file napi.h.

Referenced by DriverEntry().