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 PEPROCESS PsIdleProcess
;
19 extern ULONG NtGlobalFlag
; /* FIXME: it should go in a ddk/?.h */
20 ULONGLONG STDCALL
KeQueryInterruptTime(VOID
);
22 VOID
MmPrintMemoryStatistic(VOID
);
24 FAST_MUTEX ExpEnvironmentLock
;
25 ERESOURCE ExpFirmwareTableResource
;
26 LIST_ENTRY ExpFirmwareTableProviderListHead
;
28 /* FUNCTIONS *****************************************************************/
33 #undef ExGetPreviousMode
36 ExGetPreviousMode (VOID
)
38 return KeGetPreviousMode();
50 PHANDLE Handle OPTIONAL
61 ExGetCurrentProcessorCpuUsage (
69 Prcb
= KeGetCurrentPrcb();
71 ScaledIdle
= Prcb
->IdleThread
->KernelTime
* 100;
72 TotalTime
= Prcb
->KernelTime
+ Prcb
->UserTime
;
74 *CpuUsage
= (ULONG
)(100 - (ScaledIdle
/ TotalTime
));
84 ExGetCurrentProcessorCounts (
85 PULONG ThreadKernelTime
,
87 PULONG ProcessorNumber
92 Prcb
= KeGetCurrentPrcb();
94 *ThreadKernelTime
= Prcb
->KernelTime
+ Prcb
->UserTime
;
95 *TotalCpuTime
= Prcb
->CurrentThread
->KernelTime
;
96 *ProcessorNumber
= KeGetCurrentProcessorNumber();
104 ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature
)
106 /* Quick check to see if it exists at all */
107 if (ProcessorFeature
>= PROCESSOR_FEATURE_MAX
) return(FALSE
);
109 /* Return our support for it */
110 return(SharedUserData
->ProcessorFeatures
[ProcessorFeature
]);
118 ExVerifySuite(SUITE_TYPE SuiteType
)
120 if (SuiteType
== Personal
) return TRUE
;
125 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
126 OUT PWSTR ValueBuffer
,
127 IN ULONG ValueBufferLength
,
128 IN OUT PULONG ReturnLength OPTIONAL
)
131 UNICODE_STRING WName
;
135 UNICODE_STRING WValue
;
136 KPROCESSOR_MODE PreviousMode
;
137 NTSTATUS Status
= STATUS_SUCCESS
;
141 PreviousMode
= ExGetPreviousMode();
143 if(PreviousMode
!= KernelMode
)
147 ProbeForRead(VariableName
,
148 sizeof(UNICODE_STRING
),
150 ProbeForWrite(ValueBuffer
,
153 if(ReturnLength
!= NULL
)
155 ProbeForWriteUlong(ReturnLength
);
158 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
160 Status
= _SEH_GetExceptionCode();
164 if(!NT_SUCCESS(Status
))
171 * Copy the name to kernel space if necessary and convert it to ANSI.
173 Status
= ProbeAndCaptureUnicodeString(&WName
,
176 if(NT_SUCCESS(Status
))
179 * according to ntinternals the SeSystemEnvironmentName privilege is required!
181 if(!SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
184 ReleaseCapturedUnicodeString(&WName
,
186 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
187 return STATUS_PRIVILEGE_NOT_HELD
;
191 * convert the value name to ansi
193 Status
= RtlUnicodeStringToAnsiString(&AName
, &WName
, TRUE
);
194 ReleaseCapturedUnicodeString(&WName
,
196 if(!NT_SUCCESS(Status
))
202 * Create a temporary buffer for the value
204 Value
= ExAllocatePool(NonPagedPool
, ValueBufferLength
);
207 RtlFreeAnsiString(&AName
);
208 return STATUS_INSUFFICIENT_RESOURCES
;
212 * Get the environment variable
214 Result
= HalGetEnvironmentVariable(AName
.Buffer
,
215 (USHORT
)ValueBufferLength
,
219 RtlFreeAnsiString(&AName
);
221 return STATUS_UNSUCCESSFUL
;
225 * Convert the result to UNICODE, protect with SEH in case the value buffer
226 * isn't NULL-terminated!
230 RtlInitAnsiString(&AValue
, Value
);
231 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
233 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
235 Status
= _SEH_GetExceptionCode();
239 if(NT_SUCCESS(Status
))
242 * Copy the result back to the caller.
246 RtlCopyMemory(ValueBuffer
, WValue
.Buffer
, WValue
.Length
);
247 ValueBuffer
[WValue
.Length
/ sizeof(WCHAR
)] = L
'\0';
248 if(ReturnLength
!= NULL
)
250 *ReturnLength
= WValue
.Length
+ sizeof(WCHAR
);
253 Status
= STATUS_SUCCESS
;
255 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
257 Status
= _SEH_GetExceptionCode();
263 * Cleanup allocated resources.
265 RtlFreeAnsiString(&AName
);
274 NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
275 IN PUNICODE_STRING Value
)
277 UNICODE_STRING CapturedName
, CapturedValue
;
278 ANSI_STRING AName
, AValue
;
279 KPROCESSOR_MODE PreviousMode
;
284 PreviousMode
= ExGetPreviousMode();
287 * Copy the strings to kernel space if necessary
289 Status
= ProbeAndCaptureUnicodeString(&CapturedName
,
292 if(NT_SUCCESS(Status
))
294 Status
= ProbeAndCaptureUnicodeString(&CapturedValue
,
297 if(NT_SUCCESS(Status
))
300 * according to ntinternals the SeSystemEnvironmentName privilege is required!
302 if(SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
306 * convert the strings to ANSI
308 Status
= RtlUnicodeStringToAnsiString(&AName
,
311 if(NT_SUCCESS(Status
))
313 Status
= RtlUnicodeStringToAnsiString(&AValue
,
316 if(NT_SUCCESS(Status
))
318 BOOLEAN Result
= HalSetEnvironmentVariable(AName
.Buffer
,
321 Status
= (Result
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);
327 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
328 Status
= STATUS_PRIVILEGE_NOT_HELD
;
331 ReleaseCapturedUnicodeString(&CapturedValue
,
335 ReleaseCapturedUnicodeString(&CapturedName
,
344 NtEnumerateSystemEnvironmentValuesEx(IN ULONG InformationClass
,
346 IN ULONG BufferLength
)
349 return STATUS_NOT_IMPLEMENTED
;
354 NtQuerySystemEnvironmentValueEx(IN PUNICODE_STRING VariableName
,
355 IN LPGUID VendorGuid
)
358 return STATUS_NOT_IMPLEMENTED
;
363 NtSetSystemEnvironmentValueEx(IN PUNICODE_STRING VariableName
,
364 IN LPGUID VendorGuid
)
367 return STATUS_NOT_IMPLEMENTED
;
370 /* --- Query/Set System Information --- */
373 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
374 * so the stack is popped only in one place on x86 platform.
376 #define QSI_USE(n) QSI##n
378 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
380 #define SSI_USE(n) SSI##n
382 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
385 /* Class 0 - Basic Information */
386 QSI_DEF(SystemBasicInformation
)
388 PSYSTEM_BASIC_INFORMATION Sbi
389 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
391 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
393 * Check user buffer's size
395 if (Size
!= sizeof (SYSTEM_BASIC_INFORMATION
))
397 return (STATUS_INFO_LENGTH_MISMATCH
);
400 Sbi
->TimerResolution
= KeMaximumIncrement
;
401 Sbi
->PageSize
= PAGE_SIZE
;
402 Sbi
->NumberOfPhysicalPages
= MmStats
.NrTotalPages
;
403 Sbi
->LowestPhysicalPageNumber
= 0; /* FIXME */
404 Sbi
->HighestPhysicalPageNumber
= MmStats
.NrTotalPages
; /* FIXME */
405 Sbi
->AllocationGranularity
= MM_VIRTMEM_GRANULARITY
; /* hard coded on Intel? */
406 Sbi
->MinimumUserModeAddress
= 0x10000; /* Top of 64k */
407 Sbi
->MaximumUserModeAddress
= (ULONG_PTR
)MmHighestUserAddress
;
408 Sbi
->ActiveProcessorsAffinityMask
= KeActiveProcessors
;
409 Sbi
->NumberOfProcessors
= KeNumberProcessors
;
410 return (STATUS_SUCCESS
);
413 /* Class 1 - Processor Information */
414 QSI_DEF(SystemProcessorInformation
)
416 PSYSTEM_PROCESSOR_INFORMATION Spi
417 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
419 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
421 * Check user buffer's size
423 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
425 return (STATUS_INFO_LENGTH_MISMATCH
);
427 Prcb
= KeGetCurrentPrcb();
428 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
429 Spi
->ProcessorLevel
= Prcb
->CpuType
;
430 Spi
->ProcessorRevision
= Prcb
->CpuStep
;
432 Spi
->ProcessorFeatureBits
= Prcb
->FeatureBits
;
434 DPRINT("Arch %d Level %d Rev 0x%x\n", Spi
->ProcessorArchitecture
,
435 Spi
->ProcessorLevel
, Spi
->ProcessorRevision
);
437 return (STATUS_SUCCESS
);
440 /* Class 2 - Performance Information */
441 QSI_DEF(SystemPerformanceInformation
)
443 PSYSTEM_PERFORMANCE_INFORMATION Spi
444 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
446 PEPROCESS TheIdleProcess
;
448 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
450 * Check user buffer's size
452 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
454 return (STATUS_INFO_LENGTH_MISMATCH
);
457 TheIdleProcess
= PsIdleProcess
;
459 Spi
->IdleProcessTime
.QuadPart
= TheIdleProcess
->Pcb
.KernelTime
* 100000LL;
461 Spi
->IoReadTransferCount
= IoReadTransferCount
;
462 Spi
->IoWriteTransferCount
= IoWriteTransferCount
;
463 Spi
->IoOtherTransferCount
= IoOtherTransferCount
;
464 Spi
->IoReadOperationCount
= IoReadOperationCount
;
465 Spi
->IoWriteOperationCount
= IoWriteOperationCount
;
466 Spi
->IoOtherOperationCount
= IoOtherOperationCount
;
468 Spi
->AvailablePages
= MmStats
.NrFreePages
;
470 Add up all the used "Commitied" memory + pagefile.
471 Not sure this is right. 8^\
473 Spi
->CommittedPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
+
474 MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
+
475 MiMemoryConsumers
[MC_CACHE
].PagesUsed
+
476 MiMemoryConsumers
[MC_USER
].PagesUsed
+
479 Add up the full system total + pagefile.
480 All this make Taskmgr happy but not sure it is the right numbers.
481 This too, fixes some of GlobalMemoryStatusEx numbers.
483 Spi
->CommitLimit
= MmStats
.NrTotalPages
+ MiFreeSwapPages
+
486 Spi
->PeakCommitment
= 0; /* FIXME */
487 Spi
->PageFaultCount
= 0; /* FIXME */
488 Spi
->CopyOnWriteCount
= 0; /* FIXME */
489 Spi
->TransitionCount
= 0; /* FIXME */
490 Spi
->CacheTransitionCount
= 0; /* FIXME */
491 Spi
->DemandZeroCount
= 0; /* FIXME */
492 Spi
->PageReadCount
= 0; /* FIXME */
493 Spi
->PageReadIoCount
= 0; /* FIXME */
494 Spi
->CacheReadCount
= 0; /* FIXME */
495 Spi
->CacheIoCount
= 0; /* FIXME */
496 Spi
->DirtyPagesWriteCount
= 0; /* FIXME */
497 Spi
->DirtyWriteIoCount
= 0; /* FIXME */
498 Spi
->MappedPagesWriteCount
= 0; /* FIXME */
499 Spi
->MappedWriteIoCount
= 0; /* FIXME */
501 Spi
->PagedPoolPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
;
502 Spi
->PagedPoolAllocs
= 0; /* FIXME */
503 Spi
->PagedPoolFrees
= 0; /* FIXME */
504 Spi
->NonPagedPoolPages
= MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
;
505 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
506 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
508 Spi
->FreeSystemPtes
= 0; /* FIXME */
510 Spi
->ResidentSystemCodePage
= MmStats
.NrSystemPages
; /* FIXME */
512 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
513 Spi
->TotalSystemCodePages
= 0; /* FIXME */
514 Spi
->NonPagedPoolLookasideHits
= 0; /* FIXME */
515 Spi
->PagedPoolLookasideHits
= 0; /* FIXME */
516 Spi
->Spare3Count
= 0; /* FIXME */
518 Spi
->ResidentSystemCachePage
= MiMemoryConsumers
[MC_CACHE
].PagesUsed
;
519 Spi
->ResidentPagedPoolPage
= MmPagedPoolSize
; /* FIXME */
521 Spi
->ResidentSystemDriverPage
= 0; /* FIXME */
522 Spi
->CcFastReadNoWait
= 0; /* FIXME */
523 Spi
->CcFastReadWait
= 0; /* FIXME */
524 Spi
->CcFastReadResourceMiss
= 0; /* FIXME */
525 Spi
->CcFastReadNotPossible
= 0; /* FIXME */
527 Spi
->CcFastMdlReadNoWait
= 0; /* FIXME */
528 Spi
->CcFastMdlReadWait
= 0; /* FIXME */
529 Spi
->CcFastMdlReadResourceMiss
= 0; /* FIXME */
530 Spi
->CcFastMdlReadNotPossible
= 0; /* FIXME */
532 Spi
->CcMapDataNoWait
= 0; /* FIXME */
533 Spi
->CcMapDataWait
= 0; /* FIXME */
534 Spi
->CcMapDataNoWaitMiss
= 0; /* FIXME */
535 Spi
->CcMapDataWaitMiss
= 0; /* FIXME */
537 Spi
->CcPinMappedDataCount
= 0; /* FIXME */
538 Spi
->CcPinReadNoWait
= 0; /* FIXME */
539 Spi
->CcPinReadWait
= 0; /* FIXME */
540 Spi
->CcPinReadNoWaitMiss
= 0; /* FIXME */
541 Spi
->CcPinReadWaitMiss
= 0; /* FIXME */
542 Spi
->CcCopyReadNoWait
= 0; /* FIXME */
543 Spi
->CcCopyReadWait
= 0; /* FIXME */
544 Spi
->CcCopyReadNoWaitMiss
= 0; /* FIXME */
545 Spi
->CcCopyReadWaitMiss
= 0; /* FIXME */
547 Spi
->CcMdlReadNoWait
= 0; /* FIXME */
548 Spi
->CcMdlReadWait
= 0; /* FIXME */
549 Spi
->CcMdlReadNoWaitMiss
= 0; /* FIXME */
550 Spi
->CcMdlReadWaitMiss
= 0; /* FIXME */
551 Spi
->CcReadAheadIos
= 0; /* FIXME */
552 Spi
->CcLazyWriteIos
= 0; /* FIXME */
553 Spi
->CcLazyWritePages
= 0; /* FIXME */
554 Spi
->CcDataFlushes
= 0; /* FIXME */
555 Spi
->CcDataPages
= 0; /* FIXME */
556 Spi
->ContextSwitches
= 0; /* FIXME */
557 Spi
->FirstLevelTbFills
= 0; /* FIXME */
558 Spi
->SecondLevelTbFills
= 0; /* FIXME */
559 Spi
->SystemCalls
= 0; /* FIXME */
561 return (STATUS_SUCCESS
);
564 /* Class 3 - Time Of Day Information */
565 QSI_DEF(SystemTimeOfDayInformation
)
567 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
568 LARGE_INTEGER CurrentTime
;
570 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
571 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
573 /* Check user buffer's size */
574 if (Size
!= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
576 return STATUS_INFO_LENGTH_MISMATCH
;
579 KeQuerySystemTime(&CurrentTime
);
581 Sti
->BootTime
= KeBootTime
;
582 Sti
->CurrentTime
= CurrentTime
;
583 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
584 Sti
->TimeZoneId
= ExpTimeZoneId
;
587 return STATUS_SUCCESS
;
590 /* Class 4 - Path Information */
591 QSI_DEF(SystemPathInformation
)
593 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
594 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
596 return (STATUS_BREAKPOINT
);
599 /* Class 5 - Process Information */
600 QSI_DEF(SystemProcessInformation
)
602 ULONG ovlSize
= 0, nThreads
;
603 PEPROCESS pr
= NULL
, syspr
;
605 NTSTATUS Status
= STATUS_SUCCESS
;
609 /* scan the process list */
611 PSYSTEM_PROCESS_INFORMATION Spi
612 = (PSYSTEM_PROCESS_INFORMATION
) Buffer
;
614 *ReqSize
= sizeof(SYSTEM_PROCESS_INFORMATION
);
616 if (Size
< sizeof(SYSTEM_PROCESS_INFORMATION
))
618 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
621 syspr
= PsGetNextProcess(NULL
);
623 pCur
= (unsigned char *)Spi
;
627 PSYSTEM_PROCESS_INFORMATION SpiCur
;
630 int inLen
=32; // image name len in bytes
631 PLIST_ENTRY current_entry
;
633 PSYSTEM_THREAD_INFORMATION ThreadInfo
;
635 SpiCur
= (PSYSTEM_PROCESS_INFORMATION
)pCur
;
638 current_entry
= pr
->ThreadListHead
.Flink
;
639 while (current_entry
!= &pr
->ThreadListHead
)
642 current_entry
= current_entry
->Flink
;
645 // size of the structure for every process
646 curSize
= sizeof(SYSTEM_PROCESS_INFORMATION
)+sizeof(SYSTEM_THREAD_INFORMATION
)*nThreads
;
647 ovlSize
+= curSize
+inLen
;
652 ObDereferenceObject(pr
);
654 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
657 // fill system information
658 SpiCur
->NextEntryOffset
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
659 SpiCur
->NumberOfThreads
= nThreads
;
660 SpiCur
->CreateTime
= pr
->CreateTime
;
661 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
662 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
663 SpiCur
->ImageName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
664 SpiCur
->ImageName
.MaximumLength
= inLen
;
665 SpiCur
->ImageName
.Buffer
= (void*)(pCur
+curSize
);
667 // copy name to the end of the struct
668 if(pr
!= PsIdleProcess
)
670 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
671 RtlAnsiStringToUnicodeString(&SpiCur
->ImageName
, &imgName
, FALSE
);
675 RtlInitUnicodeString(&SpiCur
->ImageName
, NULL
);
678 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
679 SpiCur
->UniqueProcessId
= pr
->UniqueProcessId
;
680 SpiCur
->InheritedFromUniqueProcessId
= pr
->InheritedFromUniqueProcessId
;
681 SpiCur
->HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
682 SpiCur
->PeakVirtualSize
= pr
->PeakVirtualSize
;
683 SpiCur
->VirtualSize
= pr
->VirtualSize
;
684 SpiCur
->PageFaultCount
= pr
->Vm
.PageFaultCount
;
685 SpiCur
->PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
;
686 SpiCur
->WorkingSetSize
= pr
->Vm
.WorkingSetSize
;
687 SpiCur
->QuotaPeakPagedPoolUsage
= pr
->QuotaPeak
[0];
688 SpiCur
->QuotaPagedPoolUsage
= pr
->QuotaUsage
[0];
689 SpiCur
->QuotaPeakNonPagedPoolUsage
= pr
->QuotaPeak
[1];
690 SpiCur
->QuotaNonPagedPoolUsage
= pr
->QuotaUsage
[1];
691 SpiCur
->PagefileUsage
= pr
->QuotaUsage
[2];
692 SpiCur
->PeakPagefileUsage
= pr
->QuotaPeak
[2];
693 SpiCur
->PrivatePageCount
= pr
->CommitCharge
;
694 ThreadInfo
= (PSYSTEM_THREAD_INFORMATION
)(SpiCur
+ 1);
696 current_entry
= pr
->ThreadListHead
.Flink
;
697 while (current_entry
!= &pr
->ThreadListHead
)
699 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
703 ThreadInfo
->KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
704 ThreadInfo
->UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
705 // SpiCur->TH[i].CreateTime = current->CreateTime;
706 ThreadInfo
->WaitTime
= current
->Tcb
.WaitTime
;
707 ThreadInfo
->StartAddress
= (PVOID
) current
->StartAddress
;
708 ThreadInfo
->ClientId
= current
->Cid
;
709 ThreadInfo
->Priority
= current
->Tcb
.Priority
;
710 ThreadInfo
->BasePriority
= current
->Tcb
.BasePriority
;
711 ThreadInfo
->ContextSwitches
= current
->Tcb
.ContextSwitches
;
712 ThreadInfo
->ThreadState
= current
->Tcb
.State
;
713 ThreadInfo
->WaitReason
= current
->Tcb
.WaitReason
;
715 current_entry
= current_entry
->Flink
;
718 pr
= PsGetNextProcess(pr
);
720 if ((pr
== syspr
) || (pr
== NULL
))
722 SpiCur
->NextEntryOffset
= 0;
726 pCur
= pCur
+ curSize
+ inLen
;
727 } while ((pr
!= syspr
) && (pr
!= NULL
));
730 ObDereferenceObject(pr
);
731 Status
= STATUS_SUCCESS
;
736 ObDereferenceObject(pr
);
737 Status
= _SEH_GetExceptionCode();
745 /* Class 6 - Call Count Information */
746 QSI_DEF(SystemCallCountInformation
)
749 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
750 return (STATUS_NOT_IMPLEMENTED
);
753 /* Class 7 - Device Information */
754 QSI_DEF(SystemDeviceInformation
)
756 PSYSTEM_DEVICE_INFORMATION Sdi
757 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
758 PCONFIGURATION_INFORMATION ConfigInfo
;
760 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
762 * Check user buffer's size
764 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
766 return (STATUS_INFO_LENGTH_MISMATCH
);
769 ConfigInfo
= IoGetConfigurationInformation ();
771 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
772 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
773 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
774 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
775 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
776 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
778 return (STATUS_SUCCESS
);
781 /* Class 8 - Processor Performance Information */
782 QSI_DEF(SystemProcessorPerformanceInformation
)
784 PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Spi
785 = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
) Buffer
;
788 LARGE_INTEGER CurrentTime
;
791 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
);
793 * Check user buffer's size
795 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
))
797 return (STATUS_INFO_LENGTH_MISMATCH
);
800 CurrentTime
.QuadPart
= KeQueryInterruptTime();
801 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
802 for (i
= 0; i
< KeNumberProcessors
; i
++)
804 Spi
->IdleTime
.QuadPart
= (Prcb
->IdleThread
->KernelTime
+ Prcb
->IdleThread
->UserTime
) * 100000LL; // IdleTime
805 Spi
->KernelTime
.QuadPart
= Prcb
->KernelTime
* 100000LL; // KernelTime
806 Spi
->UserTime
.QuadPart
= Prcb
->UserTime
* 100000LL;
807 Spi
->DpcTime
.QuadPart
= Prcb
->DpcTime
* 100000LL;
808 Spi
->InterruptTime
.QuadPart
= Prcb
->InterruptTime
* 100000LL;
809 Spi
->InterruptCount
= Prcb
->InterruptCount
; // Interrupt Count
811 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
814 return (STATUS_SUCCESS
);
817 /* Class 9 - Flags Information */
818 QSI_DEF(SystemFlagsInformation
)
820 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
822 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
823 return (STATUS_INFO_LENGTH_MISMATCH
);
825 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
826 return (STATUS_SUCCESS
);
829 SSI_DEF(SystemFlagsInformation
)
831 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
833 return (STATUS_INFO_LENGTH_MISMATCH
);
835 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
836 return (STATUS_SUCCESS
);
839 /* Class 10 - Call Time Information */
840 QSI_DEF(SystemCallTimeInformation
)
843 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
844 return (STATUS_NOT_IMPLEMENTED
);
847 /* Class 11 - Module Information */
848 QSI_DEF(SystemModuleInformation
)
850 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
853 /* Class 12 - Locks Information */
854 QSI_DEF(SystemLocksInformation
)
857 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
858 return (STATUS_NOT_IMPLEMENTED
);
861 /* Class 13 - Stack Trace Information */
862 QSI_DEF(SystemStackTraceInformation
)
865 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
866 return (STATUS_NOT_IMPLEMENTED
);
869 /* Class 14 - Paged Pool Information */
870 QSI_DEF(SystemPagedPoolInformation
)
873 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
874 return (STATUS_NOT_IMPLEMENTED
);
877 /* Class 15 - Non Paged Pool Information */
878 QSI_DEF(SystemNonPagedPoolInformation
)
881 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
882 return (STATUS_NOT_IMPLEMENTED
);
886 /* Class 16 - Handle Information */
887 QSI_DEF(SystemHandleInformation
)
890 ULONG curSize
, i
= 0;
893 PSYSTEM_HANDLE_INFORMATION Shi
=
894 (PSYSTEM_HANDLE_INFORMATION
) Buffer
;
896 DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
898 if (Size
< sizeof (SYSTEM_HANDLE_INFORMATION
))
900 * ReqSize
= sizeof (SYSTEM_HANDLE_INFORMATION
);
901 return (STATUS_INFO_LENGTH_MISMATCH
);
904 DPRINT("SystemHandleInformation 1\n");
906 /* First Calc Size from Count. */
907 syspr
= PsGetNextProcess(NULL
);
912 hCount
= hCount
+ (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
913 pr
= PsGetNextProcess(pr
);
915 if ((pr
== syspr
) || (pr
== NULL
))
917 } while ((pr
!= syspr
) && (pr
!= NULL
));
921 ObDereferenceObject(pr
);
924 DPRINT("SystemHandleInformation 2\n");
926 curSize
= sizeof(SYSTEM_HANDLE_INFORMATION
)+
927 ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) * hCount
) -
928 (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) ));
930 Shi
->NumberOfHandles
= hCount
;
935 return (STATUS_INFO_LENGTH_MISMATCH
);
938 DPRINT("SystemHandleInformation 3\n");
940 /* Now get Handles from all processs. */
941 syspr
= PsGetNextProcess(NULL
);
946 int Count
= 0, HandleCount
;
948 HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
950 for (Count
= 0; HandleCount
> 0 ; HandleCount
--)
952 Shi
->Handles
[i
].UniqueProcessId
= (ULONG
)pr
->UniqueProcessId
;
957 pr
= PsGetNextProcess(pr
);
959 if ((pr
== syspr
) || (pr
== NULL
))
961 } while ((pr
!= syspr
) && (pr
!= NULL
));
965 ObDereferenceObject(pr
);
968 DPRINT("SystemHandleInformation 4\n");
969 return (STATUS_SUCCESS
);
973 SSI_DEF(SystemHandleInformation)
976 return (STATUS_SUCCESS);
980 /* Class 17 - Information */
981 QSI_DEF(SystemObjectInformation
)
984 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
985 return (STATUS_NOT_IMPLEMENTED
);
988 /* Class 18 - Information */
989 QSI_DEF(SystemPageFileInformation
)
991 UNICODE_STRING FileName
; /* FIXME */
992 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
994 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
996 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
997 return (STATUS_INFO_LENGTH_MISMATCH
);
1000 RtlInitUnicodeString(&FileName
, NULL
); /* FIXME */
1003 Spfi
->NextEntryOffset
= 0;
1005 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
1006 Spfi
->TotalInUse
= MiUsedSwapPages
;
1007 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
1008 Spfi
->PageFileName
= FileName
;
1009 return (STATUS_SUCCESS
);
1012 /* Class 19 - Vdm Instemul Information */
1013 QSI_DEF(SystemVdmInstemulInformation
)
1016 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
1017 return (STATUS_NOT_IMPLEMENTED
);
1020 /* Class 20 - Vdm Bop Information */
1021 QSI_DEF(SystemVdmBopInformation
)
1024 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
1025 return (STATUS_NOT_IMPLEMENTED
);
1028 /* Class 21 - File Cache Information */
1029 QSI_DEF(SystemFileCacheInformation
)
1031 SYSTEM_FILECACHE_INFORMATION
*Sci
= (SYSTEM_FILECACHE_INFORMATION
*) Buffer
;
1033 if (Size
< sizeof (SYSTEM_FILECACHE_INFORMATION
))
1035 * ReqSize
= sizeof (SYSTEM_FILECACHE_INFORMATION
);
1036 return (STATUS_INFO_LENGTH_MISMATCH
);
1039 RtlZeroMemory(Sci
, sizeof(SYSTEM_FILECACHE_INFORMATION
));
1041 /* Return the Byte size not the page size. */
1043 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
1045 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
1047 Sci
->PageFaultCount
= 0; /* FIXME */
1048 Sci
->MinimumWorkingSet
= 0; /* FIXME */
1049 Sci
->MaximumWorkingSet
= 0; /* FIXME */
1051 return (STATUS_SUCCESS
);
1054 SSI_DEF(SystemFileCacheInformation
)
1056 if (Size
< sizeof (SYSTEM_FILECACHE_INFORMATION
))
1058 return (STATUS_INFO_LENGTH_MISMATCH
);
1061 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
1062 return (STATUS_NOT_IMPLEMENTED
);
1065 /* Class 22 - Pool Tag Information */
1066 QSI_DEF(SystemPoolTagInformation
)
1069 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
1070 return (STATUS_NOT_IMPLEMENTED
);
1073 /* Class 23 - Interrupt Information for all processors */
1074 QSI_DEF(SystemInterruptInformation
)
1079 PSYSTEM_INTERRUPT_INFORMATION sii
= (PSYSTEM_INTERRUPT_INFORMATION
)Buffer
;
1081 if(Size
< KeNumberProcessors
* sizeof(SYSTEM_INTERRUPT_INFORMATION
))
1083 return (STATUS_INFO_LENGTH_MISMATCH
);
1086 ti
= KeQueryTimeIncrement();
1088 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
1089 for (i
= 0; i
< KeNumberProcessors
; i
++)
1091 //sii->ContextSwitches = Prcb->KeContextSwitches;
1092 sii
->DpcCount
= 0; /* FIXME */
1093 sii
->DpcRate
= 0; /* FIXME */
1094 sii
->TimeIncrement
= ti
;
1095 sii
->DpcBypassCount
= 0; /* FIXME */
1096 sii
->ApcBypassCount
= 0; /* FIXME */
1098 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
1101 return STATUS_SUCCESS
;
1104 /* Class 24 - DPC Behaviour Information */
1105 QSI_DEF(SystemDpcBehaviourInformation
)
1108 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
1109 return (STATUS_NOT_IMPLEMENTED
);
1112 SSI_DEF(SystemDpcBehaviourInformation
)
1115 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1116 return (STATUS_NOT_IMPLEMENTED
);
1119 /* Class 25 - Full Memory Information */
1120 QSI_DEF(SystemFullMemoryInformation
)
1122 PULONG Spi
= (PULONG
) Buffer
;
1124 PEPROCESS TheIdleProcess
;
1126 * ReqSize
= sizeof (ULONG
);
1128 if (sizeof (ULONG
) != Size
)
1130 return (STATUS_INFO_LENGTH_MISMATCH
);
1132 DPRINT("SystemFullMemoryInformation\n");
1134 TheIdleProcess
= PsIdleProcess
;
1136 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
1137 TheIdleProcess
->UniqueProcessId
,
1138 TheIdleProcess
->Pcb
.KernelTime
,
1143 MmPrintMemoryStatistic();
1146 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
1148 return (STATUS_SUCCESS
);
1151 /* Class 26 - Load Image */
1152 SSI_DEF(SystemLoadImage
)
1154 PSYSTEM_GDI_DRIVER_INFORMATION Sli
= (PSYSTEM_GDI_DRIVER_INFORMATION
)Buffer
;
1156 if (sizeof(SYSTEM_GDI_DRIVER_INFORMATION
) != Size
)
1158 return(STATUS_INFO_LENGTH_MISMATCH
);
1161 return(LdrpLoadImage(&Sli
->DriverName
,
1163 &Sli
->SectionPointer
,
1165 (PVOID
)&Sli
->ExportSectionPointer
));
1168 /* Class 27 - Unload Image */
1169 SSI_DEF(SystemUnloadImage
)
1171 PVOID Sui
= (PVOID
)Buffer
;
1173 if (sizeof(PVOID
) != Size
)
1175 return(STATUS_INFO_LENGTH_MISMATCH
);
1178 return(LdrpUnloadImage(Sui
));
1181 /* Class 28 - Time Adjustment Information */
1182 QSI_DEF(SystemTimeAdjustmentInformation
)
1184 if (sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
) > Size
)
1186 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
);
1187 return (STATUS_INFO_LENGTH_MISMATCH
);
1190 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1191 return (STATUS_NOT_IMPLEMENTED
);
1194 SSI_DEF(SystemTimeAdjustmentInformation
)
1196 if (sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
) > Size
)
1198 return (STATUS_INFO_LENGTH_MISMATCH
);
1201 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1202 return (STATUS_NOT_IMPLEMENTED
);
1205 /* Class 29 - Summary Memory Information */
1206 QSI_DEF(SystemSummaryMemoryInformation
)
1209 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1210 return (STATUS_NOT_IMPLEMENTED
);
1213 /* Class 30 - Next Event Id Information */
1214 QSI_DEF(SystemNextEventIdInformation
)
1217 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1218 return (STATUS_NOT_IMPLEMENTED
);
1221 /* Class 31 - Event Ids Information */
1222 QSI_DEF(SystemEventIdsInformation
)
1225 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1226 return (STATUS_NOT_IMPLEMENTED
);
1229 /* Class 32 - Crash Dump Information */
1230 QSI_DEF(SystemCrashDumpInformation
)
1233 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1234 return (STATUS_NOT_IMPLEMENTED
);
1237 /* Class 33 - Exception Information */
1238 QSI_DEF(SystemExceptionInformation
)
1241 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1242 return (STATUS_NOT_IMPLEMENTED
);
1245 /* Class 34 - Crash Dump State Information */
1246 QSI_DEF(SystemCrashDumpStateInformation
)
1249 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1250 return (STATUS_NOT_IMPLEMENTED
);
1253 /* Class 35 - Kernel Debugger Information */
1254 QSI_DEF(SystemKernelDebuggerInformation
)
1256 PSYSTEM_KERNEL_DEBUGGER_INFORMATION skdi
= (PSYSTEM_KERNEL_DEBUGGER_INFORMATION
) Buffer
;
1258 *ReqSize
= sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION
);
1259 if (Size
< sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION
))
1261 return STATUS_INFO_LENGTH_MISMATCH
;
1264 skdi
->KernelDebuggerEnabled
= KD_DEBUGGER_ENABLED
;
1265 skdi
->KernelDebuggerNotPresent
= KD_DEBUGGER_NOT_PRESENT
;
1267 return STATUS_SUCCESS
;
1270 /* Class 36 - Context Switch Information */
1271 QSI_DEF(SystemContextSwitchInformation
)
1274 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1275 return (STATUS_NOT_IMPLEMENTED
);
1278 /* Class 37 - Registry Quota Information */
1279 QSI_DEF(SystemRegistryQuotaInformation
)
1281 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1283 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1284 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1286 return STATUS_INFO_LENGTH_MISMATCH
;
1289 DPRINT1("Faking max registry size of 32 MB\n");
1290 srqi
->RegistryQuotaAllowed
= 0x2000000;
1291 srqi
->RegistryQuotaUsed
= 0x200000;
1292 srqi
->PagedPoolSize
= 0x200000;
1294 return STATUS_SUCCESS
;
1297 SSI_DEF(SystemRegistryQuotaInformation
)
1300 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1301 return (STATUS_NOT_IMPLEMENTED
);
1304 /* Class 38 - Load And Call Image */
1305 SSI_DEF(SystemLoadAndCallImage
)
1307 PUNICODE_STRING Slci
= (PUNICODE_STRING
)Buffer
;
1309 if (sizeof(UNICODE_STRING
) != Size
)
1311 return(STATUS_INFO_LENGTH_MISMATCH
);
1314 return(LdrpLoadAndCallImage(Slci
));
1317 /* Class 39 - Priority Separation */
1318 SSI_DEF(SystemPrioritySeperation
)
1321 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1322 return (STATUS_NOT_IMPLEMENTED
);
1325 /* Class 40 - Plug Play Bus Information */
1326 QSI_DEF(SystemPlugPlayBusInformation
)
1329 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1330 return (STATUS_NOT_IMPLEMENTED
);
1333 /* Class 41 - Dock Information */
1334 QSI_DEF(SystemDockInformation
)
1337 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1338 return (STATUS_NOT_IMPLEMENTED
);
1341 /* Class 42 - Power Information */
1342 QSI_DEF(SystemPowerInformation
)
1345 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1346 return (STATUS_NOT_IMPLEMENTED
);
1349 /* Class 43 - Processor Speed Information */
1350 QSI_DEF(SystemProcessorSpeedInformation
)
1353 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1354 return (STATUS_NOT_IMPLEMENTED
);
1357 /* Class 44 - Current Time Zone Information */
1358 QSI_DEF(SystemCurrentTimeZoneInformation
)
1360 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1362 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1364 return STATUS_INFO_LENGTH_MISMATCH
;
1367 /* Copy the time zone information struct */
1370 sizeof(TIME_ZONE_INFORMATION
));
1372 return STATUS_SUCCESS
;
1376 SSI_DEF(SystemCurrentTimeZoneInformation
)
1378 /* Check user buffer's size */
1379 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1381 return STATUS_INFO_LENGTH_MISMATCH
;
1384 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1388 /* Class 45 - Lookaside Information */
1389 QSI_DEF(SystemLookasideInformation
)
1392 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1393 return (STATUS_NOT_IMPLEMENTED
);
1397 /* Class 46 - Set time slip event */
1398 SSI_DEF(SystemSetTimeSlipEvent
)
1401 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1402 return (STATUS_NOT_IMPLEMENTED
);
1406 /* Class 47 - Create a new session (TSE) */
1407 SSI_DEF(SystemCreateSession
)
1410 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1411 return (STATUS_NOT_IMPLEMENTED
);
1415 /* Class 48 - Delete an existing session (TSE) */
1416 SSI_DEF(SystemDeleteSession
)
1419 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1420 return (STATUS_NOT_IMPLEMENTED
);
1424 /* Class 49 - UNKNOWN */
1425 QSI_DEF(SystemInvalidInfoClass4
)
1428 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1429 return (STATUS_NOT_IMPLEMENTED
);
1433 /* Class 50 - System range start address */
1434 QSI_DEF(SystemRangeStartInformation
)
1437 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1438 return (STATUS_NOT_IMPLEMENTED
);
1442 /* Class 51 - Driver verifier information */
1443 QSI_DEF(SystemVerifierInformation
)
1446 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1447 return (STATUS_NOT_IMPLEMENTED
);
1451 SSI_DEF(SystemVerifierInformation
)
1454 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1455 return (STATUS_NOT_IMPLEMENTED
);
1459 /* Class 52 - Add a driver verifier */
1460 SSI_DEF(SystemAddVerifier
)
1463 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1464 return (STATUS_NOT_IMPLEMENTED
);
1468 /* Class 53 - A session's processes */
1469 QSI_DEF(SystemSessionProcessesInformation
)
1472 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1473 return (STATUS_NOT_IMPLEMENTED
);
1477 /* Query/Set Calls Table */
1481 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1482 NTSTATUS (* Set
) (PVOID
,ULONG
);
1489 // XX unknown behaviour
1491 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1492 #define SI_QX(n) {QSI_USE(n),NULL}
1493 #define SI_XS(n) {NULL,SSI_USE(n)}
1494 #define SI_XX(n) {NULL,NULL}
1500 SI_QX(SystemBasicInformation
),
1501 SI_QX(SystemProcessorInformation
),
1502 SI_QX(SystemPerformanceInformation
),
1503 SI_QX(SystemTimeOfDayInformation
),
1504 SI_QX(SystemPathInformation
), /* should be SI_XX */
1505 SI_QX(SystemProcessInformation
),
1506 SI_QX(SystemCallCountInformation
),
1507 SI_QX(SystemDeviceInformation
),
1508 SI_QX(SystemProcessorPerformanceInformation
),
1509 SI_QS(SystemFlagsInformation
),
1510 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1511 SI_QX(SystemModuleInformation
),
1512 SI_QX(SystemLocksInformation
),
1513 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1514 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1515 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1516 SI_QX(SystemHandleInformation
),
1517 SI_QX(SystemObjectInformation
),
1518 SI_QX(SystemPageFileInformation
),
1519 SI_QX(SystemVdmInstemulInformation
),
1520 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1521 SI_QS(SystemFileCacheInformation
),
1522 SI_QX(SystemPoolTagInformation
),
1523 SI_QX(SystemInterruptInformation
),
1524 SI_QS(SystemDpcBehaviourInformation
),
1525 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1526 SI_XS(SystemLoadImage
),
1527 SI_XS(SystemUnloadImage
),
1528 SI_QS(SystemTimeAdjustmentInformation
),
1529 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1530 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1531 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1532 SI_QX(SystemCrashDumpInformation
),
1533 SI_QX(SystemExceptionInformation
),
1534 SI_QX(SystemCrashDumpStateInformation
),
1535 SI_QX(SystemKernelDebuggerInformation
),
1536 SI_QX(SystemContextSwitchInformation
),
1537 SI_QS(SystemRegistryQuotaInformation
),
1538 SI_XS(SystemLoadAndCallImage
),
1539 SI_XS(SystemPrioritySeperation
),
1540 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1541 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1542 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1543 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1544 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1545 SI_QX(SystemLookasideInformation
),
1546 SI_XS(SystemSetTimeSlipEvent
),
1547 SI_XS(SystemCreateSession
),
1548 SI_XS(SystemDeleteSession
),
1549 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1550 SI_QX(SystemRangeStartInformation
),
1551 SI_QS(SystemVerifierInformation
),
1552 SI_XS(SystemAddVerifier
),
1553 SI_QX(SystemSessionProcessesInformation
)
1561 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1562 OUT PVOID SystemInformation
,
1564 OUT PULONG UnsafeResultLength
)
1566 KPROCESSOR_MODE PreviousMode
;
1568 NTSTATUS FStatus
= STATUS_NOT_IMPLEMENTED
;
1572 PreviousMode
= ExGetPreviousMode();
1576 if (PreviousMode
!= KernelMode
)
1578 /* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
1579 ProbeForWrite(SystemInformation
, Length
, 1);
1580 if (UnsafeResultLength
!= NULL
)
1581 ProbeForWriteUlong(UnsafeResultLength
);
1584 /* Clear user buffer. */
1585 RtlZeroMemory(SystemInformation
, Length
);
1588 * Check the request is valid.
1590 if (SystemInformationClass
>= MaxSystemInfoClass
)
1592 return (STATUS_INVALID_INFO_CLASS
);
1595 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1598 * Hand the request to a subhandler.
1600 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1603 if (UnsafeResultLength
!= NULL
)
1605 if (PreviousMode
!= KernelMode
)
1609 *UnsafeResultLength
= ResultLength
;
1611 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
1613 FStatus
= _SEH_GetExceptionCode();
1619 *UnsafeResultLength
= ResultLength
;
1624 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
1626 FStatus
= _SEH_GetExceptionCode();
1636 NtSetSystemInformation (
1637 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1638 IN PVOID SystemInformation
,
1639 IN ULONG SystemInformationLength
1645 * If called from user mode, check
1646 * possible unsafe arguments.
1649 if (KernelMode
!= KeGetPreviousMode())
1653 // SystemInformation,
1663 * Check the request is valid.
1665 if ( (SystemInformationClass
>= SystemBasicInformation
)
1666 && (SystemInformationClass
< MaxSystemInfoClass
)
1669 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1672 * Hand the request to a subhandler.
1674 return CallQS
[SystemInformationClass
].Set (
1676 SystemInformationLength
1680 return (STATUS_INVALID_INFO_CLASS
);
1686 NtFlushInstructionCache (
1687 IN HANDLE ProcessHandle
,
1688 IN PVOID BaseAddress
,
1689 IN ULONG NumberOfBytesToFlush
1695 return STATUS_SUCCESS
;
1700 NtGetCurrentProcessorNumber(VOID
)
1702 /* Just return the CPU */
1703 return KeGetCurrentProcessorNumber();