1 /* $Id: sysinfo.c,v 1.16 2002/09/07 15:12:50 chorns Exp $
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 *****************************************************************/
17 #include <internal/debug.h>
20 extern ULONG NtGlobalFlag
; /* FIXME: it should go in a ddk/?.h */
22 /* FUNCTIONS *****************************************************************/
25 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING UnsafeName
,
26 OUT PVOID UnsafeValue
,
28 IN OUT PULONG UnsafeReturnLength
)
36 UNICODE_STRING WValue
;
40 * Copy the name to kernel space if necessary and convert it to ANSI.
42 if (ExGetPreviousMode() != KernelMode
)
44 Status
= RtlCaptureUnicodeString(&WName
, UnsafeName
);
45 if (!NT_SUCCESS(Status
))
49 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
50 if (!NT_SUCCESS(Status
))
57 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
58 if (!NT_SUCCESS(Status
))
65 * Create a temporary buffer for the value
67 Value
= ExAllocatePool(NonPagedPool
, Length
);
70 RtlFreeAnsiString(&AName
);
71 if (ExGetPreviousMode() != KernelMode
)
73 RtlFreeUnicodeString(&WName
);
75 return(STATUS_NO_MEMORY
);
79 * Get the environment variable
81 Result
= HalGetEnvironmentVariable(AName
.Buffer
, Value
, Length
);
84 RtlFreeAnsiString(&AName
);
85 if (ExGetPreviousMode() != KernelMode
)
87 RtlFreeUnicodeString(&WName
);
90 return(STATUS_UNSUCCESSFUL
);
94 * Convert the result to UNICODE.
96 RtlInitAnsiString(&AValue
, Value
);
97 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
98 if (!NT_SUCCESS(Status
))
100 RtlFreeAnsiString(&AName
);
101 if (ExGetPreviousMode() != KernelMode
)
103 RtlFreeUnicodeString(&WName
);
108 ReturnLength
= WValue
.Length
;
111 * Copy the result back to the caller.
113 if (ExGetPreviousMode() != KernelMode
)
115 Status
= MmCopyToCaller(UnsafeValue
, WValue
.Buffer
, ReturnLength
);
116 if (!NT_SUCCESS(Status
))
118 RtlFreeAnsiString(&AName
);
119 if (ExGetPreviousMode() != KernelMode
)
121 RtlFreeUnicodeString(&WName
);
124 RtlFreeUnicodeString(&WValue
);
128 Status
= MmCopyToCaller(UnsafeReturnLength
, &ReturnLength
,
130 if (!NT_SUCCESS(Status
))
132 RtlFreeAnsiString(&AName
);
133 if (ExGetPreviousMode() != KernelMode
)
135 RtlFreeUnicodeString(&WName
);
138 RtlFreeUnicodeString(&WValue
);
144 memcpy(UnsafeValue
, WValue
.Buffer
, ReturnLength
);
145 memcpy(UnsafeReturnLength
, &ReturnLength
, sizeof(ULONG
));
149 * Free temporary buffers.
151 RtlFreeAnsiString(&AName
);
152 if (ExGetPreviousMode() != KernelMode
)
154 RtlFreeUnicodeString(&WName
);
157 RtlFreeUnicodeString(&WValue
);
159 return(STATUS_SUCCESS
);
164 NtSetSystemEnvironmentValue (IN PUNICODE_STRING UnsafeName
,
165 IN PUNICODE_STRING UnsafeValue
)
167 UNICODE_STRING WName
;
169 UNICODE_STRING WValue
;
175 * Check for required privilege.
177 /* FIXME: Not implemented. */
180 * Copy the name to kernel space if necessary and convert it to ANSI.
182 if (ExGetPreviousMode() != KernelMode
)
184 Status
= RtlCaptureUnicodeString(&WName
, UnsafeName
);
185 if (!NT_SUCCESS(Status
))
189 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
190 if (!NT_SUCCESS(Status
))
197 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
198 if (!NT_SUCCESS(Status
))
205 * Copy the value to kernel space and convert to ANSI.
207 if (ExGetPreviousMode() != KernelMode
)
209 Status
= RtlCaptureUnicodeString(&WValue
, UnsafeValue
);
210 if (!NT_SUCCESS(Status
))
212 RtlFreeUnicodeString(&WName
);
213 RtlFreeAnsiString(&AName
);
216 Status
= RtlUnicodeStringToAnsiString(&AValue
, UnsafeValue
, TRUE
);
217 if (!NT_SUCCESS(Status
))
219 RtlFreeUnicodeString(&WName
);
220 RtlFreeAnsiString(&AName
);
221 RtlFreeUnicodeString(&WValue
);
227 Status
= RtlUnicodeStringToAnsiString(&AValue
, UnsafeValue
, TRUE
);
228 if (!NT_SUCCESS(Status
))
230 RtlFreeAnsiString(&AName
);
236 * Set the environment variable
238 Result
= HalSetEnvironmentVariable(AName
.Buffer
, AValue
.Buffer
);
241 * Free everything and return status.
243 RtlFreeAnsiString(&AName
);
244 RtlFreeAnsiString(&AValue
);
245 if (ExGetPreviousMode() != KernelMode
)
247 RtlFreeUnicodeString(&WName
);
248 RtlFreeUnicodeString(&WValue
);
253 return(STATUS_UNSUCCESSFUL
);
255 return(STATUS_SUCCESS
);
259 /* --- Query/Set System Information --- */
263 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
264 * so the stack is popped only in one place on x86 platform.
266 #define QSI_USE(n) QSI##n
268 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
270 #define SSI_USE(n) SSI##n
272 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
274 /* Class 0 - Basic Information */
275 QSI_DEF(SystemBasicInformation
)
277 PSYSTEM_BASIC_INFORMATION Sbi
278 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
280 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
282 * Check user buffer's size
284 if (Size
< sizeof (SYSTEM_BASIC_INFORMATION
))
286 return (STATUS_INFO_LENGTH_MISMATCH
);
290 Sbi
->MaximumIncrement
= 0; /* FIXME */
291 Sbi
->PhysicalPageSize
= PAGE_SIZE
;
292 Sbi
->NumberOfPhysicalPages
= 0; /* FIXME */
293 Sbi
->LowestPhysicalPage
= 0; /* FIXME */
294 Sbi
->HighestPhysicalPage
= 0; /* FIXME */
295 Sbi
->AllocationGranularity
= 65536; /* hard coded on Intel? */
296 Sbi
->LowestUserAddress
= 0; /* FIXME */
297 Sbi
->HighestUserAddress
= 0; /* FIXME */
298 Sbi
->ActiveProcessors
= 0x00000001; /* FIXME */
299 Sbi
->NumberProcessors
= 1; /* FIXME */
301 return (STATUS_SUCCESS
);
304 /* Class 1 - Processor Information */
305 QSI_DEF(SystemProcessorInformation
)
307 PSYSTEM_PROCESSOR_INFORMATION Spi
308 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
310 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
312 * Check user buffer's size
314 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
316 return (STATUS_INFO_LENGTH_MISMATCH
);
319 /* FIXME: add CPU type detection code */
320 Spi
->ProcessorArchitecture
= 0; /* FIXME */
321 Spi
->ProcessorLevel
= 0; /* FIXME */
322 Spi
->ProcessorRevision
= 0; /* FIXME */
324 Spi
->FeatureBits
= 0x00000000; /* FIXME */
326 return (STATUS_SUCCESS
);
329 /* Class 2 - Performance Information */
330 QSI_DEF(SystemPerformanceInformation
)
332 PSYSTEM_PERFORMANCE_INFORMATION Spi
333 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
335 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
337 * Check user buffer's size
339 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
341 return (STATUS_INFO_LENGTH_MISMATCH
);
344 Spi
->IdleTime
.QuadPart
= 0; /* FIXME */
345 Spi
->ReadTransferCount
.QuadPart
= 0; /* FIXME */
346 Spi
->WriteTransferCount
.QuadPart
= 0; /* FIXME */
347 Spi
->OtherTransferCount
.QuadPart
= 0; /* FIXME */
348 Spi
->ReadOperationCount
= 0; /* FIXME */
349 Spi
->WriteOperationCount
= 0; /* FIXME */
350 Spi
->OtherOperationCount
= 0; /* FIXME */
351 Spi
->AvailablePages
= 0; /* FIXME */
352 Spi
->TotalCommittedPages
= 0; /* FIXME */
353 Spi
->TotalCommitLimit
= 0; /* FIXME */
354 Spi
->PeakCommitment
= 0; /* FIXME */
355 Spi
->PageFaults
= 0; /* FIXME */
356 Spi
->WriteCopyFaults
= 0; /* FIXME */
357 Spi
->TransitionFaults
= 0; /* FIXME */
358 Spi
->CacheTransitionFaults
= 0; /* FIXME */
359 Spi
->DemandZeroFaults
= 0; /* FIXME */
360 Spi
->PagesRead
= 0; /* FIXME */
361 Spi
->PageReadIos
= 0; /* FIXME */
362 Spi
->CacheReads
= 0; /* FIXME */
363 Spi
->CacheIos
= 0; /* FIXME */
364 Spi
->PagefilePagesWritten
= 0; /* FIXME */
365 Spi
->PagefilePageWriteIos
= 0; /* FIXME */
366 Spi
->MappedFilePagesWritten
= 0; /* FIXME */
367 Spi
->MappedFilePageWriteIos
= 0; /* FIXME */
368 Spi
->PagedPoolUsage
= 0; /* FIXME */
369 Spi
->NonPagedPoolUsage
= 0; /* FIXME */
370 Spi
->PagedPoolAllocs
= 0; /* FIXME */
371 Spi
->PagedPoolFrees
= 0; /* FIXME */
372 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
373 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
374 Spi
->TotalFreeSystemPtes
= 0; /* FIXME */
375 Spi
->SystemCodePage
= 0; /* FIXME */
376 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
377 Spi
->TotalSystemCodePages
= 0; /* FIXME */
378 Spi
->SmallNonPagedLookasideListAllocateHits
= 0; /* FIXME */
379 Spi
->SmallPagedLookasideListAllocateHits
= 0; /* FIXME */
380 Spi
->Reserved3
= 0; /* FIXME */
381 Spi
->MmSystemCachePage
= 0; /* FIXME */
382 Spi
->PagedPoolPage
= 0; /* FIXME */
383 Spi
->SystemDriverPage
= 0; /* FIXME */
384 Spi
->FastReadNoWait
= 0; /* FIXME */
385 Spi
->FastReadWait
= 0; /* FIXME */
386 Spi
->FastReadResourceMiss
= 0; /* FIXME */
387 Spi
->FastReadNotPossible
= 0; /* FIXME */
388 Spi
->FastMdlReadNoWait
= 0; /* FIXME */
389 Spi
->FastMdlReadWait
= 0; /* FIXME */
390 Spi
->FastMdlReadResourceMiss
= 0; /* FIXME */
391 Spi
->FastMdlReadNotPossible
= 0; /* FIXME */
392 Spi
->MapDataNoWait
= 0; /* FIXME */
393 Spi
->MapDataWait
= 0; /* FIXME */
394 Spi
->MapDataNoWaitMiss
= 0; /* FIXME */
395 Spi
->MapDataWaitMiss
= 0; /* FIXME */
396 Spi
->PinMappedDataCount
= 0; /* FIXME */
397 Spi
->PinReadNoWait
= 0; /* FIXME */
398 Spi
->PinReadWait
= 0; /* FIXME */
399 Spi
->PinReadNoWaitMiss
= 0; /* FIXME */
400 Spi
->PinReadWaitMiss
= 0; /* FIXME */
401 Spi
->CopyReadNoWait
= 0; /* FIXME */
402 Spi
->CopyReadWait
= 0; /* FIXME */
403 Spi
->CopyReadNoWaitMiss
= 0; /* FIXME */
404 Spi
->CopyReadWaitMiss
= 0; /* FIXME */
405 Spi
->MdlReadNoWait
= 0; /* FIXME */
406 Spi
->MdlReadWait
= 0; /* FIXME */
407 Spi
->MdlReadNoWaitMiss
= 0; /* FIXME */
408 Spi
->MdlReadWaitMiss
= 0; /* FIXME */
409 Spi
->ReadAheadIos
= 0; /* FIXME */
410 Spi
->LazyWriteIos
= 0; /* FIXME */
411 Spi
->LazyWritePages
= 0; /* FIXME */
412 Spi
->DataFlushes
= 0; /* FIXME */
413 Spi
->DataPages
= 0; /* FIXME */
414 Spi
->ContextSwitches
= 0; /* FIXME */
415 Spi
->FirstLevelTbFills
= 0; /* FIXME */
416 Spi
->SecondLevelTbFills
= 0; /* FIXME */
417 Spi
->SystemCalls
= 0; /* FIXME */
419 return (STATUS_SUCCESS
);
422 /* Class 3 - Time Of Day Information */
423 QSI_DEF(SystemTimeOfDayInformation
)
425 PSYSTEM_TIMEOFDAY_INFORMATION Sti
426 = (PSYSTEM_TIMEOFDAY_INFORMATION
) Buffer
;
428 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
430 * Check user buffer's size
432 if (Size
< sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
434 return (STATUS_INFO_LENGTH_MISMATCH
);
437 Sti
->BootTime
.QuadPart
= 0; /* FIXME */
438 Sti
->CurrentTime
.QuadPart
= 0; /* FIXME */
439 Sti
->TimeZoneBias
.QuadPart
= 0; /* FIXME */
440 Sti
->TimeZoneId
= 0; /* FIXME */
441 Sti
->Reserved
= 0; /* FIXME */
443 return (STATUS_SUCCESS
);
446 /* Class 4 - Path Information */
447 QSI_DEF(SystemPathInformation
)
449 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
450 return (STATUS_BREAKPOINT
);
453 /* Class 5 - Process Information */
454 QSI_DEF(SystemProcessInformation
)
456 /* FIXME: scan the process+thread list */
457 return (STATUS_NOT_IMPLEMENTED
);
460 /* Class 6 - Call Count Information */
461 QSI_DEF(SystemCallCountInformation
)
464 return (STATUS_NOT_IMPLEMENTED
);
467 /* Class 7 - Device Information */
468 QSI_DEF(SystemDeviceInformation
)
470 PSYSTEM_DEVICE_INFORMATION Sdi
471 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
472 PCONFIGURATION_INFORMATION ConfigInfo
;
474 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
476 * Check user buffer's size
478 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
480 return (STATUS_INFO_LENGTH_MISMATCH
);
483 ConfigInfo
= IoGetConfigurationInformation ();
485 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
486 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
487 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
488 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
489 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
490 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
492 return (STATUS_SUCCESS
);
495 /* Class 8 - Processor Performance Information */
496 QSI_DEF(SystemProcessorPerformanceInformation
)
499 return (STATUS_NOT_IMPLEMENTED
);
502 /* Class 9 - Flags Information */
503 QSI_DEF(SystemFlagsInformation
)
505 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
507 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
508 return (STATUS_INFO_LENGTH_MISMATCH
);
510 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
511 return (STATUS_SUCCESS
);
514 SSI_DEF(SystemFlagsInformation
)
516 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
518 return (STATUS_INFO_LENGTH_MISMATCH
);
520 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
521 return (STATUS_SUCCESS
);
524 /* Class 10 - Call Time Information */
525 QSI_DEF(SystemCallTimeInformation
)
528 return (STATUS_NOT_IMPLEMENTED
);
531 /* Class 11 - Module Information */
532 QSI_DEF(SystemModuleInformation
)
534 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
537 /* Class 12 - Locks Information */
538 QSI_DEF(SystemLocksInformation
)
541 return (STATUS_NOT_IMPLEMENTED
);
544 /* Class 13 - Stack Trace Information */
545 QSI_DEF(SystemStackTraceInformation
)
548 return (STATUS_NOT_IMPLEMENTED
);
551 /* Class 14 - Paged Pool Information */
552 QSI_DEF(SystemPagedPoolInformation
)
555 return (STATUS_NOT_IMPLEMENTED
);
558 /* Class 15 - Non Paged Pool Information */
559 QSI_DEF(SystemNonPagedPoolInformation
)
562 return (STATUS_NOT_IMPLEMENTED
);
565 /* Class 16 - Handle Information */
566 QSI_DEF(SystemHandleInformation
)
569 return (STATUS_NOT_IMPLEMENTED
);
572 /* Class 17 - Information */
573 QSI_DEF(SystemObjectInformation
)
576 return (STATUS_NOT_IMPLEMENTED
);
579 /* Class 18 - Information */
580 QSI_DEF(SystemPageFileInformation
)
583 return (STATUS_NOT_IMPLEMENTED
);
586 /* Class 19 - Vdm Instemul Information */
587 QSI_DEF(SystemVdmInstemulInformation
)
590 return (STATUS_NOT_IMPLEMENTED
);
593 /* Class 20 - Vdm Bop Information */
594 QSI_DEF(SystemVdmBopInformation
)
597 return (STATUS_NOT_IMPLEMENTED
);
600 /* Class 21 - File Cache Information */
601 QSI_DEF(SystemFileCacheInformation
)
603 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
605 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
606 return (STATUS_INFO_LENGTH_MISMATCH
);
609 return (STATUS_NOT_IMPLEMENTED
);
612 SSI_DEF(SystemFileCacheInformation
)
614 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
616 return (STATUS_INFO_LENGTH_MISMATCH
);
619 return (STATUS_NOT_IMPLEMENTED
);
622 /* Class 22 - Pool Tag Information */
623 QSI_DEF(SystemPoolTagInformation
)
626 return (STATUS_NOT_IMPLEMENTED
);
629 /* Class 23 - Interrupt Information */
630 QSI_DEF(SystemInterruptInformation
)
633 return (STATUS_NOT_IMPLEMENTED
);
636 /* Class 24 - DPC Behaviour Information */
637 QSI_DEF(SystemDpcBehaviourInformation
)
640 return (STATUS_NOT_IMPLEMENTED
);
643 SSI_DEF(SystemDpcBehaviourInformation
)
646 return (STATUS_NOT_IMPLEMENTED
);
649 /* Class 25 - Full Memory Information */
650 QSI_DEF(SystemFullMemoryInformation
)
653 return (STATUS_NOT_IMPLEMENTED
);
656 /* Class 26 - Load Image */
657 SSI_DEF(SystemLoadImage
)
659 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
661 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
663 return(STATUS_INFO_LENGTH_MISMATCH
);
666 return(LdrpLoadImage(&Sli
->ModuleName
,
668 &Sli
->SectionPointer
,
670 &Sli
->ExportDirectory
));
673 /* Class 27 - Unload Image */
674 SSI_DEF(SystemUnloadImage
)
676 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
678 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
680 return(STATUS_INFO_LENGTH_MISMATCH
);
683 return(LdrpUnloadImage(Sui
->ModuleBase
));
686 /* Class 28 - Time Adjustment Information */
687 QSI_DEF(SystemTimeAdjustmentInformation
)
689 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
691 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
692 return (STATUS_INFO_LENGTH_MISMATCH
);
695 return (STATUS_NOT_IMPLEMENTED
);
698 SSI_DEF(SystemTimeAdjustmentInformation
)
700 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
702 return (STATUS_INFO_LENGTH_MISMATCH
);
705 return (STATUS_NOT_IMPLEMENTED
);
708 /* Class 29 - Summary Memory Information */
709 QSI_DEF(SystemSummaryMemoryInformation
)
712 return (STATUS_NOT_IMPLEMENTED
);
715 /* Class 30 - Next Event Id Information */
716 QSI_DEF(SystemNextEventIdInformation
)
719 return (STATUS_NOT_IMPLEMENTED
);
722 /* Class 31 - Event Ids Information */
723 QSI_DEF(SystemEventIdsInformation
)
726 return (STATUS_NOT_IMPLEMENTED
);
729 /* Class 32 - Crach Dump Information */
730 QSI_DEF(SystemCrashDumpInformation
)
733 return (STATUS_NOT_IMPLEMENTED
);
736 /* Class 33 - Exception Information */
737 QSI_DEF(SystemExceptionInformation
)
740 return (STATUS_NOT_IMPLEMENTED
);
743 /* Class 34 - Crach Dump State Information */
744 QSI_DEF(SystemCrashDumpStateInformation
)
747 return (STATUS_NOT_IMPLEMENTED
);
750 /* Class 35 - Kernel Debugger Information */
751 QSI_DEF(SystemKernelDebuggerInformation
)
754 return (STATUS_NOT_IMPLEMENTED
);
757 /* Class 36 - Context Switch Information */
758 QSI_DEF(SystemContextSwitchInformation
)
761 return (STATUS_NOT_IMPLEMENTED
);
764 /* Class 37 - Registry Quota Information */
765 QSI_DEF(SystemRegistryQuotaInformation
)
768 return (STATUS_NOT_IMPLEMENTED
);
771 SSI_DEF(SystemRegistryQuotaInformation
)
774 return (STATUS_NOT_IMPLEMENTED
);
777 /* Class 38 - Load And Call Image */
778 SSI_DEF(SystemLoadAndCallImage
)
780 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
782 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
784 return(STATUS_INFO_LENGTH_MISMATCH
);
787 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
790 /* Class 39 - Priority Seperation */
791 SSI_DEF(SystemPrioritySeperation
)
794 return (STATUS_NOT_IMPLEMENTED
);
797 /* Class 40 - Plug Play Bus Information */
798 QSI_DEF(SystemPlugPlayBusInformation
)
801 return (STATUS_NOT_IMPLEMENTED
);
804 /* Class 41 - Dock Information */
805 QSI_DEF(SystemDockInformation
)
808 return (STATUS_NOT_IMPLEMENTED
);
811 /* Class 42 - Power Information */
812 QSI_DEF(SystemPowerInformation
)
815 return (STATUS_NOT_IMPLEMENTED
);
818 /* Class 43 - Processor Speed Information */
819 QSI_DEF(SystemProcessorSpeedInformation
)
822 return (STATUS_NOT_IMPLEMENTED
);
825 /* Class 44 - Current Time Zone Information */
826 QSI_DEF(SystemCurrentTimeZoneInformation
)
828 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
830 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
832 return (STATUS_INFO_LENGTH_MISMATCH
);
834 /* Copy the time zone information struct */
837 & SystemTimeZoneInfo
,
838 sizeof (TIME_ZONE_INFORMATION
)
841 return (STATUS_SUCCESS
);
845 SSI_DEF(SystemCurrentTimeZoneInformation
)
848 * Check user buffer's size
850 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
852 return (STATUS_INFO_LENGTH_MISMATCH
);
854 /* Copy the time zone information struct */
856 & SystemTimeZoneInfo
,
857 (TIME_ZONE_INFORMATION
*) Buffer
,
858 sizeof (TIME_ZONE_INFORMATION
)
860 return (STATUS_SUCCESS
);
864 /* Class 45 - Lookaside Information */
865 QSI_DEF(SystemLookasideInformation
)
868 return (STATUS_NOT_IMPLEMENTED
);
872 /* Class 46 - Set time slip event */
873 SSI_DEF(SystemSetTimeSlipEvent
)
876 return (STATUS_NOT_IMPLEMENTED
);
880 /* Class 47 - Create a new session (TSE) */
881 SSI_DEF(SystemCreateSession
)
884 return (STATUS_NOT_IMPLEMENTED
);
888 /* Class 48 - Delete an existing session (TSE) */
889 SSI_DEF(SystemDeleteSession
)
892 return (STATUS_NOT_IMPLEMENTED
);
896 /* Class 49 - UNKNOWN */
897 QSI_DEF(SystemInvalidInfoClass4
)
900 return (STATUS_NOT_IMPLEMENTED
);
904 /* Class 50 - System range start address */
905 QSI_DEF(SystemRangeStartInformation
)
908 return (STATUS_NOT_IMPLEMENTED
);
912 /* Class 51 - Driver verifier information */
913 QSI_DEF(SystemVerifierInformation
)
916 return (STATUS_NOT_IMPLEMENTED
);
920 SSI_DEF(SystemVerifierInformation
)
923 return (STATUS_NOT_IMPLEMENTED
);
927 /* Class 52 - Add a driver verifier */
928 SSI_DEF(SystemAddVerifier
)
931 return (STATUS_NOT_IMPLEMENTED
);
935 /* Class 53 - A session's processes */
936 QSI_DEF(SystemSessionProcessesInformation
)
939 return (STATUS_NOT_IMPLEMENTED
);
943 /* Query/Set Calls Table */
947 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
948 NTSTATUS (* Set
) (PVOID
,ULONG
);
955 // XX unknown behaviour
957 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
958 #define SI_QX(n) {QSI_USE(n),NULL}
959 #define SI_XS(n) {NULL,SSI_USE(n)}
960 #define SI_XX(n) {NULL,NULL}
966 SI_QX(SystemBasicInformation
),
967 SI_QX(SystemProcessorInformation
),
968 SI_QX(SystemPerformanceInformation
),
969 SI_QX(SystemTimeOfDayInformation
),
970 SI_QX(SystemPathInformation
), /* should be SI_XX */
971 SI_QX(SystemProcessInformation
),
972 SI_QX(SystemCallCountInformation
),
973 SI_QX(SystemDeviceInformation
),
974 SI_QX(SystemProcessorPerformanceInformation
),
975 SI_QS(SystemFlagsInformation
),
976 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
977 SI_QX(SystemModuleInformation
),
978 SI_QX(SystemLocksInformation
),
979 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
980 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
981 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
982 SI_QX(SystemHandleInformation
),
983 SI_QX(SystemObjectInformation
),
984 SI_QX(SystemPageFileInformation
),
985 SI_QX(SystemVdmInstemulInformation
),
986 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
987 SI_QS(SystemFileCacheInformation
),
988 SI_QX(SystemPoolTagInformation
),
989 SI_QX(SystemInterruptInformation
),
990 SI_QS(SystemDpcBehaviourInformation
),
991 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
992 SI_XS(SystemLoadImage
),
993 SI_XS(SystemUnloadImage
),
994 SI_QS(SystemTimeAdjustmentInformation
),
995 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
996 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
997 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
998 SI_QX(SystemCrashDumpInformation
),
999 SI_QX(SystemExceptionInformation
),
1000 SI_QX(SystemCrashDumpStateInformation
),
1001 SI_QX(SystemKernelDebuggerInformation
),
1002 SI_QX(SystemContextSwitchInformation
),
1003 SI_QS(SystemRegistryQuotaInformation
),
1004 SI_XS(SystemLoadAndCallImage
),
1005 SI_XS(SystemPrioritySeperation
),
1006 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1007 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1008 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1009 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1010 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1011 SI_QX(SystemLookasideInformation
),
1012 SI_XS(SystemSetTimeSlipEvent
),
1013 SI_XS(SystemCreateSession
),
1014 SI_XS(SystemDeleteSession
),
1015 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1016 SI_QX(SystemRangeStartInformation
),
1017 SI_QS(SystemVerifierInformation
),
1018 SI_XS(SystemAddVerifier
),
1019 SI_QX(SystemSessionProcessesInformation
)
1024 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1025 OUT PVOID UnsafeSystemInformation
,
1027 OUT PULONG UnsafeResultLength
)
1030 PVOID SystemInformation
;
1034 if (ExGetPreviousMode() == KernelMode
)
1036 SystemInformation
= UnsafeSystemInformation
;
1040 SystemInformation
= ExAllocatePool(NonPagedPool
, Length
);
1041 if (SystemInformation
== NULL
)
1043 return(STATUS_NO_MEMORY
);
1047 /* Clear user buffer. */
1048 RtlZeroMemory(SystemInformation
, Length
);
1051 * Check the request is valid.
1053 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1054 (SystemInformationClass
< SystemInformationClassMax
))
1056 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1059 * Hand the request to a subhandler.
1061 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1064 if (ExGetPreviousMode() != KernelMode
)
1066 Status
= MmCopyToCaller(UnsafeSystemInformation
,
1069 ExFreePool(SystemInformation
);
1070 if (!NT_SUCCESS(Status
))
1075 if (UnsafeResultLength
!= NULL
)
1077 if (ExGetPreviousMode() == KernelMode
)
1079 *UnsafeResultLength
= ResultLength
;
1083 Status
= MmCopyToCaller(UnsafeResultLength
,
1086 if (!NT_SUCCESS(Status
))
1095 return (STATUS_INVALID_INFO_CLASS
);
1101 NtSetSystemInformation (
1102 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1103 IN PVOID SystemInformation
,
1104 IN ULONG SystemInformationLength
1108 * If called from user mode, check
1109 * possible unsafe arguments.
1112 if (KernelMode
!= KeGetPreviousMode())
1116 // SystemInformation,
1126 * Check the request is valid.
1128 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1129 && (SystemInformationClass
< SystemInformationClassMax
)
1132 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1135 * Hand the request to a subhandler.
1137 return CallQS
[SystemInformationClass
].Set (
1139 SystemInformationLength
1143 return (STATUS_INVALID_INFO_CLASS
);
1149 NtFlushInstructionCache (
1150 IN HANDLE ProcessHandle
,
1151 IN PVOID BaseAddress
,
1152 IN UINT NumberOfBytesToFlush