ReactOS 0.4.16-dev-1146-gc477928
main.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Driver entry and initialization of win32k
5 * FILE: win32ss/user/ntuser/main.c
6 * PROGRAMER:
7 */
8
9#include <win32k.h>
10#include <napi.h>
11
12#define NDEBUG
13#include <debug.h>
14#include <kdros.h>
15
16#ifndef STARTF_USEHOTKEY
17#define STARTF_USEHOTKEY 0x0200
18#endif
19#ifndef STARTF_SHELLPRIVATE
20#define STARTF_SHELLPRIVATE 0x0400
21#endif
22
24
27
28// TODO: Should be moved to some GDI header
33
34PSERVERINFO gpsi = NULL; // Global User Server Information.
35
38
39extern ULONG_PTR Win32kSSDT[];
40extern UCHAR Win32kSSPT[];
42
43#if DBG
44void
46DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
47{
48 GdiDbgPreServiceHook(ulSyscallId, pulArguments);
49 UserDbgPreServiceHook(ulSyscallId, pulArguments);
50}
51
54DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
55{
56 ulResult = GdiDbgPostServiceHook(ulSyscallId, ulResult);
57 ulResult = UserDbgPostServiceHook(ulSyscallId, ulResult);
58 return ulResult;
59}
60#endif
61
62
65 OUT PPROCESSINFO* W32Process)
66{
67 PPROCESSINFO ppiCurrent;
68
69 TRACE_CH(UserProcess, "In AllocW32Process(0x%p)\n", Process);
70
71 /* Check that we were not called with an already existing Win32 process info */
73 if (ppiCurrent) return STATUS_SUCCESS;
74
75 /* Allocate a new Win32 process info */
77 sizeof(*ppiCurrent),
79 if (ppiCurrent == NULL)
80 {
81 ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
82 HandleToUlong(Process->UniqueProcessId));
83 return STATUS_NO_MEMORY;
84 }
85
86 TRACE_CH(UserProcess, "Allocated ppi 0x%p for PID:0x%lx\n",
87 ppiCurrent, HandleToUlong(Process->UniqueProcessId));
88
89 RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
90
92 IntReferenceProcessInfo(ppiCurrent);
93
94 *W32Process = ppiCurrent;
95 return STATUS_SUCCESS;
96}
97
98/*
99 * Called from IntDereferenceProcessInfo
100 */
101VOID
104{
105 if (ppiCurrent->InputIdleEvent)
106 {
107 /* Free the allocated memory */
108 ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
109 }
110
111 /* Close the startup desktop */
112 if (ppiCurrent->rpdeskStartup)
113 ObDereferenceObject(ppiCurrent->rpdeskStartup);
114
115#if DBG
116 if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
117 {
118 TRACE_PPI(ppiCurrent, UserObj, "Dumping user handles now that process info %p is gets freed.\n", ppiCurrent);
120 }
121#endif
122
123 /* Free the PROCESSINFO */
125}
126
129{
131 ASSERT(ppiCurrent);
132
135
136 {
138
139 /* Allocate memory for the event structure */
141 sizeof(*Event),
143 if (Event)
144 {
145 /* Initialize the kernel event */
148 FALSE);
149 }
150 else
151 {
152 /* Out of memory */
153 DPRINT("CreateEvent() failed\n");
154 KeBugCheck(0);
155 }
156
157 /* Set the event */
158 ppiCurrent->InputIdleEvent = Event;
159 KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
160 }
161
162 ppiCurrent->peProcess = Process;
163 ppiCurrent->W32Pid = HandleToUlong(PsGetProcessId(Process));
164
165 /* Setup process flags */
166 ppiCurrent->W32PF_flags |= W32PF_PROCESSCONNECTED;
167 if (Process->Peb->ProcessParameters &&
168 (Process->Peb->ProcessParameters->WindowFlags & STARTF_SCREENSAVER))
169 {
170 ppiScrnSaver = ppiCurrent;
171 ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
172 }
173
174 // FIXME: check if this process is allowed.
175 ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting application will get it toggled off.
176
177 return STATUS_SUCCESS;
178}
179
182{
184 ASSERT(ppiCurrent);
185
186 if (ppiScrnSaver == ppiCurrent)
188
190
191 if (gpwlCache)
192 {
194 gpwlCache = NULL;
195 }
196
197 /* Destroy user objects */
199
200 TRACE_CH(UserProcess, "Freeing ppi 0x%p\n", ppiCurrent);
201#if DBG
202 if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
203 {
204 TRACE_CH(UserObj, "Dumping user handles at the end of the process %s (Info %p).\n",
205 ppiCurrent->peProcess->ImageFileName, ppiCurrent);
207 }
208#endif
209
210 /* Remove it from the list of GUI apps */
212
213 /*
214 * Deregister logon application automatically
215 */
216 if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
217 gpidLogon = 0;
218
219 /* Close the current window station */
221
222 if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
223
224 if (ppiCurrent->hdeskStartup)
225 {
226 ZwClose(ppiCurrent->hdeskStartup);
227 ppiCurrent->hdeskStartup = NULL;
228 }
229
230 /* Clean up the process icon cache */
231 IntCleanupCurIconCache(ppiCurrent);
232
233 return STATUS_SUCCESS;
234}
235
238{
240 PPROCESSINFO ppiCurrent;
241 PVOID KernelMapping = NULL, UserMapping = NULL;
242
243 /* We might be called with an already allocated win32 process */
244 ppiCurrent = PsGetProcessWin32Process(Process);
245 if (ppiCurrent != NULL)
246 {
247 /* There is no more to do for us (this is a success code!) */
249 }
250 // if (ppiCurrent->W32PF_flags & W32PF_PROCESSCONNECTED)
251 // return STATUS_ALREADY_WIN32;
252
253 /* Allocate a new Win32 process info */
254 Status = AllocW32Process(Process, &ppiCurrent);
255 if (!NT_SUCCESS(Status))
256 {
257 ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
258 HandleToUlong(Process->UniqueProcessId));
259 return Status;
260 }
261
262#if DBG
264#if defined(KDBG)
265 KdRosRegisterCliCallback(DbgGdiKdbgCliCallback);
266#endif
267#endif
268
269 /* Map the global user heap into the process */
270 Status = MapGlobalUserHeap(Process, &KernelMapping, &UserMapping);
271 if (!NT_SUCCESS(Status))
272 {
273 TRACE_CH(UserProcess, "Failed to map the global heap! 0x%x\n", Status);
274 goto error;
275 }
276
277 TRACE_CH(UserProcess, "InitProcessCallback -- We have KernelMapping 0x%p and UserMapping 0x%p with delta = 0x%x\n",
278 KernelMapping, UserMapping, (ULONG_PTR)KernelMapping - (ULONG_PTR)UserMapping);
279
280 /* Initialize USER process info */
282 if (!NT_SUCCESS(Status))
283 {
284 ERR_CH(UserProcess, "UserProcessCreate failed, Status 0x%08lx\n", Status);
285 goto error;
286 }
287
288 /* Initialize GDI process info */
290 if (!NT_SUCCESS(Status))
291 {
292 ERR_CH(UserProcess, "GdiProcessCreate failed, Status 0x%08lx\n", Status);
293 goto error;
294 }
295
296 /* Add the process to the global list */
297 ppiCurrent->ppiNext = gppiList;
298 gppiList = ppiCurrent;
299
300 return STATUS_SUCCESS;
301
302error:
303 ERR_CH(UserProcess, "InitProcessCallback failed! Freeing ppi 0x%p for PID:0x%lx\n",
304 ppiCurrent, HandleToUlong(Process->UniqueProcessId));
306 return Status;
307}
308
311{
312 PPROCESSINFO ppiCurrent, *pppi;
313
314 /* Get the Win32 Process */
315 ppiCurrent = PsGetProcessWin32Process(Process);
316 ASSERT(ppiCurrent);
317 ASSERT(ppiCurrent->peProcess == Process);
318
319 TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
320 ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
321
322 /* Remove it from the list */
323 pppi = &gppiList;
324 while (*pppi != NULL && *pppi != ppiCurrent)
325 {
326 pppi = &(*pppi)->ppiNext;
327 }
328 ASSERT(*pppi == ppiCurrent);
329 *pppi = ppiCurrent->ppiNext;
330
331 /* Cleanup GDI info */
333
334 /* Cleanup USER info */
336
337 /* The process is dying */
339 ppiCurrent->peProcess = NULL;
340
341 /* Finally, dereference */
342 IntDereferenceProcessInfo(ppiCurrent);
343
344 return STATUS_SUCCESS;
345}
346
351{
353
354 ASSERT(Process->Peb);
355
356 TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
357
359
360 if (Initialize)
361 {
363 }
364 else
365 {
367 }
368
369 UserLeave();
370
371 TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
372
373 return Status;
374}
375
376
377
380 OUT PTHREADINFO* W32Thread)
381{
382 PTHREADINFO ptiCurrent;
383
384 TRACE_CH(UserThread, "In AllocW32Thread(0x%p)\n", Thread);
385
386 /* Check that we were not called with an already existing Win32 thread info */
387 ptiCurrent = PsGetThreadWin32Thread(Thread);
388 NT_ASSERT(ptiCurrent == NULL);
389
390 /* Allocate a new Win32 thread info */
392 sizeof(*ptiCurrent),
394 if (ptiCurrent == NULL)
395 {
396 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
398 return STATUS_NO_MEMORY;
399 }
400
401 TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
402 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
403
404 RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
405
406 PsSetThreadWin32Thread(Thread, ptiCurrent, NULL);
408 IntReferenceThreadInfo(ptiCurrent);
409
410 *W32Thread = ptiCurrent;
411 return STATUS_SUCCESS;
412}
413
414/*
415 * Called from IntDereferenceThreadInfo
416 */
417VOID
419{
420 PPROCESSINFO ppi = pti->ppi;
421
422 TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
423
424 /* Free the message queue */
425 if (pti->MessageQueue)
426 {
428 }
429
431
432 ObDereferenceObject(pti->pEThread);
433
435
437
438 {
439 // Find another queue for mouse cursor.
440 MSG msg;
441 msg.message = WM_MOUSEMOVE;
442 msg.wParam = UserGetMouseButtonsState();
443 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
444 msg.pt = gpsi->ptCursor;
446 }
447}
448
451{
452 return STATUS_SUCCESS;
453}
454
457{
458 return STATUS_SUCCESS;
459}
460
463{
465 PCLIENTINFO pci;
466 PTHREADINFO ptiCurrent;
467 int i;
469 PTEB pTeb;
470 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
471 PKL pDefKL;
472 BOOLEAN bFirstThread;
473
474 Process = Thread->ThreadsProcess;
475
476 pTeb = NtCurrentTeb();
477 ASSERT(pTeb);
478
479 ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
480
481 /* Allocate a new Win32 thread info */
482 Status = AllocW32Thread(Thread, &ptiCurrent);
483 if (!NT_SUCCESS(Status))
484 {
485 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
487 return Status;
488 }
489
490 /* Initialize the THREADINFO */
491 ptiCurrent->pEThread = Thread;
492 ptiCurrent->ppi = PsGetProcessWin32Process(Process);
493 IntReferenceProcessInfo(ptiCurrent->ppi);
494 pTeb->Win32ThreadInfo = ptiCurrent;
495 ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
496 ptiCurrent->pcti = &ptiCurrent->cti;
497 bFirstThread = !(ptiCurrent->ppi->W32PF_flags & W32PF_THREADCONNECTED);
498
499 /* Mark the process as having threads */
500 ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
501
506 InitializeListHead(&ptiCurrent->PtiLink);
507 for (i = 0; i < NB_HOOKS; i++)
508 {
509 InitializeListHead(&ptiCurrent->aphkStart[i]);
510 }
511 ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
512 ptiCurrent->ppi->ptiList = ptiCurrent;
513 ptiCurrent->ppi->cThreads++;
514
515 ptiCurrent->hEventQueueClient = NULL;
516 Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
518 if (!NT_SUCCESS(Status))
519 {
520 ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
521 goto error;
522 }
525 (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
526 if (!NT_SUCCESS(Status))
527 {
528 ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
530 ptiCurrent->hEventQueueClient = NULL;
531 goto error;
532 }
533
534 ptiCurrent->pcti->timeLastRead = EngGetTickCount32();
535
536 ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
537 if (ptiCurrent->MessageQueue == NULL)
538 {
539 ERR_CH(UserThread, "Failed to allocate message loop\n");
541 goto error;
542 }
543
544 pDefKL = W32kGetDefaultKeyLayout();
545 UserAssignmentLock((PVOID*)&(ptiCurrent->KeyboardLayout), pDefKL);
546
547 ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
548
549 // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
550
551 /* CSRSS threads have some special features */
552 if (Process == gpepCSRSS || !gpepCSRSS)
554
555 /* Initialize the CLIENTINFO */
556 pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
557 RtlZeroMemory(pci, sizeof(*pci));
558 pci->ppi = ptiCurrent->ppi;
559 pci->fsHooks = ptiCurrent->fsHooks;
560 pci->dwTIFlags = ptiCurrent->TIF_flags;
561 if (pDefKL)
562 {
563 pci->hKL = pDefKL->hkl;
564 pci->CodePage = pDefKL->CodePage;
565 }
566
567 /* Populate dwExpWinVer */
568 if (Process->Peb)
569 ptiCurrent->dwExpWinVer = RtlGetExpWinVer(Process->SectionBaseAddress);
570 else
571 ptiCurrent->dwExpWinVer = WINVER_WINNT4;
572 pci->dwExpWinVer = ptiCurrent->dwExpWinVer;
573
574 /* Need to pass the user Startup Information to the current process. */
575 if ( ProcessParams )
576 {
577 if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
578 {
579 if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
580 {
581 ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
582 ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
583 ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
584 ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
585 ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
586 ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
587 ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
588 }
589 }
590
591 if (bFirstThread)
592 {
593 /* Note: Only initialize once so it can be set back to 0 after being used */
594 if (ProcessParams->WindowFlags & STARTF_USEHOTKEY)
595 ptiCurrent->ppi->dwHotkey = HandleToUlong(ProcessParams->StandardInput);
596 /* TODO:
597 else if (ProcessParams->ShellInfo.Buffer)
598 ..->dwHotkey = ParseShellInfo(ProcessParams->ShellInfo.Buffer, L"hotkey.");
599 */
600
601 if (ProcessParams->WindowFlags & STARTF_SHELLPRIVATE)
602 {
603 /* We need to validate this handle because it can also be a HICON */
604 HMONITOR hMonitor = (HMONITOR)ProcessParams->StandardOutput;
605 if (hMonitor && UserGetMonitorObject(hMonitor))
606 ptiCurrent->ppi->hMonitor = hMonitor;
607 }
608 }
609 }
610
611 /*
612 * Assign a default window station and desktop to the process.
613 * Do not try to open a desktop or window station before the very first
614 * (interactive) window station has been created by Winlogon.
615 */
616 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
617 ptiCurrent->ppi->hdeskStartup == NULL &&
619 {
620 HWINSTA hWinSta = NULL;
621 HDESK hDesk = NULL;
622 UNICODE_STRING DesktopPath;
623 PDESKTOP pdesk;
624
625 /*
626 * Inherit the thread desktop and process window station (if not yet inherited)
627 * from the process startup info structure. See documentation of CreateProcess().
628 */
630 if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
631 {
632 Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
633 }
634 if (!NT_SUCCESS(Status))
635 {
636 RtlInitUnicodeString(&DesktopPath, NULL);
637 }
638
640 &DesktopPath,
641 !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
642 &hWinSta,
643 &hDesk);
644
645 if (DesktopPath.Buffer)
646 ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
647
648 if (!NT_SUCCESS(Status))
649 {
650 ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
651 goto error;
652 }
653
654 if (!UserSetProcessWindowStation(hWinSta))
655 {
657 ERR_CH(UserThread, "Failed to set initial process winsta\n");
658 goto error;
659 }
660
661 /* Validate the new desktop */
662 Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
663 if (!NT_SUCCESS(Status))
664 {
665 ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
666 goto error;
667 }
668
669 /* Store the parsed desktop as the initial desktop */
670 ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
671 ASSERT(Process->UniqueProcessId != gpidLogon);
672 ptiCurrent->ppi->hdeskStartup = hDesk;
673 ptiCurrent->ppi->rpdeskStartup = pdesk;
674 }
675
676 if (ptiCurrent->ppi->hdeskStartup != NULL)
677 {
678 if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
679 {
680 ERR_CH(UserThread, "Failed to set thread desktop\n");
682 goto error;
683 }
684 }
685
686 /* Mark the thread as fully initialized */
687 ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
688
689 if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
690 (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
691 {
693 }
694 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
695
696 /* Create the default input context */
697 if (IS_IMM_MODE())
698 {
700 }
701
702 /* Last things to do only if we are not a SYSTEM or CSRSS thread */
703 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
704 {
705 /* Callback to User32 Client Thread Setup */
706 TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
708 if (!NT_SUCCESS(Status))
709 {
710 ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
711 goto error;
712 }
713 TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
714 }
715 else
716 {
717 TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
718 }
719
720 TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
721 return STATUS_SUCCESS;
722
723error:
724 ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
725 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
727 return Status;
728}
729
730VOID
732
733// Win: xxxDestroyThreadInfo
735NTAPI
737{
738 PTHREADINFO *ppti;
740 PPROCESSINFO ppiCurrent;
742 PTHREADINFO ptiCurrent;
743 PWINDOWLIST pwl, pwlNext;
744
745 Process = Thread->ThreadsProcess;
746
747 /* Get the Win32 Thread */
748 ptiCurrent = PsGetThreadWin32Thread(Thread);
749 ASSERT(ptiCurrent);
750
751 TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
752
753 ptiCurrent->TIF_flags |= TIF_INCLEANUP;
754 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
755
756 ppiCurrent = ptiCurrent->ppi;
757 ASSERT(ppiCurrent);
758
759 IsRemoveAttachThread(ptiCurrent);
760
761 if (gpwlList)
762 {
763 for (pwl = gpwlList; pwl; pwl = pwlNext)
764 {
765 pwlNext = pwl->pNextList;
766 if (pwl->pti == ptiCurrent)
767 IntFreeHwndList(pwl);
768 }
769 }
770
771 ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
772 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
773
775
776 /* Decrement thread count and check if its 0 */
777 ppiCurrent->cThreads--;
778
779 if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
780 {
781 /* Do now some process cleanup that requires a valid win32 thread */
782 if (ptiCurrent->ppi->cThreads == 0)
783 {
784 /* Check if we have registered the user api hook */
785 if (ptiCurrent->ppi == ppiUahServer)
786 {
787 /* Unregister the api hook */
789 }
790
791 /* Notify logon application to restart shell if needed */
792 if (ptiCurrent->pDeskInfo)
793 {
794 if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
795 {
797
798 TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
799
803 ExitCode);
804
805 ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
806 }
807 }
808 }
809
810 DceFreeThreadDCE(ptiCurrent);
811 DestroyTimersForThread(ptiCurrent);
813 UnregisterThreadHotKeys(ptiCurrent);
814
816 {
817 DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
818 ASSERT(FALSE);
819 return STATUS_UNSUCCESSFUL;
820 }
822
823 if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
824 ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
825 {
826 TRACE_CH(UserThread, "DestroyProcessClasses\n");
827 /* no process windows should exist at this point, or the function will assert! */
828 DestroyProcessClasses(ppiCurrent);
829 ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
830 }
831
832 IntBlockInput(ptiCurrent, FALSE);
833 IntCleanupThreadCallbacks(ptiCurrent);
834
835 /* cleanup user object references stack */
836 psle = PopEntryList(&ptiCurrent->ReferencesList);
837 while (psle)
838 {
840 TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
842
843 psle = PopEntryList(&ptiCurrent->ReferencesList);
844#if DBG
845 ptiCurrent->cRefObjectCo--;
846#endif
847 }
848 }
849
850 if (ptiCurrent->cEnterCount)
851 {
853 ptiCurrent->cEnterCount = 0;
854 }
855
856 /* Find the THREADINFO in the PROCESSINFO's list */
857 ppti = &ppiCurrent->ptiList;
858 while (*ppti != NULL && *ppti != ptiCurrent)
859 {
860 ppti = &((*ppti)->ptiSibling);
861 }
862
863 /* we must have found it */
864 ASSERT(*ppti == ptiCurrent);
865
866 /* Remove it from the list */
867 *ppti = ptiCurrent->ptiSibling;
868
869 if (!UserAssignmentUnlock((PVOID*)&(ptiCurrent->KeyboardLayout)))
870 ptiCurrent->pClientInfo->hKL = NULL;
871
872 if (gptiForeground == ptiCurrent)
873 {
874// IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
875// IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
876
878 }
879
880 /* Restore display mode when we are the last thread, and we changed the display mode */
881 if (ppiCurrent->cThreads == 0)
882 UserDisplayNotifyShutdown(ppiCurrent);
883
884
885 // Fixes CORE-6384 & CORE-7030.
886/* if (ptiLastInput == ptiCurrent)
887 {
888 if (!ppiCurrent->ptiList)
889 ptiLastInput = gptiForeground;
890 else
891 ptiLastInput = ppiCurrent->ptiList;
892 ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
893 }
894*/
895 TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
896
898
899 if (ptiCurrent->hEventQueueClient != NULL)
900 {
903 }
904 ptiCurrent->hEventQueueClient = NULL;
905
906 ASSERT(ptiCurrent->cRefObjectCo == 0);
907
908 /* The thread is dying */
909 PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
910
911 /* Dereference the THREADINFO */
912 IntDereferenceThreadInfo(ptiCurrent);
913
914 return STATUS_SUCCESS;
915}
916
921{
923
925
927
929 {
932 }
933 else // if (Type == PsW32ThreadCalloutExit)
934 {
937 }
938
939 UserLeave();
940
941 return Status;
942}
943
944_Function_class_(DRIVER_UNLOAD)
947{
948 // TODO: Do more cleanup!
949
954}
955
956// Return on failure
957#define NT_ROF(x) \
958{ \
959 Status = (x); \
960 if (!NT_SUCCESS(Status)) \
961 { \
962 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
963 return Status; \
964 } \
965}
966
967// Lock & return on failure
968#define USERLOCK_AND_ROF(x) \
969{ \
970 UserEnterExclusive(); \
971 Status = (x); \
972 UserLeave(); \
973 if (!NT_SUCCESS(Status)) \
974 { \
975 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
976 return Status; \
977 } \
978}
979
980
981
982/*
983 * This definition doesn't work
984 */
985CODE_SEG("INIT")
991{
994 WIN32_CALLOUTS_FPNS CalloutData = {0};
995 PVOID GlobalUserHeapBase = NULL;
996
997 /*
998 * Register user mode call interface
999 * (system service table index = 1)
1000 */
1002 NULL,
1004 Win32kSSPT,
1005 1);
1006 if (Result == FALSE)
1007 {
1008 DPRINT1("Adding system services failed!\n");
1009 return STATUS_UNSUCCESSFUL;
1010 }
1011
1013 DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
1014
1015 DriverObject->DriverUnload = DriverUnload;
1016
1017 /* Register Object Manager Callbacks */
1019 CalloutData.ThreadCallout = Win32kThreadCallback;
1020 // CalloutData.GlobalAtomTableCallout = NULL;
1023 // CalloutData.JobCallout = NULL;
1030 // CalloutData.WindowStationCloseProcedure = NULL;
1033 // CalloutData.WindowStationOpenProcedure = NULL;
1034
1035 /* Register our per-process and per-thread structures. */
1036 PsEstablishWin32Callouts(&CalloutData);
1037
1038 /* Register service hook callbacks */
1039#if DBG && defined(KDBG)
1040 KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
1041 KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
1042#endif
1043
1044 /* Create the global USER heap */
1046 &GlobalUserHeapBase,
1047 1 * 1024 * 1024); /* FIXME: 1 MB for now... */
1048 if (GlobalUserHeap == NULL)
1049 {
1050 DPRINT1("Failed to initialize the global heap!\n");
1051 return STATUS_UNSUCCESSFUL;
1052 }
1053
1054 /* Init the global user lock */
1056
1057 /* Lock while we use the heap (UserHeapAlloc asserts on this) */
1059
1060 /* Allocate global server info structure */
1061 gpsi = UserHeapAlloc(sizeof(*gpsi));
1062 UserLeave();
1063 if (!gpsi)
1064 {
1065 DPRINT1("Failed allocate server info structure!\n");
1066 return STATUS_UNSUCCESSFUL;
1067 }
1068
1069 RtlZeroMemory(gpsi, sizeof(*gpsi));
1070 DPRINT("Global Server Data -> %p\n", gpsi);
1071
1074
1075 /* Create stock objects, ie. precreated objects commonly
1076 used by win32 applications */
1079
1084 NT_ROF(InitDcImpl());
1093
1094 return STATUS_SUCCESS;
1095}
1096
1097/* EOF */
#define CODE_SEG(...)
unsigned char BOOLEAN
Type
Definition: Type.h:7
#define VOID
Definition: acefi.h:82
#define msg(x)
Definition: auth_time.c:54
HANDLE HMONITOR
Definition: axextend.idl:431
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ERR_CH(ch, fmt,...)
Definition: debug.h:108
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:111
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1434
VOID ResetCsrProcess(VOID)
Definition: csr.c:29
PEPROCESS gpepCSRSS
Definition: csr.c:15
VOID ResetCsrApiPort(VOID)
Definition: csr.c:58
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
void FASTCALL DceFreeThreadDCE(PTHREADINFO)
Definition: windc.c:780
NTSTATUS NTAPI InitDcImpl(VOID)
Definition: dclife.c:53
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
DRIVER_INITIALIZE DriverEntry
Definition: main.c:9
#define __drv_freesMem(kind)
Definition: driverspecs.h:272
#define EngGetTickCount32()
Definition: eng.h:43
NTSTATUS NTAPI InitBrushImpl(VOID)
Definition: engbrush.c:31
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID FASTCALL FreeFontSupport(VOID)
Definition: freetype.c:1063
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
Definition: gdibatch.c:487
BOOLEAN NTAPI DbgGdiKdbgCliCallback(IN PCHAR pszCommand, IN ULONG argc, IN PCH argv[])
Definition: gdikdbgext.c:324
Status
Definition: gdiplustypes.h:25
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
BOOL FASTCALL co_IntGraphicsCheck(BOOL Create)
Definition: guicheck.c:52
enum _PSW32THREADCALLOUTTYPE PSW32THREADCALLOUTTYPE
@ PsW32ThreadCalloutInitialize
Definition: pstypes.h:500
#define TIF_CSRSSTHREAD
Definition: ntuser.h:266
#define TIF_INCLEANUP
Definition: ntuser.h:263
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:269
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:287
ULONG RtlGetExpWinVer(_In_ PVOID BaseAddress)
Definition: image.c:20
#define IS_IMM_MODE()
Definition: ntuser.h:1209
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:265
struct _CLIENTINFO * PCLIENTINFO
#define NB_HOOKS
Definition: ntuser.h:127
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:268
VOID FASTCALL CreateStockObjects(VOID)
Definition: stockobj.c:247
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
#define NtCurrentTeb
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
static DRIVER_UNLOAD DriverUnload
Definition: kbdclass.c:17
NTSTATUS NTAPI KdSystemDebugControl(_In_ SYSDBG_COMMAND Command, _In_reads_bytes_(InputBufferLength) PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_writes_bytes_(OutputBufferLength) PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Out_opt_ PULONG ReturnLength, _In_ KPROCESSOR_MODE PreviousMode)
Perform various queries to the kernel debugger.
Definition: kdapi.c:2217
NTSTATUS NTAPI InitLDEVImpl(VOID)
Definition: ldevobj.c:30
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
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:2423
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
Definition: msgqueue.c:2221
NTSTATUS NTAPI MsqInitializeImpl(VOID)
Definition: msgqueue.c:30
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2396
#define UserMode
Definition: asm.h:39
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define _Pre_notnull_
Definition: no_sal2.h:516
#define _Function_class_(n)
Definition: no_sal2.h:398
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
@ NotificationEvent
@ SynchronizationEvent
POBJECT_TYPE ExEventObjectType
Definition: event.c:18
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
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
Definition: process.c:1053
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
Definition: process.c:1063
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
VOID NTAPI PsEstablishWin32Callouts(IN PWIN32_CALLOUTS_FPNS CalloutData)
Definition: win32.c:112
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:141
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
Definition: hook.c:206
PPROCESSINFO ppiUahServer
Definition: hook.c:24
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
Definition: winsta.c:106
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
Definition: winsta.c:203
NTSTATUS NTAPI InitWindowStationImpl(VOID)
Definition: winsta.c:34
HWND hwndSAS
Definition: winsta.c:24
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
Definition: winsta.c:138
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1393
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
ERESOURCE UserLock
Definition: ntuser.c:18
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
void DbgUserDumpHandleTable()
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
#define TAG_STRING
Definition: oslist.h:22
NTSTATUS NTAPI InitPDEVImpl(VOID)
Definition: pdevobj.c:31
BOOLEAN NTAPI KeAddSystemServiceTable(IN PULONG_PTR Base, IN PULONG Count OPTIONAL, IN ULONG Limit, IN PUCHAR Number, IN ULONG Index)
Definition: procobj.c:908
static GENERIC_MAPPING UserMapping
Definition: samrpc.c:48
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE gpidLogon
Definition: simplecall.c:15
#define DPRINT
Definition: sndvol32.h:73
base of all file and directory entries
Definition: entries.h:83
USHORT CodePage
Definition: ntuser.h:340
HKL hKL
Definition: ntuser.h:339
ULONG fsHooks
Definition: ntuser.h:328
DWORD dwTIFlags
Definition: ntuser.h:324
DWORD dwExpWinVer
Definition: ntuser.h:321
struct _PROCESSINFO * ppi
Definition: ntuser.h:346
HANDLE UniqueThread
Definition: compat.h:826
CLIENT_ID Cid
Definition: pstypes.h:1129
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
INT cThreads
Definition: win32.h:263
PPROCESSINFO ppiNext
Definition: win32.h:262
USERSTARTUPINFO usi
Definition: win32.h:279
HDESK hdeskStartup
Definition: win32.h:264
HMONITOR hMonitor
Definition: win32.h:271
LIST_ENTRY DriverObjListHead
Definition: win32.h:290
PTHREADINFO ptiList
Definition: win32.h:257
struct _DESKTOP * rpdeskStartup
Definition: win32.h:259
FAST_MUTEX DriverObjListLock
Definition: win32.h:289
DWORD dwHotkey
Definition: win32.h:270
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1565
Definition: ntbasedef.h:636
Definition: compat.h:836
ULONG Win32ClientInfo[31]
Definition: compat.h:847
PVOID Win32ThreadInfo
Definition: compat.h:846
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:337
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:93
DWORD dwExpWinVer
Definition: win32.h:112
INT cEnterCount
Definition: win32.h:135
PTHREADINFO ptiSibling
Definition: win32.h:116
ULONG fsHooks
Definition: win32.h:117
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:137
CLIENTTHREADINFO cti
Definition: win32.h:144
struct _CLIENTINFO * pClientInfo
Definition: win32.h:94
PKEVENT pEventQueueServer
Definition: win32.h:125
LIST_ENTRY W32CallbackListHead
Definition: win32.h:156
struct tagIMC * spDefaultImc
Definition: win32.h:132
struct tagKL * KeyboardLayout
Definition: win32.h:90
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
Definition: win32.h:143
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:91
HANDLE hEventQueueClient
Definition: win32.h:123
FLONG TIF_flags
Definition: win32.h:95
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:157
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: object.h:4
PKWIN32_POWEREVENT_CALLOUT PowerEventCallout
Definition: pstypes.h:1687
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1695
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1684
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1697
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1698
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1692
PKWIN32_POWERSTATE_CALLOUT PowerStateCallout
Definition: pstypes.h:1688
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1691
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1694
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1693
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1685
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1690
Definition: send.c:48
Definition: input.h:27
USHORT CodePage
Definition: input.h:36
HKL hkl
Definition: input.h:32
WORD wShowWindow
Definition: win32.h:220
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3568
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:988
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define NTAPI
Definition: typedefs.h:36
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define LN_SHELL_EXITED
Definition: undocuser.h:116
#define STARTF_SCREENSAVER
Definition: undocuser.h:165
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:164
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:181
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
Definition: usrheap.c:266
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 _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
#define IntDereferenceThreadInfo(pti)
Definition: win32.h:172
#define W32PF_APPSTARTING
Definition: win32.h:10
#define W32PF_TERMINATED
Definition: win32.h:16
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:182
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
#define IntReferenceThreadInfo(pti)
Definition: win32.h:167
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:187
struct tagUSERSTARTUPINFO USERSTARTUPINFO
#define W32PF_CLASSESREGISTERED
Definition: win32.h:17
#define W32PF_SCREENSAVER
Definition: win32.h:26
#define W32PF_PROCESSCONNECTED
Definition: win32.h:19
#define W32PF_THREADCONNECTED
Definition: win32.h:18
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
Definition: win32kdebug.h:167
BOOL DbgInitDebugChannels()
#define TRACE_PPI(ppi, ch, fmt,...)
Definition: win32kdebug.h:184
NTSTATUS NTAPI InitDeviceImpl(VOID)
Definition: device.c:26
NTSTATUS NTAPI InitGdiHandleTable(void)
Definition: gdiobj.c:259
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:685
NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:66
VOID FASTCALL IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
Definition: callback.c:76
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID)
Definition: callback.c:959
void FASTCALL DestroyProcessClasses(PPROCESSINFO Process)
Definition: class.c:305
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:545
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
Definition: cursoricon.c:395
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
Definition: desktop.c:203
NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:269
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:244
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1254
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:568
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:227
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:172
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3298
PTHREADINFO gptiForeground
Definition: focus.c:15
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:135
VOID FASTCALL IntFreeImeHotKeys(VOID)
Definition: ime.c:326
PIMC FASTCALL UserCreateInputContext(ULONG_PTR dwClientImcData)
Definition: ime.c:1558
BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO pti)
Definition: input.c:437
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:375
NTSTATUS NTAPI InitInputImpl(VOID)
Definition: input.c:360
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:512
NTSTATUS NTAPI InitKeyboardImpl(VOID)
Definition: keyboard.c:33
ULONG_PTR Win32kSSDT[]
Definition: napi.h:9
ULONG Win32kNumberOfSysCalls
Definition: napi.h:30
NTSTATUS ExitProcessCallback(PEPROCESS Process)
Definition: main.c:310
VOID UserDeleteW32Thread(PTHREADINFO pti)
Definition: main.c:418
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:917
PPROCESSINFO gppiList
Definition: main.c:37
#define USERLOCK_AND_ROF(x)
Definition: main.c:968
NTSTATUS UserThreadCreate(PETHREAD Thread)
Definition: main.c:450
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:237
#define STARTF_SHELLPRIVATE
Definition: main.c:20
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
Definition: main.c:102
NTSTATUS UserThreadDestroy(PETHREAD Thread)
Definition: main.c:456
HANDLE hModuleWin
Definition: main.c:23
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:349
NTSTATUS GdiThreadDestroy(PETHREAD Thread)
Definition: init.c:73
PPROCESSINFO ppiScrnSaver
Definition: main.c:36
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:919
UCHAR Win32kSSPT[]
Definition: napi.h:19
NTSTATUS GdiProcessCreate(PEPROCESS Process)
Definition: init.c:17
NTSTATUS GdiThreadCreate(PETHREAD Thread)
Definition: init.c:67
#define NT_ROF(x)
Definition: main.c:957
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:736
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:46
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:462
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:379
#define STARTF_USEHOTKEY
Definition: main.c:17
PSERVERINFO gpsi
Definition: main.c:34
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:181
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
Definition: main.c:64
NTSTATUS UserProcessCreate(PEPROCESS Process)
Definition: main.c:128
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1395
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
Definition: misc.c:781
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
Definition: misc.c:788
PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR hMonitor)
Definition: monitor.c:74
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:754
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:839
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:860
NTSTATUS NTAPI IntWin32PowerManagementCleanup(VOID)
Cleanup procedure that frees all the allocated resources by the power manager. It is triggered during...
Definition: power.c:315
NTSTATUS NTAPI IntHandlePowerState(_In_ PWIN32_POWERSTATE_PARAMETERS pWin32PwrStateParams)
Handles an incoming power state callout from the NT power manager.
Definition: power.c:419
NTSTATUS NTAPI IntHandlePowerEvent(_In_ PWIN32_POWEREVENT_PARAMETERS pWin32PwrEventParams)
Handles an incoming power event callout from the NT power manager.
Definition: power.c:362
#define USERTAG_PROCESSINFO
Definition: tags.h:260
#define USERTAG_THREADINFO
Definition: tags.h:284
#define USERTAG_EVENT
Definition: tags.h:230
#define USERTAG_WINDOWLIST
Definition: tags.h:298
NTSTATUS NTAPI InitTimerImpl(VOID)
Definition: timer.c:600
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
Definition: timer.c:555
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1473
PWINDOWLIST gpwlCache
Definition: window.c:19
PWINDOWLIST gpwlList
Definition: window.c:18
#define WINVER_WINNT4
Definition: window.h:57
NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
#define MAKELPARAM(l, h)
Definition: winuser.h:4019
#define WM_MOUSEMOVE
Definition: winuser.h:1786
_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:409
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
#define NT_ASSERT
Definition: rtlfuncs.h:3327
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:243
static void Initialize()
Definition: xlate.c:212
unsigned char UCHAR
Definition: xmlstorage.h:181