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
);
814 /* Class 16 - Handle Information */
815 QSI_DEF(SystemHandleInformation
)
818 DPRINT1("NtQuerySystemInformation - SystemHandleInformation not implemented\n");
819 return (STATUS_NOT_IMPLEMENTED
);
822 /* Class 17 - Information */
823 QSI_DEF(SystemObjectInformation
)
826 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
827 return (STATUS_NOT_IMPLEMENTED
);
830 /* Class 18 - Information */
831 QSI_DEF(SystemPageFileInformation
)
833 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
835 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
837 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
838 return (STATUS_INFO_LENGTH_MISMATCH
);
841 UNICODE_STRING FileName
; /* FIXME */
844 Spfi
->NextEntryOffset
= 0;
846 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
847 Spfi
->TotalInUse
= MiUsedSwapPages
;
848 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
849 Spfi
->PageFileName
= FileName
;
850 return (STATUS_SUCCESS
);
853 /* Class 19 - Vdm Instemul Information */
854 QSI_DEF(SystemVdmInstemulInformation
)
857 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
858 return (STATUS_NOT_IMPLEMENTED
);
861 /* Class 20 - Vdm Bop Information */
862 QSI_DEF(SystemVdmBopInformation
)
865 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
866 return (STATUS_NOT_IMPLEMENTED
);
869 /* Class 21 - File Cache Information */
870 QSI_DEF(SystemFileCacheInformation
)
872 SYSTEM_CACHE_INFORMATION
*Sci
= (SYSTEM_CACHE_INFORMATION
*) Buffer
;
874 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
876 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
877 return (STATUS_INFO_LENGTH_MISMATCH
);
879 /* Return the Byte size not the page size. */
881 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
883 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
885 Sci
->PageFaultCount
= 0; /* FIXME */
886 Sci
->MinimumWorkingSet
= 0; /* FIXME */
887 Sci
->MaximumWorkingSet
= 0; /* FIXME */
888 Sci
->TransitionSharedPages
= 0; /* FIXME */
889 Sci
->TransitionSharedPagesPeak
= 0; /* FIXME */
891 return (STATUS_SUCCESS
);
894 SSI_DEF(SystemFileCacheInformation
)
896 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
898 return (STATUS_INFO_LENGTH_MISMATCH
);
901 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
902 return (STATUS_NOT_IMPLEMENTED
);
905 /* Class 22 - Pool Tag Information */
906 QSI_DEF(SystemPoolTagInformation
)
909 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
910 return (STATUS_NOT_IMPLEMENTED
);
913 /* Class 23 - Interrupt Information */
914 QSI_DEF(SystemInterruptInformation
)
917 DPRINT1("NtQuerySystemInformation - SystemInterruptInformation not implemented\n");
918 return (STATUS_NOT_IMPLEMENTED
);
921 /* Class 24 - DPC Behaviour Information */
922 QSI_DEF(SystemDpcBehaviourInformation
)
925 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
926 return (STATUS_NOT_IMPLEMENTED
);
929 SSI_DEF(SystemDpcBehaviourInformation
)
932 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
933 return (STATUS_NOT_IMPLEMENTED
);
936 /* Class 25 - Full Memory Information */
937 QSI_DEF(SystemFullMemoryInformation
)
939 PULONG Spi
= (PULONG
) Buffer
;
941 PEPROCESS TheIdleProcess
;
943 * ReqSize
= sizeof (ULONG
);
945 if (sizeof (ULONG
) != Size
)
947 return (STATUS_INFO_LENGTH_MISMATCH
);
949 DPRINT("SystemFullMemoryInformation\n");
951 TheIdleProcess
= PsInitialSystemProcess
; /* FIXME */
953 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
954 TheIdleProcess
->UniqueProcessId
,
955 TheIdleProcess
->Pcb
.KernelTime
,
960 MmPrintMemoryStatistic();
963 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
965 return (STATUS_SUCCESS
);
968 /* Class 26 - Load Image */
969 SSI_DEF(SystemLoadImage
)
971 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
973 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
975 return(STATUS_INFO_LENGTH_MISMATCH
);
978 return(LdrpLoadImage(&Sli
->ModuleName
,
980 &Sli
->SectionPointer
,
982 &Sli
->ExportDirectory
));
985 /* Class 27 - Unload Image */
986 SSI_DEF(SystemUnloadImage
)
988 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
990 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
992 return(STATUS_INFO_LENGTH_MISMATCH
);
995 return(LdrpUnloadImage(Sui
->ModuleBase
));
998 /* Class 28 - Time Adjustment Information */
999 QSI_DEF(SystemTimeAdjustmentInformation
)
1001 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1003 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
1004 return (STATUS_INFO_LENGTH_MISMATCH
);
1007 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1008 return (STATUS_NOT_IMPLEMENTED
);
1011 SSI_DEF(SystemTimeAdjustmentInformation
)
1013 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1015 return (STATUS_INFO_LENGTH_MISMATCH
);
1018 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1019 return (STATUS_NOT_IMPLEMENTED
);
1022 /* Class 29 - Summary Memory Information */
1023 QSI_DEF(SystemSummaryMemoryInformation
)
1026 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1027 return (STATUS_NOT_IMPLEMENTED
);
1030 /* Class 30 - Next Event Id Information */
1031 QSI_DEF(SystemNextEventIdInformation
)
1034 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1035 return (STATUS_NOT_IMPLEMENTED
);
1038 /* Class 31 - Event Ids Information */
1039 QSI_DEF(SystemEventIdsInformation
)
1042 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1043 return (STATUS_NOT_IMPLEMENTED
);
1046 /* Class 32 - Crash Dump Information */
1047 QSI_DEF(SystemCrashDumpInformation
)
1050 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1051 return (STATUS_NOT_IMPLEMENTED
);
1054 /* Class 33 - Exception Information */
1055 QSI_DEF(SystemExceptionInformation
)
1058 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1059 return (STATUS_NOT_IMPLEMENTED
);
1062 /* Class 34 - Crash Dump State Information */
1063 QSI_DEF(SystemCrashDumpStateInformation
)
1066 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1067 return (STATUS_NOT_IMPLEMENTED
);
1070 /* Class 35 - Kernel Debugger Information */
1071 QSI_DEF(SystemKernelDebuggerInformation
)
1074 DPRINT1("NtQuerySystemInformation - SystemKernelDebuggerInformation not implemented\n");
1075 return (STATUS_NOT_IMPLEMENTED
);
1078 /* Class 36 - Context Switch Information */
1079 QSI_DEF(SystemContextSwitchInformation
)
1082 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1083 return (STATUS_NOT_IMPLEMENTED
);
1086 /* Class 37 - Registry Quota Information */
1087 QSI_DEF(SystemRegistryQuotaInformation
)
1089 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1091 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1092 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1094 return STATUS_INFO_LENGTH_MISMATCH
;
1097 DPRINT1("Faking max registry size of 32 MB\n");
1098 srqi
->RegistryQuotaAllowed
= 0x2000000;
1099 srqi
->RegistryQuotaUsed
= 0x200000;
1100 srqi
->Reserved1
= (void*)0x200000;
1102 return STATUS_SUCCESS
;
1105 SSI_DEF(SystemRegistryQuotaInformation
)
1108 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1109 return (STATUS_NOT_IMPLEMENTED
);
1112 /* Class 38 - Load And Call Image */
1113 SSI_DEF(SystemLoadAndCallImage
)
1115 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
1117 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
1119 return(STATUS_INFO_LENGTH_MISMATCH
);
1122 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
1125 /* Class 39 - Priority Separation */
1126 SSI_DEF(SystemPrioritySeperation
)
1129 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1130 return (STATUS_NOT_IMPLEMENTED
);
1133 /* Class 40 - Plug Play Bus Information */
1134 QSI_DEF(SystemPlugPlayBusInformation
)
1137 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1138 return (STATUS_NOT_IMPLEMENTED
);
1141 /* Class 41 - Dock Information */
1142 QSI_DEF(SystemDockInformation
)
1145 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1146 return (STATUS_NOT_IMPLEMENTED
);
1149 /* Class 42 - Power Information */
1150 QSI_DEF(SystemPowerInformation
)
1153 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1154 return (STATUS_NOT_IMPLEMENTED
);
1157 /* Class 43 - Processor Speed Information */
1158 QSI_DEF(SystemProcessorSpeedInformation
)
1161 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1162 return (STATUS_NOT_IMPLEMENTED
);
1165 /* Class 44 - Current Time Zone Information */
1166 QSI_DEF(SystemCurrentTimeZoneInformation
)
1168 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1170 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1172 return STATUS_INFO_LENGTH_MISMATCH
;
1175 /* Copy the time zone information struct */
1178 sizeof(TIME_ZONE_INFORMATION
));
1180 return STATUS_SUCCESS
;
1184 SSI_DEF(SystemCurrentTimeZoneInformation
)
1186 /* Check user buffer's size */
1187 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1189 return STATUS_INFO_LENGTH_MISMATCH
;
1192 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1196 /* Class 45 - Lookaside Information */
1197 QSI_DEF(SystemLookasideInformation
)
1200 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1201 return (STATUS_NOT_IMPLEMENTED
);
1205 /* Class 46 - Set time slip event */
1206 SSI_DEF(SystemSetTimeSlipEvent
)
1209 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1210 return (STATUS_NOT_IMPLEMENTED
);
1214 /* Class 47 - Create a new session (TSE) */
1215 SSI_DEF(SystemCreateSession
)
1218 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1219 return (STATUS_NOT_IMPLEMENTED
);
1223 /* Class 48 - Delete an existing session (TSE) */
1224 SSI_DEF(SystemDeleteSession
)
1227 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1228 return (STATUS_NOT_IMPLEMENTED
);
1232 /* Class 49 - UNKNOWN */
1233 QSI_DEF(SystemInvalidInfoClass4
)
1236 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1237 return (STATUS_NOT_IMPLEMENTED
);
1241 /* Class 50 - System range start address */
1242 QSI_DEF(SystemRangeStartInformation
)
1245 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1246 return (STATUS_NOT_IMPLEMENTED
);
1250 /* Class 51 - Driver verifier information */
1251 QSI_DEF(SystemVerifierInformation
)
1254 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1255 return (STATUS_NOT_IMPLEMENTED
);
1259 SSI_DEF(SystemVerifierInformation
)
1262 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1263 return (STATUS_NOT_IMPLEMENTED
);
1267 /* Class 52 - Add a driver verifier */
1268 SSI_DEF(SystemAddVerifier
)
1271 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1272 return (STATUS_NOT_IMPLEMENTED
);
1276 /* Class 53 - A session's processes */
1277 QSI_DEF(SystemSessionProcessesInformation
)
1280 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1281 return (STATUS_NOT_IMPLEMENTED
);
1285 /* Query/Set Calls Table */
1289 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1290 NTSTATUS (* Set
) (PVOID
,ULONG
);
1297 // XX unknown behaviour
1299 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1300 #define SI_QX(n) {QSI_USE(n),NULL}
1301 #define SI_XS(n) {NULL,SSI_USE(n)}
1302 #define SI_XX(n) {NULL,NULL}
1308 SI_QX(SystemBasicInformation
),
1309 SI_QX(SystemProcessorInformation
),
1310 SI_QX(SystemPerformanceInformation
),
1311 SI_QX(SystemTimeOfDayInformation
),
1312 SI_QX(SystemPathInformation
), /* should be SI_XX */
1313 SI_QX(SystemProcessInformation
),
1314 SI_QX(SystemCallCountInformation
),
1315 SI_QX(SystemDeviceInformation
),
1316 SI_QX(SystemProcessorPerformanceInformation
),
1317 SI_QS(SystemFlagsInformation
),
1318 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1319 SI_QX(SystemModuleInformation
),
1320 SI_QX(SystemLocksInformation
),
1321 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1322 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1323 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1324 SI_QX(SystemHandleInformation
),
1325 SI_QX(SystemObjectInformation
),
1326 SI_QX(SystemPageFileInformation
),
1327 SI_QX(SystemVdmInstemulInformation
),
1328 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1329 SI_QS(SystemFileCacheInformation
),
1330 SI_QX(SystemPoolTagInformation
),
1331 SI_QX(SystemInterruptInformation
),
1332 SI_QS(SystemDpcBehaviourInformation
),
1333 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1334 SI_XS(SystemLoadImage
),
1335 SI_XS(SystemUnloadImage
),
1336 SI_QS(SystemTimeAdjustmentInformation
),
1337 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1338 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1339 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1340 SI_QX(SystemCrashDumpInformation
),
1341 SI_QX(SystemExceptionInformation
),
1342 SI_QX(SystemCrashDumpStateInformation
),
1343 SI_QX(SystemKernelDebuggerInformation
),
1344 SI_QX(SystemContextSwitchInformation
),
1345 SI_QS(SystemRegistryQuotaInformation
),
1346 SI_XS(SystemLoadAndCallImage
),
1347 SI_XS(SystemPrioritySeperation
),
1348 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1349 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1350 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1351 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1352 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1353 SI_QX(SystemLookasideInformation
),
1354 SI_XS(SystemSetTimeSlipEvent
),
1355 SI_XS(SystemCreateSession
),
1356 SI_XS(SystemDeleteSession
),
1357 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1358 SI_QX(SystemRangeStartInformation
),
1359 SI_QS(SystemVerifierInformation
),
1360 SI_XS(SystemAddVerifier
),
1361 SI_QX(SystemSessionProcessesInformation
)
1369 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1370 OUT PVOID UnsafeSystemInformation
,
1372 OUT PULONG UnsafeResultLength
)
1375 PVOID SystemInformation
;
1381 /* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
1382 SystemInformationClass );
1384 /*if (ExGetPreviousMode() == KernelMode)
1386 SystemInformation
= UnsafeSystemInformation
;
1390 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1391 if (SystemInformation == NULL)
1393 return(STATUS_NO_MEMORY);
1397 /* Clear user buffer. */
1398 RtlZeroMemory(SystemInformation
, Length
);
1401 * Check the request is valid.
1403 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1404 (SystemInformationClass
< SystemInformationClassMax
))
1406 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1409 * Hand the request to a subhandler.
1411 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1414 /*if (ExGetPreviousMode() != KernelMode)
1416 Status = MmCopyToCaller(UnsafeSystemInformation,
1419 ExFreePool(SystemInformation);
1420 if (!NT_SUCCESS(Status))
1425 if (UnsafeResultLength
!= NULL
)
1427 /*if (ExGetPreviousMode() == KernelMode)
1429 *UnsafeResultLength = ResultLength;
1433 Status
= MmCopyToCaller(UnsafeResultLength
,
1436 if (!NT_SUCCESS(Status
))
1445 return (STATUS_INVALID_INFO_CLASS
);
1451 NtSetSystemInformation (
1452 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1453 IN PVOID SystemInformation
,
1454 IN ULONG SystemInformationLength
1460 * If called from user mode, check
1461 * possible unsafe arguments.
1464 if (KernelMode
!= KeGetPreviousMode())
1468 // SystemInformation,
1478 * Check the request is valid.
1480 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1481 && (SystemInformationClass
< SystemInformationClassMax
)
1484 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1487 * Hand the request to a subhandler.
1489 return CallQS
[SystemInformationClass
].Set (
1491 SystemInformationLength
1495 return (STATUS_INVALID_INFO_CLASS
);
1501 NtFlushInstructionCache (
1502 IN HANDLE ProcessHandle
,
1503 IN PVOID BaseAddress
,
1504 IN UINT NumberOfBytesToFlush
1509 __asm__("wbinvd\n");
1510 return STATUS_SUCCESS
;