ReactOS 0.4.16-dev-1946-g52006dd
query.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/ps/query.c
5 * PURPOSE: Process Manager: Thread/Process Query/Set Information
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Thomas Weidenmueller (w3seek@reactos.org)
8 * Eric Kohl
9 */
10
11/* INCLUDES ******************************************************************/
12
13#include <ntoskrnl.h>
14#define NDEBUG
15#include <debug.h>
16
17/* Debugging Level */
19
20/* PRIVATE FUNCTIONS *********************************************************/
21
27{
28 PSECTION Section;
29 PAGED_CODE();
30
31 /* Lock the process */
32 if (!ExAcquireRundownProtection(&Process->RundownProtect))
33 {
35 }
36
37 /* Get the section */
38 Section = Process->SectionObject;
39 if (Section)
40 {
41 /* Get the file object and reference it */
44 }
45
46 /* Release the protection */
47 ExReleaseRundownProtection(&Process->RundownProtect);
48
49 /* Return status */
50 return Section ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
51}
52
53#if DBG
54static
56PspDumpProcessInfoClassName(
57 _In_ PROCESSINFOCLASS ProcessInformationClass)
58{
59 static CHAR UnknownClassName[11];
60
61#define DBG_PROCESS_INFO_CLASS(InfoClass) [InfoClass] = #InfoClass
62 static const PCSTR ProcessInfoClasses[] =
63 {
64 DBG_PROCESS_INFO_CLASS(ProcessBasicInformation),
65 DBG_PROCESS_INFO_CLASS(ProcessQuotaLimits),
66 DBG_PROCESS_INFO_CLASS(ProcessVmCounters),
67 DBG_PROCESS_INFO_CLASS(ProcessTimes),
68 DBG_PROCESS_INFO_CLASS(ProcessBasePriority),
69 DBG_PROCESS_INFO_CLASS(ProcessRaisePriority),
70 DBG_PROCESS_INFO_CLASS(ProcessDebugPort),
71 DBG_PROCESS_INFO_CLASS(ProcessExceptionPort),
72 DBG_PROCESS_INFO_CLASS(ProcessAccessToken),
73 DBG_PROCESS_INFO_CLASS(ProcessLdtInformation),
74 DBG_PROCESS_INFO_CLASS(ProcessLdtSize),
75 DBG_PROCESS_INFO_CLASS(ProcessDefaultHardErrorMode),
76 DBG_PROCESS_INFO_CLASS(ProcessIoPortHandlers),
77 DBG_PROCESS_INFO_CLASS(ProcessPooledUsageAndLimits),
78 DBG_PROCESS_INFO_CLASS(ProcessWorkingSetWatch),
79 DBG_PROCESS_INFO_CLASS(ProcessUserModeIOPL),
80 DBG_PROCESS_INFO_CLASS(ProcessEnableAlignmentFaultFixup),
81 DBG_PROCESS_INFO_CLASS(ProcessPriorityClass),
82 DBG_PROCESS_INFO_CLASS(ProcessWx86Information),
83 DBG_PROCESS_INFO_CLASS(ProcessHandleCount),
84 DBG_PROCESS_INFO_CLASS(ProcessAffinityMask),
85 DBG_PROCESS_INFO_CLASS(ProcessPriorityBoost),
86 DBG_PROCESS_INFO_CLASS(ProcessDeviceMap),
87 DBG_PROCESS_INFO_CLASS(ProcessSessionInformation),
88 DBG_PROCESS_INFO_CLASS(ProcessForegroundInformation),
89 DBG_PROCESS_INFO_CLASS(ProcessWow64Information),
90 DBG_PROCESS_INFO_CLASS(ProcessImageFileName),
91 DBG_PROCESS_INFO_CLASS(ProcessLUIDDeviceMapsEnabled),
92 DBG_PROCESS_INFO_CLASS(ProcessBreakOnTermination),
93 DBG_PROCESS_INFO_CLASS(ProcessDebugObjectHandle),
94 DBG_PROCESS_INFO_CLASS(ProcessDebugFlags),
95 DBG_PROCESS_INFO_CLASS(ProcessHandleTracing),
96 DBG_PROCESS_INFO_CLASS(ProcessIoPriority),
97 DBG_PROCESS_INFO_CLASS(ProcessExecuteFlags),
98 DBG_PROCESS_INFO_CLASS(ProcessTlsInformation),
99 DBG_PROCESS_INFO_CLASS(ProcessCookie),
100 DBG_PROCESS_INFO_CLASS(ProcessImageInformation),
101 DBG_PROCESS_INFO_CLASS(ProcessCycleTime),
102 DBG_PROCESS_INFO_CLASS(ProcessPagePriority),
103 DBG_PROCESS_INFO_CLASS(ProcessInstrumentationCallback),
104 DBG_PROCESS_INFO_CLASS(ProcessThreadStackAllocation),
105 DBG_PROCESS_INFO_CLASS(ProcessWorkingSetWatchEx),
106 DBG_PROCESS_INFO_CLASS(ProcessImageFileNameWin32),
107 DBG_PROCESS_INFO_CLASS(ProcessImageFileMapping),
108 DBG_PROCESS_INFO_CLASS(ProcessAffinityUpdateMode),
109 DBG_PROCESS_INFO_CLASS(ProcessMemoryAllocationMode),
110 DBG_PROCESS_INFO_CLASS(ProcessGroupInformation),
111 DBG_PROCESS_INFO_CLASS(ProcessConsoleHostProcess),
112 DBG_PROCESS_INFO_CLASS(ProcessWindowInformation),
113 };
114#undef DBG_PROCESS_INFO_CLASS
115
116 if (ProcessInformationClass < RTL_NUMBER_OF(ProcessInfoClasses))
117 {
118 return ProcessInfoClasses[ProcessInformationClass];
119 }
120
121 sprintf(UnknownClassName, "%lu", ProcessInformationClass);
122 return UnknownClassName;
123}
124
125static
126PCSTR
127PspDumpThreadInfoClassName(
129{
130 static CHAR UnknownClassName[11];
131
132#define DBG_THREAD_INFO_CLASS(InfoClass) [InfoClass] = #InfoClass
133 static const PCSTR ThreadInfoClasses[] =
134 {
135 DBG_THREAD_INFO_CLASS(ThreadBasicInformation),
136 DBG_THREAD_INFO_CLASS(ThreadTimes),
137 DBG_THREAD_INFO_CLASS(ThreadPriority),
138 DBG_THREAD_INFO_CLASS(ThreadBasePriority),
139 DBG_THREAD_INFO_CLASS(ThreadAffinityMask),
140 DBG_THREAD_INFO_CLASS(ThreadImpersonationToken),
141 DBG_THREAD_INFO_CLASS(ThreadDescriptorTableEntry),
142 DBG_THREAD_INFO_CLASS(ThreadEnableAlignmentFaultFixup),
143 DBG_THREAD_INFO_CLASS(ThreadEventPair_Reusable),
144 DBG_THREAD_INFO_CLASS(ThreadQuerySetWin32StartAddress),
145 DBG_THREAD_INFO_CLASS(ThreadZeroTlsCell),
146 DBG_THREAD_INFO_CLASS(ThreadPerformanceCount),
147 DBG_THREAD_INFO_CLASS(ThreadAmILastThread),
148 DBG_THREAD_INFO_CLASS(ThreadIdealProcessor),
149 DBG_THREAD_INFO_CLASS(ThreadPriorityBoost),
150 DBG_THREAD_INFO_CLASS(ThreadSetTlsArrayAddress),
151 DBG_THREAD_INFO_CLASS(ThreadIsIoPending),
152 DBG_THREAD_INFO_CLASS(ThreadHideFromDebugger),
153 DBG_THREAD_INFO_CLASS(ThreadBreakOnTermination),
154 DBG_THREAD_INFO_CLASS(ThreadSwitchLegacyState),
155 DBG_THREAD_INFO_CLASS(ThreadIsTerminated),
156 DBG_THREAD_INFO_CLASS(ThreadLastSystemCall),
157 DBG_THREAD_INFO_CLASS(ThreadIoPriority),
158 DBG_THREAD_INFO_CLASS(ThreadCycleTime),
159 DBG_THREAD_INFO_CLASS(ThreadPagePriority),
160 DBG_THREAD_INFO_CLASS(ThreadActualBasePriority),
161 DBG_THREAD_INFO_CLASS(ThreadTebInformation),
162 DBG_THREAD_INFO_CLASS(ThreadCSwitchMon),
163 DBG_THREAD_INFO_CLASS(ThreadCSwitchPmu),
164 DBG_THREAD_INFO_CLASS(ThreadWow64Context),
165 DBG_THREAD_INFO_CLASS(ThreadGroupInformation),
166 DBG_THREAD_INFO_CLASS(ThreadUmsInformation),
167 DBG_THREAD_INFO_CLASS(ThreadCounterProfiling),
168 DBG_THREAD_INFO_CLASS(ThreadIdealProcessorEx),
169 DBG_THREAD_INFO_CLASS(ThreadCpuAccountingInformation),
170 DBG_THREAD_INFO_CLASS(ThreadSuspendCount),
171 DBG_THREAD_INFO_CLASS(ThreadHeterogeneousCpuPolicy),
172 DBG_THREAD_INFO_CLASS(ThreadContainerId),
173 DBG_THREAD_INFO_CLASS(ThreadNameInformation),
174 DBG_THREAD_INFO_CLASS(ThreadSelectedCpuSets),
175 DBG_THREAD_INFO_CLASS(ThreadSystemThreadInformation),
176 DBG_THREAD_INFO_CLASS(ThreadActualGroupAffinity),
177 DBG_THREAD_INFO_CLASS(ThreadDynamicCodePolicyInfo),
178 DBG_THREAD_INFO_CLASS(ThreadExplicitCaseSensitivity),
179 DBG_THREAD_INFO_CLASS(ThreadWorkOnBehalfTicket),
180 DBG_THREAD_INFO_CLASS(ThreadSubsystemInformation),
181 DBG_THREAD_INFO_CLASS(ThreadDbgkWerReportActive),
182 DBG_THREAD_INFO_CLASS(ThreadAttachContainer),
183 DBG_THREAD_INFO_CLASS(ThreadManageWritesToExecutableMemory),
184 DBG_THREAD_INFO_CLASS(ThreadPowerThrottlingState),
185 DBG_THREAD_INFO_CLASS(ThreadWorkloadClass),
186 DBG_THREAD_INFO_CLASS(ThreadCreateStateChange),
187 DBG_THREAD_INFO_CLASS(ThreadApplyStateChange),
188 DBG_THREAD_INFO_CLASS(ThreadStrongerBadHandleChecks),
189 DBG_THREAD_INFO_CLASS(ThreadEffectiveIoPriority),
190 DBG_THREAD_INFO_CLASS(ThreadEffectivePagePriority),
191 };
192#undef DBG_THREAD_INFO_CLASS
193
194 if (ThreadInformationClass < RTL_NUMBER_OF(ThreadInfoClasses))
195 {
196 return ThreadInfoClasses[ThreadInformationClass];
197 }
198
199 sprintf(UnknownClassName, "%lu", ThreadInformationClass);
200 return UnknownClassName;
201}
202#endif // #if DBG
203
204/* PUBLIC FUNCTIONS **********************************************************/
205
206/*
207 * @implemented
208 */
210NTAPI
213 _In_ PROCESSINFOCLASS ProcessInformationClass,
214 _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength)
215 PVOID ProcessInformation,
216 _In_ ULONG ProcessInformationLength,
218{
222 ULONG Length = 0;
223
224 PAGED_CODE();
225
226 /* Validate the information class */
227 Status = DefaultQueryInfoBufferCheck(ProcessInformationClass,
231 ProcessInformation,
232 ProcessInformationLength,
234 NULL,
236 if (!NT_SUCCESS(Status))
237 {
238#if DBG
239 DPRINT1("NtQueryInformationProcess(ProcessInformationClass: %s): Class validation failed! (Status: 0x%lx)\n",
240 PspDumpProcessInfoClassName(ProcessInformationClass), Status);
241#endif
242 return Status;
243 }
244
245 if (((ProcessInformationClass == ProcessCookie) ||
246 (ProcessInformationClass == ProcessImageInformation)) &&
248 {
249 /*
250 * Retrieving the process cookie is only allowed for the calling process
251 * itself! XP only allows NtCurrentProcess() as process handles even if
252 * a real handle actually represents the current process.
253 */
255 }
256
257 /* Check the information class */
258 switch (ProcessInformationClass)
259 {
260 /* Basic process information */
262 {
263 PPROCESS_BASIC_INFORMATION ProcessBasicInfo = (PPROCESS_BASIC_INFORMATION)ProcessInformation;
264
265 if (ProcessInformationLength != sizeof(PROCESS_BASIC_INFORMATION))
266 {
268 break;
269 }
270
271 /* Set the return length */
273
274 /* Reference the process */
279 (PVOID*)&Process,
280 NULL);
281 if (!NT_SUCCESS(Status)) break;
282
283 /* Protect writes with SEH */
285 {
286 /* Write all the information from the EPROCESS/KPROCESS */
287 ProcessBasicInfo->ExitStatus = Process->ExitStatus;
288 ProcessBasicInfo->PebBaseAddress = Process->Peb;
289 ProcessBasicInfo->AffinityMask = Process->Pcb.Affinity;
290 ProcessBasicInfo->UniqueProcessId = (ULONG_PTR)Process->
291 UniqueProcessId;
292 ProcessBasicInfo->InheritedFromUniqueProcessId =
293 (ULONG_PTR)Process->InheritedFromUniqueProcessId;
294 ProcessBasicInfo->BasePriority = Process->Pcb.BasePriority;
295
296 }
298 {
299 /* Get exception code */
301 }
302 _SEH2_END;
303
304 /* Dereference the process */
306 break;
307 }
308
309 /* Process quota limits */
311 {
312 QUOTA_LIMITS_EX QuotaLimits;
313 BOOLEAN Extended;
314
315 if (ProcessInformationLength != sizeof(QUOTA_LIMITS) &&
316 ProcessInformationLength != sizeof(QUOTA_LIMITS_EX))
317 {
319 break;
320 }
321
322 /* Set the return length */
323 Length = ProcessInformationLength;
324 Extended = (Length == sizeof(QUOTA_LIMITS_EX));
325
326 /* Reference the process */
331 (PVOID*)&Process,
332 NULL);
333 if (!NT_SUCCESS(Status)) break;
334
335 /* Indicate success */
337
338 RtlZeroMemory(&QuotaLimits, sizeof(QuotaLimits));
339
340 /* Get max/min working set sizes */
341 QuotaLimits.MaximumWorkingSetSize =
342 Process->Vm.MaximumWorkingSetSize << PAGE_SHIFT;
343 QuotaLimits.MinimumWorkingSetSize =
344 Process->Vm.MinimumWorkingSetSize << PAGE_SHIFT;
345
346 /* Get default time limits */
347 QuotaLimits.TimeLimit.QuadPart = -1LL;
348
349 /* Is quota block a default one? */
350 if (Process->QuotaBlock == &PspDefaultQuotaBlock)
351 {
352 /* Get default pools and pagefile limits */
353 QuotaLimits.PagedPoolLimit = (SIZE_T)-1;
354 QuotaLimits.NonPagedPoolLimit = (SIZE_T)-1;
355 QuotaLimits.PagefileLimit = (SIZE_T)-1;
356 }
357 else
358 {
359 /* Get limits from non-default quota block */
360 QuotaLimits.PagedPoolLimit =
361 Process->QuotaBlock->QuotaEntry[PsPagedPool].Limit;
362 QuotaLimits.NonPagedPoolLimit =
363 Process->QuotaBlock->QuotaEntry[PsNonPagedPool].Limit;
364 QuotaLimits.PagefileLimit =
365 Process->QuotaBlock->QuotaEntry[PsPageFile].Limit;
366 }
367
368 /* Get additional information, if needed */
369 if (Extended)
370 {
371 QuotaLimits.Flags |= (Process->Vm.Flags.MaximumWorkingSetHard ?
373 QuotaLimits.Flags |= (Process->Vm.Flags.MinimumWorkingSetHard ?
375
376 /* FIXME: Get the correct information */
377 //QuotaLimits.WorkingSetLimit = (SIZE_T)-1; // Not used on Win2k3, it is set to 0
378 QuotaLimits.CpuRateLimit.RateData = 0;
379 }
380
381 /* Protect writes with SEH */
383 {
384 RtlCopyMemory(ProcessInformation, &QuotaLimits, Length);
385 }
387 {
388 /* Get exception code */
390 }
391 _SEH2_END;
392
393 /* Dereference the process */
395 break;
396 }
397
399 {
400 PIO_COUNTERS IoCounters = (PIO_COUNTERS)ProcessInformation;
401 PROCESS_VALUES ProcessValues;
402
403 if (ProcessInformationLength != sizeof(IO_COUNTERS))
404 {
406 break;
407 }
408
409 Length = sizeof(IO_COUNTERS);
410
411 /* Reference the process */
416 (PVOID*)&Process,
417 NULL);
418 if (!NT_SUCCESS(Status)) break;
419
420 /* Query IO counters from the process */
421 KeQueryValuesProcess(&Process->Pcb, &ProcessValues);
422
424 {
425 RtlCopyMemory(IoCounters, &ProcessValues.IoInfo, sizeof(IO_COUNTERS));
426 }
428 {
429 /* Ignore exception */
430 }
431 _SEH2_END;
432
433 /* Set status to success in any case */
435
436 /* Dereference the process */
438 break;
439 }
440
441 /* Timing */
442 case ProcessTimes:
443 {
444 PKERNEL_USER_TIMES ProcessTime = (PKERNEL_USER_TIMES)ProcessInformation;
445 ULONG UserTime, KernelTime;
446
447 /* Set the return length */
448 if (ProcessInformationLength != sizeof(KERNEL_USER_TIMES))
449 {
451 break;
452 }
453
454 Length = sizeof(KERNEL_USER_TIMES);
455
456 /* Reference the process */
461 (PVOID*)&Process,
462 NULL);
463 if (!NT_SUCCESS(Status)) break;
464
465 /* Protect writes with SEH */
467 {
468 /* Copy time information from EPROCESS/KPROCESS */
469 KernelTime = KeQueryRuntimeProcess(&Process->Pcb, &UserTime);
470 ProcessTime->CreateTime = Process->CreateTime;
472 ProcessTime->KernelTime.QuadPart = (LONGLONG)KernelTime * KeMaximumIncrement;
473 ProcessTime->ExitTime = Process->ExitTime;
474 }
476 {
477 /* Get exception code */
479 }
480 _SEH2_END;
481
482 /* Dereference the process */
484 break;
485 }
486
487 /* Process Debug Port */
488 case ProcessDebugPort:
489
490 if (ProcessInformationLength != sizeof(HANDLE))
491 {
493 break;
494 }
495
496 /* Set the return length */
497 Length = sizeof(HANDLE);
498
499 /* Reference the process */
504 (PVOID*)&Process,
505 NULL);
506 if (!NT_SUCCESS(Status)) break;
507
508 /* Protect write with SEH */
510 {
511 /* Return whether or not we have a debug port */
512 *(PHANDLE)ProcessInformation = (Process->DebugPort ?
513 (HANDLE)-1 : NULL);
514 }
516 {
517 /* Get exception code */
519 }
520 _SEH2_END;
521
522 /* Dereference the process */
524 break;
525
527 {
528 ULONG HandleCount;
529
530 if (ProcessInformationLength != sizeof(ULONG))
531 {
533 break;
534 }
535
536 /* Set the return length*/
537 Length = sizeof(ULONG);
538
539 /* Reference the process */
544 (PVOID*)&Process,
545 NULL);
546 if (!NT_SUCCESS(Status)) break;
547
548 /* Count the number of handles this process has */
549 HandleCount = ObGetProcessHandleCount(Process);
550
551 /* Protect write in SEH */
553 {
554 /* Return the count of handles */
555 *(PULONG)ProcessInformation = HandleCount;
556 }
558 {
559 /* Get the exception code */
561 }
562 _SEH2_END;
563
564 /* Dereference the process */
566 break;
567 }
568
569 /* Session ID for the process */
571 {
573
574 if (ProcessInformationLength != sizeof(PROCESS_SESSION_INFORMATION))
575 {
577 break;
578 }
579
580 /* Set the return length*/
582
583 /* Reference the process */
588 (PVOID*)&Process,
589 NULL);
590 if (!NT_SUCCESS(Status)) break;
591
592 /* Enter SEH for write safety */
594 {
595 /* Write back the Session ID */
597 }
599 {
600 /* Get the exception code */
602 }
603 _SEH2_END;
604
605 /* Dereference the process */
607 break;
608 }
609
610 /* Virtual Memory Statistics */
612 {
613 PVM_COUNTERS VmCounters = (PVM_COUNTERS)ProcessInformation;
614
615 /* Validate the input length */
616 if ((ProcessInformationLength != sizeof(VM_COUNTERS)) &&
617 (ProcessInformationLength != sizeof(VM_COUNTERS_EX)))
618 {
620 break;
621 }
622
623 /* Reference the process */
628 (PVOID*)&Process,
629 NULL);
630 if (!NT_SUCCESS(Status)) break;
631
632 /* Enter SEH for write safety */
634 {
635 /* Return data from EPROCESS */
636 VmCounters->PeakVirtualSize = Process->PeakVirtualSize;
637 VmCounters->VirtualSize = Process->VirtualSize;
638 VmCounters->PageFaultCount = Process->Vm.PageFaultCount;
639 VmCounters->PeakWorkingSetSize = Process->Vm.PeakWorkingSetSize;
640 VmCounters->WorkingSetSize = Process->Vm.WorkingSetSize;
641 VmCounters->QuotaPeakPagedPoolUsage = Process->QuotaPeak[PsPagedPool];
642 VmCounters->QuotaPagedPoolUsage = Process->QuotaUsage[PsPagedPool];
643 VmCounters->QuotaPeakNonPagedPoolUsage = Process->QuotaPeak[PsNonPagedPool];
644 VmCounters->QuotaNonPagedPoolUsage = Process->QuotaUsage[PsNonPagedPool];
645 VmCounters->PagefileUsage = Process->QuotaUsage[PsPageFile] << PAGE_SHIFT;
646 VmCounters->PeakPagefileUsage = Process->QuotaPeak[PsPageFile] << PAGE_SHIFT;
647 //VmCounters->PrivateUsage = Process->CommitCharge << PAGE_SHIFT;
648 //
649
650 /* Set the return length */
651 Length = ProcessInformationLength;
652 }
654 {
655 /* Get the exception code */
657 }
658 _SEH2_END;
659
660 /* Dereference the process */
662 break;
663 }
664
665 /* Hard Error Processing Mode */
667
668 if (ProcessInformationLength != sizeof(ULONG))
669 {
671 break;
672 }
673
674 /* Set the return length*/
675 Length = sizeof(ULONG);
676
677 /* Reference the process */
682 (PVOID*)&Process,
683 NULL);
684 if (!NT_SUCCESS(Status)) break;
685
686 /* Enter SEH for writing back data */
688 {
689 /* Write the current processing mode */
690 *(PULONG)ProcessInformation = Process->
691 DefaultHardErrorProcessing;
692 }
694 {
695 /* Get the exception code */
697 }
698 _SEH2_END;
699
700 /* Dereference the process */
702 break;
703
704 /* Priority Boosting status */
706
707 if (ProcessInformationLength != sizeof(ULONG))
708 {
710 break;
711 }
712
713 /* Set the return length */
714 Length = sizeof(ULONG);
715
716 /* Reference the process */
721 (PVOID*)&Process,
722 NULL);
723 if (!NT_SUCCESS(Status)) break;
724
725 /* Enter SEH for writing back data */
727 {
728 /* Return boost status */
729 *(PULONG)ProcessInformation = Process->Pcb.DisableBoost ?
730 TRUE : FALSE;
731 }
733 {
734 /* Get the exception code */
736 }
737 _SEH2_END;
738
739 /* Dereference the process */
741 break;
742
743 /* DOS Device Map */
744 case ProcessDeviceMap:
745 {
746 ULONG Flags;
747
748 if (ProcessInformationLength == sizeof(PROCESS_DEVICEMAP_INFORMATION_EX))
749 {
750 /* Protect read in SEH */
752 {
753 PPROCESS_DEVICEMAP_INFORMATION_EX DeviceMapEx = ProcessInformation;
754
755 Flags = DeviceMapEx->Flags;
756 }
758 {
759 /* Get the exception code */
761 _SEH2_YIELD(break);
762 }
763 _SEH2_END;
764
765 /* Only one flag is supported and it needs LUID mappings */
766 if ((Flags & ~PROCESS_LUID_DOSDEVICES_ONLY) != 0 ||
768 {
770 break;
771 }
772 }
773 else
774 {
775 /* This has to be the size of the Query union field for x64 compatibility! */
776 if (ProcessInformationLength != RTL_FIELD_SIZE(PROCESS_DEVICEMAP_INFORMATION, Query))
777 {
779 break;
780 }
781
782 /* No flags for standard call */
783 Flags = 0;
784 }
785
786 /* Set the return length */
787 Length = ProcessInformationLength;
788
789 /* Reference the process */
794 (PVOID*)&Process,
795 NULL);
796 if (!NT_SUCCESS(Status)) break;
797
798 /* Query the device map information */
800 ProcessInformation,
801 Flags);
802
803 /* Dereference the process */
805 break;
806 }
807
808 /* Priority class */
810 {
811 PPROCESS_PRIORITY_CLASS PsPriorityClass = (PPROCESS_PRIORITY_CLASS)ProcessInformation;
812
813 if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
814 {
816 break;
817 }
818
819 /* Set the return length*/
821
822 /* Reference the process */
827 (PVOID*)&Process,
828 NULL);
829 if (!NT_SUCCESS(Status)) break;
830
831 /* Enter SEH for writing back data */
833 {
834 /* Return current priority class */
835 PsPriorityClass->PriorityClass = Process->PriorityClass;
836 PsPriorityClass->Foreground = FALSE;
837 }
839 {
840 /* Get the exception code */
842 }
843 _SEH2_END;
844
845 /* Dereference the process */
847 break;
848 }
849
851 {
853
854 /* Reference the process */
859 (PVOID*)&Process,
860 NULL);
861 if (!NT_SUCCESS(Status)) break;
862
863 /* Get the image path */
865 if (NT_SUCCESS(Status))
866 {
867 /* Set the return length */
868 Length = ImageName->MaximumLength +
870
871 /* Make sure it's large enough */
872 if (Length <= ProcessInformationLength)
873 {
874 /* Enter SEH to protect write */
876 {
877 /* Copy it */
878 RtlCopyMemory(ProcessInformation,
879 ImageName,
880 Length);
881
882 /* Update pointer */
883 ((PUNICODE_STRING)ProcessInformation)->Buffer =
884 (PWSTR)((PUNICODE_STRING)ProcessInformation + 1);
885 }
887 {
888 /* Get the exception code */
890 }
891 _SEH2_END;
892 }
893 else
894 {
895 /* Buffer too small */
897 }
898
899 /* Free the image path */
901 }
902 /* Dereference the process */
904 break;
905 }
906
907#if (NTDDI_VERSION >= NTDDI_VISTA) || (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
909 {
912
913 /* Reference the process */
915 PROCESS_QUERY_INFORMATION, // FIXME: Use PROCESS_QUERY_LIMITED_INFORMATION if implemented
918 (PVOID*)&Process,
919 NULL);
920 if (!NT_SUCCESS(Status))
921 {
922 break;
923 }
924
925 /* Get the image path */
928 if (!NT_SUCCESS(Status))
929 {
930 break;
931 }
934 if (!NT_SUCCESS(Status))
935 {
936 break;
937 }
938
939 /* Determine return length and output */
940 Length = sizeof(UNICODE_STRING) + ObjectNameInformation->Name.MaximumLength;
941 if (Length <= ProcessInformationLength)
942 {
944 {
945 PUNICODE_STRING ImageName = (PUNICODE_STRING)ProcessInformation;
946 ImageName->Length = ObjectNameInformation->Name.Length;
947 ImageName->MaximumLength = ObjectNameInformation->Name.MaximumLength;
948 if (ObjectNameInformation->Name.MaximumLength)
949 {
950 ImageName->Buffer = (PWSTR)(ImageName + 1);
951 RtlCopyMemory(ImageName->Buffer,
952 ObjectNameInformation->Name.Buffer,
953 ObjectNameInformation->Name.MaximumLength);
954 }
955 else
956 {
957 ASSERT(ImageName->Length == 0);
958 ImageName->Buffer = NULL;
959 }
960 }
962 {
964 }
965 _SEH2_END;
966 }
967 else
968 {
970 }
972
973 break;
974 }
975#endif /* (NTDDI_VERSION >= NTDDI_VISTA) || (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA) */
976
978
979 if (ProcessInformationLength != sizeof(ULONG))
980 {
982 break;
983 }
984
985 /* Set the return length*/
986 Length = sizeof(ULONG);
987
988 /* Reference the process */
993 (PVOID*)&Process,
994 NULL);
995 if (!NT_SUCCESS(Status)) break;
996
997 /* Enter SEH for writing back data */
999 {
1000 /* Return the debug flag state */
1001 *(PULONG)ProcessInformation = Process->NoDebugInherit ? 0 : 1;
1002 }
1004 {
1005 /* Get the exception code */
1007 }
1008 _SEH2_END;
1009
1010 /* Dereference the process */
1012 break;
1013
1015
1016 if (ProcessInformationLength != sizeof(ULONG))
1017 {
1019 break;
1020 }
1021
1022 /* Set the return length */
1023 Length = sizeof(ULONG);
1024
1025 /* Reference the process */
1030 (PVOID*)&Process,
1031 NULL);
1032 if (!NT_SUCCESS(Status)) break;
1033
1034 /* Enter SEH for writing back data */
1035 _SEH2_TRY
1036 {
1037 /* Return the BreakOnTermination state */
1038 *(PULONG)ProcessInformation = Process->BreakOnTermination;
1039 }
1041 {
1042 /* Get the exception code */
1044 }
1045 _SEH2_END;
1046
1047 /* Dereference the process */
1049 break;
1050
1051 /* Per-process security cookie */
1052 case ProcessCookie:
1053 {
1054 ULONG Cookie;
1055
1056 if (ProcessInformationLength != sizeof(ULONG))
1057 {
1058 /* Length size wrong, bail out */
1060 break;
1061 }
1062
1063 /* Get the current process and cookie */
1065 Cookie = Process->Cookie;
1066 if (!Cookie)
1067 {
1068 LARGE_INTEGER SystemTime;
1069 ULONG NewCookie;
1070 PKPRCB Prcb;
1071
1072 /* Generate a new cookie */
1073 KeQuerySystemTime(&SystemTime);
1074 Prcb = KeGetCurrentPrcb();
1075 NewCookie = Prcb->KeSystemCalls ^ Prcb->InterruptTime ^
1076 SystemTime.u.LowPart ^ SystemTime.u.HighPart;
1077
1078 /* Set the new cookie or return the current one */
1080 NewCookie,
1081 Cookie);
1082 if (!Cookie) Cookie = NewCookie;
1083
1084 /* Set the return length */
1085 Length = sizeof(ULONG);
1086 }
1087
1088 /* Indicate success */
1090
1091 /* Enter SEH to protect write */
1092 _SEH2_TRY
1093 {
1094 /* Write back the cookie */
1095 *(PULONG)ProcessInformation = Cookie;
1096 }
1098 {
1099 /* Get the exception code */
1101 }
1102 _SEH2_END;
1103 break;
1104 }
1105
1107
1108 if (ProcessInformationLength != sizeof(SECTION_IMAGE_INFORMATION))
1109 {
1110 /* Break out */
1112 break;
1113 }
1114
1115 /* Set the length required and validate it */
1117
1118 /* Indicate success */
1120
1121 /* Enter SEH to protect write */
1122 _SEH2_TRY
1123 {
1125 }
1127 {
1128 /* Get the exception code */
1130 }
1131 _SEH2_END;
1132 break;
1133
1135 {
1136 HANDLE DebugPort = NULL;
1137
1138 if (ProcessInformationLength != sizeof(HANDLE))
1139 {
1141 break;
1142 }
1143
1144 /* Set the return length */
1145 Length = sizeof(HANDLE);
1146
1147 /* Reference the process */
1152 (PVOID*)&Process,
1153 NULL);
1154 if (!NT_SUCCESS(Status)) break;
1155
1156 /* Get the debug port. Continue even if this fails. */
1158
1159 /* Let go of the process */
1161
1162 /* Protect write in SEH */
1163 _SEH2_TRY
1164 {
1165 /* Return debug port's handle */
1166 *(PHANDLE)ProcessInformation = DebugPort;
1167 }
1169 {
1170 if (DebugPort)
1171 ObCloseHandle(DebugPort, PreviousMode);
1172
1173 /* Get the exception code.
1174 * Note: This overwrites any previous failure status. */
1176 }
1177 _SEH2_END;
1178 break;
1179 }
1180
1182 DPRINT1("Handle tracing not implemented: %lu\n", ProcessInformationClass);
1184 break;
1185
1187
1188 if (ProcessInformationLength != sizeof(ULONG))
1189 {
1191 break;
1192 }
1193
1194 /* Set the return length */
1195 Length = sizeof(ULONG);
1196
1197 /* Indicate success */
1199
1200 /* Protect write in SEH */
1201 _SEH2_TRY
1202 {
1203 /* Query Ob */
1204 *(PULONG)ProcessInformation = ObIsLUIDDeviceMapsEnabled();
1205 }
1207 {
1208 /* Get the exception code */
1210 }
1211 _SEH2_END;
1212 break;
1213
1215
1216 if (ProcessInformationLength != sizeof(ULONG))
1217 {
1219 break;
1220 }
1221
1222 /* Set the return length */
1223 Length = sizeof(ULONG);
1224
1225 /* Reference the process */
1230 (PVOID*)&Process,
1231 NULL);
1232 if (!NT_SUCCESS(Status)) break;
1233
1234 /* Protect write in SEH */
1235 _SEH2_TRY
1236 {
1237 /* Return if the flag is set */
1238 *(PULONG)ProcessInformation = (ULONG)Process->VdmAllowed;
1239 }
1241 {
1242 /* Get the exception code */
1244 }
1245 _SEH2_END;
1246
1247 /* Dereference the process */
1249 break;
1250
1252 {
1253 ULONG_PTR Wow64 = 0;
1254
1255 if (ProcessInformationLength != sizeof(ULONG_PTR))
1256 {
1258 break;
1259 }
1260
1261 /* Set the return length */
1262 Length = sizeof(ULONG_PTR);
1263
1264 /* Reference the process */
1269 (PVOID*)&Process,
1270 NULL);
1271 if (!NT_SUCCESS(Status)) break;
1272
1273#ifdef _WIN64
1274 /* Make sure the process isn't dying */
1275 if (ExAcquireRundownProtection(&Process->RundownProtect))
1276 {
1277 /* Get the WOW64 process structure */
1278 Wow64 = (ULONG_PTR)Process->Wow64Process;
1279 /* Release the lock */
1280 ExReleaseRundownProtection(&Process->RundownProtect);
1281 }
1282#endif
1283
1284 /* Dereference the process */
1286
1287 /* Protect write with SEH */
1288 _SEH2_TRY
1289 {
1290 /* Return the Wow64 process information */
1291 *(PULONG_PTR)ProcessInformation = Wow64;
1292 }
1294 {
1295 /* Get exception code */
1297 }
1298 _SEH2_END;
1299 break;
1300 }
1301
1303 {
1304 ULONG ExecuteOptions = 0;
1305
1306 if (ProcessInformationLength != sizeof(ULONG))
1307 {
1309 break;
1310 }
1311
1312 /* Set the return length */
1313 Length = sizeof(ULONG);
1314
1316 {
1318 break;
1319 }
1320
1321 /* Get the options */
1322 Status = MmGetExecuteOptions(&ExecuteOptions);
1323 if (NT_SUCCESS(Status))
1324 {
1325 /* Protect write with SEH */
1326 _SEH2_TRY
1327 {
1328 /* Return them */
1329 *(PULONG)ProcessInformation = ExecuteOptions;
1330 }
1332 {
1333 /* Get exception code */
1335 }
1336 _SEH2_END;
1337 }
1338 break;
1339 }
1340
1342 DPRINT1("VDM/16-bit not implemented: %lu\n", ProcessInformationClass);
1344 break;
1345
1347 DPRINT1("WS Watch not implemented: %lu\n", ProcessInformationClass);
1349 break;
1350
1352 DPRINT1("Pool limits not implemented: %lu\n", ProcessInformationClass);
1354 break;
1355
1356 /* Not supported by Server 2003 */
1357 default:
1358#if DBG
1359 DPRINT1("Unsupported info class: %s\n", PspDumpProcessInfoClassName(ProcessInformationClass));
1360#endif
1362 }
1363
1364 /* Check if caller wants the return length and if there is one */
1365 if (ReturnLength != NULL && Length != 0)
1366 {
1367 /* Protect write with SEH */
1368 _SEH2_TRY
1369 {
1371 }
1373 {
1374 /* Get exception code.
1375 * Note: This overwrites any previous failure status. */
1377 }
1378 _SEH2_END;
1379 }
1380
1381 return Status;
1382}
1383
1384/*
1385 * @implemented
1386 */
1388NTAPI
1391 _In_ PROCESSINFOCLASS ProcessInformationClass,
1392 _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation,
1393 _In_ ULONG ProcessInformationLength)
1394{
1397 ACCESS_MASK Access;
1399 HANDLE PortHandle = NULL;
1403 PROCESS_PRIORITY_CLASS PriorityClass = {0};
1404 PROCESS_FOREGROUND_BACKGROUND Foreground = {0};
1405 PVOID ExceptionPort;
1406 ULONG Break;
1407 KAFFINITY ValidAffinity, Affinity = 0;
1408 KPRIORITY BasePriority = 0;
1409 UCHAR MemoryPriority = 0;
1410 BOOLEAN DisableBoost = 0;
1411 ULONG DefaultHardErrorMode = 0;
1412 ULONG DebugFlags = 0, EnableFixup = 0, Boost = 0;
1413 ULONG NoExecute = 0, VdmPower = 0;
1417 PAGED_CODE();
1418
1419 /* Validate the information class */
1420 Status = DefaultSetInfoBufferCheck(ProcessInformationClass,
1423 ProcessInformation,
1424 ProcessInformationLength,
1425 PreviousMode);
1426 if (!NT_SUCCESS(Status))
1427 {
1428#if DBG
1429 DPRINT1("NtSetInformationProcess(ProcessInformationClass: %s): Class validation failed! (Status: 0x%lx)\n",
1430 PspDumpProcessInfoClassName(ProcessInformationClass), Status);
1431#endif
1432 return Status;
1433 }
1434
1435 /* Check what class this is */
1436 Access = PROCESS_SET_INFORMATION;
1437 if (ProcessInformationClass == ProcessSessionInformation)
1438 {
1439 /* Setting the Session ID needs a special mask */
1440 Access |= PROCESS_SET_SESSIONID;
1441 }
1442 else if (ProcessInformationClass == ProcessExceptionPort)
1443 {
1444 /* Setting the exception port needs a special mask */
1445 Access |= PROCESS_SUSPEND_RESUME;
1446 }
1447
1448 /* Reference the process */
1450 Access,
1453 (PVOID*)&Process,
1454 NULL);
1455 if (!NT_SUCCESS(Status)) return Status;
1456
1457 /* Check what kind of information class this is */
1458 switch (ProcessInformationClass)
1459 {
1461
1462 /* Check buffer length */
1463 if (ProcessInformationLength != sizeof(ULONG))
1464 {
1466 break;
1467 }
1468
1469 /* Use SEH for capture */
1470 _SEH2_TRY
1471 {
1472 /* Capture the boolean */
1473 VdmPower = *(PULONG)ProcessInformation;
1474 }
1476 {
1477 /* Get the exception code */
1479 _SEH2_YIELD(break);
1480 }
1481 _SEH2_END;
1482
1483 /* Getting VDM powers requires the SeTcbPrivilege */
1485 {
1486 /* We don't hold the privilege, bail out */
1488 DPRINT1("Need TCB privilege\n");
1489 break;
1490 }
1491
1492 /* Set or clear the flag */
1493 if (VdmPower)
1494 {
1496 }
1497 else
1498 {
1500 }
1501 break;
1502
1503 /* Error/Exception Port */
1505
1506 /* Check buffer length */
1507 if (ProcessInformationLength != sizeof(HANDLE))
1508 {
1510 break;
1511 }
1512
1513 /* Use SEH for capture */
1514 _SEH2_TRY
1515 {
1516 /* Capture the handle */
1517 PortHandle = *(PHANDLE)ProcessInformation;
1518 }
1520 {
1521 /* Get the exception code */
1523 _SEH2_YIELD(break);
1524 }
1525 _SEH2_END;
1526
1527 /* Setting the error port requires the SeTcbPrivilege */
1529 {
1530 /* We don't hold the privilege, bail out */
1532 break;
1533 }
1534
1535 /* Get the LPC Port */
1536 Status = ObReferenceObjectByHandle(PortHandle,
1537 0,
1540 (PVOID)&ExceptionPort,
1541 NULL);
1542 if (!NT_SUCCESS(Status)) break;
1543
1544 /* Change the pointer */
1545 if (InterlockedCompareExchangePointer(&Process->ExceptionPort,
1546 ExceptionPort,
1547 NULL))
1548 {
1549 /* We already had one, fail */
1550 ObDereferenceObject(ExceptionPort);
1552 }
1553 break;
1554
1555 /* Security Token */
1556 case ProcessAccessToken:
1557
1558 /* Check buffer length */
1559 if (ProcessInformationLength != sizeof(PROCESS_ACCESS_TOKEN))
1560 {
1562 break;
1563 }
1564
1565 /* Use SEH for capture */
1566 _SEH2_TRY
1567 {
1568 /* Save the token handle */
1569 TokenHandle = ((PPROCESS_ACCESS_TOKEN)ProcessInformation)->
1570 Token;
1571 }
1573 {
1574 /* Get the exception code */
1576 _SEH2_YIELD(break);
1577 }
1578 _SEH2_END;
1579
1580 /* Assign the actual token */
1582 break;
1583
1584 /* Hard error processing */
1586
1587 /* Check buffer length */
1588 if (ProcessInformationLength != sizeof(ULONG))
1589 {
1591 break;
1592 }
1593
1594 /* Enter SEH for direct buffer read */
1595 _SEH2_TRY
1596 {
1597 DefaultHardErrorMode = *(PULONG)ProcessInformation;
1598 }
1600 {
1601 /* Get exception code */
1603 _SEH2_YIELD(break);
1604 }
1605 _SEH2_END;
1606
1607 /* Set the mode */
1608 Process->DefaultHardErrorProcessing = DefaultHardErrorMode;
1609
1610 /* Call Ke for the update */
1611 if (DefaultHardErrorMode & SEM_NOALIGNMENTFAULTEXCEPT)
1612 {
1614 }
1615 else
1616 {
1618 }
1620 break;
1621
1622 /* Session ID */
1624
1625 /* Check buffer length */
1626 if (ProcessInformationLength != sizeof(PROCESS_SESSION_INFORMATION))
1627 {
1629 break;
1630 }
1631
1632 /* Enter SEH for capture */
1633 _SEH2_TRY
1634 {
1635 /* Capture the caller's buffer */
1636 SessionInfo = *(PPROCESS_SESSION_INFORMATION)ProcessInformation;
1637 }
1639 {
1640 /* Get the exception code */
1642 _SEH2_YIELD(break);
1643 }
1644 _SEH2_END;
1645
1646 /* Setting the session id requires the SeTcbPrivilege */
1648 {
1649 /* We don't hold the privilege, bail out */
1651 break;
1652 }
1653
1654 /*
1655 * Since we cannot change the session ID of the given
1656 * process anymore because it is set once and for all
1657 * at process creation time and because it is stored
1658 * inside the Process->Session structure managed by MM,
1659 * we fake changing it: we just return success if the
1660 * user-defined value is the same as the session ID of
1661 * the process, and otherwise we fail.
1662 */
1663 if (SessionInfo.SessionId == PsGetProcessSessionId(Process))
1664 {
1666 }
1667 else
1668 {
1670 }
1671
1672 break;
1673
1675
1676 /* Check buffer length */
1677 if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
1678 {
1680 break;
1681 }
1682
1683 /* Enter SEH for capture */
1684 _SEH2_TRY
1685 {
1686 /* Capture the caller's buffer */
1687 PriorityClass = *(PPROCESS_PRIORITY_CLASS)ProcessInformation;
1688 }
1690 {
1691 /* Return the exception code */
1693 _SEH2_YIELD(break);
1694 }
1695 _SEH2_END;
1696
1697 /* Check for invalid PriorityClass value */
1699 {
1701 break;
1702 }
1703
1704 if ((PriorityClass.PriorityClass != Process->PriorityClass) &&
1706 {
1707 /* Check the privilege */
1711 PreviousMode);
1712 if (!HasPrivilege)
1713 {
1715 DPRINT1("Privilege to change priority to realtime lacking\n");
1717 }
1718 }
1719
1720 /* Check if we have a job */
1721 if (Process->Job)
1722 {
1723 DPRINT1("Jobs not yet supported\n");
1724 }
1725
1726 /* Set process priority class */
1727 Process->PriorityClass = PriorityClass.PriorityClass;
1728
1729 /* Set process priority mode (foreground or background) */
1731 PriorityClass.Foreground ?
1735 break;
1736
1738
1739 /* Check buffer length */
1740 if (ProcessInformationLength != sizeof(PROCESS_FOREGROUND_BACKGROUND))
1741 {
1743 break;
1744 }
1745
1746 /* Enter SEH for capture */
1747 _SEH2_TRY
1748 {
1749 /* Capture the caller's buffer */
1750 Foreground = *(PPROCESS_FOREGROUND_BACKGROUND)ProcessInformation;
1751 }
1753 {
1754 /* Return the exception code */
1756 _SEH2_YIELD(break);
1757 }
1758 _SEH2_END;
1759
1760 /* Set process priority mode (foreground or background) */
1762 Foreground.Foreground ?
1766 break;
1767
1769
1770 /* Validate input length */
1771 if (ProcessInformationLength != sizeof(KPRIORITY))
1772 {
1774 break;
1775 }
1776
1777 /* Enter SEH for direct buffer read */
1778 _SEH2_TRY
1779 {
1780 BasePriority = *(KPRIORITY*)ProcessInformation;
1781 }
1783 {
1784 /* Get exception code */
1785 Break = 0;
1787 _SEH2_YIELD(break);
1788 }
1789 _SEH2_END;
1790
1791 /* Extract the memory priority out of there */
1792 if (BasePriority & 0x80000000)
1793 {
1794 MemoryPriority = MEMORY_PRIORITY_FOREGROUND;
1795 BasePriority &= ~0x80000000;
1796 }
1797 else
1798 {
1799 MemoryPriority = MEMORY_PRIORITY_BACKGROUND;
1800 }
1801
1802 /* Validate the number */
1803 if ((BasePriority > HIGH_PRIORITY) || (BasePriority <= LOW_PRIORITY))
1804 {
1807 }
1808
1809 /* Check if the new base is higher */
1810 if (BasePriority > Process->Pcb.BasePriority)
1811 {
1815 PreviousMode);
1816 if (!HasPrivilege)
1817 {
1819 DPRINT1("Privilege to change priority from %lx to %lx lacking\n", Process->Pcb.BasePriority, BasePriority);
1821 }
1822 }
1823
1824 /* Call Ke */
1825 KeSetPriorityAndQuantumProcess(&Process->Pcb, BasePriority, 0);
1826
1827 /* Now set the memory priority */
1828 MmSetMemoryPriorityProcess(Process, MemoryPriority);
1830 break;
1831
1833
1834 /* Validate input length */
1835 if (ProcessInformationLength != sizeof(ULONG))
1836 {
1838 break;
1839 }
1840
1841 /* Enter SEH for direct buffer read */
1842 _SEH2_TRY
1843 {
1844 Boost = *(PULONG)ProcessInformation;
1845 }
1847 {
1848 /* Get exception code */
1849 Break = 0;
1851 _SEH2_YIELD(break);
1852 }
1853 _SEH2_END;
1854
1855 /* Make sure the process isn't dying */
1856 if (ExAcquireRundownProtection(&Process->RundownProtect))
1857 {
1858 /* Lock it */
1860 ExAcquirePushLockShared(&Process->ProcessLock);
1861
1862 /* Loop the threads */
1863 for (Next = Process->ThreadListHead.Flink;
1864 Next != &Process->ThreadListHead;
1865 Next = Next->Flink)
1866 {
1867 /* Call Ke for the thread */
1868 Thread = CONTAINING_RECORD(Next, ETHREAD, ThreadListEntry);
1870 }
1871
1872 /* Release the lock and rundown */
1873 ExReleasePushLockShared(&Process->ProcessLock);
1875 ExReleaseRundownProtection(&Process->RundownProtect);
1876
1877 /* Set success code */
1879 }
1880 else
1881 {
1882 /* Avoid race conditions */
1884 }
1885 break;
1886
1888
1889 /* Check buffer length */
1890 if (ProcessInformationLength != sizeof(ULONG))
1891 {
1893 break;
1894 }
1895
1896 /* Enter SEH for direct buffer read */
1897 _SEH2_TRY
1898 {
1899 Break = *(PULONG)ProcessInformation;
1900 }
1902 {
1903 /* Get exception code */
1904 Break = 0;
1906 _SEH2_YIELD(break);
1907 }
1908 _SEH2_END;
1909
1910 /* Setting 'break on termination' requires the SeDebugPrivilege */
1912 {
1913 /* We don't hold the privilege, bail out */
1915 break;
1916 }
1917
1918 /* Set or clear the flag */
1919 if (Break)
1920 {
1922 }
1923 else
1924 {
1926 }
1927
1928 break;
1929
1931
1932 /* Check buffer length */
1933 if (ProcessInformationLength != sizeof(KAFFINITY))
1934 {
1936 break;
1937 }
1938
1939 /* Enter SEH for direct buffer read */
1940 _SEH2_TRY
1941 {
1942 Affinity = *(PKAFFINITY)ProcessInformation;
1943 }
1945 {
1946 /* Get exception code */
1947 Break = 0;
1949 _SEH2_YIELD(break);
1950 }
1951 _SEH2_END;
1952
1953 /* Make sure it's valid for the CPUs present */
1954 ValidAffinity = Affinity & KeActiveProcessors;
1955 if (!Affinity || (ValidAffinity != Affinity))
1956 {
1958 break;
1959 }
1960
1961 /* Check if it's within job affinity limits */
1962 if (Process->Job)
1963 {
1964 /* Not yet implemented */
1967 break;
1968 }
1969
1970 /* Make sure the process isn't dying */
1971 if (ExAcquireRundownProtection(&Process->RundownProtect))
1972 {
1973 /* Lock it */
1975 ExAcquirePushLockShared(&Process->ProcessLock);
1976
1977 /* Call Ke to do the work */
1978 KeSetAffinityProcess(&Process->Pcb, ValidAffinity);
1979
1980 /* Release the lock and rundown */
1981 ExReleasePushLockShared(&Process->ProcessLock);
1983 ExReleaseRundownProtection(&Process->RundownProtect);
1984
1985 /* Set success code */
1987 }
1988 else
1989 {
1990 /* Avoid race conditions */
1992 }
1993 break;
1994
1995 /* Priority Boosting status */
1997
1998 /* Validate input length */
1999 if (ProcessInformationLength != sizeof(ULONG))
2000 {
2002 break;
2003 }
2004
2005 /* Enter SEH for direct buffer read */
2006 _SEH2_TRY
2007 {
2008 DisableBoost = *(PBOOLEAN)ProcessInformation;
2009 }
2011 {
2012 /* Get exception code */
2013 Break = 0;
2015 _SEH2_YIELD(break);
2016 }
2017 _SEH2_END;
2018
2019 /* Make sure the process isn't dying */
2020 if (ExAcquireRundownProtection(&Process->RundownProtect))
2021 {
2022 /* Lock it */
2024 ExAcquirePushLockShared(&Process->ProcessLock);
2025
2026 /* Call Ke to do the work */
2027 KeSetDisableBoostProcess(&Process->Pcb, DisableBoost);
2028
2029 /* Loop the threads too */
2030 for (Next = Process->ThreadListHead.Flink;
2031 Next != &Process->ThreadListHead;
2032 Next = Next->Flink)
2033 {
2034 /* Call Ke for the thread */
2035 Thread = CONTAINING_RECORD(Next, ETHREAD, ThreadListEntry);
2036 KeSetDisableBoostThread(&Thread->Tcb, DisableBoost);
2037 }
2038
2039 /* Release the lock and rundown */
2040 ExReleasePushLockShared(&Process->ProcessLock);
2042 ExReleaseRundownProtection(&Process->RundownProtect);
2043
2044 /* Set success code */
2046 }
2047 else
2048 {
2049 /* Avoid race conditions */
2051 }
2052 break;
2053
2054 case ProcessDebugFlags:
2055
2056 /* Check buffer length */
2057 if (ProcessInformationLength != sizeof(ULONG))
2058 {
2060 break;
2061 }
2062
2063 /* Enter SEH for direct buffer read */
2064 _SEH2_TRY
2065 {
2066 DebugFlags = *(PULONG)ProcessInformation;
2067 }
2069 {
2070 /* Get exception code */
2072 _SEH2_YIELD(break);
2073 }
2074 _SEH2_END;
2075
2076 /* Set the mode */
2077 if (DebugFlags & ~1)
2078 {
2080 }
2081 else
2082 {
2083 if (DebugFlags & 1)
2084 {
2086 }
2087 else
2088 {
2090 }
2091 }
2092
2093 /* Done */
2095 break;
2096
2098
2099 /* Check buffer length */
2100 if (ProcessInformationLength != sizeof(BOOLEAN))
2101 {
2103 break;
2104 }
2105
2106 /* Enter SEH for direct buffer read */
2107 _SEH2_TRY
2108 {
2109 EnableFixup = *(PULONG)ProcessInformation;
2110 }
2112 {
2113 /* Get exception code */
2115 _SEH2_YIELD(break);
2116 }
2117 _SEH2_END;
2118
2119 /* Set the mode */
2120 if (EnableFixup)
2121 {
2122 Process->DefaultHardErrorProcessing |= SEM_NOALIGNMENTFAULTEXCEPT;
2123 }
2124 else
2125 {
2126 Process->DefaultHardErrorProcessing &= ~SEM_NOALIGNMENTFAULTEXCEPT;
2127 }
2128
2129 /* Call Ke for the update */
2132 break;
2133
2135
2136 /* Only TCB can do this */
2138 {
2139 /* We don't hold the privilege, bail out */
2140 DPRINT1("Need TCB to set IOPL\n");
2142 break;
2143 }
2144
2145 /* Only supported on x86 */
2146#if defined (_X86_)
2147 Ke386SetIOPL();
2148#elif defined(_M_AMD64)
2149 /* On x64 this function isn't implemented.
2150 On Windows 2003 it returns success.
2151 On Vista+ it returns STATUS_NOT_IMPLEMENTED. */
2152 if ((ExGetPreviousMode() != KernelMode) &&
2153 (RtlRosGetAppcompatVersion() > _WIN32_WINNT_WS03))
2154 {
2156 }
2157#else
2159#endif
2160 /* Done */
2161 break;
2162
2164
2165 /* Check buffer length */
2166 if (ProcessInformationLength != sizeof(ULONG))
2167 {
2169 break;
2170 }
2171
2173 {
2175 break;
2176 }
2177
2178 /* Enter SEH for direct buffer read */
2179 _SEH2_TRY
2180 {
2181 NoExecute = *(PULONG)ProcessInformation;
2182 }
2184 {
2185 /* Get exception code */
2187 _SEH2_YIELD(break);
2188 }
2189 _SEH2_END;
2190
2191 /* Call Mm for the update */
2192 Status = MmSetExecuteOptions(NoExecute);
2193 break;
2194
2195 case ProcessDeviceMap:
2196
2197 /* Check buffer length */
2198 if (ProcessInformationLength != sizeof(HANDLE))
2199 {
2201 break;
2202 }
2203
2204 /* Use SEH for capture */
2205 _SEH2_TRY
2206 {
2207 /* Capture the handle */
2208 DirectoryHandle = *(PHANDLE)ProcessInformation;
2209 }
2211 {
2212 /* Get the exception code */
2214 _SEH2_YIELD(break);
2215 }
2216 _SEH2_END;
2217
2218 /* Call Ob to set the device map */
2220 break;
2221
2222
2223 /* We currently don't implement any of these */
2225 case ProcessLdtSize:
2227 DPRINT1("VDM/16-bit Request not implemented: %lu\n", ProcessInformationClass);
2229 break;
2230
2231 case ProcessQuotaLimits:
2232
2234 1,
2235 ProcessInformation,
2236 ProcessInformationLength,
2237 PreviousMode);
2238 break;
2239
2241 DPRINT1("WS watch not implemented\n");
2243 break;
2244
2246 DPRINT1("Handle tracing not implemented\n");
2248 break;
2249
2250 /* Anything else is invalid */
2251 default:
2252#if DBG
2253 DPRINT1("Invalid Server 2003 Info Class: %s\n", PspDumpProcessInfoClassName(ProcessInformationClass));
2254#endif
2256 }
2257
2258 /* Dereference and return status */
2260 return Status;
2261}
2262
2263/*
2264 * @implemented
2265 */
2267NTAPI
2269 _In_ HANDLE ThreadHandle,
2273{
2278 KPRIORITY Priority = 0;
2279 KAFFINITY Affinity = 0, CombinedAffinity;
2280 PVOID Address = NULL;
2282 ULONG_PTR DisableBoost = 0;
2283 ULONG_PTR IdealProcessor = 0;
2284 ULONG_PTR Break = 0;
2285 PTEB Teb;
2286 ULONG_PTR TlsIndex = 0;
2287 PVOID *ExpansionSlots;
2288 PETHREAD ProcThread;
2290 PAGED_CODE();
2291
2292 /* Validate the information class */
2296 ThreadInformation,
2298 PreviousMode);
2299 if (!NT_SUCCESS(Status))
2300 {
2301#if DBG
2302 DPRINT1("NtSetInformationThread(ThreadInformationClass: %s): Class validation failed! (Status: 0x%lx)\n",
2303 PspDumpThreadInfoClassName(ThreadInformationClass), Status);
2304#endif
2305 return Status;
2306 }
2307
2308 /* Check what kind of information class this is */
2309 switch (ThreadInformationClass)
2310 {
2311 /* Thread priority */
2312 case ThreadPriority:
2313
2314 /* Check buffer length */
2315 if (ThreadInformationLength != sizeof(KPRIORITY))
2316 {
2318 break;
2319 }
2320
2321 /* Use SEH for capture */
2322 _SEH2_TRY
2323 {
2324 /* Get the priority */
2325 Priority = *(PLONG)ThreadInformation;
2326 }
2328 {
2329 /* Get the exception code */
2331 _SEH2_YIELD(break);
2332 }
2333 _SEH2_END;
2334
2335 /* Validate it */
2336 if ((Priority > HIGH_PRIORITY) ||
2338 {
2339 /* Fail */
2341 break;
2342 }
2343
2344 /* Check for the required privilege */
2346 {
2348 ThreadHandle,
2350 PreviousMode);
2351 if (!HasPrivilege)
2352 {
2353 DPRINT1("Privilege to change priority to %lx lacking\n", Priority);
2355 }
2356 }
2357
2358 /* Reference the thread */
2359 Status = ObReferenceObjectByHandle(ThreadHandle,
2363 (PVOID*)&Thread,
2364 NULL);
2365 if (!NT_SUCCESS(Status))
2366 break;
2367
2368 /* Set the priority */
2370
2371 /* Dereference the thread */
2373 break;
2374
2375 case ThreadBasePriority:
2376
2377 /* Check buffer length */
2378 if (ThreadInformationLength != sizeof(LONG))
2379 {
2381 break;
2382 }
2383
2384 /* Use SEH for capture */
2385 _SEH2_TRY
2386 {
2387 /* Get the priority */
2388 Priority = *(PLONG)ThreadInformation;
2389 }
2391 {
2392 /* Get the exception code */
2394 _SEH2_YIELD(break);
2395 }
2396 _SEH2_END;
2397
2398 /* Validate it */
2401 {
2402 /* These ones are OK */
2403 if ((Priority != THREAD_BASE_PRIORITY_LOWRT + 1) &&
2405 {
2406 /* Check if the process is real time */
2407 if (PsGetCurrentProcess()->PriorityClass !=
2409 {
2410 /* It isn't, fail */
2412 break;
2413 }
2414 }
2415 }
2416
2417 /* Reference the thread */
2418 Status = ObReferenceObjectByHandle(ThreadHandle,
2422 (PVOID*)&Thread,
2423 NULL);
2424 if (!NT_SUCCESS(Status))
2425 break;
2426
2427 /* Set the base priority */
2429
2430 /* Dereference the thread */
2432 break;
2433
2434 case ThreadAffinityMask:
2435
2436 /* Check buffer length */
2437 if (ThreadInformationLength != sizeof(ULONG_PTR))
2438 {
2440 break;
2441 }
2442
2443 /* Use SEH for capture */
2444 _SEH2_TRY
2445 {
2446 /* Get the priority */
2447 Affinity = *(PULONG_PTR)ThreadInformation;
2448 }
2450 {
2451 /* Get the exception code */
2453 _SEH2_YIELD(break);
2454 }
2455 _SEH2_END;
2456
2457 /* Validate it */
2458 if (!Affinity)
2459 {
2460 /* Fail */
2462 break;
2463 }
2464
2465 /* Reference the thread */
2466 Status = ObReferenceObjectByHandle(ThreadHandle,
2470 (PVOID*)&Thread,
2471 NULL);
2472 if (!NT_SUCCESS(Status))
2473 break;
2474
2475 /* Get the process */
2476 Process = Thread->ThreadsProcess;
2477
2478 /* Try to acquire rundown */
2479 if (ExAcquireRundownProtection(&Process->RundownProtect))
2480 {
2481 /* Lock it */
2483 ExAcquirePushLockShared(&Process->ProcessLock);
2484
2485 /* Combine masks */
2486 CombinedAffinity = Affinity & Process->Pcb.Affinity;
2487 if (CombinedAffinity != Affinity)
2488 {
2489 /* Fail */
2491 }
2492 else
2493 {
2494 /* Set the affinity */
2495 KeSetAffinityThread(&Thread->Tcb, CombinedAffinity);
2496 }
2497
2498 /* Release the lock and rundown */
2499 ExReleasePushLockShared(&Process->ProcessLock);
2501 ExReleaseRundownProtection(&Process->RundownProtect);
2502 }
2503 else
2504 {
2505 /* Too late */
2507 }
2508
2509 /* Dereference the thread */
2511 break;
2512
2514
2515 /* Check buffer length */
2516 if (ThreadInformationLength != sizeof(HANDLE))
2517 {
2519 break;
2520 }
2521
2522 /* Use SEH for capture */
2523 _SEH2_TRY
2524 {
2525 /* Save the token handle */
2526 TokenHandle = *(PHANDLE)ThreadInformation;
2527 }
2529 {
2530 /* Get the exception code */
2532 _SEH2_YIELD(break);
2533 }
2534 _SEH2_END;
2535
2536 /* Reference the thread */
2537 Status = ObReferenceObjectByHandle(ThreadHandle,
2541 (PVOID*)&Thread,
2542 NULL);
2543 if (!NT_SUCCESS(Status))
2544 break;
2545
2546 /* Assign the actual token */
2548
2549 /* Dereference the thread */
2551 break;
2552
2554
2555 /* Check buffer length */
2556 if (ThreadInformationLength != sizeof(ULONG_PTR))
2557 {
2559 break;
2560 }
2561
2562 /* Use SEH for capture */
2563 _SEH2_TRY
2564 {
2565 /* Get the priority */
2566 Address = *(PVOID*)ThreadInformation;
2567 }
2569 {
2570 /* Get the exception code */
2572 _SEH2_YIELD(break);
2573 }
2574 _SEH2_END;
2575
2576 /* Reference the thread */
2577 Status = ObReferenceObjectByHandle(ThreadHandle,
2581 (PVOID*)&Thread,
2582 NULL);
2583 if (!NT_SUCCESS(Status))
2584 break;
2585
2586 /* Set the address */
2588
2589 /* Dereference the thread */
2591 break;
2592
2594
2595 /* Check buffer length */
2596 if (ThreadInformationLength != sizeof(ULONG_PTR))
2597 {
2599 break;
2600 }
2601
2602 /* Use SEH for capture */
2603 _SEH2_TRY
2604 {
2605 /* Get the priority */
2606 IdealProcessor = *(PULONG_PTR)ThreadInformation;
2607 }
2609 {
2610 /* Get the exception code */
2612 _SEH2_YIELD(break);
2613 }
2614 _SEH2_END;
2615
2616 /* Validate it */
2617 if (IdealProcessor > MAXIMUM_PROCESSORS)
2618 {
2619 /* Fail */
2621 break;
2622 }
2623
2624 /* Reference the thread */
2625 Status = ObReferenceObjectByHandle(ThreadHandle,
2629 (PVOID*)&Thread,
2630 NULL);
2631 if (!NT_SUCCESS(Status))
2632 break;
2633
2634 /* Set the ideal */
2636 (CCHAR)IdealProcessor);
2637
2638 /* Get the TEB and protect the thread */
2639 Teb = Thread->Tcb.Teb;
2641 {
2642 /* Save the ideal processor */
2643 Teb->IdealProcessor = Thread->Tcb.IdealProcessor;
2644
2645 /* Release rundown protection */
2647 }
2648
2649 /* Dereference the thread */
2651 break;
2652
2654
2655 /* Check buffer length */
2656 if (ThreadInformationLength != sizeof(ULONG_PTR))
2657 {
2659 break;
2660 }
2661
2662 /* Use SEH for capture */
2663 _SEH2_TRY
2664 {
2665 /* Get the priority */
2666 DisableBoost = *(PULONG_PTR)ThreadInformation;
2667 }
2669 {
2670 /* Get the exception code */
2672 _SEH2_YIELD(break);
2673 }
2674 _SEH2_END;
2675
2676 /* Reference the thread */
2677 Status = ObReferenceObjectByHandle(ThreadHandle,
2681 (PVOID*)&Thread,
2682 NULL);
2683 if (!NT_SUCCESS(Status))
2684 break;
2685
2686 /* Call the kernel */
2687 KeSetDisableBoostThread(&Thread->Tcb, (BOOLEAN)DisableBoost);
2688
2689 /* Dereference the thread */
2691 break;
2692
2693 case ThreadZeroTlsCell:
2694
2695 /* Check buffer length */
2696 if (ThreadInformationLength != sizeof(ULONG))
2697 {
2699 break;
2700 }
2701
2702 /* Use SEH for capture */
2703 _SEH2_TRY
2704 {
2705 /* Get the priority */
2706 TlsIndex = *(PULONG)ThreadInformation;
2707 }
2709 {
2710 /* Get the exception code */
2712 _SEH2_YIELD(break);
2713 }
2714 _SEH2_END;
2715
2716 /* Reference the thread */
2717 Status = ObReferenceObjectByHandle(ThreadHandle,
2721 (PVOID*)&Thread,
2722 NULL);
2723 if (!NT_SUCCESS(Status))
2724 break;
2725
2726 /* This is only valid for the current thread */
2727 if (Thread != PsGetCurrentThread())
2728 {
2729 /* Fail */
2732 break;
2733 }
2734
2735 /* Get the process */
2736 Process = Thread->ThreadsProcess;
2737
2738 /* Loop the threads */
2739 ProcThread = PsGetNextProcessThread(Process, NULL);
2740 while (ProcThread)
2741 {
2742 /* Acquire rundown */
2744 {
2745 /* Get the TEB */
2746 Teb = ProcThread->Tcb.Teb;
2747 if (Teb)
2748 {
2749 /* Check if we're in the expansion range */
2751 {
2754 {
2755 /* Check if we have expansion slots */
2756 ExpansionSlots = Teb->TlsExpansionSlots;
2757 if (ExpansionSlots)
2758 {
2759 /* Clear the index */
2760 ExpansionSlots[TlsIndex - TLS_MINIMUM_AVAILABLE] = 0;
2761 }
2762 }
2763 }
2764 else
2765 {
2766 /* Clear the index */
2767 Teb->TlsSlots[TlsIndex] = NULL;
2768 }
2769 }
2770
2771 /* Release rundown */
2773 }
2774
2775 /* Go to the next thread */
2776 ProcThread = PsGetNextProcessThread(Process, ProcThread);
2777 }
2778
2779 /* Dereference the thread */
2781 break;
2782
2784
2785 /* Check buffer length */
2786 if (ThreadInformationLength != sizeof(ULONG))
2787 {
2789 break;
2790 }
2791
2792 /* Enter SEH for direct buffer read */
2793 _SEH2_TRY
2794 {
2795 Break = *(PULONG)ThreadInformation;
2796 }
2798 {
2799 /* Get exception code */
2800 Break = 0;
2802 _SEH2_YIELD(break);
2803 }
2804 _SEH2_END;
2805
2806 /* Setting 'break on termination' requires the SeDebugPrivilege */
2808 {
2809 /* We don't hold the privilege, bail out */
2811 break;
2812 }
2813
2814 /* Reference the thread */
2815 Status = ObReferenceObjectByHandle(ThreadHandle,
2819 (PVOID*)&Thread,
2820 NULL);
2821 if (!NT_SUCCESS(Status))
2822 break;
2823
2824 /* Set or clear the flag */
2825 if (Break)
2826 {
2828 }
2829 else
2830 {
2832 }
2833
2834 /* Dereference the thread */
2836 break;
2837
2839
2840 /* Check buffer length */
2841 if (ThreadInformationLength != 0)
2842 {
2844 break;
2845 }
2846
2847 /* Reference the thread */
2848 Status = ObReferenceObjectByHandle(ThreadHandle,
2852 (PVOID*)&Thread,
2853 NULL);
2854 if (!NT_SUCCESS(Status))
2855 break;
2856
2857 /* Set the flag */
2859
2860 /* Dereference the thread */
2862 break;
2863
2864 /* Anything else */
2865 default:
2866 /* Not yet implemented */
2867#if DBG
2868 DPRINT1("Not implemented: %s\n", PspDumpThreadInfoClassName(ThreadInformationClass));
2869#endif
2871 }
2872
2873 return Status;
2874}
2875
2876/*
2877 * @implemented
2878 */
2880NTAPI
2882 _In_ HANDLE ThreadHandle,
2885 PVOID ThreadInformation,
2888{
2892 ULONG Access;
2893 ULONG Length = 0;
2894 PTHREAD_BASIC_INFORMATION ThreadBasicInfo =
2895 (PTHREAD_BASIC_INFORMATION)ThreadInformation;
2896 PKERNEL_USER_TIMES ThreadTime = (PKERNEL_USER_TIMES)ThreadInformation;
2897 KIRQL OldIrql;
2898 ULONG ThreadTerminated;
2899 PAGED_CODE();
2900
2901 /* Validate the information class */
2906 ThreadInformation,
2909 NULL,
2910 PreviousMode);
2911 if (!NT_SUCCESS(Status))
2912 {
2913#if DBG
2914 DPRINT1("NtQueryInformationThread(ThreadInformationClass: %s): Class validation failed! (Status: 0x%lx)\n",
2915 PspDumpThreadInfoClassName(ThreadInformationClass), Status);
2916#endif
2917 return Status;
2918 }
2919
2920 /* Check what class this is */
2921 Access = THREAD_QUERY_INFORMATION;
2922
2923 /* Check what kind of information class this is */
2924 switch (ThreadInformationClass)
2925 {
2926 /* Basic thread information */
2928
2929 /* Set the return length */
2931
2933 {
2935 break;
2936 }
2937
2938 /* Reference the thread */
2939 Status = ObReferenceObjectByHandle(ThreadHandle,
2940 Access,
2943 (PVOID*)&Thread,
2944 NULL);
2945 if (!NT_SUCCESS(Status))
2946 break;
2947
2948 /* Protect writes with SEH */
2949 _SEH2_TRY
2950 {
2951 /* Write all the information from the ETHREAD/KTHREAD */
2952 ThreadBasicInfo->ExitStatus = Thread->ExitStatus;
2953 ThreadBasicInfo->TebBaseAddress = (PVOID)Thread->Tcb.Teb;
2954 ThreadBasicInfo->ClientId = Thread->Cid;
2955 ThreadBasicInfo->AffinityMask = Thread->Tcb.Affinity;
2956 ThreadBasicInfo->Priority = Thread->Tcb.Priority;
2957 ThreadBasicInfo->BasePriority = KeQueryBasePriorityThread(&Thread->Tcb);
2958 }
2960 {
2961 /* Get exception code */
2963 }
2964 _SEH2_END;
2965
2966 /* Dereference the thread */
2968 break;
2969
2970 /* Thread time information */
2971 case ThreadTimes:
2972
2973 /* Set the return length */
2974 Length = sizeof(KERNEL_USER_TIMES);
2975
2977 {
2979 break;
2980 }
2981
2982 /* Reference the thread */
2983 Status = ObReferenceObjectByHandle(ThreadHandle,
2984 Access,
2987 (PVOID*)&Thread,
2988 NULL);
2989 if (!NT_SUCCESS(Status))
2990 break;
2991
2992 /* Protect writes with SEH */
2993 _SEH2_TRY
2994 {
2995 /* Copy time information from ETHREAD/KTHREAD */
2998 ThreadTime->CreateTime = Thread->CreateTime;
2999
3000 /* Exit time is in a union and only valid on actual exit! */
3002 {
3003 ThreadTime->ExitTime = Thread->ExitTime;
3004 }
3005 else
3006 {
3007 ThreadTime->ExitTime.QuadPart = 0;
3008 }
3009 }
3011 {
3012 /* Get exception code */
3014 }
3015 _SEH2_END;
3016
3017 /* Dereference the thread */
3019 break;
3020
3022
3023 /* Set the return length*/
3024 Length = sizeof(PVOID);
3025
3027 {
3029 break;
3030 }
3031
3032 /* Reference the thread */
3033 Status = ObReferenceObjectByHandle(ThreadHandle,
3034 Access,
3037 (PVOID*)&Thread,
3038 NULL);
3039 if (!NT_SUCCESS(Status))
3040 break;
3041
3042 /* Protect write with SEH */
3043 _SEH2_TRY
3044 {
3045 /* Return the Win32 Start Address */
3046 *(PVOID*)ThreadInformation = Thread->Win32StartAddress;
3047 }
3049 {
3050 /* Get exception code */
3052 }
3053 _SEH2_END;
3054
3055 /* Dereference the thread */
3057 break;
3058
3060
3061 /* Set the return length*/
3062 Length = sizeof(LARGE_INTEGER);
3063
3065 {
3067 break;
3068 }
3069
3070 /* Reference the thread */
3071 Status = ObReferenceObjectByHandle(ThreadHandle,
3072 Access,
3075 (PVOID*)&Thread,
3076 NULL);
3077 if (!NT_SUCCESS(Status))
3078 break;
3079
3080 /* Protect write with SEH */
3081 _SEH2_TRY
3082 {
3083 /* FIXME */
3084 (*(PLARGE_INTEGER)ThreadInformation).QuadPart = 0;
3085 }
3087 {
3088 /* Get exception code */
3090 }
3091 _SEH2_END;
3092
3093 /* Dereference the thread */
3095 break;
3096
3098
3099 /* Set the return length*/
3100 Length = sizeof(ULONG);
3101
3103 {
3105 break;
3106 }
3107
3108 /* Reference the thread */
3109 Status = ObReferenceObjectByHandle(ThreadHandle,
3110 Access,
3113 (PVOID*)&Thread,
3114 NULL);
3115 if (!NT_SUCCESS(Status))
3116 break;
3117
3118 /* Protect write with SEH */
3119 _SEH2_TRY
3120 {
3121 /* Return whether or not we are the last thread */
3122 *(PULONG)ThreadInformation = ((Thread->ThreadsProcess->
3123 ThreadListHead.Flink->Flink ==
3124 &Thread->ThreadsProcess->
3126 TRUE : FALSE);
3127 }
3129 {
3130 /* Get exception code */
3132 }
3133 _SEH2_END;
3134
3135 /* Dereference the thread */
3137 break;
3138
3139 case ThreadIsIoPending:
3140
3141 /* Set the return length*/
3142 Length = sizeof(ULONG);
3143
3145 {
3147 break;
3148 }
3149
3150 /* Reference the thread */
3151 Status = ObReferenceObjectByHandle(ThreadHandle,
3152 Access,
3155 (PVOID*)&Thread,
3156 NULL);
3157 if (!NT_SUCCESS(Status))
3158 break;
3159
3160 /* Raise the IRQL to protect the IRP list */
3162
3163 /* Protect write with SEH */
3164 _SEH2_TRY
3165 {
3166 /* Check if the IRP list is empty or not */
3167 *(PULONG)ThreadInformation = !IsListEmpty(&Thread->IrpList);
3168 }
3170 {
3171 /* Get exception code */
3173 }
3174 _SEH2_END;
3175
3176 /* Lower IRQL back */
3178
3179 /* Dereference the thread */
3181 break;
3182
3183 /* LDT and GDT information */
3185
3186#if defined(_X86_)
3187 /* Reference the thread */
3188 Status = ObReferenceObjectByHandle(ThreadHandle,
3189 Access,
3192 (PVOID*)&Thread,
3193 NULL);
3194 if (!NT_SUCCESS(Status))
3195 break;
3196
3197 /* Call the worker routine */
3199 ThreadInformation,
3201 ReturnLength);
3202
3203 /* Dereference the thread */
3205#else
3206 /* Only implemented on x86 */
3208#endif
3209 break;
3210
3212
3213 /* Set the return length*/
3214 Length = sizeof(ULONG);
3215
3217 {
3219 break;
3220 }
3221
3222 /* Reference the thread */
3223 Status = ObReferenceObjectByHandle(ThreadHandle,
3224 Access,
3227 (PVOID*)&Thread,
3228 NULL);
3229 if (!NT_SUCCESS(Status))
3230 break;
3231
3232 _SEH2_TRY
3233 {
3234 *(PULONG)ThreadInformation = Thread->Tcb.DisableBoost ? 1 : 0;
3235 }
3237 {
3239 }
3240 _SEH2_END;
3241
3242 /* Dereference the thread */
3244 break;
3245
3247
3248 /* Set the return length */
3249 Length = sizeof(ULONG);
3250
3252 {
3254 break;
3255 }
3256
3257 /* Reference the thread */
3258 Status = ObReferenceObjectByHandle(ThreadHandle,
3259 Access,
3262 (PVOID*)&Thread,
3263 NULL);
3264 if (!NT_SUCCESS(Status))
3265 break;
3266
3267 _SEH2_TRY
3268 {
3269 *(PULONG)ThreadInformation = Thread->BreakOnTermination;
3270 }
3272 {
3274 }
3275 _SEH2_END;
3276
3277 /* Dereference the thread */
3279 break;
3280
3281 case ThreadIsTerminated:
3282
3283 /* Set the return length*/
3284 Length = sizeof(ThreadTerminated);
3285
3287 {
3289 break;
3290 }
3291
3292 /* Reference the thread */
3293 Status = ObReferenceObjectByHandle(ThreadHandle,
3294 Access,
3297 (PVOID*)&Thread,
3298 NULL);
3299 if (!NT_SUCCESS(Status))
3300 break;
3301
3302 ThreadTerminated = PsIsThreadTerminating(Thread);
3303
3304 _SEH2_TRY
3305 {
3306 *(PULONG)ThreadInformation = ThreadTerminated ? 1 : 0;
3307 }
3309 {
3311 }
3312 _SEH2_END;
3313
3314 /* Dereference the thread */
3316 break;
3317
3318 /* Anything else */
3319 default:
3320 /* Not yet implemented */
3321#if DBG
3322 DPRINT1("Not implemented: %s\n", PspDumpThreadInfoClassName(ThreadInformationClass));
3323#endif
3325 }
3326
3327 /* Protect write with SEH */
3328 _SEH2_TRY
3329 {
3330 /* Check if caller wanted return length */
3332 }
3334 {
3335 /* Get exception code */
3337 }
3338 _SEH2_END;
3339
3340 return Status;
3341}
3342
3343/* EOF */
#define PAGED_CODE()
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
@ ObjectNameInformation
Definition: DriverTester.h:55
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG ReturnLength
_In_ PVOID _In_ ULONG _Out_ PVOID _In_ ULONG _Inout_ PULONG _In_ KPROCESSOR_MODE PreviousMode
static HANDLE DirectoryHandle
Definition: ObType.c:48
unsigned char BOOLEAN
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
KAFFINITY * PKAFFINITY
Definition: basetsd.h:189
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
@ ProcessDebugPort
Definition: cicbase.cpp:64
@ ProcessBreakOnTermination
Definition: cicbase.cpp:67
@ ProcessBasicInformation
Definition: cicbase.cpp:63
@ ProcessWow64Information
Definition: cicbase.cpp:65
@ ProcessImageFileName
Definition: cicbase.cpp:66
enum _PROCESSINFOCLASS PROCESSINFOCLASS
Definition: loader.c:63
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
NTSTATUS NTAPI DbgkOpenProcessDebugPort(IN PEPROCESS Process, IN KPROCESSOR_MODE PreviousMode, OUT HANDLE *DebugHandle)
Definition: dbgkobj.c:1526
#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
struct _THREAD_BASIC_INFORMATION THREAD_BASIC_INFORMATION
ULONG_PTR KAFFINITY
Definition: compat.h:85
@ ThreadEnableAlignmentFaultFixup
Definition: compat.h:942
@ ThreadCSwitchPmu
Definition: compat.h:963
@ ThreadDescriptorTableEntry
Definition: compat.h:941
@ ThreadEventPair_Reusable
Definition: compat.h:943
@ ThreadIdealProcessorEx
Definition: compat.h:968
@ ThreadAmILastThread
Definition: compat.h:947
@ ThreadTimes
Definition: compat.h:936
@ ThreadPagePriority
Definition: compat.h:959
@ ThreadUmsInformation
Definition: compat.h:966
@ ThreadCSwitchMon
Definition: compat.h:962
@ ThreadPriority
Definition: compat.h:937
@ ThreadIdealProcessor
Definition: compat.h:948
@ ThreadActualBasePriority
Definition: compat.h:960
@ ThreadGroupInformation
Definition: compat.h:965
@ ThreadSwitchLegacyState
Definition: compat.h:954
@ ThreadQuerySetWin32StartAddress
Definition: compat.h:944
@ ThreadIsTerminated
Definition: compat.h:955
@ ThreadLastSystemCall
Definition: compat.h:956
@ ThreadBreakOnTermination
Definition: compat.h:953
@ ThreadImpersonationToken
Definition: compat.h:940
@ ThreadSetTlsArrayAddress
Definition: compat.h:950
@ ThreadAffinityMask
Definition: compat.h:939
@ ThreadBasePriority
Definition: compat.h:938
@ ThreadTebInformation
Definition: compat.h:961
@ ThreadIoPriority
Definition: compat.h:957
@ ThreadCycleTime
Definition: compat.h:958
@ ThreadBasicInformation
Definition: compat.h:935
@ ThreadCounterProfiling
Definition: compat.h:967
@ ThreadPriorityBoost
Definition: compat.h:949
@ ThreadPerformanceCount
Definition: compat.h:946
@ ThreadIsIoPending
Definition: compat.h:951
@ ThreadZeroTlsCell
Definition: compat.h:945
@ ThreadWow64Context
Definition: compat.h:964
@ ThreadHideFromDebugger
Definition: compat.h:952
enum _THREADINFOCLASS THREADINFOCLASS
Definition: thread.c:101
struct _THREAD_BASIC_INFORMATION * PTHREAD_BASIC_INFORMATION
LONG KPRIORITY
Definition: compat.h:803
#define ULONG_PTR
Definition: config.h:101
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define APC_LEVEL
Definition: env_spec_w32.h:695
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
struct _UNICODE_STRING UNICODE_STRING
#define ExReleaseRundownProtection
Definition: ex.h:139
#define ExGetPreviousMode
Definition: ex.h:143
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1108
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1216
#define ExAcquireRundownProtection
Definition: ex.h:138
#define MAXIMUM_PROCESSORS
Definition: rwlock.h:5
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
Status
Definition: gdiplustypes.h:25
#define ICIF_PROBE_READ
Definition: icif.h:25
#define PROCESS_SUSPEND_RESUME
Definition: pstypes.h:168
struct _PROCESS_PRIORITY_CLASS PROCESS_PRIORITY_CLASS
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
#define THREAD_SET_THREAD_TOKEN
Definition: pstypes.h:151
#define THREAD_BASE_PRIORITY_LOWRT
Definition: pstypes.h:183
struct _PROCESS_PRIORITY_CLASS * PPROCESS_PRIORITY_CLASS
#define THREAD_QUERY_INFORMATION
Definition: pstypes.h:150
#define PROCESS_PRIORITY_CLASS_ABOVE_NORMAL
Definition: pstypes.h:113
#define PSF_NO_DEBUG_INHERIT_BIT
Definition: pstypes.h:275
#define CT_HIDE_FROM_DEBUGGER_BIT
Definition: pstypes.h:241
#define THREAD_BASE_PRIORITY_MIN
Definition: pstypes.h:185
#define PROCESS_SET_SESSIONID
Definition: pstypes.h:160
#define THREAD_BASE_PRIORITY_MAX
Definition: pstypes.h:184
@ PsProcessPriorityForeground
Definition: pstypes.h:460
@ PsProcessPriorityBackground
Definition: pstypes.h:461
#define THREAD_BASE_PRIORITY_IDLE
Definition: pstypes.h:186
#define PROCESS_SET_INFORMATION
Definition: pstypes.h:166
#define PSF_VDM_ALLOWED_BIT
Definition: pstypes.h:297
#define TLS_EXPANSION_SLOTS
Definition: pstypes.h:311
#define PROCESS_PRIORITY_CLASS_REALTIME
Definition: pstypes.h:111
#define CT_BREAK_ON_TERMINATION_BIT
Definition: pstypes.h:245
@ PsNonPagedPool
Definition: pstypes.h:1110
@ PsPageFile
Definition: pstypes.h:1112
@ PsPagedPool
Definition: pstypes.h:1111
struct _PROCESS_FOREGROUND_BACKGROUND * PPROCESS_FOREGROUND_BACKGROUND
#define MEMORY_PRIORITY_BACKGROUND
Definition: pstypes.h:125
#define PSF_BREAK_ON_TERMINATION_BIT
Definition: pstypes.h:286
#define MEMORY_PRIORITY_FOREGROUND
Definition: pstypes.h:127
struct _PROCESS_BASIC_INFORMATION * PPROCESS_BASIC_INFORMATION
struct _PROCESS_BASIC_INFORMATION PROCESS_BASIC_INFORMATION
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
struct _KERNEL_USER_TIMES KERNEL_USER_TIMES
@ ThreadSuspendCount
Definition: winternl.h:2316
@ ThreadActualGroupAffinity
Definition: winternl.h:2322
@ ThreadStrongerBadHandleChecks
Definition: winternl.h:2334
@ ThreadCpuAccountingInformation
Definition: winternl.h:2315
@ ThreadWorkOnBehalfTicket
Definition: winternl.h:2325
@ ThreadEffectiveIoPriority
Definition: winternl.h:2335
@ ThreadCreateStateChange
Definition: winternl.h:2332
@ ThreadSelectedCpuSets
Definition: winternl.h:2320
@ ThreadApplyStateChange
Definition: winternl.h:2333
@ ThreadSystemThreadInformation
Definition: winternl.h:2321
@ ThreadManageWritesToExecutableMemory
Definition: winternl.h:2329
@ ThreadDynamicCodePolicyInfo
Definition: winternl.h:2323
@ ThreadExplicitCaseSensitivity
Definition: winternl.h:2324
@ ThreadPowerThrottlingState
Definition: winternl.h:2330
@ ThreadHeterogeneousCpuPolicy
Definition: winternl.h:2317
@ ThreadEffectivePagePriority
Definition: winternl.h:2336
@ ThreadNameInformation
Definition: winternl.h:2319
@ ThreadDbgkWerReportActive
Definition: winternl.h:2327
@ ThreadSubsystemInformation
Definition: winternl.h:2326
@ ThreadAttachContainer
Definition: winternl.h:2328
@ ThreadContainerId
Definition: winternl.h:2318
@ ThreadWorkloadClass
Definition: winternl.h:2331
struct _KERNEL_USER_TIMES * PKERNEL_USER_TIMES
@ ProcessPagePriority
Definition: winternl.h:1921
@ ProcessLUIDDeviceMapsEnabled
Definition: winternl.h:1910
@ ProcessMemoryAllocationMode
Definition: winternl.h:1928
@ ProcessTlsInformation
Definition: winternl.h:1917
@ ProcessWx86Information
Definition: winternl.h:1901
@ ProcessDebugFlags
Definition: winternl.h:1913
@ ProcessConsoleHostProcess
Definition: winternl.h:1931
@ ProcessSessionInformation
Definition: winternl.h:1906
@ ProcessWorkingSetWatchEx
Definition: winternl.h:1924
@ ProcessAffinityMask
Definition: winternl.h:1903
@ ProcessInstrumentationCallback
Definition: winternl.h:1922
@ ProcessImageFileMapping
Definition: winternl.h:1926
@ ProcessIoPortHandlers
Definition: winternl.h:1895
@ ProcessRaisePriority
Definition: winternl.h:1888
@ ProcessVmCounters
Definition: winternl.h:1885
@ ProcessPriorityClass
Definition: winternl.h:1900
@ ProcessPriorityBoost
Definition: winternl.h:1904
@ ProcessImageInformation
Definition: winternl.h:1919
@ ProcessExecuteFlags
Definition: winternl.h:1916
@ ProcessCookie
Definition: winternl.h:1918
@ ProcessPooledUsageAndLimits
Definition: winternl.h:1896
@ ProcessLdtSize
Definition: winternl.h:1893
@ ProcessIoCounters
Definition: winternl.h:1884
@ ProcessImageFileNameWin32
Definition: winternl.h:1925
@ ProcessDefaultHardErrorMode
Definition: winternl.h:1894
@ ProcessAffinityUpdateMode
Definition: winternl.h:1927
@ ProcessEnableAlignmentFaultFixup
Definition: winternl.h:1899
@ ProcessDeviceMap
Definition: winternl.h:1905
@ ProcessBasePriority
Definition: winternl.h:1887
@ ProcessQuotaLimits
Definition: winternl.h:1883
@ ProcessCycleTime
Definition: winternl.h:1920
@ ProcessAccessToken
Definition: winternl.h:1891
@ ProcessIoPriority
Definition: winternl.h:1915
@ ProcessHandleTracing
Definition: winternl.h:1914
@ ProcessThreadStackAllocation
Definition: winternl.h:1923
@ ProcessForegroundInformation
Definition: winternl.h:1907
@ ProcessWindowInformation
Definition: winternl.h:1932
@ ProcessTimes
Definition: winternl.h:1886
@ ProcessDebugObjectHandle
Definition: winternl.h:1912
@ ProcessExceptionPort
Definition: winternl.h:1890
@ ProcessWorkingSetWatch
Definition: winternl.h:1897
@ ProcessGroupInformation
Definition: winternl.h:1929
@ ProcessLdtInformation
Definition: winternl.h:1892
@ ProcessHandleCount
Definition: winternl.h:1902
@ ProcessUserModeIOPL
Definition: winternl.h:1898
struct _VM_COUNTERS * PVM_COUNTERS
struct _VM_COUNTERS_EX VM_COUNTERS_EX
#define QUOTA_LIMITS_HARDWS_MIN_DISABLE
#define PROCESS_LUID_DOSDEVICES_ONLY
Definition: pstypes.h:228
struct _IO_COUNTERS IO_COUNTERS
struct _PROCESS_SESSION_INFORMATION PROCESS_SESSION_INFORMATION
struct _PROCESS_SESSION_INFORMATION * PPROCESS_SESSION_INFORMATION
#define LOW_PRIORITY
#define QUOTA_LIMITS_HARDWS_MAX_DISABLE
struct _QUOTA_LIMITS_EX QUOTA_LIMITS_EX
#define QUOTA_LIMITS_HARDWS_MAX_ENABLE
#define QUOTA_LIMITS_HARDWS_MIN_ENABLE
#define LOW_REALTIME_PRIORITY
#define HIGH_PRIORITY
struct _IO_COUNTERS * PIO_COUNTERS
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define InterlockedCompareExchange
Definition: interlocked.h:119
static LIST_ENTRY ThreadListHead
Definition: sys_arch.c:6
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
if(dx< 0)
Definition: linetemp.h:194
POBJECT_TYPE LpcPortObjectType
Definition: port.c:17
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define sprintf
Definition: sprintf.c:45
static const char * ImageName
Definition: image.c:34
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1187
#define KernelMode
Definition: asm.h:38
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
struct _SECTION_IMAGE_INFORMATION SECTION_IMAGE_INFORMATION
_In_ ACCESS_MASK _In_ ULONG _Out_ PHANDLE TokenHandle
Definition: psfuncs.h:727
_In_ THREADINFOCLASS _In_ ULONG ThreadInformationLength
Definition: psfuncs.h:844
_In_ THREADINFOCLASS ThreadInformationClass
Definition: psfuncs.h:841
#define SEM_NOALIGNMENTFAULTEXCEPT
Definition: rtltypes.h:71
#define _In_reads_bytes_(s)
Definition: no_sal2.h:170
#define _Out_opt_
Definition: no_sal2.h:214
#define _Outptr_
Definition: no_sal2.h:262
#define _In_
Definition: no_sal2.h:158
#define _Out_writes_bytes_to_opt_(s, c)
Definition: no_sal2.h:240
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define NtCurrentProcess()
Definition: nt_native.h:1660
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
#define THREAD_SET_INFORMATION
Definition: nt_native.h:1340
struct _PROCESS_ACCESS_TOKEN * PPROCESS_ACCESS_TOKEN
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
LONG NTAPI KeQueryBasePriorityThread(IN PKTHREAD Thread)
Definition: thrdobj.c:52
ULONG NTAPI KeQueryRuntimeProcess(IN PKPROCESS Process, OUT PULONG UserTime)
Definition: procobj.c:860
KAFFINITY NTAPI KeSetAffinityProcess(IN PKPROCESS Process, IN KAFFINITY Affinity)
Definition: procobj.c:265
KAFFINITY KeActiveProcessors
Definition: processor.c:16
VOID NTAPI Ke386SetIOPL(VOID)
Definition: v86vdm.c:595
VOID NTAPI KeQueryValuesProcess(IN PKPROCESS Process, PPROCESS_VALUES Values)
Definition: procobj.c:525
BOOLEAN NTAPI KeSetDisableBoostProcess(IN PKPROCESS Process, IN BOOLEAN Disable)
Definition: procobj.c:331
BOOLEAN NTAPI KeSetDisableBoostThread(IN OUT PKTHREAD Thread, IN BOOLEAN Disable)
Definition: thrdobj.c:86
BOOLEAN NTAPI KeReadStateThread(IN PKTHREAD Thread)
Definition: thrdobj.c:42
BOOLEAN NTAPI KeSetAutoAlignmentProcess(IN PKPROCESS Process, IN BOOLEAN Enable)
Definition: procobj.c:313
VOID NTAPI KeBoostPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Increment)
Definition: thrdobj.c:220
KPRIORITY NTAPI KeSetPriorityAndQuantumProcess(IN PKPROCESS Process, IN KPRIORITY Priority, IN UCHAR Quantum OPTIONAL)
Definition: procobj.c:349
PFILE_OBJECT NTAPI MmGetFileObjectForSection(IN PVOID Section)
Definition: section.c:1540
VOID NTAPI MmGetImageInformation(OUT PSECTION_IMAGE_INFORMATION ImageInformation)
Definition: section.c:1617
NTSTATUS NTAPI MmSetExecuteOptions(IN ULONG ExecuteOptions)
Definition: pagfault.c:2695
NTSTATUS NTAPI MmSetMemoryPriorityProcess(IN PEPROCESS Process, IN UCHAR MemoryPriority)
Definition: procsup.c:487
NTSTATUS NTAPI MmGetExecuteOptions(IN PULONG ExecuteOptions)
Definition: pagfault.c:2653
static __inline NTSTATUS DefaultQueryInfoBufferCheck(_In_ ULONG Class, _In_ const INFORMATION_CLASS_INFO *ClassList, _In_ ULONG ClassListEntries, _In_ ULONG Flags, _In_opt_ PVOID Buffer, _In_ ULONG BufferLength, _In_opt_ PULONG ReturnLength, _In_opt_ PULONG_PTR ReturnLengthPtr, _In_ KPROCESSOR_MODE PreviousMode)
Probe helper that validates the provided parameters whenever a NtQuery*** system call is invoked from...
Definition: probe.h:219
static __inline NTSTATUS DefaultSetInfoBufferCheck(_In_ ULONG Class, _In_ const INFORMATION_CLASS_INFO *ClassList, _In_ ULONG ClassListEntries, _In_ PVOID Buffer, _In_ ULONG BufferLength, _In_ KPROCESSOR_MODE PreviousMode)
Probe helper that validates the provided parameters whenever a NtSet*** system call is invoked from u...
Definition: probe.h:70
const LUID SeDebugPrivilege
Definition: priv.c:39
BOOLEAN NTAPI SeCheckPrivilegedObject(_In_ LUID PrivilegeValue, _In_ HANDLE ObjectHandle, _In_ ACCESS_MASK DesiredAccess, _In_ KPROCESSOR_MODE PreviousMode)
Checks a privileged object if such object has the specific privilege submitted by the caller.
Definition: priv.c:803
const LUID SeTcbPrivilege
Definition: priv.c:26
const LUID SeIncreaseBasePriorityPrivilege
Definition: priv.c:33
NTSTATUS NTAPI IoQueryFileDosDeviceName(IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation)
Definition: file.c:3664
ULONG KeMaximumIncrement
Definition: clock.c:20
POBJECT_TYPE PsProcessType
Definition: process.c:20
ULONG NTAPI PsGetProcessSessionId(IN PEPROCESS Process)
Definition: process.c:1163
VOID NTAPI PsSetProcessPriorityByClass(IN PEPROCESS Process, IN PSPROCESSPRIORITYMODE Type)
Definition: process.c:1325
ULONG PspTraceLevel
Definition: query.c:18
NTSTATUS NTAPI NtQueryInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _Out_writes_bytes_to_opt_(ThreadInformationLength, *ReturnLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:2881
NTSTATUS NTAPI NtSetInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength)
Definition: query.c:1389
NTSTATUS NTAPI PsReferenceProcessFilePointer(_In_ PEPROCESS Process, _Outptr_ PFILE_OBJECT *FileObject)
Definition: query.c:24
NTSTATUS NTAPI NtSetInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength)
Definition: query.c:2268
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
NTSTATUS NTAPI PsAssignImpersonationToken(IN PETHREAD Thread, IN HANDLE TokenHandle)
Definition: security.c:502
POBJECT_TYPE PsThreadType
Definition: thread.c:20
BOOLEAN NTAPI PsIsThreadTerminating(IN PETHREAD Thread)
Definition: thread.c:868
NTSTATUS NTAPI SeLocateProcessImageName(_In_ PEPROCESS Process, _Out_ PUNICODE_STRING *ProcessImageName)
Finds the process image name of a specific process.
Definition: audit.c:199
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_PROCESS_IS_TERMINATING
Definition: ntstatus.h:596
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:333
#define STATUS_PORT_ALREADY_SET
Definition: ntstatus.h:402
ULONG NTAPI ObGetProcessHandleCount(IN PEPROCESS Process)
Definition: obhandle.c:56
NTSTATUS NTAPI ObSetDeviceMap(IN PEPROCESS Process, IN HANDLE DirectoryHandle)
Definition: devicemap.c:24
ULONG NTAPI ObIsLUIDDeviceMapsEnabled(VOID)
Definition: devicemap.c:662
NTSTATUS NTAPI ObQueryDeviceMapInformation(_In_opt_ PEPROCESS Process, _Out_ PPROCESS_DEVICEMAP_INFORMATION DeviceMapInfo, _In_ ULONG Flags)
Definition: devicemap.c:539
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3379
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
long LONG
Definition: pedump.c:60
static WCHAR Address[46]
Definition: ping.c:68
NTSTATUS NTAPI PspSetPrimaryToken(IN PEPROCESS Process, IN HANDLE TokenHandle OPTIONAL, IN PACCESS_TOKEN Token OPTIONAL)
Definition: security.c:215
NTSTATUS NTAPI PspSetQuotaLimits(_In_ PEPROCESS Process, _In_ ULONG Unused, _In_ PVOID QuotaLimits, _In_ ULONG QuotaLimitsLength, _In_ KPROCESSOR_MODE PreviousMode)
This function adjusts the working set limits of a process and sets up new quota limits when necessary...
Definition: quota.c:1045
PETHREAD NTAPI PsGetNextProcessThread(IN PEPROCESS Process, IN PETHREAD Thread OPTIONAL)
Definition: process.c:75
EPROCESS_QUOTA_BLOCK PspDefaultQuotaBlock
Definition: quota.c:16
static const INFORMATION_CLASS_INFO PsThreadInfoClass[]
Definition: ps_i.h:362
static const INFORMATION_CLASS_INFO PsProcessInfoClass[]
Definition: ps_i.h:15
#define PspSetCrossThreadFlag(Thread, Flag)
Definition: ps_x.h:25
#define PspClearCrossThreadFlag(Thread, Flag)
Definition: ps_x.h:27
#define PspClearProcessFlag(Process, Flag)
Definition: ps_x.h:35
#define PspSetProcessFlag(Process, Flag)
Definition: ps_x.h:33
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
NTSTATUS NTAPI PspQueryDescriptorThread(IN PETHREAD Thread, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: psldt.c:43
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define STATUS_SUCCESS
Definition: shellext.h:65
STDMETHOD() Next(THIS_ ULONG celt, IAssociationElement *pElement, ULONG *pceltFetched) PURE
#define TLS_MINIMUM_AVAILABLE
Definition: ntddk_ex.h:236
LARGE_INTEGER ExitTime
Definition: pstypes.h:1196
NTSTATUS ExitStatus
Definition: pstypes.h:1202
KTHREAD Tcb
Definition: pstypes.h:1192
EX_RUNDOWN_REF RundownProtect
Definition: pstypes.h:1248
PVOID Win32StartAddress
Definition: pstypes.h:1241
CLIENT_ID Cid
Definition: pstypes.h:1217
LIST_ENTRY IrpList
Definition: pstypes.h:1233
LARGE_INTEGER CreateTime
Definition: pstypes.h:1193
ULONG BreakOnTermination
Definition: pstypes.h:1273
LARGE_INTEGER UserTime
Definition: winternl.h:2377
LARGE_INTEGER CreateTime
Definition: winternl.h:2374
LARGE_INTEGER KernelTime
Definition: winternl.h:2376
LARGE_INTEGER ExitTime
Definition: winternl.h:2375
ULONG InterruptTime
Definition: ketypes.h:834
ULONG KeSystemCalls
Definition: ketypes.h:745
GROUP_AFFINITY Affinity
Definition: ketypes.h:2066
ULONG IdealProcessor
Definition: ketypes.h:2072
ULONG DisableBoost
Definition: ketypes.h:1853
SCHAR Priority
Definition: ketypes.h:1910
PVOID Teb
Definition: ketypes.h:1935
ULONG KernelTime
Definition: ketypes.h:2115
ULONG UserTime
Definition: ketypes.h:2131
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG_PTR InheritedFromUniqueProcessId
Definition: pstypes.h:362
IO_COUNTERS IoInfo
Definition: ke.h:48
SIZE_T MaximumWorkingSetSize
Definition: pstypes.h:71
SIZE_T PagedPoolLimit
Definition: pstypes.h:68
SIZE_T PagefileLimit
Definition: pstypes.h:72
LARGE_INTEGER TimeLimit
Definition: pstypes.h:73
RATE_QUOTA_LIMIT CpuRateLimit
Definition: pstypes.h:79
SIZE_T NonPagedPoolLimit
Definition: pstypes.h:69
SIZE_T MinimumWorkingSetSize
Definition: pstypes.h:70
Definition: compat.h:836
PVOID * TlsExpansionSlots
Definition: compat.h:894
PVOID TlsSlots[64]
Definition: compat.h:879
KPRIORITY BasePriority
Definition: compat.h:932
KAFFINITY AffinityMask
Definition: compat.h:930
SIZE_T PeakWorkingSetSize
Definition: winternl.h:3134
SIZE_T PeakPagefileUsage
Definition: winternl.h:3141
ULONG PageFaultCount
Definition: winternl.h:3133
SIZE_T QuotaPagedPoolUsage
Definition: winternl.h:3137
SIZE_T QuotaPeakPagedPoolUsage
Definition: winternl.h:3136
SIZE_T QuotaPeakNonPagedPoolUsage
Definition: winternl.h:3138
SIZE_T PeakVirtualSize
Definition: winternl.h:3131
SIZE_T VirtualSize
Definition: winternl.h:3132
SIZE_T QuotaNonPagedPoolUsage
Definition: winternl.h:3139
SIZE_T WorkingSetSize
Definition: winternl.h:3135
SIZE_T PagefileUsage
Definition: winternl.h:3140
#define TAG_SEPA
Definition: tag.h:155
UCHAR NTAPI KeSetIdealProcessorThread(IN PKTHREAD Thread, IN UCHAR Processor)
Definition: thrdobj.c:1066
LONG NTAPI KeSetBasePriorityThread(IN PKTHREAD Thread, IN LONG Increment)
Definition: thrdobj.c:1157
KPRIORITY NTAPI KeSetPriorityThread(IN PKTHREAD Thread, IN KPRIORITY Priority)
Definition: thrdobj.c:1300
KAFFINITY NTAPI KeSetAffinityThread(IN PKTHREAD Thread, IN KAFFINITY Affinity)
Definition: thrdobj.c:1276
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t * PULONG_PTR
Definition: typedefs.h:65
uint32_t * PULONG
Definition: typedefs.h:59
unsigned char * PBOOLEAN
Definition: typedefs.h:53
int64_t LONGLONG
Definition: typedefs.h:68
#define NTAPI
Definition: typedefs.h:36
union _LARGE_INTEGER LARGE_INTEGER
void * PVOID
Definition: typedefs.h:50
PVOID HANDLE
Definition: typedefs.h:73
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
int32_t * PLONG
Definition: typedefs.h:58
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:85
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
char CCHAR
Definition: typedefs.h:51
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2479 u
ULONG RateData
Definition: pstypes.h:60
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
BOOLEAN HasPrivilege(IN PPRIVILEGE_SET Privilege)
Definition: shutdown.c:92
#define TlsIndex
Definition: ws2_32p.h:277
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14
_In_ ULONG _In_ ULONG _In_ ULONG _Out_ PKIRQL _Out_ PKAFFINITY Affinity
Definition: halfuncs.h:174
* PFILE_OBJECT
Definition: iotypes.h:1998
_Out_ PULONG UserTime
Definition: kefuncs.h:759
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
#define ObDereferenceObject
Definition: obfuncs.h:203
#define ObReferenceObject
Definition: obfuncs.h:204
#define PsGetCurrentProcess
Definition: psfuncs.h:17
unsigned char UCHAR
Definition: xmlstorage.h:181
char CHAR
Definition: xmlstorage.h:175