3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/sysinfo.c
6 * PURPOSE: System information functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <ddk/exfuncs.h>
16 #include <ddk/halfuncs.h>
17 #include <ddk/iofuncs.h>
18 #include <internal/ex.h>
19 #include <internal/ldr.h>
20 #include <internal/safe.h>
22 #include <internal/debug.h>
24 extern ULONG NtGlobalFlag; /* FIXME: it should go in a ddk/?.h */
26 /* FUNCTIONS *****************************************************************/
29 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING UnsafeName,
30 OUT PVOID UnsafeValue,
32 IN OUT PULONG UnsafeReturnLength)
40 UNICODE_STRING WValue;
44 * Copy the name to kernel space if necessary and convert it to ANSI.
46 if (ExGetPreviousMode() != KernelMode)
48 Status = RtlCaptureUnicodeString(&WName, UnsafeName);
49 if (!NT_SUCCESS(Status))
53 Status = RtlUnicodeStringToAnsiString(&AName, UnsafeName, TRUE);
54 if (!NT_SUCCESS(Status))
61 Status = RtlUnicodeStringToAnsiString(&AName, UnsafeName, TRUE);
62 if (!NT_SUCCESS(Status))
69 * Create a temporary buffer for the value
71 Value = ExAllocatePool(NonPagedPool, Length);
74 RtlFreeAnsiString(&AName);
75 if (ExGetPreviousMode() != KernelMode)
77 RtlFreeUnicodeString(&WName);
79 return(STATUS_NO_MEMORY);
83 * Get the environment variable
85 Result = HalGetEnvironmentVariable(AName.Buffer, Value, Length);
88 RtlFreeAnsiString(&AName);
89 if (ExGetPreviousMode() != KernelMode)
91 RtlFreeUnicodeString(&WName);
94 return(STATUS_UNSUCCESSFUL);
98 * Convert the result to UNICODE.
100 RtlInitAnsiString(&AValue, Value);
101 Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, TRUE);
102 if (!NT_SUCCESS(Status))
104 RtlFreeAnsiString(&AName);
105 if (ExGetPreviousMode() != KernelMode)
107 RtlFreeUnicodeString(&WName);
112 ReturnLength = WValue.Length;
115 * Copy the result back to the caller.
117 if (ExGetPreviousMode() != KernelMode)
119 Status = MmCopyToCaller(UnsafeValue, WValue.Buffer, ReturnLength);
120 if (!NT_SUCCESS(Status))
122 RtlFreeAnsiString(&AName);
123 if (ExGetPreviousMode() != KernelMode)
125 RtlFreeUnicodeString(&WName);
128 RtlFreeUnicodeString(&WValue);
132 Status = MmCopyToCaller(UnsafeReturnLength, &ReturnLength,
134 if (!NT_SUCCESS(Status))
136 RtlFreeAnsiString(&AName);
137 if (ExGetPreviousMode() != KernelMode)
139 RtlFreeUnicodeString(&WName);
142 RtlFreeUnicodeString(&WValue);
148 memcpy(UnsafeValue, WValue.Buffer, ReturnLength);
149 memcpy(UnsafeReturnLength, &ReturnLength, sizeof(ULONG));
153 * Free temporary buffers.
155 RtlFreeAnsiString(&AName);
156 if (ExGetPreviousMode() != KernelMode)
158 RtlFreeUnicodeString(&WName);
161 RtlFreeUnicodeString(&WValue);
163 return(STATUS_SUCCESS);
168 NtSetSystemEnvironmentValue (IN PUNICODE_STRING UnsafeName,
169 IN PUNICODE_STRING UnsafeValue)
171 UNICODE_STRING WName;
173 UNICODE_STRING WValue;
179 * Check for required privilege.
181 /* FIXME: Not implemented. */
184 * Copy the name to kernel space if necessary and convert it to ANSI.
186 if (ExGetPreviousMode() != KernelMode)
188 Status = RtlCaptureUnicodeString(&WName, UnsafeName);
189 if (!NT_SUCCESS(Status))
193 Status = RtlUnicodeStringToAnsiString(&AName, UnsafeName, TRUE);
194 if (!NT_SUCCESS(Status))
201 Status = RtlUnicodeStringToAnsiString(&AName, UnsafeName, TRUE);
202 if (!NT_SUCCESS(Status))
209 * Copy the value to kernel space and convert to ANSI.
211 if (ExGetPreviousMode() != KernelMode)
213 Status = RtlCaptureUnicodeString(&WValue, UnsafeValue);
214 if (!NT_SUCCESS(Status))
216 RtlFreeUnicodeString(&WName);
217 RtlFreeAnsiString(&AName);
220 Status = RtlUnicodeStringToAnsiString(&AValue, UnsafeValue, TRUE);
221 if (!NT_SUCCESS(Status))
223 RtlFreeUnicodeString(&WName);
224 RtlFreeAnsiString(&AName);
225 RtlFreeUnicodeString(&WValue);
231 Status = RtlUnicodeStringToAnsiString(&AValue, UnsafeValue, TRUE);
232 if (!NT_SUCCESS(Status))
234 RtlFreeAnsiString(&AName);
240 * Set the environment variable
242 Result = HalSetEnvironmentVariable(AName.Buffer, AValue.Buffer);
245 * Free everything and return status.
247 RtlFreeAnsiString(&AName);
248 RtlFreeAnsiString(&AValue);
249 if (ExGetPreviousMode() != KernelMode)
251 RtlFreeUnicodeString(&WName);
252 RtlFreeUnicodeString(&WValue);
257 return(STATUS_UNSUCCESSFUL);
259 return(STATUS_SUCCESS);
263 /* --- Query/Set System Information --- */
267 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
268 * so the stack is popped only in one place on x86 platform.
270 #define QSI_USE(n) QSI##n
272 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
274 #define SSI_USE(n) SSI##n
276 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
278 /* Class 0 - Basic Information */
279 QSI_DEF(SystemBasicInformation)
281 PSYSTEM_BASIC_INFORMATION Sbi
282 = (PSYSTEM_BASIC_INFORMATION) Buffer;
284 *ReqSize = sizeof (SYSTEM_BASIC_INFORMATION);
286 * Check user buffer's size
288 if (Size < sizeof (SYSTEM_BASIC_INFORMATION))
290 return (STATUS_INFO_LENGTH_MISMATCH);
294 Sbi->TimerResolution = 0; /* FIXME */
295 Sbi->PageSize = PAGE_SIZE; /* FIXME: it should be PAGE_SIZE */
296 Sbi->NumberOfPhysicalPages = 0; /* FIXME */
297 Sbi->LowestPhysicalPageNumber = 0; /* FIXME */
298 Sbi->HighestPhysicalPageNumber = 0; /* FIXME */
299 Sbi->AllocationGranularity = 65536; /* hard coded on Intel? */
300 Sbi->MinimumUserModeAddress = 0; /* FIXME */
301 Sbi->MaximumUserModeAddress = 0; /* FIXME */
302 Sbi->ActiveProcessorsAffinityMask = 0x00000001; /* FIXME */
303 Sbi->NumberOfProcessors = 1; /* FIXME */
305 return (STATUS_SUCCESS);
308 /* Class 1 - Processor Information */
309 QSI_DEF(SystemProcessorInformation)
311 PSYSTEM_PROCESSOR_INFORMATION Spi
312 = (PSYSTEM_PROCESSOR_INFORMATION) Buffer;
314 *ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION);
316 * Check user buffer's size
318 if (Size < sizeof (SYSTEM_PROCESSOR_INFORMATION))
320 return (STATUS_INFO_LENGTH_MISMATCH);
323 /* FIXME: add CPU type detection code */
324 Spi->ProcessorArchitecture = 0; /* FIXME */
325 Spi->ProcessorLevel = 0; /* FIXME */
326 Spi->ProcessorRevision = 0; /* FIXME */
328 Spi->ProcessorFeatureBits = 0x00000000; /* FIXME */
330 return (STATUS_SUCCESS);
333 /* Class 2 - Performance Information */
334 QSI_DEF(SystemPerformanceInformation)
336 PSYSTEM_PERFORMANCE_INFO Spi
337 = (PSYSTEM_PERFORMANCE_INFO) Buffer;
339 *ReqSize = sizeof (SYSTEM_PERFORMANCE_INFO);
341 * Check user buffer's size
343 if (Size < sizeof (SYSTEM_PERFORMANCE_INFO))
345 return (STATUS_INFO_LENGTH_MISMATCH);
348 Spi->IdleProcessorTime.QuadPart = 0; /* FIXME */
349 Spi->IoReadTransferCount.QuadPart = 0; /* FIXME */
350 Spi->IoWriteTransferCount.QuadPart = 0; /* FIXME */
351 Spi->IoOtherTransferCount.QuadPart = 0; /* FIXME */
352 Spi->IoReadOperationCount = 0; /* FIXME */
353 Spi->IoWriteOperationCount = 0; /* FIXME */
354 Spi->IoOtherOperationCount = 0; /* FIXME */
355 Spi->AvailablePages = 0; /* FIXME */
356 Spi->CommitedPages = 0; /* FIXME */
357 Spi->CommitLimit = 0; /* FIXME */
358 Spi->PeakCommitment = 0; /* FIXME */
359 Spi->PageFaultCount = 0; /* FIXME */
360 Spi->CopyOnWriteCount = 0; /* FIXME */
361 Spi->TransitionCount = 0; /* FIXME */
362 Spi->CacheTransitionCount = 0; /* FIXME */
363 Spi->DemandZeroCount = 0; /* FIXME */
364 Spi->PageReadCount = 0; /* FIXME */
365 Spi->PageReadIoCount = 0; /* FIXME */
366 Spi->CacheReadCount = 0; /* FIXME */
367 Spi->CacheIoCount = 0; /* FIXME */
368 Spi->DirtyPagesWriteCount = 0; /* FIXME */
369 Spi->DirtyWriteIoCount = 0; /* FIXME */
370 Spi->MappedPagesWriteCount = 0; /* FIXME */
371 Spi->MappedWriteIoCount = 0; /* FIXME */
372 Spi->PagedPoolPages = 0; /* FIXME */
373 Spi->NonPagedPoolPages = 0; /* FIXME */
374 Spi->Unknown6 = 0; /* FIXME */
375 Spi->Unknown7 = 0; /* FIXME */
376 Spi->Unknown8 = 0; /* FIXME */
377 Spi->Unknown9 = 0; /* FIXME */
378 Spi->MmTotalSystemFreePtes = 0; /* FIXME */
379 Spi->MmSystemCodepage = 0; /* FIXME */
380 Spi->MmTotalSystemDriverPages = 0; /* FIXME */
381 Spi->MmTotalSystemCodePages = 0; /* FIXME */
382 Spi->Unknown10 = 0; /* FIXME */
383 Spi->Unknown11 = 0; /* FIXME */
384 Spi->Unknown12 = 0; /* FIXME */
385 Spi->MmSystemCachePage = 0; /* FIXME */
386 Spi->MmPagedPoolPage = 0; /* FIXME */
387 Spi->MmSystemDriverPage = 0; /* FIXME */
388 Spi->CcFastReadNoWait = 0; /* FIXME */
389 Spi->CcFastReadWait = 0; /* FIXME */
390 Spi->CcFastReadResourceMiss = 0; /* FIXME */
391 Spi->CcFastReadNotPossible = 0; /* FIXME */
392 Spi->CcFastMdlReadNoWait = 0; /* FIXME */
393 Spi->CcFastMdlReadWait = 0; /* FIXME */
394 Spi->CcFastMdlReadResourceMiss = 0; /* FIXME */
395 Spi->CcFastMdlReadNotPossible = 0; /* FIXME */
396 Spi->CcMapDataNoWait = 0; /* FIXME */
397 Spi->CcMapDataWait = 0; /* FIXME */
398 Spi->CcMapDataNoWaitMiss = 0; /* FIXME */
399 Spi->CcMapDataWaitMiss = 0; /* FIXME */
400 Spi->CcPinMappedDataCount = 0; /* FIXME */
401 Spi->CcPinReadNoWait = 0; /* FIXME */
402 Spi->CcPinReadWait = 0; /* FIXME */
403 Spi->CcPinReadNoWaitMiss = 0; /* FIXME */
404 Spi->CcPinReadWaitMiss = 0; /* FIXME */
405 Spi->CcCopyReadNoWait = 0; /* FIXME */
406 Spi->CcCopyReadWait = 0; /* FIXME */
407 Spi->CcCopyReadNoWaitMiss = 0; /* FIXME */
408 Spi->CcCopyReadWaitMiss = 0; /* FIXME */
409 Spi->CcMdlReadNoWait = 0; /* FIXME */
410 Spi->CcMdlReadWait = 0; /* FIXME */
411 Spi->CcMdlReadNoWaitMiss = 0; /* FIXME */
412 Spi->CcMdlReadWaitMiss = 0; /* FIXME */
413 Spi->CcReadaheadIos = 0; /* FIXME */
414 Spi->CcLazyWriteIos = 0; /* FIXME */
415 Spi->CcLazyWritePages = 0; /* FIXME */
416 Spi->CcDataFlushes = 0; /* FIXME */
417 Spi->CcDataPages = 0; /* FIXME */
418 Spi->ContextSwitches = 0; /* FIXME */
419 Spi->Unknown13 = 0; /* FIXME */
420 Spi->Unknown14 = 0; /* FIXME */
421 Spi->SystemCalls = 0; /* FIXME */
423 return (STATUS_SUCCESS);
426 /* Class 3 - Time Of Day Information */
427 QSI_DEF(SystemTimeOfDayInformation)
429 PSYSTEM_TIMEOFDAY_INFORMATION Sti
430 = (PSYSTEM_TIMEOFDAY_INFORMATION) Buffer;
432 *ReqSize = sizeof (SYSTEM_TIMEOFDAY_INFORMATION);
434 * Check user buffer's size
436 if (Size < sizeof (SYSTEM_TIMEOFDAY_INFORMATION))
438 return (STATUS_INFO_LENGTH_MISMATCH);
441 Sti->BootTime.QuadPart = 0; /* FIXME */
442 Sti->CurrentTime.QuadPart = 0; /* FIXME */
443 Sti->TimeZoneBias.QuadPart = 0; /* FIXME */
444 Sti->TimeZoneId = 0; /* FIXME */
445 Sti->Reserved = 0; /* FIXME */
447 return (STATUS_SUCCESS);
450 /* Class 4 - Path Information */
451 QSI_DEF(SystemPathInformation)
453 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
454 return (STATUS_BREAKPOINT);
457 /* Class 5 - Process Information */
458 QSI_DEF(SystemProcessInformation)
460 /* FIXME: scan the process+thread list */
461 return (STATUS_NOT_IMPLEMENTED);
464 /* Class 6 - Call Count Information */
465 QSI_DEF(SystemCallCountInformation)
468 return (STATUS_NOT_IMPLEMENTED);
471 /* Class 7 - Device Information */
472 QSI_DEF(SystemDeviceInformation)
474 PSYSTEM_DEVICE_INFORMATION Sdi
475 = (PSYSTEM_DEVICE_INFORMATION) Buffer;
476 PCONFIGURATION_INFORMATION ConfigInfo;
478 *ReqSize = sizeof (SYSTEM_DEVICE_INFORMATION);
480 * Check user buffer's size
482 if (Size < sizeof (SYSTEM_DEVICE_INFORMATION))
484 return (STATUS_INFO_LENGTH_MISMATCH);
487 ConfigInfo = IoGetConfigurationInformation ();
489 Sdi->NumberOfDisks = ConfigInfo->DiskCount;
490 Sdi->NumberOfFloppies = ConfigInfo->FloppyCount;
491 Sdi->NumberOfCdRoms = ConfigInfo->CDRomCount;
492 Sdi->NumberOfTapes = ConfigInfo->TapeCount;
493 Sdi->NumberOfSerialPorts = ConfigInfo->SerialCount;
494 Sdi->NumberOfParallelPorts = ConfigInfo->ParallelCount;
496 return (STATUS_SUCCESS);
499 /* Class 8 - Processor Performance Information */
500 QSI_DEF(SystemProcessorPerformanceInformation)
503 return (STATUS_NOT_IMPLEMENTED);
506 /* Class 9 - Flags Information */
507 QSI_DEF(SystemFlagsInformation)
509 if (sizeof (SYSTEM_FLAGS_INFORMATION) != Size)
511 * ReqSize = sizeof (SYSTEM_FLAGS_INFORMATION);
512 return (STATUS_INFO_LENGTH_MISMATCH);
514 ((PSYSTEM_FLAGS_INFORMATION) Buffer)->Flags = NtGlobalFlag;
515 return (STATUS_SUCCESS);
518 SSI_DEF(SystemFlagsInformation)
520 if (sizeof (SYSTEM_FLAGS_INFORMATION) != Size)
522 return (STATUS_INFO_LENGTH_MISMATCH);
524 NtGlobalFlag = ((PSYSTEM_FLAGS_INFORMATION) Buffer)->Flags;
525 return (STATUS_SUCCESS);
528 /* Class 10 - Call Time Information */
529 QSI_DEF(SystemCallTimeInformation)
532 return (STATUS_NOT_IMPLEMENTED);
535 /* Class 11 - Module Information */
536 QSI_DEF(SystemModuleInformation)
538 return LdrpQueryModuleInformation(Buffer, Size, ReqSize);
541 /* Class 12 - Locks Information */
542 QSI_DEF(SystemLocksInformation)
545 return (STATUS_NOT_IMPLEMENTED);
548 /* Class 13 - Stack Trace Information */
549 QSI_DEF(SystemStackTraceInformation)
552 return (STATUS_NOT_IMPLEMENTED);
555 /* Class 14 - Paged Pool Information */
556 QSI_DEF(SystemPagedPoolInformation)
559 return (STATUS_NOT_IMPLEMENTED);
562 /* Class 15 - Non Paged Pool Information */
563 QSI_DEF(SystemNonPagedPoolInformation)
566 return (STATUS_NOT_IMPLEMENTED);
569 /* Class 16 - Handle Information */
570 QSI_DEF(SystemHandleInformation)
573 return (STATUS_NOT_IMPLEMENTED);
576 /* Class 17 - Information */
577 QSI_DEF(SystemObjectInformation)
580 return (STATUS_NOT_IMPLEMENTED);
583 /* Class 18 - Information */
584 QSI_DEF(SystemPageFileInformation)
587 return (STATUS_NOT_IMPLEMENTED);
590 /* Class 19 - Vdm Instemul Information */
591 QSI_DEF(SystemVdmInstemulInformation)
594 return (STATUS_NOT_IMPLEMENTED);
597 /* Class 20 - Vdm Bop Information */
598 QSI_DEF(SystemVdmBopInformation)
601 return (STATUS_NOT_IMPLEMENTED);
604 /* Class 21 - File Cache Information */
605 QSI_DEF(SystemFileCacheInformation)
607 if (Size < sizeof (SYSTEM_CACHE_INFORMATION))
609 * ReqSize = sizeof (SYSTEM_CACHE_INFORMATION);
610 return (STATUS_INFO_LENGTH_MISMATCH);
613 return (STATUS_NOT_IMPLEMENTED);
616 SSI_DEF(SystemFileCacheInformation)
618 if (Size < sizeof (SYSTEM_CACHE_INFORMATION))
620 return (STATUS_INFO_LENGTH_MISMATCH);
623 return (STATUS_NOT_IMPLEMENTED);
626 /* Class 22 - Pool Tag Information */
627 QSI_DEF(SystemPoolTagInformation)
630 return (STATUS_NOT_IMPLEMENTED);
633 /* Class 23 - Interrupt Information */
634 QSI_DEF(SystemInterruptInformation)
637 return (STATUS_NOT_IMPLEMENTED);
640 /* Class 24 - DPC Behaviour Information */
641 QSI_DEF(SystemDpcBehaviourInformation)
644 return (STATUS_NOT_IMPLEMENTED);
647 SSI_DEF(SystemDpcBehaviourInformation)
650 return (STATUS_NOT_IMPLEMENTED);
653 /* Class 25 - Full Memory Information */
654 QSI_DEF(SystemFullMemoryInformation)
657 return (STATUS_NOT_IMPLEMENTED);
660 /* Class 26 - Load Image */
661 SSI_DEF(SystemLoadImage)
663 PSYSTEM_LOAD_IMAGE Sli = (PSYSTEM_LOAD_IMAGE)Buffer;
665 if (sizeof(SYSTEM_LOAD_IMAGE) != Size)
667 return(STATUS_INFO_LENGTH_MISMATCH);
670 return(LdrpLoadImage(&Sli->ModuleName,
672 &Sli->SectionPointer,
674 &Sli->ExportDirectory));
677 /* Class 27 - Unload Image */
678 SSI_DEF(SystemUnloadImage)
680 PSYSTEM_UNLOAD_IMAGE Sui = (PSYSTEM_UNLOAD_IMAGE)Buffer;
682 if (sizeof(SYSTEM_UNLOAD_IMAGE) != Size)
684 return(STATUS_INFO_LENGTH_MISMATCH);
687 return(LdrpUnloadImage(Sui->ModuleBase));
690 /* Class 28 - Time Adjustment Information */
691 QSI_DEF(SystemTimeAdjustmentInformation)
693 if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size)
695 * ReqSize = sizeof (SYSTEM_TIME_ADJUSTMENT_INFO);
696 return (STATUS_INFO_LENGTH_MISMATCH);
699 return (STATUS_NOT_IMPLEMENTED);
702 SSI_DEF(SystemTimeAdjustmentInformation)
704 if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size)
706 return (STATUS_INFO_LENGTH_MISMATCH);
709 return (STATUS_NOT_IMPLEMENTED);
712 /* Class 29 - Summary Memory Information */
713 QSI_DEF(SystemSummaryMemoryInformation)
716 return (STATUS_NOT_IMPLEMENTED);
719 /* Class 30 - Next Event Id Information */
720 QSI_DEF(SystemNextEventIdInformation)
723 return (STATUS_NOT_IMPLEMENTED);
726 /* Class 31 - Event Ids Information */
727 QSI_DEF(SystemEventIdsInformation)
730 return (STATUS_NOT_IMPLEMENTED);
733 /* Class 32 - Crach Dump Information */
734 QSI_DEF(SystemCrashDumpInformation)
737 return (STATUS_NOT_IMPLEMENTED);
740 /* Class 33 - Exception Information */
741 QSI_DEF(SystemExceptionInformation)
744 return (STATUS_NOT_IMPLEMENTED);
747 /* Class 34 - Crach Dump State Information */
748 QSI_DEF(SystemCrashDumpStateInformation)
751 return (STATUS_NOT_IMPLEMENTED);
754 /* Class 35 - Kernel Debugger Information */
755 QSI_DEF(SystemKernelDebuggerInformation)
758 return (STATUS_NOT_IMPLEMENTED);
761 /* Class 36 - Context Switch Information */
762 QSI_DEF(SystemContextSwitchInformation)
765 return (STATUS_NOT_IMPLEMENTED);
768 /* Class 37 - Registry Quota Information */
769 QSI_DEF(SystemRegistryQuotaInformation)
772 return (STATUS_NOT_IMPLEMENTED);
775 SSI_DEF(SystemRegistryQuotaInformation)
778 return (STATUS_NOT_IMPLEMENTED);
781 /* Class 38 - Load And Call Image */
782 SSI_DEF(SystemLoadAndCallImage)
784 PSYSTEM_LOAD_AND_CALL_IMAGE Slci = (PSYSTEM_LOAD_AND_CALL_IMAGE)Buffer;
786 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE) != Size)
788 return(STATUS_INFO_LENGTH_MISMATCH);
791 return(LdrpLoadAndCallImage(&Slci->ModuleName));
794 /* Class 39 - Priority Seperation */
795 SSI_DEF(SystemPrioritySeperation)
798 return (STATUS_NOT_IMPLEMENTED);
801 /* Class 40 - Plug Play Bus Information */
802 QSI_DEF(SystemPlugPlayBusInformation)
805 return (STATUS_NOT_IMPLEMENTED);
808 /* Class 41 - Dock Information */
809 QSI_DEF(SystemDockInformation)
812 return (STATUS_NOT_IMPLEMENTED);
815 /* Class 42 - Power Information */
816 QSI_DEF(SystemPowerInformation)
819 return (STATUS_NOT_IMPLEMENTED);
822 /* Class 43 - Processor Speed Information */
823 QSI_DEF(SystemProcessorSpeedInformation)
826 return (STATUS_NOT_IMPLEMENTED);
829 /* Class 44 - Current Time Zone Information */
830 QSI_DEF(SystemCurrentTimeZoneInformation)
832 * ReqSize = sizeof (TIME_ZONE_INFORMATION);
834 if (sizeof (TIME_ZONE_INFORMATION) != Size)
836 return (STATUS_INFO_LENGTH_MISMATCH);
838 /* Copy the time zone information struct */
841 & SystemTimeZoneInfo,
842 sizeof (TIME_ZONE_INFORMATION)
845 return (STATUS_SUCCESS);
849 SSI_DEF(SystemCurrentTimeZoneInformation)
852 * Check user buffer's size
854 if (Size < sizeof (TIME_ZONE_INFORMATION))
856 return (STATUS_INFO_LENGTH_MISMATCH);
858 /* Copy the time zone information struct */
860 & SystemTimeZoneInfo,
861 (TIME_ZONE_INFORMATION *) Buffer,
862 sizeof (TIME_ZONE_INFORMATION)
864 return (STATUS_SUCCESS);
868 /* Class 45 - Lookaside Information */
869 QSI_DEF(SystemLookasideInformation)
872 return (STATUS_NOT_IMPLEMENTED);
876 /* Class 46 - Set time slip event */
877 SSI_DEF(SystemSetTimeSlipEvent)
880 return (STATUS_NOT_IMPLEMENTED);
884 /* Class 47 - Create a new session (TSE) */
885 SSI_DEF(SystemCreateSession)
888 return (STATUS_NOT_IMPLEMENTED);
892 /* Class 48 - Delete an existing session (TSE) */
893 SSI_DEF(SystemDeleteSession)
896 return (STATUS_NOT_IMPLEMENTED);
900 /* Class 49 - UNKNOWN */
901 QSI_DEF(SystemInvalidInfoClass4)
904 return (STATUS_NOT_IMPLEMENTED);
908 /* Class 50 - System range start address */
909 QSI_DEF(SystemRangeStartInformation)
912 return (STATUS_NOT_IMPLEMENTED);
916 /* Class 51 - Driver verifier information */
917 QSI_DEF(SystemVerifierInformation)
920 return (STATUS_NOT_IMPLEMENTED);
924 SSI_DEF(SystemVerifierInformation)
927 return (STATUS_NOT_IMPLEMENTED);
931 /* Class 52 - Add a driver verifier */
932 SSI_DEF(SystemAddVerifier)
935 return (STATUS_NOT_IMPLEMENTED);
939 /* Class 53 - A session's processes */
940 QSI_DEF(SystemSessionProcessesInformation)
943 return (STATUS_NOT_IMPLEMENTED);
947 /* Query/Set Calls Table */
951 NTSTATUS (* Query) (PVOID,ULONG,PULONG);
952 NTSTATUS (* Set) (PVOID,ULONG);
959 // XX unknown behaviour
961 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
962 #define SI_QX(n) {QSI_USE(n),NULL}
963 #define SI_XS(n) {NULL,SSI_USE(n)}
964 #define SI_XX(n) {NULL,NULL}
970 SI_QX(SystemBasicInformation),
971 SI_QX(SystemProcessorInformation),
972 SI_QX(SystemPerformanceInformation),
973 SI_QX(SystemTimeOfDayInformation),
974 SI_QX(SystemPathInformation), /* should be SI_XX */
975 SI_QX(SystemProcessInformation),
976 SI_QX(SystemCallCountInformation),
977 SI_QX(SystemDeviceInformation),
978 SI_QX(SystemProcessorPerformanceInformation),
979 SI_QS(SystemFlagsInformation),
980 SI_QX(SystemCallTimeInformation), /* should be SI_XX */
981 SI_QX(SystemModuleInformation),
982 SI_QX(SystemLocksInformation),
983 SI_QX(SystemStackTraceInformation), /* should be SI_XX */
984 SI_QX(SystemPagedPoolInformation), /* should be SI_XX */
985 SI_QX(SystemNonPagedPoolInformation), /* should be SI_XX */
986 SI_QX(SystemHandleInformation),
987 SI_QX(SystemObjectInformation),
988 SI_QX(SystemPageFileInformation),
989 SI_QX(SystemVdmInstemulInformation),
990 SI_QX(SystemVdmBopInformation), /* it should be SI_XX */
991 SI_QS(SystemFileCacheInformation),
992 SI_QX(SystemPoolTagInformation),
993 SI_QX(SystemInterruptInformation),
994 SI_QS(SystemDpcBehaviourInformation),
995 SI_QX(SystemFullMemoryInformation), /* it should be SI_XX */
996 SI_XS(SystemLoadImage),
997 SI_XS(SystemUnloadImage),
998 SI_QS(SystemTimeAdjustmentInformation),
999 SI_QX(SystemSummaryMemoryInformation), /* it should be SI_XX */
1000 SI_QX(SystemNextEventIdInformation), /* it should be SI_XX */
1001 SI_QX(SystemEventIdsInformation), /* it should be SI_XX */
1002 SI_QX(SystemCrashDumpInformation),
1003 SI_QX(SystemExceptionInformation),
1004 SI_QX(SystemCrashDumpStateInformation),
1005 SI_QX(SystemKernelDebuggerInformation),
1006 SI_QX(SystemContextSwitchInformation),
1007 SI_QS(SystemRegistryQuotaInformation),
1008 SI_XS(SystemLoadAndCallImage),
1009 SI_XS(SystemPrioritySeperation),
1010 SI_QX(SystemPlugPlayBusInformation), /* it should be SI_XX */
1011 SI_QX(SystemDockInformation), /* it should be SI_XX */
1012 SI_QX(SystemPowerInformation), /* it should be SI_XX */
1013 SI_QX(SystemProcessorSpeedInformation), /* it should be SI_XX */
1014 SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */
1015 SI_QX(SystemLookasideInformation),
1016 SI_XS(SystemSetTimeSlipEvent),
1017 SI_XS(SystemCreateSession),
1018 SI_XS(SystemDeleteSession),
1019 SI_QX(SystemInvalidInfoClass4), /* it should be SI_XX */
1020 SI_QX(SystemRangeStartInformation),
1021 SI_QS(SystemVerifierInformation),
1022 SI_XS(SystemAddVerifier),
1023 SI_QX(SystemSessionProcessesInformation)
1028 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
1029 OUT PVOID UnsafeSystemInformation,
1031 OUT PULONG UnsafeResultLength)
1034 PVOID SystemInformation;
1038 if (ExGetPreviousMode() == KernelMode)
1040 SystemInformation = UnsafeSystemInformation;
1044 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1045 if (SystemInformation == NULL)
1047 return(STATUS_NO_MEMORY);
1051 /* Clear user buffer. */
1052 RtlZeroMemory(SystemInformation, Length);
1055 * Check the request is valid.
1057 if ((SystemInformationClass >= SystemInformationClassMin) &&
1058 (SystemInformationClass < SystemInformationClassMax))
1060 if (NULL != CallQS [SystemInformationClass].Query)
1063 * Hand the request to a subhandler.
1065 FStatus = CallQS [SystemInformationClass].Query(SystemInformation,
1068 if (ExGetPreviousMode() != KernelMode)
1070 Status = MmCopyToCaller(UnsafeSystemInformation,
1073 ExFreePool(SystemInformation);
1074 if (!NT_SUCCESS(Status))
1079 if (UnsafeResultLength != NULL)
1081 if (ExGetPreviousMode() == KernelMode)
1083 *UnsafeResultLength = ResultLength;
1087 Status = MmCopyToCaller(UnsafeResultLength,
1090 if (!NT_SUCCESS(Status))
1099 return (STATUS_INVALID_INFO_CLASS);
1105 NtSetSystemInformation (
1106 IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
1107 IN PVOID SystemInformation,
1108 IN ULONG SystemInformationLength
1112 * If called from user mode, check
1113 * possible unsafe arguments.
1116 if (KernelMode != KeGetPreviousMode())
1120 // SystemInformation,
1130 * Check the request is valid.
1132 if ( (SystemInformationClass >= SystemInformationClassMin)
1133 && (SystemInformationClass < SystemInformationClassMax)
1136 if (NULL != CallQS [SystemInformationClass].Set)
1139 * Hand the request to a subhandler.
1141 return CallQS [SystemInformationClass].Set (
1143 SystemInformationLength
1147 return (STATUS_INVALID_INFO_CLASS);
1153 NtFlushInstructionCache (
1154 IN HANDLE ProcessHandle,
1155 IN PVOID BaseAddress,
1156 IN UINT NumberOfBytesToFlush