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
;
104 PreviousMode
= ExGetPreviousMode();
106 if(PreviousMode
!= KernelMode
)
110 ProbeForRead(VariableName
,
111 sizeof(UNICODE_STRING
),
113 ProbeForWrite(ValueBuffer
,
116 if(ReturnLength
!= NULL
)
118 ProbeForWrite(ReturnLength
,
125 Status
= _SEH_GetExceptionCode();
129 if(!NT_SUCCESS(Status
))
136 * Copy the name to kernel space if necessary and convert it to ANSI.
138 Status
= RtlCaptureUnicodeString(&WName
,
143 if(NT_SUCCESS(Status
))
146 * according to ntinternals the SeSystemEnvironmentName privilege is required!
148 if(!SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
151 RtlReleaseCapturedUnicodeString(&WName
,
154 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
155 return STATUS_PRIVILEGE_NOT_HELD
;
159 * convert the value name to ansi
161 Status
= RtlUnicodeStringToAnsiString(&AName
, &WName
, TRUE
);
162 RtlReleaseCapturedUnicodeString(&WName
,
165 if(!NT_SUCCESS(Status
))
171 * Create a temporary buffer for the value
173 Value
= ExAllocatePool(NonPagedPool
, ValueBufferLength
);
176 RtlFreeAnsiString(&AName
);
177 return STATUS_INSUFFICIENT_RESOURCES
;
181 * Get the environment variable
183 Result
= HalGetEnvironmentVariable(AName
.Buffer
, Value
, ValueBufferLength
);
186 RtlFreeAnsiString(&AName
);
188 return STATUS_UNSUCCESSFUL
;
192 * Convert the result to UNICODE, protect with SEH in case the value buffer
193 * isn't NULL-terminated!
197 RtlInitAnsiString(&AValue
, Value
);
198 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
202 Status
= _SEH_GetExceptionCode();
206 if(NT_SUCCESS(Status
))
209 * Copy the result back to the caller.
213 RtlCopyMemory(ValueBuffer
, WValue
.Buffer
, WValue
.Length
);
214 ValueBuffer
[WValue
.Length
/ sizeof(WCHAR
)] = L
'\0';
215 if(ReturnLength
!= NULL
)
217 *ReturnLength
= WValue
.Length
+ sizeof(WCHAR
);
220 Status
= STATUS_SUCCESS
;
224 Status
= _SEH_GetExceptionCode();
230 * Cleanup allocated resources.
232 RtlFreeAnsiString(&AName
);
241 NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
242 IN PUNICODE_STRING Value
)
244 UNICODE_STRING CapturedName
, CapturedValue
;
245 ANSI_STRING AName
, AValue
;
246 KPROCESSOR_MODE PreviousMode
;
249 PreviousMode
= ExGetPreviousMode();
252 * Copy the strings to kernel space if necessary
254 Status
= RtlCaptureUnicodeString(&CapturedName
,
259 if(NT_SUCCESS(Status
))
261 Status
= RtlCaptureUnicodeString(&CapturedValue
,
266 if(NT_SUCCESS(Status
))
269 * according to ntinternals the SeSystemEnvironmentName privilege is required!
271 if(SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
275 * convert the strings to ANSI
277 Status
= RtlUnicodeStringToAnsiString(&AName
,
280 if(NT_SUCCESS(Status
))
282 Status
= RtlUnicodeStringToAnsiString(&AValue
,
285 if(NT_SUCCESS(Status
))
287 BOOLEAN Result
= HalSetEnvironmentVariable(AName
.Buffer
,
290 Status
= (Result
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);
296 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
297 Status
= STATUS_PRIVILEGE_NOT_HELD
;
300 RtlReleaseCapturedUnicodeString(&CapturedValue
,
305 RtlReleaseCapturedUnicodeString(&CapturedName
,
314 /* --- Query/Set System Information --- */
317 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
318 * so the stack is popped only in one place on x86 platform.
320 #define QSI_USE(n) QSI##n
322 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
324 #define SSI_USE(n) SSI##n
326 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
329 /* Class 0 - Basic Information */
330 QSI_DEF(SystemBasicInformation
)
332 PSYSTEM_BASIC_INFORMATION Sbi
333 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
335 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
337 * Check user buffer's size
339 if (Size
< sizeof (SYSTEM_BASIC_INFORMATION
))
341 return (STATUS_INFO_LENGTH_MISMATCH
);
344 Sbi
->MaximumIncrement
= KeMaximumIncrement
;
345 Sbi
->PhysicalPageSize
= PAGE_SIZE
;
346 Sbi
->NumberOfPhysicalPages
= MmStats
.NrTotalPages
;
347 Sbi
->LowestPhysicalPage
= 0; /* FIXME */
348 Sbi
->HighestPhysicalPage
= MmStats
.NrTotalPages
; /* FIXME */
349 Sbi
->AllocationGranularity
= MM_VIRTMEM_GRANULARITY
; /* hard coded on Intel? */
350 Sbi
->LowestUserAddress
= 0x10000; /* Top of 64k */
351 Sbi
->HighestUserAddress
= (ULONG_PTR
)MmHighestUserAddress
;
352 Sbi
->ActiveProcessors
= KeActiveProcessors
;
353 Sbi
->NumberProcessors
= KeNumberProcessors
;
354 return (STATUS_SUCCESS
);
357 /* Class 1 - Processor Information */
358 QSI_DEF(SystemProcessorInformation
)
360 PSYSTEM_PROCESSOR_INFORMATION Spi
361 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
363 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
365 * Check user buffer's size
367 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
369 return (STATUS_INFO_LENGTH_MISMATCH
);
371 Pcr
= KeGetCurrentKPCR();
372 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
373 Spi
->ProcessorLevel
= Pcr
->PrcbData
.CpuType
;
374 Spi
->ProcessorRevision
= Pcr
->PrcbData
.CpuStep
;
376 Spi
->FeatureBits
= Pcr
->PrcbData
.FeatureBits
;
378 DPRINT("Arch %d Level %d Rev 0x%x\n", Spi
->ProcessorArchitecture
,
379 Spi
->ProcessorLevel
, Spi
->ProcessorRevision
);
381 return (STATUS_SUCCESS
);
384 /* Class 2 - Performance Information */
385 QSI_DEF(SystemPerformanceInformation
)
387 PSYSTEM_PERFORMANCE_INFORMATION Spi
388 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
390 PEPROCESS TheIdleProcess
;
392 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
394 * Check user buffer's size
396 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
398 return (STATUS_INFO_LENGTH_MISMATCH
);
401 TheIdleProcess
= PsInitialSystemProcess
; /* FIXME */
403 Spi
->IdleTime
.QuadPart
= TheIdleProcess
->Pcb
.KernelTime
* 100000LL;
405 Spi
->ReadTransferCount
.QuadPart
= IoReadTransferCount
;
406 Spi
->WriteTransferCount
.QuadPart
= IoWriteTransferCount
;
407 Spi
->OtherTransferCount
.QuadPart
= IoOtherTransferCount
;
408 Spi
->ReadOperationCount
= IoReadOperationCount
;
409 Spi
->WriteOperationCount
= IoWriteOperationCount
;
410 Spi
->OtherOperationCount
= IoOtherOperationCount
;
412 Spi
->AvailablePages
= MmStats
.NrFreePages
;
414 Add up all the used "Commitied" memory + pagefile.
415 Not sure this is right. 8^\
417 Spi
->TotalCommittedPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
+
418 MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
+
419 MiMemoryConsumers
[MC_CACHE
].PagesUsed
+
420 MiMemoryConsumers
[MC_USER
].PagesUsed
+
423 Add up the full system total + pagefile.
424 All this make Taskmgr happy but not sure it is the right numbers.
425 This too, fixes some of GlobalMemoryStatusEx numbers.
427 Spi
->TotalCommitLimit
= MmStats
.NrTotalPages
+ MiFreeSwapPages
+
430 Spi
->PeakCommitment
= 0; /* FIXME */
431 Spi
->PageFaults
= 0; /* FIXME */
432 Spi
->WriteCopyFaults
= 0; /* FIXME */
433 Spi
->TransitionFaults
= 0; /* FIXME */
434 Spi
->CacheTransitionFaults
= 0; /* FIXME */
435 Spi
->DemandZeroFaults
= 0; /* FIXME */
436 Spi
->PagesRead
= 0; /* FIXME */
437 Spi
->PageReadIos
= 0; /* FIXME */
438 Spi
->CacheReads
= 0; /* FIXME */
439 Spi
->CacheIos
= 0; /* FIXME */
440 Spi
->PagefilePagesWritten
= 0; /* FIXME */
441 Spi
->PagefilePageWriteIos
= 0; /* FIXME */
442 Spi
->MappedFilePagesWritten
= 0; /* FIXME */
443 Spi
->MappedFilePageWriteIos
= 0; /* FIXME */
445 Spi
->PagedPoolUsage
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
;
446 Spi
->PagedPoolAllocs
= 0; /* FIXME */
447 Spi
->PagedPoolFrees
= 0; /* FIXME */
448 Spi
->NonPagedPoolUsage
= MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
;
449 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
450 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
452 Spi
->TotalFreeSystemPtes
= 0; /* FIXME */
454 Spi
->SystemCodePage
= MmStats
.NrSystemPages
; /* FIXME */
456 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
457 Spi
->TotalSystemCodePages
= 0; /* FIXME */
458 Spi
->SmallNonPagedLookasideListAllocateHits
= 0; /* FIXME */
459 Spi
->SmallPagedLookasideListAllocateHits
= 0; /* FIXME */
460 Spi
->Reserved3
= 0; /* FIXME */
462 Spi
->MmSystemCachePage
= MiMemoryConsumers
[MC_CACHE
].PagesUsed
;
463 Spi
->PagedPoolPage
= MmPagedPoolSize
; /* FIXME */
465 Spi
->SystemDriverPage
= 0; /* FIXME */
466 Spi
->FastReadNoWait
= 0; /* FIXME */
467 Spi
->FastReadWait
= 0; /* FIXME */
468 Spi
->FastReadResourceMiss
= 0; /* FIXME */
469 Spi
->FastReadNotPossible
= 0; /* FIXME */
471 Spi
->FastMdlReadNoWait
= 0; /* FIXME */
472 Spi
->FastMdlReadWait
= 0; /* FIXME */
473 Spi
->FastMdlReadResourceMiss
= 0; /* FIXME */
474 Spi
->FastMdlReadNotPossible
= 0; /* FIXME */
476 Spi
->MapDataNoWait
= 0; /* FIXME */
477 Spi
->MapDataWait
= 0; /* FIXME */
478 Spi
->MapDataNoWaitMiss
= 0; /* FIXME */
479 Spi
->MapDataWaitMiss
= 0; /* FIXME */
481 Spi
->PinMappedDataCount
= 0; /* FIXME */
482 Spi
->PinReadNoWait
= 0; /* FIXME */
483 Spi
->PinReadWait
= 0; /* FIXME */
484 Spi
->PinReadNoWaitMiss
= 0; /* FIXME */
485 Spi
->PinReadWaitMiss
= 0; /* FIXME */
486 Spi
->CopyReadNoWait
= 0; /* FIXME */
487 Spi
->CopyReadWait
= 0; /* FIXME */
488 Spi
->CopyReadNoWaitMiss
= 0; /* FIXME */
489 Spi
->CopyReadWaitMiss
= 0; /* FIXME */
491 Spi
->MdlReadNoWait
= 0; /* FIXME */
492 Spi
->MdlReadWait
= 0; /* FIXME */
493 Spi
->MdlReadNoWaitMiss
= 0; /* FIXME */
494 Spi
->MdlReadWaitMiss
= 0; /* FIXME */
495 Spi
->ReadAheadIos
= 0; /* FIXME */
496 Spi
->LazyWriteIos
= 0; /* FIXME */
497 Spi
->LazyWritePages
= 0; /* FIXME */
498 Spi
->DataFlushes
= 0; /* FIXME */
499 Spi
->DataPages
= 0; /* FIXME */
500 Spi
->ContextSwitches
= 0; /* FIXME */
501 Spi
->FirstLevelTbFills
= 0; /* FIXME */
502 Spi
->SecondLevelTbFills
= 0; /* FIXME */
503 Spi
->SystemCalls
= 0; /* FIXME */
505 return (STATUS_SUCCESS
);
508 /* Class 3 - Time Of Day Information */
509 QSI_DEF(SystemTimeOfDayInformation
)
511 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
512 LARGE_INTEGER CurrentTime
;
514 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
515 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
517 /* Check user buffer's size */
518 if (Size
< sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
520 return STATUS_INFO_LENGTH_MISMATCH
;
523 KeQuerySystemTime(&CurrentTime
);
525 Sti
->BootTime
= SystemBootTime
;
526 Sti
->CurrentTime
= CurrentTime
;
527 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
528 Sti
->TimeZoneId
= ExpTimeZoneId
;
531 return STATUS_SUCCESS
;
534 /* Class 4 - Path Information */
535 QSI_DEF(SystemPathInformation
)
537 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
538 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
540 return (STATUS_BREAKPOINT
);
543 /* Class 5 - Process Information */
544 QSI_DEF(SystemProcessInformation
)
546 ULONG ovlSize
=0, nThreads
;
550 /* scan the process list */
552 PSYSTEM_PROCESSES Spi
553 = (PSYSTEM_PROCESSES
) Buffer
;
555 *ReqSize
= sizeof(SYSTEM_PROCESSES
);
557 if (Size
< sizeof(SYSTEM_PROCESSES
))
559 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
562 syspr
= PsGetNextProcess(NULL
);
564 pCur
= (unsigned char *)Spi
;
568 PSYSTEM_PROCESSES SpiCur
;
571 int inLen
=32; // image name len in bytes
572 PLIST_ENTRY current_entry
;
575 SpiCur
= (PSYSTEM_PROCESSES
)pCur
;
577 nThreads
= PsEnumThreadsByProcess(pr
);
579 // size of the structure for every process
580 curSize
= sizeof(SYSTEM_PROCESSES
)-sizeof(SYSTEM_THREADS
)+sizeof(SYSTEM_THREADS
)*nThreads
;
581 ovlSize
+= curSize
+inLen
;
586 ObDereferenceObject(pr
);
588 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
591 // fill system information
592 SpiCur
->NextEntryDelta
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
593 SpiCur
->ThreadCount
= nThreads
;
594 SpiCur
->CreateTime
= pr
->CreateTime
;
595 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
596 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
597 SpiCur
->ProcessName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
598 SpiCur
->ProcessName
.MaximumLength
= inLen
;
599 SpiCur
->ProcessName
.Buffer
= (void*)(pCur
+curSize
);
601 // copy name to the end of the struct
602 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
603 RtlAnsiStringToUnicodeString(&SpiCur
->ProcessName
, &imgName
, FALSE
);
605 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
606 SpiCur
->ProcessId
= pr
->UniqueProcessId
;
607 SpiCur
->InheritedFromProcessId
= pr
->InheritedFromUniqueProcessId
;
608 SpiCur
->HandleCount
= ObpGetHandleCountByHandleTable(&pr
->HandleTable
);
609 SpiCur
->VmCounters
.PeakVirtualSize
= pr
->PeakVirtualSize
;
610 SpiCur
->VmCounters
.VirtualSize
= pr
->VirtualSize
.QuadPart
;
611 SpiCur
->VmCounters
.PageFaultCount
= pr
->LastFaultCount
;
612 SpiCur
->VmCounters
.PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
; // Is this right using ->Vm. here ?
613 SpiCur
->VmCounters
.WorkingSetSize
= pr
->Vm
.WorkingSetSize
; // Is this right using ->Vm. here ?
614 SpiCur
->VmCounters
.QuotaPeakPagedPoolUsage
=
615 pr
->QuotaPeakPoolUsage
[0];
616 SpiCur
->VmCounters
.QuotaPagedPoolUsage
=
617 pr
->QuotaPoolUsage
[0];
618 SpiCur
->VmCounters
.QuotaPeakNonPagedPoolUsage
=
619 pr
->QuotaPeakPoolUsage
[1];
620 SpiCur
->VmCounters
.QuotaNonPagedPoolUsage
=
621 pr
->QuotaPoolUsage
[1];
622 SpiCur
->VmCounters
.PagefileUsage
= pr
->PagefileUsage
; // FIXME
623 SpiCur
->VmCounters
.PeakPagefileUsage
= pr
->PeakPagefileUsage
;
624 // KJK::Hyperion: I don't know what does this mean. VM_COUNTERS
625 // doesn't seem to contain any equivalent field
626 //SpiCur->TotalPrivateBytes = pr->NumberOfPrivatePages; //FIXME: bytes != pages
628 current_entry
= pr
->ThreadListHead
.Flink
;
629 while (current_entry
!= &pr
->ThreadListHead
)
631 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
634 SpiCur
->Threads
[i
].KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
635 SpiCur
->Threads
[i
].UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
636 // SpiCur->Threads[i].CreateTime = current->CreateTime;
637 SpiCur
->Threads
[i
].WaitTime
= current
->Tcb
.WaitTime
;
638 SpiCur
->Threads
[i
].StartAddress
= (PVOID
) current
->StartAddress
;
639 SpiCur
->Threads
[i
].ClientId
= current
->Cid
;
640 SpiCur
->Threads
[i
].Priority
= current
->Tcb
.Priority
;
641 SpiCur
->Threads
[i
].BasePriority
= current
->Tcb
.BasePriority
;
642 SpiCur
->Threads
[i
].ContextSwitchCount
= current
->Tcb
.ContextSwitches
;
643 SpiCur
->Threads
[i
].State
= current
->Tcb
.State
;
644 SpiCur
->Threads
[i
].WaitReason
= current
->Tcb
.WaitReason
;
646 current_entry
= current_entry
->Flink
;
649 pr
= PsGetNextProcess(pr
);
651 if ((pr
== syspr
) || (pr
== NULL
))
653 SpiCur
->NextEntryDelta
= 0;
657 pCur
= pCur
+ curSize
+ inLen
;
658 } while ((pr
!= syspr
) && (pr
!= NULL
));
663 ObDereferenceObject(pr
);
665 return (STATUS_SUCCESS
);
668 /* Class 6 - Call Count Information */
669 QSI_DEF(SystemCallCountInformation
)
672 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
673 return (STATUS_NOT_IMPLEMENTED
);
676 /* Class 7 - Device Information */
677 QSI_DEF(SystemDeviceInformation
)
679 PSYSTEM_DEVICE_INFORMATION Sdi
680 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
681 PCONFIGURATION_INFORMATION ConfigInfo
;
683 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
685 * Check user buffer's size
687 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
689 return (STATUS_INFO_LENGTH_MISMATCH
);
692 ConfigInfo
= IoGetConfigurationInformation ();
694 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
695 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
696 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
697 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
698 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
699 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
701 return (STATUS_SUCCESS
);
704 /* Class 8 - Processor Performance Information */
705 QSI_DEF(SystemProcessorPerformanceInformation
)
707 PSYSTEM_PROCESSORTIME_INFO Spi
708 = (PSYSTEM_PROCESSORTIME_INFO
) Buffer
;
711 LARGE_INTEGER CurrentTime
;
714 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSORTIME_INFO
);
716 * Check user buffer's size
718 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSORTIME_INFO
))
720 return (STATUS_INFO_LENGTH_MISMATCH
);
723 CurrentTime
.QuadPart
= KeQueryInterruptTime();
724 Pcr
= (PKPCR
)KPCR_BASE
;
725 for (i
= 0; i
< KeNumberProcessors
; i
++)
728 Spi
->TotalProcessorRunTime
.QuadPart
= (Pcr
->PrcbData
.IdleThread
->KernelTime
+ Pcr
->PrcbData
.IdleThread
->UserTime
) * 100000LL; // IdleTime
729 Spi
->TotalProcessorTime
.QuadPart
= Pcr
->PrcbData
.KernelTime
* 100000LL; // KernelTime
730 Spi
->TotalProcessorUserTime
.QuadPart
= Pcr
->PrcbData
.UserTime
* 100000LL;
731 Spi
->TotalDPCTime
.QuadPart
= Pcr
->PrcbData
.DpcTime
* 100000LL;
732 Spi
->TotalInterruptTime
.QuadPart
= Pcr
->PrcbData
.InterruptTime
* 100000LL;
733 Spi
->TotalInterrupts
= Pcr
->PrcbData
.InterruptCount
; // Interrupt Count
736 Pcr
= (PKPCR
)((ULONG_PTR
)Pcr
+ PAGE_SIZE
);
739 return (STATUS_SUCCESS
);
742 /* Class 9 - Flags Information */
743 QSI_DEF(SystemFlagsInformation
)
745 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
747 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
748 return (STATUS_INFO_LENGTH_MISMATCH
);
750 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
751 return (STATUS_SUCCESS
);
754 SSI_DEF(SystemFlagsInformation
)
756 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
758 return (STATUS_INFO_LENGTH_MISMATCH
);
760 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
761 return (STATUS_SUCCESS
);
764 /* Class 10 - Call Time Information */
765 QSI_DEF(SystemCallTimeInformation
)
768 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
769 return (STATUS_NOT_IMPLEMENTED
);
772 /* Class 11 - Module Information */
773 QSI_DEF(SystemModuleInformation
)
775 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
778 /* Class 12 - Locks Information */
779 QSI_DEF(SystemLocksInformation
)
782 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
783 return (STATUS_NOT_IMPLEMENTED
);
786 /* Class 13 - Stack Trace Information */
787 QSI_DEF(SystemStackTraceInformation
)
790 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
791 return (STATUS_NOT_IMPLEMENTED
);
794 /* Class 14 - Paged Pool Information */
795 QSI_DEF(SystemPagedPoolInformation
)
798 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
799 return (STATUS_NOT_IMPLEMENTED
);
802 /* Class 15 - Non Paged Pool Information */
803 QSI_DEF(SystemNonPagedPoolInformation
)
806 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
807 return (STATUS_NOT_IMPLEMENTED
);
810 /* Class 16 - Handle Information */
811 QSI_DEF(SystemHandleInformation
)
814 DPRINT1("NtQuerySystemInformation - SystemHandleInformation not implemented\n");
815 return (STATUS_NOT_IMPLEMENTED
);
818 /* Class 17 - Information */
819 QSI_DEF(SystemObjectInformation
)
822 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
823 return (STATUS_NOT_IMPLEMENTED
);
826 /* Class 18 - Information */
827 QSI_DEF(SystemPageFileInformation
)
829 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
831 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
833 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
834 return (STATUS_INFO_LENGTH_MISMATCH
);
837 UNICODE_STRING FileName
; /* FIXME */
840 Spfi
->NextEntryOffset
= 0;
842 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
843 Spfi
->TotalInUse
= MiUsedSwapPages
;
844 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
845 Spfi
->PageFileName
= FileName
;
846 return (STATUS_SUCCESS
);
849 /* Class 19 - Vdm Instemul Information */
850 QSI_DEF(SystemVdmInstemulInformation
)
853 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
854 return (STATUS_NOT_IMPLEMENTED
);
857 /* Class 20 - Vdm Bop Information */
858 QSI_DEF(SystemVdmBopInformation
)
861 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
862 return (STATUS_NOT_IMPLEMENTED
);
865 /* Class 21 - File Cache Information */
866 QSI_DEF(SystemFileCacheInformation
)
868 SYSTEM_CACHE_INFORMATION
*Sci
= (SYSTEM_CACHE_INFORMATION
*) Buffer
;
870 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
872 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
873 return (STATUS_INFO_LENGTH_MISMATCH
);
875 /* Return the Byte size not the page size. */
877 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
879 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
881 Sci
->PageFaultCount
= 0; /* FIXME */
882 Sci
->MinimumWorkingSet
= 0; /* FIXME */
883 Sci
->MaximumWorkingSet
= 0; /* FIXME */
884 Sci
->TransitionSharedPages
= 0; /* FIXME */
885 Sci
->TransitionSharedPagesPeak
= 0; /* FIXME */
887 return (STATUS_SUCCESS
);
890 SSI_DEF(SystemFileCacheInformation
)
892 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
894 return (STATUS_INFO_LENGTH_MISMATCH
);
897 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
898 return (STATUS_NOT_IMPLEMENTED
);
901 /* Class 22 - Pool Tag Information */
902 QSI_DEF(SystemPoolTagInformation
)
905 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
906 return (STATUS_NOT_IMPLEMENTED
);
909 /* Class 23 - Interrupt Information */
910 QSI_DEF(SystemInterruptInformation
)
913 DPRINT1("NtQuerySystemInformation - SystemInterruptInformation not implemented\n");
914 return (STATUS_NOT_IMPLEMENTED
);
917 /* Class 24 - DPC Behaviour Information */
918 QSI_DEF(SystemDpcBehaviourInformation
)
921 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
922 return (STATUS_NOT_IMPLEMENTED
);
925 SSI_DEF(SystemDpcBehaviourInformation
)
928 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
929 return (STATUS_NOT_IMPLEMENTED
);
932 /* Class 25 - Full Memory Information */
933 QSI_DEF(SystemFullMemoryInformation
)
935 PULONG Spi
= (PULONG
) Buffer
;
937 PEPROCESS TheIdleProcess
;
939 * ReqSize
= sizeof (ULONG
);
941 if (sizeof (ULONG
) != Size
)
943 return (STATUS_INFO_LENGTH_MISMATCH
);
945 DPRINT("SystemFullMemoryInformation\n");
947 TheIdleProcess
= PsInitialSystemProcess
; /* FIXME */
949 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
950 TheIdleProcess
->UniqueProcessId
,
951 TheIdleProcess
->Pcb
.KernelTime
,
956 MmPrintMemoryStatistic();
959 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
961 return (STATUS_SUCCESS
);
964 /* Class 26 - Load Image */
965 SSI_DEF(SystemLoadImage
)
967 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
969 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
971 return(STATUS_INFO_LENGTH_MISMATCH
);
974 return(LdrpLoadImage(&Sli
->ModuleName
,
976 &Sli
->SectionPointer
,
978 &Sli
->ExportDirectory
));
981 /* Class 27 - Unload Image */
982 SSI_DEF(SystemUnloadImage
)
984 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
986 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
988 return(STATUS_INFO_LENGTH_MISMATCH
);
991 return(LdrpUnloadImage(Sui
->ModuleBase
));
994 /* Class 28 - Time Adjustment Information */
995 QSI_DEF(SystemTimeAdjustmentInformation
)
997 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
999 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
1000 return (STATUS_INFO_LENGTH_MISMATCH
);
1003 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1004 return (STATUS_NOT_IMPLEMENTED
);
1007 SSI_DEF(SystemTimeAdjustmentInformation
)
1009 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1011 return (STATUS_INFO_LENGTH_MISMATCH
);
1014 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1015 return (STATUS_NOT_IMPLEMENTED
);
1018 /* Class 29 - Summary Memory Information */
1019 QSI_DEF(SystemSummaryMemoryInformation
)
1022 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1023 return (STATUS_NOT_IMPLEMENTED
);
1026 /* Class 30 - Next Event Id Information */
1027 QSI_DEF(SystemNextEventIdInformation
)
1030 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1031 return (STATUS_NOT_IMPLEMENTED
);
1034 /* Class 31 - Event Ids Information */
1035 QSI_DEF(SystemEventIdsInformation
)
1038 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1039 return (STATUS_NOT_IMPLEMENTED
);
1042 /* Class 32 - Crash Dump Information */
1043 QSI_DEF(SystemCrashDumpInformation
)
1046 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1047 return (STATUS_NOT_IMPLEMENTED
);
1050 /* Class 33 - Exception Information */
1051 QSI_DEF(SystemExceptionInformation
)
1054 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1055 return (STATUS_NOT_IMPLEMENTED
);
1058 /* Class 34 - Crash Dump State Information */
1059 QSI_DEF(SystemCrashDumpStateInformation
)
1062 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1063 return (STATUS_NOT_IMPLEMENTED
);
1066 /* Class 35 - Kernel Debugger Information */
1067 QSI_DEF(SystemKernelDebuggerInformation
)
1070 DPRINT1("NtQuerySystemInformation - SystemKernelDebuggerInformation not implemented\n");
1071 return (STATUS_NOT_IMPLEMENTED
);
1074 /* Class 36 - Context Switch Information */
1075 QSI_DEF(SystemContextSwitchInformation
)
1078 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1079 return (STATUS_NOT_IMPLEMENTED
);
1082 /* Class 37 - Registry Quota Information */
1083 QSI_DEF(SystemRegistryQuotaInformation
)
1085 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1087 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1088 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1090 return STATUS_INFO_LENGTH_MISMATCH
;
1093 DPRINT1("Faking max registry size of 32 MB\n");
1094 srqi
->RegistryQuotaAllowed
= 0x2000000;
1095 srqi
->RegistryQuotaUsed
= 0x200000;
1096 srqi
->Reserved1
= (void*)0x200000;
1098 return STATUS_SUCCESS
;
1101 SSI_DEF(SystemRegistryQuotaInformation
)
1104 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1105 return (STATUS_NOT_IMPLEMENTED
);
1108 /* Class 38 - Load And Call Image */
1109 SSI_DEF(SystemLoadAndCallImage
)
1111 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
1113 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
1115 return(STATUS_INFO_LENGTH_MISMATCH
);
1118 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
1121 /* Class 39 - Priority Separation */
1122 SSI_DEF(SystemPrioritySeperation
)
1125 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1126 return (STATUS_NOT_IMPLEMENTED
);
1129 /* Class 40 - Plug Play Bus Information */
1130 QSI_DEF(SystemPlugPlayBusInformation
)
1133 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1134 return (STATUS_NOT_IMPLEMENTED
);
1137 /* Class 41 - Dock Information */
1138 QSI_DEF(SystemDockInformation
)
1141 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1142 return (STATUS_NOT_IMPLEMENTED
);
1145 /* Class 42 - Power Information */
1146 QSI_DEF(SystemPowerInformation
)
1149 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1150 return (STATUS_NOT_IMPLEMENTED
);
1153 /* Class 43 - Processor Speed Information */
1154 QSI_DEF(SystemProcessorSpeedInformation
)
1157 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1158 return (STATUS_NOT_IMPLEMENTED
);
1161 /* Class 44 - Current Time Zone Information */
1162 QSI_DEF(SystemCurrentTimeZoneInformation
)
1164 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1166 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1168 return STATUS_INFO_LENGTH_MISMATCH
;
1171 /* Copy the time zone information struct */
1174 sizeof(TIME_ZONE_INFORMATION
));
1176 return STATUS_SUCCESS
;
1180 SSI_DEF(SystemCurrentTimeZoneInformation
)
1182 /* Check user buffer's size */
1183 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1185 return STATUS_INFO_LENGTH_MISMATCH
;
1188 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1192 /* Class 45 - Lookaside Information */
1193 QSI_DEF(SystemLookasideInformation
)
1196 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1197 return (STATUS_NOT_IMPLEMENTED
);
1201 /* Class 46 - Set time slip event */
1202 SSI_DEF(SystemSetTimeSlipEvent
)
1205 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1206 return (STATUS_NOT_IMPLEMENTED
);
1210 /* Class 47 - Create a new session (TSE) */
1211 SSI_DEF(SystemCreateSession
)
1214 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1215 return (STATUS_NOT_IMPLEMENTED
);
1219 /* Class 48 - Delete an existing session (TSE) */
1220 SSI_DEF(SystemDeleteSession
)
1223 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1224 return (STATUS_NOT_IMPLEMENTED
);
1228 /* Class 49 - UNKNOWN */
1229 QSI_DEF(SystemInvalidInfoClass4
)
1232 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1233 return (STATUS_NOT_IMPLEMENTED
);
1237 /* Class 50 - System range start address */
1238 QSI_DEF(SystemRangeStartInformation
)
1241 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1242 return (STATUS_NOT_IMPLEMENTED
);
1246 /* Class 51 - Driver verifier information */
1247 QSI_DEF(SystemVerifierInformation
)
1250 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1251 return (STATUS_NOT_IMPLEMENTED
);
1255 SSI_DEF(SystemVerifierInformation
)
1258 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1259 return (STATUS_NOT_IMPLEMENTED
);
1263 /* Class 52 - Add a driver verifier */
1264 SSI_DEF(SystemAddVerifier
)
1267 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1268 return (STATUS_NOT_IMPLEMENTED
);
1272 /* Class 53 - A session's processes */
1273 QSI_DEF(SystemSessionProcessesInformation
)
1276 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1277 return (STATUS_NOT_IMPLEMENTED
);
1281 /* Query/Set Calls Table */
1285 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1286 NTSTATUS (* Set
) (PVOID
,ULONG
);
1293 // XX unknown behaviour
1295 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1296 #define SI_QX(n) {QSI_USE(n),NULL}
1297 #define SI_XS(n) {NULL,SSI_USE(n)}
1298 #define SI_XX(n) {NULL,NULL}
1304 SI_QX(SystemBasicInformation
),
1305 SI_QX(SystemProcessorInformation
),
1306 SI_QX(SystemPerformanceInformation
),
1307 SI_QX(SystemTimeOfDayInformation
),
1308 SI_QX(SystemPathInformation
), /* should be SI_XX */
1309 SI_QX(SystemProcessInformation
),
1310 SI_QX(SystemCallCountInformation
),
1311 SI_QX(SystemDeviceInformation
),
1312 SI_QX(SystemProcessorPerformanceInformation
),
1313 SI_QS(SystemFlagsInformation
),
1314 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1315 SI_QX(SystemModuleInformation
),
1316 SI_QX(SystemLocksInformation
),
1317 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1318 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1319 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1320 SI_QX(SystemHandleInformation
),
1321 SI_QX(SystemObjectInformation
),
1322 SI_QX(SystemPageFileInformation
),
1323 SI_QX(SystemVdmInstemulInformation
),
1324 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1325 SI_QS(SystemFileCacheInformation
),
1326 SI_QX(SystemPoolTagInformation
),
1327 SI_QX(SystemInterruptInformation
),
1328 SI_QS(SystemDpcBehaviourInformation
),
1329 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1330 SI_XS(SystemLoadImage
),
1331 SI_XS(SystemUnloadImage
),
1332 SI_QS(SystemTimeAdjustmentInformation
),
1333 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1334 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1335 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1336 SI_QX(SystemCrashDumpInformation
),
1337 SI_QX(SystemExceptionInformation
),
1338 SI_QX(SystemCrashDumpStateInformation
),
1339 SI_QX(SystemKernelDebuggerInformation
),
1340 SI_QX(SystemContextSwitchInformation
),
1341 SI_QS(SystemRegistryQuotaInformation
),
1342 SI_XS(SystemLoadAndCallImage
),
1343 SI_XS(SystemPrioritySeperation
),
1344 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1345 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1346 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1347 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1348 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1349 SI_QX(SystemLookasideInformation
),
1350 SI_XS(SystemSetTimeSlipEvent
),
1351 SI_XS(SystemCreateSession
),
1352 SI_XS(SystemDeleteSession
),
1353 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1354 SI_QX(SystemRangeStartInformation
),
1355 SI_QS(SystemVerifierInformation
),
1356 SI_XS(SystemAddVerifier
),
1357 SI_QX(SystemSessionProcessesInformation
)
1365 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1366 OUT PVOID UnsafeSystemInformation
,
1368 OUT PULONG UnsafeResultLength
)
1371 PVOID SystemInformation
;
1375 /* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
1376 SystemInformationClass );
1378 /*if (ExGetPreviousMode() == KernelMode)
1380 SystemInformation
= UnsafeSystemInformation
;
1384 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1385 if (SystemInformation == NULL)
1387 return(STATUS_NO_MEMORY);
1391 /* Clear user buffer. */
1392 RtlZeroMemory(SystemInformation
, Length
);
1395 * Check the request is valid.
1397 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1398 (SystemInformationClass
< SystemInformationClassMax
))
1400 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1403 * Hand the request to a subhandler.
1405 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1408 /*if (ExGetPreviousMode() != KernelMode)
1410 Status = MmCopyToCaller(UnsafeSystemInformation,
1413 ExFreePool(SystemInformation);
1414 if (!NT_SUCCESS(Status))
1419 if (UnsafeResultLength
!= NULL
)
1421 /*if (ExGetPreviousMode() == KernelMode)
1423 *UnsafeResultLength = ResultLength;
1427 Status
= MmCopyToCaller(UnsafeResultLength
,
1430 if (!NT_SUCCESS(Status
))
1439 return (STATUS_INVALID_INFO_CLASS
);
1445 NtSetSystemInformation (
1446 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1447 IN PVOID SystemInformation
,
1448 IN ULONG SystemInformationLength
1452 * If called from user mode, check
1453 * possible unsafe arguments.
1456 if (KernelMode
!= KeGetPreviousMode())
1460 // SystemInformation,
1470 * Check the request is valid.
1472 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1473 && (SystemInformationClass
< SystemInformationClassMax
)
1476 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1479 * Hand the request to a subhandler.
1481 return CallQS
[SystemInformationClass
].Set (
1483 SystemInformationLength
1487 return (STATUS_INVALID_INFO_CLASS
);
1493 NtFlushInstructionCache (
1494 IN HANDLE ProcessHandle
,
1495 IN PVOID BaseAddress
,
1496 IN UINT NumberOfBytesToFlush
1499 __asm__("wbinvd\n");
1500 return STATUS_SUCCESS
;