ReactOS  0.4.12-dev-685-gf36cbf7
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 
27 PSERVERINFO gpsi = NULL; // Global User Server Information.
28 
32 
33 extern ULONG_PTR Win32kSSDT[];
34 extern UCHAR Win32kSSPT[];
36 
37 #if DBG
38 void
39 NTAPI
40 DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
41 {
42  GdiDbgPreServiceHook(ulSyscallId, pulArguments);
43  UserDbgPreServiceHook(ulSyscallId, pulArguments);
44 }
45 
47 NTAPI
48 DbgPostServiceHook(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 */
66  ppiCurrent = PsGetProcessWin32Process(Process);
67  if (ppiCurrent) return STATUS_SUCCESS;
68 
69  /* Allocate a new Win32 process info */
71  sizeof(*ppiCurrent),
73  if (ppiCurrent == NULL)
74  {
75  ERR_CH(UserProcess, "Failed to allocate ppi for PID:0x%lx\n",
76  HandleToUlong(Process->UniqueProcessId));
77  return STATUS_NO_MEMORY;
78  }
79 
80  TRACE_CH(UserProcess, "Allocated ppi 0x%p for PID:0x%lx\n",
81  ppiCurrent, HandleToUlong(Process->UniqueProcessId));
82 
83  RtlZeroMemory(ppiCurrent, sizeof(*ppiCurrent));
84 
86  IntReferenceProcessInfo(ppiCurrent);
87 
88  *W32Process = ppiCurrent;
89  return STATUS_SUCCESS;
90 }
91 
92 #define FreeW32Process(/*Process*/ W32Process) \
93 do { \
94  /*PPROCESSINFO W32Process = PsGetProcessWin32Process(Process);*/ \
95  /*ASSERT(W32Process);*/ \
96  IntDereferenceProcessInfo(W32Process); \
97 } while(0)
98 
99 /*
100  * Called from IntDereferenceProcessInfo
101  */
102 VOID
104  _Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
105 {
106  if (ppiCurrent->InputIdleEvent)
107  {
108  /* Free the allocated memory */
109  ExFreePoolWithTag(ppiCurrent->InputIdleEvent, USERTAG_EVENT);
110  }
111 
112  /* Close the startup desktop */
113  if (ppiCurrent->rpdeskStartup)
114  ObDereferenceObject(ppiCurrent->rpdeskStartup);
115 
116 #if DBG
117  if (DBG_IS_CHANNEL_ENABLED(ppiCurrent, DbgChUserObj, WARN_LEVEL))
118  {
119  TRACE_PPI(ppiCurrent, UserObj, "Dumping user handles now that process info %p is gets freed.\n", ppiCurrent);
121  }
122 #endif
123 
124  /* Free the PROCESSINFO */
126 }
127 
128 NTSTATUS
130 {
132  ASSERT(ppiCurrent);
133 
136 
137  {
138  PKEVENT Event;
139 
140  /* Allocate memory for the event structure */
142  sizeof(*Event),
143  USERTAG_EVENT);
144  if (Event)
145  {
146  /* Initialize the kernel event */
149  FALSE);
150  }
151  else
152  {
153  /* Out of memory */
154  DPRINT("CreateEvent() failed\n");
155  KeBugCheck(0);
156  }
157 
158  /* Set the event */
159  ppiCurrent->InputIdleEvent = Event;
160  KeInitializeEvent(ppiCurrent->InputIdleEvent, NotificationEvent, FALSE);
161  }
162 
163  ppiCurrent->peProcess = Process;
164  ppiCurrent->W32Pid = HandleToUlong(PsGetProcessId(Process));
165 
166  /* Setup process flags */
167  ppiCurrent->W32PF_flags |= W32PF_PROCESSCONNECTED;
168  if (Process->Peb->ProcessParameters &&
169  (Process->Peb->ProcessParameters->WindowFlags & STARTF_SCREENSAVER))
170  {
171  ppiScrnSaver = ppiCurrent;
172  ppiCurrent->W32PF_flags |= W32PF_SCREENSAVER;
173  }
174 
175  // FIXME: check if this process is allowed.
176  ppiCurrent->W32PF_flags |= W32PF_ALLOWFOREGROUNDACTIVATE; // Starting application will get it toggled off.
177 
178  return STATUS_SUCCESS;
179 }
180 
181 NTSTATUS
183 {
185  ASSERT(ppiCurrent);
186 
187  if (ppiScrnSaver == ppiCurrent)
188  ppiScrnSaver = NULL;
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 
229 NTSTATUS
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!) */
241  return STATUS_ALREADY_WIN32;
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 
295 error:
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 
302 NTSTATUS
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 */
331  PsSetProcessWin32Process(Process, NULL, ppiCurrent);
332  ppiCurrent->peProcess = NULL;
333 
334  /* Finally, dereference */
335  FreeW32Process(/*Process*/ ppiCurrent); // IntDereferenceProcessInfo(ppiCurrent);
336 
337  return STATUS_SUCCESS;
338 }
339 
340 NTSTATUS
341 APIENTRY
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 
371 NTSTATUS
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 */
384  ptiCurrent = ExAllocatePoolWithTag(NonPagedPool,
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);
400  IntReferenceThreadInfo(ptiCurrent);
401 
402  *W32Thread = ptiCurrent;
403  return STATUS_SUCCESS;
404 }
405 
406 #define FreeW32Thread(/*Thread*/ W32Thread) \
407 do { \
408  /*PTHREADINFO W32Thread = PsGetThreadWin32Thread(Thread);*/ \
409  /*ASSERT(W32Thread);*/ \
410  IntDereferenceThreadInfo(W32Thread); \
411 } while(0)
412 
413 /*
414  * Called from IntDereferenceThreadInfo
415  */
416 VOID
418 {
419  PPROCESSINFO ppi = pti->ppi;
420 
421  TRACE_CH(UserThread, "UserDeleteW32Thread pti 0x%p\n",pti);
422 
423  /* Free the message queue */
424  if (pti->MessageQueue)
425  {
427  }
428 
430 
432 
434 }
435 
436 NTSTATUS
438 {
439  return STATUS_SUCCESS;
440 }
441 
442 NTSTATUS
444 {
445  return STATUS_SUCCESS;
446 }
447 
450 {
452  PCLIENTINFO pci;
453  PTHREADINFO ptiCurrent;
454  int i;
456  PTEB pTeb;
457  LARGE_INTEGER LargeTickCount;
458  PRTL_USER_PROCESS_PARAMETERS ProcessParams;
459 
460  Process = Thread->ThreadsProcess;
461 
462  pTeb = NtCurrentTeb();
463  ASSERT(pTeb);
464 
465  ProcessParams = pTeb->ProcessEnvironmentBlock->ProcessParameters;
466 
467  /* Allocate a new Win32 thread info */
468  Status = AllocW32Thread(Thread, &ptiCurrent);
469  if (!NT_SUCCESS(Status))
470  {
471  ERR_CH(UserThread, "Failed to allocate pti for TID:0x%lx\n",
473  return Status;
474  }
475 
476  /* Initialize the THREADINFO */
477  ptiCurrent->pEThread = Thread;
478  ptiCurrent->ppi = PsGetProcessWin32Process(Process);
479  IntReferenceProcessInfo(ptiCurrent->ppi);
480  pTeb->Win32ThreadInfo = ptiCurrent;
481  ptiCurrent->pClientInfo = (PCLIENTINFO)pTeb->Win32ClientInfo;
482 
483  /* Mark the process as having threads */
484  ptiCurrent->ppi->W32PF_flags |= W32PF_THREADCONNECTED;
485 
486  InitializeListHead(&ptiCurrent->WindowListHead);
490  InitializeListHead(&ptiCurrent->PtiLink);
491  for (i = 0; i < NB_HOOKS; i++)
492  {
493  InitializeListHead(&ptiCurrent->aphkStart[i]);
494  }
495  ptiCurrent->ptiSibling = ptiCurrent->ppi->ptiList;
496  ptiCurrent->ppi->ptiList = ptiCurrent;
497  ptiCurrent->ppi->cThreads++;
498 
499  ptiCurrent->hEventQueueClient = NULL;
500  Status = ZwCreateEvent(&ptiCurrent->hEventQueueClient, EVENT_ALL_ACCESS,
502  if (!NT_SUCCESS(Status))
503  {
504  ERR_CH(UserThread, "Event creation failed, Status 0x%08x.\n", Status);
505  goto error;
506  }
509  (PVOID*)&ptiCurrent->pEventQueueServer, NULL);
510  if (!NT_SUCCESS(Status))
511  {
512  ERR_CH(UserThread, "Failed referencing the event object, Status 0x%08x.\n", Status);
514  ptiCurrent->hEventQueueClient = NULL;
515  goto error;
516  }
517 
518  KeQueryTickCount(&LargeTickCount);
519  ptiCurrent->timeLast = LargeTickCount.u.LowPart;
520 
521  ptiCurrent->MessageQueue = MsqCreateMessageQueue(ptiCurrent);
522  if (ptiCurrent->MessageQueue == NULL)
523  {
524  ERR_CH(UserThread, "Failed to allocate message loop\n");
526  goto error;
527  }
528 
529  ptiCurrent->KeyboardLayout = W32kGetDefaultKeyLayout();
530  if (ptiCurrent->KeyboardLayout)
531  UserReferenceObject(ptiCurrent->KeyboardLayout);
532 
533  ptiCurrent->TIF_flags &= ~TIF_INCLEANUP;
534 
535  // FIXME: Flag SYSTEM threads with... TIF_SYSTEMTHREAD !!
536 
537  /* CSRSS threads have some special features */
538  if (Process == gpepCSRSS || !gpepCSRSS)
540 
541  ptiCurrent->pcti = &ptiCurrent->cti;
542 
543  /* Initialize the CLIENTINFO */
544  pci = (PCLIENTINFO)pTeb->Win32ClientInfo;
545  RtlZeroMemory(pci, sizeof(*pci));
546  pci->ppi = ptiCurrent->ppi;
547  pci->fsHooks = ptiCurrent->fsHooks;
548  pci->dwTIFlags = ptiCurrent->TIF_flags;
549  if (ptiCurrent->KeyboardLayout)
550  {
551  pci->hKL = ptiCurrent->KeyboardLayout->hkl;
552  pci->CodePage = ptiCurrent->KeyboardLayout->CodePage;
553  }
554 
555  /* Need to pass the user Startup Information to the current process. */
556  if ( ProcessParams )
557  {
558  if ( ptiCurrent->ppi->usi.cb == 0 ) // Not initialized yet.
559  {
560  if ( ProcessParams->WindowFlags != 0 ) // Need window flags set.
561  {
562  ptiCurrent->ppi->usi.cb = sizeof(USERSTARTUPINFO);
563  ptiCurrent->ppi->usi.dwX = ProcessParams->StartingX;
564  ptiCurrent->ppi->usi.dwY = ProcessParams->StartingY;
565  ptiCurrent->ppi->usi.dwXSize = ProcessParams->CountX;
566  ptiCurrent->ppi->usi.dwYSize = ProcessParams->CountY;
567  ptiCurrent->ppi->usi.dwFlags = ProcessParams->WindowFlags;
568  ptiCurrent->ppi->usi.wShowWindow = (WORD)ProcessParams->ShowWindowFlags;
569  }
570  }
571  }
572 
573  /*
574  * Assign a default window station and desktop to the process.
575  * Do not try to open a desktop or window station before the very first
576  * (interactive) window station has been created by Winlogon.
577  */
578  if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)) &&
579  ptiCurrent->ppi->hdeskStartup == NULL &&
581  {
582  HWINSTA hWinSta = NULL;
583  HDESK hDesk = NULL;
584  UNICODE_STRING DesktopPath;
585  PDESKTOP pdesk;
586 
587  /*
588  * Inherit the thread desktop and process window station (if not yet inherited)
589  * from the process startup info structure. See documentation of CreateProcess().
590  */
592  if (ProcessParams && ProcessParams->DesktopInfo.Length > 0)
593  {
594  Status = IntSafeCopyUnicodeStringTerminateNULL(&DesktopPath, &ProcessParams->DesktopInfo);
595  }
596  if (!NT_SUCCESS(Status))
597  {
598  RtlInitUnicodeString(&DesktopPath, NULL);
599  }
600 
602  &DesktopPath,
603  !!(ProcessParams->WindowFlags & STARTF_INHERITDESKTOP),
604  &hWinSta,
605  &hDesk);
606 
607  if (DesktopPath.Buffer)
608  ExFreePoolWithTag(DesktopPath.Buffer, TAG_STRING);
609 
610  if (!NT_SUCCESS(Status))
611  {
612  ERR_CH(UserThread, "Failed to assign default desktop and winsta to process\n");
613  goto error;
614  }
615 
616  if (!UserSetProcessWindowStation(hWinSta))
617  {
619  ERR_CH(UserThread, "Failed to set initial process winsta\n");
620  goto error;
621  }
622 
623  /* Validate the new desktop */
624  Status = IntValidateDesktopHandle(hDesk, UserMode, 0, &pdesk);
625  if (!NT_SUCCESS(Status))
626  {
627  ERR_CH(UserThread, "Failed to validate initial desktop handle\n");
628  goto error;
629  }
630 
631  /* Store the parsed desktop as the initial desktop */
632  ASSERT(ptiCurrent->ppi->hdeskStartup == NULL);
633  ASSERT(Process->UniqueProcessId != gpidLogon);
634  ptiCurrent->ppi->hdeskStartup = hDesk;
635  ptiCurrent->ppi->rpdeskStartup = pdesk;
636  }
637 
638  if (ptiCurrent->ppi->hdeskStartup != NULL)
639  {
640  if (!IntSetThreadDesktop(ptiCurrent->ppi->hdeskStartup, FALSE))
641  {
642  ERR_CH(UserThread, "Failed to set thread desktop\n");
644  goto error;
645  }
646  }
647 
648  /* Mark the thread as fully initialized */
649  ptiCurrent->TIF_flags |= TIF_GUITHREADINITIALIZED;
650 
651  if (!(ptiCurrent->ppi->W32PF_flags & (W32PF_ALLOWFOREGROUNDACTIVATE | W32PF_APPSTARTING)) &&
652  (gptiForeground && gptiForeground->ppi == ptiCurrent->ppi ))
653  {
654  ptiCurrent->TIF_flags |= TIF_ALLOWFOREGROUNDACTIVATE;
655  }
656  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
657 
658  /* Last things to do only if we are not a SYSTEM or CSRSS thread */
659  if (!(ptiCurrent->TIF_flags & (TIF_SYSTEMTHREAD | TIF_CSRSSTHREAD)))
660  {
661  /* Callback to User32 Client Thread Setup */
662  TRACE_CH(UserThread, "Call co_IntClientThreadSetup...\n");
664  if (!NT_SUCCESS(Status))
665  {
666  ERR_CH(UserThread, "ClientThreadSetup failed with Status 0x%08lx\n", Status);
667  goto error;
668  }
669  TRACE_CH(UserThread, "co_IntClientThreadSetup succeeded!\n");
670  }
671  else
672  {
673  TRACE_CH(UserThread, "co_IntClientThreadSetup cannot be called...\n");
674  }
675 
676  TRACE_CH(UserThread, "UserCreateW32Thread pti 0x%p\n", ptiCurrent);
677  return STATUS_SUCCESS;
678 
679 error:
680  ERR_CH(UserThread, "InitThreadCallback failed! Freeing pti 0x%p for TID:0x%lx\n",
681  ptiCurrent, HandleToUlong(Thread->Cid.UniqueThread));
683  return Status;
684 }
685 
686 VOID
688 
689 NTSTATUS
690 NTAPI
692 {
693  PTHREADINFO *ppti;
694  PSINGLE_LIST_ENTRY psle;
695  PPROCESSINFO ppiCurrent;
697  PTHREADINFO ptiCurrent;
698 
699  Process = Thread->ThreadsProcess;
700 
701  /* Get the Win32 Thread */
702  ptiCurrent = PsGetThreadWin32Thread(Thread);
703  ASSERT(ptiCurrent);
704 
705  TRACE_CH(UserThread, "Destroying pti 0x%p eThread 0x%p\n", ptiCurrent, Thread);
706 
707  ptiCurrent->TIF_flags |= TIF_INCLEANUP;
708  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
709 
710  ppiCurrent = ptiCurrent->ppi;
711  ASSERT(ppiCurrent);
712 
713  IsRemoveAttachThread(ptiCurrent);
714 
715  ptiCurrent->TIF_flags |= TIF_DONTATTACHQUEUE;
716  ptiCurrent->pClientInfo->dwTIFlags = ptiCurrent->TIF_flags;
717 
719 
720  /* Decrement thread count and check if its 0 */
721  ppiCurrent->cThreads--;
722 
723  if (ptiCurrent->TIF_flags & TIF_GUITHREADINITIALIZED)
724  {
725  /* Do now some process cleanup that requires a valid win32 thread */
726  if (ptiCurrent->ppi->cThreads == 0)
727  {
728  /* Check if we have registered the user api hook */
729  if (ptiCurrent->ppi == ppiUahServer)
730  {
731  /* Unregister the api hook */
733  }
734 
735  /* Notify logon application to restart shell if needed */
736  if (ptiCurrent->pDeskInfo)
737  {
738  if (ptiCurrent->pDeskInfo->ppiShellProcess == ppiCurrent)
739  {
741 
742  TRACE_CH(UserProcess, "Shell process is exiting (%lu)\n", ExitCode);
743 
747  ExitCode);
748 
749  ptiCurrent->pDeskInfo->ppiShellProcess = NULL;
750  }
751  }
752  }
753 
754  DceFreeThreadDCE(ptiCurrent);
755  DestroyTimersForThread(ptiCurrent);
757  UnregisterThreadHotKeys(ptiCurrent);
758 
759  if (!UserDestroyObjectsForOwner(gHandleTable, ptiCurrent))
760  {
761  DPRINT1("Failed to delete objects belonging to thread %p. This is VERY BAD!.\n", ptiCurrent);
762  ASSERT(FALSE);
763  return STATUS_UNSUCCESSFUL;
764  }
765 
766  if (ppiCurrent && ppiCurrent->ptiList == ptiCurrent && !ptiCurrent->ptiSibling &&
767  ppiCurrent->W32PF_flags & W32PF_CLASSESREGISTERED)
768  {
769  TRACE_CH(UserThread, "DestroyProcessClasses\n");
770  /* no process windows should exist at this point, or the function will assert! */
771  DestroyProcessClasses(ppiCurrent);
772  ppiCurrent->W32PF_flags &= ~W32PF_CLASSESREGISTERED;
773  }
774 
775  IntBlockInput(ptiCurrent, FALSE);
776  IntCleanupThreadCallbacks(ptiCurrent);
777 
778  /* cleanup user object references stack */
779  psle = PopEntryList(&ptiCurrent->ReferencesList);
780  while (psle)
781  {
783  TRACE_CH(UserThread, "thread clean: remove reference obj 0x%p\n",ref->obj);
785 
786  psle = PopEntryList(&ptiCurrent->ReferencesList);
787  }
788  }
789 
790  if (ptiCurrent->cEnterCount)
791  {
793  ptiCurrent->cEnterCount = 0;
794  }
795 
796  /* Find the THREADINFO in the PROCESSINFO's list */
797  ppti = &ppiCurrent->ptiList;
798  while (*ppti != NULL && *ppti != ptiCurrent)
799  {
800  ppti = &((*ppti)->ptiSibling);
801  }
802 
803  /* we must have found it */
804  ASSERT(*ppti == ptiCurrent);
805 
806  /* Remove it from the list */
807  *ppti = ptiCurrent->ptiSibling;
808 
809  if (ptiCurrent->KeyboardLayout)
811 
812  if (gptiForeground == ptiCurrent)
813  {
814 // IntNotifyWinEvent(EVENT_OBJECT_FOCUS, NULL, OBJID_CLIENT, CHILDID_SELF, 0);
815 // IntNotifyWinEvent(EVENT_SYSTEM_FOREGROUND, NULL, OBJID_WINDOW, CHILDID_SELF, 0);
816 
818  }
819 
820  /* Restore display mode when we are the last thread, and we changed the display mode */
821  if (ppiCurrent->cThreads == 0)
822  UserDisplayNotifyShutdown(ppiCurrent);
823 
824 
825  // Fixes CORE-6384 & CORE-7030.
826 /* if (ptiLastInput == ptiCurrent)
827  {
828  if (!ppiCurrent->ptiList)
829  ptiLastInput = gptiForeground;
830  else
831  ptiLastInput = ppiCurrent->ptiList;
832  ERR_CH(UserThread, "DTI: ptiLastInput is Cleared!!\n");
833  }
834 */
835  TRACE_CH(UserThread, "Freeing pti 0x%p\n", ptiCurrent);
836 
838 
839  if (ptiCurrent->hEventQueueClient != NULL)
840  {
843  }
844  ptiCurrent->hEventQueueClient = NULL;
845 
846  /* The thread is dying */
847  PsSetThreadWin32Thread(Thread /*ptiCurrent->pEThread*/, NULL, ptiCurrent);
848  ptiCurrent->pEThread = NULL;
849 
850  /* Free the THREADINFO */
851  FreeW32Thread(/*Thread*/ ptiCurrent); // IntDereferenceThreadInfo(ptiCurrent);
852 
853  return STATUS_SUCCESS;
854 }
855 
856 NTSTATUS
857 APIENTRY
860 {
862 
863  ASSERT(NtCurrentTeb());
864 
866 
868  {
871  }
872  else // if (Type == PsW32ThreadCalloutExit)
873  {
876  }
877 
878  UserLeave();
879 
880  return Status;
881 }
882 
883 _Function_class_(DRIVER_UNLOAD)
884 VOID NTAPI
886 {
887  // TODO: Do more cleanup!
888 
889  ResetCsrApiPort();
890  ResetCsrProcess();
891 }
892 
893 // Return on failure
894 #define NT_ROF(x) \
895 { \
896  Status = (x); \
897  if (!NT_SUCCESS(Status)) \
898  { \
899  DPRINT1("Failed '%s' (0x%lx)\n", #x, Status); \
900  return Status; \
901  } \
902 }
903 
904 /*
905  * This definition doesn't work
906  */
907 INIT_FUNCTION
908 NTSTATUS
909 APIENTRY
913 {
915  BOOLEAN Result;
916  WIN32_CALLOUTS_FPNS CalloutData = {0};
917  PVOID GlobalUserHeapBase = NULL;
918 
919  /*
920  * Register user mode call interface
921  * (system service table index = 1)
922  */
924  NULL,
926  Win32kSSPT,
927  1);
928  if (Result == FALSE)
929  {
930  DPRINT1("Adding system services failed!\n");
931  return STATUS_UNSUCCESSFUL;
932  }
933 
935  DPRINT("Win32k hInstance 0x%p!\n", hModuleWin);
936 
938 
939  /* Register Object Manager Callbacks */
941  CalloutData.ThreadCallout = Win32kThreadCallback;
942  // CalloutData.GlobalAtomTableCallout = NULL;
943  // CalloutData.PowerEventCallout = NULL;
944  // CalloutData.PowerStateCallout = NULL;
945  // CalloutData.JobCallout = NULL;
952  // CalloutData.WindowStationCloseProcedure = NULL;
955  // CalloutData.WindowStationOpenProcedure = NULL;
956 
957  /* Register our per-process and per-thread structures. */
958  PsEstablishWin32Callouts(&CalloutData);
959 
960  /* Register service hook callbacks */
961 #if DBG && defined(KDBG)
962  KdSystemDebugControl('CsoR', DbgPreServiceHook, ID_Win32PreServiceHook, 0, 0, 0, 0);
963  KdSystemDebugControl('CsoR', DbgPostServiceHook, ID_Win32PostServiceHook, 0, 0, 0, 0);
964 #endif
965 
966  /* Create the global USER heap */
968  &GlobalUserHeapBase,
969  1 * 1024 * 1024); /* FIXME: 1 MB for now... */
970  if (GlobalUserHeap == NULL)
971  {
972  DPRINT1("Failed to initialize the global heap!\n");
973  return STATUS_UNSUCCESSFUL;
974  }
975 
976  /* Allocate global server info structure */
977  gpsi = UserHeapAlloc(sizeof(*gpsi));
978  if (!gpsi)
979  {
980  DPRINT1("Failed allocate server info structure!\n");
981  return STATUS_UNSUCCESSFUL;
982  }
983 
984  RtlZeroMemory(gpsi, sizeof(*gpsi));
985  DPRINT("Global Server Data -> %p\n", gpsi);
986 
989 
990  /* Create stock objects, ie. precreated objects commonly
991  used by win32 applications */
994 
996  NT_ROF(InitPDEVImpl());
997  NT_ROF(InitLDEVImpl());
999  NT_ROF(InitDcImpl());
1000  NT_ROF(InitUserImpl());
1003  NT_ROF(InitInputImpl());
1006  NT_ROF(InitTimerImpl());
1007  NT_ROF(InitDCEImpl());
1008 
1010 
1011  /* Initialize FreeType library */
1012  if (!InitFontSupport())
1013  {
1014  DPRINT1("Unable to initialize font support\n");
1015  return Status;
1016  }
1017 
1018  return STATUS_SUCCESS;
1019 }
1020 
1021 /* EOF */
NTSTATUS APIENTRY Win32kThreadCallback(PETHREAD Thread, PSW32THREADCALLOUTTYPE Type)
Definition: main.c:858
INIT_FUNCTION NTSTATUS NTAPI InitKeyboardImpl(VOID)
Definition: keyboard.c:31
ULONG fsHooks
Definition: ntuser.h:296
USERSTARTUPINFO usi
Definition: win32.h:269
PVOID NTAPI PsSetThreadWin32Thread(_Inout_ PETHREAD Thread, _In_ PVOID Win32Thread, _In_ PVOID OldWin32Thread)
Definition: thread.c:909
#define IN
Definition: typedefs.h:38
PVOID NTAPI PsGetThreadWin32Thread(IN PETHREAD Thread)
Definition: thread.c:795
BOOL FASTCALL UserPostMessage(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1189
ULONG Win32ClientInfo[31]
Definition: compat.h:496
NTSTATUS NTAPI IntDesktopObjectOpen(_In_ PVOID Parameters)
Definition: desktop.c:202
PPROCESSINFO ppiScrnSaver
Definition: main.c:30
#define TRUE
Definition: types.h:120
NTSTATUS InitProcessCallback(PEPROCESS Process)
Definition: main.c:230
PPEB ProcessEnvironmentBlock
Definition: ntddk_ex.h:341
void FASTCALL DestroyProcessClasses(PPROCESSINFO Process)
Definition: class.c:300
Type
Definition: Type.h:6
PKWIN32_SESSION_CALLOUT WindowStationOkToCloseProcedure
Definition: pstypes.h:1625
NTSTATUS GdiThreadDestroy(PETHREAD Thread)
Definition: init.c:74
#define error(str)
Definition: mkdosfs.c:1605
PPROCESSINFO ppiNext
Definition: win32.h:252
Definition: ntbasedef.h:635
NTSTATUS AllocW32Process(IN PEPROCESS Process, OUT PPROCESSINFO *W32Process)
Definition: main.c:58
PVOID Win32ThreadInfo
Definition: compat.h:495
VOID ResetCsrProcess(VOID)
Definition: csr.c:29
PGDI_BATCHFLUSH_ROUTINE BatchFlushRoutine
Definition: pstypes.h:1620
INIT_FUNCTION NTSTATUS NTAPI InitGdiHandleTable(void)
Definition: gdiobj.c:257
LIST_ENTRY WindowListHead
Definition: win32.h:149
PTHREADINFO ptiSibling
Definition: win32.h:115
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
#define TAG_STRING
Definition: oslist.c:24
#define TIF_DONTATTACHQUEUE
Definition: ntuser.h:246
BOOLEAN NTAPI KeAddSystemServiceTable(IN PULONG_PTR Base, IN PULONG Count OPTIONAL, IN ULONG Limit, IN PUCHAR Number, IN ULONG Index)
Definition: procobj.c:905
PVOID NTAPI PsGetProcessWin32Process(PEPROCESS Process)
Definition: process.c:1193
FLONG TIF_flags
Definition: win32.h:94
PWINSTATION_OBJECT InputWindowStation
Definition: winsta.c:21
PEPROCESS gpepCSRSS
Definition: csr.c:15
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
#define NT_ROF(x)
Definition: main.c:894
NTSTATUS NTAPI IntDesktopOkToClose(_In_ PVOID Parameters)
Definition: desktop.c:178
BOOL FASTCALL DestroyTimersForThread(PTHREADINFO pti)
Definition: timer.c:553
NTSTATUS ExitProcessCallback(PEPROCESS Process)
Definition: main.c:303
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
LIST_ENTRY PtiLink
Definition: win32.h:125
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PKWIN32_THREAD_CALLOUT ThreadCallout
Definition: pstypes.h:1615
ULONG Win32kNumberOfSysCalls
Definition: napi.h:22
static __inline PVOID UserHeapAlloc(SIZE_T Bytes)
Definition: usrheap.h:34
NTSTATUS APIENTRY NtGdiFlushUserBatch(VOID)
Definition: gdibatch.c:168
#define USERTAG_EVENT
Definition: tags.h:229
UNICODE_STRING DesktopInfo
Definition: rtltypes.h:1526
#define USERTAG_THREADINFO
Definition: tags.h:283
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define TIF_SYSTEMTHREAD
Definition: ntuser.h:242
PSERVERINFO gpsi
Definition: main.c:27
Definition: send.c:47
POBJECT_TYPE ExEventObjectType
Definition: event.c:22
PKWIN32_SESSION_CALLOUT DesktopCloseProcedure
Definition: pstypes.h:1623
PPROCESSINFO ppi
Definition: win32.h:87
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define USERTAG_PROCESSINFO
Definition: tags.h:259
INIT_FUNCTION NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:63
NTSTATUS MapGlobalUserHeap(IN PEPROCESS Process, OUT PVOID *KernelMapping, OUT PVOID *UserMapping)
Definition: usrheap.c:262
NTSTATUS NTAPI IntWinStaObjectParse(_In_ PVOID Parameters)
Definition: winsta.c:136
static GENERIC_MAPPING UserMapping
Definition: samrpc.c:48
PTHREADINFO gptiForeground
Definition: focus.c:14
#define W32PF_PROCESSCONNECTED
Definition: win32.h:19
INIT_FUNCTION NTSTATUS NTAPI InitBrushImpl(VOID)
Definition: engbrush.c:31
BOOL FASTCALL InitFontSupport(VOID)
Definition: freetype.c:615
PKWIN32_SESSION_CALLOUT WindowStationDeleteProcedure
Definition: pstypes.h:1627
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define W32PF_ALLOWFOREGROUNDACTIVATE
Definition: win32.h:12
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
HDESK hdeskStartup
Definition: win32.h:254
VOID FASTCALL CreateSysColorObjects(VOID)
Definition: stockobj.c:329
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
INIT_FUNCTION NTSTATUS NTAPI InitDCEImpl(VOID)
Definition: windc.c:30
NTSTATUS FASTCALL IntSafeCopyUnicodeStringTerminateNULL(PUNICODE_STRING Dest, PUNICODE_STRING Source)
Definition: misc.c:659
NTSTATUS NTAPI PsGetProcessExitStatus(PEPROCESS Process)
Definition: process.c:1053
#define TIF_CSRSSTHREAD
Definition: ntuser.h:243
BOOL NTAPI UserCloseClipboard(VOID)
Definition: clipboard.c:527
NTSTATUS NTAPI PsSetProcessWin32Process(_Inout_ PEPROCESS Process, _In_opt_ PVOID Win32Process, _In_opt_ PVOID OldWin32Process)
Definition: process.c:1257
LIST_ENTRY SentMessagesListHead
Definition: win32.h:99
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
short SHORT
Definition: pedump.c:59
void FASTCALL DceFreeThreadDCE(PTHREADINFO)
Definition: windc.c:779
VOID FASTCALL CreateStockObjects(VOID)
Definition: stockobj.c:247
NTSTATUS AllocW32Thread(IN PETHREAD Thread, OUT PTHREADINFO *W32Thread)
Definition: main.c:372
_Function_class_(DRIVER_UNLOAD)
Definition: main.c:883
#define W32PF_TERMINATED
Definition: win32.h:16
INIT_FUNCTION NTSTATUS NTAPI InitWindowStationImpl(VOID)
Definition: winsta.c:34
#define STARTF_INHERITDESKTOP
Definition: undocuser.h:162
INIT_FUNCTION NTSTATUS NTAPI InitUserImpl(VOID)
Definition: ntuser.c:77
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
NTSTATUS NTAPI IntWinStaObjectDelete(_In_ PVOID Parameters)
Definition: winsta.c:106
PPROCESSINFO gppiList
Definition: main.c:31
Definition: object.h:3
unsigned char BOOLEAN
NTSTATUS GdiProcessDestroy(PEPROCESS Process)
Definition: init.c:47
PPROCESSINFO gppiInputProvider
Definition: ntuser.c:16
smooth NULL
Definition: ftsmooth.c:416
#define IntReferenceProcessInfo(ppi)
Definition: win32.h:177
LIST_ENTRY W32CallbackListHead
Definition: win32.h:150
VOID UserDeleteW32Process(_Pre_notnull_ __drv_freesMem(Mem) PPROCESSINFO ppiCurrent)
Definition: main.c:103
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
#define TIF_GUITHREADINITIALIZED
Definition: ntuser.h:264
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS GdiThreadCreate(PETHREAD Thread)
Definition: init.c:68
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1469
PKWIN32_SESSION_CALLOUT DesktopOkToCloseProcedure
Definition: pstypes.h:1622
NTSTATUS APIENTRY Win32kProcessCallback(PEPROCESS Process, BOOLEAN Initialize)
Definition: main.c:342
INIT_FUNCTION NTSTATUS NTAPI MsqInitializeImpl(VOID)
Definition: msgqueue.c:30
enum _PSW32THREADCALLOUTTYPE PSW32THREADCALLOUTTYPE
struct _CLIENTTHREADINFO * pcti
Definition: win32.h:90
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
PKWIN32_SESSION_CALLOUT DesktopDeleteProcedure
Definition: pstypes.h:1624
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FORCEINLINE PSINGLE_LIST_ENTRY PopEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead)
Definition: rtlfuncs.h:240
#define TIF_ALLOWFOREGROUNDACTIVATE
Definition: ntuser.h:245
INT cThreads
Definition: win32.h:253
INIT_FUNCTION NTSTATUS NTAPI InitDcImpl(VOID)
Definition: dclife.c:53
#define IntReferenceThreadInfo(pti)
Definition: win32.h:162
NTSTATUS NTAPI KdSystemDebugControl(IN SYSDBG_COMMAND Command, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN OUT PULONG ReturnLength, IN KPROCESSOR_MODE PreviousMode)
Definition: kdmain.c:489
void NTAPI UserDbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
Definition: misc.c:757
SHORT gusLanguageID
Definition: main.c:29
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:247
HWND hwndSAS
Definition: winsta.c:24
INIT_FUNCTION NTSTATUS NTAPI InitLDEVImpl(VOID)
Definition: ldevobj.c:30
INIT_FUNCTION NTSTATUS NTAPI InitDeviceImpl(VOID)
Definition: device.c:24
ULONG fsHooks
Definition: win32.h:116
BOOLEAN NTAPI DbgGdiKdbgCliCallback(IN PCHAR pszCommand, IN ULONG argc, IN PCH argv[])
Definition: gdikdbgext.c:324
VOID FASTCALL MsqDestroyMessageQueue(_In_ PTHREADINFO pti)
Definition: msgqueue.c:2457
NTSTATUS UserThreadDestroy(PETHREAD Thread)
Definition: main.c:443
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
PUSER_MESSAGE_QUEUE FASTCALL MsqCreateMessageQueue(PTHREADINFO pti)
Definition: msgqueue.c:2430
CLIENT_ID Cid
Definition: pstypes.h:1059
struct _DESKTOP * rpdeskStartup
Definition: win32.h:249
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
PKEVENT pEventQueueServer
Definition: win32.h:124
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3320
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
struct _CLIENTINFO * pClientInfo
Definition: win32.h:93
HKL hKL
Definition: ntuser.h:307
HANDLE UniqueThread
Definition: compat.h:475
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
NTSTATUS UserProcessCreate(PEPROCESS Process)
Definition: main.c:129
unsigned char UCHAR
Definition: xmlstorage.h:181
BOOL DbgInitDebugChannels()
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
INIT_FUNCTION NTSTATUS NTAPI InitPDEVImpl(VOID)
Definition: pdevobj.c:21
LONG timeLast
Definition: win32.h:101
struct _CLIENTINFO * PCLIENTINFO
BOOL FASTCALL UserSetProcessWindowStation(HWINSTA hWindowStation)
Definition: winsta.c:1346
ULONG_PTR NTAPI UserDbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult)
Definition: misc.c:764
PKWIN32_SESSION_CALLOUT DesktopOpenProcedure
Definition: pstypes.h:1621
BOOL FASTCALL co_IntGraphicsCheck(BOOL Create)
Definition: guicheck.c:52
NTSTATUS GdiProcessCreate(PEPROCESS Process)
Definition: init.c:18
#define NB_HOOKS
Definition: ntuser.h:130
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
LIST_ENTRY aphkStart[NB_HOOKS]
FIXME!
Definition: win32.h:137
PRTL_USER_PROCESS_PARAMETERS ProcessParameters
Definition: btrfs_drv.h:1838
NTSTATUS UserThreadCreate(PETHREAD Thread)
Definition: main.c:437
NTSTATUS NTAPI InitThreadCallback(PETHREAD Thread)
Definition: main.c:449
PPROCESSINFO ppiUahServer
Definition: hook.c:25
static BOOL Initialize(LPCWSTR lpDriverPath)
Definition: main.c:4
BOOL FASTCALL IntBlockInput(PTHREADINFO pti, BOOL BlockIt)
Definition: input.c:379
NTSTATUS NTAPI IntWinStaOkToClose(_In_ PVOID Parameters)
Definition: winsta.c:201
#define WM_LOGONNOTIFY
Definition: undocuser.h:37
CLIENTTHREADINFO cti
Definition: win32.h:138
VOID ResetCsrApiPort(VOID)
Definition: csr.c:58
PVOID GlobalUserHeapSection
Definition: usrheap.c:26
NTSTATUS NTAPI ExitThreadCallback(PETHREAD Thread)
Definition: main.c:691
#define _Pre_notnull_
Definition: no_sal2.h:496
struct tagKL * KeyboardLayout
Definition: win32.h:89
VOID FASTCALL UnregisterThreadHotKeys(PTHREADINFO pti)
Definition: hotkey.c:121
LIST_ENTRY DriverObjListHead
Definition: win32.h:280
Status
Definition: gdiplustypes.h:24
NTSTATUS UserProcessDestroy(PEPROCESS Process)
Definition: main.c:182
#define FreeW32Thread(W32Thread)
Definition: main.c:406
HANDLE hEventQueueClient
Definition: win32.h:122
ULONG_PTR Win32kSSDT[]
Definition: napi.h:9
struct _USER_MESSAGE_QUEUE * MessageQueue
Definition: win32.h:88
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:255
Definition: compat.h:484
USHORT CodePage
Definition: ntuser.h:308
#define TRACE_CH(ch, fmt,...)
Definition: debug.h:107
#define DBG_IS_CHANNEL_ENABLED(ppi, ch, level)
Definition: win32kdebug.h:164
#define TRACE_PPI(ppi, ch, fmt,...)
Definition: win32kdebug.h:181
SHORT FASTCALL UserGetLanguageID(VOID)
Definition: misc.c:96
#define W32PF_CLASSESREGISTERED
Definition: win32.h:17
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
VOID FASTCALL IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
Definition: callback.c:75
LIST_ENTRY PostedMessagesListHead
Definition: win32.h:131
#define STATUS_ALREADY_WIN32
Definition: ntstatus.h:141
UCHAR Win32kSSPT[]
Definition: napi.h:15
NTSTATUS NTAPI DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
Definition: main.c:690
BOOL IntSetThreadDesktop(IN HDESK hDesktop, IN BOOL FreeOnFailure)
Definition: desktop.c:3181
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSTATUS NTAPI IntDesktopObjectDelete(_In_ PVOID Parameters)
Definition: desktop.c:147
struct tagUSERSTARTUPINFO USERSTARTUPINFO
static DRIVER_UNLOAD DriverUnload
Definition: kbdclass.c:17
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
PKL W32kGetDefaultKeyLayout(VOID)
Definition: kbdlayout.c:343
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
Definition: cursoricon.c:391
#define STARTF_SCREENSAVER
Definition: undocuser.h:163
NTSTATUS FASTCALL IntResolveDesktop(IN PEPROCESS Process, IN PUNICODE_STRING DesktopPath, IN BOOL bInherit, OUT HWINSTA *phWinSta, OUT HDESK *phDesktop)
Definition: desktop.c:535
HANDLE GlobalUserHeap
Definition: usrheap.c:25
NTSTATUS FASTCALL IntValidateDesktopHandle(HDESK Desktop, KPROCESSOR_MODE AccessMode, ACCESS_MASK DesiredAccess, PDESKTOP *Object)
Definition: desktop.c:1200
HANDLE hModuleWin
Definition: main.c:16
VOID FASTCALL MsqCleanupThreadMsgs(PTHREADINFO pti)
Definition: msgqueue.c:2255
#define __drv_freesMem(kind)
Definition: driverspecs.h:254
NTSTATUS APIENTRY co_IntClientThreadSetup(VOID)
Definition: callback.c:948
INIT_FUNCTION NTSTATUS NTAPI InitInputImpl(VOID)
Definition: input.c:364
#define W32PF_APPSTARTING
Definition: win32.h:10
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI IntDesktopObjectClose(_In_ PVOID Parameters)
Definition: desktop.c:215
#define ERR_CH(ch, fmt,...)
Definition: debug.h:104
WORD wShowWindow
Definition: win32.h:214
struct _LARGE_INTEGER::@2190 u
#define FreeW32Process(W32Process)
Definition: main.c:92
BOOLEAN UserDestroyObjectsForOwner(PUSER_HANDLE_TABLE Table, PVOID Owner)
Definition: object.c:720
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID NTAPI PsEstablishWin32Callouts(IN PWIN32_CALLOUTS_FPNS CalloutData)
Definition: win32.c:112
void DbgUserDumpHandleTable()
#define OUT
Definition: typedefs.h:39
INIT_FUNCTION NTSTATUS NTAPI InitDesktopImpl(VOID)
Definition: desktop.c:236
INIT_FUNCTION NTSTATUS NTAPI InitTimerImpl(VOID)
Definition: timer.c:598
SINGLE_LIST_ENTRY ReferencesList
Definition: win32.h:151
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
PWIN32HEAP UserCreateHeap(OUT PVOID *SectionObject, IN OUT PVOID *SystemBase, IN SIZE_T HeapSize)
Definition: usrheap.c:177
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
uint32_t * PULONG_PTR
Definition: typedefs.h:63
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
PTHREADINFO ptiList
Definition: win32.h:247
VOID UserDeleteW32Thread(PTHREADINFO pti)
Definition: main.c:417
HANDLE NTAPI PsGetProcessId(PEPROCESS Process)
Definition: process.c:1063
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
BOOL FASTCALL IsRemoveAttachThread(PTHREADINFO pti)
Definition: input.c:441
PKWIN32_SESSION_CALLOUT WindowStationParseProcedure
Definition: pstypes.h:1628
PKWIN32_PROCESS_CALLOUT ProcessCallout
Definition: pstypes.h:1614
FAST_MUTEX DriverObjListLock
Definition: win32.h:279
struct _DESKTOPINFO * pDeskInfo
Definition: win32.h:92
struct _PROCESSINFO * ppi
Definition: ntuser.h:314
return STATUS_SUCCESS
Definition: btrfs.c:2725
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
#define IntDereferenceProcessInfo(ppi)
Definition: win32.h:182
DWORD dwTIFlags
Definition: ntuser.h:292
INT cEnterCount
Definition: win32.h:129
VOID UserDisplayNotifyShutdown(PPROCESSINFO ppiCurrent)
Definition: display.c:887
#define TIF_INCLEANUP
Definition: ntuser.h:240
base of all file and directory entries
Definition: entries.h:82
#define W32PF_THREADCONNECTED
Definition: win32.h:18
HANDLE gpidLogon
Definition: simplecall.c:15
#define APIENTRY
Definition: api.h:79
#define LN_SHELL_EXITED
Definition: undocuser.h:114
BOOLEAN NTAPI KeSetKernelStackSwapEnable(IN BOOLEAN Enable)
Definition: thrdobj.c:997
BOOL FASTCALL UserUnregisterUserApiHook(VOID)
Definition: hook.c:207
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
#define W32PF_SCREENSAVER
Definition: win32.h:26
#define NT_ASSERT
Definition: rtlfuncs.h:3312