1 /* $Id: sysinfo.c,v 1.61 2004/12/01 23:51:11 ea Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ex/sysinfo.c
6 * PURPOSE: System information functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
10 * 20/03/2003: implemented querying SystemProcessInformation,
11 * no more copying to-from the caller (Aleksey
12 * Bragin <aleksey@studiocerebral.com>)
15 /* INCLUDES *****************************************************************/
19 #include <internal/debug.h>
21 extern ULONG NtGlobalFlag
; /* FIXME: it should go in a ddk/?.h */
22 ULONGLONG STDCALL
KeQueryInterruptTime(VOID
);
24 VOID
MmPrintMemoryStatistic(VOID
);
26 /* FUNCTIONS *****************************************************************/
37 PHANDLE Handle OPTIONAL
48 ExGetCurrentProcessorCpuUsage (
54 ULONG PercentTime
= 0;
57 Pcr
= KeGetCurrentKPCR();
59 ScaledIdle
= Pcr
->PrcbData
.IdleThread
->KernelTime
* 100;
60 TotalTime
= Pcr
->PrcbData
.KernelTime
+ Pcr
->PrcbData
.UserTime
;
61 if (TotalTime
) PercentTime
= 100 - (ScaledIdle
/ TotalTime
);
62 CpuUsage
= &PercentTime
;
70 ExGetCurrentProcessorCounts (
71 PULONG ThreadKernelTime
,
73 PULONG ProcessorNumber
81 Pcr
= KeGetCurrentKPCR();
83 TotalTime
= Pcr
->PrcbData
.KernelTime
+ Pcr
->PrcbData
.UserTime
;
84 ThreadTime
= Pcr
->PrcbData
.CurrentThread
->KernelTime
;
85 ProcNumber
= Pcr
->ProcessorNumber
;
87 ThreadKernelTime
= &ThreadTime
;
88 TotalCpuTime
= &TotalTime
;
89 ProcessorNumber
= &ProcNumber
;
93 NtQuerySystemEnvironmentValue (IN PUNICODE_STRING UnsafeName
,
94 OUT PVOID UnsafeValue
,
96 IN OUT PULONG UnsafeReturnLength
)
100 UNICODE_STRING WName
;
104 UNICODE_STRING WValue
;
108 * Copy the name to kernel space if necessary and convert it to ANSI.
110 if (ExGetPreviousMode() != KernelMode
)
112 Status
= RtlCaptureUnicodeString(&WName
, UnsafeName
);
113 if (!NT_SUCCESS(Status
))
117 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
118 if (!NT_SUCCESS(Status
))
125 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
126 if (!NT_SUCCESS(Status
))
133 * Create a temporary buffer for the value
135 Value
= ExAllocatePool(NonPagedPool
, Length
);
138 RtlFreeAnsiString(&AName
);
139 if (ExGetPreviousMode() != KernelMode
)
141 RtlFreeUnicodeString(&WName
);
143 return(STATUS_NO_MEMORY
);
147 * Get the environment variable
149 Result
= HalGetEnvironmentVariable(AName
.Buffer
, Value
, Length
);
152 RtlFreeAnsiString(&AName
);
153 if (ExGetPreviousMode() != KernelMode
)
155 RtlFreeUnicodeString(&WName
);
158 return(STATUS_UNSUCCESSFUL
);
162 * Convert the result to UNICODE.
164 RtlInitAnsiString(&AValue
, Value
);
165 Status
= RtlAnsiStringToUnicodeString(&WValue
, &AValue
, TRUE
);
166 if (!NT_SUCCESS(Status
))
168 RtlFreeAnsiString(&AName
);
169 if (ExGetPreviousMode() != KernelMode
)
171 RtlFreeUnicodeString(&WName
);
176 ReturnLength
= WValue
.Length
;
179 * Copy the result back to the caller.
181 if (ExGetPreviousMode() != KernelMode
)
183 Status
= MmCopyToCaller(UnsafeValue
, WValue
.Buffer
, ReturnLength
);
184 if (!NT_SUCCESS(Status
))
186 RtlFreeAnsiString(&AName
);
187 if (ExGetPreviousMode() != KernelMode
)
189 RtlFreeUnicodeString(&WName
);
192 RtlFreeUnicodeString(&WValue
);
196 Status
= MmCopyToCaller(UnsafeReturnLength
, &ReturnLength
,
198 if (!NT_SUCCESS(Status
))
200 RtlFreeAnsiString(&AName
);
201 if (ExGetPreviousMode() != KernelMode
)
203 RtlFreeUnicodeString(&WName
);
206 RtlFreeUnicodeString(&WValue
);
212 memcpy(UnsafeValue
, WValue
.Buffer
, ReturnLength
);
213 memcpy(UnsafeReturnLength
, &ReturnLength
, sizeof(ULONG
));
217 * Free temporary buffers.
219 RtlFreeAnsiString(&AName
);
220 if (ExGetPreviousMode() != KernelMode
)
222 RtlFreeUnicodeString(&WName
);
225 RtlFreeUnicodeString(&WValue
);
227 return(STATUS_SUCCESS
);
232 NtSetSystemEnvironmentValue (IN PUNICODE_STRING UnsafeName
,
233 IN PUNICODE_STRING UnsafeValue
)
235 UNICODE_STRING WName
;
237 UNICODE_STRING WValue
;
243 * Check for required privilege.
245 /* FIXME: Not implemented. */
248 * Copy the name to kernel space if necessary and convert it to ANSI.
250 if (ExGetPreviousMode() != KernelMode
)
252 Status
= RtlCaptureUnicodeString(&WName
, UnsafeName
);
253 if (!NT_SUCCESS(Status
))
257 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
258 if (!NT_SUCCESS(Status
))
265 Status
= RtlUnicodeStringToAnsiString(&AName
, UnsafeName
, TRUE
);
266 if (!NT_SUCCESS(Status
))
273 * Copy the value to kernel space and convert to ANSI.
275 if (ExGetPreviousMode() != KernelMode
)
277 Status
= RtlCaptureUnicodeString(&WValue
, UnsafeValue
);
278 if (!NT_SUCCESS(Status
))
280 RtlFreeUnicodeString(&WName
);
281 RtlFreeAnsiString(&AName
);
284 Status
= RtlUnicodeStringToAnsiString(&AValue
, UnsafeValue
, TRUE
);
285 if (!NT_SUCCESS(Status
))
287 RtlFreeUnicodeString(&WName
);
288 RtlFreeAnsiString(&AName
);
289 RtlFreeUnicodeString(&WValue
);
295 Status
= RtlUnicodeStringToAnsiString(&AValue
, UnsafeValue
, TRUE
);
296 if (!NT_SUCCESS(Status
))
298 RtlFreeAnsiString(&AName
);
304 * Set the environment variable
306 Result
= HalSetEnvironmentVariable(AName
.Buffer
, AValue
.Buffer
);
309 * Free everything and return status.
311 RtlFreeAnsiString(&AName
);
312 RtlFreeAnsiString(&AValue
);
313 if (ExGetPreviousMode() != KernelMode
)
315 RtlFreeUnicodeString(&WName
);
316 RtlFreeUnicodeString(&WValue
);
321 return(STATUS_UNSUCCESSFUL
);
323 return(STATUS_SUCCESS
);
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 Pcr
= KeGetCurrentKPCR();
385 Spi
->ProcessorArchitecture
= 0; /* Intel Processor */
386 Spi
->ProcessorLevel
= Pcr
->PrcbData
.CpuType
;
387 Spi
->ProcessorRevision
= Pcr
->PrcbData
.CpuStep
;
389 Spi
->FeatureBits
= Pcr
->PrcbData
.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 PsLookupProcessByProcessId((PVOID
) 1, &TheIdleProcess
);
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 ObDereferenceObject(TheIdleProcess
);
520 return (STATUS_SUCCESS
);
523 /* Class 3 - Time Of Day Information */
524 QSI_DEF(SystemTimeOfDayInformation
)
526 PSYSTEM_TIMEOFDAY_INFORMATION Sti
;
527 LARGE_INTEGER CurrentTime
;
529 Sti
= (PSYSTEM_TIMEOFDAY_INFORMATION
)Buffer
;
530 *ReqSize
= sizeof (SYSTEM_TIMEOFDAY_INFORMATION
);
532 /* Check user buffer's size */
533 if (Size
< sizeof (SYSTEM_TIMEOFDAY_INFORMATION
))
535 return STATUS_INFO_LENGTH_MISMATCH
;
538 KeQuerySystemTime(&CurrentTime
);
540 Sti
->BootTime
= SystemBootTime
;
541 Sti
->CurrentTime
= CurrentTime
;
542 Sti
->TimeZoneBias
.QuadPart
= ExpTimeZoneBias
.QuadPart
;
543 Sti
->TimeZoneId
= ExpTimeZoneId
;
546 return STATUS_SUCCESS
;
549 /* Class 4 - Path Information */
550 QSI_DEF(SystemPathInformation
)
552 /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */
553 DPRINT1("NtQuerySystemInformation - SystemPathInformation not implemented\n");
555 return (STATUS_BREAKPOINT
);
558 /* Class 5 - Process Information */
559 QSI_DEF(SystemProcessInformation
)
561 ULONG ovlSize
=0, nThreads
;
565 /* scan the process list */
567 PSYSTEM_PROCESSES Spi
568 = (PSYSTEM_PROCESSES
) Buffer
;
570 *ReqSize
= sizeof(SYSTEM_PROCESSES
);
572 if (Size
< sizeof(SYSTEM_PROCESSES
))
574 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
577 syspr
= PsGetNextProcess(NULL
);
579 pCur
= (unsigned char *)Spi
;
583 PSYSTEM_PROCESSES SpiCur
;
586 int inLen
=32; // image name len in bytes
587 PLIST_ENTRY current_entry
;
590 SpiCur
= (PSYSTEM_PROCESSES
)pCur
;
592 nThreads
= PsEnumThreadsByProcess(pr
);
594 // size of the structure for every process
595 curSize
= sizeof(SYSTEM_PROCESSES
)-sizeof(SYSTEM_THREADS
)+sizeof(SYSTEM_THREADS
)*nThreads
;
596 ovlSize
+= curSize
+inLen
;
601 ObDereferenceObject(pr
);
603 return (STATUS_INFO_LENGTH_MISMATCH
); // in case buffer size is too small
606 // fill system information
607 SpiCur
->NextEntryDelta
= curSize
+inLen
; // relative offset to the beginnnig of the next structure
608 SpiCur
->ThreadCount
= nThreads
;
609 SpiCur
->CreateTime
= pr
->CreateTime
;
610 SpiCur
->UserTime
.QuadPart
= pr
->Pcb
.UserTime
* 100000LL;
611 SpiCur
->KernelTime
.QuadPart
= pr
->Pcb
.KernelTime
* 100000LL;
612 SpiCur
->ProcessName
.Length
= strlen(pr
->ImageFileName
) * sizeof(WCHAR
);
613 SpiCur
->ProcessName
.MaximumLength
= inLen
;
614 SpiCur
->ProcessName
.Buffer
= (void*)(pCur
+curSize
);
616 // copy name to the end of the struct
617 RtlInitAnsiString(&imgName
, pr
->ImageFileName
);
618 RtlAnsiStringToUnicodeString(&SpiCur
->ProcessName
, &imgName
, FALSE
);
620 SpiCur
->BasePriority
= pr
->Pcb
.BasePriority
;
621 SpiCur
->ProcessId
= pr
->UniqueProcessId
;
622 SpiCur
->InheritedFromProcessId
= (DWORD
)(pr
->InheritedFromUniqueProcessId
);
623 SpiCur
->HandleCount
= ObpGetHandleCountByHandleTable(&pr
->HandleTable
);
624 SpiCur
->VmCounters
.PeakVirtualSize
= pr
->PeakVirtualSize
;
625 SpiCur
->VmCounters
.VirtualSize
= pr
->VirtualSize
.QuadPart
;
626 SpiCur
->VmCounters
.PageFaultCount
= pr
->LastFaultCount
;
627 SpiCur
->VmCounters
.PeakWorkingSetSize
= pr
->Vm
.PeakWorkingSetSize
; // Is this right using ->Vm. here ?
628 SpiCur
->VmCounters
.WorkingSetSize
= pr
->Vm
.WorkingSetSize
; // Is this right using ->Vm. here ?
629 SpiCur
->VmCounters
.QuotaPeakPagedPoolUsage
=
630 pr
->QuotaPeakPoolUsage
[0];
631 SpiCur
->VmCounters
.QuotaPagedPoolUsage
=
632 pr
->QuotaPoolUsage
[0];
633 SpiCur
->VmCounters
.QuotaPeakNonPagedPoolUsage
=
634 pr
->QuotaPeakPoolUsage
[1];
635 SpiCur
->VmCounters
.QuotaNonPagedPoolUsage
=
636 pr
->QuotaPoolUsage
[1];
637 SpiCur
->VmCounters
.PagefileUsage
= pr
->PagefileUsage
; // FIXME
638 SpiCur
->VmCounters
.PeakPagefileUsage
= pr
->PeakPagefileUsage
;
639 // KJK::Hyperion: I don't know what does this mean. VM_COUNTERS
640 // doesn't seem to contain any equivalent field
641 //SpiCur->TotalPrivateBytes = pr->NumberOfPrivatePages; //FIXME: bytes != pages
643 current_entry
= pr
->ThreadListHead
.Flink
;
644 while (current_entry
!= &pr
->ThreadListHead
)
646 current
= CONTAINING_RECORD(current_entry
, ETHREAD
,
649 SpiCur
->Threads
[i
].KernelTime
.QuadPart
= current
->Tcb
.KernelTime
* 100000LL;
650 SpiCur
->Threads
[i
].UserTime
.QuadPart
= current
->Tcb
.UserTime
* 100000LL;
651 // SpiCur->Threads[i].CreateTime = current->CreateTime;
652 SpiCur
->Threads
[i
].WaitTime
= current
->Tcb
.WaitTime
;
653 SpiCur
->Threads
[i
].StartAddress
= (PVOID
) current
->StartAddress
;
654 SpiCur
->Threads
[i
].ClientId
= current
->Cid
;
655 SpiCur
->Threads
[i
].Priority
= current
->Tcb
.Priority
;
656 SpiCur
->Threads
[i
].BasePriority
= current
->Tcb
.BasePriority
;
657 SpiCur
->Threads
[i
].ContextSwitchCount
= current
->Tcb
.ContextSwitches
;
658 SpiCur
->Threads
[i
].State
= current
->Tcb
.State
;
659 SpiCur
->Threads
[i
].WaitReason
= current
->Tcb
.WaitReason
;
661 current_entry
= current_entry
->Flink
;
664 pr
= PsGetNextProcess(pr
);
666 if ((pr
== syspr
) || (pr
== NULL
))
668 SpiCur
->NextEntryDelta
= 0;
672 pCur
= pCur
+ curSize
+ inLen
;
673 } while ((pr
!= syspr
) && (pr
!= NULL
));
678 ObDereferenceObject(pr
);
680 return (STATUS_SUCCESS
);
683 /* Class 6 - Call Count Information */
684 QSI_DEF(SystemCallCountInformation
)
687 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
688 return (STATUS_NOT_IMPLEMENTED
);
691 /* Class 7 - Device Information */
692 QSI_DEF(SystemDeviceInformation
)
694 PSYSTEM_DEVICE_INFORMATION Sdi
695 = (PSYSTEM_DEVICE_INFORMATION
) Buffer
;
696 PCONFIGURATION_INFORMATION ConfigInfo
;
698 *ReqSize
= sizeof (SYSTEM_DEVICE_INFORMATION
);
700 * Check user buffer's size
702 if (Size
< sizeof (SYSTEM_DEVICE_INFORMATION
))
704 return (STATUS_INFO_LENGTH_MISMATCH
);
707 ConfigInfo
= IoGetConfigurationInformation ();
709 Sdi
->NumberOfDisks
= ConfigInfo
->DiskCount
;
710 Sdi
->NumberOfFloppies
= ConfigInfo
->FloppyCount
;
711 Sdi
->NumberOfCdRoms
= ConfigInfo
->CdRomCount
;
712 Sdi
->NumberOfTapes
= ConfigInfo
->TapeCount
;
713 Sdi
->NumberOfSerialPorts
= ConfigInfo
->SerialCount
;
714 Sdi
->NumberOfParallelPorts
= ConfigInfo
->ParallelCount
;
716 return (STATUS_SUCCESS
);
719 /* Class 8 - Processor Performance Information */
720 QSI_DEF(SystemProcessorPerformanceInformation
)
722 PSYSTEM_PROCESSORTIME_INFO Spi
723 = (PSYSTEM_PROCESSORTIME_INFO
) Buffer
;
729 *ReqSize
= KeNumberProcessors
* sizeof (SYSTEM_PROCESSORTIME_INFO
);
731 * Check user buffer's size
733 if (Size
< KeNumberProcessors
* sizeof(SYSTEM_PROCESSORTIME_INFO
))
735 return (STATUS_INFO_LENGTH_MISMATCH
);
738 CurrentTime
.QuadPart
= KeQueryInterruptTime();
739 Pcr
= (PKPCR
)KPCR_BASE
;
740 for (i
= 0; i
< KeNumberProcessors
; i
++)
743 Spi
->TotalProcessorRunTime
.QuadPart
= (Pcr
->PrcbData
.IdleThread
->KernelTime
+ Pcr
->PrcbData
.IdleThread
->UserTime
) * 100000LL; // IdleTime
744 Spi
->TotalProcessorTime
.QuadPart
= Pcr
->PrcbData
.KernelTime
* 100000LL; // KernelTime
745 Spi
->TotalProcessorUserTime
.QuadPart
= Pcr
->PrcbData
.UserTime
* 100000LL;
746 Spi
->TotalDPCTime
.QuadPart
= Pcr
->PrcbData
.DpcTime
* 100000LL;
747 Spi
->TotalInterruptTime
.QuadPart
= Pcr
->PrcbData
.InterruptTime
* 100000LL;
748 Spi
->TotalInterrupts
= Pcr
->PrcbData
.InterruptCount
; // Interrupt Count
751 Pcr
= (PKPCR
)((ULONG_PTR
)Pcr
+ PAGE_SIZE
);
754 return (STATUS_SUCCESS
);
757 /* Class 9 - Flags Information */
758 QSI_DEF(SystemFlagsInformation
)
760 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
762 * ReqSize
= sizeof (SYSTEM_FLAGS_INFORMATION
);
763 return (STATUS_INFO_LENGTH_MISMATCH
);
765 ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
= NtGlobalFlag
;
766 return (STATUS_SUCCESS
);
769 SSI_DEF(SystemFlagsInformation
)
771 if (sizeof (SYSTEM_FLAGS_INFORMATION
) != Size
)
773 return (STATUS_INFO_LENGTH_MISMATCH
);
775 NtGlobalFlag
= ((PSYSTEM_FLAGS_INFORMATION
) Buffer
)->Flags
;
776 return (STATUS_SUCCESS
);
779 /* Class 10 - Call Time Information */
780 QSI_DEF(SystemCallTimeInformation
)
783 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
784 return (STATUS_NOT_IMPLEMENTED
);
787 /* Class 11 - Module Information */
788 QSI_DEF(SystemModuleInformation
)
790 return LdrpQueryModuleInformation(Buffer
, Size
, ReqSize
);
793 /* Class 12 - Locks Information */
794 QSI_DEF(SystemLocksInformation
)
797 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
798 return (STATUS_NOT_IMPLEMENTED
);
801 /* Class 13 - Stack Trace Information */
802 QSI_DEF(SystemStackTraceInformation
)
805 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
806 return (STATUS_NOT_IMPLEMENTED
);
809 /* Class 14 - Paged Pool Information */
810 QSI_DEF(SystemPagedPoolInformation
)
813 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
814 return (STATUS_NOT_IMPLEMENTED
);
817 /* Class 15 - Non Paged Pool Information */
818 QSI_DEF(SystemNonPagedPoolInformation
)
821 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
822 return (STATUS_NOT_IMPLEMENTED
);
825 /* Class 16 - Handle Information */
826 QSI_DEF(SystemHandleInformation
)
829 DPRINT1("NtQuerySystemInformation - SystemHandleInformation not implemented\n");
830 return (STATUS_NOT_IMPLEMENTED
);
833 /* Class 17 - Information */
834 QSI_DEF(SystemObjectInformation
)
837 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
838 return (STATUS_NOT_IMPLEMENTED
);
841 /* Class 18 - Information */
842 QSI_DEF(SystemPageFileInformation
)
844 SYSTEM_PAGEFILE_INFORMATION
*Spfi
= (SYSTEM_PAGEFILE_INFORMATION
*) Buffer
;
846 if (Size
< sizeof (SYSTEM_PAGEFILE_INFORMATION
))
848 * ReqSize
= sizeof (SYSTEM_PAGEFILE_INFORMATION
);
849 return (STATUS_INFO_LENGTH_MISMATCH
);
852 UNICODE_STRING FileName
; /* FIXME */
855 Spfi
->NextEntryOffset
= 0;
857 Spfi
->TotalSize
= MiFreeSwapPages
+ MiUsedSwapPages
;
858 Spfi
->TotalInUse
= MiUsedSwapPages
;
859 Spfi
->PeakUsage
= MiUsedSwapPages
; /* FIXME */
860 Spfi
->PageFileName
= FileName
;
861 return (STATUS_SUCCESS
);
864 /* Class 19 - Vdm Instemul Information */
865 QSI_DEF(SystemVdmInstemulInformation
)
868 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
869 return (STATUS_NOT_IMPLEMENTED
);
872 /* Class 20 - Vdm Bop Information */
873 QSI_DEF(SystemVdmBopInformation
)
876 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
877 return (STATUS_NOT_IMPLEMENTED
);
880 /* Class 21 - File Cache Information */
881 QSI_DEF(SystemFileCacheInformation
)
883 SYSTEM_CACHE_INFORMATION
*Sci
= (SYSTEM_CACHE_INFORMATION
*) Buffer
;
885 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
887 * ReqSize
= sizeof (SYSTEM_CACHE_INFORMATION
);
888 return (STATUS_INFO_LENGTH_MISMATCH
);
890 /* Return the Byte size not the page size. */
892 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
;
894 MiMemoryConsumers
[MC_CACHE
].PagesUsed
* PAGE_SIZE
; /* FIXME */
896 Sci
->PageFaultCount
= 0; /* FIXME */
897 Sci
->MinimumWorkingSet
= 0; /* FIXME */
898 Sci
->MaximumWorkingSet
= 0; /* FIXME */
899 Sci
->TransitionSharedPages
= 0; /* FIXME */
900 Sci
->TransitionSharedPagesPeak
= 0; /* FIXME */
902 return (STATUS_SUCCESS
);
905 SSI_DEF(SystemFileCacheInformation
)
907 if (Size
< sizeof (SYSTEM_CACHE_INFORMATION
))
909 return (STATUS_INFO_LENGTH_MISMATCH
);
912 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
913 return (STATUS_NOT_IMPLEMENTED
);
916 /* Class 22 - Pool Tag Information */
917 QSI_DEF(SystemPoolTagInformation
)
920 DPRINT1("NtQuerySystemInformation - SystemPoolTagInformation not implemented\n");
921 return (STATUS_NOT_IMPLEMENTED
);
924 /* Class 23 - Interrupt Information */
925 QSI_DEF(SystemInterruptInformation
)
928 DPRINT1("NtQuerySystemInformation - SystemInterruptInformation not implemented\n");
929 return (STATUS_NOT_IMPLEMENTED
);
932 /* Class 24 - DPC Behaviour Information */
933 QSI_DEF(SystemDpcBehaviourInformation
)
936 DPRINT1("NtQuerySystemInformation - SystemDpcBehaviourInformation not implemented\n");
937 return (STATUS_NOT_IMPLEMENTED
);
940 SSI_DEF(SystemDpcBehaviourInformation
)
943 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
944 return (STATUS_NOT_IMPLEMENTED
);
947 /* Class 25 - Full Memory Information */
948 QSI_DEF(SystemFullMemoryInformation
)
950 PULONG Spi
= (PULONG
) Buffer
;
952 PEPROCESS TheIdleProcess
;
954 * ReqSize
= sizeof (ULONG
);
956 if (sizeof (ULONG
) != Size
)
958 return (STATUS_INFO_LENGTH_MISMATCH
);
960 DPRINT("SystemFullMemoryInformation\n");
962 PsLookupProcessByProcessId((PVOID
) 1, &TheIdleProcess
);
964 DPRINT("PID: %d, KernelTime: %u PFFree: %d PFUsed: %d\n",
965 TheIdleProcess
->UniqueProcessId
,
966 TheIdleProcess
->Pcb
.KernelTime
,
971 MmPrintMemoryStatistic();
974 *Spi
= MiMemoryConsumers
[MC_USER
].PagesUsed
;
976 ObDereferenceObject(TheIdleProcess
);
978 return (STATUS_SUCCESS
);
981 /* Class 26 - Load Image */
982 SSI_DEF(SystemLoadImage
)
984 PSYSTEM_LOAD_IMAGE Sli
= (PSYSTEM_LOAD_IMAGE
)Buffer
;
986 if (sizeof(SYSTEM_LOAD_IMAGE
) != Size
)
988 return(STATUS_INFO_LENGTH_MISMATCH
);
991 return(LdrpLoadImage(&Sli
->ModuleName
,
993 &Sli
->SectionPointer
,
995 &Sli
->ExportDirectory
));
998 /* Class 27 - Unload Image */
999 SSI_DEF(SystemUnloadImage
)
1001 PSYSTEM_UNLOAD_IMAGE Sui
= (PSYSTEM_UNLOAD_IMAGE
)Buffer
;
1003 if (sizeof(SYSTEM_UNLOAD_IMAGE
) != Size
)
1005 return(STATUS_INFO_LENGTH_MISMATCH
);
1008 return(LdrpUnloadImage(Sui
->ModuleBase
));
1011 /* Class 28 - Time Adjustment Information */
1012 QSI_DEF(SystemTimeAdjustmentInformation
)
1014 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1016 * ReqSize
= sizeof (SYSTEM_SET_TIME_ADJUSTMENT
);
1017 return (STATUS_INFO_LENGTH_MISMATCH
);
1020 DPRINT1("NtQuerySystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1021 return (STATUS_NOT_IMPLEMENTED
);
1024 SSI_DEF(SystemTimeAdjustmentInformation
)
1026 if (sizeof (SYSTEM_SET_TIME_ADJUSTMENT
) > Size
)
1028 return (STATUS_INFO_LENGTH_MISMATCH
);
1031 DPRINT1("NtSetSystemInformation - SystemTimeAdjustmentInformation not implemented\n");
1032 return (STATUS_NOT_IMPLEMENTED
);
1035 /* Class 29 - Summary Memory Information */
1036 QSI_DEF(SystemSummaryMemoryInformation
)
1039 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1040 return (STATUS_NOT_IMPLEMENTED
);
1043 /* Class 30 - Next Event Id Information */
1044 QSI_DEF(SystemNextEventIdInformation
)
1047 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1048 return (STATUS_NOT_IMPLEMENTED
);
1051 /* Class 31 - Event Ids Information */
1052 QSI_DEF(SystemEventIdsInformation
)
1055 DPRINT1("NtQuerySystemInformation - SystemEventIdsInformation not implemented\n");
1056 return (STATUS_NOT_IMPLEMENTED
);
1059 /* Class 32 - Crash Dump Information */
1060 QSI_DEF(SystemCrashDumpInformation
)
1063 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1064 return (STATUS_NOT_IMPLEMENTED
);
1067 /* Class 33 - Exception Information */
1068 QSI_DEF(SystemExceptionInformation
)
1071 DPRINT1("NtQuerySystemInformation - SystemExceptionInformation not implemented\n");
1072 return (STATUS_NOT_IMPLEMENTED
);
1075 /* Class 34 - Crash Dump State Information */
1076 QSI_DEF(SystemCrashDumpStateInformation
)
1079 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1080 return (STATUS_NOT_IMPLEMENTED
);
1083 /* Class 35 - Kernel Debugger Information */
1084 QSI_DEF(SystemKernelDebuggerInformation
)
1087 DPRINT1("NtQuerySystemInformation - SystemKernelDebuggerInformation not implemented\n");
1088 return (STATUS_NOT_IMPLEMENTED
);
1091 /* Class 36 - Context Switch Information */
1092 QSI_DEF(SystemContextSwitchInformation
)
1095 DPRINT1("NtQuerySystemInformation - SystemContextSwitchInformation not implemented\n");
1096 return (STATUS_NOT_IMPLEMENTED
);
1099 /* Class 37 - Registry Quota Information */
1100 QSI_DEF(SystemRegistryQuotaInformation
)
1102 PSYSTEM_REGISTRY_QUOTA_INFORMATION srqi
= (PSYSTEM_REGISTRY_QUOTA_INFORMATION
) Buffer
;
1104 *ReqSize
= sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
);
1105 if (Size
< sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION
))
1107 return STATUS_INFO_LENGTH_MISMATCH
;
1110 DPRINT1("Faking max registry size of 32 MB\n");
1111 srqi
->RegistryQuotaAllowed
= 0x2000000;
1112 srqi
->RegistryQuotaUsed
= 0x200000;
1113 srqi
->Reserved1
= (void*)0x200000;
1115 return STATUS_SUCCESS
;
1118 SSI_DEF(SystemRegistryQuotaInformation
)
1121 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1122 return (STATUS_NOT_IMPLEMENTED
);
1125 /* Class 38 - Load And Call Image */
1126 SSI_DEF(SystemLoadAndCallImage
)
1128 PSYSTEM_LOAD_AND_CALL_IMAGE Slci
= (PSYSTEM_LOAD_AND_CALL_IMAGE
)Buffer
;
1130 if (sizeof(SYSTEM_LOAD_AND_CALL_IMAGE
) != Size
)
1132 return(STATUS_INFO_LENGTH_MISMATCH
);
1135 return(LdrpLoadAndCallImage(&Slci
->ModuleName
));
1138 /* Class 39 - Priority Separation */
1139 SSI_DEF(SystemPrioritySeperation
)
1142 DPRINT1("NtSetSystemInformation - SystemPrioritySeperation not implemented\n");
1143 return (STATUS_NOT_IMPLEMENTED
);
1146 /* Class 40 - Plug Play Bus Information */
1147 QSI_DEF(SystemPlugPlayBusInformation
)
1150 DPRINT1("NtQuerySystemInformation - SystemPlugPlayBusInformation not implemented\n");
1151 return (STATUS_NOT_IMPLEMENTED
);
1154 /* Class 41 - Dock Information */
1155 QSI_DEF(SystemDockInformation
)
1158 DPRINT1("NtQuerySystemInformation - SystemDockInformation not implemented\n");
1159 return (STATUS_NOT_IMPLEMENTED
);
1162 /* Class 42 - Power Information */
1163 QSI_DEF(SystemPowerInformation
)
1166 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
1167 return (STATUS_NOT_IMPLEMENTED
);
1170 /* Class 43 - Processor Speed Information */
1171 QSI_DEF(SystemProcessorSpeedInformation
)
1174 DPRINT1("NtQuerySystemInformation - SystemProcessorSpeedInformation not implemented\n");
1175 return (STATUS_NOT_IMPLEMENTED
);
1178 /* Class 44 - Current Time Zone Information */
1179 QSI_DEF(SystemCurrentTimeZoneInformation
)
1181 * ReqSize
= sizeof (TIME_ZONE_INFORMATION
);
1183 if (sizeof (TIME_ZONE_INFORMATION
) != Size
)
1185 return STATUS_INFO_LENGTH_MISMATCH
;
1188 /* Copy the time zone information struct */
1191 sizeof(TIME_ZONE_INFORMATION
));
1193 return STATUS_SUCCESS
;
1197 SSI_DEF(SystemCurrentTimeZoneInformation
)
1199 /* Check user buffer's size */
1200 if (Size
< sizeof (TIME_ZONE_INFORMATION
))
1202 return STATUS_INFO_LENGTH_MISMATCH
;
1205 return ExpSetTimeZoneInformation((PTIME_ZONE_INFORMATION
)Buffer
);
1209 /* Class 45 - Lookaside Information */
1210 QSI_DEF(SystemLookasideInformation
)
1213 DPRINT1("NtQuerySystemInformation - SystemLookasideInformation not implemented\n");
1214 return (STATUS_NOT_IMPLEMENTED
);
1218 /* Class 46 - Set time slip event */
1219 SSI_DEF(SystemSetTimeSlipEvent
)
1222 DPRINT1("NtSetSystemInformation - SystemSetTimSlipEvent not implemented\n");
1223 return (STATUS_NOT_IMPLEMENTED
);
1227 /* Class 47 - Create a new session (TSE) */
1228 SSI_DEF(SystemCreateSession
)
1231 DPRINT1("NtSetSystemInformation - SystemCreateSession not implemented\n");
1232 return (STATUS_NOT_IMPLEMENTED
);
1236 /* Class 48 - Delete an existing session (TSE) */
1237 SSI_DEF(SystemDeleteSession
)
1240 DPRINT1("NtSetSystemInformation - SystemDeleteSession not implemented\n");
1241 return (STATUS_NOT_IMPLEMENTED
);
1245 /* Class 49 - UNKNOWN */
1246 QSI_DEF(SystemInvalidInfoClass4
)
1249 DPRINT1("NtQuerySystemInformation - SystemInvalidInfoClass4 not implemented\n");
1250 return (STATUS_NOT_IMPLEMENTED
);
1254 /* Class 50 - System range start address */
1255 QSI_DEF(SystemRangeStartInformation
)
1258 DPRINT1("NtQuerySystemInformation - SystemRangeStartInformation not implemented\n");
1259 return (STATUS_NOT_IMPLEMENTED
);
1263 /* Class 51 - Driver verifier information */
1264 QSI_DEF(SystemVerifierInformation
)
1267 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
1268 return (STATUS_NOT_IMPLEMENTED
);
1272 SSI_DEF(SystemVerifierInformation
)
1275 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
1276 return (STATUS_NOT_IMPLEMENTED
);
1280 /* Class 52 - Add a driver verifier */
1281 SSI_DEF(SystemAddVerifier
)
1284 DPRINT1("NtSetSystemInformation - SystemAddVerifier not implemented\n");
1285 return (STATUS_NOT_IMPLEMENTED
);
1289 /* Class 53 - A session's processes */
1290 QSI_DEF(SystemSessionProcessesInformation
)
1293 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
1294 return (STATUS_NOT_IMPLEMENTED
);
1298 /* Query/Set Calls Table */
1302 NTSTATUS (* Query
) (PVOID
,ULONG
,PULONG
);
1303 NTSTATUS (* Set
) (PVOID
,ULONG
);
1310 // XX unknown behaviour
1312 #define SI_QS(n) {QSI_USE(n),SSI_USE(n)}
1313 #define SI_QX(n) {QSI_USE(n),NULL}
1314 #define SI_XS(n) {NULL,SSI_USE(n)}
1315 #define SI_XX(n) {NULL,NULL}
1321 SI_QX(SystemBasicInformation
),
1322 SI_QX(SystemProcessorInformation
),
1323 SI_QX(SystemPerformanceInformation
),
1324 SI_QX(SystemTimeOfDayInformation
),
1325 SI_QX(SystemPathInformation
), /* should be SI_XX */
1326 SI_QX(SystemProcessInformation
),
1327 SI_QX(SystemCallCountInformation
),
1328 SI_QX(SystemDeviceInformation
),
1329 SI_QX(SystemProcessorPerformanceInformation
),
1330 SI_QS(SystemFlagsInformation
),
1331 SI_QX(SystemCallTimeInformation
), /* should be SI_XX */
1332 SI_QX(SystemModuleInformation
),
1333 SI_QX(SystemLocksInformation
),
1334 SI_QX(SystemStackTraceInformation
), /* should be SI_XX */
1335 SI_QX(SystemPagedPoolInformation
), /* should be SI_XX */
1336 SI_QX(SystemNonPagedPoolInformation
), /* should be SI_XX */
1337 SI_QX(SystemHandleInformation
),
1338 SI_QX(SystemObjectInformation
),
1339 SI_QX(SystemPageFileInformation
),
1340 SI_QX(SystemVdmInstemulInformation
),
1341 SI_QX(SystemVdmBopInformation
), /* it should be SI_XX */
1342 SI_QS(SystemFileCacheInformation
),
1343 SI_QX(SystemPoolTagInformation
),
1344 SI_QX(SystemInterruptInformation
),
1345 SI_QS(SystemDpcBehaviourInformation
),
1346 SI_QX(SystemFullMemoryInformation
), /* it should be SI_XX */
1347 SI_XS(SystemLoadImage
),
1348 SI_XS(SystemUnloadImage
),
1349 SI_QS(SystemTimeAdjustmentInformation
),
1350 SI_QX(SystemSummaryMemoryInformation
), /* it should be SI_XX */
1351 SI_QX(SystemNextEventIdInformation
), /* it should be SI_XX */
1352 SI_QX(SystemEventIdsInformation
), /* it should be SI_XX */
1353 SI_QX(SystemCrashDumpInformation
),
1354 SI_QX(SystemExceptionInformation
),
1355 SI_QX(SystemCrashDumpStateInformation
),
1356 SI_QX(SystemKernelDebuggerInformation
),
1357 SI_QX(SystemContextSwitchInformation
),
1358 SI_QS(SystemRegistryQuotaInformation
),
1359 SI_XS(SystemLoadAndCallImage
),
1360 SI_XS(SystemPrioritySeperation
),
1361 SI_QX(SystemPlugPlayBusInformation
), /* it should be SI_XX */
1362 SI_QX(SystemDockInformation
), /* it should be SI_XX */
1363 SI_QX(SystemPowerInformation
), /* it should be SI_XX */
1364 SI_QX(SystemProcessorSpeedInformation
), /* it should be SI_XX */
1365 SI_QS(SystemCurrentTimeZoneInformation
), /* it should be SI_QX */
1366 SI_QX(SystemLookasideInformation
),
1367 SI_XS(SystemSetTimeSlipEvent
),
1368 SI_XS(SystemCreateSession
),
1369 SI_XS(SystemDeleteSession
),
1370 SI_QX(SystemInvalidInfoClass4
), /* it should be SI_XX */
1371 SI_QX(SystemRangeStartInformation
),
1372 SI_QS(SystemVerifierInformation
),
1373 SI_XS(SystemAddVerifier
),
1374 SI_QX(SystemSessionProcessesInformation
)
1382 NtQuerySystemInformation (IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1383 OUT PVOID UnsafeSystemInformation
,
1385 OUT PULONG UnsafeResultLength
)
1388 PVOID SystemInformation
;
1392 /* DPRINT("NtQuerySystemInformation Start. Class:%d\n",
1393 SystemInformationClass );
1395 /*if (ExGetPreviousMode() == KernelMode)
1397 SystemInformation
= UnsafeSystemInformation
;
1401 SystemInformation = ExAllocatePool(NonPagedPool, Length);
1402 if (SystemInformation == NULL)
1404 return(STATUS_NO_MEMORY);
1408 /* Clear user buffer. */
1409 RtlZeroMemory(SystemInformation
, Length
);
1412 * Check the request is valid.
1414 if ((SystemInformationClass
>= SystemInformationClassMin
) &&
1415 (SystemInformationClass
< SystemInformationClassMax
))
1417 if (NULL
!= CallQS
[SystemInformationClass
].Query
)
1420 * Hand the request to a subhandler.
1422 FStatus
= CallQS
[SystemInformationClass
].Query(SystemInformation
,
1425 /*if (ExGetPreviousMode() != KernelMode)
1427 Status = MmCopyToCaller(UnsafeSystemInformation,
1430 ExFreePool(SystemInformation);
1431 if (!NT_SUCCESS(Status))
1436 if (UnsafeResultLength
!= NULL
)
1438 /*if (ExGetPreviousMode() == KernelMode)
1440 *UnsafeResultLength = ResultLength;
1444 Status
= MmCopyToCaller(UnsafeResultLength
,
1447 if (!NT_SUCCESS(Status
))
1456 return (STATUS_INVALID_INFO_CLASS
);
1462 NtSetSystemInformation (
1463 IN SYSTEM_INFORMATION_CLASS SystemInformationClass
,
1464 IN PVOID SystemInformation
,
1465 IN ULONG SystemInformationLength
1469 * If called from user mode, check
1470 * possible unsafe arguments.
1473 if (KernelMode
!= KeGetPreviousMode())
1477 // SystemInformation,
1487 * Check the request is valid.
1489 if ( (SystemInformationClass
>= SystemInformationClassMin
)
1490 && (SystemInformationClass
< SystemInformationClassMax
)
1493 if (NULL
!= CallQS
[SystemInformationClass
].Set
)
1496 * Hand the request to a subhandler.
1498 return CallQS
[SystemInformationClass
].Set (
1500 SystemInformationLength
1504 return (STATUS_INVALID_INFO_CLASS
);
1510 NtFlushInstructionCache (
1511 IN HANDLE ProcessHandle
,
1512 IN PVOID BaseAddress
,
1513 IN UINT NumberOfBytesToFlush
1517 return(STATUS_NOT_IMPLEMENTED
);