3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/sysinfo.c
6 * PURPOSE: System information functions
8 * PROGRAMMERS: David Welch (welch@mcmail.com)
9 * Aleksey Bragin (aleksey@studiocerebral.com)
12 /* INCLUDES *****************************************************************/
16 #include <internal/debug.h>
18 extern ULONG NtGlobalFlag
; /* FIXME: it should go in a ddk/?.h */
19 ULONGLONG STDCALL
KeQueryInterruptTime(VOID
);
21 VOID
MmPrintMemoryStatistic(VOID
);
23 /* FUNCTIONS *****************************************************************/
34 PHANDLE Handle OPTIONAL
45 ExGetCurrentProcessorCpuUsage (
51 ULONG PercentTime
= 0;
54 Pcr
= KeGetCurrentKPCR();
56 ScaledIdle
= Pcr
->PrcbData
.IdleThread
->KernelTime
* 100;
57 TotalTime
= Pcr
->PrcbData
.KernelTime
+ Pcr
->PrcbData
.UserTime
;
58 if (TotalTime
) PercentTime
= 100 - (ScaledIdle
/ TotalTime
);
59 CpuUsage
= &PercentTime
;
67 ExGetCurrentProcessorCounts (
68 PULONG ThreadKernelTime
,
70 PULONG ProcessorNumber
78 Pcr
= KeGetCurrentKPCR();
80 TotalTime
= Pcr
->PrcbData
.KernelTime
+ Pcr
->PrcbData
.UserTime
;
81 ThreadTime
= Pcr
->PrcbData
.CurrentThread
->KernelTime
;
82 ProcNumber
= Pcr
->ProcessorNumber
;
84 ThreadKernelTime
= &ThreadTime
;
85 TotalCpuTime
= &TotalTime
;
86 ProcessorNumber
= &ProcNumber
;
90 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
91 OUT PWCHAR ValueBuffer
,
92 IN ULONG ValueBufferLength
,
93 IN OUT PULONG ReturnLength OPTIONAL
)
100 UNICODE_STRING WValue
;
101 KPROCESSOR_MODE PreviousMode
;
102 NTSTATUS Status
= STATUS_SUCCESS
;
106 PreviousMode
= ExGetPreviousMode();
108 if(PreviousMode
!= KernelMode
)
112 ProbeForRead(VariableName
,
113 sizeof(UNICODE_STRING
),
115 ProbeForWrite(ValueBuffer
,
118 if(ReturnLength
!= NULL
)
120 ProbeForWrite(ReturnLength
,
127 Status
= _SEH_GetExceptionCode();
131 if(!NT_SUCCESS(Status
))
138 * Copy the name to kernel space if necessary and convert it to ANSI.
140 Status
= RtlCaptureUnicodeString(&WName
,
145 if(NT_SUCCESS(Status
))
148 * according to ntinternals the SeSystemEnvironmentName privilege is required!
150 if(!SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
153 RtlReleaseCapturedUnicodeString(&WName
,
156 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
157 return STATUS_PRIVILEGE_NOT_HELD
;
161 * convert the value name to ansi
163 Status
= RtlUnicodeStringToAnsiString(&AName
, &WName
, TRUE
);
164 RtlReleaseCapturedUnicodeString(&WName
,
167 if(!NT_SUCCESS(Status
))
173 * Create a temporary buffer for the value
175 Value
= ExAllocatePool(NonPagedPool
, ValueBufferLength
);
178 RtlFreeAnsiString(&AName
);
179 return STATUS_INSUFFICIENT_RESOURCES
;
183 * Get the environment variable
185 Result
= HalGetEnvironmentVariable(AName
.Buffer
, Value
, ValueBufferLength
);
188 RtlFreeAnsiString(&AName
);
190 return STATUS_UNSUCCESSFUL
;
194 * Convert the result to UNICODE, protect with SEH in case the value buffer
195 * isn't NULL-terminated!
199 RtlInitAnsiString(&AValue
, Value
);
200 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
204 Status
= _SEH_GetExceptionCode();
208 if(NT_SUCCESS(Status
))
211 * Copy the result back to the caller.
215 RtlCopyMemory(ValueBuffer
, WValue
.Buffer
, WValue
.Length
);
216 ValueBuffer
[WValue
.Length
/ sizeof(WCHAR
)] = L
'\0';
217 if(ReturnLength
!= NULL
)
219 *ReturnLength
= WValue
.Length
+ sizeof(WCHAR
);
222 Status
= STATUS_SUCCESS
;
226 Status
= _SEH_GetExceptionCode();
232 * Cleanup allocated resources.
234 RtlFreeAnsiString(&AName
);
243 NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
244 IN PUNICODE_STRING Value
)
246 UNICODE_STRING CapturedName
, CapturedValue
;
247 ANSI_STRING AName
, AValue
;
248 KPROCESSOR_MODE PreviousMode
;
253 PreviousMode
= ExGetPreviousMode();
256 * Copy the strings to kernel space if necessary
258 Status
= RtlCaptureUnicodeString(&CapturedName
,
263 if(NT_SUCCESS(Status
))
265 Status
= RtlCaptureUnicodeString(&CapturedValue
,
270 if(NT_SUCCESS(Status
))
273 * according to ntinternals the SeSystemEnvironmentName privilege is required!
275 if(SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
279 * convert the strings to ANSI
281 Status
= RtlUnicodeStringToAnsiString(&AName
,
284 if(NT_SUCCESS(Status
))
286 Status
= RtlUnicodeStringToAnsiString(&AValue
,
289 if(NT_SUCCESS(Status
))
291 BOOLEAN Result
= HalSetEnvironmentVariable(AName
.Buffer
,
294 Status
= (Result
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);
300 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
301 Status
= STATUS_PRIVILEGE_NOT_HELD
;
304 RtlReleaseCapturedUnicodeString(&CapturedValue
,
309 RtlReleaseCapturedUnicodeString(&CapturedName
,
318 /* --- Query/Set System Information --- */
321 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
322 * so the stack is popped only in one place on x86 platform.
324 #define QSI_USE(n) QSI##n
326 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
328 #define SSI_USE(n) SSI##n
330 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
333 /* Class 0 - Basic Information */
334 QSI_DEF(SystemBasicInformation
)
336 PSYSTEM_BASIC_INFORMATION Sbi
337 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
339 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
341 * Check user buffer's size
343 if (Size
< sizeof (SYSTEM_BASIC_INFORMATION
))
345 return (STATUS_INFO_LENGTH_MISMATCH
);
348 Sbi
->MaximumIncrement
= KeMaximumIncrement
;
349 Sbi
->PhysicalPageSize
= PAGE_SIZE
;
350 Sbi
->NumberOfPhysicalPages
= MmStats
.NrTotalPages
;
351 Sbi
->LowestPhysicalPage
= 0; /* FIXME */
352 Sbi
->HighestPhysicalPage
= MmStats
.NrTotalPages
; /* FIXME */
353 Sbi
->AllocationGranularity
= MM_VIRTMEM_GRANULARITY
; /* hard coded on Intel? */
354 Sbi
->LowestUserAddress
= 0x10000; /* Top of 64k */
355 Sbi
->HighestUserAddress
= (ULONG_PTR
)MmHighestUserAddress
;
356 Sbi
->ActiveProcessors
= KeActiveProcessors
;
357 Sbi
->NumberProcessors
= KeNumberProcessors
;
358 return (STATUS_SUCCESS
);
361 /* Class 1 - Processor Information */
362 QSI_DEF(SystemProcessorInformation
)
364 PSYSTEM_PROCESSOR_INFORMATION Spi
365 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
367 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
369 * Check user buffer's size
371 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
373 return (STATUS_INFO_LENGTH_MISMATCH
);
375 Pcr
= KeGetCurrentKPCR();
376 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
377 Spi
->ProcessorLevel
= Pcr
->PrcbData
.CpuType
;
378 Spi
->ProcessorRevision
= Pcr
->PrcbData
.CpuStep
;
380 Spi
->FeatureBits
= Pcr
->PrcbData
.FeatureBits
;
382 DPRINT("Arch %d Level %d Rev 0x%x\n", Spi
->ProcessorArchitecture
,
383 Spi
->ProcessorLevel
, Spi
->ProcessorRevision
);
385 return (STATUS_SUCCESS
);
388 /* Class 2 - Performance Information */
389 QSI_DEF(SystemPerformanceInformation
)
391 PSYSTEM_PERFORMANCE_INFORMATION Spi
392 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
394 PEPROCESS TheIdleProcess
;
396 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
398 * Check user buffer's size
400 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
402 return (STATUS_INFO_LENGTH_MISMATCH
);
405 TheIdleProcess
= PsInitialSystemProcess
; /* FIXME */
407 Spi
->IdleTime
.QuadPart
= TheIdleProcess
->Pcb
.KernelTime
* 100000LL;
409 Spi
->ReadTransferCount
.QuadPart
= IoReadTransferCount
;
410 Spi
->WriteTransferCount
.QuadPart
= IoWriteTransferCount
;
411 Spi
->OtherTransferCount
.QuadPart
= IoOtherTransferCount
;
412 Spi
->ReadOperationCount
= IoReadOperationCount
;
413 Spi
->WriteOperationCount
= IoWriteOperationCount
;
414 Spi
->OtherOperationCount
= IoOtherOperationCount
;
416 Spi
->AvailablePages
= MmStats
.NrFreePages
;
418 Add up all the used "Commitied" memory + pagefile.
419 Not sure this is right. 8^\
421 Spi
->TotalCommittedPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
+
422 MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
+
423 MiMemoryConsumers
[MC_CACHE
].PagesUsed
+
424 MiMemoryConsumers
[MC_USER
].PagesUsed
+
427 Add up the full system total + pagefile.
428 All this make Taskmgr happy but not sure it is the right numbers.
429 This too, fixes some of GlobalMemoryStatusEx numbers.
431 Spi
->TotalCommitLimit
= MmStats
.NrTotalPages
+ MiFreeSwapPages
+
434 Spi
->PeakCommitment
= 0; /* FIXME */
435 Spi
->PageFaults
= 0; /* FIXME */
436 Spi
->WriteCopyFaults
= 0; /* FIXME */
437 Spi
->TransitionFaults
= 0; /* FIXME */
438 Spi
->CacheTransitionFaults
= 0; /* FIXME */
439 Spi
->DemandZeroFaults
= 0; /* FIXME */
440 Spi
->PagesRead
= 0; /* FIXME */
441 Spi
->PageReadIos
= 0; /* FIXME */
442 Spi
->CacheReads
= 0; /* FIXME */
443 Spi
->CacheIos
= 0; /* FIXME */
444 Spi
->PagefilePagesWritten
= 0; /* FIXME */
445 Spi
->PagefilePageWriteIos
= 0; /* FIXME */
446 Spi
->MappedFilePagesWritten
= 0; /* FIXME */
447 Spi
->MappedFilePageWriteIos
= 0; /* FIXME */
449 Spi
->PagedPoolUsage
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
;
450 Spi
->PagedPoolAllocs
= 0; /* FIXME */
451 Spi
->PagedPoolFrees
= 0; /* FIXME */
452 Spi
->NonPagedPoolUsage
= MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
;
453 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
454 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
456 Spi
->TotalFreeSystemPtes
= 0; /* FIXME */
458 Spi
->SystemCodePage
= MmStats
.NrSystemPages
; /* FIXME */
460 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
461 Spi
->TotalSystemCodePages
= 0; /* FIXME */
462 Spi
->SmallNonPagedLookasideListAllocateHits
= 0; /* FIXME */
463 Spi
->SmallPagedLookasideListAllocateHits
= 0; /* FIXME */
464 Spi
->Reserved3
= 0; /* FIXME */
466 Spi
->MmSystemCachePage
= MiMemoryConsumers
[MC_CACHE
].PagesUsed
;
467 Spi
->PagedPoolPage
= MmPagedPoolSize
; /* FIXME */
469 Spi
->SystemDriverPage
= 0; /* FIXME */
470 Spi
->FastReadNoWait
= 0; /* FIXME */
471 Spi
->FastReadWait
= 0; /* FIXME */
472 Spi
->FastReadResourceMiss
= 0; /* FIXME */
473 Spi
->FastReadNotPossible
= 0; /* FIXME */
475 Spi
->FastMdlReadNoWait
= 0; /* FIXME */
476 Spi
->FastMdlReadWait
= 0; /* FIXME */
477 Spi
->FastMdlReadResourceMiss
= 0; /* FIXME */
478 Spi
->FastMdlReadNotPossible
= 0; /* FIXME */
480 Spi
->MapDataNoWait
= 0; /* FIXME */
481 Spi
->MapDataWait
= 0; /* FIXME */
482 Spi
->MapDataNoWaitMiss
= 0; /* FIXME */
483 Spi
->MapDataWaitMiss
= 0; /* FIXME */
485 Spi
->PinMappedDataCount
= 0; /* FIXME */
486 Spi
->PinReadNoWait
= 0; /* FIXME */
487 Spi
->PinReadWait
= 0; /* FIXME */
488 Spi
->PinReadNoWaitMiss
= 0; /* FIXME */
489 Spi
->PinReadWaitMiss
= 0; /* FIXME */
490 Spi
->CopyReadNoWait
= 0; /* FIXME */
491 Spi
->CopyReadWait
= 0; /* FIXME */
492 Spi
->CopyReadNoWaitMiss
= 0; /* FIXME */
493 Spi
->CopyReadWaitMiss
= 0; /* FIXME */
495 Spi
->MdlReadNoWait
= 0; /* FIXME */
496 Spi
->MdlReadWait
= 0; /* FIXME */
497 Spi
->MdlReadNoWaitMiss
= 0; /* FIXME */
498 Spi
->MdlReadWaitMiss
= 0; /* FIXME */
499 Spi
->ReadAheadIos
= 0; /* FIXME */
500 Spi
->LazyWriteIos
= 0; /* FIXME */
501 Spi
->LazyWritePages
= 0; /* FIXME */
502 Spi
->DataFlushes
= 0; /* FIXME */
503 Spi
->DataPages
= 0; /* FIXME */
504 Spi
->ContextSwitches
= 0; /* FIXME */
505 Spi
->FirstLevelTbFills
= 0; /* FIXME */
506 Spi
->SecondLevelTbFills
= 0; /* FIXME */
507 Spi
->SystemCalls
= 0; /* FIXME */
509 return (STATUS_SUCCESS
);
512 /* Class 3 - Time Of Day Information */
513 QSI_DEF(SystemTimeOfDayInformation
)
515 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
516 LARGE_INTEGER CurrentTime
;
518 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
519 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
521 /* Check user buffer's size */
522 if (Size
< sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
524 return STATUS_INFO_LENGTH_MISMATCH
;
527 KeQuerySystemTime(&CurrentTime
);
529 Sti
->BootTime
= SystemBootTime
;
530 Sti
->CurrentTime
= CurrentTime
;
531 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
532 Sti
->TimeZoneId
= ExpTimeZoneId
;
535 return STATUS_SUCCESS
;
538 /* Class 4 - Path Information */
539 QSI_DEF(SystemPathInformation
)
541 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
542 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
544 return (STATUS_BREAKPOINT
);
547 /* Class 5 - Process Information */
548 QSI_DEF(SystemProcessInformation
)
550 ULONG ovlSize
=0, nThreads
;
554 /* scan the process list */
556 PSYSTEM_PROCESSES Spi
557 = (PSYSTEM_PROCESSES
) Buffer
;
559 *ReqSize
= sizeof(SYSTEM_PROCESSES
);
561 if (Size
< sizeof(SYSTEM_PROCESSES
))
563 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
566 syspr
= PsGetNextProcess(NULL
);
568 pCur
= (unsigned char *)Spi
;
572 PSYSTEM_PROCESSES SpiCur
;
575 int inLen
=32; // image name len in bytes
576 PLIST_ENTRY current_entry
;
579 SpiCur
= (PSYSTEM_PROCESSES
)pCur
;
581 nThreads
= PsEnumThreadsByProcess(pr
);
583 // size of the structure for every process
584 curSize
= sizeof(SYSTEM_PROCESSES
)-sizeof(SYSTEM_THREADS
)+sizeof(SYSTEM_THREADS
)*nThreads
;
585 ovlSize
+= curSize
+inLen
;
590 ObDereferenceObject(pr
);
592 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
595 // fill system information
596 SpiCur
->NextEntryDelta
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
597 SpiCur
->ThreadCount
= nThreads
;
598 SpiCur
->CreateTime
= pr
->CreateTime
;
599 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
600 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
601 SpiCur
->ProcessName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
602 SpiCur
->ProcessName
.MaximumLength
= inLen
;
603 SpiCur
->ProcessName
.Buffer
= (void*)(pCur
+curSize
);
605 // copy name to the end of the struct
606 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
607 RtlAnsiStringToUnicodeString(&SpiCur
->ProcessName
, &imgName
, FALSE
);
609 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
610 SpiCur
->ProcessId
= pr
->UniqueProcessId
;
611 SpiCur
->InheritedFromProcessId
= pr
->InheritedFromUniqueProcessId
;
612 SpiCur
->HandleCount
= ObpGetHandleCountByHandleTable(&pr
->HandleTable
);
613 SpiCur
->VmCounters
.PeakVirtualSize
= pr
->PeakVirtualSize
;
614 SpiCur
->VmCounters
.VirtualSize
= pr
->VirtualSize
.QuadPart
;
615 SpiCur
->VmCounters
.PageFaultCount
= pr
->LastFaultCount
;
616 SpiCur
->VmCounters
.PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
; // Is this right using ->Vm. here ?
617 SpiCur
->VmCounters
.WorkingSetSize
= pr
->Vm
.WorkingSetSize
; // Is this right using ->Vm. here ?
618 SpiCur
->VmCounters
.QuotaPeakPagedPoolUsage
=
619 pr
->QuotaPeakPoolUsage
[0];
620 SpiCur
->VmCounters
.QuotaPagedPoolUsage
=
621 pr
->QuotaPoolUsage
[0];
622 SpiCur
->VmCounters
.QuotaPeakNonPagedPoolUsage
=
623 pr
->QuotaPeakPoolUsage
[1];
624 SpiCur
->VmCounters
.QuotaNonPagedPoolUsage
=
625 pr
->QuotaPoolUsage
[1];
626 SpiCur
->VmCounters
.PagefileUsage
= pr
->PagefileUsage
; // FIXME
627 SpiCur
->VmCounters
.PeakPagefileUsage
= pr
->PeakPagefileUsage
;
628 // KJK::Hyperion: I don't know what does this mean. VM_COUNTERS
629 // doesn't seem to contain any equivalent field
630 //SpiCur->TotalPrivateBytes = pr->NumberOfPrivatePages; //FIXME: bytes != pages
632 current_entry
= pr
->ThreadListHead
.Flink
;
633 while (current_entry
!= &pr
->ThreadListHead
)
635 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
638 SpiCur
->Threads
[i
].KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
639 SpiCur
->Threads
[i
].UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
640 // SpiCur->Threads[i].CreateTime = current->CreateTime;
641 SpiCur
->Threads
[i
].WaitTime
= current
->Tcb
.WaitTime
;
642 SpiCur
->Threads
[i
].StartAddress
= (PVOID
) current
->StartAddress
;
643 SpiCur
->Threads
[i
].ClientId
= current
->Cid
;
644 SpiCur
->Threads
[i
].Priority
= current
->Tcb
.Priority
;
645 SpiCur
->Threads
[i
].BasePriority
= current
->Tcb
.BasePriority
;
646 SpiCur
->Threads
[i
].ContextSwitchCount
= current
->Tcb
.ContextSwitches
;
647 SpiCur
->Threads
[i
].State
= current
->Tcb
.State
;
648 SpiCur
->Threads
[i
].WaitReason
= current
->Tcb
.WaitReason
;
650 current_entry
= current_entry
->Flink
;
653 pr
= PsGetNextProcess(pr
);
655 if ((pr
== syspr
) || (pr
== NULL
))
657 SpiCur
->NextEntryDelta
= 0;
661 pCur
= pCur
+ curSize
+ inLen
;
662 } while ((pr
!= syspr
) && (pr
!= NULL
));
667 ObDereferenceObject(pr
);
669 return (STATUS_SUCCESS
);
672 /* Class 6 - Call Count Information */
673 QSI_DEF(SystemCallCountInformation
)
676 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
677 return (STATUS_NOT_IMPLEMENTED
);
680 /* Class 7 - Device Information */
681 QSI_DEF(SystemDeviceInformation
)
683 PSYSTEM_DEVICE_INFORMATION Sdi
684 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
685 PCONFIGURATION_INFORMATION ConfigInfo
;
687 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
689 * Check user buffer's size
691 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
693 return (STATUS_INFO_LENGTH_MISMATCH
);
696 ConfigInfo
= IoGetConfigurationInformation ();
698 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
699 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
700 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
701 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
702 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
703 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
705 return (STATUS_SUCCESS
);
708 /* Class 8 - Processor Performance Information */
709 QSI_DEF(SystemProcessorPerformanceInformation
)
711 PSYSTEM_PROCESSORTIME_INFO Spi
712 = (PSYSTEM_PROCESSORTIME_INFO
) Buffer
;
715 LARGE_INTEGER CurrentTime
;
718 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSORTIME_INFO
);
720 * Check user buffer's size
722 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSORTIME_INFO
))
724 return (STATUS_INFO_LENGTH_MISMATCH
);
727 CurrentTime
.QuadPart
= KeQueryInterruptTime();
728 Pcr
= (PKPCR
)KPCR_BASE
;
729 for (i
= 0; i
< KeNumberProcessors
; i
++)
732 Spi
->TotalProcessorRunTime
.QuadPart
= (Pcr
->PrcbData
.IdleThread
->KernelTime
+ Pcr
->PrcbData
.IdleThread
->UserTime
) * 100000LL; // IdleTime
733 Spi
->TotalProcessorTime
.QuadPart
= Pcr
->PrcbData
.KernelTime
* 100000LL; // KernelTime
734 Spi
->TotalProcessorUserTime
.QuadPart
= Pcr
->PrcbData
.UserTime
* 100000LL;
735 Spi
->TotalDPCTime
.QuadPart
= Pcr
->PrcbData
.DpcTime
* 100000LL;
736 Spi
->TotalInterruptTime
.QuadPart
= Pcr
->PrcbData
.InterruptTime
* 100000LL;
737 Spi
->TotalInterrupts
= Pcr
->PrcbData
.InterruptCount
; // Interrupt Count
740 Pcr
= (PKPCR
)((ULONG_PTR
)Pcr
+ PAGE_SIZE
);
743 return (STATUS_SUCCESS
);
746 /* Class 9 - Flags Information */
747 QSI_DEF(SystemFlagsInformation
)
749 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
751 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
752 return (STATUS_INFO_LENGTH_MISMATCH
);
754 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
755 return (STATUS_SUCCESS
);
758 SSI_DEF(SystemFlagsInformation
)
760 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
762 return (STATUS_INFO_LENGTH_MISMATCH
);
764 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
765 return (STATUS_SUCCESS
);
768 /* Class 10 - Call Time Information */
769 QSI_DEF(SystemCallTimeInformation
)
772 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
773 return (STATUS_NOT_IMPLEMENTED
);
776 /* Class 11 - Module Information */
777 QSI_DEF(SystemModuleInformation
)
779 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
782 /* Class 12 - Locks Information */
783 QSI_DEF(SystemLocksInformation
)
786 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
787 return (STATUS_NOT_IMPLEMENTED
);
790 /* Class 13 - Stack Trace Information */
791 QSI_DEF(SystemStackTraceInformation
)
794 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
795 return (STATUS_NOT_IMPLEMENTED
);
798 /* Class 14 - Paged Pool Information */
799 QSI_DEF(SystemPagedPoolInformation
)
802 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
803 return (STATUS_NOT_IMPLEMENTED
);
806 /* Class 15 - Non Paged Pool Information */
807 QSI_DEF(SystemNonPagedPoolInformation
)
810 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
811 return (STATUS_NOT_IMPLEMENTED
);
816 ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi
,
820 /* Class 16 - Handle Information */
821 QSI_DEF(SystemHandleInformation
)
824 PSYSTEM_HANDLE_INFORMATION Shi
=
825 (PSYSTEM_HANDLE_INFORMATION
) Buffer
;
827 DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
829 if (Size
< sizeof (SYSTEM_HANDLE_INFORMATION
))
831 * ReqSize
= sizeof (SYSTEM_HANDLE_INFORMATION
);
832 return (STATUS_INFO_LENGTH_MISMATCH
);
835 DPRINT("SystemHandleInformation 1\n");
841 /* First Calc Size from Count. */
842 syspr
= PsGetNextProcess(NULL
);
847 hCount
= hCount
+ ObpGetHandleCountByHandleTable(&pr
->HandleTable
);
849 curSize
= sizeof(SYSTEM_HANDLE_INFORMATION
)+
850 ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) * hCount
) -
851 (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) ));
853 Shi
->NumberOfHandles
= hCount
;
858 DPRINT1("SystemHandleInformation 2\n");
859 return (STATUS_INFO_LENGTH_MISMATCH
);
862 pr
= PsGetNextProcess(pr
);
864 if ((pr
== syspr
) || (pr
== NULL
))
866 } while ((pr
!= syspr
) && (pr
!= NULL
));
870 ObDereferenceObject(pr
);
873 DPRINT("SystemHandleInformation 3\n");
875 /* Now get Handles from all processs. */
876 syspr
= PsGetNextProcess(NULL
);
881 int Count
= 0, HandleCount
= 0;
883 HandleCount
= ObpGetHandleCountByHandleTable(&pr
->HandleTable
);
885 for (Count
= 0; HandleCount
> 0 ; HandleCount
--)
887 ObpGetNextHandleByProcessCount( &Shi
->Handles
[i
], pr
, Count
);
892 pr
= PsGetNextProcess(pr
);
894 if ((pr
== syspr
) || (pr
== NULL
))
896 } while ((pr
!= syspr
) && (pr
!= NULL
));
901 ObDereferenceObject(pr
);
904 DPRINT("SystemHandleInformation 4\n");
905 return (STATUS_SUCCESS
);
909 SSI_DEF(SystemHandleInformation)
912 return (STATUS_SUCCESS);
916 /* Class 17 - Information */
917 QSI_DEF(SystemObjectInformation
)
920 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
921 return (STATUS_NOT_IMPLEMENTED
);
924 /* Class 18 - Information */
925 QSI_DEF(SystemPageFileInformation
)
927 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
929 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
931 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
932 return (STATUS_INFO_LENGTH_MISMATCH
);
935 UNICODE_STRING FileName
; /* FIXME */
938 Spfi
->NextEntryOffset
= 0;
940 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
941 Spfi
->TotalInUse
= MiUsedSwapPages
;
942 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
943 Spfi
->PageFileName
= FileName
;
944 return (STATUS_SUCCESS
);
947 /* Class 19 - Vdm Instemul Information */
948 QSI_DEF(SystemVdmInstemulInformation
)
951 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
952 return (STATUS_NOT_IMPLEMENTED
);
955 /* Class 20 - Vdm Bop Information */
956 QSI_DEF(SystemVdmBopInformation
)
959 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
960 return (STATUS_NOT_IMPLEMENTED
);
963 /* Class 21 - File Cache Information */
964 QSI_DEF(SystemFileCacheInformation
)
966 SYSTEM_CACHE_INFORMATION
*Sci
= (SYSTEM_CACHE_INFORMATION
*) Buffer
;
968 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
970 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
971 return (STATUS_INFO_LENGTH_MISMATCH
);
973 /* Return the Byte size not the page size. */
975 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
977 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
979 Sci
->PageFaultCount
= 0; /* FIXME */
980 Sci
->MinimumWorkingSet
= 0; /* FIXME */
981 Sci
->MaximumWorkingSet
= 0; /* FIXME */
982 Sci
->TransitionSharedPages
= 0; /* FIXME */
983 Sci
->TransitionSharedPagesPeak
= 0; /* FIXME */
985 return (STATUS_SUCCESS
);
988 SSI_DEF(SystemFileCacheInformation
)
990 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
992 return (STATUS_INFO_LENGTH_MISMATCH
);
995 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
996 return (STATUS_NOT_IMPLEMENTED
);
999 /* Class 22 - Pool Tag Information */
1000 QSI_DEF(SystemPoolTagInformation
)
1003 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
1004 return (STATUS_NOT_IMPLEMENTED
);
1007 /* Class 23 - Interrupt Information */
1008 QSI_DEF(SystemInterruptInformation
)
1011 DPRINT1("NtQuerySystemInformation - SystemInterruptInformation not implemented\n");
1012 return (STATUS_NOT_IMPLEMENTED
);
1015 /* Class 24 - DPC Behaviour Information */
1016 QSI_DEF(SystemDpcBehaviourInformation
)
1019 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
1020 return (STATUS_NOT_IMPLEMENTED
);
1023 SSI_DEF(SystemDpcBehaviourInformation
)
1026 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1027 return (STATUS_NOT_IMPLEMENTED
);
1030 /* Class 25 - Full Memory Information */
1031 QSI_DEF(SystemFullMemoryInformation
)
1033 PULONG Spi
= (PULONG
) Buffer
;
1035 PEPROCESS TheIdleProcess
;
1037 * ReqSize
= sizeof (ULONG
);
1039 if (sizeof (ULONG
) != Size
)
1041 return (STATUS_INFO_LENGTH_MISMATCH
);
1043 DPRINT("SystemFullMemoryInformation\n");
1045 TheIdleProcess
= PsInitialSystemProcess
; /* FIXME */
1047 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
1048 TheIdleProcess
->UniqueProcessId
,
1049 TheIdleProcess
->Pcb
.KernelTime
,
1054 MmPrintMemoryStatistic();
1057 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
1059 return (STATUS_SUCCESS
);
1062 /* Class 26 - Load Image */
1063 SSI_DEF(SystemLoadImage
)
1065 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
1067 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
1069 return(STATUS_INFO_LENGTH_MISMATCH
);
1072 return(LdrpLoadImage(&Sli
->ModuleName
,
1074 &Sli
->SectionPointer
,
1076 &Sli
->ExportDirectory
));
1079 /* Class 27 - Unload Image */
1080 SSI_DEF(SystemUnloadImage
)
1082 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
1084 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
1086 return(STATUS_INFO_LENGTH_MISMATCH
);
1089 return(LdrpUnloadImage(Sui
->ModuleBase
));
1092 /* Class 28 - Time Adjustment Information */
1093 QSI_DEF(SystemTimeAdjustmentInformation
)
1095 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1097 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
1098 return (STATUS_INFO_LENGTH_MISMATCH
);
1101 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1102 return (STATUS_NOT_IMPLEMENTED
);
1105 SSI_DEF(SystemTimeAdjustmentInformation
)
1107 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1109 return (STATUS_INFO_LENGTH_MISMATCH
);
1112 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1113 return (STATUS_NOT_IMPLEMENTED
);
1116 /* Class 29 - Summary Memory Information */
1117 QSI_DEF(SystemSummaryMemoryInformation
)
1120 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1121 return (STATUS_NOT_IMPLEMENTED
);
1124 /* Class 30 - Next Event Id Information */
1125 QSI_DEF(SystemNextEventIdInformation
)
1128 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1129 return (STATUS_NOT_IMPLEMENTED
);
1132 /* Class 31 - Event Ids Information */
1133 QSI_DEF(SystemEventIdsInformation
)
1136 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1137 return (STATUS_NOT_IMPLEMENTED
);
1140 /* Class 32 - Crash Dump Information */
1141 QSI_DEF(SystemCrashDumpInformation
)
1144 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1145 return (STATUS_NOT_IMPLEMENTED
);
1148 /* Class 33 - Exception Information */
1149 QSI_DEF(SystemExceptionInformation
)
1152 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1153 return (STATUS_NOT_IMPLEMENTED
);
1156 /* Class 34 - Crash Dump State Information */
1157 QSI_DEF(SystemCrashDumpStateInformation
)
1160 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1161 return (STATUS_NOT_IMPLEMENTED
);
1164 /* Class 35 - Kernel Debugger Information */
1165 QSI_DEF(SystemKernelDebuggerInformation
)
1168 DPRINT1("NtQuerySystemInformation - SystemKernelDebuggerInformation not implemented\n");
1169 return (STATUS_NOT_IMPLEMENTED
);
1172 /* Class 36 - Context Switch Information */
1173 QSI_DEF(SystemContextSwitchInformation
)
1176 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1177 return (STATUS_NOT_IMPLEMENTED
);
1180 /* Class 37 - Registry Quota Information */
1181 QSI_DEF(SystemRegistryQuotaInformation
)
1183 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1185 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1186 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1188 return STATUS_INFO_LENGTH_MISMATCH
;
1191 DPRINT1("Faking max registry size of 32 MB\n");
1192 srqi
->RegistryQuotaAllowed
= 0x2000000;
1193 srqi
->RegistryQuotaUsed
= 0x200000;
1194 srqi
->Reserved1
= (void*)0x200000;
1196 return STATUS_SUCCESS
;
1199 SSI_DEF(SystemRegistryQuotaInformation
)
1202 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1203 return (STATUS_NOT_IMPLEMENTED
);
1206 /* Class 38 - Load And Call Image */
1207 SSI_DEF(SystemLoadAndCallImage
)
1209 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
1211 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
1213 return(STATUS_INFO_LENGTH_MISMATCH
);
1216 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
1219 /* Class 39 - Priority Separation */
1220 SSI_DEF(SystemPrioritySeperation
)
1223 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1224 return (STATUS_NOT_IMPLEMENTED
);
1227 /* Class 40 - Plug Play Bus Information */
1228 QSI_DEF(SystemPlugPlayBusInformation
)
1231 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1232 return (STATUS_NOT_IMPLEMENTED
);
1235 /* Class 41 - Dock Information */
1236 QSI_DEF(SystemDockInformation
)
1239 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1240 return (STATUS_NOT_IMPLEMENTED
);
1243 /* Class 42 - Power Information */
1244 QSI_DEF(SystemPowerInformation
)
1247 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1248 return (STATUS_NOT_IMPLEMENTED
);
1251 /* Class 43 - Processor Speed Information */
1252 QSI_DEF(SystemProcessorSpeedInformation
)
1255 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1256 return (STATUS_NOT_IMPLEMENTED
);
1259 /* Class 44 - Current Time Zone Information */
1260 QSI_DEF(SystemCurrentTimeZoneInformation
)
1262 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1264 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1266 return STATUS_INFO_LENGTH_MISMATCH
;
1269 /* Copy the time zone information struct */
1272 sizeof(TIME_ZONE_INFORMATION
));
1274 return STATUS_SUCCESS
;
1278 SSI_DEF(SystemCurrentTimeZoneInformation
)
1280 /* Check user buffer's size */
1281 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1283 return STATUS_INFO_LENGTH_MISMATCH
;
1286 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1290 /* Class 45 - Lookaside Information */
1291 QSI_DEF(SystemLookasideInformation
)
1294 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1295 return (STATUS_NOT_IMPLEMENTED
);
1299 /* Class 46 - Set time slip event */
1300 SSI_DEF(SystemSetTimeSlipEvent
)
1303 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1304 return (STATUS_NOT_IMPLEMENTED
);
1308 /* Class 47 - Create a new session (TSE) */
1309 SSI_DEF(SystemCreateSession
)
1312 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1313 return (STATUS_NOT_IMPLEMENTED
);
1317 /* Class 48 - Delete an existing session (TSE) */
1318 SSI_DEF(SystemDeleteSession
)
1321 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1322 return (STATUS_NOT_IMPLEMENTED
);
1326 /* Class 49 - UNKNOWN */
1327 QSI_DEF(SystemInvalidInfoClass4
)
1330 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1331 return (STATUS_NOT_IMPLEMENTED
);
1335 /* Class 50 - System range start address */
1336 QSI_DEF(SystemRangeStartInformation
)
1339 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1340 return (STATUS_NOT_IMPLEMENTED
);
1344 /* Class 51 - Driver verifier information */
1345 QSI_DEF(SystemVerifierInformation
)
1348 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1349 return (STATUS_NOT_IMPLEMENTED
);
1353 SSI_DEF(SystemVerifierInformation
)
1356 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1357 return (STATUS_NOT_IMPLEMENTED
);
1361 /* Class 52 - Add a driver verifier */
1362 SSI_DEF(SystemAddVerifier
)
1365 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1366 return (STATUS_NOT_IMPLEMENTED
);
1370 /* Class 53 - A session's processes */
1371 QSI_DEF(SystemSessionProcessesInformation
)
1374 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1375 return (STATUS_NOT_IMPLEMENTED
);
1379 /* Query/Set Calls Table */
1383 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1384 NTSTATUS (* Set
) (PVOID
,ULONG
);
1391 // XX unknown behaviour
1393 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1394 #define SI_QX(n) {QSI_USE(n),NULL}
1395 #define SI_XS(n) {NULL,SSI_USE(n)}
1396 #define SI_XX(n) {NULL,NULL}
1402 SI_QX(SystemBasicInformation
),
1403 SI_QX(SystemProcessorInformation
),
1404 SI_QX(SystemPerformanceInformation
),
1405 SI_QX(SystemTimeOfDayInformation
),
1406 SI_QX(SystemPathInformation
), /* should be SI_XX */
1407 SI_QX(SystemProcessInformation
),
1408 SI_QX(SystemCallCountInformation
),
1409 SI_QX(SystemDeviceInformation
),
1410 SI_QX(SystemProcessorPerformanceInformation
),
1411 SI_QS(SystemFlagsInformation
),
1412 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1413 SI_QX(SystemModuleInformation
),
1414 SI_QX(SystemLocksInformation
),
1415 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1416 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1417 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1418 SI_QX(SystemHandleInformation
),
1419 SI_QX(SystemObjectInformation
),
1420 SI_QX(SystemPageFileInformation
),
1421 SI_QX(SystemVdmInstemulInformation
),
1422 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1423 SI_QS(SystemFileCacheInformation
),
1424 SI_QX(SystemPoolTagInformation
),
1425 SI_QX(SystemInterruptInformation
),
1426 SI_QS(SystemDpcBehaviourInformation
),
1427 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1428 SI_XS(SystemLoadImage
),
1429 SI_XS(SystemUnloadImage
),
1430 SI_QS(SystemTimeAdjustmentInformation
),
1431 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1432 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1433 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1434 SI_QX(SystemCrashDumpInformation
),
1435 SI_QX(SystemExceptionInformation
),
1436 SI_QX(SystemCrashDumpStateInformation
),
1437 SI_QX(SystemKernelDebuggerInformation
),
1438 SI_QX(SystemContextSwitchInformation
),
1439 SI_QS(SystemRegistryQuotaInformation
),
1440 SI_XS(SystemLoadAndCallImage
),
1441 SI_XS(SystemPrioritySeperation
),
1442 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1443 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1444 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1445 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1446 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1447 SI_QX(SystemLookasideInformation
),
1448 SI_XS(SystemSetTimeSlipEvent
),
1449 SI_XS(SystemCreateSession
),
1450 SI_XS(SystemDeleteSession
),
1451 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1452 SI_QX(SystemRangeStartInformation
),
1453 SI_QS(SystemVerifierInformation
),
1454 SI_XS(SystemAddVerifier
),
1455 SI_QX(SystemSessionProcessesInformation
)
1463 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1464 OUT PVOID UnsafeSystemInformation
,
1466 OUT PULONG UnsafeResultLength
)
1469 PVOID SystemInformation
;
1475 /* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
1476 SystemInformationClass );
1478 /*if (ExGetPreviousMode() == KernelMode)
1480 SystemInformation
= UnsafeSystemInformation
;
1484 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1485 if (SystemInformation == NULL)
1487 return(STATUS_NO_MEMORY);
1491 /* Clear user buffer. */
1492 RtlZeroMemory(SystemInformation
, Length
);
1495 * Check the request is valid.
1497 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1498 (SystemInformationClass
< SystemInformationClassMax
))
1500 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1503 * Hand the request to a subhandler.
1505 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1508 /*if (ExGetPreviousMode() != KernelMode)
1510 Status = MmCopyToCaller(UnsafeSystemInformation,
1513 ExFreePool(SystemInformation);
1514 if (!NT_SUCCESS(Status))
1519 if (UnsafeResultLength
!= NULL
)
1521 /*if (ExGetPreviousMode() == KernelMode)
1523 *UnsafeResultLength = ResultLength;
1527 Status
= MmCopyToCaller(UnsafeResultLength
,
1530 if (!NT_SUCCESS(Status
))
1539 return (STATUS_INVALID_INFO_CLASS
);
1545 NtSetSystemInformation (
1546 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1547 IN PVOID SystemInformation
,
1548 IN ULONG SystemInformationLength
1554 * If called from user mode, check
1555 * possible unsafe arguments.
1558 if (KernelMode
!= KeGetPreviousMode())
1562 // SystemInformation,
1572 * Check the request is valid.
1574 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1575 && (SystemInformationClass
< SystemInformationClassMax
)
1578 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1581 * Hand the request to a subhandler.
1583 return CallQS
[SystemInformationClass
].Set (
1585 SystemInformationLength
1589 return (STATUS_INVALID_INFO_CLASS
);
1595 NtFlushInstructionCache (
1596 IN HANDLE ProcessHandle
,
1597 IN PVOID BaseAddress
,
1598 IN UINT NumberOfBytesToFlush
1603 __asm__("wbinvd\n");
1604 return STATUS_SUCCESS
;