ReactOS  0.4.11-dev-721-g95bc44e
sysinfo.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: ntoskrnl/ex/sysinfo.c
5  * PURPOSE: System information functions
6  *
7  * PROGRAMMERS: David Welch (welch@mcmail.com)
8  * Aleksey Bragin (aleksey@reactos.org)
9  */
10 
11 /* INCLUDES *****************************************************************/
12 
13 #include <ntoskrnl.h>
14 #include <wmidata.h>
15 #include <wmistr.h>
16 #define NDEBUG
17 #include <debug.h>
18 
19 /* The maximum size of an environment value (in bytes) */
20 #define MAX_ENVVAL_SIZE 1024
21 
22 #define SIG_ACPI 0x41435049
23 #define SIG_FIRM 0x4649524D
24 #define SIG_RSMB 0x52534D42
25 
28 
32 
36  IN PLDR_DATA_TABLE_ENTRY LdrEntry,
38 {
39  PCHAR p;
42 
43  /* Fill it out */
44  ModuleInfo->MappedBase = NULL;
45  ModuleInfo->ImageBase = LdrEntry->DllBase;
46  ModuleInfo->ImageSize = LdrEntry->SizeOfImage;
47  ModuleInfo->Flags = LdrEntry->Flags;
48  ModuleInfo->LoadCount = LdrEntry->LoadCount;
49  ModuleInfo->LoadOrderIndex = (USHORT)ModuleCount;
50  ModuleInfo->InitOrderIndex = 0;
51 
52  /* Setup name */
53  RtlInitEmptyAnsiString(&ModuleName,
54  ModuleInfo->FullPathName,
55  sizeof(ModuleInfo->FullPathName));
56 
57  /* Convert it */
58  Status = RtlUnicodeStringToAnsiString(&ModuleName,
59  &LdrEntry->FullDllName,
60  FALSE);
61  if ((NT_SUCCESS(Status)) || (Status == STATUS_BUFFER_OVERFLOW))
62  {
63  /* Calculate offset to name */
64  p = ModuleName.Buffer + ModuleName.Length;
65  while ((p > ModuleName.Buffer) && (*--p))
66  {
67  /* Check if we found the separator */
68  if (*p == OBJ_NAME_PATH_SEPARATOR)
69  {
70  /* We did, break out */
71  p++;
72  break;
73  }
74  }
75 
76  /* Set the offset */
77  ModuleInfo->OffsetToFileName = (USHORT)(p - ModuleName.Buffer);
78  }
79  else
80  {
81  /* Return empty name */
82  ModuleInfo->FullPathName[0] = ANSI_NULL;
83  ModuleInfo->OffsetToFileName = 0;
84  }
85 
86  return Status;
87 }
88 
90 NTAPI
92  IN PLIST_ENTRY UserModeList,
93  OUT PRTL_PROCESS_MODULES Modules,
94  IN ULONG Length,
96 {
100  PLDR_DATA_TABLE_ENTRY LdrEntry;
101  ULONG ModuleCount = 0;
102  PLIST_ENTRY NextEntry;
103 
104  /* Setup defaults */
105  RequiredLength = FIELD_OFFSET(RTL_PROCESS_MODULES, Modules);
106  ModuleInfo = &Modules->Modules[0];
107 
108  /* Loop the kernel list */
109  NextEntry = KernelModeList->Flink;
110  while (NextEntry != KernelModeList)
111  {
112  /* Get the entry */
113  LdrEntry = CONTAINING_RECORD(NextEntry,
115  InLoadOrderLinks);
116 
117  /* Update size and check if we can manage one more entry */
118  RequiredLength += sizeof(RTL_PROCESS_MODULE_INFORMATION);
119  if (Length >= RequiredLength)
120  {
121  Status = ExpConvertLdrModuleToRtlModule(ModuleCount,
122  LdrEntry,
123  ModuleInfo);
124 
125  /* Go to the next module */
126  ModuleInfo++;
127  }
128  else
129  {
130  /* Set error code */
132  }
133 
134  /* Update count and move to next entry */
135  ModuleCount++;
136  NextEntry = NextEntry->Flink;
137  }
138 
139  /* Check if caller also wanted user modules */
140  if (UserModeList)
141  {
142  NextEntry = UserModeList->Flink;
143  while (NextEntry != UserModeList)
144  {
145  /* Get the entry */
146  LdrEntry = CONTAINING_RECORD(NextEntry,
148  InLoadOrderLinks);
149 
150  /* Update size and check if we can manage one more entry */
151  RequiredLength += sizeof(RTL_PROCESS_MODULE_INFORMATION);
152  if (Length >= RequiredLength)
153  {
154  Status = ExpConvertLdrModuleToRtlModule(ModuleCount,
155  LdrEntry,
156  ModuleInfo);
157 
158  /* Go to the next module */
159  ModuleInfo++;
160  }
161  else
162  {
163  /* Set error code */
165  }
166 
167  /* Update count and move to next entry */
168  ModuleCount++;
169  NextEntry = NextEntry->Flink;
170  }
171  }
172 
173  /* Update return length */
174  if (ReturnLength) *ReturnLength = RequiredLength;
175 
176  /* Validate the length again */
177  if (Length >= FIELD_OFFSET(RTL_PROCESS_MODULES, Modules))
178  {
179  /* Set the final count */
180  Modules->NumberOfModules = ModuleCount;
181  }
182  else
183  {
184  /* Otherwise, we failed */
186  }
187 
188  /* Done */
189  return Status;
190 }
191 
192 VOID
193 NTAPI
195 {
196  MmUnlockPages(Mdl);
198 }
199 
200 NTSTATUS
201 NTAPI
204  ULONG Length,
207  PVOID *MappedSystemVa,
208  PMDL *OutMdl)
209 {
210  PMDL Mdl;
211  PAGED_CODE();
212 
213  *MappedSystemVa = NULL;
214  *OutMdl = NULL;
215 
216  /* Allocate an MDL for the buffer */
217  Mdl = IoAllocateMdl(BaseAddress, Length, FALSE, TRUE, NULL);
218  if (Mdl == NULL)
219  {
221  }
222 
223  /* Enter SEH for probing */
224  _SEH2_TRY
225  {
226  MmProbeAndLockPages(Mdl, AccessMode, Operation);
227  }
229  {
232  }
233  _SEH2_END;
234 
235  /* Return the safe kernel mode buffer */
236  *MappedSystemVa = MmGetSystemAddressForMdlSafe(Mdl, NormalPagePriority);
237  if (*MappedSystemVa == NULL)
238  {
239  ExUnlockUserBuffer(Mdl);
241  }
242 
243  /* Return the MDL */
244  *OutMdl = Mdl;
245  return STATUS_SUCCESS;
246 }
247 
248 NTSTATUS
249 NTAPI
252  _Out_ ULONG * OutSize,
254 {
256  PVOID DataBlockObject;
257  PWNODE_ALL_DATA AllData;
258  ULONG WMIBufSize;
259 
260  ASSERT(OutSize != NULL);
261  *OutSize = 0;
262 
263  /* Open the data block object for the SMBIOS table */
266  &DataBlockObject);
267  if (!NT_SUCCESS(Status))
268  {
269  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
270  return Status;
271  }
272 
273  /* Query the required buffer size */
274  WMIBufSize = 0;
275  Status = IoWMIQueryAllData(DataBlockObject, &WMIBufSize, NULL);
276  if (!NT_SUCCESS(Status))
277  {
278  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
279  return Status;
280  }
281 
282  AllData = ExAllocatePoolWithTag(PagedPool, WMIBufSize, 'itfS');
283  if (AllData == NULL)
284  {
285  DPRINT1("Failed to allocate %lu bytes for SMBIOS tables\n", WMIBufSize);
287  }
288 
289  /* Query the buffer data */
290  Status = IoWMIQueryAllData(DataBlockObject, &WMIBufSize, AllData);
291  if (!NT_SUCCESS(Status))
292  {
293  DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
294  ExFreePoolWithTag(AllData, 'itfS');
295  return Status;
296  }
297 
298  Status = STATUS_SUCCESS;
299  *OutSize = AllData->FixedInstanceSize;
300  if (Buffer != NULL)
301  {
302  if (BufferSize >= *OutSize)
303  {
304  RtlMoveMemory(Buffer, AllData + 1, *OutSize);
305  }
306  else
307  {
308  Status = STATUS_BUFFER_TOO_SMALL;
309  }
310  }
311 
312  /* Free the buffer */
313  ExFreePoolWithTag(AllData, 'itfS');
314  return Status;
315 }
316 
317 /* FUNCTIONS *****************************************************************/
318 
319 /*
320  * @implemented
321  */
322 VOID
323 NTAPI
325 {
326  PKPRCB Prcb;
327  ULONG TotalTime;
328  ULONGLONG ScaledIdle;
329 
330  Prcb = KeGetCurrentPrcb();
331 
332  ScaledIdle = (ULONGLONG)Prcb->IdleThread->KernelTime * 100;
333  TotalTime = Prcb->KernelTime + Prcb->UserTime;
334  if (TotalTime != 0)
335  *CpuUsage = (ULONG)(100 - (ScaledIdle / TotalTime));
336  else
337  *CpuUsage = 0;
338 }
339 
340 /*
341  * @implemented
342  */
343 VOID
344 NTAPI
346  PULONG TotalCpuTime,
347  PULONG ProcessorNumber)
348 {
349  PKPRCB Prcb;
350 
351  Prcb = KeGetCurrentPrcb();
352 
353  *ThreadKernelTime = Prcb->KernelTime + Prcb->UserTime;
354  *TotalCpuTime = Prcb->CurrentThread->KernelTime;
355  *ProcessorNumber = KeGetCurrentProcessorNumber();
356 }
357 
358 /*
359  * @implemented
360  */
361 BOOLEAN
362 NTAPI
364 {
365  /* Quick check to see if it exists at all */
366  if (ProcessorFeature >= PROCESSOR_FEATURE_MAX) return(FALSE);
367 
368  /* Return our support for it */
369  return(SharedUserData->ProcessorFeatures[ProcessorFeature]);
370 }
371 
372 /*
373  * @implemented
374  */
375 BOOLEAN
376 NTAPI
378 {
379  if (SuiteType == Personal) return TRUE;
380  return FALSE;
381 }
382 
383 NTSTATUS
384 NTAPI
386  OUT PWSTR ValueBuffer,
387  IN ULONG ValueBufferLength,
389 {
390  ANSI_STRING AName;
391  UNICODE_STRING WName;
393  PCH AnsiValueBuffer;
394  ANSI_STRING AValue;
395  UNICODE_STRING WValue;
398  PAGED_CODE();
399 
400  /* Check if the call came from user mode */
401  PreviousMode = ExGetPreviousMode();
402  if (PreviousMode != KernelMode)
403  {
404  _SEH2_TRY
405  {
406  /* Probe the input and output buffers */
407  ProbeForRead(VariableName, sizeof(UNICODE_STRING), sizeof(ULONG));
408  ProbeForWrite(ValueBuffer, ValueBufferLength, sizeof(WCHAR));
410  }
412  {
413  /* Return the exception code */
415  }
416  _SEH2_END;
417  }
418 
419  /* According to NTInternals the SeSystemEnvironmentName privilege is required! */
421  {
422  DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
424  }
425 
426  /* Copy the name to kernel space if necessary */
427  Status = ProbeAndCaptureUnicodeString(&WName, PreviousMode, VariableName);
428  if (!NT_SUCCESS(Status)) return Status;
429 
430  /* Convert the name to ANSI and release the captured UNICODE string */
431  Status = RtlUnicodeStringToAnsiString(&AName, &WName, TRUE);
432  ReleaseCapturedUnicodeString(&WName, PreviousMode);
433  if (!NT_SUCCESS(Status)) return Status;
434 
435  /* Allocate a buffer for the ANSI environment variable */
436  AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, MAX_ENVVAL_SIZE, 'rvnE');
437  if (AnsiValueBuffer == NULL)
438  {
439  RtlFreeAnsiString(&AName);
441  }
442 
443  /* Get the environment variable and free the ANSI name */
444  Result = HalGetEnvironmentVariable(AName.Buffer,
446  AnsiValueBuffer);
447  RtlFreeAnsiString(&AName);
448 
449  /* Check if we had success */
450  if (Result == ESUCCESS)
451  {
452  /* Copy the result back to the caller. */
453  _SEH2_TRY
454  {
455  /* Initialize ANSI string from the result */
456  RtlInitAnsiString(&AValue, AnsiValueBuffer);
457 
458  /* Initialize a UNICODE string from the callers buffer */
459  RtlInitEmptyUnicodeString(&WValue, ValueBuffer, (USHORT)ValueBufferLength);
460 
461  /* Convert the result to UNICODE */
462  Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);
463 
464  if (ReturnLength != NULL)
465  *ReturnLength = WValue.Length;
466  }
468  {
469  Status = _SEH2_GetExceptionCode();
470  }
471  _SEH2_END;
472  }
473  else
474  {
475  Status = STATUS_UNSUCCESSFUL;
476  }
477 
478  /* Free the allocated ANSI value buffer */
479  ExFreePoolWithTag(AnsiValueBuffer, 'rvnE');
480 
481  return Status;
482 }
483 
484 
485 NTSTATUS
486 NTAPI
489 {
490  UNICODE_STRING CapturedName, CapturedValue;
491  ANSI_STRING AName, AValue;
494 
495  PAGED_CODE();
496 
497  PreviousMode = ExGetPreviousMode();
498 
499  /*
500  * Copy the strings to kernel space if necessary
501  */
502  Status = ProbeAndCaptureUnicodeString(&CapturedName,
503  PreviousMode,
504  VariableName);
505  if (NT_SUCCESS(Status))
506  {
507  Status = ProbeAndCaptureUnicodeString(&CapturedValue,
508  PreviousMode,
509  Value);
510  if (NT_SUCCESS(Status))
511  {
512  /*
513  * according to ntinternals the SeSystemEnvironmentName privilege is required!
514  */
516  PreviousMode))
517  {
518  /*
519  * convert the strings to ANSI
520  */
521  Status = RtlUnicodeStringToAnsiString(&AName,
522  &CapturedName,
523  TRUE);
524  if (NT_SUCCESS(Status))
525  {
526  Status = RtlUnicodeStringToAnsiString(&AValue,
527  &CapturedValue,
528  TRUE);
529  if (NT_SUCCESS(Status))
530  {
532  AValue.Buffer);
533 
534  Status = (Result ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
535  }
536  }
537  }
538  else
539  {
540  DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
541  Status = STATUS_PRIVILEGE_NOT_HELD;
542  }
543 
544  ReleaseCapturedUnicodeString(&CapturedValue,
545  PreviousMode);
546  }
547 
548  ReleaseCapturedUnicodeString(&CapturedName,
549  PreviousMode);
550  }
551 
552  return Status;
553 }
554 
555 NTSTATUS
556 NTAPI
558  IN PVOID Buffer,
560 {
562  return STATUS_NOT_IMPLEMENTED;
563 }
564 
565 NTSTATUS
566 NTAPI
568  IN LPGUID VendorGuid,
569  IN PVOID Value,
572 {
574  return STATUS_NOT_IMPLEMENTED;
575 }
576 
577 NTSTATUS
578 NTAPI
580  IN LPGUID VendorGuid,
581  IN PVOID Value,
584 {
586  return STATUS_NOT_IMPLEMENTED;
587 }
588 
589 /* --- Query/Set System Information --- */
590 
591 /*
592  * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
593  * so the stack is popped only in one place on x86 platform.
594  */
595 #define QSI_USE(n) QSI##n
596 #define QSI_DEF(n) \
597 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
598 
599 #define SSI_USE(n) SSI##n
600 #define SSI_DEF(n) \
601 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
602 
603 VOID
604 NTAPI
605 ExQueryPoolUsage(OUT PULONG PagedPoolPages,
606  OUT PULONG NonPagedPoolPages,
607  OUT PULONG PagedPoolAllocs,
608  OUT PULONG PagedPoolFrees,
609  OUT PULONG PagedPoolLookasideHits,
610  OUT PULONG NonPagedPoolAllocs,
611  OUT PULONG NonPagedPoolFrees,
612  OUT PULONG NonPagedPoolLookasideHits);
613 
614 /* Class 0 - Basic Information */
616 {
619 
620  *ReqSize = sizeof(SYSTEM_BASIC_INFORMATION);
621 
622  /* Check user buffer's size */
623  if (Size != sizeof(SYSTEM_BASIC_INFORMATION))
624  {
626  }
627 
628  RtlZeroMemory(Sbi, Size);
629  Sbi->Reserved = 0;
631  Sbi->PageSize = PAGE_SIZE;
635  Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */
636  Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */
640 
641  return STATUS_SUCCESS;
642 }
643 
644 /* Class 1 - Processor Information */
646 {
649 
650  *ReqSize = sizeof(SYSTEM_PROCESSOR_INFORMATION);
651 
652  /* Check user buffer's size */
653  if (Size < sizeof(SYSTEM_PROCESSOR_INFORMATION))
654  {
656  }
660  Spi->Reserved = 0;
662 
663  DPRINT("Arch %u Level %u Rev 0x%x\n", Spi->ProcessorArchitecture,
664  Spi->ProcessorLevel, Spi->ProcessorRevision);
665 
666  return STATUS_SUCCESS;
667 }
668 
669 /* Class 2 - Performance Information */
671 {
672  ULONG IdleUser, IdleKernel;
675 
677 
678  *ReqSize = sizeof(SYSTEM_PERFORMANCE_INFORMATION);
679 
680  /* Check user buffer's size */
681  if (Size < sizeof(SYSTEM_PERFORMANCE_INFORMATION))
682  {
684  }
685 
686  TheIdleProcess = PsIdleProcess;
687 
688  IdleKernel = KeQueryRuntimeProcess(&TheIdleProcess->Pcb, &IdleUser);
696 
698  /*
699  * Add up all the used "Committed" memory + pagefile.
700  * Not sure this is right. 8^\
701  */
706  /*
707  * Add up the full system total + pagefile.
708  * All this make Taskmgr happy but not sure it is the right numbers.
709  * This too, fixes some of GlobalMemoryStatusEx numbers.
710  */
712 
713  Spi->PeakCommitment = 0; /* FIXME */
714  Spi->PageFaultCount = 0; /* FIXME */
715  Spi->CopyOnWriteCount = 0; /* FIXME */
716  Spi->TransitionCount = 0; /* FIXME */
717  Spi->CacheTransitionCount = 0; /* FIXME */
718  Spi->DemandZeroCount = 0; /* FIXME */
719  Spi->PageReadCount = 0; /* FIXME */
720  Spi->PageReadIoCount = 0; /* FIXME */
721  Spi->CacheReadCount = 0; /* FIXME */
722  Spi->CacheIoCount = 0; /* FIXME */
723  Spi->DirtyPagesWriteCount = 0; /* FIXME */
724  Spi->DirtyWriteIoCount = 0; /* FIXME */
725  Spi->MappedPagesWriteCount = 0; /* FIXME */
726  Spi->MappedWriteIoCount = 0; /* FIXME */
727 
728  Spi->PagedPoolPages = 0;
729  Spi->NonPagedPoolPages = 0;
730  Spi->PagedPoolAllocs = 0;
731  Spi->PagedPoolFrees = 0;
732  Spi->PagedPoolLookasideHits = 0;
733  Spi->NonPagedPoolAllocs = 0;
734  Spi->NonPagedPoolFrees = 0;
735  Spi->NonPagedPoolLookasideHits = 0;
737  &Spi->NonPagedPoolPages,
738  &Spi->PagedPoolAllocs,
739  &Spi->PagedPoolFrees,
741  &Spi->NonPagedPoolAllocs,
742  &Spi->NonPagedPoolFrees,
744  Spi->FreeSystemPtes = 0; /* FIXME */
745 
746  Spi->ResidentSystemCodePage = 0; /* FIXME */
747 
748  Spi->TotalSystemDriverPages = 0; /* FIXME */
749  Spi->Spare3Count = 0; /* FIXME */
750 
752  Spi->ResidentPagedPoolPage = 0; /* FIXME */
753 
754  Spi->ResidentSystemDriverPage = 0; /* FIXME */
755  Spi->CcFastReadNoWait = 0; /* FIXME */
756  Spi->CcFastReadWait = 0; /* FIXME */
757  Spi->CcFastReadResourceMiss = 0; /* FIXME */
758  Spi->CcFastReadNotPossible = 0; /* FIXME */
759 
760  Spi->CcFastMdlReadNoWait = 0; /* FIXME */
761  Spi->CcFastMdlReadWait = 0; /* FIXME */
762  Spi->CcFastMdlReadResourceMiss = 0; /* FIXME */
763  Spi->CcFastMdlReadNotPossible = 0; /* FIXME */
764 
767  Spi->CcMapDataNoWaitMiss = 0; /* FIXME */
768  Spi->CcMapDataWaitMiss = 0; /* FIXME */
769 
773  Spi->CcPinReadNoWaitMiss = 0; /* FIXME */
774  Spi->CcPinReadWaitMiss = 0; /* FIXME */
775  Spi->CcCopyReadNoWait = 0; /* FIXME */
776  Spi->CcCopyReadWait = 0; /* FIXME */
777  Spi->CcCopyReadNoWaitMiss = 0; /* FIXME */
778  Spi->CcCopyReadWaitMiss = 0; /* FIXME */
779 
780  Spi->CcMdlReadNoWait = 0; /* FIXME */
781  Spi->CcMdlReadWait = 0; /* FIXME */
782  Spi->CcMdlReadNoWaitMiss = 0; /* FIXME */
783  Spi->CcMdlReadWaitMiss = 0; /* FIXME */
784  Spi->CcReadAheadIos = 0; /* FIXME */
788  Spi->CcDataPages = CcDataPages;
789  Spi->ContextSwitches = 0; /* FIXME */
790  Spi->FirstLevelTbFills = 0; /* FIXME */
791  Spi->SecondLevelTbFills = 0; /* FIXME */
792  Spi->SystemCalls = 0; /* FIXME */
793 
794  return STATUS_SUCCESS;
795 }
796 
797 /* Class 3 - Time Of Day Information */
799 {
801  LARGE_INTEGER CurrentTime;
802 
803  /* Set amount of written information to 0 */
804  *ReqSize = 0;
805 
806  /* Check user buffer's size */
807  if (Size > sizeof(SYSTEM_TIMEOFDAY_INFORMATION))
808  {
810  }
811 
812  /* Get current time */
813  KeQuerySystemTime(&CurrentTime);
814 
815  /* Zero local buffer */
817 
818  /* Fill local time structure */
819  Sti.BootTime= KeBootTime;
820  Sti.CurrentTime = CurrentTime;
823  Sti.Reserved = 0;
824 
825  /* Copy as much as requested by caller */
826  RtlCopyMemory(Buffer, &Sti, Size);
827 
828  /* Set amount of information we copied */
829  *ReqSize = Size;
830 
831  return STATUS_SUCCESS;
832 }
833 
834 /* Class 4 - Path Information */
836 {
837  /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
838  DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
839 
840  return STATUS_BREAKPOINT;
841 }
842 
843 /* Class 5 - Process Information */
845 {
846  PSYSTEM_PROCESS_INFORMATION SpiCurrent;
848  PEPROCESS Process = NULL, SystemProcess;
849  PETHREAD CurrentThread;
851  ULONG CurrentSize;
852  USHORT ImageNameMaximumLength; // image name length in bytes
853  USHORT ImageNameLength;
854  PLIST_ENTRY CurrentEntry;
855  ULONG TotalSize = 0, ThreadsCount;
856  ULONG TotalUser, TotalKernel;
857  PUCHAR Current;
859  PUNICODE_STRING TempProcessImageName;
860  _SEH2_VOLATILE PUNICODE_STRING ProcessImageName = NULL;
861  PWCHAR szSrc;
862  BOOLEAN Overflow = FALSE;
863 
864  _SEH2_TRY
865  {
866  /* scan the process list */
867 
870 
871  *ReqSize = sizeof(SYSTEM_PROCESS_INFORMATION);
872 
873  /* Check for overflow */
874  if (Size < sizeof(SYSTEM_PROCESS_INFORMATION))
875  {
876  Overflow = TRUE;
877  }
878 
879  /* Zero user's buffer */
880  if (!Overflow) RtlZeroMemory(Spi, Size);
881 
882  SystemProcess = PsIdleProcess;
883  Process = SystemProcess;
884  Current = (PUCHAR) Spi;
885 
886  do
887  {
888  SpiCurrent = (PSYSTEM_PROCESS_INFORMATION) Current;
889 
890  /* Lock the Process */
893 
894  if ((Process->ProcessExiting) &&
895  (Process->Pcb.Header.SignalState) &&
896  !(Process->ActiveThreads) &&
897  (IsListEmpty(&Process->Pcb.ThreadListHead)))
898  {
899  DPRINT1("Process %p (%s:%p) is a zombie\n",
900  Process, Process->ImageFileName, Process->UniqueProcessId);
901  CurrentSize = 0;
902  ImageNameMaximumLength = 0;
903 
904  /* Unlock the Process */
907  goto Skip;
908  }
909 
910  ThreadsCount = 0;
911  CurrentEntry = Process->Pcb.ThreadListHead.Flink;
912  while (CurrentEntry != &Process->Pcb.ThreadListHead)
913  {
914  ThreadsCount++;
915  CurrentEntry = CurrentEntry->Flink;
916  }
917 
918  // size of the structure for every process
919  CurrentSize = sizeof(SYSTEM_PROCESS_INFORMATION) + sizeof(SYSTEM_THREAD_INFORMATION) * ThreadsCount;
920  ImageNameLength = 0;
921  Status = SeLocateProcessImageName(Process, &TempProcessImageName);
922  ProcessImageName = TempProcessImageName;
923  szSrc = NULL;
924  if (NT_SUCCESS(Status) && (ProcessImageName->Length > 0))
925  {
926  szSrc = (PWCHAR)((PCHAR)ProcessImageName->Buffer + ProcessImageName->Length);
927  /* Loop the file name*/
928  while (szSrc > ProcessImageName->Buffer)
929  {
930  /* Make sure this isn't a backslash */
931  if (*--szSrc == OBJ_NAME_PATH_SEPARATOR)
932  {
933  szSrc++;
934  break;
935  }
936  else
937  {
938  ImageNameLength += sizeof(WCHAR);
939  }
940  }
941  }
942  if (!ImageNameLength && Process != PsIdleProcess)
943  {
944  ImageNameLength = (USHORT)strlen(Process->ImageFileName) * sizeof(WCHAR);
945  }
946 
947  /* Round up the image name length as NT does */
948  if (ImageNameLength > 0)
949  ImageNameMaximumLength = ROUND_UP(ImageNameLength + sizeof(WCHAR), 8);
950  else
951  ImageNameMaximumLength = 0;
952 
953  TotalSize += CurrentSize + ImageNameMaximumLength;
954 
955  /* Check for overflow */
956  if (TotalSize > Size)
957  {
958  Overflow = TRUE;
959  }
960 
961  /* Fill system information */
962  if (!Overflow)
963  {
964  SpiCurrent->NextEntryOffset = CurrentSize + ImageNameMaximumLength; // relative offset to the beginning of the next structure
965  SpiCurrent->NumberOfThreads = ThreadsCount;
966  SpiCurrent->CreateTime = Process->CreateTime;
967  SpiCurrent->ImageName.Length = ImageNameLength;
968  SpiCurrent->ImageName.MaximumLength = ImageNameMaximumLength;
969  SpiCurrent->ImageName.Buffer = (void*)(Current + CurrentSize);
970 
971  /* Copy name to the end of the struct */
972  if(Process != PsIdleProcess)
973  {
974  if (szSrc)
975  {
976  RtlCopyMemory(SpiCurrent->ImageName.Buffer, szSrc, SpiCurrent->ImageName.Length);
977  }
978  else
979  {
980  RtlInitAnsiString(&ImageName, Process->ImageFileName);
981  RtlAnsiStringToUnicodeString(&SpiCurrent->ImageName, &ImageName, FALSE);
982  }
983  }
984  else
985  {
986  RtlInitUnicodeString(&SpiCurrent->ImageName, NULL);
987  }
988 
989  SpiCurrent->BasePriority = Process->Pcb.BasePriority;
990  SpiCurrent->UniqueProcessId = Process->UniqueProcessId;
992  SpiCurrent->HandleCount = ObGetProcessHandleCount(Process);
993  SpiCurrent->PeakVirtualSize = Process->PeakVirtualSize;
994  SpiCurrent->VirtualSize = Process->VirtualSize;
995  SpiCurrent->PageFaultCount = Process->Vm.PageFaultCount;
996  SpiCurrent->PeakWorkingSetSize = Process->Vm.PeakWorkingSetSize;
997  SpiCurrent->WorkingSetSize = Process->Vm.WorkingSetSize;
998  SpiCurrent->QuotaPeakPagedPoolUsage = Process->QuotaPeak[0];
999  SpiCurrent->QuotaPagedPoolUsage = Process->QuotaUsage[0];
1000  SpiCurrent->QuotaPeakNonPagedPoolUsage = Process->QuotaPeak[1];
1001  SpiCurrent->QuotaNonPagedPoolUsage = Process->QuotaUsage[1];
1002  SpiCurrent->PagefileUsage = Process->QuotaUsage[2];
1003  SpiCurrent->PeakPagefileUsage = Process->QuotaPeak[2];
1004  SpiCurrent->PrivatePageCount = Process->CommitCharge;
1005  ThreadInfo = (PSYSTEM_THREAD_INFORMATION)(SpiCurrent + 1);
1006 
1007  CurrentEntry = Process->Pcb.ThreadListHead.Flink;
1008  while (CurrentEntry != &Process->Pcb.ThreadListHead)
1009  {
1010  CurrentThread = CONTAINING_RECORD(CurrentEntry, ETHREAD, Tcb.ThreadListEntry);
1011 
1012  ThreadInfo->KernelTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.KernelTime, KeMaximumIncrement);
1013  ThreadInfo->UserTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.UserTime, KeMaximumIncrement);
1014  ThreadInfo->CreateTime.QuadPart = CurrentThread->CreateTime.QuadPart;
1015  ThreadInfo->WaitTime = CurrentThread->Tcb.WaitTime;
1016  ThreadInfo->StartAddress = (PVOID) CurrentThread->StartAddress;
1017  ThreadInfo->ClientId = CurrentThread->Cid;
1018  ThreadInfo->Priority = CurrentThread->Tcb.Priority;
1019  ThreadInfo->BasePriority = CurrentThread->Tcb.BasePriority;
1020  ThreadInfo->ContextSwitches = CurrentThread->Tcb.ContextSwitches;
1021  ThreadInfo->ThreadState = CurrentThread->Tcb.State;
1022  ThreadInfo->WaitReason = CurrentThread->Tcb.WaitReason;
1023 
1024  ThreadInfo++;
1025  CurrentEntry = CurrentEntry->Flink;
1026  }
1027 
1028  /* Query total user/kernel times of a process */
1029  TotalKernel = KeQueryRuntimeProcess(&Process->Pcb, &TotalUser);
1030  SpiCurrent->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
1031  SpiCurrent->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
1032  }
1033 
1034  if (ProcessImageName)
1035  {
1036  /* Release the memory allocated by SeLocateProcessImageName */
1037  ExFreePoolWithTag(ProcessImageName, TAG_SEPA);
1038  ProcessImageName = NULL;
1039  }
1040 
1041  /* Unlock the Process */
1044 
1045  /* Handle idle process entry */
1046 Skip:
1047  if (Process == PsIdleProcess) Process = NULL;
1048 
1049  Process = PsGetNextProcess(Process);
1050  ThreadsCount = 0;
1051  if ((Process == SystemProcess) || (Process == NULL))
1052  {
1053  if (!Overflow)
1054  SpiCurrent->NextEntryOffset = 0;
1055  break;
1056  }
1057  else
1058  Current += CurrentSize + ImageNameMaximumLength;
1059  } while ((Process != SystemProcess) && (Process != NULL));
1060 
1061  if(Process != NULL)
1062  ObDereferenceObject(Process);
1063  Status = STATUS_SUCCESS;
1064  }
1066  {
1067  if(Process != NULL)
1068  ObDereferenceObject(Process);
1069  if (ProcessImageName)
1070  {
1071  /* Release the memory allocated by SeLocateProcessImageName */
1072  ExFreePoolWithTag(ProcessImageName, TAG_SEPA);
1073  }
1074 
1075  Status = _SEH2_GetExceptionCode();
1076  }
1077  _SEH2_END
1078 
1079  if (Overflow)
1080  Status = STATUS_INFO_LENGTH_MISMATCH;
1081 
1082  *ReqSize = TotalSize;
1083  return Status;
1084 }
1085 
1086 /* Class 6 - Call Count Information */
1088 {
1089  /* FIXME */
1090  DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
1091  return STATUS_NOT_IMPLEMENTED;
1092 }
1093 
1094 /* Class 7 - Device Information */
1096 {
1100 
1101  *ReqSize = sizeof(SYSTEM_DEVICE_INFORMATION);
1102 
1103  /* Check user buffer's size */
1104  if (Size < sizeof(SYSTEM_DEVICE_INFORMATION))
1105  {
1107  }
1108 
1109  ConfigInfo = IoGetConfigurationInformation();
1110 
1111  Sdi->NumberOfDisks = ConfigInfo->DiskCount;
1112  Sdi->NumberOfFloppies = ConfigInfo->FloppyCount;
1113  Sdi->NumberOfCdRoms = ConfigInfo->CdRomCount;
1114  Sdi->NumberOfTapes = ConfigInfo->TapeCount;
1115  Sdi->NumberOfSerialPorts = ConfigInfo->SerialCount;
1116  Sdi->NumberOfParallelPorts = ConfigInfo->ParallelCount;
1117 
1118  return STATUS_SUCCESS;
1119 }
1120 
1121 /* Class 8 - Processor Performance Information */
1123 {
1126 
1127  LONG i;
1128  ULONG TotalTime;
1129  PKPRCB Prcb;
1130 
1132 
1133  /* Check user buffer's size */
1134  if (Size < *ReqSize)
1135  {
1137  }
1138 
1139  for (i = 0; i < KeNumberProcessors; i++)
1140  {
1141  /* Get the PRCB on this processor */
1142  Prcb = KiProcessorBlock[i];
1143 
1144  /* Calculate total user and kernel times */
1145  TotalTime = Prcb->IdleThread->KernelTime + Prcb->IdleThread->UserTime;
1151  Spi->InterruptCount = Prcb->InterruptCount;
1152  Spi++;
1153  }
1154 
1155  return STATUS_SUCCESS;
1156 }
1157 
1158 /* Class 9 - Flags Information */
1160 {
1161 #if (NTDDI_VERSION >= NTDDI_VISTA)
1162  *ReqSize = sizeof(SYSTEM_FLAGS_INFORMATION);
1163 #endif
1164 
1165  if (sizeof(SYSTEM_FLAGS_INFORMATION) != Size)
1166  {
1168  }
1169 
1171 #if (NTDDI_VERSION < NTDDI_VISTA)
1172  *ReqSize = sizeof(SYSTEM_FLAGS_INFORMATION);
1173 #endif
1174 
1175  return STATUS_SUCCESS;
1176 }
1177 
1179 {
1180  if (sizeof(SYSTEM_FLAGS_INFORMATION) != Size)
1181  {
1183  }
1184 
1186  {
1187  return STATUS_ACCESS_DENIED;
1188  }
1189 
1191  return STATUS_SUCCESS;
1192 }
1193 
1194 /* Class 10 - Call Time Information */
1196 {
1197  /* FIXME */
1198  DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
1199  return STATUS_NOT_IMPLEMENTED;
1200 }
1201 
1202 /* Class 11 - Module Information */
1204 {
1205  NTSTATUS Status;
1206 
1207  /* Acquire system module list lock */
1210 
1211  /* Call the generic handler with the system module list */
1215  Size,
1216  ReqSize);
1217 
1218  /* Release list lock and return status */
1221  return Status;
1222 }
1223 
1224 /* Class 12 - Locks Information */
1226 {
1227  /* FIXME */
1228  DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
1229  return STATUS_NOT_IMPLEMENTED;
1230 }
1231 
1232 /* Class 13 - Stack Trace Information */
1234 {
1235  /* FIXME */
1236  DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
1237  return STATUS_NOT_IMPLEMENTED;
1238 }
1239 
1240 /* Class 14 - Paged Pool Information */
1242 {
1243  /* FIXME */
1244  DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
1245  return STATUS_NOT_IMPLEMENTED;
1246 }
1247 
1248 /* Class 15 - Non Paged Pool Information */
1250 {
1251  /* FIXME */
1252  DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
1253  return STATUS_NOT_IMPLEMENTED;
1254 }
1255 
1256 
1257 /* Class 16 - Handle Information */
1259 {
1261  PLIST_ENTRY NextTableEntry;
1263  PHANDLE_TABLE_ENTRY HandleTableEntry;
1264  EXHANDLE Handle;
1265  ULONG Index = 0;
1266  NTSTATUS Status;
1267  PMDL Mdl;
1268  PAGED_CODE();
1269 
1270  DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
1271 
1272  /* Set initial required buffer size */
1273  *ReqSize = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION, Handles);
1274 
1275  /* Check user's buffer size */
1276  if (Size < *ReqSize)
1277  {
1279  }
1280 
1281  /* We need to lock down the memory */
1282  Status = ExLockUserBuffer(Buffer,
1283  Size,
1285  IoWriteAccess,
1286  (PVOID*)&HandleInformation,
1287  &Mdl);
1288  if (!NT_SUCCESS(Status))
1289  {
1290  DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
1291  return Status;
1292  }
1293 
1294  /* Reset of count of handles */
1295  HandleInformation->NumberOfHandles = 0;
1296 
1297  /* Enter a critical region */
1299 
1300  /* Acquire the handle table lock */
1301  ExAcquirePushLockShared(&HandleTableListLock);
1302 
1303  /* Enumerate all system handles */
1304  for (NextTableEntry = HandleTableListHead.Flink;
1305  NextTableEntry != &HandleTableListHead;
1306  NextTableEntry = NextTableEntry->Flink)
1307  {
1308  /* Get current handle table */
1309  HandleTable = CONTAINING_RECORD(NextTableEntry, HANDLE_TABLE, HandleTableList);
1310 
1311  /* Set the initial value and loop the entries */
1312  Handle.Value = 0;
1313  while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
1314  {
1315  /* Validate the entry */
1316  if ((HandleTableEntry->Object) &&
1317  (HandleTableEntry->NextFreeTableEntry != -2))
1318  {
1319  /* Increase of count of handles */
1320  ++HandleInformation->NumberOfHandles;
1321 
1322  /* Lock the entry */
1323  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1324  {
1325  /* Increase required buffer size */
1326  *ReqSize += sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO);
1327 
1328  /* Check user's buffer size */
1329  if (*ReqSize > Size)
1330  {
1331  Status = STATUS_INFO_LENGTH_MISMATCH;
1332  }
1333  else
1334  {
1335  POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
1336 
1337  /* Filling handle information */
1338  HandleInformation->Handles[Index].UniqueProcessId =
1339  (USHORT)(ULONG_PTR) HandleTable->UniqueProcessId;
1340 
1341  HandleInformation->Handles[Index].CreatorBackTraceIndex = 0;
1342 
1343 #if 0 /* FIXME!!! Type field currupted */
1344  HandleInformation->Handles[Index].ObjectTypeIndex =
1345  (UCHAR) ObjectHeader->Type->Index;
1346 #else
1347  HandleInformation->Handles[Index].ObjectTypeIndex = 0;
1348 #endif
1349 
1350  HandleInformation->Handles[Index].HandleAttributes =
1351  HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
1352 
1353  HandleInformation->Handles[Index].HandleValue =
1355 
1356  HandleInformation->Handles[Index].Object = &ObjectHeader->Body;
1357 
1358  HandleInformation->Handles[Index].GrantedAccess =
1359  HandleTableEntry->GrantedAccess;
1360 
1361  ++Index;
1362  }
1363 
1364  /* Unlock it */
1365  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1366  }
1367  }
1368 
1369  /* Go to the next entry */
1370  Handle.Value += sizeof(HANDLE);
1371  }
1372  }
1373 
1374  /* Release the lock */
1375  ExReleasePushLockShared(&HandleTableListLock);
1376 
1377  /* Leave the critical region */
1379 
1380  /* Release the locked user buffer */
1381  ExUnlockUserBuffer(Mdl);
1382 
1383  return Status;
1384 }
1385 
1386 /* Class 17 - Information */
1388 {
1389  /* FIXME */
1390  DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
1391  return STATUS_NOT_IMPLEMENTED;
1392 }
1393 
1394 /* Class 18 - Information */
1396 {
1397  UNICODE_STRING FileName; /* FIXME */
1399 
1400  if (Size < sizeof(SYSTEM_PAGEFILE_INFORMATION))
1401  {
1402  * ReqSize = sizeof(SYSTEM_PAGEFILE_INFORMATION);
1404  }
1405 
1406  RtlInitUnicodeString(&FileName, NULL); /* FIXME */
1407 
1408  /* FIXME */
1409  Spfi->NextEntryOffset = 0;
1410 
1412  Spfi->TotalInUse = MiUsedSwapPages;
1413  Spfi->PeakUsage = MiUsedSwapPages; /* FIXME */
1414  Spfi->PageFileName = FileName;
1415  return STATUS_SUCCESS;
1416 }
1417 
1418 /* Class 19 - Vdm Instemul Information */
1420 {
1421  /* FIXME */
1422  DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
1423  return STATUS_NOT_IMPLEMENTED;
1424 }
1425 
1426 /* Class 20 - Vdm Bop Information */
1428 {
1429  /* FIXME */
1430  DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
1431  return STATUS_NOT_IMPLEMENTED;
1432 }
1433 
1434 /* Class 21 - File Cache Information */
1436 {
1438 
1439  *ReqSize = sizeof(SYSTEM_FILECACHE_INFORMATION);
1440 
1441  if (Size < *ReqSize)
1442  {
1444  }
1445 
1447 
1448  /* Return the Byte size not the page size. */
1449  Sci->CurrentSize =
1451  Sci->PeakSize =
1453  /* Taskmgr multiplies this one by page size right away */
1455  MiMemoryConsumers[MC_CACHE].PagesUsed; /* FIXME: Should be */
1456  /* system working set and standby pages. */
1457  Sci->PageFaultCount = 0; /* FIXME */
1458  Sci->MinimumWorkingSet = 0; /* FIXME */
1459  Sci->MaximumWorkingSet = 0; /* FIXME */
1460 
1461  return STATUS_SUCCESS;
1462 }
1463 
1465 {
1466  if (Size < sizeof(SYSTEM_FILECACHE_INFORMATION))
1467  {
1469  }
1470  /* FIXME */
1471  DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
1472  return STATUS_NOT_IMPLEMENTED;
1473 }
1474 
1475 /* Class 22 - Pool Tag Information */
1477 {
1479  return ExGetPoolTagInfo(Buffer, Size, ReqSize);
1480 }
1481 
1482 /* Class 23 - Interrupt Information for all processors */
1484 {
1485  PKPRCB Prcb;
1486  LONG i;
1487  ULONG ti;
1489 
1491  {
1493  }
1494 
1495  ti = KeQueryTimeIncrement();
1496 
1497  for (i = 0; i < KeNumberProcessors; i++)
1498  {
1499  Prcb = KiProcessorBlock[i];
1501  sii->DpcCount = Prcb->DpcData[0].DpcCount;
1502  sii->DpcRate = Prcb->DpcRequestRate;
1503  sii->TimeIncrement = ti;
1504  sii->DpcBypassCount = 0;
1505  sii->ApcBypassCount = 0;
1506  sii++;
1507  }
1508 
1509  return STATUS_SUCCESS;
1510 }
1511 
1512 /* Class 24 - DPC Behaviour Information */
1514 {
1515  /* FIXME */
1516  DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
1517  return STATUS_NOT_IMPLEMENTED;
1518 }
1519 
1521 {
1522  /* FIXME */
1523  DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1524  return STATUS_NOT_IMPLEMENTED;
1525 }
1526 
1527 /* Class 25 - Full Memory Information */
1529 {
1530  PULONG Spi = (PULONG) Buffer;
1531 
1533 
1534  *ReqSize = sizeof(ULONG);
1535 
1536  if (sizeof(ULONG) != Size)
1537  {
1539  }
1540 
1541  DPRINT("SystemFullMemoryInformation\n");
1542 
1543  TheIdleProcess = PsIdleProcess;
1544 
1545  DPRINT("PID: %p, KernelTime: %u PFFree: %lu PFUsed: %lu\n",
1546  TheIdleProcess->UniqueProcessId,
1547  TheIdleProcess->Pcb.KernelTime,
1549  MiUsedSwapPages);
1550 
1552 
1553  return STATUS_SUCCESS;
1554 }
1555 
1556 /* Class 26 - Load Image */
1558 {
1561  PVOID ImageBase;
1562  PVOID SectionPointer;
1563  ULONG_PTR EntryPoint;
1564  NTSTATUS Status;
1565  ULONG DirSize;
1566  PIMAGE_NT_HEADERS NtHeader;
1567 
1568  /* Validate size */
1569  if (Size != sizeof(SYSTEM_GDI_DRIVER_INFORMATION))
1570  {
1571  /* Incorrect buffer length, fail */
1573  }
1574 
1575  /* Only kernel mode can call this function */
1577 
1578  /* Load the driver */
1579  ImageName = DriverInfo->DriverName;
1580  Status = MmLoadSystemImage(&ImageName,
1581  NULL,
1582  NULL,
1583  0,
1584  &SectionPointer,
1585  &ImageBase);
1586  if (!NT_SUCCESS(Status)) return Status;
1587 
1588  /* Return the export pointer */
1589  DriverInfo->ExportSectionPointer =
1590  RtlImageDirectoryEntryToData(ImageBase,
1591  TRUE,
1593  &DirSize);
1594 
1595  /* Get the entrypoint */
1596  NtHeader = RtlImageNtHeader(ImageBase);
1597  EntryPoint = NtHeader->OptionalHeader.AddressOfEntryPoint;
1598  EntryPoint += (ULONG_PTR)ImageBase;
1599 
1600  /* Save other data */
1601  DriverInfo->ImageAddress = ImageBase;
1602  DriverInfo->SectionPointer = SectionPointer;
1603  DriverInfo->EntryPoint = (PVOID)EntryPoint;
1604  DriverInfo->ImageLength = NtHeader->OptionalHeader.SizeOfImage;
1605 
1606  /* All is good */
1607  return STATUS_SUCCESS;
1608 }
1609 
1610 /* Class 27 - Unload Image */
1612 {
1613  PVOID *SectionPointer = Buffer;
1614 
1615  /* Validate size */
1616  if (Size != sizeof(PVOID))
1617  {
1618  /* Incorrect length, fail */
1620  }
1621 
1622  /* Only kernel mode can call this function */
1624 
1625  /* Unload the image */
1626  MmUnloadSystemImage(*SectionPointer);
1627  return STATUS_SUCCESS;
1628 }
1629 
1630 /* Class 28 - Time Adjustment Information */
1632 {
1635 
1636  /* Check if enough storage was provided */
1638  {
1639  * ReqSize = sizeof(SYSTEM_QUERY_TIME_ADJUST_INFORMATION);
1641  }
1642 
1643  /* Give time values to our caller */
1644  TimeInfo->TimeIncrement = KeMaximumIncrement;
1645  TimeInfo->TimeAdjustment = KeTimeAdjustment;
1646  TimeInfo->Enable = !KiTimeAdjustmentEnabled;
1647 
1648  return STATUS_SUCCESS;
1649 }
1650 
1652 {
1656 
1657  /* Check size of a buffer, it must match our expectations */
1660 
1661  /* Check who is calling */
1662  if (PreviousMode != KernelMode)
1663  {
1664  /* Check access rights */
1665  if (!SeSinglePrivilegeCheck(SeSystemtimePrivilege, PreviousMode))
1666  {
1668  }
1669  }
1670 
1671  /* FIXME: behaviour suggests the member be named 'Disable' */
1672  if (TimeInfo->Enable)
1673  {
1674  /* Disable time adjustment and set default value */
1677  }
1678  else
1679  {
1680  /* Check if a valid time adjustment value is given */
1681  if (TimeInfo->TimeAdjustment == 0) return STATUS_INVALID_PARAMETER_2;
1682 
1683  /* Enable time adjustment and set the adjustment value */
1685  KeTimeAdjustment = TimeInfo->TimeAdjustment;
1686  }
1687 
1688  return STATUS_SUCCESS;
1689 }
1690 
1691 /* Class 29 - Summary Memory Information */
1693 {
1694  /* FIXME */
1695  DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1696  return STATUS_NOT_IMPLEMENTED;
1697 }
1698 
1699 /* Class 30 - Next Event Id Information */
1701 {
1702  /* FIXME */
1703  DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1704  return STATUS_NOT_IMPLEMENTED;
1705 }
1706 
1707 /* Class 31 */
1709 {
1710  /* FIXME */
1711  DPRINT1("NtQuerySystemInformation - SystemPerformanceTraceInformation not implemented\n");
1712  return STATUS_NOT_IMPLEMENTED;
1713 }
1714 
1715 /* Class 32 - Crash Dump Information */
1717 {
1718  /* FIXME */
1719  DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1720  return STATUS_NOT_IMPLEMENTED;
1721 }
1722 
1723 /* Class 33 - Exception Information */
1725 {
1726  PSYSTEM_EXCEPTION_INFORMATION ExceptionInformation =
1728  PKPRCB Prcb;
1729  ULONG AlignmentFixupCount = 0, ExceptionDispatchCount = 0;
1730  ULONG FloatingEmulationCount = 0, ByteWordEmulationCount = 0;
1731  CHAR i;
1732 
1733  /* Check size of a buffer, it must match our expectations */
1734  if (sizeof(SYSTEM_EXCEPTION_INFORMATION) != Size)
1736 
1737  /* Sum up exception count information from all processors */
1738  for (i = 0; i < KeNumberProcessors; i++)
1739  {
1740  Prcb = KiProcessorBlock[i];
1741  if (Prcb)
1742  {
1743  AlignmentFixupCount += Prcb->KeAlignmentFixupCount;
1744  ExceptionDispatchCount += Prcb->KeExceptionDispatchCount;
1745 #ifndef _M_ARM
1746  FloatingEmulationCount += Prcb->KeFloatingEmulationCount;
1747 #endif // _M_ARM
1748  }
1749  }
1750 
1751  /* Save information in user's buffer */
1752  ExceptionInformation->AlignmentFixupCount = AlignmentFixupCount;
1753  ExceptionInformation->ExceptionDispatchCount = ExceptionDispatchCount;
1754  ExceptionInformation->FloatingEmulationCount = FloatingEmulationCount;
1755  ExceptionInformation->ByteWordEmulationCount = ByteWordEmulationCount;
1756 
1757  return STATUS_SUCCESS;
1758 }
1759 
1760 /* Class 34 - Crash Dump State Information */
1762 {
1763  /* FIXME */
1764  DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1765  return STATUS_NOT_IMPLEMENTED;
1766 }
1767 
1768 /* Class 35 - Kernel Debugger Information */
1770 {
1772 
1773 #if (NTDDI_VERSION >= NTDDI_VISTA)
1774  *ReqSize = sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION);
1775 #endif
1776 
1778  {
1780  }
1781 
1784 
1785 #if (NTDDI_VERSION < NTDDI_VISTA)
1786  *ReqSize = sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION);
1787 #endif
1788 
1789  return STATUS_SUCCESS;
1790 }
1791 
1792 /* Class 36 - Context Switch Information */
1794 {
1795  PSYSTEM_CONTEXT_SWITCH_INFORMATION ContextSwitchInformation =
1797  ULONG ContextSwitches;
1798  PKPRCB Prcb;
1799  CHAR i;
1800 
1801  /* Check size of a buffer, it must match our expectations */
1802  if (sizeof(SYSTEM_CONTEXT_SWITCH_INFORMATION) != Size)
1804 
1805  /* Calculate total value of context switches across all processors */
1806  ContextSwitches = 0;
1807  for (i = 0; i < KeNumberProcessors; i ++)
1808  {
1809  Prcb = KiProcessorBlock[i];
1810  if (Prcb)
1811  {
1812  ContextSwitches += KeGetContextSwitches(Prcb);
1813  }
1814  }
1815 
1816  ContextSwitchInformation->ContextSwitches = ContextSwitches;
1817 
1818  /* FIXME */
1819  ContextSwitchInformation->FindAny = 0;
1820  ContextSwitchInformation->FindLast = 0;
1821  ContextSwitchInformation->FindIdeal = 0;
1822  ContextSwitchInformation->IdleAny = 0;
1823  ContextSwitchInformation->IdleCurrent = 0;
1824  ContextSwitchInformation->IdleLast = 0;
1825  ContextSwitchInformation->IdleIdeal = 0;
1826  ContextSwitchInformation->PreemptAny = 0;
1827  ContextSwitchInformation->PreemptCurrent = 0;
1828  ContextSwitchInformation->PreemptLast = 0;
1829  ContextSwitchInformation->SwitchToIdle = 0;
1830 
1831  return STATUS_SUCCESS;
1832 }
1833 
1834 /* Class 37 - Registry Quota Information */
1836 {
1838 
1839  *ReqSize = sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION);
1841  {
1843  }
1844 
1845  DPRINT1("Faking max registry size of 32 MB\n");
1846  srqi->RegistryQuotaAllowed = 0x2000000;
1847  srqi->RegistryQuotaUsed = 0x200000;
1848  srqi->PagedPoolSize = 0x200000;
1849 
1850  return STATUS_SUCCESS;
1851 }
1852 
1854 {
1855  /* FIXME */
1856  DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1857  return STATUS_NOT_IMPLEMENTED;
1858 }
1859 
1860 /* Class 38 - Load And Call Image */
1862 {
1865  PLDR_DATA_TABLE_ENTRY ModuleObject;
1866  NTSTATUS Status;
1867  PIMAGE_NT_HEADERS NtHeader;
1868  DRIVER_OBJECT Win32k;
1869  PDRIVER_INITIALIZE DriverInit;
1870  PVOID ImageBase;
1871  ULONG_PTR EntryPoint;
1872 
1873  /* Validate the size */
1874  if (Size != sizeof(UNICODE_STRING)) return STATUS_INFO_LENGTH_MISMATCH;
1875 
1876  /* Check who is calling */
1877  if (PreviousMode != KernelMode)
1878  {
1879  static const UNICODE_STRING Win32kName =
1880  RTL_CONSTANT_STRING(L"\\SystemRoot\\System32\\win32k.sys");
1881 
1882  /* Make sure we can load drivers */
1884  {
1885  /* FIXME: We can't, fail */
1887  }
1888 
1889  _SEH2_TRY
1890  {
1891  /* Probe and copy the unicode string */
1892  ProbeForRead(Buffer, sizeof(ImageName), 1);
1893  ImageName = *(PUNICODE_STRING)Buffer;
1894 
1895  /* Probe the string buffer */
1896  ProbeForRead(ImageName.Buffer, ImageName.Length, sizeof(WCHAR));
1897 
1898  /* Check if we have the correct name (nothing else is allowed!) */
1899  if (!RtlEqualUnicodeString(&ImageName, &Win32kName, FALSE))
1900  {
1902  }
1903  }
1905  {
1907  }
1908  _SEH2_END;
1909 
1910  /* Recursively call the function, so that we are from kernel mode */
1912  (PVOID)&Win32kName,
1913  sizeof(Win32kName));
1914  }
1915 
1916  /* Load the image */
1918  NULL,
1919  NULL,
1920  0,
1921  (PVOID)&ModuleObject,
1922  &ImageBase);
1923 
1924  if (!NT_SUCCESS(Status)) return Status;
1925 
1926  /* Get the headers */
1927  NtHeader = RtlImageNtHeader(ImageBase);
1928  if (!NtHeader)
1929  {
1930  /* Fail */
1931  MmUnloadSystemImage(ModuleObject);
1933  }
1934 
1935  /* Get the entrypoint */
1936  EntryPoint = NtHeader->OptionalHeader.AddressOfEntryPoint;
1937  EntryPoint += (ULONG_PTR)ImageBase;
1938  DriverInit = (PDRIVER_INITIALIZE)EntryPoint;
1939 
1940  /* Create a dummy device */
1941  RtlZeroMemory(&Win32k, sizeof(Win32k));
1943  Win32k.DriverStart = ImageBase;
1944 
1945  /* Call it */
1946  Status = (DriverInit)(&Win32k, NULL);
1948 
1949  /* Unload if we failed */
1950  if (!NT_SUCCESS(Status)) MmUnloadSystemImage(ModuleObject);
1951  return Status;
1952 }
1953 
1954 /* Class 39 - Priority Separation */
1956 {
1957  /* Check if the size is correct */
1958  if (Size != sizeof(ULONG))
1959  {
1961  }
1962 
1963  /* We need the TCB privilege */
1965  {
1967  }
1968 
1969  /* Modify the quantum table */
1971 
1972  return STATUS_SUCCESS;
1973 }
1974 
1975 /* Class 40 */
1976 QSI_DEF(SystemVerifierAddDriverInformation)
1977 {
1978  /* FIXME */
1979  DPRINT1("NtQuerySystemInformation - SystemVerifierAddDriverInformation not implemented\n");
1980  return STATUS_NOT_IMPLEMENTED;
1981 }
1982 
1983 /* Class 41 */
1984 QSI_DEF(SystemVerifierRemoveDriverInformation)
1985 {
1986  /* FIXME */
1987  DPRINT1("NtQuerySystemInformation - SystemVerifierRemoveDriverInformation not implemented\n");
1988  return STATUS_NOT_IMPLEMENTED;
1989 }
1990 
1991 /* Class 42 - Power Information */
1992 QSI_DEF(SystemProcessorIdleInformation)
1993 {
1994  *ReqSize = sizeof(PROCESSOR_POWER_INFORMATION) * KeNumberProcessors;
1995 
1997  {
1999  }
2000 
2001  /* FIXME */
2002  DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
2003  return STATUS_NOT_IMPLEMENTED;
2004 }
2005 
2006 /* Class 43 */
2007 QSI_DEF(SystemLegacyDriverInformation)
2008 {
2009  /* FIXME */
2010  DPRINT1("NtQuerySystemInformation - SystemLegacyDriverInformation not implemented\n");
2011  return STATUS_NOT_IMPLEMENTED;
2012 }
2013 
2014 /* Class 44 - Current Time Zone Information */
2016 {
2017  *ReqSize = sizeof(RTL_TIME_ZONE_INFORMATION);
2018 
2019  if (sizeof(RTL_TIME_ZONE_INFORMATION) != Size)
2020  {
2022  }
2023 
2024  /* Copy the time zone information struct */
2025  memcpy(Buffer,
2026  &ExpTimeZoneInfo,
2027  sizeof(RTL_TIME_ZONE_INFORMATION));
2028 
2029  return STATUS_SUCCESS;
2030 }
2031 
2032 
2034 {
2035  /* Check user buffer's size */
2036  if (Size < sizeof(RTL_TIME_ZONE_INFORMATION))
2037  {
2039  }
2040 
2042 }
2043 
2044 static
2045 VOID
2047  PSYSTEM_LOOKASIDE_INFORMATION *InfoPointer,
2048  PULONG RemainingPointer,
2049  PLIST_ENTRY ListHead,
2050  BOOLEAN ListUsesMisses)
2051 
2052 {
2055  PLIST_ENTRY ListEntry;
2056  ULONG Remaining;
2057 
2058  /* Get info pointer and remaining count of free array element */
2059  Info = *InfoPointer;
2060  Remaining = *RemainingPointer;
2061 
2062  /* Loop as long as we have lookaside lists and free array elements */
2063  for (ListEntry = ListHead->Flink;
2064  (ListEntry != ListHead) && (Remaining > 0);
2065  ListEntry = ListEntry->Flink, Remaining--)
2066  {
2067  LookasideList = CONTAINING_RECORD(ListEntry, GENERAL_LOOKASIDE, ListEntry);
2068 
2069  /* Fill the next array element */
2070  Info->CurrentDepth = LookasideList->Depth;
2071  Info->MaximumDepth = LookasideList->MaximumDepth;
2072  Info->TotalAllocates = LookasideList->TotalAllocates;
2073  Info->TotalFrees = LookasideList->TotalFrees;
2074  Info->Type = LookasideList->Type;
2075  Info->Tag = LookasideList->Tag;
2076  Info->Size = LookasideList->Size;
2077 
2078  /* Check how the lists track misses/hits */
2079  if (ListUsesMisses)
2080  {
2081  /* Copy misses */
2082  Info->AllocateMisses = LookasideList->AllocateMisses;
2083  Info->FreeMisses = LookasideList->FreeMisses;
2084  }
2085  else
2086  {
2087  /* Calculate misses */
2088  Info->AllocateMisses = LookasideList->TotalAllocates
2089  - LookasideList->AllocateHits;
2090  Info->FreeMisses = LookasideList->TotalFrees
2091  - LookasideList->FreeHits;
2092  }
2093  }
2094 
2095  /* Return the updated pointer and remaining count */
2096  *InfoPointer = Info;
2097  *RemainingPointer = Remaining;
2098 }
2099 
2100 /* Class 45 - Lookaside Information */
2102 {
2105  PMDL Mdl;
2106  ULONG MaxCount, Remaining;
2107  KIRQL OldIrql;
2108  NTSTATUS Status;
2109 
2110  /* First we need to lock down the memory, since we are going to access it
2111  at high IRQL */
2112  PreviousMode = ExGetPreviousMode();
2113  Status = ExLockUserBuffer(Buffer,
2114  Size,
2115  PreviousMode,
2116  IoWriteAccess,
2117  (PVOID*)&Info,
2118  &Mdl);
2119  if (!NT_SUCCESS(Status))
2120  {
2121  DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
2122  return Status;
2123  }
2124 
2125  /* Calculate how many items we can store */
2126  Remaining = MaxCount = Size / sizeof(SYSTEM_LOOKASIDE_INFORMATION);
2127  if (Remaining == 0)
2128  {
2129  goto Leave;
2130  }
2131 
2132  /* Copy info from pool lookaside lists */
2134  &Remaining,
2136  FALSE);
2137  if (Remaining == 0)
2138  {
2139  goto Leave;
2140  }
2141 
2142  /* Copy info from system lookaside lists */
2144  &Remaining,
2146  TRUE);
2147  if (Remaining == 0)
2148  {
2149  goto Leave;
2150  }
2151 
2152  /* Acquire spinlock for ExpNonPagedLookasideListHead */
2154 
2155  /* Copy info from non-paged lookaside lists */
2157  &Remaining,
2159  TRUE);
2160 
2161  /* Release spinlock for ExpNonPagedLookasideListHead */
2163 
2164  if (Remaining == 0)
2165  {
2166  goto Leave;
2167  }
2168 
2169  /* Acquire spinlock for ExpPagedLookasideListHead */
2171 
2172  /* Copy info from paged lookaside lists */
2174  &Remaining,
2176  TRUE);
2177 
2178  /* Release spinlock for ExpPagedLookasideListHead */
2180 
2181 Leave:
2182 
2183  /* Release the locked user buffer */
2184  ExUnlockUserBuffer(Mdl);
2185 
2186  /* Return the size of the actually written data */
2187  *ReqSize = (MaxCount - Remaining) * sizeof(SYSTEM_LOOKASIDE_INFORMATION);
2188  return STATUS_SUCCESS;
2189 }
2190 
2191 
2192 /* Class 46 - Set time slip event */
2194 {
2195  /* FIXME */
2196  DPRINT1("NtSetSystemInformation - SystemTimeSlipNotification not implemented\n");
2197  return STATUS_NOT_IMPLEMENTED;
2198 }
2199 
2200 NTSTATUS
2201 NTAPI
2203 
2204 NTSTATUS
2205 NTAPI
2207 
2208 /* Class 47 - Create a new session (TSE) */
2210 {
2211  ULONG SessionId;
2213  NTSTATUS Status;
2214 
2215  if (Size != sizeof(ULONG)) return STATUS_INFO_LENGTH_MISMATCH;
2216 
2217  if (PreviousMode != KernelMode)
2218  {
2219  if (!SeSinglePrivilegeCheck(SeLoadDriverPrivilege, PreviousMode))
2220  {
2222  }
2223 
2225  }
2226 
2227  Status = MmSessionCreate(&SessionId);
2228  if (NT_SUCCESS(Status)) *(PULONG)Buffer = SessionId;
2229 
2230  return Status;
2231 }
2232 
2233 
2234 /* Class 48 - Delete an existing session (TSE) */
2236 {
2237  ULONG SessionId;
2239 
2240  if (Size != sizeof(ULONG)) return STATUS_INFO_LENGTH_MISMATCH;
2241 
2242  if (PreviousMode != KernelMode)
2243  {
2244  if (!SeSinglePrivilegeCheck(SeLoadDriverPrivilege, PreviousMode))
2245  {
2247  }
2248  }
2249 
2250  SessionId = *(PULONG)Buffer;
2251 
2252  return MmSessionDelete(SessionId);
2253 }
2254 
2255 
2256 /* Class 49 - UNKNOWN */
2258 {
2259  /* FIXME */
2260  DPRINT1("NtQuerySystemInformation - SystemSessionInformation not implemented\n");
2261  return STATUS_NOT_IMPLEMENTED;
2262 }
2263 
2264 
2265 /* Class 50 - System range start address */
2267 {
2268  /* Check user buffer's size */
2269  if (Size != sizeof(ULONG_PTR)) return STATUS_INFO_LENGTH_MISMATCH;
2270 
2272 
2273  if (ReqSize) *ReqSize = sizeof(ULONG_PTR);
2274 
2275  return STATUS_SUCCESS;
2276 }
2277 
2278 /* Class 51 - Driver verifier information */
2280 {
2281  /* FIXME */
2282  DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
2283  return STATUS_NOT_IMPLEMENTED;
2284 }
2285 
2286 
2288 {
2289  /* FIXME */
2290  DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
2291  return STATUS_NOT_IMPLEMENTED;
2292 }
2293 
2294 
2295 /* Class 52 */
2296 SSI_DEF(SystemVerifierThunkExtend)
2297 {
2298  /* FIXME */
2299  DPRINT1("NtSetSystemInformation - SystemVerifierThunkExtend not implemented\n");
2300  return STATUS_NOT_IMPLEMENTED;
2301 }
2302 
2303 
2304 /* Class 53 - A session's processes */
2306 {
2307  /* FIXME */
2308  DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
2309  return STATUS_NOT_IMPLEMENTED;
2310 }
2311 
2312 
2313 /* Class 54 - Load & map in system space */
2315 {
2316  /* FIXME */
2317  DPRINT1("NtSetSystemInformation - SystemLoadGdiDriverInSystemSpaceInformation not implemented\n");
2318  return STATUS_NOT_IMPLEMENTED;
2319 }
2320 
2321 
2322 /* Class 55 - NUMA processor information */
2324 {
2325  ULONG MaxEntries, Node;
2327 
2328  /* Validate input size */
2329  if (Size < sizeof(ULONG))
2330  {
2332  }
2333 
2334  /* Return highest node */
2335  NumaInformation->HighestNodeNumber = KeNumberNodes - 1;
2336 
2337  /* Compute how much entries we will be able to put in output structure */
2338  MaxEntries = (Size - FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask)) / sizeof(ULONGLONG);
2339  /* Make sure we don't overflow KeNodeBlock */
2340  if (MaxEntries > KeNumberNodes)
2341  {
2342  MaxEntries = KeNumberNodes;
2343  }
2344 
2345  /* If we have entries to write, and room for it */
2346  if (Size >= FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask) &&
2347  MaxEntries != 0)
2348  {
2349  /* Already set size we return */
2350  *ReqSize = FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask) +
2351  MaxEntries * sizeof(ULONGLONG);
2352 
2353  /* For each node, return processor mask */
2354  for (Node = 0; Node < MaxEntries; ++Node)
2355  {
2357  }
2358  }
2359  else
2360  {
2361  /* We only returned highest node number */
2362  *ReqSize = sizeof(ULONG);
2363  }
2364 
2365  return STATUS_SUCCESS;
2366 }
2367 
2368 
2369 /* Class 56 - Prefetcher information */
2371 {
2372  /* FIXME */
2373  DPRINT1("NtQuerySystemInformation - SystemPrefetcherInformation not implemented\n");
2374  return STATUS_NOT_IMPLEMENTED;
2375 }
2376 
2377 
2378 /* Class 57 - Extended process information */
2380 {
2381  /* FIXME */
2382  DPRINT1("NtQuerySystemInformation - SystemExtendedProcessInformation not implemented\n");
2383  return STATUS_NOT_IMPLEMENTED;
2384 }
2385 
2386 
2387 /* Class 58 - Recommended shared ata alignment */
2389 {
2390  /* FIXME */
2391  DPRINT1("NtQuerySystemInformation - SystemRecommendedSharedDataAlignment not implemented\n");
2392  return STATUS_NOT_IMPLEMENTED;
2393 }
2394 
2395 
2396 /* Class 60 - NUMA memory information */
2398 {
2399  ULONG MaxEntries, Node;
2401 
2402  /* Validate input size */
2403  if (Size < sizeof(ULONG))
2404  {
2406  }
2407 
2408  /* Return highest node */
2409  NumaInformation->HighestNodeNumber = KeNumberNodes - 1;
2410 
2411  /* Compute how much entries we will be able to put in output structure */
2412  MaxEntries = (Size - FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory)) / sizeof(ULONGLONG);
2413  /* Make sure we don't overflow KeNodeBlock */
2414  if (MaxEntries > KeNumberNodes)
2415  {
2416  MaxEntries = KeNumberNodes;
2417  }
2418 
2419  /* If we have entries to write, and room for it */
2420  if (Size >= FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory) &&
2421  MaxEntries != 0)
2422  {
2423  /* Already set size we return */
2424  *ReqSize = FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory) +
2425  MaxEntries * sizeof(ULONGLONG);
2426 
2427  /* If we have a single entry (us), directly return MM information */
2428  if (MaxEntries == 1)
2429  {
2430  NumaInformation->AvailableMemory[0] = MmAvailablePages << PAGE_SHIFT;
2431  }
2432  else
2433  {
2434  /* Otherwise, for each node, return available bytes */
2435  for (Node = 0; Node < MaxEntries; ++Node)
2436  {
2437  NumaInformation->AvailableMemory[Node] = (KeNodeBlock[Node]->FreeCount[0] + KeNodeBlock[Node]->FreeCount[1]) << PAGE_SHIFT;
2438  }
2439  }
2440  }
2441  else
2442  {
2443  /* We only returned highest node number */
2444  *ReqSize = sizeof(ULONG);
2445  }
2446 
2447  return STATUS_SUCCESS;
2448 }
2449 
2450 /* Class 64 - Extended handle information */
2452 {
2454  PLIST_ENTRY NextTableEntry;
2456  PHANDLE_TABLE_ENTRY HandleTableEntry;
2457  EXHANDLE Handle;
2458  ULONG Index = 0;
2459  NTSTATUS Status;
2460  PMDL Mdl;
2461  PAGED_CODE();
2462 
2463  DPRINT("NtQuerySystemInformation - SystemExtendedHandleInformation\n");
2464 
2465  /* Set initial required buffer size */
2466  *ReqSize = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION_EX, Handle);
2467 
2468  /* Check user's buffer size */
2469  if (Size < *ReqSize)
2470  {
2472  }
2473 
2474  /* We need to lock down the memory */
2475  Status = ExLockUserBuffer(Buffer,
2476  Size,
2478  IoWriteAccess,
2479  (PVOID*)&HandleInformation,
2480  &Mdl);
2481  if (!NT_SUCCESS(Status))
2482  {
2483  DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
2484  return Status;
2485  }
2486 
2487  /* Reset of count of handles */
2488  HandleInformation->Count = 0;
2489 
2490  /* Enter a critical region */
2492 
2493  /* Acquire the handle table lock */
2494  ExAcquirePushLockShared(&HandleTableListLock);
2495 
2496  /* Enumerate all system handles */
2497  for (NextTableEntry = HandleTableListHead.Flink;
2498  NextTableEntry != &HandleTableListHead;
2499  NextTableEntry = NextTableEntry->Flink)
2500  {
2501  /* Get current handle table */
2502  HandleTable = CONTAINING_RECORD(NextTableEntry, HANDLE_TABLE, HandleTableList);
2503 
2504  /* Set the initial value and loop the entries */
2505  Handle.Value = 0;
2506  while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
2507  {
2508  /* Validate the entry */
2509  if ((HandleTableEntry->Object) &&
2510  (HandleTableEntry->NextFreeTableEntry != -2))
2511  {
2512  /* Increase of count of handles */
2513  ++HandleInformation->Count;
2514 
2515  /* Lock the entry */
2516  if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
2517  {
2518  /* Increase required buffer size */
2519  *ReqSize += sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX);
2520 
2521  /* Check user's buffer size */
2522  if (*ReqSize > Size)
2523  {
2524  Status = STATUS_INFO_LENGTH_MISMATCH;
2525  }
2526  else
2527  {
2528  POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
2529 
2530  /* Filling handle information */
2531  HandleInformation->Handle[Index].UniqueProcessId =
2532  (USHORT)(ULONG_PTR) HandleTable->UniqueProcessId;
2533 
2534  HandleInformation->Handle[Index].CreatorBackTraceIndex = 0;
2535 
2536 #if 0 /* FIXME!!! Type field currupted */
2537  HandleInformation->Handles[Index].ObjectTypeIndex =
2538  (UCHAR) ObjectHeader->Type->Index;
2539 #else
2540  HandleInformation->Handle[Index].ObjectTypeIndex = 0;
2541 #endif
2542 
2543  HandleInformation->Handle[Index].HandleAttributes =
2544  HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
2545 
2546  HandleInformation->Handle[Index].HandleValue =
2548 
2549  HandleInformation->Handle[Index].Object = &ObjectHeader->Body;
2550 
2551  HandleInformation->Handle[Index].GrantedAccess =
2552  HandleTableEntry->GrantedAccess;
2553 
2554  HandleInformation->Handle[Index].Reserved = 0;
2555 
2556  ++Index;
2557  }
2558 
2559  /* Unlock it */
2560  ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
2561  }
2562  }
2563 
2564  /* Go to the next entry */
2565  Handle.Value += sizeof(HANDLE);
2566  }
2567  }
2568 
2569  /* Release the lock */
2570  ExReleasePushLockShared(&HandleTableListLock);
2571 
2572  /* Leave the critical region */
2574 
2575  /* Release the locked user buffer */
2576  ExUnlockUserBuffer(Mdl);
2577 
2578  return Status;
2579 }
2580 
2581 /* Class 76 - System firmware table information */
2583 {
2586  ULONG InputBufSize;
2587  ULONG DataSize = 0;
2588  ULONG TableCount = 0;
2589 
2590  DPRINT("NtQuerySystemInformation - SystemFirmwareTableInformation\n");
2591 
2592  /* Set initial required buffer size */
2593  *ReqSize = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
2594 
2595  /* Check user's buffer size */
2596  if (Size < *ReqSize)
2597  {
2599  }
2600 
2601  InputBufSize = SysFirmwareInfo->TableBufferLength;
2602  switch (SysFirmwareInfo->ProviderSignature)
2603  {
2604  /*
2605  * ExpFirmwareTableResource and ExpFirmwareTableProviderListHead
2606  * variables should be used there somehow...
2607  */
2608  case SIG_ACPI:
2609  {
2610  /* FIXME: Not implemented yet */
2611  DPRINT1("ACPI provider not implemented\n");
2612  Status = STATUS_NOT_IMPLEMENTED;
2613  break;
2614  }
2615  case SIG_FIRM:
2616  {
2617  /* FIXME: Not implemented yet */
2618  DPRINT1("FIRM provider not implemented\n");
2619  Status = STATUS_NOT_IMPLEMENTED;
2620  break;
2621  }
2622  case SIG_RSMB:
2623  {
2624  Status = ExpGetRawSMBiosTable(NULL, &DataSize, 0);
2625  if (DataSize > 0)
2626  {
2627  TableCount = 1;
2628  if (SysFirmwareInfo->Action == SystemFirmwareTable_Enumerate)
2629  {
2630  DataSize = TableCount * sizeof(ULONG);
2631  if (DataSize <= InputBufSize)
2632  {
2633  *(ULONG *)SysFirmwareInfo->TableBuffer = 0;
2634  }
2635  }
2636  else if (SysFirmwareInfo->Action == SystemFirmwareTable_Get
2637  && DataSize <= InputBufSize)
2638  {
2639  Status = ExpGetRawSMBiosTable(SysFirmwareInfo->TableBuffer, &DataSize, InputBufSize);
2640  }
2641  SysFirmwareInfo->TableBufferLength = DataSize;
2642  }
2643  break;
2644  }
2645  default:
2646  {
2647  DPRINT1("SystemFirmwareTableInformation: Unsupported provider (0x%x)\n",
2648  SysFirmwareInfo->ProviderSignature);
2649  Status = STATUS_ILLEGAL_FUNCTION;
2650  }
2651  }
2652 
2653  if (NT_SUCCESS(Status))
2654  {
2655  switch (SysFirmwareInfo->Action)
2656  {
2659  {
2660  if (SysFirmwareInfo->TableBufferLength > InputBufSize)
2661  {
2662  Status = STATUS_BUFFER_TOO_SMALL;
2663  }
2664  break;
2665  }
2666  default:
2667  {
2668  DPRINT1("SystemFirmwareTableInformation: Unsupported action (0x%x)\n",
2669  SysFirmwareInfo->Action);
2670  Status = STATUS_ILLEGAL_FUNCTION;
2671  }
2672  }
2673  }
2674  else
2675  {
2676  SysFirmwareInfo->TableBufferLength = 0;
2677  }
2678  return Status;
2679 }
2680 
2681 /* Query/Set Calls Table */
2682 typedef
2683 struct _QSSI_CALLS
2684 {
2687 } QSSI_CALLS;
2688 
2689 // QS Query & Set
2690 // QX Query
2691 // XS Set
2692 // XX unknown behaviour
2693 //
2694 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
2695 #define SI_QX(n) {QSI_USE(n),NULL}
2696 #define SI_XS(n) {NULL,SSI_USE(n)}
2697 #define SI_XX(n) {NULL,NULL}
2698 
2699 static
2700 QSSI_CALLS
2702 {
2707  SI_QX(SystemPathInformation), /* should be SI_XX */
2713  SI_QX(SystemCallTimeInformation), /* should be SI_XX */
2716  SI_QX(SystemStackTraceInformation), /* should be SI_XX */
2717  SI_QX(SystemPagedPoolInformation), /* should be SI_XX */
2718  SI_QX(SystemNonPagedPoolInformation), /* should be SI_XX */
2723  SI_QX(SystemVdmBopInformation), /* it should be SI_XX */
2728  SI_QX(SystemFullMemoryInformation), /* it should be SI_XX */
2732  SI_QX(SystemSummaryMemoryInformation), /* it should be SI_XX */
2733  SI_QX(SystemNextEventIdInformation), /* it should be SI_XX */
2734  SI_QX(SystemPerformanceTraceInformation), /* it should be SI_XX */
2743  SI_QX(SystemVerifierAddDriverInformation), /* it should be SI_XX */
2744  SI_QX(SystemVerifierRemoveDriverInformation), /* it should be SI_XX */
2745  SI_QX(SystemProcessorIdleInformation), /* it should be SI_XX */
2746  SI_QX(SystemLegacyDriverInformation), /* it should be SI_XX */
2747  SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */
2752  SI_QX(SystemSessionInformation), /* it should be SI_XX */
2755  SI_XS(SystemVerifierThunkExtend),
2764  SI_XX(SystemProcessorPowerInformation), /* FIXME: not implemented */
2765  SI_XX(SystemEmulationBasicInformation), /* FIXME: not implemented */
2766  SI_XX(SystemEmulationProcessorInformation), /* FIXME: not implemented */
2768  SI_XX(SystemLostDelayedWriteInformation), /* FIXME: not implemented */
2769  SI_XX(SystemBigPoolInformation), /* FIXME: not implemented */
2770  SI_XX(SystemSessionPoolTagInformation), /* FIXME: not implemented */
2771  SI_XX(SystemSessionMappedViewInformation), /* FIXME: not implemented */
2772  SI_XX(SystemHotpatchInformation), /* FIXME: not implemented */
2773  SI_XX(SystemObjectSecurityMode), /* FIXME: not implemented */
2774  SI_XX(SystemWatchdogTimerHandler), /* FIXME: not implemented */
2775  SI_XX(SystemWatchdogTimerInformation), /* FIXME: not implemented */
2776  SI_XX(SystemLogicalProcessorInformation), /* FIXME: not implemented */
2777  SI_XX(SystemWow64SharedInformation), /* FIXME: not implemented */
2778  SI_XX(SystemRegisterFirmwareTableInformationHandler), /* FIXME: not implemented */
2780 };
2781 
2783 #define MIN_SYSTEM_INFO_CLASS (SystemBasicInformation)
2784 #define MAX_SYSTEM_INFO_CLASS (sizeof(CallQS) / sizeof(CallQS[0]))
2785 
2786 /*
2787  * @implemented
2788  */
2790 NTSTATUS
2791 NTAPI
2793  _In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
2794  _Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID SystemInformation,
2795  _In_ ULONG Length,
2796  _Out_opt_ PULONG UnsafeResultLength)
2797 {
2799  ULONG ResultLength = 0;
2801  NTSTATUS FStatus = STATUS_NOT_IMPLEMENTED;
2802 
2803  PAGED_CODE();
2804 
2805  PreviousMode = ExGetPreviousMode();
2806 
2807  _SEH2_TRY
2808  {
2809 #if (NTDDI_VERSION >= NTDDI_VISTA)
2810  /*
2811  * Check if the request is valid.
2812  */
2813  if (SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
2814  {
2816  }
2817 #endif
2818 
2819  if (PreviousMode != KernelMode)
2820  {
2821  /* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
2822  if (SystemInformationClass == SystemKernelDebuggerInformation)
2823  Alignment = TYPE_ALIGNMENT(BOOLEAN);
2824 
2825  ProbeForWrite(SystemInformation, Length, Alignment);
2826  if (UnsafeResultLength != NULL)
2827  ProbeForWriteUlong(UnsafeResultLength);
2828  }
2829 
2830  if (UnsafeResultLength)
2831  *UnsafeResultLength = 0;
2832 
2833 #if (NTDDI_VERSION < NTDDI_VISTA)
2834  /*
2835  * Check if the request is valid.
2836  */
2837  if (SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
2838  {
2840  }
2841 #endif
2842 
2843  if (NULL != CallQS [SystemInformationClass].Query)
2844  {
2845  /*
2846  * Hand the request to a subhandler.
2847  */
2848  FStatus = CallQS [SystemInformationClass].Query(SystemInformation,
2849  Length,
2850  &ResultLength);
2851 
2852  /* Save the result length to the caller */
2853  if (UnsafeResultLength)
2854  *UnsafeResultLength = ResultLength;
2855  }
2856  }
2858  {
2859  FStatus = _SEH2_GetExceptionCode();
2860  }
2861  _SEH2_END;
2862 
2863  return FStatus;
2864 }
2865 
2866 
2867 NTSTATUS
2868 NTAPI
2870  IN PVOID SystemInformation,
2871  IN ULONG SystemInformationLength)
2872 {
2875 
2876  PAGED_CODE();
2877 
2878  PreviousMode = ExGetPreviousMode();
2879 
2880  _SEH2_TRY
2881  {
2882  /*
2883  * If called from user mode, check
2884  * possible unsafe arguments.
2885  */
2886  if (PreviousMode != KernelMode)
2887  {
2888  ProbeForRead(SystemInformation, SystemInformationLength, sizeof(ULONG));
2889  }
2890 
2891  /*
2892  * Check the request is valid.
2893  */
2894  if ((SystemInformationClass >= MIN_SYSTEM_INFO_CLASS) &&
2895  (SystemInformationClass < MAX_SYSTEM_INFO_CLASS))
2896  {
2897  if (NULL != CallQS [SystemInformationClass].Set)
2898  {
2899  /*
2900  * Hand the request to a subhandler.
2901  */
2902  Status = CallQS [SystemInformationClass].Set(SystemInformation,
2903  SystemInformationLength);
2904  }
2905  }
2906  }
2908  {
2909  Status = _SEH2_GetExceptionCode();
2910  }
2911  _SEH2_END;
2912 
2913  return Status;
2914 }
2915 
2916 ULONG
2917 NTAPI
2919 {
2920  /* Just use Ke */
2921  return KeGetCurrentProcessorNumber();
2922 }
2923 
2924 #undef ExGetPreviousMode
2926 NTAPI
2928 {
2929  /* Just use Ke */
2930  return KeGetPreviousMode();
2931 }
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
enum _SYSTEM_INFORMATION_CLASS SYSTEM_INFORMATION_CLASS
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
DWORD *typedef PVOID
Definition: winlogon.h:61
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
ULONG CcLazyWriteIos
Definition: lazywrite.c:21
const LUID SeSystemEnvironmentPrivilege
Definition: priv.c:43
signed char * PCHAR
Definition: retypes.h:7
ULONG HandleAttributes
Definition: extypes.h:1412
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1269
ULONGLONG AvailableMemory[MAXIMUM_NUMA_NODES]
Definition: extypes.h:1397
ULONG KeMaximumIncrement
Definition: clock.c:20
NTSTATUS NTAPI MmSessionCreate(OUT PULONG SessionId)
Definition: session.c:822
#define QSI_DEF(n)
Definition: sysinfo.c:596
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:39
NTSTATUS NTAPI ExpQueryModuleInformation(IN PLIST_ENTRY KernelModeList, IN PLIST_ENTRY UserModeList, OUT PRTL_PROCESS_MODULES Modules, IN ULONG Length, OUT PULONG ReturnLength)
Definition: sysinfo.c:91
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
PVOID Object
Definition: extypes.h:1406
#define IN
Definition: typedefs.h:38
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:37
#define MM_VIRTMEM_GRANULARITY
Definition: mm.h:78
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
ERESOURCE ExpFirmwareTableResource
Definition: sysinfo.c:30
struct _SYSTEM_REGISTRY_QUOTA_INFORMATION SYSTEM_REGISTRY_QUOTA_INFORMATION
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LIST_ENTRY ThreadListEntry
Definition: pstypes.h:1089
USHORT ObjectTypeIndex
Definition: extypes.h:1411
#define TYPE_ALIGNMENT(t)
Definition: ntbasedef.h:117
const LUID SeSystemtimePrivilege
Definition: priv.c:33
MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM]
Definition: balance.c:36
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ULONG Index
Definition: obtypes.h:385
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
ULONG InterruptTime
Definition: ketypes.h:736
LARGE_INTEGER IoWriteTransferCount
Definition: iomgr.c:42
struct _PROCESSOR_POWER_INFORMATION PROCESSOR_POWER_INFORMATION
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:26
BOOLEAN NTAPI ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature)
Definition: sysinfo.c:363
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
USHORT CreatorBackTraceIndex
Definition: extypes.h:1410
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define _Out_writes_bytes_to_opt_(size, count)
Definition: no_sal2.h:375
Definition: arc.h:32
struct _SYSTEM_NUMA_INFORMATION * PSYSTEM_NUMA_INFORMATION
const LUID SeDebugPrivilege
Definition: priv.c:41
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Definition: iorsrce.c:830
ULONG_PTR ObAttributes
Definition: extypes.h:600
SIZE_T QuotaPeak[3]
Definition: pstypes.h:1201
KDPC_DATA DpcData[2]
Definition: ketypes.h:676
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define SI_XS(n)
Definition: sysinfo.c:2696
NTSTATUS NTAPI NtSetSystemEnvironmentValueEx(IN PUNICODE_STRING VariableName, IN LPGUID VendorGuid, IN PVOID Value, IN OUT PULONG ReturnLength, IN OUT PULONG Attributes)
Definition: sysinfo.c:579
LARGE_INTEGER IoReadTransferCount
Definition: iomgr.c:40
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MC_USER
Definition: mm.h:94
HANDLE InheritedFromUniqueProcessId
Definition: pstypes.h:1240
SIZE_T PeakVirtualSize
Definition: pstypes.h:1203
SCHAR BasePriority
Definition: ketypes.h:2011
ULONG CcDataFlushes
Definition: copy.c:51
struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION * PSYSTEM_QUERY_TIME_ADJUST_INFORMATION
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
LARGE_INTEGER CreateTime
Definition: pstypes.h:1035
NTSTATUS NTAPI SeLocateProcessImageName(IN PEPROCESS Process, OUT PUNICODE_STRING *ProcessImageName)
Definition: audit.c:122
static VOID ExpCopyLookasideInformation(PSYSTEM_LOOKASIDE_INFORMATION *InfoPointer, PULONG RemainingPointer, PLIST_ENTRY ListHead, BOOLEAN ListUsesMisses)
Definition: sysinfo.c:2046
ULONG SessionId
Definition: dllmain.c:28
NTSTATUS(* Set)(PVOID, ULONG)
Definition: sysinfo.c:2686
#define SI_QS(n)
Definition: sysinfo.c:2694
#define KeGetPreviousMode()
Definition: ketypes.h:1081
PVOID DriverStart
Definition: iotypes.h:2170
KTHREAD Tcb
Definition: pstypes.h:1034
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1062
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
#define SIG_RSMB
Definition: sysinfo.c:24
PVOID *typedef PWSTR
Definition: winlogon.h:66
SCHAR Priority
Definition: ketypes.h:1672
FAST_MUTEX ExpEnvironmentLock
Definition: sysinfo.c:29
ULONG CcLazyWritePages
Definition: lazywrite.c:20
__kernel_entry NTSTATUS NTAPI NtQuerySystemInformation(_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _Out_writes_bytes_to_opt_(SystemInformationLength,*ReturnLength) PVOID SystemInformation, _In_ ULONG Length, _Out_opt_ PULONG UnsafeResultLength)
Definition: sysinfo.c:2792
PFN_NUMBER MmLowestPhysicalPage
Definition: meminit.c:30
BOOLEAN NTAPI SeSinglePrivilegeCheck(IN LUID PrivilegeValue, IN KPROCESSOR_MODE PreviousMode)
Definition: priv.c:524
ULONG KeFeatureBits
Definition: krnlinit.c:22
struct _ThreadInfo ThreadInfo
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1439
KPROCESSOR_MODE NTAPI ExGetPreviousMode(VOID)
Definition: sysinfo.c:2927
ULONG ARC_STATUS
Definition: arc.h:4
#define MC_SYSTEM
Definition: mm.h:95
NTSTATUS NTAPI NtEnumerateSystemEnvironmentValuesEx(IN ULONG InformationClass, IN PVOID Buffer, IN ULONG BufferLength)
Definition: sysinfo.c:557
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
VOID NTAPI ExUnlockUserBuffer(PMDL Mdl)
Definition: sysinfo.c:194
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133
struct _SYSTEM_PERFORMANCE_INFORMATION * PSYSTEM_PERFORMANCE_INFORMATION
_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
VOID NTAPI ExGetCurrentProcessorCounts(PULONG ThreadKernelTime, PULONG TotalCpuTime, PULONG ProcessorNumber)
Definition: sysinfo.c:345
NTSTATUS NTAPI ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: expool.c:1348
uint16_t * PWCHAR
Definition: typedefs.h:54
ARC_STATUS NTAPI HalGetEnvironmentVariable(IN PCH Name, IN USHORT ValueLength, IN PCH Value)
Definition: rtc.c:70
LARGE_INTEGER IoWriteTransferCount
Definition: memtest.h:13
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
BOOLEAN NTAPI ExVerifySuite(SUITE_TYPE SuiteType)
Definition: sysinfo.c:377
#define WCHAR
Definition: msvc.h:43
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
PVOID PMDL
Definition: usb.h:39
LARGE_INTEGER CreateTime
Definition: extypes.h:887
struct _SYSTEM_PROCESSOR_INFORMATION SYSTEM_PROCESSOR_INFORMATION
ULONG DpcTime
Definition: ketypes.h:735
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:887
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
HANDLE UniqueProcessId
Definition: pstypes.h:1198
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
struct TraceInfo Info
ULONG IoWriteOperationCount
Definition: iomgr.c:41
#define PAGED_CODE()
Definition: video.h:57
static BOOL Set
Definition: pageheap.c:10
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSTATUS NTAPI ExLockUserBuffer(PVOID BaseAddress, ULONG Length, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation, PVOID *MappedSystemVa, PMDL *OutMdl)
Definition: sysinfo.c:202
SIZE_T QuotaUsage[3]
Definition: pstypes.h:1200
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:52
#define MAX_ENVVAL_SIZE
Definition: sysinfo.c:20
_SEH2_TRY
Definition: create.c:4250
BOOLEAN KiTimeAdjustmentEnabled
Definition: time.c:19
SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[1]
Definition: extypes.h:1021
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
PKSTART_ROUTINE StartAddress
Definition: pstypes.h:1086
ULONG IoReadOperationCount
Definition: iomgr.c:39
uint32_t ULONG_PTR
Definition: typedefs.h:63
LARGE_INTEGER CreateTime
Definition: pstypes.h:1195
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
ERESOURCE PsLoadedModuleResource
Definition: sysldr.c:37
ULONG NTAPI NtGetCurrentProcessorNumber(VOID)
Definition: sysinfo.c:2918
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
LARGE_INTEGER KeBootTime
Definition: clock.c:17
UCHAR ObjectTypeIndex
Definition: extypes.h:1011
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:325
struct _SYSTEM_PROCESSOR_INFORMATION * PSYSTEM_PROCESSOR_INFORMATION
UCHAR KIRQL
Definition: env_spec_w32.h:591
PEPROCESS PsIdleProcess
Definition: psmgr.c:51
UNICODE_STRING PageFileName
Definition: extypes.h:1063
GLenum GLclampf GLint i
Definition: glfuncs.h:14
LARGE_INTEGER CurrentTime
Definition: extypes.h:846
NTSTATUS NTAPI MmSessionDelete(IN ULONG SessionId)
Definition: session.c:882
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_REGISTRY_QUOTA_INFORMATION * PSYSTEM_REGISTRY_QUOTA_INFORMATION
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static QSSI_CALLS CallQS[]
Definition: sysinfo.c:2701
#define FALSE
Definition: types.h:117
#define ANSI_NULL
ULONG ProcessExiting
Definition: pstypes.h:1326
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1115
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
ULONG GrantedAccess
Definition: extypes.h:1409
ULONG KeAlignmentFixupCount
Definition: ketypes.h:796
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
ULONG NTAPI ObGetProcessHandleCount(IN PEPROCESS Process)
Definition: obhandle.c:59
NTSTATUS NTAPI NtSetSystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
Definition: sysinfo.c:2869
ULONG ActiveThreads
Definition: pstypes.h:1267
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
UINTN * BufferSize
Definition: acefiex.h:370
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:155
CHAR * PCH
Definition: ntbasedef.h:398
struct _SYSTEM_FLAGS_INFORMATION SYSTEM_FLAGS_INFORMATION
Definition: extypes.h:595
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _KTHREAD * CurrentThread
Definition: ketypes.h:566
struct _RTL_TIME_ZONE_INFORMATION RTL_TIME_ZONE_INFORMATION
ULONG CcMapDataWait
Definition: pin.c:28
SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle[1]
Definition: extypes.h:1420
smooth NULL
Definition: ftsmooth.c:416
#define ObpGetHandleObject(x)
Definition: ob.h:81
#define STATUS_BREAKPOINT
Definition: ntstatus.h:172
const LUID SeLoadDriverPrivilege
Definition: priv.c:31
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:462
LARGE_INTEGER CreateTime
Definition: extypes.h:864
#define SIG_ACPI
Definition: sysinfo.c:22
PEPROCESS TheIdleProcess
Definition: kdpacket.c:30
#define FORCEINLINE
Definition: ntbasedef.h:221
#define _Out_
Definition: no_sal2.h:323
void DPRINT(...)
Definition: polytest.cpp:61
struct _SYSTEM_FLAGS_INFORMATION * PSYSTEM_FLAGS_INFORMATION
ULONG KeTimeAdjustment
Definition: time.c:18
VOID NTAPI PsChangeQuantumTable(IN BOOLEAN Immediate, IN ULONG PrioritySeparation)
Definition: process.c:235
Definition: bufpool.h:45
ULONG KernelTime
Definition: ketypes.h:733
#define SystemPerformanceInformation
Definition: memtest.h:87
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
ULONG ExpTimeZoneId
Definition: time.c:25
NTSTATUS(* Query)(PVOID, ULONG, PULONG)
Definition: sysinfo.c:2685
LIST_ENTRY ThreadListHead
Definition: ketypes.h:1997
ULONG DpcCount
Definition: ketypes.h:748
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
ULONG InterruptCount
Definition: ketypes.h:732
UCHAR WaitReason
Definition: ketypes.h:1854
CHAR BasePriority
Definition: ketypes.h:1807
UCHAR HandleAttributes
Definition: extypes.h:1012
UINTN Size
Definition: acefiex.h:555
NTSTATUS NTAPI MmUnloadSystemImage(IN PVOID ImageHandle)
Definition: sysldr.c:911
struct _SYSTEM_SET_TIME_ADJUST_INFORMATION * PSYSTEM_SET_TIME_ADJUST_INFORMATION
#define SIG_FIRM
Definition: sysinfo.c:23
FAST_MUTEX
Definition: extypes.h:17
NTSTATUS NTAPI ExpGetRawSMBiosTable(_Out_opt_ PVOID Buffer, _Out_ ULONG *OutSize, _In_ ULONG BufferSize)
Definition: sysinfo.c:250
LARGE_INTEGER UserTime
Definition: extypes.h:863
#define _Out_opt_
Definition: no_sal2.h:339
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
ULONG PageFaultCount
Definition: mmtypes.h:908
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:228
USHORT KeProcessorArchitecture
Definition: krnlinit.c:19
unsigned char BOOLEAN
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
USHORT KeProcessorRevision
Definition: krnlinit.c:21
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:21
struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION SYSTEM_QUERY_TIME_ADJUST_INFORMATION
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
ULONG CcDataPages
Definition: copy.c:50
ULONG_PTR HandleValue
Definition: extypes.h:1408
ULONG KernelTime
Definition: ketypes.h:1877
struct _SYSTEM_THREAD_INFORMATION * PSYSTEM_THREAD_INFORMATION
LONG NTSTATUS
Definition: precomp.h:26
struct _SYSTEM_PAGEFILE_INFORMATION SYSTEM_PAGEFILE_INFORMATION
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:345
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define __kernel_entry
Definition: specstrings.h:50
LARGE_INTEGER KernelTime
Definition: extypes.h:862
if(!(yy_init))
Definition: macro.lex.yy.c:717
#define PROCESSOR_FEATURE_MAX
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION * PSYSTEM_KERNEL_DEBUGGER_INFORMATION
#define SSI_DEF(n)
Definition: sysinfo.c:600
ULONG_PTR UniqueProcessId
Definition: extypes.h:1407
LIST_ENTRY HandleTableListHead
Definition: handle.c:18
struct _SYSTEM_CONTEXT_SWITCH_INFORMATION * PSYSTEM_CONTEXT_SWITCH_INFORMATION
#define TAG_MDL
Definition: tag.h:86
uint64_t ULONGLONG
Definition: typedefs.h:65
NTSTATUS NTAPI NtSetSystemEnvironmentValue(IN PUNICODE_STRING VariableName, IN PUNICODE_STRING Value)
Definition: sysinfo.c:487
PVOID Object
Definition: extypes.h:1014
ULONG CcPinReadNoWait
Definition: pin.c:31
CLIENT_ID Cid
Definition: pstypes.h:1059
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:34
struct _SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION
HANDLE GenericHandleOverlay
Definition: ex.h:97
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
ULONG GrantedAccess
Definition: extypes.h:1015
ULONG GrantedAccess
Definition: extypes.h:606
PKNODE KeNodeBlock[1]
Definition: krnlinit.c:39
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:848
static const UCHAR Index[8]
Definition: usbohci.c:18
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
#define KD_DEBUGGER_ENABLED
Definition: kdfuncs.h:130
struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION SYSTEM_KERNEL_DEBUGGER_INFORMATION
_In_ ACCESS_MASK _In_opt_ POBJECT_TYPE _In_ KPROCESSOR_MODE _Out_ PVOID _Out_opt_ POBJECT_HANDLE_INFORMATION HandleInformation
Definition: obfuncs.h:40
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
struct _SYSTEM_FIRMWARE_TABLE_INFORMATION * PSYSTEM_FIRMWARE_TABLE_INFORMATION
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_FILECACHE_INFORMATION SYSTEM_FILECACHE_INFORMATION
FORCEINLINE NTSTATUS ExpConvertLdrModuleToRtlModule(IN ULONG ModuleCount, IN PLDR_DATA_TABLE_ENTRY LdrEntry, OUT PRTL_PROCESS_MODULE_INFORMATION ModuleInfo)
Definition: sysinfo.c:35
NTSYSAPI NTSTATUS NTAPI ZwSetSystemInformation(_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _In_ PVOID SystemInformation, _In_ SIZE_T SystemInformationLength)
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:24
#define KeGetContextSwitches(Prcb)
Definition: ke.h:153
UNICODE_STRING ImageName
Definition: extypes.h:890
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LIST_ENTRY MmLoadedUserImageList
Definition: sysldr.c:35
LARGE_INTEGER IoOtherTransferCount
Definition: iomgr.c:44
ULONG CcMapDataNoWait
Definition: pin.c:29
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
struct _RTL_PROCESS_MODULE_INFORMATION RTL_PROCESS_MODULE_INFORMATION
#define SharedUserData
unsigned char UCHAR
Definition: xmlstorage.h:181
Definition: ex.h:81
static const char * ImageName
Definition: image.c:34
DRIVER_INITIALIZE * PDRIVER_INITIALIZE
Definition: iotypes.h:2126
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:226
static const WCHAR L[]
Definition: oid.c:1087
VOID UINTN Length
Definition: acefiex.h:744
#define RtlImageDirectoryEntryToData
Definition: compat.h:460
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define NTSTATUS
Definition: precomp.h:20
C_ASSERT(SystemBasicInformation==0)
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:893
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:22
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
Definition: btrfs_drv.h:1762
NTSTATUS NTAPI NtQuerySystemEnvironmentValue(IN PUNICODE_STRING VariableName, OUT PWSTR ValueBuffer, IN ULONG ValueBufferLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: sysinfo.c:385
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
ULONG UserTime
Definition: ketypes.h:734
VOID NTAPI ExQueryPoolUsage(OUT PULONG PagedPoolPages, OUT PULONG NonPagedPoolPages, OUT PULONG PagedPoolAllocs, OUT PULONG PagedPoolFrees, OUT PULONG PagedPoolLookasideHits, OUT PULONG NonPagedPoolAllocs, OUT PULONG NonPagedPoolFrees, OUT PULONG NonPagedPoolLookasideHits)
Definition: expool.c:1616
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
#define SystemExtendServiceTableInformation
Definition: DriverTester.h:35
KPROCESS Pcb
Definition: pstypes.h:1193
struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define MIN_SYSTEM_INFO_CLASS
Definition: sysinfo.c:2783
ULONG CcPinMappedDataCount
Definition: pin.c:32
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:140
UINT64 UINTN DataSize
Definition: acefiex.h:499
UINTN UINT8 Value
Definition: acefiex.h:751
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
VOID NTAPI ExGetCurrentProcessorCpuUsage(PULONG CpuUsage)
Definition: sysinfo.c:324
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
MMSUPPORT Vm
Definition: pstypes.h:1287
UCHAR KeNumberNodes
Definition: krnlinit.c:40
Status
Definition: gdiplustypes.h:24
const LUID SeTcbPrivilege
Definition: priv.c:28
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
LARGE_INTEGER IoReadTransferCount
Definition: memtest.h:12
struct _KTHREAD * IdleThread
Definition: ketypes.h:568
#define _In_
Definition: no_sal2.h:204
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
#define SystemLoadGdiDriverInformation
Definition: DriverTester.h:34
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:126
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1049
ULONG PeakWorkingSetSize
Definition: mmtypes.h:909
struct _SYSTEM_EXCEPTION_INFORMATION * PSYSTEM_EXCEPTION_INFORMATION
ARC_STATUS NTAPI HalSetEnvironmentVariable(IN PCH Name, IN PCH Value)
Definition: rtc.c:57
struct _FileName FileName
Definition: fatprocs.h:884
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
DWORD *typedef HANDLE
Definition: winlogon.h:61
USHORT HandleValue
Definition: extypes.h:1013
_SEH2_END
Definition: create.c:4424
DRIVER_INFORMATION DriverInfo
Definition: main.c:59
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:351
KAFFINITY ActiveProcessorsAffinityMask
Definition: ntddk_ex.h:171
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:49
LARGE_INTEGER KernelTime
Definition: extypes.h:889
struct _SYSTEM_LOOKASIDE_INFORMATION SYSTEM_LOOKASIDE_INFORMATION
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
struct _SYSTEM_DEVICE_INFORMATION * PSYSTEM_DEVICE_INFORMATION
enum _LOCK_OPERATION LOCK_OPERATION
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21
unsigned short USHORT
Definition: pedump.c:61
LARGE_INTEGER TimeZoneBias
Definition: extypes.h:847
#define SI_XX(n)
Definition: sysinfo.c:2697
ULONG KeExceptionDispatchCount
Definition: ketypes.h:701
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:29
ULONG FixedInstanceSize
Definition: wmistr.h:118
#define WMIGUID_QUERY
Definition: wmistr.h:159
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:56
ULONG NTAPI KeQueryRuntimeProcess(IN PKPROCESS Process, OUT PULONG UserTime)
Definition: procobj.c:857
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
struct _SYSTEM_PERFORMANCE_INFORMATION SYSTEM_PERFORMANCE_INFORMATION
ULONG CcPinReadWait
Definition: pin.c:30
SYSTEM_FIRMWARE_TABLE_ACTION Action
#define SystemBasicInformation
Definition: xboxvmp.h:35
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
NTSTATUS ExpSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
Definition: time.c:278
unsigned int * PULONG
Definition: retypes.h:1
struct _SYSTEM_BASIC_INFORMATION SYSTEM_BASIC_INFORMATION
struct _SYSTEM_INTERRUPT_INFORMATION * PSYSTEM_INTERRUPT_INFORMATION
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
LIST_ENTRY ExpFirmwareTableProviderListHead
Definition: sysinfo.c:31
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
LONG NextFreeTableEntry
Definition: extypes.h:612
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
ULONG KernelTime
Definition: ketypes.h:1992
enum _SUITE_TYPE SUITE_TYPE
ULONGLONG ActiveProcessorsAffinityMask[MAXIMUM_NUMA_NODES]
Definition: extypes.h:1396
LARGE_INTEGER IoOtherTransferCount
Definition: memtest.h:14
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:457
ULONG UserTime
Definition: ketypes.h:1893
struct _SYSTEM_BASIC_INFORMATION * PSYSTEM_BASIC_INFORMATION
USHORT KeProcessorLevel
Definition: krnlinit.c:20
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
#define MC_CACHE
Definition: mm.h:93
#define OUT
Definition: typedefs.h:39
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1157
volatile UCHAR State
Definition: ketypes.h:1679
ULONG ERESOURCE
Definition: env_spec_w32.h:594
CHAR ImageFileName[16]
Definition: pstypes.h:1257
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:53
unsigned int ULONG
Definition: retypes.h:1
ULONG ContextSwitches
Definition: ketypes.h:1678
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
LARGE_INTEGER UserTime
Definition: extypes.h:888
#define ULONG_PTR
Definition: config.h:101
_In_ FLT_SET_CONTEXT_OPERATION Operation
Definition: fltkernel.h:1468
uint32_t * PULONG_PTR
Definition: typedefs.h:63
PVOID Object
Definition: extypes.h:599
ULONG WaitTime
Definition: ketypes.h:1765
struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO SYSTEM_HANDLE_TABLE_ENTRY_INFO
ULONG PagesUsed
Definition: mm.h:385
EX_PUSH_LOCK ProcessLock
Definition: pstypes.h:1194
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
#define TAG_SEPA
Definition: tag.h:187
ULONG_PTR Value
Definition: ex.h:98
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
KAFFINITY ProcessorMask
Definition: ketypes.h:776
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
ULONG IoOtherOperationCount
Definition: iomgr.c:43
struct _QSSI_CALLS QSSI_CALLS
GLfloat GLfloat p
Definition: glext.h:8902
#define SI_QX(n)
Definition: sysinfo.c:2695
ULONG DpcRequestRate
Definition: ketypes.h:684
_In_ FILTER_INFORMATION_CLASS InformationClass
Definition: fltkernel.h:1714
POBJECT_TYPE Type
Definition: obtypes.h:493
#define OBJ_HANDLE_ATTRIBUTES
Definition: ob.h:52
SIZE_T VirtualSize
Definition: pstypes.h:1204
IN PVOID IN PVOID IN PCHAR IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo
Definition: srb.h:462
SIZE_T CommitCharge
Definition: pstypes.h:1202
return STATUS_SUCCESS
Definition: btrfs.c:2710
ULONG WorkingSetSize
Definition: mmtypes.h:931
ULONG NtGlobalFlag
Definition: init.c:51
#define MAX_SYSTEM_INFO_CLASS
Definition: sysinfo.c:2784
#define STATUS_ILLEGAL_FUNCTION
Definition: ntstatus.h:397
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
USHORT UniqueProcessId
Definition: extypes.h:1009
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
NTSTATUS NTAPI NtQuerySystemEnvironmentValueEx(IN PUNICODE_STRING VariableName, IN LPGUID VendorGuid, IN PVOID Value, IN OUT PULONG ReturnLength, IN OUT PULONG Attributes)
Definition: sysinfo.c:567
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
struct _SYSTEM_DEVICE_INFORMATION SYSTEM_DEVICE_INFORMATION
#define MmSystemRangeStart
Definition: mm.h:31
PIMAGE_EXPORT_DIRECTORY ExportSectionPointer
Definition: DriverTester.h:49
IN HDEVINFO IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL
Definition: devinst.c:44
ULONG FreeCount[2]
Definition: ketypes.h:785
union gl_dlist_node Node
Definition: dlist.c:302
PVOID UniqueProcessId
Definition: extypes.h:624
ULONG Reserved
Definition: extypes.h:1413
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:23
USHORT CreatorBackTraceIndex
Definition: extypes.h:1010
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:25
struct _ACPI_EFI_FILE_HANDLE CHAR16 UINT64 UINT64 Attributes
Definition: acefiex.h:335
DISPATCHER_HEADER Header
Definition: ketypes.h:1974
LONGLONG QuadPart
Definition: typedefs.h:112
NTSTATUS NTAPI MmLoadSystemImage(IN PUNICODE_STRING FileName, IN PUNICODE_STRING NamePrefix OPTIONAL, IN PUNICODE_STRING LoadedName OPTIONAL, IN ULONG Flags, OUT PVOID *ModuleObject, OUT PVOID *ImageBaseAddress)
Definition: sysldr.c:2853
_Must_inspect_result_ _In_ LPCGUID _In_ ULONG _In_ FSRTL_ALLOCATE_ECP_FLAGS _In_opt_ PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK _Inout_ PVOID LookasideList
Definition: fltkernel.h:2551
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14