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
= KeGetCurrentKPCR()->ProcessorNumber
;
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
]);
99 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
100 OUT PWCHAR ValueBuffer
,
101 IN ULONG ValueBufferLength
,
102 IN OUT PULONG ReturnLength OPTIONAL
)
105 UNICODE_STRING WName
;
109 UNICODE_STRING WValue
;
110 KPROCESSOR_MODE PreviousMode
;
111 NTSTATUS Status
= STATUS_SUCCESS
;
115 PreviousMode
= ExGetPreviousMode();
117 if(PreviousMode
!= KernelMode
)
121 ProbeForRead(VariableName
,
122 sizeof(UNICODE_STRING
),
124 ProbeForWrite(ValueBuffer
,
127 if(ReturnLength
!= NULL
)
129 ProbeForWrite(ReturnLength
,
134 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
136 Status
= _SEH_GetExceptionCode();
140 if(!NT_SUCCESS(Status
))
147 * Copy the name to kernel space if necessary and convert it to ANSI.
149 Status
= RtlCaptureUnicodeString(&WName
,
154 if(NT_SUCCESS(Status
))
157 * according to ntinternals the SeSystemEnvironmentName privilege is required!
159 if(!SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
162 RtlReleaseCapturedUnicodeString(&WName
,
165 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
166 return STATUS_PRIVILEGE_NOT_HELD
;
170 * convert the value name to ansi
172 Status
= RtlUnicodeStringToAnsiString(&AName
, &WName
, TRUE
);
173 RtlReleaseCapturedUnicodeString(&WName
,
176 if(!NT_SUCCESS(Status
))
182 * Create a temporary buffer for the value
184 Value
= ExAllocatePool(NonPagedPool
, ValueBufferLength
);
187 RtlFreeAnsiString(&AName
);
188 return STATUS_INSUFFICIENT_RESOURCES
;
192 * Get the environment variable
194 Result
= HalGetEnvironmentVariable(AName
.Buffer
, Value
, ValueBufferLength
);
197 RtlFreeAnsiString(&AName
);
199 return STATUS_UNSUCCESSFUL
;
203 * Convert the result to UNICODE, protect with SEH in case the value buffer
204 * isn't NULL-terminated!
208 RtlInitAnsiString(&AValue
, Value
);
209 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
211 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
213 Status
= _SEH_GetExceptionCode();
217 if(NT_SUCCESS(Status
))
220 * Copy the result back to the caller.
224 RtlCopyMemory(ValueBuffer
, WValue
.Buffer
, WValue
.Length
);
225 ValueBuffer
[WValue
.Length
/ sizeof(WCHAR
)] = L
'\0';
226 if(ReturnLength
!= NULL
)
228 *ReturnLength
= WValue
.Length
+ sizeof(WCHAR
);
231 Status
= STATUS_SUCCESS
;
233 _SEH_EXCEPT(_SEH_ExSystemExceptionFilter
)
235 Status
= _SEH_GetExceptionCode();
241 * Cleanup allocated resources.
243 RtlFreeAnsiString(&AName
);
252 NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName
,
253 IN PUNICODE_STRING Value
)
255 UNICODE_STRING CapturedName
, CapturedValue
;
256 ANSI_STRING AName
, AValue
;
257 KPROCESSOR_MODE PreviousMode
;
262 PreviousMode
= ExGetPreviousMode();
265 * Copy the strings to kernel space if necessary
267 Status
= RtlCaptureUnicodeString(&CapturedName
,
272 if(NT_SUCCESS(Status
))
274 Status
= RtlCaptureUnicodeString(&CapturedValue
,
279 if(NT_SUCCESS(Status
))
282 * according to ntinternals the SeSystemEnvironmentName privilege is required!
284 if(SeSinglePrivilegeCheck(SeSystemEnvironmentPrivilege
,
288 * convert the strings to ANSI
290 Status
= RtlUnicodeStringToAnsiString(&AName
,
293 if(NT_SUCCESS(Status
))
295 Status
= RtlUnicodeStringToAnsiString(&AValue
,
298 if(NT_SUCCESS(Status
))
300 BOOLEAN Result
= HalSetEnvironmentVariable(AName
.Buffer
,
303 Status
= (Result
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL
);
309 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
310 Status
= STATUS_PRIVILEGE_NOT_HELD
;
313 RtlReleaseCapturedUnicodeString(&CapturedValue
,
318 RtlReleaseCapturedUnicodeString(&CapturedName
,
327 /* --- Query/Set System Information --- */
330 * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols
331 * so the stack is popped only in one place on x86 platform.
333 #define QSI_USE(n) QSI##n
335 static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
337 #define SSI_USE(n) SSI##n
339 static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
342 /* Class 0 - Basic Information */
343 QSI_DEF(SystemBasicInformation
)
345 PSYSTEM_BASIC_INFORMATION Sbi
346 = (PSYSTEM_BASIC_INFORMATION
) Buffer
;
348 *ReqSize
= sizeof (SYSTEM_BASIC_INFORMATION
);
350 * Check user buffer's size
352 if (Size
< sizeof (SYSTEM_BASIC_INFORMATION
))
354 return (STATUS_INFO_LENGTH_MISMATCH
);
357 Sbi
->MaximumIncrement
= KeMaximumIncrement
;
358 Sbi
->PhysicalPageSize
= PAGE_SIZE
;
359 Sbi
->NumberOfPhysicalPages
= MmStats
.NrTotalPages
;
360 Sbi
->LowestPhysicalPage
= 0; /* FIXME */
361 Sbi
->HighestPhysicalPage
= MmStats
.NrTotalPages
; /* FIXME */
362 Sbi
->AllocationGranularity
= MM_VIRTMEM_GRANULARITY
; /* hard coded on Intel? */
363 Sbi
->LowestUserAddress
= 0x10000; /* Top of 64k */
364 Sbi
->HighestUserAddress
= (ULONG_PTR
)MmHighestUserAddress
;
365 Sbi
->ActiveProcessors
= KeActiveProcessors
;
366 Sbi
->NumberProcessors
= KeNumberProcessors
;
367 return (STATUS_SUCCESS
);
370 /* Class 1 - Processor Information */
371 QSI_DEF(SystemProcessorInformation
)
373 PSYSTEM_PROCESSOR_INFORMATION Spi
374 = (PSYSTEM_PROCESSOR_INFORMATION
) Buffer
;
376 *ReqSize
= sizeof (SYSTEM_PROCESSOR_INFORMATION
);
378 * Check user buffer's size
380 if (Size
< sizeof (SYSTEM_PROCESSOR_INFORMATION
))
382 return (STATUS_INFO_LENGTH_MISMATCH
);
384 Prcb
= KeGetCurrentPrcb();
385 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
386 Spi
->ProcessorLevel
= Prcb
->CpuType
;
387 Spi
->ProcessorRevision
= Prcb
->CpuStep
;
389 Spi
->FeatureBits
= Prcb
->FeatureBits
;
391 DPRINT("Arch %d Level %d Rev 0x%x\n", Spi
->ProcessorArchitecture
,
392 Spi
->ProcessorLevel
, Spi
->ProcessorRevision
);
394 return (STATUS_SUCCESS
);
397 /* Class 2 - Performance Information */
398 QSI_DEF(SystemPerformanceInformation
)
400 PSYSTEM_PERFORMANCE_INFORMATION Spi
401 = (PSYSTEM_PERFORMANCE_INFORMATION
) Buffer
;
403 PEPROCESS TheIdleProcess
;
405 *ReqSize
= sizeof (SYSTEM_PERFORMANCE_INFORMATION
);
407 * Check user buffer's size
409 if (Size
< sizeof (SYSTEM_PERFORMANCE_INFORMATION
))
411 return (STATUS_INFO_LENGTH_MISMATCH
);
414 TheIdleProcess
= PsIdleProcess
;
416 Spi
->IdleTime
.QuadPart
= TheIdleProcess
->Pcb
.KernelTime
* 100000LL;
418 Spi
->ReadTransferCount
.QuadPart
= IoReadTransferCount
;
419 Spi
->WriteTransferCount
.QuadPart
= IoWriteTransferCount
;
420 Spi
->OtherTransferCount
.QuadPart
= IoOtherTransferCount
;
421 Spi
->ReadOperationCount
= IoReadOperationCount
;
422 Spi
->WriteOperationCount
= IoWriteOperationCount
;
423 Spi
->OtherOperationCount
= IoOtherOperationCount
;
425 Spi
->AvailablePages
= MmStats
.NrFreePages
;
427 Add up all the used "Commitied" memory + pagefile.
428 Not sure this is right. 8^\
430 Spi
->TotalCommittedPages
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
+
431 MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
+
432 MiMemoryConsumers
[MC_CACHE
].PagesUsed
+
433 MiMemoryConsumers
[MC_USER
].PagesUsed
+
436 Add up the full system total + pagefile.
437 All this make Taskmgr happy but not sure it is the right numbers.
438 This too, fixes some of GlobalMemoryStatusEx numbers.
440 Spi
->TotalCommitLimit
= MmStats
.NrTotalPages
+ MiFreeSwapPages
+
443 Spi
->PeakCommitment
= 0; /* FIXME */
444 Spi
->PageFaults
= 0; /* FIXME */
445 Spi
->WriteCopyFaults
= 0; /* FIXME */
446 Spi
->TransitionFaults
= 0; /* FIXME */
447 Spi
->CacheTransitionFaults
= 0; /* FIXME */
448 Spi
->DemandZeroFaults
= 0; /* FIXME */
449 Spi
->PagesRead
= 0; /* FIXME */
450 Spi
->PageReadIos
= 0; /* FIXME */
451 Spi
->CacheReads
= 0; /* FIXME */
452 Spi
->CacheIos
= 0; /* FIXME */
453 Spi
->PagefilePagesWritten
= 0; /* FIXME */
454 Spi
->PagefilePageWriteIos
= 0; /* FIXME */
455 Spi
->MappedFilePagesWritten
= 0; /* FIXME */
456 Spi
->MappedFilePageWriteIos
= 0; /* FIXME */
458 Spi
->PagedPoolUsage
= MiMemoryConsumers
[MC_PPOOL
].PagesUsed
;
459 Spi
->PagedPoolAllocs
= 0; /* FIXME */
460 Spi
->PagedPoolFrees
= 0; /* FIXME */
461 Spi
->NonPagedPoolUsage
= MiMemoryConsumers
[MC_NPPOOL
].PagesUsed
;
462 Spi
->NonPagedPoolAllocs
= 0; /* FIXME */
463 Spi
->NonPagedPoolFrees
= 0; /* FIXME */
465 Spi
->TotalFreeSystemPtes
= 0; /* FIXME */
467 Spi
->SystemCodePage
= MmStats
.NrSystemPages
; /* FIXME */
469 Spi
->TotalSystemDriverPages
= 0; /* FIXME */
470 Spi
->TotalSystemCodePages
= 0; /* FIXME */
471 Spi
->SmallNonPagedLookasideListAllocateHits
= 0; /* FIXME */
472 Spi
->SmallPagedLookasideListAllocateHits
= 0; /* FIXME */
473 Spi
->Reserved3
= 0; /* FIXME */
475 Spi
->MmSystemCachePage
= MiMemoryConsumers
[MC_CACHE
].PagesUsed
;
476 Spi
->PagedPoolPage
= MmPagedPoolSize
; /* FIXME */
478 Spi
->SystemDriverPage
= 0; /* FIXME */
479 Spi
->FastReadNoWait
= 0; /* FIXME */
480 Spi
->FastReadWait
= 0; /* FIXME */
481 Spi
->FastReadResourceMiss
= 0; /* FIXME */
482 Spi
->FastReadNotPossible
= 0; /* FIXME */
484 Spi
->FastMdlReadNoWait
= 0; /* FIXME */
485 Spi
->FastMdlReadWait
= 0; /* FIXME */
486 Spi
->FastMdlReadResourceMiss
= 0; /* FIXME */
487 Spi
->FastMdlReadNotPossible
= 0; /* FIXME */
489 Spi
->MapDataNoWait
= 0; /* FIXME */
490 Spi
->MapDataWait
= 0; /* FIXME */
491 Spi
->MapDataNoWaitMiss
= 0; /* FIXME */
492 Spi
->MapDataWaitMiss
= 0; /* FIXME */
494 Spi
->PinMappedDataCount
= 0; /* FIXME */
495 Spi
->PinReadNoWait
= 0; /* FIXME */
496 Spi
->PinReadWait
= 0; /* FIXME */
497 Spi
->PinReadNoWaitMiss
= 0; /* FIXME */
498 Spi
->PinReadWaitMiss
= 0; /* FIXME */
499 Spi
->CopyReadNoWait
= 0; /* FIXME */
500 Spi
->CopyReadWait
= 0; /* FIXME */
501 Spi
->CopyReadNoWaitMiss
= 0; /* FIXME */
502 Spi
->CopyReadWaitMiss
= 0; /* FIXME */
504 Spi
->MdlReadNoWait
= 0; /* FIXME */
505 Spi
->MdlReadWait
= 0; /* FIXME */
506 Spi
->MdlReadNoWaitMiss
= 0; /* FIXME */
507 Spi
->MdlReadWaitMiss
= 0; /* FIXME */
508 Spi
->ReadAheadIos
= 0; /* FIXME */
509 Spi
->LazyWriteIos
= 0; /* FIXME */
510 Spi
->LazyWritePages
= 0; /* FIXME */
511 Spi
->DataFlushes
= 0; /* FIXME */
512 Spi
->DataPages
= 0; /* FIXME */
513 Spi
->ContextSwitches
= 0; /* FIXME */
514 Spi
->FirstLevelTbFills
= 0; /* FIXME */
515 Spi
->SecondLevelTbFills
= 0; /* FIXME */
516 Spi
->SystemCalls
= 0; /* FIXME */
518 return (STATUS_SUCCESS
);
521 /* Class 3 - Time Of Day Information */
522 QSI_DEF(SystemTimeOfDayInformation
)
524 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
525 LARGE_INTEGER CurrentTime
;
527 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
528 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
530 /* Check user buffer's size */
531 if (Size
< sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
533 return STATUS_INFO_LENGTH_MISMATCH
;
536 KeQuerySystemTime(&CurrentTime
);
538 Sti
->BootTime
= SystemBootTime
;
539 Sti
->CurrentTime
= CurrentTime
;
540 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
541 Sti
->TimeZoneId
= ExpTimeZoneId
;
544 return STATUS_SUCCESS
;
547 /* Class 4 - Path Information */
548 QSI_DEF(SystemPathInformation
)
550 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
551 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
553 return (STATUS_BREAKPOINT
);
556 /* Class 5 - Process Information */
557 QSI_DEF(SystemProcessInformation
)
559 ULONG ovlSize
=0, nThreads
;
563 /* scan the process list */
565 PSYSTEM_PROCESS_INFORMATION Spi
566 = (PSYSTEM_PROCESS_INFORMATION
) Buffer
;
568 *ReqSize
= sizeof(SYSTEM_PROCESS_INFORMATION
);
570 if (Size
< sizeof(SYSTEM_PROCESS_INFORMATION
))
572 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
575 syspr
= PsGetNextProcess(NULL
);
577 pCur
= (unsigned char *)Spi
;
581 PSYSTEM_PROCESS_INFORMATION SpiCur
;
584 int inLen
=32; // image name len in bytes
585 PLIST_ENTRY current_entry
;
588 SpiCur
= (PSYSTEM_PROCESS_INFORMATION
)pCur
;
591 current_entry
= pr
->ThreadListHead
.Flink
;
592 while (current_entry
!= &pr
->ThreadListHead
)
595 current_entry
= current_entry
->Flink
;
598 // size of the structure for every process
599 curSize
= sizeof(SYSTEM_PROCESS_INFORMATION
)-sizeof(SYSTEM_THREAD_INFORMATION
)+sizeof(SYSTEM_THREAD_INFORMATION
)*nThreads
;
600 ovlSize
+= curSize
+inLen
;
605 ObDereferenceObject(pr
);
607 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
610 // fill system information
611 SpiCur
->NextEntryOffset
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
612 SpiCur
->NumberOfThreads
= nThreads
;
613 SpiCur
->CreateTime
= pr
->CreateTime
;
614 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
615 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
616 SpiCur
->ImageName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
617 SpiCur
->ImageName
.MaximumLength
= inLen
;
618 SpiCur
->ImageName
.Buffer
= (void*)(pCur
+curSize
);
620 // copy name to the end of the struct
621 if(pr
!= PsIdleProcess
)
623 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
624 RtlAnsiStringToUnicodeString(&SpiCur
->ImageName
, &imgName
, FALSE
);
628 RtlInitUnicodeString(&SpiCur
->ImageName
, NULL
);
631 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
632 SpiCur
->UniqueProcessId
= pr
->UniqueProcessId
;
633 SpiCur
->InheritedFromUniqueProcessId
= pr
->InheritedFromUniqueProcessId
;
634 SpiCur
->HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
635 SpiCur
->PeakVirtualSize
= pr
->PeakVirtualSize
;
636 SpiCur
->VirtualSize
= pr
->VirtualSize
;
637 SpiCur
->PageFaultCount
= pr
->Vm
.PageFaultCount
;
638 SpiCur
->PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
; // Is this right using ->Vm. here ?
639 SpiCur
->WorkingSetSize
= pr
->Vm
.WorkingSetSize
; // Is this right using ->Vm. here ?
640 SpiCur
->QuotaPeakPagedPoolUsage
= pr
->QuotaPeak
[0];
641 SpiCur
->QuotaPagedPoolUsage
= pr
->QuotaUsage
[0];
642 SpiCur
->QuotaPeakNonPagedPoolUsage
= pr
->QuotaPeak
[1];
643 SpiCur
->QuotaNonPagedPoolUsage
= pr
->QuotaUsage
[1];
644 SpiCur
->PagefileUsage
= pr
->QuotaUsage
[3];
645 SpiCur
->PeakPagefileUsage
= pr
->QuotaPeak
[3];
646 SpiCur
->PrivateUsage
= pr
->CommitCharge
;
648 current_entry
= pr
->ThreadListHead
.Flink
;
649 while (current_entry
!= &pr
->ThreadListHead
)
651 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
654 SpiCur
->TH
[i
].KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
655 SpiCur
->TH
[i
].UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
656 // SpiCur->TH[i].CreateTime = current->CreateTime;
657 SpiCur
->TH
[i
].WaitTime
= current
->Tcb
.WaitTime
;
658 SpiCur
->TH
[i
].StartAddress
= (PVOID
) current
->StartAddress
;
659 SpiCur
->TH
[i
].ClientId
= current
->Cid
;
660 SpiCur
->TH
[i
].Priority
= current
->Tcb
.Priority
;
661 SpiCur
->TH
[i
].BasePriority
= current
->Tcb
.BasePriority
;
662 SpiCur
->TH
[i
].ContextSwitches
= current
->Tcb
.ContextSwitches
;
663 SpiCur
->TH
[i
].ThreadState
= current
->Tcb
.State
;
664 SpiCur
->TH
[i
].WaitReason
= current
->Tcb
.WaitReason
;
666 current_entry
= current_entry
->Flink
;
669 pr
= PsGetNextProcess(pr
);
671 if ((pr
== syspr
) || (pr
== NULL
))
673 SpiCur
->NextEntryOffset
= 0;
677 pCur
= pCur
+ curSize
+ inLen
;
678 } while ((pr
!= syspr
) && (pr
!= NULL
));
682 ObDereferenceObject(pr
);
686 return (STATUS_SUCCESS
);
689 /* Class 6 - Call Count Information */
690 QSI_DEF(SystemCallCountInformation
)
693 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
694 return (STATUS_NOT_IMPLEMENTED
);
697 /* Class 7 - Device Information */
698 QSI_DEF(SystemDeviceInformation
)
700 PSYSTEM_DEVICE_INFORMATION Sdi
701 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
702 PCONFIGURATION_INFORMATION ConfigInfo
;
704 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
706 * Check user buffer's size
708 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
710 return (STATUS_INFO_LENGTH_MISMATCH
);
713 ConfigInfo
= IoGetConfigurationInformation ();
715 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
716 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
717 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
718 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
719 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
720 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
722 return (STATUS_SUCCESS
);
725 /* Class 8 - Processor Performance Information */
726 QSI_DEF(SystemProcessorPerformanceInformation
)
728 PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION Spi
729 = (PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
) Buffer
;
732 LARGE_INTEGER CurrentTime
;
735 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
);
737 * Check user buffer's size
739 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
))
741 return (STATUS_INFO_LENGTH_MISMATCH
);
744 CurrentTime
.QuadPart
= KeQueryInterruptTime();
745 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
746 for (i
= 0; i
< KeNumberProcessors
; i
++)
748 Spi
->IdleTime
.QuadPart
= (Prcb
->IdleThread
->KernelTime
+ Prcb
->IdleThread
->UserTime
) * 100000LL; // IdleTime
749 Spi
->KernelTime
.QuadPart
= Prcb
->KernelTime
* 100000LL; // KernelTime
750 Spi
->UserTime
.QuadPart
= Prcb
->UserTime
* 100000LL;
751 Spi
->DpcTime
.QuadPart
= Prcb
->DpcTime
* 100000LL;
752 Spi
->InterruptTime
.QuadPart
= Prcb
->InterruptTime
* 100000LL;
753 Spi
->InterruptCount
= Prcb
->InterruptCount
; // Interrupt Count
755 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
758 return (STATUS_SUCCESS
);
761 /* Class 9 - Flags Information */
762 QSI_DEF(SystemFlagsInformation
)
764 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
766 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
767 return (STATUS_INFO_LENGTH_MISMATCH
);
769 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
770 return (STATUS_SUCCESS
);
773 SSI_DEF(SystemFlagsInformation
)
775 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
777 return (STATUS_INFO_LENGTH_MISMATCH
);
779 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
780 return (STATUS_SUCCESS
);
783 /* Class 10 - Call Time Information */
784 QSI_DEF(SystemCallTimeInformation
)
787 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
788 return (STATUS_NOT_IMPLEMENTED
);
791 /* Class 11 - Module Information */
792 QSI_DEF(SystemModuleInformation
)
794 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
797 /* Class 12 - Locks Information */
798 QSI_DEF(SystemLocksInformation
)
801 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
802 return (STATUS_NOT_IMPLEMENTED
);
805 /* Class 13 - Stack Trace Information */
806 QSI_DEF(SystemStackTraceInformation
)
809 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
810 return (STATUS_NOT_IMPLEMENTED
);
813 /* Class 14 - Paged Pool Information */
814 QSI_DEF(SystemPagedPoolInformation
)
817 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
818 return (STATUS_NOT_IMPLEMENTED
);
821 /* Class 15 - Non Paged Pool Information */
822 QSI_DEF(SystemNonPagedPoolInformation
)
825 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
826 return (STATUS_NOT_IMPLEMENTED
);
831 ObpGetNextHandleByProcessCount(PSYSTEM_HANDLE_TABLE_ENTRY_INFO pshi
,
835 /* Class 16 - Handle Information */
836 QSI_DEF(SystemHandleInformation
)
838 PSYSTEM_HANDLE_INFORMATION Shi
=
839 (PSYSTEM_HANDLE_INFORMATION
) Buffer
;
841 DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
843 if (Size
< sizeof (SYSTEM_HANDLE_INFORMATION
))
845 * ReqSize
= sizeof (SYSTEM_HANDLE_INFORMATION
);
846 return (STATUS_INFO_LENGTH_MISMATCH
);
849 DPRINT("SystemHandleInformation 1\n");
855 /* First Calc Size from Count. */
856 syspr
= PsGetNextProcess(NULL
);
861 hCount
= hCount
+ (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
862 pr
= PsGetNextProcess(pr
);
864 if ((pr
== syspr
) || (pr
== NULL
))
866 } while ((pr
!= syspr
) && (pr
!= NULL
));
870 ObDereferenceObject(pr
);
873 DPRINT("SystemHandleInformation 2\n");
875 curSize
= sizeof(SYSTEM_HANDLE_INFORMATION
)+
876 ( (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) * hCount
) -
877 (sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO
) ));
879 Shi
->NumberOfHandles
= hCount
;
884 return (STATUS_INFO_LENGTH_MISMATCH
);
887 DPRINT("SystemHandleInformation 3\n");
889 /* Now get Handles from all processs. */
890 syspr
= PsGetNextProcess(NULL
);
895 int Count
= 0, HandleCount
;
897 HandleCount
= (pr
->ObjectTable
? ObpGetHandleCountByHandleTable(pr
->ObjectTable
) : 0);
899 for (Count
= 0; HandleCount
> 0 ; HandleCount
--)
901 ObpGetNextHandleByProcessCount( &Shi
->Handles
[i
], pr
, Count
);
906 pr
= PsGetNextProcess(pr
);
908 if ((pr
== syspr
) || (pr
== NULL
))
910 } while ((pr
!= syspr
) && (pr
!= NULL
));
914 ObDereferenceObject(pr
);
917 DPRINT("SystemHandleInformation 4\n");
918 return (STATUS_SUCCESS
);
922 SSI_DEF(SystemHandleInformation)
925 return (STATUS_SUCCESS);
929 /* Class 17 - Information */
930 QSI_DEF(SystemObjectInformation
)
933 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
934 return (STATUS_NOT_IMPLEMENTED
);
937 /* Class 18 - Information */
938 QSI_DEF(SystemPageFileInformation
)
940 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
942 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
944 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
945 return (STATUS_INFO_LENGTH_MISMATCH
);
948 UNICODE_STRING FileName
; /* FIXME */
949 RtlInitUnicodeString(&FileName
, NULL
); /* FIXME */
952 Spfi
->NextEntryOffset
= 0;
954 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
955 Spfi
->TotalInUse
= MiUsedSwapPages
;
956 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
957 Spfi
->PageFileName
= FileName
;
958 return (STATUS_SUCCESS
);
961 /* Class 19 - Vdm Instemul Information */
962 QSI_DEF(SystemVdmInstemulInformation
)
965 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
966 return (STATUS_NOT_IMPLEMENTED
);
969 /* Class 20 - Vdm Bop Information */
970 QSI_DEF(SystemVdmBopInformation
)
973 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
974 return (STATUS_NOT_IMPLEMENTED
);
977 /* Class 21 - File Cache Information */
978 QSI_DEF(SystemFileCacheInformation
)
980 SYSTEM_CACHE_INFORMATION
*Sci
= (SYSTEM_CACHE_INFORMATION
*) Buffer
;
982 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
984 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
985 return (STATUS_INFO_LENGTH_MISMATCH
);
987 /* Return the Byte size not the page size. */
989 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
991 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
993 Sci
->PageFaultCount
= 0; /* FIXME */
994 Sci
->MinimumWorkingSet
= 0; /* FIXME */
995 Sci
->MaximumWorkingSet
= 0; /* FIXME */
996 Sci
->TransitionSharedPages
= 0; /* FIXME */
997 Sci
->TransitionSharedPagesPeak
= 0; /* FIXME */
999 return (STATUS_SUCCESS
);
1002 SSI_DEF(SystemFileCacheInformation
)
1004 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
1006 return (STATUS_INFO_LENGTH_MISMATCH
);
1009 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
1010 return (STATUS_NOT_IMPLEMENTED
);
1013 /* Class 22 - Pool Tag Information */
1014 QSI_DEF(SystemPoolTagInformation
)
1017 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
1018 return (STATUS_NOT_IMPLEMENTED
);
1021 /* Class 23 - Interrupt Information for all processors */
1022 QSI_DEF(SystemInterruptInformation
)
1027 PSYSTEM_INTERRUPT_INFORMATION sii
= (PSYSTEM_INTERRUPT_INFORMATION
)Buffer
;
1029 if(Size
< KeNumberProcessors
* sizeof(SYSTEM_INTERRUPT_INFORMATION
))
1031 return (STATUS_INFO_LENGTH_MISMATCH
);
1034 ti
= KeQueryTimeIncrement();
1036 Prcb
= ((PKPCR
)KPCR_BASE
)->Prcb
;
1037 for (i
= 0; i
< KeNumberProcessors
; i
++)
1039 sii
->ContextSwitches
= Prcb
->KeContextSwitches
;
1040 sii
->DpcCount
= 0; /* FIXME */
1041 sii
->DpcRate
= 0; /* FIXME */
1042 sii
->TimeIncrement
= ti
;
1043 sii
->DpcBypassCount
= 0; /* FIXME */
1044 sii
->ApcBypassCount
= 0; /* FIXME */
1046 Prcb
= (PKPRCB
)((ULONG_PTR
)Prcb
+ PAGE_SIZE
);
1049 return STATUS_SUCCESS
;
1052 /* Class 24 - DPC Behaviour Information */
1053 QSI_DEF(SystemDpcBehaviourInformation
)
1056 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
1057 return (STATUS_NOT_IMPLEMENTED
);
1060 SSI_DEF(SystemDpcBehaviourInformation
)
1063 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1064 return (STATUS_NOT_IMPLEMENTED
);
1067 /* Class 25 - Full Memory Information */
1068 QSI_DEF(SystemFullMemoryInformation
)
1070 PULONG Spi
= (PULONG
) Buffer
;
1072 PEPROCESS TheIdleProcess
;
1074 * ReqSize
= sizeof (ULONG
);
1076 if (sizeof (ULONG
) != Size
)
1078 return (STATUS_INFO_LENGTH_MISMATCH
);
1080 DPRINT("SystemFullMemoryInformation\n");
1082 TheIdleProcess
= PsIdleProcess
;
1084 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
1085 TheIdleProcess
->UniqueProcessId
,
1086 TheIdleProcess
->Pcb
.KernelTime
,
1091 MmPrintMemoryStatistic();
1094 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
1096 return (STATUS_SUCCESS
);
1099 /* Class 26 - Load Image */
1100 SSI_DEF(SystemLoadImage
)
1102 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
1104 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
1106 return(STATUS_INFO_LENGTH_MISMATCH
);
1109 return(LdrpLoadImage(&Sli
->ModuleName
,
1111 &Sli
->SectionPointer
,
1113 &Sli
->ExportDirectory
));
1116 /* Class 27 - Unload Image */
1117 SSI_DEF(SystemUnloadImage
)
1119 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
1121 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
1123 return(STATUS_INFO_LENGTH_MISMATCH
);
1126 return(LdrpUnloadImage(Sui
->ModuleBase
));
1129 /* Class 28 - Time Adjustment Information */
1130 QSI_DEF(SystemTimeAdjustmentInformation
)
1132 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1134 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
1135 return (STATUS_INFO_LENGTH_MISMATCH
);
1138 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1139 return (STATUS_NOT_IMPLEMENTED
);
1142 SSI_DEF(SystemTimeAdjustmentInformation
)
1144 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1146 return (STATUS_INFO_LENGTH_MISMATCH
);
1149 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1150 return (STATUS_NOT_IMPLEMENTED
);
1153 /* Class 29 - Summary Memory Information */
1154 QSI_DEF(SystemSummaryMemoryInformation
)
1157 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1158 return (STATUS_NOT_IMPLEMENTED
);
1161 /* Class 30 - Next Event Id Information */
1162 QSI_DEF(SystemNextEventIdInformation
)
1165 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1166 return (STATUS_NOT_IMPLEMENTED
);
1169 /* Class 31 - Event Ids Information */
1170 QSI_DEF(SystemEventIdsInformation
)
1173 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1174 return (STATUS_NOT_IMPLEMENTED
);
1177 /* Class 32 - Crash Dump Information */
1178 QSI_DEF(SystemCrashDumpInformation
)
1181 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1182 return (STATUS_NOT_IMPLEMENTED
);
1185 /* Class 33 - Exception Information */
1186 QSI_DEF(SystemExceptionInformation
)
1189 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1190 return (STATUS_NOT_IMPLEMENTED
);
1193 /* Class 34 - Crash Dump State Information */
1194 QSI_DEF(SystemCrashDumpStateInformation
)
1197 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1198 return (STATUS_NOT_IMPLEMENTED
);
1201 /* Class 35 - Kernel Debugger Information */
1202 QSI_DEF(SystemKernelDebuggerInformation
)
1205 DPRINT1("NtQuerySystemInformation - SystemKernelDebuggerInformation not implemented\n");
1206 return (STATUS_NOT_IMPLEMENTED
);
1209 /* Class 36 - Context Switch Information */
1210 QSI_DEF(SystemContextSwitchInformation
)
1213 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1214 return (STATUS_NOT_IMPLEMENTED
);
1217 /* Class 37 - Registry Quota Information */
1218 QSI_DEF(SystemRegistryQuotaInformation
)
1220 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1222 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1223 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1225 return STATUS_INFO_LENGTH_MISMATCH
;
1228 DPRINT1("Faking max registry size of 32 MB\n");
1229 srqi
->RegistryQuotaAllowed
= 0x2000000;
1230 srqi
->RegistryQuotaUsed
= 0x200000;
1231 srqi
->Reserved1
= (void*)0x200000;
1233 return STATUS_SUCCESS
;
1236 SSI_DEF(SystemRegistryQuotaInformation
)
1239 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1240 return (STATUS_NOT_IMPLEMENTED
);
1243 /* Class 38 - Load And Call Image */
1244 SSI_DEF(SystemLoadAndCallImage
)
1246 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
1248 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
1250 return(STATUS_INFO_LENGTH_MISMATCH
);
1253 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
1256 /* Class 39 - Priority Separation */
1257 SSI_DEF(SystemPrioritySeperation
)
1260 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1261 return (STATUS_NOT_IMPLEMENTED
);
1264 /* Class 40 - Plug Play Bus Information */
1265 QSI_DEF(SystemPlugPlayBusInformation
)
1268 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1269 return (STATUS_NOT_IMPLEMENTED
);
1272 /* Class 41 - Dock Information */
1273 QSI_DEF(SystemDockInformation
)
1276 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1277 return (STATUS_NOT_IMPLEMENTED
);
1280 /* Class 42 - Power Information */
1281 QSI_DEF(SystemPowerInformation
)
1284 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1285 return (STATUS_NOT_IMPLEMENTED
);
1288 /* Class 43 - Processor Speed Information */
1289 QSI_DEF(SystemProcessorSpeedInformation
)
1292 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1293 return (STATUS_NOT_IMPLEMENTED
);
1296 /* Class 44 - Current Time Zone Information */
1297 QSI_DEF(SystemCurrentTimeZoneInformation
)
1299 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1301 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1303 return STATUS_INFO_LENGTH_MISMATCH
;
1306 /* Copy the time zone information struct */
1309 sizeof(TIME_ZONE_INFORMATION
));
1311 return STATUS_SUCCESS
;
1315 SSI_DEF(SystemCurrentTimeZoneInformation
)
1317 /* Check user buffer's size */
1318 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1320 return STATUS_INFO_LENGTH_MISMATCH
;
1323 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1327 /* Class 45 - Lookaside Information */
1328 QSI_DEF(SystemLookasideInformation
)
1331 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1332 return (STATUS_NOT_IMPLEMENTED
);
1336 /* Class 46 - Set time slip event */
1337 SSI_DEF(SystemSetTimeSlipEvent
)
1340 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1341 return (STATUS_NOT_IMPLEMENTED
);
1345 /* Class 47 - Create a new session (TSE) */
1346 SSI_DEF(SystemCreateSession
)
1349 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1350 return (STATUS_NOT_IMPLEMENTED
);
1354 /* Class 48 - Delete an existing session (TSE) */
1355 SSI_DEF(SystemDeleteSession
)
1358 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1359 return (STATUS_NOT_IMPLEMENTED
);
1363 /* Class 49 - UNKNOWN */
1364 QSI_DEF(SystemInvalidInfoClass4
)
1367 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1368 return (STATUS_NOT_IMPLEMENTED
);
1372 /* Class 50 - System range start address */
1373 QSI_DEF(SystemRangeStartInformation
)
1376 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1377 return (STATUS_NOT_IMPLEMENTED
);
1381 /* Class 51 - Driver verifier information */
1382 QSI_DEF(SystemVerifierInformation
)
1385 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1386 return (STATUS_NOT_IMPLEMENTED
);
1390 SSI_DEF(SystemVerifierInformation
)
1393 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1394 return (STATUS_NOT_IMPLEMENTED
);
1398 /* Class 52 - Add a driver verifier */
1399 SSI_DEF(SystemAddVerifier
)
1402 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1403 return (STATUS_NOT_IMPLEMENTED
);
1407 /* Class 53 - A session's processes */
1408 QSI_DEF(SystemSessionProcessesInformation
)
1411 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1412 return (STATUS_NOT_IMPLEMENTED
);
1416 /* Query/Set Calls Table */
1420 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1421 NTSTATUS (* Set
) (PVOID
,ULONG
);
1428 // XX unknown behaviour
1430 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1431 #define SI_QX(n) {QSI_USE(n),NULL}
1432 #define SI_XS(n) {NULL,SSI_USE(n)}
1433 #define SI_XX(n) {NULL,NULL}
1439 SI_QX(SystemBasicInformation
),
1440 SI_QX(SystemProcessorInformation
),
1441 SI_QX(SystemPerformanceInformation
),
1442 SI_QX(SystemTimeOfDayInformation
),
1443 SI_QX(SystemPathInformation
), /* should be SI_XX */
1444 SI_QX(SystemProcessInformation
),
1445 SI_QX(SystemCallCountInformation
),
1446 SI_QX(SystemDeviceInformation
),
1447 SI_QX(SystemProcessorPerformanceInformation
),
1448 SI_QS(SystemFlagsInformation
),
1449 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1450 SI_QX(SystemModuleInformation
),
1451 SI_QX(SystemLocksInformation
),
1452 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1453 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1454 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1455 SI_QX(SystemHandleInformation
),
1456 SI_QX(SystemObjectInformation
),
1457 SI_QX(SystemPageFileInformation
),
1458 SI_QX(SystemVdmInstemulInformation
),
1459 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1460 SI_QS(SystemFileCacheInformation
),
1461 SI_QX(SystemPoolTagInformation
),
1462 SI_QX(SystemInterruptInformation
),
1463 SI_QS(SystemDpcBehaviourInformation
),
1464 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1465 SI_XS(SystemLoadImage
),
1466 SI_XS(SystemUnloadImage
),
1467 SI_QS(SystemTimeAdjustmentInformation
),
1468 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1469 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1470 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1471 SI_QX(SystemCrashDumpInformation
),
1472 SI_QX(SystemExceptionInformation
),
1473 SI_QX(SystemCrashDumpStateInformation
),
1474 SI_QX(SystemKernelDebuggerInformation
),
1475 SI_QX(SystemContextSwitchInformation
),
1476 SI_QS(SystemRegistryQuotaInformation
),
1477 SI_XS(SystemLoadAndCallImage
),
1478 SI_XS(SystemPrioritySeperation
),
1479 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1480 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1481 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1482 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1483 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1484 SI_QX(SystemLookasideInformation
),
1485 SI_XS(SystemSetTimeSlipEvent
),
1486 SI_XS(SystemCreateSession
),
1487 SI_XS(SystemDeleteSession
),
1488 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1489 SI_QX(SystemRangeStartInformation
),
1490 SI_QS(SystemVerifierInformation
),
1491 SI_XS(SystemAddVerifier
),
1492 SI_QX(SystemSessionProcessesInformation
)
1500 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1501 OUT PVOID UnsafeSystemInformation
,
1503 OUT PULONG UnsafeResultLength
)
1506 PVOID SystemInformation
;
1512 /* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
1513 SystemInformationClass );
1515 /*if (ExGetPreviousMode() == KernelMode)
1517 SystemInformation
= UnsafeSystemInformation
;
1521 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1522 if (SystemInformation == NULL)
1524 return(STATUS_NO_MEMORY);
1528 /* Clear user buffer. */
1529 RtlZeroMemory(SystemInformation
, Length
);
1532 * Check the request is valid.
1534 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1535 (SystemInformationClass
< SystemInformationClassMax
))
1537 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1540 * Hand the request to a subhandler.
1542 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1545 /*if (ExGetPreviousMode() != KernelMode)
1547 Status = MmCopyToCaller(UnsafeSystemInformation,
1550 ExFreePool(SystemInformation);
1551 if (!NT_SUCCESS(Status))
1556 if (UnsafeResultLength
!= NULL
)
1558 /*if (ExGetPreviousMode() == KernelMode)
1560 *UnsafeResultLength = ResultLength;
1564 Status
= MmCopyToCaller(UnsafeResultLength
,
1567 if (!NT_SUCCESS(Status
))
1576 return (STATUS_INVALID_INFO_CLASS
);
1582 NtSetSystemInformation (
1583 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1584 IN PVOID SystemInformation
,
1585 IN ULONG SystemInformationLength
1591 * If called from user mode, check
1592 * possible unsafe arguments.
1595 if (KernelMode
!= KeGetPreviousMode())
1599 // SystemInformation,
1609 * Check the request is valid.
1611 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1612 && (SystemInformationClass
< SystemInformationClassMax
)
1615 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1618 * Hand the request to a subhandler.
1620 return CallQS
[SystemInformationClass
].Set (
1622 SystemInformationLength
1626 return (STATUS_INVALID_INFO_CLASS
);
1632 NtFlushInstructionCache (
1633 IN HANDLE ProcessHandle
,
1634 IN PVOID BaseAddress
,
1635 IN UINT NumberOfBytesToFlush
1640 __asm__("wbinvd\n");
1641 return STATUS_SUCCESS
;