ReactOS 0.4.15-dev-5666-gc548b97
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)
 
#define USERLOCK_AND_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)
 
NTSTATUS APIENTRY DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

HANDLE hModuleWin
 
PSERVERINFO gpsi = NULL
 
USHORT 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; \
} \
}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Definition at line 917 of file main.c.

◆ USERLOCK_AND_ROF

#define USERLOCK_AND_ROF (   x)
Value:
{ \
UserEnterExclusive(); \
Status = (x); \
UserLeave(); \
if (!NT_SUCCESS(Status)) \
{ \
DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
return Status; \
} \
}

Definition at line 928 of file main.c.

Function Documentation

◆ _Function_class_()

_Function_class_ ( DRIVER_UNLOAD  )

Definition at line 906 of file main.c.

909{
910 // TODO: Do more cleanup!
911
914}
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 */
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}
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ERR_CH(ch, fmt,...)
Definition: debug.h:105
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:108
#define NULL
Definition: types.h:112
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
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 STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_SUCCESS
Definition: shellext.h:65
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:181
#define USERTAG_PROCESSINFO
Definition: tags.h:260

Referenced by InitProcessCallback().

◆ AllocW32Thread()

NTSTATUS AllocW32Thread ( IN PETHREAD  Thread,
OUT PTHREADINFO W32Thread 
)

Definition at line 373 of file main.c.

375{
376 PTHREADINFO ptiCurrent;
377
378 TRACE_CH(UserThread, "In AllocW32Thread(0x%p)\n", Thread);
379
380 /* Check that we were not called with an already existing Win32 thread info */
381 ptiCurrent = PsGetThreadWin32Thread(Thread);
382 NT_ASSERT(ptiCurrent == NULL);
383
384 /* Allocate a new Win32 thread info */
386 sizeof(*ptiCurrent),
388 if (ptiCurrent == NULL)
389 {
390 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
392 return STATUS_NO_MEMORY;
393 }
394
395 TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
396 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
397
398 RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
399
400 PsSetThreadWin32Thread(Thread, ptiCurrent, NULL);
402 IntReferenceThreadInfo(ptiCurrent);
403
404 *W32Thread = ptiCurrent;
405 return STATUS_SUCCESS;
406}
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
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
HANDLE UniqueThread
Definition: compat.h:826
CLIENT_ID Cid
Definition: pstypes.h:1128
#define IntReferenceThreadInfo(pti)
Definition: win32.h:166
#define USERTAG_THREADINFO
Definition: tags.h:284
#define ObReferenceObject
Definition: obfuncs.h:204
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by InitThreadCallback().

◆ DriverEntry()

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

Definition at line 948 of file main.c.

951{
954 WIN32_CALLOUTS_FPNS CalloutData = {0};
955 PVOID GlobalUserHeapBase = NULL;
956
957 /*
958 * Register user mode call interface
959 * (system service table index = 1)
960 */
962 NULL,
965 1);
966 if (Result == FALSE)
967 {
968 DPRINT1("Adding system services failed!\n");
969 return STATUS_UNSUCCESSFUL;
970 }
971
973 DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
974
975 DriverObject->DriverUnload = DriverUnload;
976
977 /* Register Object Manager Callbacks */
980 // CalloutData.GlobalAtomTableCallout = NULL;
981 // CalloutData.PowerEventCallout = NULL;
982 // CalloutData.PowerStateCallout = NULL;
983 // CalloutData.JobCallout = NULL;
990 // CalloutData.WindowStationCloseProcedure = NULL;
993 // CalloutData.WindowStationOpenProcedure = NULL;
994
995 /* Register our per-process and per-thread structures. */
996 PsEstablishWin32Callouts(&CalloutData);
997
998 /* Register service hook callbacks */
999#if DBG && defined(KDBG)
1000 KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
1001 KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
1002#endif
1003
1004 /* Create the global USER heap */
1006 &GlobalUserHeapBase,
1007 1 * 1024 * 1024); /* FIXME: 1 MB for now... */
1008 if (GlobalUserHeap == NULL)
1009 {
1010 DPRINT1("Failed to initialize the global heap!\n");
1011 return STATUS_UNSUCCESSFUL;
1012 }
1013
1014 /* Init the global user lock */
1016
1017 /* Lock while we use the heap (UserHeapAlloc asserts on this) */
1019
1020 /* Allocate global server info structure */
1021 gpsi = UserHeapAlloc(sizeof(*gpsi));
1022 UserLeave();
1023 if (!gpsi)
1024 {
1025 DPRINT1("Failed allocate server info structure!\n");
1026 return STATUS_UNSUCCESSFUL;
1027 }
1028
1029 RtlZeroMemory(gpsi, sizeof(*gpsi));
1030 DPRINT("Global Server Data -> %p\n", gpsi);
1031
1034
1035 /* Create stock objects, ie. precreated objects commonly
1036 used by win32 applications */
1039
1044 NT_ROF(InitDcImpl());
1053
1055
1056 /* Initialize FreeType library */
1057 if (!InitFontSupport())
1058 {
1059 DPRINT1("Unable to initialize font support\n");
1060 return Status;
1061 }
1062
1063 return STATUS_SUCCESS;
1064}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI InitDcImpl(VOID)
Definition: dclife.c:53
#define FALSE
Definition: types.h:117
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
NTSTATUS NTAPI InitBrushImpl(VOID)
Definition: engbrush.c:31
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
BOOL FASTCALL InitFontSupport(VOID)
Definition: freetype.c:661
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
Definition: gdibatch.c:487
VOID FASTCALL CreateStockObjects(VOID)
Definition: stockobj.c:247
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
static DRIVER_UNLOAD DriverUnload
Definition: kbdclass.c:17
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)
Definition: kdapi.c:2152
NTSTATUS NTAPI InitLDEVImpl(VOID)
Definition: ldevobj.c:30
NTSTATUS NTAPI MsqInitializeImpl(VOID)
Definition: msgqueue.c:30
VOID NTAPI PsEstablishWin32Callouts(IN PWIN32_CALLOUTS_FPNS CalloutData)
Definition: win32.c:112
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
Definition: winsta.c:106
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
Definition: winsta.c:203
NTSTATUS NTAPI InitWindowStationImpl(VOID)
Definition: winsta.c:34
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
Definition: winsta.c:138
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:254
ERESOURCE UserLock
Definition: ntuser.c:18
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:245
NTSTATUS NTAPI InitPDEVImpl(VOID)
Definition: pdevobj.c:30
BOOLEAN NTAPI KeAddSystemServiceTable(IN PULONG_PTR Base, IN PULONG Count OPTIONAL, IN ULONG Limit, IN PUCHAR Number, IN ULONG Index)
Definition: procobj.c:908
#define DPRINT
Definition: sndvol32.h:71
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1694
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1683
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1696
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1697
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1691
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1690
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1693
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1692
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1684
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1689
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3504
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:181
HANDLE GlobalUserHeap
Definition: usrheap.c:25
PVOID GlobalUserHeapSection
Definition: usrheap.c:26
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
NTSTATUS NTAPI InitDeviceImpl(VOID)
Definition: device.c:26
NTSTATUS NTAPI InitGdiHandleTable(void)
Definition: gdiobj.c:259
USHORT FASTCALL UserGetLanguageID(VOID)
Definition: misc.c:97
NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:66
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
Definition: desktop.c:186
NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:252
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:227
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:210
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:155
NTSTATUS NTAPI InitInputImpl(VOID)
Definition: input.c:360
NTSTATUS NTAPI InitKeyboardImpl(VOID)
Definition: keyboard.c:31
ULONG_PTR Win32kSSDT[]
Definition: napi.h:9
ULONG Win32kNumberOfSysCalls
Definition: napi.h:22
USHORT gusLanguageID
Definition: main.c:29
#define USERLOCK_AND_ROF(x)
Definition: main.c:928
HANDLE hModuleWin
Definition: main.c:16
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:343
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:881
UCHAR Win32kSSPT[]
Definition: napi.h:15
#define NT_ROF(x)
Definition: main.c:917
PSERVERINFO gpsi
Definition: main.c:27
NTSTATUS NTAPI InitTimerImpl(VOID)
Definition: timer.c:594
NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
_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

◆ ExitProcessCallback()

NTSTATUS ExitProcessCallback ( PEPROCESS  Process)

Definition at line 304 of file main.c.

305{
306 PPROCESSINFO ppiCurrent, *pppi;
307
308 /* Get the Win32 Process */
309 ppiCurrent = PsGetProcessWin32Process(Process);
310 ASSERT(ppiCurrent);
311 ASSERT(ppiCurrent->peProcess == Process);
312
313 TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
314 ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
315
316 /* Remove it from the list */
317 pppi = &gppiList;
318 while (*pppi != NULL && *pppi != ppiCurrent)
319 {
320 pppi = &(*pppi)->ppiNext;
321 }
322 ASSERT(*pppi == ppiCurrent);
323 *pppi = ppiCurrent->ppiNext;
324
325 /* Cleanup GDI info */
327
328 /* Cleanup USER info */
330
331 /* The process is dying */
333 ppiCurrent->peProcess = NULL;
334
335 /* Finally, dereference */
336 IntDereferenceProcessInfo(ppiCurrent);
337
338 return STATUS_SUCCESS;
339}
#define ASSERT(a)
Definition: mode.c:44
PPROCESSINFO ppiNext
Definition: win32.h:261
#define W32PF_TERMINATED
Definition: win32.h:16
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:186
PPROCESSINFO gppiList
Definition: main.c:31
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:47
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:175

Referenced by InitProcessCallback(), and Win32kProcessCallback().

◆ ExitThreadCallback()

NTSTATUS NTAPI ExitThreadCallback ( PETHREAD  Thread)

Definition at line 703 of file main.c.

704{
705 PTHREADINFO *ppti;
707 PPROCESSINFO ppiCurrent;
709 PTHREADINFO ptiCurrent;
710 PWINDOWLIST pwl, pwlNext;
711
712 Process = Thread->ThreadsProcess;
713
714 /* Get the Win32 Thread */
715 ptiCurrent = PsGetThreadWin32Thread(Thread);
716 ASSERT(ptiCurrent);
717
718 TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
719
720 ptiCurrent->TIF_flags |= TIF_INCLEANUP;
721 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
722
723 ppiCurrent = ptiCurrent->ppi;
724 ASSERT(ppiCurrent);
725
726 IsRemoveAttachThread(ptiCurrent);
727
728 if (gpwlList)
729 {
730 for (pwl = gpwlList; pwl; pwl = pwlNext)
731 {
732 pwlNext = pwl->pNextList;
733 if (pwl->pti == ptiCurrent)
734 IntFreeHwndList(pwl);
735 }
736 }
737
738 ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
739 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
740
742
743 /* Decrement thread count and check if its 0 */
744 ppiCurrent->cThreads--;
745
746 if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
747 {
748 /* Do now some process cleanup that requires a valid win32 thread */
749 if (ptiCurrent->ppi->cThreads == 0)
750 {
751 /* Check if we have registered the user api hook */
752 if (ptiCurrent->ppi == ppiUahServer)
753 {
754 /* Unregister the api hook */
756 }
757
758 /* Notify logon application to restart shell if needed */
759 if (ptiCurrent->pDeskInfo)
760 {
761 if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
762 {
764
765 TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
766
770 ExitCode);
771
772 ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
773 }
774 }
775 }
776
777 DceFreeThreadDCE(ptiCurrent);
778 DestroyTimersForThread(ptiCurrent);
780 UnregisterThreadHotKeys(ptiCurrent);
781
783 {
784 DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
785 ASSERT(FALSE);
786 return STATUS_UNSUCCESSFUL;
787 }
789
790 if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
791 ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
792 {
793 TRACE_CH(UserThread, "DestroyProcessClasses\n");
794 /* no process windows should exist at this point, or the function will assert! */
795 DestroyProcessClasses(ppiCurrent);
796 ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
797 }
798
799 IntBlockInput(ptiCurrent, FALSE);
800 IntCleanupThreadCallbacks(ptiCurrent);
801
802 /* cleanup user object references stack */
803 psle = PopEntryList(&ptiCurrent->ReferencesList);
804 while (psle)
805 {
807 TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
809
810 psle = PopEntryList(&ptiCurrent->ReferencesList);
811 }
812 }
813
814 if (ptiCurrent->cEnterCount)
815 {
817 ptiCurrent->cEnterCount = 0;
818 }
819
820 /* Find the THREADINFO in the PROCESSINFO's list */
821 ppti = &ppiCurrent->ptiList;
822 while (*ppti != NULL && *ppti != ptiCurrent)
823 {
824 ppti = &((*ppti)->ptiSibling);
825 }
826
827 /* we must have found it */
828 ASSERT(*ppti == ptiCurrent);
829
830 /* Remove it from the list */
831 *ppti = ptiCurrent->ptiSibling;
832
833 if (!UserAssignmentUnlock((PVOID*)&(ptiCurrent->KeyboardLayout)))
834 ptiCurrent->pClientInfo->hKL = NULL;
835
836 if (gptiForeground == ptiCurrent)
837 {
838// IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
839// IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
840
842 }
843
844 /* Restore display mode when we are the last thread, and we changed the display mode */
845 if (ppiCurrent->cThreads == 0)
846 UserDisplayNotifyShutdown(ppiCurrent);
847
848
849 // Fixes CORE-6384 & CORE-7030.
850/* if (ptiLastInput == ptiCurrent)
851 {
852 if (!ppiCurrent->ptiList)
853 ptiLastInput = gptiForeground;
854 else
855 ptiLastInput = ppiCurrent->ptiList;
856 ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
857 }
858*/
859 TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
860
862
863 if (ptiCurrent->hEventQueueClient != NULL)
864 {
867 }
868 ptiCurrent->hEventQueueClient = NULL;
869
870 /* The thread is dying */
871 PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
872
873 /* Dereference the THREADINFO */
874 IntDereferenceThreadInfo(ptiCurrent);
875
876 return STATUS_SUCCESS;
877}
void FASTCALL DceFreeThreadDCE(PTHREADINFO)
Definition: windc.c:780
#define TRUE
Definition: types.h:120
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TIF_INCLEANUP
Definition: ntuser.h:262
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:268
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:286
#define UserMode
Definition: asm.h:35
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
Definition: process.c:1053
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
Definition: hook.c:207
PPROCESSINFO ppiUahServer
Definition: hook.c:25
HWND hwndSAS
Definition: winsta.c:24
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
base of all file and directory entries
Definition: entries.h:83
INT cThreads
Definition: win32.h:262
PTHREADINFO ptiList
Definition: win32.h:256
Definition: ntbasedef.h:628
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
INT cEnterCount
Definition: win32.h:135
PTHREADINFO ptiSibling
Definition: win32.h:116
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
PKEVENT pEventQueueServer
Definition: win32.h:125
struct tagIMC * spDefaultImc
Definition: win32.h:132
struct tagKL * KeyboardLayout
Definition: win32.h:90
HANDLE hEventQueueClient
Definition: win32.h:123
FLONG TIF_flags
Definition: win32.h:95
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:157
Definition: object.h:4
Definition: send.c:48
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define LN_SHELL_EXITED
Definition: undocuser.h:116
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define IntDereferenceThreadInfo(pti)
Definition: win32.h:171
#define W32PF_CLASSESREGISTERED
Definition: win32.h:17
VOID FASTCALL IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
Definition: callback.c:76
void FASTCALL DestroyProcessClasses(PPROCESSINFO Process)
Definition: class.c:300
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:545
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3260
PTHREADINFO gptiForeground
Definition: focus.c:15
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:121
BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO pti)
Definition: input.c:437
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:375
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:933
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1346
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:754
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
Definition: object.c:861
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
Definition: timer.c:549
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1459
PWINDOWLIST gpwlList
Definition: window.c:16
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ObDereferenceObject
Definition: obfuncs.h:203
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240

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}
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
PGDI_POOL NTAPI GdiPoolCreate(ULONG cjAllocSize, ULONG ulTag)
Definition: gdipool.c:316
#define GDI_BATCH_LIMIT
Definition: ntgdityp.h:201
LIST_ENTRY PrivateMemFontListHead
Definition: win32.h:285
FAST_MUTEX PrivateFontListLock
Definition: win32.h:283
struct _GDI_POOL * pPoolRgnAttr
Definition: win32.h:293
struct _GDI_POOL * pPoolBrushAttr
Definition: win32.h:292
UINT PrivateMemFontHandleCount
Definition: win32.h:286
LIST_ENTRY PrivateFontListHead
Definition: win32.h:284
struct _GDI_POOL * pPoolDcAttr
Definition: win32.h:291
PVOID NTAPI GDI_MapHandleTable(PEPROCESS pProcess)
Definition: gdiobj.c:1552
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274

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}
VOID FASTCALL IntGdiCleanupPrivateFontsForProcess(VOID)
Definition: freetype.c:1917
VOID NTAPI GdiPoolDestroy(PGDI_POOL pPool)
Definition: gdipool.c:343
BOOL NTAPI GDI_CleanupForProcess(struct _EPROCESS *Process)
Definition: gdiobj.c:1582

Referenced by ExitProcessCallback().

◆ GdiThreadCreate()

NTSTATUS GdiThreadCreate ( PETHREAD  Thread)

Definition at line 68 of file init.c.

69{
70 return STATUS_SUCCESS;
71}

◆ GdiThreadDestroy()

NTSTATUS GdiThreadDestroy ( PETHREAD  Thread)

Definition at line 74 of file init.c.

75{
76 return STATUS_SUCCESS;
77}

◆ InitProcessCallback()

NTSTATUS InitProcessCallback ( PEPROCESS  Process)

Definition at line 231 of file main.c.

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

Referenced by Win32kProcessCallback().

◆ InitThreadCallback()

NTSTATUS NTAPI InitThreadCallback ( PETHREAD  Thread)

Definition at line 457 of file main.c.

458{
460 PCLIENTINFO pci;
461 PTHREADINFO ptiCurrent;
462 int i;
464 PTEB pTeb;
465 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
466 PKL pDefKL;
467
468 Process = Thread->ThreadsProcess;
469
470 pTeb = NtCurrentTeb();
471 ASSERT(pTeb);
472
473 ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
474
475 /* Allocate a new Win32 thread info */
476 Status = AllocW32Thread(Thread, &ptiCurrent);
477 if (!NT_SUCCESS(Status))
478 {
479 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
481 return Status;
482 }
483
484 /* Initialize the THREADINFO */
485 ptiCurrent->pEThread = Thread;
486 ptiCurrent->ppi = PsGetProcessWin32Process(Process);
487 IntReferenceProcessInfo(ptiCurrent->ppi);
488 pTeb->Win32ThreadInfo = ptiCurrent;
489 ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
490 ptiCurrent->pcti = &ptiCurrent->cti;
491
492 /* Mark the process as having threads */
493 ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
494
499 InitializeListHead(&ptiCurrent->PtiLink);
500 for (i = 0; i < NB_HOOKS; i++)
501 {
502 InitializeListHead(&ptiCurrent->aphkStart[i]);
503 }
504 ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
505 ptiCurrent->ppi->ptiList = ptiCurrent;
506 ptiCurrent->ppi->cThreads++;
507
508 ptiCurrent->hEventQueueClient = NULL;
509 Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
511 if (!NT_SUCCESS(Status))
512 {
513 ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
514 goto error;
515 }
518 (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
519 if (!NT_SUCCESS(Status))
520 {
521 ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
523 ptiCurrent->hEventQueueClient = NULL;
524 goto error;
525 }
526
527 ptiCurrent->pcti->timeLastRead = EngGetTickCount32();
528
529 ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
530 if (ptiCurrent->MessageQueue == NULL)
531 {
532 ERR_CH(UserThread, "Failed to allocate message loop\n");
534 goto error;
535 }
536
537 pDefKL = W32kGetDefaultKeyLayout();
538 UserAssignmentLock((PVOID*)&(ptiCurrent->KeyboardLayout), pDefKL);
539
540 ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
541
542 // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
543
544 /* CSRSS threads have some special features */
545 if (Process == gpepCSRSS || !gpepCSRSS)
547
548 /* Initialize the CLIENTINFO */
549 pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
550 RtlZeroMemory(pci, sizeof(*pci));
551 pci->ppi = ptiCurrent->ppi;
552 pci->fsHooks = ptiCurrent->fsHooks;
553 pci->dwTIFlags = ptiCurrent->TIF_flags;
554 if (pDefKL)
555 {
556 pci->hKL = pDefKL->hkl;
557 pci->CodePage = pDefKL->CodePage;
558 }
559
560 /* Need to pass the user Startup Information to the current process. */
561 if ( ProcessParams )
562 {
563 if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
564 {
565 if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
566 {
567 ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
568 ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
569 ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
570 ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
571 ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
572 ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
573 ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
574 }
575 }
576 }
577
578 /*
579 * Assign a default window station and desktop to the process.
580 * Do not try to open a desktop or window station before the very first
581 * (interactive) window station has been created by Winlogon.
582 */
583 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
584 ptiCurrent->ppi->hdeskStartup == NULL &&
586 {
587 HWINSTA hWinSta = NULL;
588 HDESK hDesk = NULL;
589 UNICODE_STRING DesktopPath;
590 PDESKTOP pdesk;
591
592 /*
593 * Inherit the thread desktop and process window station (if not yet inherited)
594 * from the process startup info structure. See documentation of CreateProcess().
595 */
597 if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
598 {
599 Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
600 }
601 if (!NT_SUCCESS(Status))
602 {
603 RtlInitUnicodeString(&DesktopPath, NULL);
604 }
605
607 &DesktopPath,
608 !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
609 &hWinSta,
610 &hDesk);
611
612 if (DesktopPath.Buffer)
613 ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
614
615 if (!NT_SUCCESS(Status))
616 {
617 ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
618 goto error;
619 }
620
621 if (!UserSetProcessWindowStation(hWinSta))
622 {
624 ERR_CH(UserThread, "Failed to set initial process winsta\n");
625 goto error;
626 }
627
628 /* Validate the new desktop */
629 Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
630 if (!NT_SUCCESS(Status))
631 {
632 ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
633 goto error;
634 }
635
636 /* Store the parsed desktop as the initial desktop */
637 ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
638 ASSERT(Process->UniqueProcessId != gpidLogon);
639 ptiCurrent->ppi->hdeskStartup = hDesk;
640 ptiCurrent->ppi->rpdeskStartup = pdesk;
641 }
642
643 if (ptiCurrent->ppi->hdeskStartup != NULL)
644 {
645 if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
646 {
647 ERR_CH(UserThread, "Failed to set thread desktop\n");
649 goto error;
650 }
651 }
652
653 /* Mark the thread as fully initialized */
654 ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
655
656 if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
657 (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
658 {
660 }
661 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
662
663 /* Create the default input context */
664 if (IS_IMM_MODE())
665 {
667 }
668
669 /* Last things to do only if we are not a SYSTEM or CSRSS thread */
670 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
671 {
672 /* Callback to User32 Client Thread Setup */
673 TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
675 if (!NT_SUCCESS(Status))
676 {
677 ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
678 goto error;
679 }
680 TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
681 }
682 else
683 {
684 TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
685 }
686
687 TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
688 return STATUS_SUCCESS;
689
690error:
691 ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
692 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
694 return Status;
695}
#define VOID
Definition: acefi.h:82
PEPROCESS gpepCSRSS
Definition: csr.c:15
#define EngGetTickCount32()
Definition: eng.h:43
unsigned short WORD
Definition: ntddk_ex.h:93
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 TIF_CSRSSTHREAD
Definition: ntuser.h:265
#define IS_IMM_MODE()
Definition: ntuser.h:1232
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:264
struct _CLIENTINFO * PCLIENTINFO
#define NB_HOOKS
Definition: ntuser.h:127
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:267
#define NtCurrentTeb
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2440
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
@ SynchronizationEvent
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1382
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:494
#define TAG_STRING
Definition: oslist.h:22
HANDLE gpidLogon
Definition: simplecall.c:15
USHORT CodePage
Definition: ntuser.h:335
HKL hKL
Definition: ntuser.h:334
ULONG fsHooks
Definition: ntuser.h:323
DWORD dwTIFlags
Definition: ntuser.h:319
struct _PROCESSINFO * ppi
Definition: ntuser.h:341
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
USERSTARTUPINFO usi
Definition: win32.h:278
HDESK hdeskStartup
Definition: win32.h:263
struct _DESKTOP * rpdeskStartup
Definition: win32.h:258
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1555
Definition: compat.h:836
ULONG Win32ClientInfo[31]
Definition: compat.h:847
PVOID Win32ThreadInfo
Definition: compat.h:846
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
ULONG fsHooks
Definition: win32.h:117
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:137
CLIENTTHREADINFO cti
Definition: win32.h:144
LIST_ENTRY W32CallbackListHead
Definition: win32.h:156
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
Definition: win32.h:143
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:91
LIST_ENTRY SentMessagesListHead
Definition: win32.h:100
LIST_ENTRY WindowListHead
Definition: win32.h:155
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:89
LIST_ENTRY PtiLink
Definition: win32.h:126
Definition: input.h:27
USHORT CodePage
Definition: input.h:36
HKL hkl
Definition: input.h:32
WORD wShowWindow
Definition: win32.h:219
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:164
#define W32PF_APPSTARTING
Definition: win32.h:10
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
struct tagUSERSTARTUPINFO USERSTARTUPINFO
#define W32PF_THREADCONNECTED
Definition: win32.h:18
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:679
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID)
Definition: callback.c:959
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1237
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:551
PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1565
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:514
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:703
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:373
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:840

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 DbgUserDumpHandleTable()
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
Definition: win32kdebug.h:166
#define TRACE_PPI(ppi, ch, fmt,...)
Definition: win32kdebug.h:183
#define USERTAG_EVENT
Definition: tags.h:230

◆ UserDeleteW32Thread()

VOID UserDeleteW32Thread ( PTHREADINFO  pti)

Definition at line 412 of file main.c.

413{
414 PPROCESSINFO ppi = pti->ppi;
415
416 TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
417
418 /* Free the message queue */
419 if (pti->MessageQueue)
420 {
422 }
423
425
426 ObDereferenceObject(pti->pEThread);
427
429
431
432 {
433 // Find another queue for mouse cursor.
434 MSG msg;
435 msg.message = WM_MOUSEMOVE;
436 msg.wParam = UserGetMouseButtonsState();
437 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
438 msg.pt = gpsi->ptCursor;
440 }
441}
#define msg(x)
Definition: auth_time.c:54
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
Definition: msgqueue.c:2467
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
Definition: msgqueue.c:2265
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
#define WM_MOUSEMOVE
Definition: winuser.h:1765

◆ UserDisplayNotifyShutdown()

VOID UserDisplayNotifyShutdown ( PPROCESSINFO  ppiCurrent)

Definition at line 933 of file display.c.

935{
936 if (ppiCurrent == gpFullscreen)
937 {
939 if (gpFullscreen)
940 ERR("Failed to restore display mode!\n");
941 }
942}
#define ERR(fmt,...)
Definition: debug.h:110
LONG APIENTRY UserChangeDisplaySettings(PUNICODE_STRING pustrDevice, LPDEVMODEW pdm, DWORD flags, LPVOID lParam)
Definition: display.c:716
static PPROCESSINFO gpFullscreen
Definition: display.c:13

Referenced by ExitThreadCallback().

◆ UserProcessCreate()

NTSTATUS UserProcessCreate ( PEPROCESS  Process)

Definition at line 122 of file main.c.

123{
125 ASSERT(ppiCurrent);
126
129
130 {
132
133 /* Allocate memory for the event structure */
135 sizeof(*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}
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1427
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
@ NotificationEvent
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
Definition: process.c:1063
LIST_ENTRY DriverObjListHead
Definition: win32.h:289
FAST_MUTEX DriverObjListLock
Definition: win32.h:288
#define STARTF_SCREENSAVER
Definition: undocuser.h:165
#define W32PF_SCREENSAVER
Definition: win32.h:26
#define W32PF_PROCESSCONNECTED
Definition: win32.h:19
PPROCESSINFO ppiScrnSaver
Definition: main.c:30

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)
182
184
185 if (gpwlCache)
186 {
188 gpwlCache = NULL;
189 }
190
191 /* Destroy user objects */
193
194 TRACE_CH(UserProcess, "Freeing ppi 0x%p\n", ppiCurrent);
195#if DBG
196 if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
197 {
198 TRACE_CH(UserObj, "Dumping user handles at the end of the process %s (Info %p).\n",
199 ppiCurrent->peProcess->ImageFileName, ppiCurrent);
201 }
202#endif
203
204 /* Remove it from the list of GUI apps */
206
207 /*
208 * Deregister logon application automatically
209 */
210 if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
211 gpidLogon = 0;
212
213 /* Close the current window station */
215
216 if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
217
218 if (ppiCurrent->hdeskStartup)
219 {
220 ZwClose(ppiCurrent->hdeskStartup);
221 ppiCurrent->hdeskStartup = NULL;
222 }
223
224 /* Clean up the process icon cache */
225 IntCleanupCurIconCache(ppiCurrent);
226
227 return STATUS_SUCCESS;
228}
BOOL FASTCALL co_IntGraphicsCheck(BOOL Create)
Definition: guicheck.c:52
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
Definition: cursoricon.c:391
VOID FASTCALL IntFreeImeHotKeys(VOID)
Definition: ime.c:340
#define USERTAG_WINDOWLIST
Definition: tags.h:298
PWINDOWLIST gpwlCache
Definition: window.c:17

Referenced by ExitProcessCallback().

◆ UserThreadCreate()

NTSTATUS UserThreadCreate ( PETHREAD  Thread)

Definition at line 444 of file main.c.

445{
446 return STATUS_SUCCESS;
447}

◆ UserThreadDestroy()

NTSTATUS UserThreadDestroy ( PETHREAD  Thread)

Definition at line 450 of file main.c.

451{
452 return STATUS_SUCCESS;
453}

◆ Win32kProcessCallback()

NTSTATUS APIENTRY Win32kProcessCallback ( PEPROCESS  Process,
BOOLEAN  Initialize 
)

Definition at line 343 of file main.c.

345{
347
348 ASSERT(Process->Peb);
349
350 TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
351
353
354 if (Initialize)
355 {
357 }
358 else
359 {
361 }
362
363 UserLeave();
364
365 TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
366
367 return Status;
368}
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:231
static void Initialize()
Definition: xlate.c:212

Referenced by DriverEntry().

◆ Win32kThreadCallback()

NTSTATUS APIENTRY Win32kThreadCallback ( PETHREAD  Thread,
PSW32THREADCALLOUTTYPE  Type 
)

Definition at line 881 of file main.c.

883{
885
887
889
891 {
894 }
895 else // if (Type == PsW32ThreadCalloutExit)
896 {
899 }
900
901 UserLeave();
902
903 return Status;
904}
Type
Definition: Type.h:7
@ PsW32ThreadCalloutInitialize
Definition: pstypes.h:499
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:457

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 DriverEntry(), and UserDeleteW32Thread().

◆ gusLanguageID

◆ hModuleWin

HANDLE hModuleWin

Definition at line 16 of file main.c.

Referenced by DriverEntry(), and UserRegisterSystemClasses().

◆ ppiScrnSaver

◆ Win32kNumberOfSysCalls

ULONG Win32kNumberOfSysCalls
extern

Definition at line 22 of file napi.h.

Referenced by DriverEntry().

◆ Win32kSSDT

ULONG_PTR Win32kSSDT[]
extern

Definition at line 9 of file napi.h.

Referenced by DriverEntry().

◆ Win32kSSPT

UCHAR Win32kSSPT[]
extern

Definition at line 15 of file napi.h.

Referenced by DriverEntry().