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 /* FUNCTIONS *****************************************************************/
35 PHANDLE Handle OPTIONAL
46 ExGetCurrentProcessorCpuUsage (
54 Prcb
= KeGetCurrentPrcb();
56 ScaledIdle
= Prcb
->IdleThread
->KernelTime
* 100;
57 TotalTime
= Prcb
->KernelTime
+ Prcb
->UserTime
;
59 *CpuUsage
= 100 - (ScaledIdle
/ TotalTime
);
69 ExGetCurrentProcessorCounts (
70 PULONG ThreadKernelTime
,
72 PULONG ProcessorNumber
77 Prcb
= KeGetCurrentPrcb();
79 *ThreadKernelTime
= Prcb
->KernelTime
+ Prcb
->UserTime
;
80 *TotalCpuTime
= Prcb
->CurrentThread
->KernelTime
;
81 *ProcessorNumber
= KeGetCurrentProcessorNumber();
89 ExIsProcessorFeaturePresent(IN ULONG ProcessorFeature
)
91 /* Quick check to see if it exists at all */
92 if (ProcessorFeature
>= PROCESSOR_FEATURE_MAX
) return(FALSE
);
94 /* Return our support for it */
95 return(SharedUserData
->ProcessorFeatures
[ProcessorFeature
]);
103 ExVerifySuite(SUITE_TYPE SuiteType
)
105 if (SuiteType
== Personal
) return TRUE
;
110 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
111 OUT PWSTR ValueBuffer
,
112 IN ULONG ValueBufferLength
,
113 IN OUT PULONG ReturnLength OPTIONAL
)
116 UNICODE_STRING WName
;
120 UNICODE_STRING WValue
;
121 KPROCESSOR_MODE PreviousMode
;
122 NTSTATUS Status
= STATUS_SUCCESS
;
126 PreviousMode
= ExGetPreviousMode();
128 if(PreviousMode
!= KernelMode
)
132 ProbeForRead(VariableName
,
133 sizeof(UNICODE_STRING
),
135 ProbeForWrite(ValueBuffer
,
138 if(ReturnLength
!= NULL
)
140 ProbeForWriteUlong(ReturnLength
);
143 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
145 Status
= _SEH_GetExceptionCode();
149 if(!NT_SUCCESS(Status
))
156 * Copy the name to kernel space if necessary and convert it to ANSI.
158 Status
= ProbeAndCaptureUnicodeString(&WName
,
161 if(NT_SUCCESS(Status
))
164 * according to ntinternals the SeSystemEnvironmentName privilege is required!
166 if(!SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
169 ReleaseCapturedUnicodeString(&WName
,
171 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
172 return STATUS_PRIVILEGE_NOT_HELD
;
176 * convert the value name to ansi
178 Status
= RtlUnicodeStringToAnsiString(&AName
, &WName
, TRUE
);
179 ReleaseCapturedUnicodeString(&WName
,
181 if(!NT_SUCCESS(Status
))
187 * Create a temporary buffer for the value
189 Value
= ExAllocatePool(NonPagedPool
, ValueBufferLength
);
192 RtlFreeAnsiString(&AName
);
193 return STATUS_INSUFFICIENT_RESOURCES
;
197 * Get the environment variable
199 Result
= HalGetEnvironmentVariable(AName
.Buffer
, ValueBufferLength
, Value
);
202 RtlFreeAnsiString(&AName
);
204 return STATUS_UNSUCCESSFUL
;
208 * Convert the result to UNICODE, protect with SEH in case the value buffer
209 * isn't NULL-terminated!
213 RtlInitAnsiString(&AValue
, Value
);
214 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
216 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
218 Status
= _SEH_GetExceptionCode();
222 if(NT_SUCCESS(Status
))
225 * Copy the result back to the caller.
229 RtlCopyMemory(ValueBuffer
, WValue
.Buffer
, WValue
.Length
);
230 ValueBuffer
[WValue
.Length
/ sizeof(WCHAR
)] = L
'\0';
231 if(ReturnLength
!= NULL
)
233 *ReturnLength
= WValue
.Length
+ sizeof(WCHAR
);
236 Status
= STATUS_SUCCESS
;
238 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
240 Status
= _SEH_GetExceptionCode();
246 * Cleanup allocated resources.
248 RtlFreeAnsiString(&AName
);
257 NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
258 IN PUNICODE_STRING Value
)
260 UNICODE_STRING CapturedName
, CapturedValue
;
261 ANSI_STRING AName
, AValue
;
262 KPROCESSOR_MODE PreviousMode
;
267 PreviousMode
= ExGetPreviousMode();
270 * Copy the strings to kernel space if necessary
272 Status
= ProbeAndCaptureUnicodeString(&CapturedName
,
275 if(NT_SUCCESS(Status
))
277 Status
= ProbeAndCaptureUnicodeString(&CapturedValue
,
280 if(NT_SUCCESS(Status
))
283 * according to ntinternals the SeSystemEnvironmentName privilege is required!
285 if(SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
289 * convert the strings to ANSI
291 Status
= RtlUnicodeStringToAnsiString(&AName
,
294 if(NT_SUCCESS(Status
))
296 Status
= RtlUnicodeStringToAnsiString(&AValue
,
299 if(NT_SUCCESS(Status
))
301 BOOLEAN Result
= HalSetEnvironmentVariable(AName
.Buffer
,
304 Status
= (Result
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);
310 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
311 Status
= STATUS_PRIVILEGE_NOT_HELD
;
314 ReleaseCapturedUnicodeString(&CapturedValue
,
318 ReleaseCapturedUnicodeString(&CapturedName
,
326 /* --- Query/Set System Information --- */
329 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
330 * so the stack is popped only in one place on x86 platform.
332 #define QSI_USE(n) QSI##n
334 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
336 #define SSI_USE(n) SSI##n
338 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
341 /* Class 0 - Basic Information */
342 QSI_DEF(SystemBasicInformation
)
344 PSYSTEM_BASIC_INFORMATION Sbi
345 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
347 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
349 * Check user buffer's size
351 if (Size
!= sizeof (SYSTEM_BASIC_INFORMATION
))
353 return (STATUS_INFO_LENGTH_MISMATCH
);
356 Sbi
->TimerResolution
= KeMaximumIncrement
;
357 Sbi
->PageSize
= PAGE_SIZE
;
358 Sbi
->NumberOfPhysicalPages
= MmStats
.NrTotalPages
;
359 Sbi
->LowestPhysicalPageNumber
= 0; /* FIXME */
360 Sbi
->HighestPhysicalPageNumber
= MmStats
.NrTotalPages
; /* FIXME */
361 Sbi
->AllocationGranularity
= MM_VIRTMEM_GRANULARITY
; /* hard coded on Intel? */
362 Sbi
->MinimumUserModeAddress
= 0x10000; /* Top of 64k */
363 Sbi
->MaximumUserModeAddress
= (ULONG_PTR
)MmHighestUserAddress
;
364 Sbi
->ActiveProcessorsAffinityMask
= KeActiveProcessors
;
365 Sbi
->NumberOfProcessors
= KeNumberProcessors
;
366 return (STATUS_SUCCESS
);
369 /* Class 1 - Processor Information */
370 QSI_DEF(SystemProcessorInformation
)
372 PSYSTEM_PROCESSOR_INFORMATION Spi
373 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
375 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
377 * Check user buffer's size
379 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
381 return (STATUS_INFO_LENGTH_MISMATCH
);
383 Prcb
= KeGetCurrentPrcb();
384 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
385 Spi
->ProcessorLevel
= Prcb
->CpuType
;
386 Spi
->ProcessorRevision
= Prcb
->CpuStep
;
388 Spi
->ProcessorFeatureBits
= Prcb
->FeatureBits
;
390 DPRINT("Arch %d Level %d Rev 0x%x\n", Spi
->ProcessorArchitecture
,
391 Spi
->ProcessorLevel
, Spi
->ProcessorRevision
);
393 return (STATUS_SUCCESS
);
396 /* Class 2 - Performance Information */
397 QSI_DEF(SystemPerformanceInformation
)
399 PSYSTEM_PERFORMANCE_INFORMATION Spi
400 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
402 PEPROCESS TheIdleProcess
;
404 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
406 * Check user buffer's size
408 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
410 return (STATUS_INFO_LENGTH_MISMATCH
);
413 TheIdleProcess
= PsIdleProcess
;
415 Spi
->IdleProcessTime
.QuadPart
= TheIdleProcess
->Pcb
.KernelTime
* 100000LL;
417 Spi
->IoReadTransferCount
= IoReadTransferCount
;
418 Spi
->IoWriteTransferCount
= IoWriteTransferCount
;
419 Spi
->IoOtherTransferCount
= IoOtherTransferCount
;
420 Spi
->IoReadOperationCount
= IoReadOperationCount
;
421 Spi
->IoWriteOperationCount
= IoWriteOperationCount
;
422 Spi
->IoOtherOperationCount
= IoOtherOperationCount
;
424 Spi
->AvailablePages
= MmStats
.NrFreePages
;
426 Add up all the used "Commitied" memory + pagefile.
427 Not sure this is right. 8^\
429 Spi
->CommittedPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
+
430 MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
+
431 MiMemoryConsumers
[MC_CACHE
].PagesUsed
+
432 MiMemoryConsumers
[MC_USER
].PagesUsed
+
435 Add up the full system total + pagefile.
436 All this make Taskmgr happy but not sure it is the right numbers.
437 This too, fixes some of GlobalMemoryStatusEx numbers.
439 Spi
->CommitLimit
= MmStats
.NrTotalPages
+ MiFreeSwapPages
+
442 Spi
->PeakCommitment
= 0; /* FIXME */
443 Spi
->PageFaultCount
= 0; /* FIXME */
444 Spi
->CopyOnWriteCount
= 0; /* FIXME */
445 Spi
->TransitionCount
= 0; /* FIXME */
446 Spi
->CacheTransitionCount
= 0; /* FIXME */
447 Spi
->DemandZeroCount
= 0; /* FIXME */
448 Spi
->PageReadCount
= 0; /* FIXME */
449 Spi
->PageReadIoCount
= 0; /* FIXME */
450 Spi
->CacheReadCount
= 0; /* FIXME */
451 Spi
->CacheIoCount
= 0; /* FIXME */
452 Spi
->DirtyPagesWriteCount
= 0; /* FIXME */
453 Spi
->DirtyWriteIoCount
= 0; /* FIXME */
454 Spi
->MappedPagesWriteCount
= 0; /* FIXME */
455 Spi
->MappedWriteIoCount
= 0; /* FIXME */
457 Spi
->PagedPoolPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
;
458 Spi
->PagedPoolAllocs
= 0; /* FIXME */
459 Spi
->PagedPoolFrees
= 0; /* FIXME */
460 Spi
->NonPagedPoolPages
= MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
;
461 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
462 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
464 Spi
->FreeSystemPtes
= 0; /* FIXME */
466 Spi
->ResidentSystemCodePage
= MmStats
.NrSystemPages
; /* FIXME */
468 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
469 Spi
->TotalSystemCodePages
= 0; /* FIXME */
470 Spi
->NonPagedPoolLookasideHits
= 0; /* FIXME */
471 Spi
->PagedPoolLookasideHits
= 0; /* FIXME */
472 Spi
->Spare3Count
= 0; /* FIXME */
474 Spi
->ResidentSystemCachePage
= MiMemoryConsumers
[MC_CACHE
].PagesUsed
;
475 Spi
->ResidentPagedPoolPage
= MmPagedPoolSize
; /* FIXME */
477 Spi
->ResidentSystemDriverPage
= 0; /* FIXME */
478 Spi
->CcFastReadNoWait
= 0; /* FIXME */
479 Spi
->CcFastReadWait
= 0; /* FIXME */
480 Spi
->CcFastReadResourceMiss
= 0; /* FIXME */
481 Spi
->CcFastReadNotPossible
= 0; /* FIXME */
483 Spi
->CcFastMdlReadNoWait
= 0; /* FIXME */
484 Spi
->CcFastMdlReadWait
= 0; /* FIXME */
485 Spi
->CcFastMdlReadResourceMiss
= 0; /* FIXME */
486 Spi
->CcFastMdlReadNotPossible
= 0; /* FIXME */
488 Spi
->CcMapDataNoWait
= 0; /* FIXME */
489 Spi
->CcMapDataWait
= 0; /* FIXME */
490 Spi
->CcMapDataNoWaitMiss
= 0; /* FIXME */
491 Spi
->CcMapDataWaitMiss
= 0; /* FIXME */
493 Spi
->CcPinMappedDataCount
= 0; /* FIXME */
494 Spi
->CcPinReadNoWait
= 0; /* FIXME */
495 Spi
->CcPinReadWait
= 0; /* FIXME */
496 Spi
->CcPinReadNoWaitMiss
= 0; /* FIXME */
497 Spi
->CcPinReadWaitMiss
= 0; /* FIXME */
498 Spi
->CcCopyReadNoWait
= 0; /* FIXME */
499 Spi
->CcCopyReadWait
= 0; /* FIXME */
500 Spi
->CcCopyReadNoWaitMiss
= 0; /* FIXME */
501 Spi
->CcCopyReadWaitMiss
= 0; /* FIXME */
503 Spi
->CcMdlReadNoWait
= 0; /* FIXME */
504 Spi
->CcMdlReadWait
= 0; /* FIXME */
505 Spi
->CcMdlReadNoWaitMiss
= 0; /* FIXME */
506 Spi
->CcMdlReadWaitMiss
= 0; /* FIXME */
507 Spi
->CcReadAheadIos
= 0; /* FIXME */
508 Spi
->CcLazyWriteIos
= 0; /* FIXME */
509 Spi
->CcLazyWritePages
= 0; /* FIXME */
510 Spi
->CcDataFlushes
= 0; /* FIXME */
511 Spi
->CcDataPages
= 0; /* FIXME */
512 Spi
->ContextSwitches
= 0; /* FIXME */
513 Spi
->FirstLevelTbFills
= 0; /* FIXME */
514 Spi
->SecondLevelTbFills
= 0; /* FIXME */
515 Spi
->SystemCalls
= 0; /* FIXME */
517 return (STATUS_SUCCESS
);
520 /* Class 3 - Time Of Day Information */
521 QSI_DEF(SystemTimeOfDayInformation
)
523 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
524 LARGE_INTEGER CurrentTime
;
526 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
527 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
529 /* Check user buffer's size */
530 if (Size
!= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
532 return STATUS_INFO_LENGTH_MISMATCH
;
535 KeQuerySystemTime(&CurrentTime
);
537 Sti
->BootTime
= SystemBootTime
;
538 Sti
->CurrentTime
= CurrentTime
;
539 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
540 Sti
->TimeZoneId
= ExpTimeZoneId
;
543 return STATUS_SUCCESS
;
546 /* Class 4 - Path Information */
547 QSI_DEF(SystemPathInformation
)
549 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
550 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
552 return (STATUS_BREAKPOINT
);
555 /* Class 5 - Process Information */
556 QSI_DEF(SystemProcessInformation
)
558 ULONG ovlSize
= 0, nThreads
;
559 PEPROCESS pr
= NULL
, syspr
;
561 NTSTATUS Status
= STATUS_SUCCESS
;
565 /* scan the process list */
567 PSYSTEM_PROCESS_INFORMATION Spi
568 = (PSYSTEM_PROCESS_INFORMATION
) Buffer
;
570 *ReqSize
= sizeof(SYSTEM_PROCESS_INFORMATION
);
572 if (Size
< sizeof(SYSTEM_PROCESS_INFORMATION
))
574 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
577 syspr
= PsGetNextProcess(NULL
);
579 pCur
= (unsigned char *)Spi
;
583 PSYSTEM_PROCESS_INFORMATION SpiCur
;
586 int inLen
=32; // image name len in bytes
587 PLIST_ENTRY current_entry
;
589 PSYSTEM_THREAD_INFORMATION ThreadInfo
;
591 SpiCur
= (PSYSTEM_PROCESS_INFORMATION
)pCur
;
594 current_entry
= pr
->ThreadListHead
.Flink
;
595 while (current_entry
!= &pr
->ThreadListHead
)
598 current_entry
= current_entry
->Flink
;
601 // size of the structure for every process
602 curSize
= sizeof(SYSTEM_PROCESS_INFORMATION
)+sizeof(SYSTEM_THREAD_INFORMATION
)*nThreads
;
603 ovlSize
+= curSize
+inLen
;
608 ObDereferenceObject(pr
);
610 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
613 // fill system information
614 SpiCur
->NextEntryOffset
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
615 SpiCur
->NumberOfThreads
= nThreads
;
616 SpiCur
->CreateTime
= pr
->CreateTime
;
617 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
618 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
619 SpiCur
->ImageName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
620 SpiCur
->ImageName
.MaximumLength
= inLen
;
621 SpiCur
->ImageName
.Buffer
= (void*)(pCur
+curSize
);
623 // copy name to the end of the struct
624 if(pr
!= PsIdleProcess
)
626 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
627 RtlAnsiStringToUnicodeString(&SpiCur
->ImageName
, &imgName
, FALSE
);
631 RtlInitUnicodeString(&SpiCur
->ImageName
, NULL
);
634 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
635 SpiCur
->UniqueProcessId
= pr
->UniqueProcessId
;
636 SpiCur
->InheritedFromUniqueProcessId
= pr
->InheritedFromUniqueProcessId
;
637 SpiCur
->HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
638 SpiCur
->PeakVirtualSize
= pr
->PeakVirtualSize
;
639 SpiCur
->VirtualSize
= pr
->VirtualSize
;
640 SpiCur
->PageFaultCount
= pr
->Vm
.PageFaultCount
;
641 SpiCur
->PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
;
642 SpiCur
->WorkingSetSize
= pr
->Vm
.WorkingSetSize
;
643 SpiCur
->QuotaPeakPagedPoolUsage
= pr
->QuotaPeak
[0];
644 SpiCur
->QuotaPagedPoolUsage
= pr
->QuotaUsage
[0];
645 SpiCur
->QuotaPeakNonPagedPoolUsage
= pr
->QuotaPeak
[1];
646 SpiCur
->QuotaNonPagedPoolUsage
= pr
->QuotaUsage
[1];
647 SpiCur
->PagefileUsage
= pr
->QuotaUsage
[3];
648 SpiCur
->PeakPagefileUsage
= pr
->QuotaPeak
[3];
649 SpiCur
->PrivatePageCount
= pr
->CommitCharge
;
650 ThreadInfo
= (PSYSTEM_THREAD_INFORMATION
)(SpiCur
+ 1);
652 current_entry
= pr
->ThreadListHead
.Flink
;
653 while (current_entry
!= &pr
->ThreadListHead
)
655 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
659 ThreadInfo
->KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
660 ThreadInfo
->UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
661 // SpiCur->TH[i].CreateTime = current->CreateTime;
662 ThreadInfo
->WaitTime
= current
->Tcb
.WaitTime
;
663 ThreadInfo
->StartAddress
= (PVOID
) current
->StartAddress
;
664 ThreadInfo
->ClientId
= current
->Cid
;
665 ThreadInfo
->Priority
= current
->Tcb
.Priority
;
666 ThreadInfo
->BasePriority
= current
->Tcb
.BasePriority
;
667 ThreadInfo
->ContextSwitches
= current
->Tcb
.ContextSwitches
;
668 ThreadInfo
->ThreadState
= current
->Tcb
.State
;
669 ThreadInfo
->WaitReason
= current
->Tcb
.WaitReason
;
671 current_entry
= current_entry
->Flink
;
674 pr
= PsGetNextProcess(pr
);
676 if ((pr
== syspr
) || (pr
== NULL
))
678 SpiCur
->NextEntryOffset
= 0;
682 pCur
= pCur
+ curSize
+ inLen
;
683 } while ((pr
!= syspr
) && (pr
!= NULL
));
686 ObDereferenceObject(pr
);
687 Status
= STATUS_SUCCESS
;
692 ObDereferenceObject(pr
);
693 Status
= _SEH_GetExceptionCode();
701 /* Class 6 - Call Count Information */
702 QSI_DEF(SystemCallCountInformation
)
705 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
706 return (STATUS_NOT_IMPLEMENTED
);
709 /* Class 7 - Device Information */
710 QSI_DEF(SystemDeviceInformation
)
712 PSYSTEM_DEVICE_INFORMATION Sdi
713 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
714 PCONFIGURATION_INFORMATION ConfigInfo
;
716 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
718 * Check user buffer's size
720 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
722 return (STATUS_INFO_LENGTH_MISMATCH
);
725 ConfigInfo
= IoGetConfigurationInformation ();
727 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
728 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
729 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
730 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
731 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
732 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
734 return (STATUS_SUCCESS
);
737 /* Class 8 - Processor Performance Information */
738 QSI_DEF(SystemProcessorPerformanceInformation
)
740 PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Spi
741 = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
) Buffer
;
744 LARGE_INTEGER CurrentTime
;
747 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
);
749 * Check user buffer's size
751 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
))
753 return (STATUS_INFO_LENGTH_MISMATCH
);
756 CurrentTime
.QuadPart
= KeQueryInterruptTime();
757 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
758 for (i
= 0; i
< KeNumberProcessors
; i
++)
760 Spi
->IdleTime
.QuadPart
= (Prcb
->IdleThread
->KernelTime
+ Prcb
->IdleThread
->UserTime
) * 100000LL; // IdleTime
761 Spi
->KernelTime
.QuadPart
= Prcb
->KernelTime
* 100000LL; // KernelTime
762 Spi
->UserTime
.QuadPart
= Prcb
->UserTime
* 100000LL;
763 Spi
->DpcTime
.QuadPart
= Prcb
->DpcTime
* 100000LL;
764 Spi
->InterruptTime
.QuadPart
= Prcb
->InterruptTime
* 100000LL;
765 Spi
->InterruptCount
= Prcb
->InterruptCount
; // Interrupt Count
767 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
770 return (STATUS_SUCCESS
);
773 /* Class 9 - Flags Information */
774 QSI_DEF(SystemFlagsInformation
)
776 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
778 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
779 return (STATUS_INFO_LENGTH_MISMATCH
);
781 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
782 return (STATUS_SUCCESS
);
785 SSI_DEF(SystemFlagsInformation
)
787 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
789 return (STATUS_INFO_LENGTH_MISMATCH
);
791 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
792 return (STATUS_SUCCESS
);
795 /* Class 10 - Call Time Information */
796 QSI_DEF(SystemCallTimeInformation
)
799 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
800 return (STATUS_NOT_IMPLEMENTED
);
803 /* Class 11 - Module Information */
804 QSI_DEF(SystemModuleInformation
)
806 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
809 /* Class 12 - Locks Information */
810 QSI_DEF(SystemLocksInformation
)
813 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
814 return (STATUS_NOT_IMPLEMENTED
);
817 /* Class 13 - Stack Trace Information */
818 QSI_DEF(SystemStackTraceInformation
)
821 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
822 return (STATUS_NOT_IMPLEMENTED
);
825 /* Class 14 - Paged Pool Information */
826 QSI_DEF(SystemPagedPoolInformation
)
829 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
830 return (STATUS_NOT_IMPLEMENTED
);
833 /* Class 15 - Non Paged Pool Information */
834 QSI_DEF(SystemNonPagedPoolInformation
)
837 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
838 return (STATUS_NOT_IMPLEMENTED
);
842 /* Class 16 - Handle Information */
843 QSI_DEF(SystemHandleInformation
)
846 ULONG curSize
, i
= 0;
849 PSYSTEM_HANDLE_INFORMATION Shi
=
850 (PSYSTEM_HANDLE_INFORMATION
) Buffer
;
852 DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
854 if (Size
< sizeof (SYSTEM_HANDLE_INFORMATION
))
856 * ReqSize
= sizeof (SYSTEM_HANDLE_INFORMATION
);
857 return (STATUS_INFO_LENGTH_MISMATCH
);
860 DPRINT("SystemHandleInformation 1\n");
862 /* First Calc Size from Count. */
863 syspr
= PsGetNextProcess(NULL
);
868 hCount
= hCount
+ (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
869 pr
= PsGetNextProcess(pr
);
871 if ((pr
== syspr
) || (pr
== NULL
))
873 } while ((pr
!= syspr
) && (pr
!= NULL
));
877 ObDereferenceObject(pr
);
880 DPRINT("SystemHandleInformation 2\n");
882 curSize
= sizeof(SYSTEM_HANDLE_INFORMATION
)+
883 ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) * hCount
) -
884 (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) ));
886 Shi
->NumberOfHandles
= hCount
;
891 return (STATUS_INFO_LENGTH_MISMATCH
);
894 DPRINT("SystemHandleInformation 3\n");
896 /* Now get Handles from all processs. */
897 syspr
= PsGetNextProcess(NULL
);
902 int Count
= 0, HandleCount
;
904 HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
906 for (Count
= 0; HandleCount
> 0 ; HandleCount
--)
908 Shi
->Handles
[i
].UniqueProcessId
= (ULONG
)pr
->UniqueProcessId
;
913 pr
= PsGetNextProcess(pr
);
915 if ((pr
== syspr
) || (pr
== NULL
))
917 } while ((pr
!= syspr
) && (pr
!= NULL
));
921 ObDereferenceObject(pr
);
924 DPRINT("SystemHandleInformation 4\n");
925 return (STATUS_SUCCESS
);
929 SSI_DEF(SystemHandleInformation)
932 return (STATUS_SUCCESS);
936 /* Class 17 - Information */
937 QSI_DEF(SystemObjectInformation
)
940 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
941 return (STATUS_NOT_IMPLEMENTED
);
944 /* Class 18 - Information */
945 QSI_DEF(SystemPageFileInformation
)
947 UNICODE_STRING FileName
; /* FIXME */
948 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
950 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
952 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
953 return (STATUS_INFO_LENGTH_MISMATCH
);
956 RtlInitUnicodeString(&FileName
, NULL
); /* FIXME */
959 Spfi
->NextEntryOffset
= 0;
961 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
962 Spfi
->TotalInUse
= MiUsedSwapPages
;
963 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
964 Spfi
->PageFileName
= FileName
;
965 return (STATUS_SUCCESS
);
968 /* Class 19 - Vdm Instemul Information */
969 QSI_DEF(SystemVdmInstemulInformation
)
972 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
973 return (STATUS_NOT_IMPLEMENTED
);
976 /* Class 20 - Vdm Bop Information */
977 QSI_DEF(SystemVdmBopInformation
)
980 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
981 return (STATUS_NOT_IMPLEMENTED
);
984 /* Class 21 - File Cache Information */
985 QSI_DEF(SystemFileCacheInformation
)
987 SYSTEM_FILECACHE_INFORMATION
*Sci
= (SYSTEM_FILECACHE_INFORMATION
*) Buffer
;
989 if (Size
< sizeof (SYSTEM_FILECACHE_INFORMATION
))
991 * ReqSize
= sizeof (SYSTEM_FILECACHE_INFORMATION
);
992 return (STATUS_INFO_LENGTH_MISMATCH
);
995 RtlZeroMemory(Sci
, sizeof(SYSTEM_FILECACHE_INFORMATION
));
997 /* Return the Byte size not the page size. */
999 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
1001 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
1003 Sci
->PageFaultCount
= 0; /* FIXME */
1004 Sci
->MinimumWorkingSet
= 0; /* FIXME */
1005 Sci
->MaximumWorkingSet
= 0; /* FIXME */
1007 return (STATUS_SUCCESS
);
1010 SSI_DEF(SystemFileCacheInformation
)
1012 if (Size
< sizeof (SYSTEM_FILECACHE_INFORMATION
))
1014 return (STATUS_INFO_LENGTH_MISMATCH
);
1017 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
1018 return (STATUS_NOT_IMPLEMENTED
);
1021 /* Class 22 - Pool Tag Information */
1022 QSI_DEF(SystemPoolTagInformation
)
1025 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
1026 return (STATUS_NOT_IMPLEMENTED
);
1029 /* Class 23 - Interrupt Information for all processors */
1030 QSI_DEF(SystemInterruptInformation
)
1035 PSYSTEM_INTERRUPT_INFORMATION sii
= (PSYSTEM_INTERRUPT_INFORMATION
)Buffer
;
1037 if(Size
< KeNumberProcessors
* sizeof(SYSTEM_INTERRUPT_INFORMATION
))
1039 return (STATUS_INFO_LENGTH_MISMATCH
);
1042 ti
= KeQueryTimeIncrement();
1044 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
1045 for (i
= 0; i
< KeNumberProcessors
; i
++)
1047 sii
->ContextSwitches
= Prcb
->KeContextSwitches
;
1048 sii
->DpcCount
= 0; /* FIXME */
1049 sii
->DpcRate
= 0; /* FIXME */
1050 sii
->TimeIncrement
= ti
;
1051 sii
->DpcBypassCount
= 0; /* FIXME */
1052 sii
->ApcBypassCount
= 0; /* FIXME */
1054 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
1057 return STATUS_SUCCESS
;
1060 /* Class 24 - DPC Behaviour Information */
1061 QSI_DEF(SystemDpcBehaviourInformation
)
1064 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
1065 return (STATUS_NOT_IMPLEMENTED
);
1068 SSI_DEF(SystemDpcBehaviourInformation
)
1071 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1072 return (STATUS_NOT_IMPLEMENTED
);
1075 /* Class 25 - Full Memory Information */
1076 QSI_DEF(SystemFullMemoryInformation
)
1078 PULONG Spi
= (PULONG
) Buffer
;
1080 PEPROCESS TheIdleProcess
;
1082 * ReqSize
= sizeof (ULONG
);
1084 if (sizeof (ULONG
) != Size
)
1086 return (STATUS_INFO_LENGTH_MISMATCH
);
1088 DPRINT("SystemFullMemoryInformation\n");
1090 TheIdleProcess
= PsIdleProcess
;
1092 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
1093 TheIdleProcess
->UniqueProcessId
,
1094 TheIdleProcess
->Pcb
.KernelTime
,
1099 MmPrintMemoryStatistic();
1102 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
1104 return (STATUS_SUCCESS
);
1107 /* Class 26 - Load Image */
1108 SSI_DEF(SystemLoadImage
)
1110 PSYSTEM_GDI_DRIVER_INFORMATION Sli
= (PSYSTEM_GDI_DRIVER_INFORMATION
)Buffer
;
1112 if (sizeof(SYSTEM_GDI_DRIVER_INFORMATION
) != Size
)
1114 return(STATUS_INFO_LENGTH_MISMATCH
);
1117 return(LdrpLoadImage(&Sli
->DriverName
,
1119 &Sli
->SectionPointer
,
1121 (PVOID
)&Sli
->ExportSectionPointer
));
1124 /* Class 27 - Unload Image */
1125 SSI_DEF(SystemUnloadImage
)
1127 PVOID Sui
= (PVOID
)Buffer
;
1129 if (sizeof(PVOID
) != Size
)
1131 return(STATUS_INFO_LENGTH_MISMATCH
);
1134 return(LdrpUnloadImage(Sui
));
1137 /* Class 28 - Time Adjustment Information */
1138 QSI_DEF(SystemTimeAdjustmentInformation
)
1140 if (sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
) > Size
)
1142 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
);
1143 return (STATUS_INFO_LENGTH_MISMATCH
);
1146 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1147 return (STATUS_NOT_IMPLEMENTED
);
1150 SSI_DEF(SystemTimeAdjustmentInformation
)
1152 if (sizeof (SYSTEM_SET_TIME_ADJUST_INFORMATION
) > Size
)
1154 return (STATUS_INFO_LENGTH_MISMATCH
);
1157 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1158 return (STATUS_NOT_IMPLEMENTED
);
1161 /* Class 29 - Summary Memory Information */
1162 QSI_DEF(SystemSummaryMemoryInformation
)
1165 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1166 return (STATUS_NOT_IMPLEMENTED
);
1169 /* Class 30 - Next Event Id Information */
1170 QSI_DEF(SystemNextEventIdInformation
)
1173 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1174 return (STATUS_NOT_IMPLEMENTED
);
1177 /* Class 31 - Event Ids Information */
1178 QSI_DEF(SystemEventIdsInformation
)
1181 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1182 return (STATUS_NOT_IMPLEMENTED
);
1185 /* Class 32 - Crash Dump Information */
1186 QSI_DEF(SystemCrashDumpInformation
)
1189 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1190 return (STATUS_NOT_IMPLEMENTED
);
1193 /* Class 33 - Exception Information */
1194 QSI_DEF(SystemExceptionInformation
)
1197 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1198 return (STATUS_NOT_IMPLEMENTED
);
1201 /* Class 34 - Crash Dump State Information */
1202 QSI_DEF(SystemCrashDumpStateInformation
)
1205 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1206 return (STATUS_NOT_IMPLEMENTED
);
1209 /* Class 35 - Kernel Debugger Information */
1210 QSI_DEF(SystemKernelDebuggerInformation
)
1212 PSYSTEM_KERNEL_DEBUGGER_INFORMATION skdi
= (PSYSTEM_KERNEL_DEBUGGER_INFORMATION
) Buffer
;
1214 *ReqSize
= sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION
);
1215 if (Size
< sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION
))
1217 return STATUS_INFO_LENGTH_MISMATCH
;
1220 skdi
->KernelDebuggerEnabled
= KD_DEBUGGER_ENABLED
;
1221 skdi
->KernelDebuggerNotPresent
= KD_DEBUGGER_NOT_PRESENT
;
1223 return STATUS_SUCCESS
;
1226 /* Class 36 - Context Switch Information */
1227 QSI_DEF(SystemContextSwitchInformation
)
1230 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1231 return (STATUS_NOT_IMPLEMENTED
);
1234 /* Class 37 - Registry Quota Information */
1235 QSI_DEF(SystemRegistryQuotaInformation
)
1237 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1239 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1240 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1242 return STATUS_INFO_LENGTH_MISMATCH
;
1245 DPRINT1("Faking max registry size of 32 MB\n");
1246 srqi
->RegistryQuotaAllowed
= 0x2000000;
1247 srqi
->RegistryQuotaUsed
= 0x200000;
1248 srqi
->PagedPoolSize
= 0x200000;
1250 return STATUS_SUCCESS
;
1253 SSI_DEF(SystemRegistryQuotaInformation
)
1256 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1257 return (STATUS_NOT_IMPLEMENTED
);
1260 /* Class 38 - Load And Call Image */
1261 SSI_DEF(SystemLoadAndCallImage
)
1263 PUNICODE_STRING Slci
= (PUNICODE_STRING
)Buffer
;
1265 if (sizeof(UNICODE_STRING
) != Size
)
1267 return(STATUS_INFO_LENGTH_MISMATCH
);
1270 return(LdrpLoadAndCallImage(Slci
));
1273 /* Class 39 - Priority Separation */
1274 SSI_DEF(SystemPrioritySeperation
)
1277 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1278 return (STATUS_NOT_IMPLEMENTED
);
1281 /* Class 40 - Plug Play Bus Information */
1282 QSI_DEF(SystemPlugPlayBusInformation
)
1285 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1286 return (STATUS_NOT_IMPLEMENTED
);
1289 /* Class 41 - Dock Information */
1290 QSI_DEF(SystemDockInformation
)
1293 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1294 return (STATUS_NOT_IMPLEMENTED
);
1297 /* Class 42 - Power Information */
1298 QSI_DEF(SystemPowerInformation
)
1301 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1302 return (STATUS_NOT_IMPLEMENTED
);
1305 /* Class 43 - Processor Speed Information */
1306 QSI_DEF(SystemProcessorSpeedInformation
)
1309 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1310 return (STATUS_NOT_IMPLEMENTED
);
1313 /* Class 44 - Current Time Zone Information */
1314 QSI_DEF(SystemCurrentTimeZoneInformation
)
1316 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1318 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1320 return STATUS_INFO_LENGTH_MISMATCH
;
1323 /* Copy the time zone information struct */
1326 sizeof(TIME_ZONE_INFORMATION
));
1328 return STATUS_SUCCESS
;
1332 SSI_DEF(SystemCurrentTimeZoneInformation
)
1334 /* Check user buffer's size */
1335 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1337 return STATUS_INFO_LENGTH_MISMATCH
;
1340 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1344 /* Class 45 - Lookaside Information */
1345 QSI_DEF(SystemLookasideInformation
)
1348 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1349 return (STATUS_NOT_IMPLEMENTED
);
1353 /* Class 46 - Set time slip event */
1354 SSI_DEF(SystemSetTimeSlipEvent
)
1357 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1358 return (STATUS_NOT_IMPLEMENTED
);
1362 /* Class 47 - Create a new session (TSE) */
1363 SSI_DEF(SystemCreateSession
)
1366 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1367 return (STATUS_NOT_IMPLEMENTED
);
1371 /* Class 48 - Delete an existing session (TSE) */
1372 SSI_DEF(SystemDeleteSession
)
1375 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1376 return (STATUS_NOT_IMPLEMENTED
);
1380 /* Class 49 - UNKNOWN */
1381 QSI_DEF(SystemInvalidInfoClass4
)
1384 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1385 return (STATUS_NOT_IMPLEMENTED
);
1389 /* Class 50 - System range start address */
1390 QSI_DEF(SystemRangeStartInformation
)
1393 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1394 return (STATUS_NOT_IMPLEMENTED
);
1398 /* Class 51 - Driver verifier information */
1399 QSI_DEF(SystemVerifierInformation
)
1402 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1403 return (STATUS_NOT_IMPLEMENTED
);
1407 SSI_DEF(SystemVerifierInformation
)
1410 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1411 return (STATUS_NOT_IMPLEMENTED
);
1415 /* Class 52 - Add a driver verifier */
1416 SSI_DEF(SystemAddVerifier
)
1419 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1420 return (STATUS_NOT_IMPLEMENTED
);
1424 /* Class 53 - A session's processes */
1425 QSI_DEF(SystemSessionProcessesInformation
)
1428 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1429 return (STATUS_NOT_IMPLEMENTED
);
1433 /* Query/Set Calls Table */
1437 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1438 NTSTATUS (* Set
) (PVOID
,ULONG
);
1445 // XX unknown behaviour
1447 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1448 #define SI_QX(n) {QSI_USE(n),NULL}
1449 #define SI_XS(n) {NULL,SSI_USE(n)}
1450 #define SI_XX(n) {NULL,NULL}
1456 SI_QX(SystemBasicInformation
),
1457 SI_QX(SystemProcessorInformation
),
1458 SI_QX(SystemPerformanceInformation
),
1459 SI_QX(SystemTimeOfDayInformation
),
1460 SI_QX(SystemPathInformation
), /* should be SI_XX */
1461 SI_QX(SystemProcessInformation
),
1462 SI_QX(SystemCallCountInformation
),
1463 SI_QX(SystemDeviceInformation
),
1464 SI_QX(SystemProcessorPerformanceInformation
),
1465 SI_QS(SystemFlagsInformation
),
1466 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1467 SI_QX(SystemModuleInformation
),
1468 SI_QX(SystemLocksInformation
),
1469 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1470 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1471 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1472 SI_QX(SystemHandleInformation
),
1473 SI_QX(SystemObjectInformation
),
1474 SI_QX(SystemPageFileInformation
),
1475 SI_QX(SystemVdmInstemulInformation
),
1476 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1477 SI_QS(SystemFileCacheInformation
),
1478 SI_QX(SystemPoolTagInformation
),
1479 SI_QX(SystemInterruptInformation
),
1480 SI_QS(SystemDpcBehaviourInformation
),
1481 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1482 SI_XS(SystemLoadImage
),
1483 SI_XS(SystemUnloadImage
),
1484 SI_QS(SystemTimeAdjustmentInformation
),
1485 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1486 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1487 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1488 SI_QX(SystemCrashDumpInformation
),
1489 SI_QX(SystemExceptionInformation
),
1490 SI_QX(SystemCrashDumpStateInformation
),
1491 SI_QX(SystemKernelDebuggerInformation
),
1492 SI_QX(SystemContextSwitchInformation
),
1493 SI_QS(SystemRegistryQuotaInformation
),
1494 SI_XS(SystemLoadAndCallImage
),
1495 SI_XS(SystemPrioritySeperation
),
1496 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1497 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1498 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1499 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1500 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1501 SI_QX(SystemLookasideInformation
),
1502 SI_XS(SystemSetTimeSlipEvent
),
1503 SI_XS(SystemCreateSession
),
1504 SI_XS(SystemDeleteSession
),
1505 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1506 SI_QX(SystemRangeStartInformation
),
1507 SI_QS(SystemVerifierInformation
),
1508 SI_XS(SystemAddVerifier
),
1509 SI_QX(SystemSessionProcessesInformation
)
1517 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1518 OUT PVOID SystemInformation
,
1520 OUT PULONG UnsafeResultLength
)
1522 KPROCESSOR_MODE PreviousMode
;
1524 NTSTATUS FStatus
= STATUS_NOT_IMPLEMENTED
;
1528 PreviousMode
= ExGetPreviousMode();
1532 if (PreviousMode
!= KernelMode
)
1534 /* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
1535 ProbeForWrite(SystemInformation
, Length
, 1);
1536 if (UnsafeResultLength
!= NULL
)
1537 ProbeForWriteUlong(UnsafeResultLength
);
1540 /* Clear user buffer. */
1541 RtlZeroMemory(SystemInformation
, Length
);
1544 * Check the request is valid.
1546 if (SystemInformationClass
>= MaxSystemInfoClass
)
1548 return (STATUS_INVALID_INFO_CLASS
);
1551 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1554 * Hand the request to a subhandler.
1556 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1559 if (UnsafeResultLength
!= NULL
)
1561 if (PreviousMode
!= KernelMode
)
1565 *UnsafeResultLength
= ResultLength
;
1567 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
1569 FStatus
= _SEH_GetExceptionCode();
1575 *UnsafeResultLength
= ResultLength
;
1580 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
1582 FStatus
= _SEH_GetExceptionCode();
1592 NtSetSystemInformation (
1593 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1594 IN PVOID SystemInformation
,
1595 IN ULONG SystemInformationLength
1601 * If called from user mode, check
1602 * possible unsafe arguments.
1605 if (KernelMode
!= KeGetPreviousMode())
1609 // SystemInformation,
1619 * Check the request is valid.
1621 if ( (SystemInformationClass
>= SystemBasicInformation
)
1622 && (SystemInformationClass
< MaxSystemInfoClass
)
1625 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1628 * Hand the request to a subhandler.
1630 return CallQS
[SystemInformationClass
].Set (
1632 SystemInformationLength
1636 return (STATUS_INVALID_INFO_CLASS
);
1642 NtFlushInstructionCache (
1643 IN HANDLE ProcessHandle
,
1644 IN PVOID BaseAddress
,
1645 IN ULONG NumberOfBytesToFlush
1650 __asm__("wbinvd\n");
1652 return STATUS_SUCCESS
;