ReactOS 0.4.17-dev-806-gffa4164
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#include <winbase_undoc.h>
12
13#define NDEBUG
14#include <debug.h>
15#include <kdros.h>
16
18
21
22// TODO: Should be moved to some GDI header
27
28PSERVERINFO gpsi = NULL; // Global User Server Information.
29
32
33extern ULONG_PTR Win32kSSDT[];
34extern UCHAR Win32kSSPT[];
36
37#if DBG
38void
40DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
41{
42 GdiDbgPreServiceHook(ulSyscallId, pulArguments);
43 UserDbgPreServiceHook(ulSyscallId, pulArguments);
44}
45
48DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
49{
50 ulResult = GdiDbgPostServiceHook(ulSyscallId, ulResult);
51 ulResult = UserDbgPostServiceHook(ulSyscallId, ulResult);
52 return ulResult;
53}
54#endif
55
56
59 OUT PPROCESSINFO* W32Process)
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}
91
92/*
93 * Called from IntDereferenceProcessInfo
94 */
95VOID
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}
120
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}
173
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}
229
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 /* If we belong to a job that restricts the UI, join it now. A process is
295 normally assigned to its job while still suspended, i.e. before it ever
296 calls into win32k, so the kernel could not hand us over back then. */
297 Status = IntJobConnectProcess(ppiCurrent);
298 if (!NT_SUCCESS(Status))
299 {
300 ERR_CH(UserProcess, "IntJobConnectProcess failed, Status 0x%08lx\n", Status);
301 goto error;
302 }
303
304 return STATUS_SUCCESS;
305
306error:
307 ERR_CH(UserProcess, "InitProcessCallback failed! Freeing ppi 0x%p for PID:0x%lx\n",
308 ppiCurrent, HandleToUlong(Process->UniqueProcessId));
310 return Status;
311}
312
315{
316 PPROCESSINFO ppiCurrent, *pppi;
317
318 /* Get the Win32 Process */
319 ppiCurrent = PsGetProcessWin32Process(Process);
320 ASSERT(ppiCurrent);
321 ASSERT(ppiCurrent->peProcess == Process);
322
323 TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
324 ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
325
326 /* Leave the job we were restricted by, if any */
327 IntJobDisconnectProcess(ppiCurrent);
328
329 /* Remove it from the list */
330 pppi = &gppiList;
331 while (*pppi != NULL && *pppi != ppiCurrent)
332 {
333 pppi = &(*pppi)->ppiNext;
334 }
335 ASSERT(*pppi == ppiCurrent);
336 *pppi = ppiCurrent->ppiNext;
337
338 /* Cleanup GDI info */
340
341 /* Cleanup USER info */
343
344 /* The process is dying */
346 ppiCurrent->peProcess = NULL;
347
348 /* Finally, dereference */
349 IntDereferenceProcessInfo(ppiCurrent);
350
351 return STATUS_SUCCESS;
352}
353
358{
360
361 ASSERT(Process->Peb);
362
363 TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
364
366
367 if (Initialize)
368 {
370 }
371 else
372 {
374 }
375
376 UserLeave();
377
378 TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
379
380 return Status;
381}
382
383
384
387 OUT PTHREADINFO* W32Thread)
388{
389 PTHREADINFO ptiCurrent;
390
391 TRACE_CH(UserThread, "In AllocW32Thread(0x%p)\n", Thread);
392
393 /* Check that we were not called with an already existing Win32 thread info */
394 ptiCurrent = PsGetThreadWin32Thread(Thread);
395 NT_ASSERT(ptiCurrent == NULL);
396
397 /* Allocate a new Win32 thread info */
399 sizeof(*ptiCurrent),
401 if (ptiCurrent == NULL)
402 {
403 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
405 return STATUS_NO_MEMORY;
406 }
407
408 TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
409 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
410
411 RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
412
413 PsSetThreadWin32Thread(Thread, ptiCurrent, NULL);
415 IntReferenceThreadInfo(ptiCurrent);
416
417 *W32Thread = ptiCurrent;
418 return STATUS_SUCCESS;
419}
420
421/*
422 * Called from IntDereferenceThreadInfo
423 */
424VOID
426{
427 PPROCESSINFO ppi = pti->ppi;
428
429 TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
430
431 /* Free the message queue */
432 if (pti->MessageQueue)
433 {
435 }
436
438
439 ObDereferenceObject(pti->pEThread);
440
442
444
445 {
446 // Find another queue for mouse cursor.
447 MSG msg;
448 msg.message = WM_MOUSEMOVE;
449 msg.wParam = UserGetMouseButtonsState();
450 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
451 msg.pt = gpsi->ptCursor;
453 }
454}
455
458{
459 return STATUS_SUCCESS;
460}
461
464{
465 return STATUS_SUCCESS;
466}
467
470{
472 PCLIENTINFO pci;
473 PTHREADINFO ptiCurrent;
474 int i;
476 PTEB pTeb;
477 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
478 PKL pDefKL;
479 BOOLEAN bFirstThread;
480
481 Process = Thread->ThreadsProcess;
482
483 pTeb = NtCurrentTeb();
484 ASSERT(pTeb);
485
486 ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
487
488 /* Allocate a new Win32 thread info */
489 Status = AllocW32Thread(Thread, &ptiCurrent);
490 if (!NT_SUCCESS(Status))
491 {
492 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
494 return Status;
495 }
496
497 /* Initialize the THREADINFO */
498 ptiCurrent->pEThread = Thread;
499 ptiCurrent->ppi = PsGetProcessWin32Process(Process);
500 IntReferenceProcessInfo(ptiCurrent->ppi);
501 pTeb->Win32ThreadInfo = ptiCurrent;
502 ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
503 ptiCurrent->pcti = &ptiCurrent->cti;
504 bFirstThread = !(ptiCurrent->ppi->W32PF_flags & W32PF_THREADCONNECTED);
505
506 /* Mark the process as having threads */
507 ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
508
513 InitializeListHead(&ptiCurrent->PtiLink);
514 for (i = 0; i < NB_HOOKS; i++)
515 {
516 InitializeListHead(&ptiCurrent->aphkStart[i]);
517 }
518 ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
519 ptiCurrent->ppi->ptiList = ptiCurrent;
520 ptiCurrent->ppi->cThreads++;
521
522 ptiCurrent->hEventQueueClient = NULL;
523 Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
525 if (!NT_SUCCESS(Status))
526 {
527 ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
528 goto error;
529 }
532 (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
533 if (!NT_SUCCESS(Status))
534 {
535 ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
537 ptiCurrent->hEventQueueClient = NULL;
538 goto error;
539 }
540
541 ptiCurrent->pcti->timeLastRead = EngGetTickCount32();
542
543 ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
544 if (ptiCurrent->MessageQueue == NULL)
545 {
546 ERR_CH(UserThread, "Failed to allocate message loop\n");
548 goto error;
549 }
550
551 pDefKL = W32kGetDefaultKeyLayout();
552 UserAssignmentLock((PVOID*)&(ptiCurrent->KeyboardLayout), pDefKL);
553
554 ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
555
556 // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
557
558 /* CSRSS threads have some special features */
559 if (Process == gpepCSRSS || !gpepCSRSS)
561
562 /* A thread of a process that is in a job restricting the UI is restricted
563 from the moment it appears, not from the next time the job is touched */
564 if (ptiCurrent->ppi->W32PF_flags & W32PF_JOBRESTRICTED)
565 ptiCurrent->TIF_flags |= TIF_JOBRESTRICTED;
566
567 /* Initialize the CLIENTINFO */
568 pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
569 RtlZeroMemory(pci, sizeof(*pci));
570 pci->ppi = ptiCurrent->ppi;
571 pci->fsHooks = ptiCurrent->fsHooks;
572 pci->dwTIFlags = ptiCurrent->TIF_flags;
573 if (pDefKL)
574 {
575 pci->hKL = pDefKL->hkl;
576 pci->CodePage = pDefKL->CodePage;
577 }
578
579 /* Populate dwExpWinVer */
580 if (Process->Peb)
581 ptiCurrent->dwExpWinVer = RtlGetExpWinVer(Process->SectionBaseAddress);
582 else
583 ptiCurrent->dwExpWinVer = WINVER_WINNT4;
584 pci->dwExpWinVer = ptiCurrent->dwExpWinVer;
585
586 /* Need to pass the user Startup Information to the current process. */
587 if ( ProcessParams )
588 {
589 if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
590 {
591 if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
592 {
593 ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
594 ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
595 ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
596 ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
597 ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
598 ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
599 ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
600 }
601 }
602
603 if (bFirstThread)
604 {
605 /* Note: Only initialize once so it can be set back to 0 after being used */
606 if (ProcessParams->WindowFlags & STARTF_USEHOTKEY)
607 ptiCurrent->ppi->dwHotkey = HandleToUlong(ProcessParams->StandardInput);
608 /* TODO:
609 else if (ProcessParams->ShellInfo.Buffer)
610 ..->dwHotkey = ParseShellInfo(ProcessParams->ShellInfo.Buffer, L"hotkey.");
611 */
612
613 if (ProcessParams->WindowFlags & STARTF_SHELLPRIVATE)
614 {
615 /* We need to validate this handle because it can also be a HICON */
616 HMONITOR hMonitor = (HMONITOR)ProcessParams->StandardOutput;
617 if (hMonitor && UserGetMonitorObject(hMonitor))
618 ptiCurrent->ppi->hMonitor = hMonitor;
619 }
620 }
621 }
622
623 /*
624 * Assign a default window station and desktop to the process.
625 * Do not try to open a desktop or window station before the very first
626 * (interactive) window station has been created by Winlogon.
627 */
628 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
629 ptiCurrent->ppi->hdeskStartup == NULL &&
631 {
632 HWINSTA hWinSta = NULL;
633 HDESK hDesk = NULL;
634 UNICODE_STRING DesktopPath;
635 PDESKTOP pdesk;
636
637 /*
638 * Inherit the thread desktop and process window station (if not yet inherited)
639 * from the process startup info structure. See documentation of CreateProcess().
640 */
642 if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
643 {
644 Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
645 }
646 if (!NT_SUCCESS(Status))
647 {
648 RtlInitUnicodeString(&DesktopPath, NULL);
649 }
650
652 &DesktopPath,
653 !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
654 &hWinSta,
655 &hDesk);
656
657 if (DesktopPath.Buffer)
658 ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
659
660 if (!NT_SUCCESS(Status))
661 {
662 ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
663 goto error;
664 }
665
666 if (!UserSetProcessWindowStation(hWinSta))
667 {
669 ERR_CH(UserThread, "Failed to set initial process winsta\n");
670 goto error;
671 }
672
673 /* Validate the new desktop */
674 Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
675 if (!NT_SUCCESS(Status))
676 {
677 ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
678 goto error;
679 }
680
681 /* Store the parsed desktop as the initial desktop */
682 ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
683 ASSERT(Process->UniqueProcessId != gpidLogon);
684 ptiCurrent->ppi->hdeskStartup = hDesk;
685 ptiCurrent->ppi->rpdeskStartup = pdesk;
686 }
687
688 if (ptiCurrent->ppi->hdeskStartup != NULL)
689 {
690 if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
691 {
692 ERR_CH(UserThread, "Failed to set thread desktop\n");
694 goto error;
695 }
696 }
697
698 /* Mark the thread as fully initialized */
699 ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
700
701 if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
702 (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
703 {
705 }
706 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
707
708 /* Create the default input context */
709 if (IS_IMM_MODE())
710 {
712 }
713
714 /* Last things to do only if we are not a SYSTEM or CSRSS thread */
715 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
716 {
717 /* Callback to User32 Client Thread Setup */
718 TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
720 if (!NT_SUCCESS(Status))
721 {
722 ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
723 goto error;
724 }
725 TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
726 }
727 else
728 {
729 TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
730 }
731
732 TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
733 return STATUS_SUCCESS;
734
735error:
736 ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
737 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
739 return Status;
740}
741
742VOID
744
746NTAPI
748{
749 PTHREADINFO *ppti;
751 PPROCESSINFO ppiCurrent;
753 PTHREADINFO ptiCurrent;
754 PWINDOWLIST pwl, pwlNext;
755
756 Process = Thread->ThreadsProcess;
757
758 /* Get the Win32 Thread */
759 ptiCurrent = PsGetThreadWin32Thread(Thread);
760 ASSERT(ptiCurrent);
761
762 TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
763
764 ptiCurrent->TIF_flags |= TIF_INCLEANUP;
765 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
766
767 ppiCurrent = ptiCurrent->ppi;
768 ASSERT(ppiCurrent);
769
770 IsRemoveAttachThread(ptiCurrent);
771
772 if (gpwlList)
773 {
774 for (pwl = gpwlList; pwl; pwl = pwlNext)
775 {
776 pwlNext = pwl->pNextList;
777 if (pwl->pti == ptiCurrent)
778 IntFreeHwndList(pwl);
779 }
780 }
781
782 ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
783 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
784
786
787 /* Decrement thread count and check if its 0 */
788 ppiCurrent->cThreads--;
789
790 if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
791 {
792 /* Do now some process cleanup that requires a valid win32 thread */
793 if (ptiCurrent->ppi->cThreads == 0)
794 {
795 /* Check if we have registered the user api hook */
796 if (ptiCurrent->ppi == ppiUahServer)
797 {
798 /* Unregister the api hook */
800 }
801
802 /* Notify logon application to restart shell if needed */
803 if (ptiCurrent->pDeskInfo)
804 {
805 if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
806 {
808
809 TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
810
814 ExitCode);
815
816 ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
817 }
818 }
819 }
820
821 DceFreeThreadDCE(ptiCurrent);
822 DestroyTimersForThread(ptiCurrent);
824 UnregisterThreadHotKeys(ptiCurrent);
825
827 {
828 DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
829 ASSERT(FALSE);
830 return STATUS_UNSUCCESSFUL;
831 }
833
834 if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
835 ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
836 {
837 TRACE_CH(UserThread, "DestroyProcessClasses\n");
838 /* no process windows should exist at this point, or the function will assert! */
839 DestroyProcessClasses(ppiCurrent);
840 ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
841 }
842
843 IntBlockInput(ptiCurrent, FALSE);
844 IntCleanupThreadCallbacks(ptiCurrent);
845
846 /* cleanup user object references stack */
847 psle = PopEntryList(&ptiCurrent->ReferencesList);
848 while (psle)
849 {
851 TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
853
854 psle = PopEntryList(&ptiCurrent->ReferencesList);
855#if DBG
856 ptiCurrent->cRefObjectCo--;
857#endif
858 }
859 }
860
861 if (ptiCurrent->cEnterCount)
862 {
864 ptiCurrent->cEnterCount = 0;
865 }
866
867 /* Find the THREADINFO in the PROCESSINFO's list */
868 ppti = &ppiCurrent->ptiList;
869 while (*ppti != NULL && *ppti != ptiCurrent)
870 {
871 ppti = &((*ppti)->ptiSibling);
872 }
873
874 /* we must have found it */
875 ASSERT(*ppti == ptiCurrent);
876
877 /* Remove it from the list */
878 *ppti = ptiCurrent->ptiSibling;
879
880 if (!UserAssignmentUnlock((PVOID*)&(ptiCurrent->KeyboardLayout)))
881 ptiCurrent->pClientInfo->hKL = NULL;
882
883 if (gptiForeground == ptiCurrent)
884 {
885// IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
886// IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
887
889 }
890
891 /* Restore display mode when we are the last thread, and we changed the display mode */
892 if (ppiCurrent->cThreads == 0)
893 UserDisplayNotifyShutdown(ppiCurrent);
894
895
896 // Fixes CORE-6384 & CORE-7030.
897/* if (ptiLastInput == ptiCurrent)
898 {
899 if (!ppiCurrent->ptiList)
900 ptiLastInput = gptiForeground;
901 else
902 ptiLastInput = ppiCurrent->ptiList;
903 ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
904 }
905*/
906 TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
907
909
910 if (ptiCurrent->hEventQueueClient != NULL)
911 {
914 }
915 ptiCurrent->hEventQueueClient = NULL;
916
917 ASSERT(ptiCurrent->cRefObjectCo == 0);
918
919 /* The thread is dying */
920 PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
921
922 /* Dereference the THREADINFO */
923 IntDereferenceThreadInfo(ptiCurrent);
924
925 return STATUS_SUCCESS;
926}
927
932{
934
936
938
940 {
943 }
944 else // if (Type == PsW32ThreadCalloutExit)
945 {
948 }
949
950 UserLeave();
951
952 return Status;
953}
954
955_Function_class_(DRIVER_UNLOAD)
958{
959 // TODO: Do more cleanup!
960
965}
966
967// Return on failure
968#define NT_ROF(x) \
969{ \
970 Status = (x); \
971 if (!NT_SUCCESS(Status)) \
972 { \
973 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
974 return Status; \
975 } \
976}
977
978// Lock & return on failure
979#define USERLOCK_AND_ROF(x) \
980{ \
981 UserEnterExclusive(); \
982 Status = (x); \
983 UserLeave(); \
984 if (!NT_SUCCESS(Status)) \
985 { \
986 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
987 return Status; \
988 } \
989}
990
991
992
993/*
994 * This definition doesn't work
995 */
996CODE_SEG("INIT")
1002{
1005 WIN32_CALLOUTS_FPNS CalloutData = {0};
1006 PVOID GlobalUserHeapBase = NULL;
1007
1008 /*
1009 * Register user mode call interface
1010 * (system service table index = 1)
1011 */
1013 NULL,
1015 Win32kSSPT,
1016 1);
1017 if (Result == FALSE)
1018 {
1019 DPRINT1("Adding system services failed!\n");
1020 return STATUS_UNSUCCESSFUL;
1021 }
1022
1024 DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
1025
1026 DriverObject->DriverUnload = DriverUnload;
1027
1028 /* Register Object Manager Callbacks */
1030 CalloutData.ThreadCallout = Win32kThreadCallback;
1031 // CalloutData.GlobalAtomTableCallout = NULL;
1034 CalloutData.JobCallout = Win32kJobCallout;
1041 // CalloutData.WindowStationCloseProcedure = NULL;
1044 // CalloutData.WindowStationOpenProcedure = NULL;
1045
1046 /* Register our per-process and per-thread structures. */
1047 PsEstablishWin32Callouts(&CalloutData);
1048
1049 /* Register service hook callbacks */
1050#if DBG && defined(KDBG)
1051 KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
1052 KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
1053#endif
1054
1055 /* Create the global USER heap */
1057 &GlobalUserHeapBase,
1058 1 * 1024 * 1024); /* FIXME: 1 MB for now... */
1059 if (GlobalUserHeap == NULL)
1060 {
1061 DPRINT1("Failed to initialize the global heap!\n");
1062 return STATUS_UNSUCCESSFUL;
1063 }
1064
1065 /* Init the global user lock */
1067
1068 /* Lock while we use the heap (UserHeapAlloc asserts on this) */
1070
1071 /* Allocate global server info structure */
1072 gpsi = UserHeapAlloc(sizeof(*gpsi));
1073 UserLeave();
1074 if (!gpsi)
1075 {
1076 DPRINT1("Failed allocate server info structure!\n");
1077 return STATUS_UNSUCCESSFUL;
1078 }
1079
1080 RtlZeroMemory(gpsi, sizeof(*gpsi));
1081 DPRINT("Global Server Data -> %p\n", gpsi);
1082
1085
1086 /* Create stock objects, ie. precreated objects commonly
1087 used by win32 applications */
1090
1095 NT_ROF(InitDcImpl());
1104
1105 return STATUS_SUCCESS;
1106}
1107
1108/* EOF */
#define CODE_SEG(...)
Type
Definition: Type.h:7
#define VOID
Definition: acefi.h:82
unsigned char BOOLEAN
Definition: actypes.h:127
#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:73
#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
PTHREADINFO gptiForeground
Definition: focus.c:15
#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 short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
VOID FASTCALL FreeFontSupport(VOID)
Definition: freetype.c:991
_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:24
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:563
#define TIF_CSRSSTHREAD
Definition: ntuser.h:269
#define TIF_INCLEANUP
Definition: ntuser.h:266
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:272
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:290
ULONG RtlGetExpWinVer(_In_ PVOID BaseAddress)
Definition: image.c:20
#define IS_IMM_MODE()
Definition: ntuser.h:1216
#define TIF_JOBRESTRICTED
Definition: ntuser.h:295
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:268
struct _CLIENTINFO * PCLIENTINFO
#define NB_HOOKS
Definition: ntuser.h:130
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:271
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:1223
NTSTATUS NTAPI PsSetProcessWin32Process(_Inout_ PEPROCESS Process, _In_opt_ PVOID Win32Process, _In_opt_ PVOID OldWin32Process)
Definition: process.c:1287
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
Definition: process.c:1083
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
Definition: process.c:1093
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:113
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:216
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
Definition: hook.c:206
PPROCESSINFO ppiUahServer
Definition: hook.c:24
PIMC FASTCALL UserCreateInputContext(_In_ ULONG_PTR dwClientImcData)
Definition: ime.c:1651
VOID FASTCALL IntFreeImeHotKeys(VOID)
Definition: ime.c:345
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
Definition: winsta.c:99
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
Definition: winsta.c:216
NTSTATUS NTAPI InitWindowStationImpl(VOID)
Definition: winsta.c:35
HWND hwndSAS
Definition: winsta.c:24
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
Definition: winsta.c:151
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1614
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
ERESOURCE UserLock
Definition: ntuser.c:18
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3406
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:493
#define TAG_STRING
Definition: oslist.h:22
#define STARTF_USEHOTKEY
Definition: pch.h:41
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
Entry
Definition: section.c:5216
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE gpidLogon
Definition: simplecall.c:15
#define DPRINT
Definition: sndvol32.h:73
USHORT CodePage
Definition: ntuser.h:344
HKL hKL
Definition: ntuser.h:343
ULONG fsHooks
Definition: ntuser.h:332
DWORD dwTIFlags
Definition: ntuser.h:328
DWORD dwExpWinVer
Definition: ntuser.h:325
struct _PROCESSINFO * ppi
Definition: ntuser.h:350
HANDLE UniqueThread
Definition: compat.h:826
CLIENT_ID Cid
Definition: pstypes.h:1253
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
INT cThreads
Definition: win32.h:264
PPROCESSINFO ppiNext
Definition: win32.h:263
USERSTARTUPINFO usi
Definition: win32.h:280
HDESK hdeskStartup
Definition: win32.h:265
HMONITOR hMonitor
Definition: win32.h:272
LIST_ENTRY DriverObjListHead
Definition: win32.h:291
PTHREADINFO ptiList
Definition: win32.h:258
struct _DESKTOP * rpdeskStartup
Definition: win32.h:260
FAST_MUTEX DriverObjListLock
Definition: win32.h:290
DWORD dwHotkey
Definition: win32.h:271
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1582
Definition: ntbasedef.h:640
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:89
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:94
DWORD dwExpWinVer
Definition: win32.h:113
INT cEnterCount
Definition: win32.h:136
PTHREADINFO ptiSibling
Definition: win32.h:117
ULONG fsHooks
Definition: win32.h:118
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:138
CLIENTTHREADINFO cti
Definition: win32.h:145
struct _CLIENTINFO * pClientInfo
Definition: win32.h:95
PKEVENT pEventQueueServer
Definition: win32.h:126
LIST_ENTRY W32CallbackListHead
Definition: win32.h:157
struct tagIMC * spDefaultImc
Definition: win32.h:133
struct tagKL * KeyboardLayout
Definition: win32.h:91
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
Definition: win32.h:144
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:92
HANDLE hEventQueueClient
Definition: win32.h:124
FLONG TIF_flags
Definition: win32.h:96
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:158
LIST_ENTRY SentMessagesListHead
Definition: win32.h:101
LIST_ENTRY WindowListHead
Definition: win32.h:156
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:90
LIST_ENTRY PtiLink
Definition: win32.h:127
Definition: object.h:4
PKWIN32_POWEREVENT_CALLOUT PowerEventCallout
Definition: pstypes.h:1825
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1833
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1822
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1835
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1836
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1830
PKWIN32_POWERSTATE_CALLOUT PowerStateCallout
Definition: pstypes.h:1826
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1829
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1832
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1831
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1823
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1828
PKWIN32_JOB_CALLOUT JobCallout
Definition: pstypes.h:1827
Definition: send.c:48
Definition: input.h:28
USHORT CodePage
Definition: input.h:37
HKL hkl
Definition: input.h:33
WORD wShowWindow
Definition: win32.h:221
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3622
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
unsigned char UCHAR
Definition: typedefs.h:53
#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:117
#define STARTF_SCREENSAVER
Definition: undocuser.h:167
#define WM_LOGONNOTIFY
Definition: undocuser.h:39
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:166
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:173
#define W32PF_APPSTARTING
Definition: win32.h:10
#define W32PF_TERMINATED
Definition: win32.h:16
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:183
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
#define IntReferenceThreadInfo(pti)
Definition: win32.h:168
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:188
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 W32PF_JOBRESTRICTED
Definition: win32.h:36
#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:684
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:210
NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:276
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:251
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1265
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:575
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:234
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:179
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3400
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:135
BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO pti)
Definition: input.c:478
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:416
NTSTATUS NTAPI InitInputImpl(VOID)
Definition: input.c:401
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:512
NTSTATUS NTAPI Win32kJobCallout(_In_ PWIN32_JOBCALLOUT_PARAMETERS Parameters)
Definition: job.c:476
NTSTATUS NTAPI InitKeyboardImpl(VOID)
Definition: keyboard.c:48
ULONG_PTR Win32kSSDT[]
Definition: napi.h:9
ULONG Win32kNumberOfSysCalls
Definition: napi.h:30
NTSTATUS ExitProcessCallback(PEPROCESS Process)
Definition: main.c:314
VOID UserDeleteW32Thread(PTHREADINFO pti)
Definition: main.c:425
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:940
PPROCESSINFO gppiList
Definition: main.c:31
#define USERLOCK_AND_ROF(x)
Definition: main.c:979
NTSTATUS UserThreadCreate(PETHREAD Thread)
Definition: main.c:457
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:231
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
Definition: main.c:96
NTSTATUS UserThreadDestroy(PETHREAD Thread)
Definition: main.c:463
HANDLE hModuleWin
Definition: main.c:17
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:356
NTSTATUS GdiThreadDestroy(PETHREAD Thread)
Definition: init.c:73
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:930
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:968
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:747
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:46
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:469
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:386
PSERVERINFO gpsi
Definition: main.c:28
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:175
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
Definition: main.c:58
NTSTATUS UserProcessCreate(PEPROCESS Process)
Definition: main.c:122
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:780
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
Definition: misc.c:787
PMONITOR NTAPI UserGetMonitorObject(IN HMONITOR hMonitor)
Definition: monitor.c:74
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:777
PVOID FASTCALL UserAssignmentLock(PVOID *ppvObj, PVOID pvNew)
Definition: object.c:861
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:647
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserAssignmentUnlock(PVOID *ppvObj)
Definition: object.c:881
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:1467
PWINDOWLIST gpwlCache
Definition: window.c:19
PWINDOWLIST gpwlList
Definition: window.c:18
NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
#define WINVER_WINNT4
Definition: window.h:57
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
#define WM_MOUSEMOVE
Definition: winuser.h:1803
_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