ReactOS 0.4.15-dev-8207-gd73a838
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
17
20
21// TODO: Should be moved to some GDI header
26
27PSERVERINFO gpsi = NULL; // Global User Server Information.
28
31
32extern ULONG_PTR Win32kSSDT[];
33extern UCHAR Win32kSSPT[];
35
36#if DBG
37void
39DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
40{
41 GdiDbgPreServiceHook(ulSyscallId, pulArguments);
42 UserDbgPreServiceHook(ulSyscallId, pulArguments);
43}
44
47DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
48{
49 ulResult = GdiDbgPostServiceHook(ulSyscallId, ulResult);
50 ulResult = UserDbgPostServiceHook(ulSyscallId, ulResult);
51 return ulResult;
52}
53#endif
54
55
58 OUT PPROCESSINFO* W32Process)
59{
60 PPROCESSINFO ppiCurrent;
61
62 TRACE_CH(UserProcess, "In AllocW32Process(0x%p)\n", Process);
63
64 /* Check that we were not called with an already existing Win32 process info */
66 if (ppiCurrent) return STATUS_SUCCESS;
67
68 /* Allocate a new Win32 process info */
70 sizeof(*ppiCurrent),
72 if (ppiCurrent == NULL)
73 {
74 ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
75 HandleToUlong(Process->UniqueProcessId));
76 return STATUS_NO_MEMORY;
77 }
78
79 TRACE_CH(UserProcess, "Allocated ppi 0x%p for PID:0x%lx\n",
80 ppiCurrent, HandleToUlong(Process->UniqueProcessId));
81
82 RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
83
85 IntReferenceProcessInfo(ppiCurrent);
86
87 *W32Process = ppiCurrent;
88 return STATUS_SUCCESS;
89}
90
91/*
92 * Called from IntDereferenceProcessInfo
93 */
94VOID
97{
98 if (ppiCurrent->InputIdleEvent)
99 {
100 /* Free the allocated memory */
101 ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
102 }
103
104 /* Close the startup desktop */
105 if (ppiCurrent->rpdeskStartup)
106 ObDereferenceObject(ppiCurrent->rpdeskStartup);
107
108#if DBG
109 if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
110 {
111 TRACE_PPI(ppiCurrent, UserObj, "Dumping user handles now that process info %p is gets freed.\n", ppiCurrent);
113 }
114#endif
115
116 /* Free the PROCESSINFO */
118}
119
122{
124 ASSERT(ppiCurrent);
125
128
129 {
131
132 /* Allocate memory for the event structure */
134 sizeof(*Event),
136 if (Event)
137 {
138 /* Initialize the kernel event */
141 FALSE);
142 }
143 else
144 {
145 /* Out of memory */
146 DPRINT("CreateEvent() failed\n");
147 KeBugCheck(0);
148 }
149
150 /* Set the event */
151 ppiCurrent->InputIdleEvent = Event;
152 KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
153 }
154
155 ppiCurrent->peProcess = Process;
156 ppiCurrent->W32Pid = HandleToUlong(PsGetProcessId(Process));
157
158 /* Setup process flags */
159 ppiCurrent->W32PF_flags |= W32PF_PROCESSCONNECTED;
160 if (Process->Peb->ProcessParameters &&
161 (Process->Peb->ProcessParameters->WindowFlags & STARTF_SCREENSAVER))
162 {
163 ppiScrnSaver = ppiCurrent;
164 ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
165 }
166
167 // FIXME: check if this process is allowed.
168 ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting application will get it toggled off.
169
170 return STATUS_SUCCESS;
171}
172
175{
177 ASSERT(ppiCurrent);
178
179 if (ppiScrnSaver == ppiCurrent)
181
183
184 if (gpwlCache)
185 {
187 gpwlCache = NULL;
188 }
189
190 /* Destroy user objects */
192
193 TRACE_CH(UserProcess, "Freeing ppi 0x%p\n", ppiCurrent);
194#if DBG
195 if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
196 {
197 TRACE_CH(UserObj, "Dumping user handles at the end of the process %s (Info %p).\n",
198 ppiCurrent->peProcess->ImageFileName, ppiCurrent);
200 }
201#endif
202
203 /* Remove it from the list of GUI apps */
205
206 /*
207 * Deregister logon application automatically
208 */
209 if (gpidLogon == ppiCurrent->peProcess->UniqueProcessId)
210 gpidLogon = 0;
211
212 /* Close the current window station */
214
215 if (gppiInputProvider == ppiCurrent) gppiInputProvider = NULL;
216
217 if (ppiCurrent->hdeskStartup)
218 {
219 ZwClose(ppiCurrent->hdeskStartup);
220 ppiCurrent->hdeskStartup = NULL;
221 }
222
223 /* Clean up the process icon cache */
224 IntCleanupCurIconCache(ppiCurrent);
225
226 return STATUS_SUCCESS;
227}
228
231{
233 PPROCESSINFO ppiCurrent;
234 PVOID KernelMapping = NULL, UserMapping = NULL;
235
236 /* We might be called with an already allocated win32 process */
237 ppiCurrent = PsGetProcessWin32Process(Process);
238 if (ppiCurrent != NULL)
239 {
240 /* There is no more to do for us (this is a success code!) */
242 }
243 // if (ppiCurrent->W32PF_flags & W32PF_PROCESSCONNECTED)
244 // return STATUS_ALREADY_WIN32;
245
246 /* Allocate a new Win32 process info */
247 Status = AllocW32Process(Process, &ppiCurrent);
248 if (!NT_SUCCESS(Status))
249 {
250 ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
251 HandleToUlong(Process->UniqueProcessId));
252 return Status;
253 }
254
255#if DBG
257#if defined(KDBG)
258 KdRosRegisterCliCallback(DbgGdiKdbgCliCallback);
259#endif
260#endif
261
262 /* Map the global user heap into the process */
263 Status = MapGlobalUserHeap(Process, &KernelMapping, &UserMapping);
264 if (!NT_SUCCESS(Status))
265 {
266 TRACE_CH(UserProcess, "Failed to map the global heap! 0x%x\n", Status);
267 goto error;
268 }
269
270 TRACE_CH(UserProcess, "InitProcessCallback -- We have KernelMapping 0x%p and UserMapping 0x%p with delta = 0x%x\n",
271 KernelMapping, UserMapping, (ULONG_PTR)KernelMapping - (ULONG_PTR)UserMapping);
272
273 /* Initialize USER process info */
275 if (!NT_SUCCESS(Status))
276 {
277 ERR_CH(UserProcess, "UserProcessCreate failed, Status 0x%08lx\n", Status);
278 goto error;
279 }
280
281 /* Initialize GDI process info */
283 if (!NT_SUCCESS(Status))
284 {
285 ERR_CH(UserProcess, "GdiProcessCreate failed, Status 0x%08lx\n", Status);
286 goto error;
287 }
288
289 /* Add the process to the global list */
290 ppiCurrent->ppiNext = gppiList;
291 gppiList = ppiCurrent;
292
293 return STATUS_SUCCESS;
294
295error:
296 ERR_CH(UserProcess, "InitProcessCallback failed! Freeing ppi 0x%p for PID:0x%lx\n",
297 ppiCurrent, HandleToUlong(Process->UniqueProcessId));
299 return Status;
300}
301
304{
305 PPROCESSINFO ppiCurrent, *pppi;
306
307 /* Get the Win32 Process */
308 ppiCurrent = PsGetProcessWin32Process(Process);
309 ASSERT(ppiCurrent);
310 ASSERT(ppiCurrent->peProcess == Process);
311
312 TRACE_CH(UserProcess, "Destroying ppi 0x%p\n", ppiCurrent);
313 ppiCurrent->W32PF_flags |= W32PF_TERMINATED;
314
315 /* Remove it from the list */
316 pppi = &gppiList;
317 while (*pppi != NULL && *pppi != ppiCurrent)
318 {
319 pppi = &(*pppi)->ppiNext;
320 }
321 ASSERT(*pppi == ppiCurrent);
322 *pppi = ppiCurrent->ppiNext;
323
324 /* Cleanup GDI info */
326
327 /* Cleanup USER info */
329
330 /* The process is dying */
332 ppiCurrent->peProcess = NULL;
333
334 /* Finally, dereference */
335 IntDereferenceProcessInfo(ppiCurrent);
336
337 return STATUS_SUCCESS;
338}
339
344{
346
347 ASSERT(Process->Peb);
348
349 TRACE_CH(UserProcess, "Win32kProcessCallback -->\n");
350
352
353 if (Initialize)
354 {
356 }
357 else
358 {
360 }
361
362 UserLeave();
363
364 TRACE_CH(UserProcess, "<-- Win32kProcessCallback\n");
365
366 return Status;
367}
368
369
370
373 OUT PTHREADINFO* W32Thread)
374{
375 PTHREADINFO ptiCurrent;
376
377 TRACE_CH(UserThread, "In AllocW32Thread(0x%p)\n", Thread);
378
379 /* Check that we were not called with an already existing Win32 thread info */
380 ptiCurrent = PsGetThreadWin32Thread(Thread);
381 NT_ASSERT(ptiCurrent == NULL);
382
383 /* Allocate a new Win32 thread info */
385 sizeof(*ptiCurrent),
387 if (ptiCurrent == NULL)
388 {
389 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
391 return STATUS_NO_MEMORY;
392 }
393
394 TRACE_CH(UserThread, "Allocated pti 0x%p for TID:0x%lx\n",
395 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
396
397 RtlZeroMemory(ptiCurrent, sizeof(*ptiCurrent));
398
399 PsSetThreadWin32Thread(Thread, ptiCurrent, NULL);
401 IntReferenceThreadInfo(ptiCurrent);
402
403 *W32Thread = ptiCurrent;
404 return STATUS_SUCCESS;
405}
406
407/*
408 * Called from IntDereferenceThreadInfo
409 */
410VOID
412{
413 PPROCESSINFO ppi = pti->ppi;
414
415 TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
416
417 /* Free the message queue */
418 if (pti->MessageQueue)
419 {
421 }
422
424
425 ObDereferenceObject(pti->pEThread);
426
428
430
431 {
432 // Find another queue for mouse cursor.
433 MSG msg;
434 msg.message = WM_MOUSEMOVE;
435 msg.wParam = UserGetMouseButtonsState();
436 msg.lParam = MAKELPARAM(gpsi->ptCursor.x, gpsi->ptCursor.y);
437 msg.pt = gpsi->ptCursor;
439 }
440}
441
444{
445 return STATUS_SUCCESS;
446}
447
450{
451 return STATUS_SUCCESS;
452}
453
454/* Win: xxxCreateThreadInfo */
457{
459 PCLIENTINFO pci;
460 PTHREADINFO ptiCurrent;
461 int i;
463 PTEB pTeb;
464 PRTL_USER_PROCESS_PARAMETERS ProcessParams;
465 PKL pDefKL;
466
467 Process = Thread->ThreadsProcess;
468
469 pTeb = NtCurrentTeb();
470 ASSERT(pTeb);
471
472 ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
473
474 /* Allocate a new Win32 thread info */
475 Status = AllocW32Thread(Thread, &ptiCurrent);
476 if (!NT_SUCCESS(Status))
477 {
478 ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
480 return Status;
481 }
482
483 /* Initialize the THREADINFO */
484 ptiCurrent->pEThread = Thread;
485 ptiCurrent->ppi = PsGetProcessWin32Process(Process);
486 IntReferenceProcessInfo(ptiCurrent->ppi);
487 pTeb->Win32ThreadInfo = ptiCurrent;
488 ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
489 ptiCurrent->pcti = &ptiCurrent->cti;
490
491 /* Mark the process as having threads */
492 ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
493
498 InitializeListHead(&ptiCurrent->PtiLink);
499 for (i = 0; i < NB_HOOKS; i++)
500 {
501 InitializeListHead(&ptiCurrent->aphkStart[i]);
502 }
503 ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
504 ptiCurrent->ppi->ptiList = ptiCurrent;
505 ptiCurrent->ppi->cThreads++;
506
507 ptiCurrent->hEventQueueClient = NULL;
508 Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
510 if (!NT_SUCCESS(Status))
511 {
512 ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
513 goto error;
514 }
517 (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
518 if (!NT_SUCCESS(Status))
519 {
520 ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
522 ptiCurrent->hEventQueueClient = NULL;
523 goto error;
524 }
525
526 ptiCurrent->pcti->timeLastRead = EngGetTickCount32();
527
528 ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
529 if (ptiCurrent->MessageQueue == NULL)
530 {
531 ERR_CH(UserThread, "Failed to allocate message loop\n");
533 goto error;
534 }
535
536 pDefKL = W32kGetDefaultKeyLayout();
537 UserAssignmentLock((PVOID*)&(ptiCurrent->KeyboardLayout), pDefKL);
538
539 ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
540
541 // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
542
543 /* CSRSS threads have some special features */
544 if (Process == gpepCSRSS || !gpepCSRSS)
546
547 /* Initialize the CLIENTINFO */
548 pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
549 RtlZeroMemory(pci, sizeof(*pci));
550 pci->ppi = ptiCurrent->ppi;
551 pci->fsHooks = ptiCurrent->fsHooks;
552 pci->dwTIFlags = ptiCurrent->TIF_flags;
553 if (pDefKL)
554 {
555 pci->hKL = pDefKL->hkl;
556 pci->CodePage = pDefKL->CodePage;
557 }
558
559 /* Need to pass the user Startup Information to the current process. */
560 if ( ProcessParams )
561 {
562 if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
563 {
564 if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
565 {
566 ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
567 ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
568 ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
569 ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
570 ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
571 ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
572 ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
573 }
574 }
575 }
576
577 /*
578 * Assign a default window station and desktop to the process.
579 * Do not try to open a desktop or window station before the very first
580 * (interactive) window station has been created by Winlogon.
581 */
582 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
583 ptiCurrent->ppi->hdeskStartup == NULL &&
585 {
586 HWINSTA hWinSta = NULL;
587 HDESK hDesk = NULL;
588 UNICODE_STRING DesktopPath;
589 PDESKTOP pdesk;
590
591 /*
592 * Inherit the thread desktop and process window station (if not yet inherited)
593 * from the process startup info structure. See documentation of CreateProcess().
594 */
596 if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
597 {
598 Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
599 }
600 if (!NT_SUCCESS(Status))
601 {
602 RtlInitUnicodeString(&DesktopPath, NULL);
603 }
604
606 &DesktopPath,
607 !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
608 &hWinSta,
609 &hDesk);
610
611 if (DesktopPath.Buffer)
612 ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
613
614 if (!NT_SUCCESS(Status))
615 {
616 ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
617 goto error;
618 }
619
620 if (!UserSetProcessWindowStation(hWinSta))
621 {
623 ERR_CH(UserThread, "Failed to set initial process winsta\n");
624 goto error;
625 }
626
627 /* Validate the new desktop */
628 Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
629 if (!NT_SUCCESS(Status))
630 {
631 ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
632 goto error;
633 }
634
635 /* Store the parsed desktop as the initial desktop */
636 ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
637 ASSERT(Process->UniqueProcessId != gpidLogon);
638 ptiCurrent->ppi->hdeskStartup = hDesk;
639 ptiCurrent->ppi->rpdeskStartup = pdesk;
640 }
641
642 if (ptiCurrent->ppi->hdeskStartup != NULL)
643 {
644 if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
645 {
646 ERR_CH(UserThread, "Failed to set thread desktop\n");
648 goto error;
649 }
650 }
651
652 /* Mark the thread as fully initialized */
653 ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
654
655 if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
656 (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
657 {
659 }
660 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
661
662 /* Create the default input context */
663 if (IS_IMM_MODE())
664 {
666 }
667
668 /* Last things to do only if we are not a SYSTEM or CSRSS thread */
669 if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
670 {
671 /* Callback to User32 Client Thread Setup */
672 TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
674 if (!NT_SUCCESS(Status))
675 {
676 ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
677 goto error;
678 }
679 TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
680 }
681 else
682 {
683 TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
684 }
685
686 TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
687 return STATUS_SUCCESS;
688
689error:
690 ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
691 ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
693 return Status;
694}
695
696VOID
698
699// Win: xxxDestroyThreadInfo
701NTAPI
703{
704 PTHREADINFO *ppti;
706 PPROCESSINFO ppiCurrent;
708 PTHREADINFO ptiCurrent;
709 PWINDOWLIST pwl, pwlNext;
710
711 Process = Thread->ThreadsProcess;
712
713 /* Get the Win32 Thread */
714 ptiCurrent = PsGetThreadWin32Thread(Thread);
715 ASSERT(ptiCurrent);
716
717 TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
718
719 ptiCurrent->TIF_flags |= TIF_INCLEANUP;
720 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
721
722 ppiCurrent = ptiCurrent->ppi;
723 ASSERT(ppiCurrent);
724
725 IsRemoveAttachThread(ptiCurrent);
726
727 if (gpwlList)
728 {
729 for (pwl = gpwlList; pwl; pwl = pwlNext)
730 {
731 pwlNext = pwl->pNextList;
732 if (pwl->pti == ptiCurrent)
733 IntFreeHwndList(pwl);
734 }
735 }
736
737 ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
738 ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
739
741
742 /* Decrement thread count and check if its 0 */
743 ppiCurrent->cThreads--;
744
745 if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
746 {
747 /* Do now some process cleanup that requires a valid win32 thread */
748 if (ptiCurrent->ppi->cThreads == 0)
749 {
750 /* Check if we have registered the user api hook */
751 if (ptiCurrent->ppi == ppiUahServer)
752 {
753 /* Unregister the api hook */
755 }
756
757 /* Notify logon application to restart shell if needed */
758 if (ptiCurrent->pDeskInfo)
759 {
760 if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
761 {
763
764 TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
765
769 ExitCode);
770
771 ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
772 }
773 }
774 }
775
776 DceFreeThreadDCE(ptiCurrent);
777 DestroyTimersForThread(ptiCurrent);
779 UnregisterThreadHotKeys(ptiCurrent);
780
782 {
783 DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
784 ASSERT(FALSE);
785 return STATUS_UNSUCCESSFUL;
786 }
788
789 if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
790 ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
791 {
792 TRACE_CH(UserThread, "DestroyProcessClasses\n");
793 /* no process windows should exist at this point, or the function will assert! */
794 DestroyProcessClasses(ppiCurrent);
795 ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
796 }
797
798 IntBlockInput(ptiCurrent, FALSE);
799 IntCleanupThreadCallbacks(ptiCurrent);
800
801 /* cleanup user object references stack */
802 psle = PopEntryList(&ptiCurrent->ReferencesList);
803 while (psle)
804 {
806 TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
808
809 psle = PopEntryList(&ptiCurrent->ReferencesList);
810 }
811 }
812
813 if (ptiCurrent->cEnterCount)
814 {
816 ptiCurrent->cEnterCount = 0;
817 }
818
819 /* Find the THREADINFO in the PROCESSINFO's list */
820 ppti = &ppiCurrent->ptiList;
821 while (*ppti != NULL && *ppti != ptiCurrent)
822 {
823 ppti = &((*ppti)->ptiSibling);
824 }
825
826 /* we must have found it */
827 ASSERT(*ppti == ptiCurrent);
828
829 /* Remove it from the list */
830 *ppti = ptiCurrent->ptiSibling;
831
832 if (!UserAssignmentUnlock((PVOID*)&(ptiCurrent->KeyboardLayout)))
833 ptiCurrent->pClientInfo->hKL = NULL;
834
835 if (gptiForeground == ptiCurrent)
836 {
837// IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
838// IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
839
841 }
842
843 /* Restore display mode when we are the last thread, and we changed the display mode */
844 if (ppiCurrent->cThreads == 0)
845 UserDisplayNotifyShutdown(ppiCurrent);
846
847
848 // Fixes CORE-6384 & CORE-7030.
849/* if (ptiLastInput == ptiCurrent)
850 {
851 if (!ppiCurrent->ptiList)
852 ptiLastInput = gptiForeground;
853 else
854 ptiLastInput = ppiCurrent->ptiList;
855 ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
856 }
857*/
858 TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
859
861
862 if (ptiCurrent->hEventQueueClient != NULL)
863 {
866 }
867 ptiCurrent->hEventQueueClient = NULL;
868
869 /* The thread is dying */
870 PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
871
872 /* Dereference the THREADINFO */
873 IntDereferenceThreadInfo(ptiCurrent);
874
875 return STATUS_SUCCESS;
876}
877
882{
884
886
888
890 {
893 }
894 else // if (Type == PsW32ThreadCalloutExit)
895 {
898 }
899
900 UserLeave();
901
902 return Status;
903}
904
905_Function_class_(DRIVER_UNLOAD)
908{
909 // TODO: Do more cleanup!
910
914}
915
916// Return on failure
917#define NT_ROF(x) \
918{ \
919 Status = (x); \
920 if (!NT_SUCCESS(Status)) \
921 { \
922 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
923 return Status; \
924 } \
925}
926
927// Lock & return on failure
928#define USERLOCK_AND_ROF(x) \
929{ \
930 UserEnterExclusive(); \
931 Status = (x); \
932 UserLeave(); \
933 if (!NT_SUCCESS(Status)) \
934 { \
935 DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
936 return Status; \
937 } \
938}
939
940
941
942/*
943 * This definition doesn't work
944 */
945CODE_SEG("INIT")
951{
954 WIN32_CALLOUTS_FPNS CalloutData = {0};
955 PVOID GlobalUserHeapBase = NULL;
956
957 /*
958 * Register user mode call interface
959 * (system service table index = 1)
960 */
962 NULL,
965 1);
966 if (Result == FALSE)
967 {
968 DPRINT1("Adding system services failed!\n");
969 return STATUS_UNSUCCESSFUL;
970 }
971
973 DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
974
975 DriverObject->DriverUnload = DriverUnload;
976
977 /* Register Object Manager Callbacks */
980 // CalloutData.GlobalAtomTableCallout = NULL;
981 // CalloutData.PowerEventCallout = NULL;
982 // CalloutData.PowerStateCallout = NULL;
983 // CalloutData.JobCallout = NULL;
990 // CalloutData.WindowStationCloseProcedure = NULL;
993 // CalloutData.WindowStationOpenProcedure = NULL;
994
995 /* Register our per-process and per-thread structures. */
996 PsEstablishWin32Callouts(&CalloutData);
997
998 /* Register service hook callbacks */
999#if DBG && defined(KDBG)
1000 KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
1001 KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
1002#endif
1003
1004 /* Create the global USER heap */
1006 &GlobalUserHeapBase,
1007 1 * 1024 * 1024); /* FIXME: 1 MB for now... */
1008 if (GlobalUserHeap == NULL)
1009 {
1010 DPRINT1("Failed to initialize the global heap!\n");
1011 return STATUS_UNSUCCESSFUL;
1012 }
1013
1014 /* Init the global user lock */
1016
1017 /* Lock while we use the heap (UserHeapAlloc asserts on this) */
1019
1020 /* Allocate global server info structure */
1021 gpsi = UserHeapAlloc(sizeof(*gpsi));
1022 UserLeave();
1023 if (!gpsi)
1024 {
1025 DPRINT1("Failed allocate server info structure!\n");
1026 return STATUS_UNSUCCESSFUL;
1027 }
1028
1029 RtlZeroMemory(gpsi, sizeof(*gpsi));
1030 DPRINT("Global Server Data -> %p\n", gpsi);
1031
1034
1035 /* Create stock objects, ie. precreated objects commonly
1036 used by win32 applications */
1039
1044 NT_ROF(InitDcImpl());
1053
1054 return STATUS_SUCCESS;
1055}
1056
1057/* 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
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:1430
VOID ResetCsrProcess(VOID)
Definition: csr.c:29
PEPROCESS gpepCSRSS
Definition: csr.c:15
VOID ResetCsrApiPort(VOID)
Definition: csr.c:58
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:32
#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:715
_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:499
#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
#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_ PVOID InputBuffer, _In_ ULONG InputBufferLength, _Out_ PVOID OutputBuffer, _In_ ULONG OutputBufferLength, _Inout_ PULONG ReturnLength, _In_ KPROCESSOR_MODE PreviousMode)
Definition: kdapi.c:2183
NTSTATUS NTAPI InitLDEVImpl(VOID)
Definition: ldevobj.c:30
#define error(str)
Definition: mkdosfs.c:1605
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define _Function_class_(x)
Definition: ms_sal.h:2946
#define _Pre_notnull_
Definition: ms_sal.h:680
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:2417
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
Definition: msgqueue.c:2215
NTSTATUS NTAPI MsqInitializeImpl(VOID)
Definition: msgqueue.c:30
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2390
#define UserMode
Definition: asm.h:35
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
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
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
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:1382
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:79
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
ERESOURCE UserLock
Definition: ntuser.c:18
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:242
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
struct _PROCESSINFO * ppi
Definition: ntuser.h:346
HANDLE UniqueThread
Definition: compat.h:826
CLIENT_ID Cid
Definition: pstypes.h:1128
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1913
INT cThreads
Definition: win32.h:262
PPROCESSINFO ppiNext
Definition: win32.h:261
USERSTARTUPINFO usi
Definition: win32.h:278
HDESK hdeskStartup
Definition: win32.h:263
LIST_ENTRY DriverObjListHead
Definition: win32.h:289
PTHREADINFO ptiList
Definition: win32.h:256
struct _DESKTOP * rpdeskStartup
Definition: win32.h:258
FAST_MUTEX DriverObjListLock
Definition: win32.h:288
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1555
Definition: ntbasedef.h:628
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
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_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1694
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1683
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1696
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1697
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1691
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1690
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1693
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1692
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1684
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1689
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:219
struct tagWINDOWLIST * pNextList
Definition: window.h:87
PTHREADINFO pti
Definition: window.h:90
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3557
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:171
#define W32PF_APPSTARTING
Definition: win32.h:10
#define W32PF_TERMINATED
Definition: win32.h:16
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:181
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
#define IntReferenceThreadInfo(pti)
Definition: win32.h:166
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:186
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:166
BOOL DbgInitDebugChannels()
#define TRACE_PPI(ppi, ch, fmt,...)
Definition: win32kdebug.h:183
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:303
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:186
NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:252
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:227
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1237
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:551
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:210
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:155
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3260
PTHREADINFO gptiForeground
Definition: focus.c:15
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:121
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:514
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:303
VOID UserDeleteW32Thread(PTHREADINFO pti)
Definition: main.c:411
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:933
PPROCESSINFO gppiList
Definition: main.c:30
#define USERLOCK_AND_ROF(x)
Definition: main.c:928
NTSTATUS UserThreadCreate(PETHREAD Thread)
Definition: main.c:443
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:230
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
Definition: main.c:95
NTSTATUS UserThreadDestroy(PETHREAD Thread)
Definition: main.c:449
HANDLE hModuleWin
Definition: main.c:16
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:342
NTSTATUS GdiThreadDestroy(PETHREAD Thread)
Definition: init.c:73
PPROCESSINFO ppiScrnSaver
Definition: main.c:29
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:880
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:917
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:702
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:46
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:456
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:372
PSERVERINFO gpsi
Definition: main.c:27
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:174
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
Definition: main.c:57
NTSTATUS UserProcessCreate(PEPROCESS Process)
Definition: main.c:121
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1345
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
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
#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:594
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
Definition: timer.c:549
VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget)
Definition: window.c:1470
PWINDOWLIST gpwlCache
Definition: window.c:17
PWINDOWLIST gpwlList
Definition: window.c:16
NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define WM_MOUSEMOVE
Definition: winuser.h:1775
_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:3310
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
static void Initialize()
Definition: xlate.c:212
unsigned char UCHAR
Definition: xmlstorage.h:181