ReactOS 0.4.16-dev-340-g0540c21
sysinfo.c File Reference
#include <ntoskrnl.h>
#include <wmidata.h>
#include <wmistr.h>
#include <debug.h>
Include dependency graph for sysinfo.c:

Go to the source code of this file.

Classes

struct  _QSSI_CALLS
 

Macros

#define NDEBUG
 
#define MAX_ENVVAL_SIZE   1024
 
#define SIG_ACPI   0x41435049
 
#define SIG_FIRM   0x4649524D
 
#define SIG_RSMB   0x52534D42
 
#define QSI_USE(n)   QSI##n
 
#define QSI_DEF(n)   static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)
 
#define SSI_USE(n)   SSI##n
 
#define SSI_DEF(n)   static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)
 
#define SI_QS(n)   {QSI_USE(n),SSI_USE(n)}
 
#define SI_QX(n)   {QSI_USE(n),NULL}
 
#define SI_XS(n)   {NULL,SSI_USE(n)}
 
#define SI_XX(n)   {NULL,NULL}
 
#define MIN_SYSTEM_INFO_CLASS   (SystemBasicInformation)
 
#define MAX_SYSTEM_INFO_CLASS   RTL_NUMBER_OF(CallQS)
 

Typedefs

typedef struct _QSSI_CALLS QSSI_CALLS
 

Functions

FORCEINLINE NTSTATUS ExpConvertLdrModuleToRtlModule (IN ULONG ModuleCount, IN PLDR_DATA_TABLE_ENTRY LdrEntry, OUT PRTL_PROCESS_MODULE_INFORMATION ModuleInfo)
 
NTSTATUS NTAPI ExpQueryModuleInformation (IN PLIST_ENTRY KernelModeList, IN PLIST_ENTRY UserModeList, OUT PRTL_PROCESS_MODULES Modules, IN ULONG Length, OUT PULONG ReturnLength)
 
VOID NTAPI ExUnlockUserBuffer (PMDL Mdl)
 
NTSTATUS NTAPI ExLockUserBuffer (PVOID BaseAddress, ULONG Length, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation, PVOID *MappedSystemVa, PMDL *OutMdl)
 
NTSTATUS NTAPI ExpGetRawSMBiosTable (_Out_opt_ PVOID Buffer, _Out_ ULONG *OutSize, _In_ ULONG BufferSize)
 
VOID NTAPI ExGetCurrentProcessorCpuUsage (PULONG CpuUsage)
 
VOID NTAPI ExGetCurrentProcessorCounts (PULONG IdleTime, PULONG KernelAndUserTime, PULONG ProcessorNumber)
 
BOOLEAN NTAPI ExIsProcessorFeaturePresent (IN ULONG ProcessorFeature)
 
BOOLEAN NTAPI ExVerifySuite (SUITE_TYPE SuiteType)
 
NTSTATUS NTAPI NtQuerySystemEnvironmentValue (IN PUNICODE_STRING VariableName, OUT PWSTR ValueBuffer, IN ULONG ValueBufferLength, IN OUT PULONG ReturnLength OPTIONAL)
 
NTSTATUS NTAPI NtSetSystemEnvironmentValue (IN PUNICODE_STRING VariableName, IN PUNICODE_STRING Value)
 
NTSTATUS NTAPI NtEnumerateSystemEnvironmentValuesEx (IN ULONG InformationClass, IN PVOID Buffer, IN ULONG BufferLength)
 
NTSTATUS NTAPI NtQuerySystemEnvironmentValueEx (_In_ PUNICODE_STRING VariableName, _In_ LPGUID VendorGuid, _Out_opt_ PVOID Value, _Inout_ PULONG ReturnLength, _Out_opt_ PULONG Attributes)
 
NTSTATUS NTAPI NtSetSystemEnvironmentValueEx (_In_ PUNICODE_STRING VariableName, _In_ LPGUID VendorGuid, _In_reads_bytes_opt_(ValueLength) PVOID Value, _In_ ULONG ValueLength, _In_ ULONG Attributes)
 
VOID NTAPI ExQueryPoolUsage (OUT PULONG PagedPoolPages, OUT PULONG NonPagedPoolPages, OUT PULONG PagedPoolAllocs, OUT PULONG PagedPoolFrees, OUT PULONG PagedPoolLookasideHits, OUT PULONG NonPagedPoolAllocs, OUT PULONG NonPagedPoolFrees, OUT PULONG NonPagedPoolLookasideHits)
 
 QSI_DEF (SystemBasicInformation)
 
 QSI_DEF (SystemProcessorInformation)
 
 QSI_DEF (SystemPerformanceInformation)
 
 QSI_DEF (SystemTimeOfDayInformation)
 
 QSI_DEF (SystemPathInformation)
 
 QSI_DEF (SystemProcessInformation)
 
 QSI_DEF (SystemCallCountInformation)
 
 QSI_DEF (SystemDeviceInformation)
 
 QSI_DEF (SystemProcessorPerformanceInformation)
 
 QSI_DEF (SystemFlagsInformation)
 
 SSI_DEF (SystemFlagsInformation)
 
 QSI_DEF (SystemCallTimeInformation)
 
 QSI_DEF (SystemModuleInformation)
 
 QSI_DEF (SystemLocksInformation)
 
 QSI_DEF (SystemStackTraceInformation)
 
 QSI_DEF (SystemPagedPoolInformation)
 
 QSI_DEF (SystemNonPagedPoolInformation)
 
 QSI_DEF (SystemHandleInformation)
 
 QSI_DEF (SystemObjectInformation)
 
 QSI_DEF (SystemPageFileInformation)
 
 QSI_DEF (SystemVdmInstemulInformation)
 
 QSI_DEF (SystemVdmBopInformation)
 
 QSI_DEF (SystemFileCacheInformation)
 
 SSI_DEF (SystemFileCacheInformation)
 
 QSI_DEF (SystemPoolTagInformation)
 
 QSI_DEF (SystemInterruptInformation)
 
 QSI_DEF (SystemDpcBehaviourInformation)
 
 SSI_DEF (SystemDpcBehaviourInformation)
 
 QSI_DEF (SystemFullMemoryInformation)
 
 SSI_DEF (SystemLoadGdiDriverInformation)
 
 SSI_DEF (SystemUnloadGdiDriverInformation)
 
 QSI_DEF (SystemTimeAdjustmentInformation)
 
 SSI_DEF (SystemTimeAdjustmentInformation)
 
 QSI_DEF (SystemSummaryMemoryInformation)
 
 QSI_DEF (SystemNextEventIdInformation)
 
 QSI_DEF (SystemPerformanceTraceInformation)
 
 QSI_DEF (SystemCrashDumpInformation)
 
 QSI_DEF (SystemExceptionInformation)
 
 QSI_DEF (SystemCrashDumpStateInformation)
 
 QSI_DEF (SystemKernelDebuggerInformation)
 
 QSI_DEF (SystemContextSwitchInformation)
 
 QSI_DEF (SystemRegistryQuotaInformation)
 
 SSI_DEF (SystemRegistryQuotaInformation)
 
 SSI_DEF (SystemExtendServiceTableInformation)
 
 SSI_DEF (SystemPrioritySeperation)
 
 QSI_DEF (SystemVerifierAddDriverInformation)
 
 QSI_DEF (SystemVerifierRemoveDriverInformation)
 
 QSI_DEF (SystemProcessorIdleInformation)
 
 QSI_DEF (SystemLegacyDriverInformation)
 
 QSI_DEF (SystemCurrentTimeZoneInformation)
 
 SSI_DEF (SystemCurrentTimeZoneInformation)
 
static VOID ExpCopyLookasideInformation (PSYSTEM_LOOKASIDE_INFORMATION *InfoPointer, PULONG RemainingPointer, PLIST_ENTRY ListHead, BOOLEAN ListUsesMisses)
 
 QSI_DEF (SystemLookasideInformation)
 
 SSI_DEF (SystemTimeSlipNotification)
 
NTSTATUS NTAPI MmSessionCreate (OUT PULONG SessionId)
 
NTSTATUS NTAPI MmSessionDelete (IN ULONG SessionId)
 
 SSI_DEF (SystemSessionCreate)
 
 SSI_DEF (SystemSessionDetach)
 
 QSI_DEF (SystemSessionInformation)
 
 QSI_DEF (SystemRangeStartInformation)
 
 QSI_DEF (SystemVerifierInformation)
 
 SSI_DEF (SystemVerifierInformation)
 
 SSI_DEF (SystemVerifierThunkExtend)
 
 QSI_DEF (SystemSessionProcessesInformation)
 
 SSI_DEF (SystemLoadGdiDriverInSystemSpaceInformation)
 
 QSI_DEF (SystemNumaProcessorMap)
 
 QSI_DEF (SystemPrefetcherInformation)
 
 QSI_DEF (SystemExtendedProcessInformation)
 
 QSI_DEF (SystemRecommendedSharedDataAlignment)
 
 QSI_DEF (SystemNumaAvailableMemory)
 
 QSI_DEF (SystemExtendedHandleInformation)
 
 QSI_DEF (SystemObjectSecurityMode)
 
 QSI_DEF (SystemLogicalProcessorInformation)
 
 QSI_DEF (SystemFirmwareTableInformation)
 
 C_ASSERT (SystemBasicInformation==0)
 
__kernel_entry NTSTATUS NTAPI NtQuerySystemInformation (_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID SystemInformation, _In_ ULONG SystemInformationLength, _Out_opt_ PULONG ReturnLength)
 
__kernel_entry NTSTATUS NTAPI NtSetSystemInformation (_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _In_reads_bytes_(SystemInformationLength) PVOID SystemInformation, _In_ ULONG SystemInformationLength)
 
ULONG NTAPI NtGetCurrentProcessorNumber (VOID)
 
KPROCESSOR_MODE NTAPI ExGetPreviousMode (VOID)
 

Variables

LIST_ENTRY HandleTableListHead
 
EX_PUSH_LOCK HandleTableListLock
 
FAST_MUTEX ExpEnvironmentLock
 
ERESOURCE ExpFirmwareTableResource
 
LIST_ENTRY ExpFirmwareTableProviderListHead
 
static QSSI_CALLS CallQS []
 

Macro Definition Documentation

◆ MAX_ENVVAL_SIZE

#define MAX_ENVVAL_SIZE   1024

Definition at line 20 of file sysinfo.c.

◆ MAX_SYSTEM_INFO_CLASS

#define MAX_SYSTEM_INFO_CLASS   RTL_NUMBER_OF(CallQS)

Definition at line 2923 of file sysinfo.c.

◆ MIN_SYSTEM_INFO_CLASS

#define MIN_SYSTEM_INFO_CLASS   (SystemBasicInformation)

Definition at line 2922 of file sysinfo.c.

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file sysinfo.c.

◆ QSI_DEF

#define QSI_DEF (   n)    static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize)

Definition at line 598 of file sysinfo.c.

◆ QSI_USE

#define QSI_USE (   n)    QSI##n

Definition at line 597 of file sysinfo.c.

◆ SI_QS

#define SI_QS (   n)    {QSI_USE(n),SSI_USE(n)}

Definition at line 2833 of file sysinfo.c.

◆ SI_QX

#define SI_QX (   n)    {QSI_USE(n),NULL}

Definition at line 2834 of file sysinfo.c.

◆ SI_XS

#define SI_XS (   n)    {NULL,SSI_USE(n)}

Definition at line 2835 of file sysinfo.c.

◆ SI_XX

#define SI_XX (   n)    {NULL,NULL}

Definition at line 2836 of file sysinfo.c.

◆ SIG_ACPI

#define SIG_ACPI   0x41435049

Definition at line 22 of file sysinfo.c.

◆ SIG_FIRM

#define SIG_FIRM   0x4649524D

Definition at line 23 of file sysinfo.c.

◆ SIG_RSMB

#define SIG_RSMB   0x52534D42

Definition at line 24 of file sysinfo.c.

◆ SSI_DEF

#define SSI_DEF (   n)    static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size)

Definition at line 602 of file sysinfo.c.

◆ SSI_USE

#define SSI_USE (   n)    SSI##n

Definition at line 601 of file sysinfo.c.

Typedef Documentation

◆ QSSI_CALLS

Function Documentation

◆ C_ASSERT()

C_ASSERT ( SystemBasicInformation  = =0)

◆ ExGetCurrentProcessorCounts()

VOID NTAPI ExGetCurrentProcessorCounts ( PULONG  IdleTime,
PULONG  KernelAndUserTime,
PULONG  ProcessorNumber 
)

Definition at line 345 of file sysinfo.c.

348{
349 PKPRCB Prcb;
350
351 Prcb = KeGetCurrentPrcb();
352
353 *IdleTime = Prcb->IdleThread->KernelTime;
354 *KernelAndUserTime = Prcb->KernelTime + Prcb->UserTime;
355 *ProcessorNumber = (ULONG)Prcb->Number;
356}
FORCEINLINE struct _KPRCB * KeGetCurrentPrcb(VOID)
Definition: ketypes.h:1150
struct _KTHREAD * IdleThread
Definition: ketypes.h:641
ULONG UserTime
Definition: ketypes.h:807
USHORT Number
Definition: ketypes.h:632
ULONG KernelTime
Definition: ketypes.h:806
uint32_t ULONG
Definition: typedefs.h:59

Referenced by NdisGetCurrentProcessorCounts().

◆ ExGetCurrentProcessorCpuUsage()

VOID NTAPI ExGetCurrentProcessorCpuUsage ( PULONG  CpuUsage)

Definition at line 324 of file sysinfo.c.

325{
326 PKPRCB Prcb;
327 ULONG TotalTime;
328 ULONGLONG ScaledIdle;
329
330 Prcb = KeGetCurrentPrcb();
331
332 ScaledIdle = (ULONGLONG)Prcb->IdleThread->KernelTime * 100;
333 TotalTime = Prcb->KernelTime + Prcb->UserTime;
334 if (TotalTime != 0)
335 *CpuUsage = (ULONG)(100 - (ScaledIdle / TotalTime));
336 else
337 *CpuUsage = 0;
338}
if(dx< 0)
Definition: linetemp.h:194
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by NdisGetCurrentProcessorCpuUsage().

◆ ExGetPreviousMode()

KPROCESSOR_MODE NTAPI ExGetPreviousMode ( VOID  )

Definition at line 3064 of file sysinfo.c.

3065{
3066 /* Just use Ke */
3067 return KeGetPreviousMode();
3068}
#define KeGetPreviousMode()
Definition: ketypes.h:1115

◆ ExIsProcessorFeaturePresent()

BOOLEAN NTAPI ExIsProcessorFeaturePresent ( IN ULONG  ProcessorFeature)

Definition at line 363 of file sysinfo.c.

364{
365 /* Quick check to see if it exists at all */
366 if (ProcessorFeature >= PROCESSOR_FEATURE_MAX) return(FALSE);
367
368 /* Return our support for it */
369 return(SharedUserData->ProcessorFeatures[ProcessorFeature]);
370}
#define FALSE
Definition: types.h:117
#define SharedUserData
#define PROCESSOR_FEATURE_MAX

Referenced by KsecReadMachineSpecificCounters(), PciApplyHacks(), PciQueryRequirements(), and START_TEST().

◆ ExLockUserBuffer()

NTSTATUS NTAPI ExLockUserBuffer ( PVOID  BaseAddress,
ULONG  Length,
KPROCESSOR_MODE  AccessMode,
LOCK_OPERATION  Operation,
PVOID MappedSystemVa,
PMDL OutMdl 
)

Definition at line 202 of file sysinfo.c.

209{
210 PMDL Mdl;
211 PAGED_CODE();
212
213 *MappedSystemVa = NULL;
214 *OutMdl = NULL;
215
216 /* Allocate an MDL for the buffer */
218 if (Mdl == NULL)
219 {
221 }
222
223 /* Enter SEH for probing */
225 {
227 }
229 {
232 }
233 _SEH2_END;
234
235 /* Return the safe kernel mode buffer */
237 if (*MappedSystemVa == NULL)
238 {
241 }
242
243 /* Return the MDL */
244 *OutMdl = Mdl;
245 return STATUS_SUCCESS;
246}
#define PAGED_CODE()
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
FP_OP Operation
Definition: fpcontrol.c:150
#define IoAllocateMdl
Definition: fxmdl.h:88
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:931
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
@ NormalPagePriority
Definition: imports.h:54
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
VOID NTAPI ExUnlockUserBuffer(PMDL Mdl)
Definition: sysinfo.c:194
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TAG_MDL
Definition: tag.h:89
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define MmGetSystemAddressForMdlSafe(_Mdl, _Priority)
_In_ PEPROCESS _In_ KPROCESSOR_MODE AccessMode
Definition: mmfuncs.h:396

Referenced by QSI_DEF().

◆ ExpConvertLdrModuleToRtlModule()

FORCEINLINE NTSTATUS ExpConvertLdrModuleToRtlModule ( IN ULONG  ModuleCount,
IN PLDR_DATA_TABLE_ENTRY  LdrEntry,
OUT PRTL_PROCESS_MODULE_INFORMATION  ModuleInfo 
)

Definition at line 35 of file sysinfo.c.

38{
39 PCHAR p;
42
43 /* Fill it out */
44 ModuleInfo->MappedBase = NULL;
45 ModuleInfo->ImageBase = LdrEntry->DllBase;
46 ModuleInfo->ImageSize = LdrEntry->SizeOfImage;
47 ModuleInfo->Flags = LdrEntry->Flags;
48 ModuleInfo->LoadCount = LdrEntry->LoadCount;
49 ModuleInfo->LoadOrderIndex = (USHORT)ModuleCount;
50 ModuleInfo->InitOrderIndex = 0;
51
52 /* Setup name */
53 RtlInitEmptyAnsiString(&ModuleName,
55 sizeof(ModuleInfo->FullPathName));
56
57 /* Convert it */
59 &LdrEntry->FullDllName,
60 FALSE);
62 {
63 /* Calculate offset to name */
64 p = ModuleName.Buffer + ModuleName.Length;
65 while ((p > ModuleName.Buffer) && (*--p))
66 {
67 /* Check if we found the separator */
69 {
70 /* We did, break out */
71 p++;
72 break;
73 }
74 }
75
76 /* Set the offset */
77 ModuleInfo->OffsetToFileName = (USHORT)(p - ModuleName.Buffer);
78 }
79 else
80 {
81 /* Return empty name */
83 ModuleInfo->OffsetToFileName = 0;
84 }
85
86 return Status;
87}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1280
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
_In_ ULONG _Out_writes_bytes_opt_ InformationLength PAUX_MODULE_EXTENDED_INFO ModuleInfo
Definition: aux_klib.h:65
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat p
Definition: glext.h:8902
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define ANSI_NULL
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
CHAR FullPathName[AUX_KLIB_MODULE_PATH_LEN]
Definition: aux_klib.h:41
ACPI_SIZE Length
Definition: actypes.h:1053
char * PCHAR
Definition: typedefs.h:51

Referenced by ExpQueryModuleInformation().

◆ ExpCopyLookasideInformation()

static VOID ExpCopyLookasideInformation ( PSYSTEM_LOOKASIDE_INFORMATION InfoPointer,
PULONG  RemainingPointer,
PLIST_ENTRY  ListHead,
BOOLEAN  ListUsesMisses 
)
static

Definition at line 2098 of file sysinfo.c.

2104{
2107 PLIST_ENTRY ListEntry;
2108 ULONG Remaining;
2109
2110 /* Get info pointer and remaining count of free array element */
2111 Info = *InfoPointer;
2112 Remaining = *RemainingPointer;
2113
2114 /* Loop as long as we have lookaside lists and free array elements */
2115 for (ListEntry = ListHead->Flink;
2116 (ListEntry != ListHead) && (Remaining > 0);
2117 ListEntry = ListEntry->Flink, Remaining--)
2118 {
2119 LookasideList = CONTAINING_RECORD(ListEntry, GENERAL_LOOKASIDE, ListEntry);
2120
2121 /* Fill the next array element */
2122 Info->CurrentDepth = LookasideList->Depth;
2123 Info->MaximumDepth = LookasideList->MaximumDepth;
2124 Info->TotalAllocates = LookasideList->TotalAllocates;
2125 Info->TotalFrees = LookasideList->TotalFrees;
2126 Info->Type = LookasideList->Type;
2127 Info->Tag = LookasideList->Tag;
2128 Info->Size = LookasideList->Size;
2129
2130 /* Check how the lists track misses/hits */
2131 if (ListUsesMisses)
2132 {
2133 /* Copy misses */
2134 Info->AllocateMisses = LookasideList->AllocateMisses;
2135 Info->FreeMisses = LookasideList->FreeMisses;
2136 }
2137 else
2138 {
2139 /* Calculate misses */
2140 Info->AllocateMisses = LookasideList->TotalAllocates
2141 - LookasideList->AllocateHits;
2142 Info->FreeMisses = LookasideList->TotalFrees
2143 - LookasideList->FreeHits;
2144 }
2145 }
2146
2147 /* Return the updated pointer and remaining count */
2148 *InfoPointer = Info;
2149 *RemainingPointer = Remaining;
2150}
_Must_inspect_result_ _In_ LPCGUID _In_ ULONG _In_ FSRTL_ALLOCATE_ECP_FLAGS _In_opt_ PFSRTL_EXTRA_CREATE_PARAMETER_CLEANUP_CALLBACK _Inout_ PVOID LookasideList
Definition: fltkernel.h:2554
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE GENERAL_LOOKASIDE
struct LOOKASIDE_ALIGN _GENERAL_LOOKASIDE * PGENERAL_LOOKASIDE

Referenced by QSI_DEF().

◆ ExpGetRawSMBiosTable()

NTSTATUS NTAPI ExpGetRawSMBiosTable ( _Out_opt_ PVOID  Buffer,
_Out_ ULONG OutSize,
_In_ ULONG  BufferSize 
)

Definition at line 250 of file sysinfo.c.

254{
256 PVOID DataBlockObject;
257 PWNODE_ALL_DATA AllData;
258 ULONG WMIBufSize;
259
260 ASSERT(OutSize != NULL);
261 *OutSize = 0;
262
263 /* Open the data block object for the SMBIOS table */
266 &DataBlockObject);
267 if (!NT_SUCCESS(Status))
268 {
269 DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
270 return Status;
271 }
272
273 /* Query the required buffer size */
274 WMIBufSize = 0;
275 Status = IoWMIQueryAllData(DataBlockObject, &WMIBufSize, NULL);
276 if (!NT_SUCCESS(Status))
277 {
278 DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
279 return Status;
280 }
281
282 AllData = ExAllocatePoolWithTag(PagedPool, WMIBufSize, 'itfS');
283 if (AllData == NULL)
284 {
285 DPRINT1("Failed to allocate %lu bytes for SMBIOS tables\n", WMIBufSize);
287 }
288
289 /* Query the buffer data */
290 Status = IoWMIQueryAllData(DataBlockObject, &WMIBufSize, AllData);
291 if (!NT_SUCCESS(Status))
292 {
293 DPRINT1("IoWMIOpenBlock failed: 0x%08lx\n", Status);
294 ExFreePoolWithTag(AllData, 'itfS');
295 return Status;
296 }
297
299 *OutSize = AllData->FixedInstanceSize;
300 if (Buffer != NULL)
301 {
302 if (BufferSize >= *OutSize)
303 {
304 RtlMoveMemory(Buffer, AllData + 1, *OutSize);
305 }
306 else
307 {
309 }
310 }
311
312 /* Free the buffer */
313 ExFreePoolWithTag(AllData, 'itfS');
314 return Status;
315}
#define DPRINT1
Definition: precomp.h:8
Definition: bufpool.h:45
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
const GUID MSSmBios_RawSMBiosTables_GUID
Definition: hwhacks.c:20
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS NTAPI IoWMIOpenBlock(_In_ LPCGUID DataBlockGuid, _In_ ULONG DesiredAccess, _Out_ PVOID *DataBlockObject)
Definition: wmi.c:140
NTSTATUS NTAPI IoWMIQueryAllData(IN PVOID DataBlockObject, IN OUT ULONG *InOutBufferSize, OUT PVOID OutBuffer)
Definition: wmi.c:169
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
ULONG FixedInstanceSize
Definition: wmistr.h:118
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
#define WMIGUID_QUERY
Definition: wmistr.h:159

Referenced by QSI_DEF().

◆ ExpQueryModuleInformation()

NTSTATUS NTAPI ExpQueryModuleInformation ( IN PLIST_ENTRY  KernelModeList,
IN PLIST_ENTRY  UserModeList,
OUT PRTL_PROCESS_MODULES  Modules,
IN ULONG  Length,
OUT PULONG  ReturnLength 
)

Definition at line 91 of file sysinfo.c.

96{
100 PLDR_DATA_TABLE_ENTRY LdrEntry;
101 ULONG ModuleCount = 0;
102 PLIST_ENTRY NextEntry;
103
104 /* Setup defaults */
106 ModuleInfo = &Modules->Modules[0];
107
108 /* Loop the kernel list */
109 NextEntry = KernelModeList->Flink;
110 while (NextEntry != KernelModeList)
111 {
112 /* Get the entry */
113 LdrEntry = CONTAINING_RECORD(NextEntry,
115 InLoadOrderLinks);
116
117 /* Update size and check if we can manage one more entry */
119 if (Length >= RequiredLength)
120 {
122 LdrEntry,
123 ModuleInfo);
124
125 /* Go to the next module */
126 ModuleInfo++;
127 }
128 else
129 {
130 /* Set error code */
132 }
133
134 /* Update count and move to next entry */
135 ModuleCount++;
136 NextEntry = NextEntry->Flink;
137 }
138
139 /* Check if caller also wanted user modules */
140 if (UserModeList)
141 {
142 NextEntry = UserModeList->Flink;
143 while (NextEntry != UserModeList)
144 {
145 /* Get the entry */
146 LdrEntry = CONTAINING_RECORD(NextEntry,
148 InLoadOrderLinks);
149
150 /* Update size and check if we can manage one more entry */
152 if (Length >= RequiredLength)
153 {
155 LdrEntry,
156 ModuleInfo);
157
158 /* Go to the next module */
159 ModuleInfo++;
160 }
161 else
162 {
163 /* Set error code */
165 }
166
167 /* Update count and move to next entry */
168 ModuleCount++;
169 NextEntry = NextEntry->Flink;
170 }
171 }
172
173 /* Update return length */
175
176 /* Validate the length again */
177 if (Length >= FIELD_OFFSET(RTL_PROCESS_MODULES, Modules))
178 {
179 /* Set the final count */
180 Modules->NumberOfModules = ModuleCount;
181 }
182 else
183 {
184 /* Otherwise, we failed */
186 }
187
188 /* Done */
189 return Status;
190}
IN CINT OUT PVOID IN ULONG OUT PULONG ReturnLength
Definition: dumpinfo.c:43
struct _RTL_PROCESS_MODULE_INFORMATION RTL_PROCESS_MODULE_INFORMATION
FORCEINLINE NTSTATUS ExpConvertLdrModuleToRtlModule(IN ULONG ModuleCount, IN PLDR_DATA_TABLE_ENTRY LdrEntry, OUT PRTL_PROCESS_MODULE_INFORMATION ModuleInfo)
Definition: sysinfo.c:35
Definition: btrfs_drv.h:1876
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
_In_ ULONG _Out_opt_ PULONG RequiredLength
Definition: wmifuncs.h:30

Referenced by QSI_DEF().

◆ ExQueryPoolUsage()

VOID NTAPI ExQueryPoolUsage ( OUT PULONG  PagedPoolPages,
OUT PULONG  NonPagedPoolPages,
OUT PULONG  PagedPoolAllocs,
OUT PULONG  PagedPoolFrees,
OUT PULONG  PagedPoolLookasideHits,
OUT PULONG  NonPagedPoolAllocs,
OUT PULONG  NonPagedPoolFrees,
OUT PULONG  NonPagedPoolLookasideHits 
)

Definition at line 1768 of file expool.c.

1776{
1777 ULONG i;
1778 PPOOL_DESCRIPTOR PoolDesc;
1779
1780 //
1781 // Assume all failures
1782 //
1783 *PagedPoolPages = 0;
1784 *PagedPoolAllocs = 0;
1785 *PagedPoolFrees = 0;
1786
1787 //
1788 // Tally up the totals for all the apged pool
1789 //
1790 for (i = 0; i < ExpNumberOfPagedPools + 1; i++)
1791 {
1792 PoolDesc = ExpPagedPoolDescriptor[i];
1793 *PagedPoolPages += PoolDesc->TotalPages + PoolDesc->TotalBigPages;
1794 *PagedPoolAllocs += PoolDesc->RunningAllocs;
1795 *PagedPoolFrees += PoolDesc->RunningDeAllocs;
1796 }
1797
1798 //
1799 // The first non-paged pool has a hardcoded well-known descriptor name
1800 //
1801 PoolDesc = &NonPagedPoolDescriptor;
1802 *NonPagedPoolPages = PoolDesc->TotalPages + PoolDesc->TotalBigPages;
1803 *NonPagedPoolAllocs = PoolDesc->RunningAllocs;
1804 *NonPagedPoolFrees = PoolDesc->RunningDeAllocs;
1805
1806 //
1807 // If the system has more than one non-paged pool, copy the other descriptor
1808 // totals as well
1809 //
1810#if 0
1811 if (ExpNumberOfNonPagedPools > 1)
1812 {
1813 for (i = 0; i < ExpNumberOfNonPagedPools; i++)
1814 {
1815 PoolDesc = ExpNonPagedPoolDescriptor[i];
1816 *NonPagedPoolPages += PoolDesc->TotalPages + PoolDesc->TotalBigPages;
1817 *NonPagedPoolAllocs += PoolDesc->RunningAllocs;
1818 *NonPagedPoolFrees += PoolDesc->RunningDeAllocs;
1819 }
1820 }
1821#endif
1822
1823 //
1824 // Get the amount of hits in the system lookaside lists
1825 //
1827 {
1828 PLIST_ENTRY ListEntry;
1829
1830 for (ListEntry = ExPoolLookasideListHead.Flink;
1831 ListEntry != &ExPoolLookasideListHead;
1832 ListEntry = ListEntry->Flink)
1833 {
1835
1836 Lookaside = CONTAINING_RECORD(ListEntry, GENERAL_LOOKASIDE, ListEntry);
1837
1838 if (Lookaside->Type == NonPagedPool)
1839 {
1840 *NonPagedPoolLookasideHits += Lookaside->AllocateHits;
1841 }
1842 else
1843 {
1844 *PagedPoolLookasideHits += Lookaside->AllocateHits;
1845 }
1846 }
1847 }
1848}
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define NonPagedPool
Definition: env_spec_w32.h:307
ULONG ExpNumberOfPagedPools
Definition: expool.c:41
POOL_DESCRIPTOR NonPagedPoolDescriptor
Definition: expool.c:42
PPOOL_DESCRIPTOR ExpPagedPoolDescriptor[16+1]
Definition: expool.c:43
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LIST_ENTRY ExPoolLookasideListHead
Definition: lookas.c:22
ULONG RunningAllocs
Definition: miarm.h:327
ULONG TotalPages
Definition: miarm.h:329
ULONG RunningDeAllocs
Definition: miarm.h:328
ULONG TotalBigPages
Definition: miarm.h:330
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _In_ _Strict_type_match_ POOL_TYPE _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_opt_ ULONG _Out_ WDFLOOKASIDE * Lookaside
Definition: wdfmemory.h:414

Referenced by QSI_DEF().

◆ ExUnlockUserBuffer()

VOID NTAPI ExUnlockUserBuffer ( PMDL  Mdl)

Definition at line 194 of file sysinfo.c.

195{
198}
VOID NTAPI MmUnlockPages(IN PMDL Mdl)
Definition: mdlsup.c:1435

Referenced by ExLockUserBuffer(), and QSI_DEF().

◆ ExVerifySuite()

BOOLEAN NTAPI ExVerifySuite ( SUITE_TYPE  SuiteType)

Definition at line 377 of file sysinfo.c.

378{
379 if (SuiteType == Personal) return TRUE;
380 return FALSE;
381}
@ Personal
Definition: extypes.h:29

Referenced by DisplayBootBitmap(), and InitializeMachineInformation().

◆ MmSessionCreate()

NTSTATUS NTAPI MmSessionCreate ( OUT PULONG  SessionId)

Definition at line 827 of file session.c.

828{
830 ULONG SessionLeaderExists;
832
833 /* Fail if the process is already in a session */
835 {
836 DPRINT1("Process already in session\n");
838 }
839
840 /* Check if the process is already the session leader */
841 if (!Process->Vm.Flags.SessionLeader)
842 {
843 /* Atomically set it as the leader */
844 SessionLeaderExists = InterlockedCompareExchange(&MiSessionLeaderExists, 1, 0);
845 if (SessionLeaderExists)
846 {
847 DPRINT1("Session leader race\n");
849 }
850
851 /* Do the work required to upgrade him */
853 }
854
855 /* Create the session */
858 if (!NT_SUCCESS(Status))
859 {
861 return Status;
862 }
863
864 /* Set up the session working set */
866 if (!NT_SUCCESS(Status))
867 {
868 /* Fail */
869 //MiDereferenceSession();
870 ASSERT(FALSE);
872 return Status;
873 }
874
875 /* All done */
877
878 /* Set and assert the flags, and return */
882 return Status;
883}
ULONG SessionId
Definition: dllmain.c:28
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
#define PSF_PROCESS_IN_SESSION_BIT
Definition: pstypes.h:289
#define InterlockedCompareExchange
Definition: interlocked.h:104
#define KeLeaveCriticalRegion()
Definition: ke_x.h:119
#define KeEnterCriticalRegion()
Definition: ke_x.h:88
PMM_SESSION_SPACE MmSessionSpace
Definition: session.c:21
NTSTATUS NTAPI MiSessionCreateInternal(OUT PULONG SessionId)
Definition: session.c:599
VOID NTAPI MiSessionLeader(IN PEPROCESS Process)
Definition: session.c:167
NTSTATUS NTAPI MiSessionInitializeWorkingSetList(VOID)
Definition: session.c:461
volatile LONG MiSessionLeaderExists
Definition: session.c:27
#define STATUS_ALREADY_COMMITTED
Definition: ntstatus.h:270
#define STATUS_INVALID_SYSTEM_SERVICE
Definition: ntstatus.h:265
#define PspSetProcessFlag(Process, Flag)
Definition: ps_x.h:33
MM_SESSION_SPACE_FLAGS Flags
Definition: miarm.h:489
union _MM_SESSION_SPACE::@1842 u
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by SSI_DEF().

◆ MmSessionDelete()

NTSTATUS NTAPI MmSessionDelete ( IN ULONG  SessionId)

Definition at line 887 of file session.c.

888{
890
891 /* Process must be in a session */
892 if (!(Process->Flags & PSF_PROCESS_IN_SESSION_BIT))
893 {
894 DPRINT1("Not in a session!\n");
896 }
897
898 /* It must be the session leader */
899 if (!Process->Vm.Flags.SessionLeader)
900 {
901 DPRINT1("Not a session leader!\n");
903 }
904
905 /* Remove one reference count */
909
910 /* All done */
911 return STATUS_SUCCESS;
912}
VOID NTAPI MiDereferenceSession(VOID)
Definition: session.c:339
#define STATUS_UNABLE_TO_FREE_VM
Definition: ntstatus.h:263

Referenced by SSI_DEF().

◆ NtEnumerateSystemEnvironmentValuesEx()

NTSTATUS NTAPI NtEnumerateSystemEnvironmentValuesEx ( IN ULONG  InformationClass,
IN PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 557 of file sysinfo.c.

560{
563}
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42

◆ NtGetCurrentProcessorNumber()

ULONG NTAPI NtGetCurrentProcessorNumber ( VOID  )

Definition at line 3055 of file sysinfo.c.

3056{
3057 /* Just use Ke */
3059}
FORCEINLINE ULONG KeGetCurrentProcessorNumber(VOID)
Definition: ke.h:341

Referenced by RtlGetCurrentProcessorNumber().

◆ NtQuerySystemEnvironmentValue()

NTSTATUS NTAPI NtQuerySystemEnvironmentValue ( IN PUNICODE_STRING  VariableName,
OUT PWSTR  ValueBuffer,
IN ULONG  ValueBufferLength,
IN OUT PULONG ReturnLength  OPTIONAL 
)

Definition at line 385 of file sysinfo.c.

389{
390 ANSI_STRING AName;
391 UNICODE_STRING WName;
393 PCH AnsiValueBuffer;
394 ANSI_STRING AValue;
395 UNICODE_STRING WValue;
398 PAGED_CODE();
399
400 /* Check if the call came from user mode */
403 {
405 {
406 /* Probe the input and output buffers */
407 ProbeForRead(VariableName, sizeof(UNICODE_STRING), sizeof(ULONG));
408 ProbeForWrite(ValueBuffer, ValueBufferLength, sizeof(WCHAR));
410 }
412 {
413 /* Return the exception code */
415 }
416 _SEH2_END;
417 }
418
419 /* According to NTInternals the SeSystemEnvironmentName privilege is required! */
421 {
422 DPRINT1("NtQuerySystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
424 }
425
426 /* Copy the name to kernel space if necessary */
427 Status = ProbeAndCaptureUnicodeString(&WName, PreviousMode, VariableName);
428 if (!NT_SUCCESS(Status)) return Status;
429
430 /* Convert the name to ANSI and release the captured UNICODE string */
431 Status = RtlUnicodeStringToAnsiString(&AName, &WName, TRUE);
433 if (!NT_SUCCESS(Status)) return Status;
434
435 /* Allocate a buffer for the ANSI environment variable */
436 AnsiValueBuffer = ExAllocatePoolWithTag(NonPagedPool, MAX_ENVVAL_SIZE, 'rvnE');
437 if (AnsiValueBuffer == NULL)
438 {
439 RtlFreeAnsiString(&AName);
441 }
442
443 /* Get the environment variable and free the ANSI name */
446 AnsiValueBuffer);
447 RtlFreeAnsiString(&AName);
448
449 /* Check if we had success */
450 if (Result == ESUCCESS)
451 {
452 /* Copy the result back to the caller. */
454 {
455 /* Initialize ANSI string from the result */
456 RtlInitAnsiString(&AValue, AnsiValueBuffer);
457
458 /* Initialize a UNICODE string from the callers buffer */
459 RtlInitEmptyUnicodeString(&WValue, ValueBuffer, (USHORT)ValueBufferLength);
460
461 /* Convert the result to UNICODE */
462 Status = RtlAnsiStringToUnicodeString(&WValue, &AValue, FALSE);
463
464 if (ReturnLength != NULL)
465 *ReturnLength = WValue.Length;
466 }
468 {
470 }
471 _SEH2_END;
472 }
473 else
474 {
476 }
477
478 /* Free the allocated ANSI value buffer */
479 ExFreePoolWithTag(AnsiValueBuffer, 'rvnE');
480
481 return Status;
482}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
#define ExGetPreviousMode
Definition: ex.h:140
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
LONG NTAPI ExSystemExceptionFilter(VOID)
Definition: harderr.c:349
#define KernelMode
Definition: asm.h:34
NTSYSAPI VOID NTAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
CHAR * PCH
Definition: ntbasedef.h:399
#define MAX_ENVVAL_SIZE
Definition: sysinfo.c:20
const LUID SeSystemEnvironmentPrivilege
Definition: priv.c:41
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
ARC_STATUS NTAPI HalGetEnvironmentVariable(IN PCH Name, IN USHORT ValueLength, IN PCH Value)
Definition: rtc.c:70
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:239
#define ProbeForWriteUlong(Ptr)
Definition: probe.h:36
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
CCHAR KPROCESSOR_MODE
Definition: ketypes.h:7
_In_ KPROCESSOR_MODE PreviousMode
Definition: sefuncs.h:103
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Test_API().

◆ NtQuerySystemEnvironmentValueEx()

NTSTATUS NTAPI NtQuerySystemEnvironmentValueEx ( _In_ PUNICODE_STRING  VariableName,
_In_ LPGUID  VendorGuid,
_Out_opt_ PVOID  Value,
_Inout_ PULONG  ReturnLength,
_Out_opt_ PULONG  Attributes 
)

Definition at line 567 of file sysinfo.c.

573{
576}

Referenced by _Success_().

◆ NtQuerySystemInformation()

__kernel_entry NTSTATUS NTAPI NtQuerySystemInformation ( _In_ SYSTEM_INFORMATION_CLASS  SystemInformationClass,
_Out_writes_bytes_to_opt_(SystemInformationLength, *ReturnLength) PVOID  SystemInformation,
_In_ ULONG  SystemInformationLength,
_Out_opt_ PULONG  ReturnLength 
)

Definition at line 2931 of file sysinfo.c.

2936{
2938 ULONG CapturedResultLength = 0;
2941
2942 PAGED_CODE();
2943
2945
2946 _SEH2_TRY
2947 {
2948#if (NTDDI_VERSION >= NTDDI_VISTA)
2949 /*
2950 * Check whether the request is valid.
2951 */
2952 if (SystemInformationClass < MIN_SYSTEM_INFO_CLASS ||
2953 SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
2954 {
2956 }
2957#endif
2958
2959 if (PreviousMode != KernelMode)
2960 {
2961 /* SystemKernelDebuggerInformation needs only BOOLEAN alignment */
2962 if (SystemInformationClass == SystemKernelDebuggerInformation)
2964
2965 ProbeForWrite(SystemInformation, SystemInformationLength, Alignment);
2966 if (ReturnLength != NULL)
2968 }
2969
2970 if (ReturnLength)
2971 *ReturnLength = 0;
2972
2973#if (NTDDI_VERSION < NTDDI_VISTA)
2974 /*
2975 * Check whether the request is valid.
2976 */
2977 if (SystemInformationClass < MIN_SYSTEM_INFO_CLASS ||
2978 SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
2979 {
2981 }
2982#endif
2983
2984 if (CallQS[SystemInformationClass].Query != NULL)
2985 {
2986 /* Hand the request to a subhandler */
2987 Status = CallQS[SystemInformationClass].Query(SystemInformation,
2988 SystemInformationLength,
2989 &CapturedResultLength);
2990
2991 /* Save the result length to the caller */
2992 if (ReturnLength)
2993 *ReturnLength = CapturedResultLength;
2994 }
2995 }
2997 {
2999 }
3000 _SEH2_END;
3001
3002 return Status;
3003}
unsigned char BOOLEAN
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
@ SystemKernelDebuggerInformation
Definition: ntddk_ex.h:46
#define TYPE_ALIGNMENT(t)
Definition: ntbasedef.h:117
#define MAX_SYSTEM_INFO_CLASS
Definition: sysinfo.c:2923
#define MIN_SYSTEM_INFO_CLASS
Definition: sysinfo.c:2922
static QSSI_CALLS CallQS[]
Definition: sysinfo.c:2840
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
NTSTATUS(* Query)(PVOID, ULONG, PULONG)
Definition: sysinfo.c:2824

◆ NtSetSystemEnvironmentValue()

NTSTATUS NTAPI NtSetSystemEnvironmentValue ( IN PUNICODE_STRING  VariableName,
IN PUNICODE_STRING  Value 
)

Definition at line 487 of file sysinfo.c.

489{
490 UNICODE_STRING CapturedName, CapturedValue;
491 ANSI_STRING AName, AValue;
494
495 PAGED_CODE();
496
498
499 /*
500 * Copy the strings to kernel space if necessary
501 */
502 Status = ProbeAndCaptureUnicodeString(&CapturedName,
504 VariableName);
505 if (NT_SUCCESS(Status))
506 {
507 Status = ProbeAndCaptureUnicodeString(&CapturedValue,
509 Value);
510 if (NT_SUCCESS(Status))
511 {
512 /*
513 * according to ntinternals the SeSystemEnvironmentName privilege is required!
514 */
517 {
518 /*
519 * convert the strings to ANSI
520 */
522 &CapturedName,
523 TRUE);
524 if (NT_SUCCESS(Status))
525 {
527 &CapturedValue,
528 TRUE);
529 if (NT_SUCCESS(Status))
530 {
532 AValue.Buffer);
533
535 }
536 }
537 }
538 else
539 {
540 DPRINT1("NtSetSystemEnvironmentValue: Caller requires the SeSystemEnvironmentPrivilege privilege!\n");
542 }
543
544 ReleaseCapturedUnicodeString(&CapturedValue,
546 }
547
548 ReleaseCapturedUnicodeString(&CapturedName,
550 }
551
552 return Status;
553}
ARC_STATUS NTAPI HalSetEnvironmentVariable(IN PCH Name, IN PCH Value)
Definition: rtc.c:57
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ NtSetSystemEnvironmentValueEx()

NTSTATUS NTAPI NtSetSystemEnvironmentValueEx ( _In_ PUNICODE_STRING  VariableName,
_In_ LPGUID  VendorGuid,
_In_reads_bytes_opt_(ValueLength) PVOID  Value,
_In_ ULONG  ValueLength,
_In_ ULONG  Attributes 
)

Definition at line 580 of file sysinfo.c.

586{
589}

Referenced by SetFirmwareEnvironmentVariableExW().

◆ NtSetSystemInformation()

__kernel_entry NTSTATUS NTAPI NtSetSystemInformation ( _In_ SYSTEM_INFORMATION_CLASS  SystemInformationClass,
_In_reads_bytes_(SystemInformationLength) PVOID  SystemInformation,
_In_ ULONG  SystemInformationLength 
)

Definition at line 3008 of file sysinfo.c.

3012{
3015
3016 PAGED_CODE();
3017
3019
3020 _SEH2_TRY
3021 {
3022 /*
3023 * If called from user mode, check possible unsafe arguments.
3024 */
3025 if (PreviousMode != KernelMode)
3026 {
3027 ProbeForRead(SystemInformation, SystemInformationLength, sizeof(ULONG));
3028 }
3029
3030 /*
3031 * Check whether the request is valid.
3032 */
3033 if ((SystemInformationClass >= MIN_SYSTEM_INFO_CLASS) &&
3034 (SystemInformationClass < MAX_SYSTEM_INFO_CLASS))
3035 {
3036 if (CallQS[SystemInformationClass].Set != NULL)
3037 {
3038 /* Hand the request to a subhandler */
3039 Status = CallQS[SystemInformationClass].Set(SystemInformation,
3040 SystemInformationLength);
3041 }
3042 }
3043 }
3045 {
3047 }
3048 _SEH2_END;
3049
3050 return Status;
3051}
static BOOL Set
Definition: pageheap.c:10
NTSTATUS(* Set)(PVOID, ULONG)
Definition: sysinfo.c:2825

◆ QSI_DEF() [1/55]

QSI_DEF ( SystemBasicInformation  )

Definition at line 617 of file sysinfo.c.

618{
621
622 *ReqSize = sizeof(SYSTEM_BASIC_INFORMATION);
623
624 /* Check user buffer's size */
625 if (Size != sizeof(SYSTEM_BASIC_INFORMATION))
626 {
628 }
629
630 RtlZeroMemory(Sbi, Size);
631 Sbi->Reserved = 0;
633 Sbi->PageSize = PAGE_SIZE;
637 Sbi->AllocationGranularity = MM_VIRTMEM_GRANULARITY; /* hard coded on Intel? */
638 Sbi->MinimumUserModeAddress = 0x10000; /* Top of 64k */
642
643 return STATUS_SUCCESS;
644}
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
CCHAR KeNumberProcessors
Definition: krnlinit.c:35
PFN_NUMBER MmLowestPhysicalPage
Definition: meminit.c:30
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
KAFFINITY KeActiveProcessors
Definition: krnlinit.c:23
PFN_COUNT MmNumberOfPhysicalPages
Definition: init.c:48
#define MM_VIRTMEM_GRANULARITY
Definition: mm.h:102
ULONG KeMaximumIncrement
Definition: clock.c:20
PVOID MmHighestUserAddress
Definition: rtlcompat.c:29
struct _SYSTEM_BASIC_INFORMATION * PSYSTEM_BASIC_INFORMATION
struct _SYSTEM_BASIC_INFORMATION SYSTEM_BASIC_INFORMATION
KAFFINITY ActiveProcessorsAffinityMask
Definition: ntddk_ex.h:167
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

◆ QSI_DEF() [2/55]

Definition at line 1130 of file sysinfo.c.

1131{
1132 /* FIXME */
1133 DPRINT1("NtQuerySystemInformation - SystemCallCountInformation not implemented\n");
1135}

◆ QSI_DEF() [3/55]

Definition at line 1242 of file sysinfo.c.

1243{
1244 /* FIXME */
1245 DPRINT1("NtQuerySystemInformation - SystemCallTimeInformation not implemented\n");
1247}

◆ QSI_DEF() [4/55]

Definition at line 1846 of file sysinfo.c.

1847{
1848 PSYSTEM_CONTEXT_SWITCH_INFORMATION ContextSwitchInformation =
1850 ULONG ContextSwitches;
1851 PKPRCB Prcb;
1852 CHAR i;
1853
1854 /* Check size of a buffer, it must match our expectations */
1857
1858 /* Calculate total value of context switches across all processors */
1859 ContextSwitches = 0;
1860 for (i = 0; i < KeNumberProcessors; i ++)
1861 {
1862 Prcb = KiProcessorBlock[i];
1863 if (Prcb)
1864 {
1865 ContextSwitches += KeGetContextSwitches(Prcb);
1866 }
1867 }
1868
1869 ContextSwitchInformation->ContextSwitches = ContextSwitches;
1870
1871 /* FIXME */
1872 ContextSwitchInformation->FindAny = 0;
1873 ContextSwitchInformation->FindLast = 0;
1874 ContextSwitchInformation->FindIdeal = 0;
1875 ContextSwitchInformation->IdleAny = 0;
1876 ContextSwitchInformation->IdleCurrent = 0;
1877 ContextSwitchInformation->IdleLast = 0;
1878 ContextSwitchInformation->IdleIdeal = 0;
1879 ContextSwitchInformation->PreemptAny = 0;
1880 ContextSwitchInformation->PreemptCurrent = 0;
1881 ContextSwitchInformation->PreemptLast = 0;
1882 ContextSwitchInformation->SwitchToIdle = 0;
1883
1884 return STATUS_SUCCESS;
1885}
struct _SYSTEM_CONTEXT_SWITCH_INFORMATION * PSYSTEM_CONTEXT_SWITCH_INFORMATION
#define KeGetContextSwitches(Prcb)
Definition: ke.h:216
PKPRCB KiProcessorBlock[]
Definition: krnlinit.c:32
char CHAR
Definition: xmlstorage.h:175

◆ QSI_DEF() [5/55]

Definition at line 1769 of file sysinfo.c.

1770{
1771 /* FIXME */
1772 DPRINT1("NtQuerySystemInformation - SystemCrashDumpInformation not implemented\n");
1774}

◆ QSI_DEF() [6/55]

Definition at line 1814 of file sysinfo.c.

1815{
1816 /* FIXME */
1817 DPRINT1("NtQuerySystemInformation - SystemCrashDumpStateInformation not implemented\n");
1819}

◆ QSI_DEF() [7/55]

Definition at line 2068 of file sysinfo.c.

2069{
2070 *ReqSize = sizeof(RTL_TIME_ZONE_INFORMATION);
2071
2072 if (sizeof(RTL_TIME_ZONE_INFORMATION) != Size)
2073 {
2075 }
2076
2077 /* Copy the time zone information struct */
2078 memcpy(Buffer,
2081
2082 return STATUS_SUCCESS;
2083}
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct _RTL_TIME_ZONE_INFORMATION RTL_TIME_ZONE_INFORMATION
RTL_TIME_ZONE_INFORMATION ExpTimeZoneInfo
Definition: time.c:21

◆ QSI_DEF() [8/55]

QSI_DEF ( SystemDeviceInformation  )

Definition at line 1138 of file sysinfo.c.

1139{
1142 PCONFIGURATION_INFORMATION ConfigInfo;
1143
1144 *ReqSize = sizeof(SYSTEM_DEVICE_INFORMATION);
1145
1146 /* Check user buffer's size */
1147 if (Size < sizeof(SYSTEM_DEVICE_INFORMATION))
1148 {
1150 }
1151
1152 ConfigInfo = IoGetConfigurationInformation();
1153
1154 Sdi->NumberOfDisks = ConfigInfo->DiskCount;
1155 Sdi->NumberOfFloppies = ConfigInfo->FloppyCount;
1156 Sdi->NumberOfCdRoms = ConfigInfo->CdRomCount;
1157 Sdi->NumberOfTapes = ConfigInfo->TapeCount;
1158 Sdi->NumberOfSerialPorts = ConfigInfo->SerialCount;
1159 Sdi->NumberOfParallelPorts = ConfigInfo->ParallelCount;
1160
1161 return STATUS_SUCCESS;
1162}
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Returns a pointer to the I/O manager's global configuration information structure.
Definition: iorsrce.c:998
struct _SYSTEM_DEVICE_INFORMATION * PSYSTEM_DEVICE_INFORMATION
struct _SYSTEM_DEVICE_INFORMATION SYSTEM_DEVICE_INFORMATION

◆ QSI_DEF() [9/55]

Definition at line 1556 of file sysinfo.c.

1557{
1559
1561 {
1563 }
1564
1569
1570 return STATUS_SUCCESS;
1571}
struct _SYSTEM_DPC_BEHAVIOR_INFORMATION * PSYSTEM_DPC_BEHAVIOR_INFORMATION
ULONG KiAdjustDpcThreshold
Definition: dpc.c:21
ULONG KiMaximumDpcQueueDepth
Definition: dpc.c:19
ULONG KiMinimumDpcRate
Definition: dpc.c:20
ULONG KiIdealDpcRate
Definition: dpc.c:22

◆ QSI_DEF() [10/55]

Definition at line 1777 of file sysinfo.c.

1778{
1779 PSYSTEM_EXCEPTION_INFORMATION ExceptionInformation =
1781 PKPRCB Prcb;
1782 ULONG AlignmentFixupCount = 0, ExceptionDispatchCount = 0;
1783 ULONG FloatingEmulationCount = 0, ByteWordEmulationCount = 0;
1784 CHAR i;
1785
1786 /* Check size of a buffer, it must match our expectations */
1787 if (sizeof(SYSTEM_EXCEPTION_INFORMATION) != Size)
1789
1790 /* Sum up exception count information from all processors */
1791 for (i = 0; i < KeNumberProcessors; i++)
1792 {
1793 Prcb = KiProcessorBlock[i];
1794 if (Prcb)
1795 {
1796 AlignmentFixupCount += Prcb->KeAlignmentFixupCount;
1797 ExceptionDispatchCount += Prcb->KeExceptionDispatchCount;
1798#ifndef _M_ARM
1799 FloatingEmulationCount += Prcb->KeFloatingEmulationCount;
1800#endif // _M_ARM
1801 }
1802 }
1803
1804 /* Save information in user's buffer */
1805 ExceptionInformation->AlignmentFixupCount = AlignmentFixupCount;
1806 ExceptionInformation->ExceptionDispatchCount = ExceptionDispatchCount;
1807 ExceptionInformation->FloatingEmulationCount = FloatingEmulationCount;
1808 ExceptionInformation->ByteWordEmulationCount = ByteWordEmulationCount;
1809
1810 return STATUS_SUCCESS;
1811}
struct _SYSTEM_EXCEPTION_INFORMATION * PSYSTEM_EXCEPTION_INFORMATION
ULONG KeExceptionDispatchCount
Definition: ketypes.h:774
ULONG KeAlignmentFixupCount
Definition: ketypes.h:869

◆ QSI_DEF() [11/55]

Definition at line 2490 of file sysinfo.c.

2491{
2493 PLIST_ENTRY NextTableEntry;
2495 PHANDLE_TABLE_ENTRY HandleTableEntry;
2497 ULONG Index = 0;
2499 PMDL Mdl;
2500 PAGED_CODE();
2501
2502 DPRINT("NtQuerySystemInformation - SystemExtendedHandleInformation\n");
2503
2504 /* Set initial required buffer size */
2506
2507 /* Check user's buffer size */
2508 if (Size < *ReqSize)
2509 {
2511 }
2512
2513 /* We need to lock down the memory */
2515 Size,
2519 &Mdl);
2520 if (!NT_SUCCESS(Status))
2521 {
2522 DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
2523 return Status;
2524 }
2525
2526 /* Reset of count of handles */
2527 HandleInformation->Count = 0;
2528
2529 /* Enter a critical region */
2531
2532 /* Acquire the handle table lock */
2534
2535 /* Enumerate all system handles */
2536 for (NextTableEntry = HandleTableListHead.Flink;
2537 NextTableEntry != &HandleTableListHead;
2538 NextTableEntry = NextTableEntry->Flink)
2539 {
2540 /* Get current handle table */
2541 HandleTable = CONTAINING_RECORD(NextTableEntry, HANDLE_TABLE, HandleTableList);
2542
2543 /* Set the initial value and loop the entries */
2544 Handle.Value = 0;
2545 while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
2546 {
2547 /* Validate the entry */
2548 if ((HandleTableEntry->Object) &&
2549 (HandleTableEntry->NextFreeTableEntry != -2))
2550 {
2551 /* Increase of count of handles */
2552 ++HandleInformation->Count;
2553
2554 /* Lock the entry */
2555 if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
2556 {
2557 /* Increase required buffer size */
2558 *ReqSize += sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX);
2559
2560 /* Check user's buffer size */
2561 if (*ReqSize > Size)
2562 {
2564 }
2565 else
2566 {
2567 POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
2568
2569 /* Filling handle information */
2570 HandleInformation->Handle[Index].UniqueProcessId =
2571 (USHORT)(ULONG_PTR) HandleTable->UniqueProcessId;
2572
2573 HandleInformation->Handle[Index].CreatorBackTraceIndex = 0;
2574
2575#if 0 /* FIXME!!! Type field corrupted */
2576 HandleInformation->Handles[Index].ObjectTypeIndex =
2577 (UCHAR) ObjectHeader->Type->Index;
2578#else
2579 HandleInformation->Handle[Index].ObjectTypeIndex = 0;
2580#endif
2581
2582 HandleInformation->Handle[Index].HandleAttributes =
2583 HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
2584
2585 HandleInformation->Handle[Index].HandleValue =
2586 (USHORT)(ULONG_PTR) Handle.GenericHandleOverlay;
2587
2588 HandleInformation->Handle[Index].Object = &ObjectHeader->Body;
2589
2590 HandleInformation->Handle[Index].GrantedAccess =
2591 HandleTableEntry->GrantedAccess;
2592
2593 HandleInformation->Handle[Index].Reserved = 0;
2594
2595 ++Index;
2596 }
2597
2598 /* Unlock it */
2599 ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
2600 }
2601 }
2602
2603 /* Go to the next entry */
2604 Handle.Value += sizeof(HANDLE);
2605 }
2606 }
2607
2608 /* Release the lock */
2610
2611 /* Leave the critical region */
2613
2614 /* Release the locked user buffer */
2616
2617 return Status;
2618}
FORCEINLINE VOID ExAcquirePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1105
FORCEINLINE VOID ExReleasePushLockShared(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1213
ULONG Handle
Definition: gdb_input.c:15
static XMS_HANDLE HandleTable[XMS_MAX_HANDLES]
Definition: himem.c:83
struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX
PHANDLE_TABLE_ENTRY NTAPI ExpLookupHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN EXHANDLE Handle)
Definition: handle.c:43
BOOLEAN NTAPI ExpLockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:884
VOID NTAPI ExUnlockHandleTableEntry(IN PHANDLE_TABLE HandleTable, IN PHANDLE_TABLE_ENTRY HandleTableEntry)
Definition: handle.c:923
EX_PUSH_LOCK HandleTableListLock
Definition: handle.c:19
LIST_ENTRY HandleTableListHead
Definition: handle.c:18
NTSTATUS NTAPI ExLockUserBuffer(PVOID BaseAddress, ULONG Length, KPROCESSOR_MODE AccessMode, LOCK_OPERATION Operation, PVOID *MappedSystemVa, PMDL *OutMdl)
Definition: sysinfo.c:202
#define OBJ_HANDLE_ATTRIBUTES
Definition: ob.h:52
#define ObpGetHandleObject(x)
Definition: ob.h:91
#define DPRINT
Definition: sndvol32.h:73
Definition: extypes.h:596
PVOID Object
Definition: extypes.h:599
ULONG GrantedAccess
Definition: extypes.h:606
ULONG_PTR ObAttributes
Definition: extypes.h:600
LONG NextFreeTableEntry
Definition: extypes.h:612
POBJECT_TYPE Type
Definition: obtypes.h:493
ULONG Index
Definition: obtypes.h:385
PVOID HANDLE
Definition: typedefs.h:73
uint32_t ULONG_PTR
Definition: typedefs.h:65
Definition: ex.h:87
_In_ WDFCOLLECTION _In_ ULONG Index
@ IoWriteAccess
Definition: ketypes.h:864
_In_ ACCESS_MASK _In_opt_ POBJECT_TYPE _In_ KPROCESSOR_MODE _Out_ PVOID _Out_opt_ POBJECT_HANDLE_INFORMATION HandleInformation
Definition: obfuncs.h:44
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ QSI_DEF() [12/55]

Definition at line 2420 of file sysinfo.c.

2421{
2422 /* FIXME */
2423 DPRINT1("NtQuerySystemInformation - SystemExtendedProcessInformation not implemented\n");
2425}

◆ QSI_DEF() [13/55]

Definition at line 1481 of file sysinfo.c.

1482{
1484
1485 *ReqSize = sizeof(SYSTEM_FILECACHE_INFORMATION);
1486
1487 if (Size < *ReqSize)
1488 {
1490 }
1491
1493
1494 /* Return the Byte size not the page size. */
1495 Sci->CurrentSize = MiMemoryConsumers[MC_USER].PagesUsed; /* FIXME */
1496 Sci->PeakSize = MiMemoryConsumers[MC_USER].PagesUsed; /* FIXME */
1497 /* Taskmgr multiplies this one by page size right away */
1499 /* system working set and standby pages. */
1500 Sci->PageFaultCount = 0; /* FIXME */
1501 Sci->MinimumWorkingSet = 0; /* FIXME */
1502 Sci->MaximumWorkingSet = 0; /* FIXME */
1503
1504 return STATUS_SUCCESS;
1505}
struct _SYSTEM_FILECACHE_INFORMATION SYSTEM_FILECACHE_INFORMATION
MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM]
Definition: balance.c:28
#define MC_USER
Definition: mm.h:114
ULONG PagesUsed
Definition: mm.h:457
SIZE_T CurrentSizeIncludingTransitionInPages
Definition: extypes.h:1127

◆ QSI_DEF() [14/55]

Definition at line 2721 of file sysinfo.c.

2722{
2725 ULONG InputBufSize;
2726 ULONG DataSize = 0;
2727 ULONG TableCount = 0;
2728
2729 DPRINT("NtQuerySystemInformation - SystemFirmwareTableInformation\n");
2730
2731 /* Set initial required buffer size */
2732 *ReqSize = FIELD_OFFSET(SYSTEM_FIRMWARE_TABLE_INFORMATION, TableBuffer);
2733
2734 /* Check user's buffer size */
2735 if (Size < *ReqSize)
2736 {
2738 }
2739
2740 InputBufSize = SysFirmwareInfo->TableBufferLength;
2741 switch (SysFirmwareInfo->ProviderSignature)
2742 {
2743 /*
2744 * ExpFirmwareTableResource and ExpFirmwareTableProviderListHead
2745 * variables should be used there somehow...
2746 */
2747 case SIG_ACPI:
2748 {
2749 /* FIXME: Not implemented yet */
2750 DPRINT1("ACPI provider not implemented\n");
2752 break;
2753 }
2754 case SIG_FIRM:
2755 {
2756 /* FIXME: Not implemented yet */
2757 DPRINT1("FIRM provider not implemented\n");
2759 break;
2760 }
2761 case SIG_RSMB:
2762 {
2764 if (DataSize > 0)
2765 {
2766 TableCount = 1;
2767 if (SysFirmwareInfo->Action == SystemFirmwareTable_Enumerate)
2768 {
2769 DataSize = TableCount * sizeof(ULONG);
2770 if (DataSize <= InputBufSize)
2771 {
2772 *(ULONG *)SysFirmwareInfo->TableBuffer = 0;
2773 }
2774 }
2775 else if (SysFirmwareInfo->Action == SystemFirmwareTable_Get
2776 && DataSize <= InputBufSize)
2777 {
2778 Status = ExpGetRawSMBiosTable(SysFirmwareInfo->TableBuffer, &DataSize, InputBufSize);
2779 }
2780 SysFirmwareInfo->TableBufferLength = DataSize;
2781 }
2782 break;
2783 }
2784 default:
2785 {
2786 DPRINT1("SystemFirmwareTableInformation: Unsupported provider (0x%x)\n",
2787 SysFirmwareInfo->ProviderSignature);
2789 }
2790 }
2791
2792 if (NT_SUCCESS(Status))
2793 {
2794 switch (SysFirmwareInfo->Action)
2795 {
2798 {
2799 if (SysFirmwareInfo->TableBufferLength > InputBufSize)
2800 {
2802 }
2803 break;
2804 }
2805 default:
2806 {
2807 DPRINT1("SystemFirmwareTableInformation: Unsupported action (0x%x)\n",
2808 SysFirmwareInfo->Action);
2810 }
2811 }
2812 }
2813 else
2814 {
2815 SysFirmwareInfo->TableBufferLength = 0;
2816 }
2817 return Status;
2818}
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
struct _SYSTEM_FIRMWARE_TABLE_INFORMATION * PSYSTEM_FIRMWARE_TABLE_INFORMATION
@ SystemFirmwareTable_Enumerate
@ SystemFirmwareTable_Get
#define SIG_RSMB
Definition: sysinfo.c:24
#define SIG_FIRM
Definition: sysinfo.c:23
#define SIG_ACPI
Definition: sysinfo.c:22
NTSTATUS NTAPI ExpGetRawSMBiosTable(_Out_opt_ PVOID Buffer, _Out_ ULONG *OutSize, _In_ ULONG BufferSize)
Definition: sysinfo.c:250
#define STATUS_ILLEGAL_FUNCTION
Definition: ntstatus.h:411
SYSTEM_FIRMWARE_TABLE_ACTION Action

◆ QSI_DEF() [15/55]

QSI_DEF ( SystemFlagsInformation  )

Definition at line 1202 of file sysinfo.c.

1203{
1204#if (NTDDI_VERSION >= NTDDI_VISTA)
1205 *ReqSize = sizeof(SYSTEM_FLAGS_INFORMATION);
1206#endif
1207
1208 if (sizeof(SYSTEM_FLAGS_INFORMATION) != Size)
1209 {
1211 }
1212
1214#if (NTDDI_VERSION < NTDDI_VISTA)
1215 *ReqSize = sizeof(SYSTEM_FLAGS_INFORMATION);
1216#endif
1217
1218 return STATUS_SUCCESS;
1219}
struct _SYSTEM_FLAGS_INFORMATION SYSTEM_FLAGS_INFORMATION
struct _SYSTEM_FLAGS_INFORMATION * PSYSTEM_FLAGS_INFORMATION
ULONG NtGlobalFlag
Definition: init.c:54

◆ QSI_DEF() [16/55]

Definition at line 1581 of file sysinfo.c.

1582{
1583 PULONG Spi = (PULONG) Buffer;
1584
1586
1587 *ReqSize = sizeof(ULONG);
1588
1589 if (sizeof(ULONG) != Size)
1590 {
1592 }
1593
1594 DPRINT("SystemFullMemoryInformation\n");
1595
1597
1598 DPRINT("PID: %p, KernelTime: %u PFFree: %lu PFUsed: %lu\n",
1603
1605
1606 return STATUS_SUCCESS;
1607}
PEPROCESS TheIdleProcess
Definition: kdpacket.c:30
PFN_COUNT MiFreeSwapPages
Definition: pagefile.c:66
PFN_COUNT MiUsedSwapPages
Definition: pagefile.c:69
PEPROCESS PsIdleProcess
Definition: psmgr.c:51
KPROCESS Pcb
Definition: pstypes.h:1263
HANDLE UniqueProcessId
Definition: pstypes.h:1268
ULONG KernelTime
Definition: ketypes.h:2102
uint32_t * PULONG
Definition: typedefs.h:59

◆ QSI_DEF() [17/55]

QSI_DEF ( SystemHandleInformation  )

Definition at line 1304 of file sysinfo.c.

1305{
1307 PLIST_ENTRY NextTableEntry;
1309 PHANDLE_TABLE_ENTRY HandleTableEntry;
1311 ULONG Index = 0;
1313 PMDL Mdl;
1314 PAGED_CODE();
1315
1316 DPRINT("NtQuerySystemInformation - SystemHandleInformation\n");
1317
1318 /* Set initial required buffer size */
1319 *ReqSize = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION, Handles);
1320
1321 /* Check user's buffer size */
1322 if (Size < *ReqSize)
1323 {
1325 }
1326
1327 /* We need to lock down the memory */
1329 Size,
1333 &Mdl);
1334 if (!NT_SUCCESS(Status))
1335 {
1336 DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
1337 return Status;
1338 }
1339
1340 /* Reset of count of handles */
1341 HandleInformation->NumberOfHandles = 0;
1342
1343 /* Enter a critical region */
1345
1346 /* Acquire the handle table lock */
1348
1349 /* Enumerate all system handles */
1350 for (NextTableEntry = HandleTableListHead.Flink;
1351 NextTableEntry != &HandleTableListHead;
1352 NextTableEntry = NextTableEntry->Flink)
1353 {
1354 /* Get current handle table */
1355 HandleTable = CONTAINING_RECORD(NextTableEntry, HANDLE_TABLE, HandleTableList);
1356
1357 /* Set the initial value and loop the entries */
1358 Handle.Value = 0;
1359 while ((HandleTableEntry = ExpLookupHandleTableEntry(HandleTable, Handle)))
1360 {
1361 /* Validate the entry */
1362 if ((HandleTableEntry->Object) &&
1363 (HandleTableEntry->NextFreeTableEntry != -2))
1364 {
1365 /* Increase of count of handles */
1366 ++HandleInformation->NumberOfHandles;
1367
1368 /* Lock the entry */
1369 if (ExpLockHandleTableEntry(HandleTable, HandleTableEntry))
1370 {
1371 /* Increase required buffer size */
1372 *ReqSize += sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO);
1373
1374 /* Check user's buffer size */
1375 if (*ReqSize > Size)
1376 {
1378 }
1379 else
1380 {
1381 POBJECT_HEADER ObjectHeader = ObpGetHandleObject(HandleTableEntry);
1382
1383 /* Filling handle information */
1384 HandleInformation->Handles[Index].UniqueProcessId =
1385 (USHORT)(ULONG_PTR) HandleTable->UniqueProcessId;
1386
1387 HandleInformation->Handles[Index].CreatorBackTraceIndex = 0;
1388
1389#if 0 /* FIXME!!! Type field corrupted */
1390 HandleInformation->Handles[Index].ObjectTypeIndex =
1391 (UCHAR) ObjectHeader->Type->Index;
1392#else
1393 HandleInformation->Handles[Index].ObjectTypeIndex = 0;
1394#endif
1395
1396 HandleInformation->Handles[Index].HandleAttributes =
1397 HandleTableEntry->ObAttributes & OBJ_HANDLE_ATTRIBUTES;
1398
1399 HandleInformation->Handles[Index].HandleValue =
1400 (USHORT)(ULONG_PTR) Handle.GenericHandleOverlay;
1401
1402 HandleInformation->Handles[Index].Object = &ObjectHeader->Body;
1403
1404 HandleInformation->Handles[Index].GrantedAccess =
1405 HandleTableEntry->GrantedAccess;
1406
1407 ++Index;
1408 }
1409
1410 /* Unlock it */
1411 ExUnlockHandleTableEntry(HandleTable, HandleTableEntry);
1412 }
1413 }
1414
1415 /* Go to the next entry */
1416 Handle.Value += sizeof(HANDLE);
1417 }
1418 }
1419
1420 /* Release the lock */
1422
1423 /* Leave the critical region */
1425
1426 /* Release the locked user buffer */
1428
1429 return Status;
1430}
struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO SYSTEM_HANDLE_TABLE_ENTRY_INFO

◆ QSI_DEF() [18/55]

Definition at line 1526 of file sysinfo.c.

1527{
1528 PKPRCB Prcb;
1529 LONG i;
1530 ULONG ti;
1532
1534 {
1536 }
1537
1538 ti = KeQueryTimeIncrement();
1539
1540 for (i = 0; i < KeNumberProcessors; i++)
1541 {
1542 Prcb = KiProcessorBlock[i];
1544 sii->DpcCount = Prcb->DpcData[0].DpcCount;
1545 sii->DpcRate = Prcb->DpcRequestRate;
1546 sii->TimeIncrement = ti;
1547 sii->DpcBypassCount = 0;
1548 sii->ApcBypassCount = 0;
1549 sii++;
1550 }
1551
1552 return STATUS_SUCCESS;
1553}
struct _SYSTEM_INTERRUPT_INFORMATION * PSYSTEM_INTERRUPT_INFORMATION
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
long LONG
Definition: pedump.c:60
ULONG DpcCount
Definition: ketypes.h:860
KDPC_DATA DpcData[2]
Definition: ketypes.h:749
ULONG DpcRequestRate
Definition: ketypes.h:757

◆ QSI_DEF() [19/55]

Definition at line 1822 of file sysinfo.c.

1823{
1825
1826#if (NTDDI_VERSION >= NTDDI_VISTA)
1827 *ReqSize = sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION);
1828#endif
1829
1831 {
1833 }
1834
1837
1838#if (NTDDI_VERSION < NTDDI_VISTA)
1839 *ReqSize = sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION);
1840#endif
1841
1842 return STATUS_SUCCESS;
1843}
struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION SYSTEM_KERNEL_DEBUGGER_INFORMATION
struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION * PSYSTEM_KERNEL_DEBUGGER_INFORMATION
#define KD_DEBUGGER_ENABLED
Definition: kdfuncs.h:130
#define KD_DEBUGGER_NOT_PRESENT
Definition: kdfuncs.h:133

◆ QSI_DEF() [20/55]

QSI_DEF ( SystemLegacyDriverInformation  )

Definition at line 2060 of file sysinfo.c.

2061{
2062 /* FIXME */
2063 DPRINT1("NtQuerySystemInformation - SystemLegacyDriverInformation not implemented\n");
2065}

◆ QSI_DEF() [21/55]

QSI_DEF ( SystemLocksInformation  )

Definition at line 1272 of file sysinfo.c.

1273{
1274 /* FIXME */
1275 DPRINT1("NtQuerySystemInformation - SystemLocksInformation not implemented\n");
1277}

◆ QSI_DEF() [22/55]

Definition at line 2637 of file sysinfo.c.

2638{
2639 LONG i;
2640 PKPRCB Prcb;
2641 KAFFINITY CurrentProc;
2643 ULONG DataSize = 0, ProcessorFlags;
2645
2646 /* First, browse active processors, thanks to the map */
2647 i = 0;
2648 CurrentInfo = Buffer;
2649 CurrentProc = KeActiveProcessors;
2650 do
2651 {
2652 /* If current processor is active and is main in case of HT/MC, return it */
2653 Prcb = KiProcessorBlock[i];
2654 if ((CurrentProc & 1) &&
2655 Prcb == Prcb->MultiThreadSetMaster)
2656 {
2657 /* Assume processor can do HT or multicore */
2658 ProcessorFlags = 1;
2659
2660 /* If set is the same for PRCB and multithread, then
2661 * actually, the processor is single core
2662 */
2663 if (Prcb->SetMember == Prcb->MultiThreadProcessorSet)
2664 {
2665 ProcessorFlags = 0;
2666 }
2667
2668 /* Check we have enough room to return */
2670 if (DataSize > Size)
2671 {
2673 }
2674 else
2675 {
2676 /* Zero output and return */
2678 CurrentInfo->ProcessorMask = Prcb->MultiThreadProcessorSet;
2679
2680 /* Processor core needs 1 if HT/MC is supported */
2681 CurrentInfo->Relationship = RelationProcessorCore;
2682 CurrentInfo->ProcessorCore.Flags = ProcessorFlags;
2683 ++CurrentInfo;
2684 }
2685 }
2686
2687 /* Move to the next proc */
2688 CurrentProc >>= 1;
2689 ++i;
2690 /* Loop while there's someone in the bitmask */
2691 } while (CurrentProc != 0);
2692
2693 /* Now, return the NUMA nodes */
2694 for (i = 0; i < KeNumberNodes; ++i)
2695 {
2696 /* Check we have enough room to return */
2698 if (DataSize > Size)
2699 {
2701 }
2702 else
2703 {
2704 /* Zero output and return */
2706 CurrentInfo->ProcessorMask = KeActiveProcessors;
2707
2708 /* NUMA node needs its ID */
2709 CurrentInfo->Relationship = RelationNumaNode;
2710 CurrentInfo->NumaNode.NodeNumber = i;
2711 ++CurrentInfo;
2712 }
2713 }
2714
2715 *ReqSize = DataSize;
2716
2717 return Status;
2718}
ULONG_PTR KAFFINITY
Definition: compat.h:85
UCHAR KeNumberNodes
Definition: krnlinit.c:40
struct _KPRCB * MultiThreadSetMaster
Definition: ketypes.h:826
UINT64 SetMember
Definition: ketypes.h:651
UINT64 MultiThreadProcessorSet
Definition: ketypes.h:825
LOGICAL_PROCESSOR_RELATIONSHIP Relationship
Definition: ketypes.h:99
struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION::@4104::@4106 NumaNode
struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION::@4104::@4105 ProcessorCore
@ RelationNumaNode
Definition: ketypes.h:83
@ RelationProcessorCore
Definition: ketypes.h:82
struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION SYSTEM_LOGICAL_PROCESSOR_INFORMATION

◆ QSI_DEF() [23/55]

Definition at line 2153 of file sysinfo.c.

2154{
2157 PMDL Mdl;
2158 ULONG MaxCount, Remaining;
2159 KIRQL OldIrql;
2161
2162 /* First we need to lock down the memory, since we are going to access it
2163 at high IRQL */
2166 Size,
2169 (PVOID*)&Info,
2170 &Mdl);
2171 if (!NT_SUCCESS(Status))
2172 {
2173 DPRINT1("Failed to lock the user buffer: 0x%lx\n", Status);
2174 return Status;
2175 }
2176
2177 /* Calculate how many items we can store */
2178 Remaining = MaxCount = Size / sizeof(SYSTEM_LOOKASIDE_INFORMATION);
2179 if (Remaining == 0)
2180 {
2181 goto Leave;
2182 }
2183
2184 /* Copy info from pool lookaside lists */
2186 &Remaining,
2188 FALSE);
2189 if (Remaining == 0)
2190 {
2191 goto Leave;
2192 }
2193
2194 /* Copy info from system lookaside lists */
2196 &Remaining,
2198 TRUE);
2199 if (Remaining == 0)
2200 {
2201 goto Leave;
2202 }
2203
2204 /* Acquire spinlock for ExpNonPagedLookasideListHead */
2206
2207 /* Copy info from non-paged lookaside lists */
2209 &Remaining,
2211 TRUE);
2212
2213 /* Release spinlock for ExpNonPagedLookasideListHead */
2215
2216 if (Remaining == 0)
2217 {
2218 goto Leave;
2219 }
2220
2221 /* Acquire spinlock for ExpPagedLookasideListHead */
2223
2224 /* Copy info from paged lookaside lists */
2226 &Remaining,
2228 TRUE);
2229
2230 /* Release spinlock for ExpPagedLookasideListHead */
2232
2233Leave:
2234
2235 /* Release the locked user buffer */
2237
2238 /* Return the size of the actually written data */
2239 *ReqSize = (MaxCount - Remaining) * sizeof(SYSTEM_LOOKASIDE_INFORMATION);
2240 return STATUS_SUCCESS;
2241}
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
KSPIN_LOCK ExpPagedLookasideListLock
Definition: lookas.c:20
KSPIN_LOCK ExpNonPagedLookasideListLock
Definition: lookas.c:18
LIST_ENTRY ExpPagedLookasideListHead
Definition: lookas.c:19
LIST_ENTRY ExSystemLookasideListHead
Definition: lookas.c:21
LIST_ENTRY ExpNonPagedLookasideListHead
Definition: lookas.c:17
struct _SYSTEM_LOOKASIDE_INFORMATION SYSTEM_LOOKASIDE_INFORMATION
static VOID ExpCopyLookasideInformation(PSYSTEM_LOOKASIDE_INFORMATION *InfoPointer, PULONG RemainingPointer, PLIST_ENTRY ListHead, BOOLEAN ListUsesMisses)
Definition: sysinfo.c:2098
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

◆ QSI_DEF() [24/55]

QSI_DEF ( SystemModuleInformation  )

Definition at line 1250 of file sysinfo.c.

1251{
1253
1254 /* Acquire system module list lock */
1257
1258 /* Call the generic handler with the system module list */
1262 Size,
1263 ReqSize);
1264
1265 /* Release list lock and return status */
1268 return Status;
1269}
#define ExAcquireResourceExclusiveLite(res, wait)
Definition: env_spec_w32.h:615
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
NTSTATUS NTAPI ExpQueryModuleInformation(IN PLIST_ENTRY KernelModeList, IN PLIST_ENTRY UserModeList, OUT PRTL_PROCESS_MODULES Modules, IN ULONG Length, OUT PULONG ReturnLength)
Definition: sysinfo.c:91
LIST_ENTRY MmLoadedUserImageList
Definition: sysldr.c:22
LIST_ENTRY PsLoadedModuleList
Definition: sysldr.c:21
ERESOURCE PsLoadedModuleResource
Definition: sysldr.c:24

◆ QSI_DEF() [25/55]

Definition at line 1753 of file sysinfo.c.

1754{
1755 /* FIXME */
1756 DPRINT1("NtQuerySystemInformation - SystemNextEventIdInformation not implemented\n");
1758}

◆ QSI_DEF() [26/55]

Definition at line 1296 of file sysinfo.c.

1297{
1298 /* FIXME */
1299 DPRINT1("NtQuerySystemInformation - SystemNonPagedPoolInformation not implemented\n");
1301}

◆ QSI_DEF() [27/55]

Definition at line 2436 of file sysinfo.c.

2437{
2438 ULONG MaxEntries, Node;
2440
2441 /* Validate input size */
2442 if (Size < sizeof(ULONG))
2443 {
2445 }
2446
2447 /* Return highest node */
2448 NumaInformation->HighestNodeNumber = KeNumberNodes - 1;
2449
2450 /* Compute how much entries we will be able to put in output structure */
2451 MaxEntries = (Size - FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory)) / sizeof(ULONGLONG);
2452 /* Make sure we don't overflow KeNodeBlock */
2453 if (MaxEntries > KeNumberNodes)
2454 {
2455 MaxEntries = KeNumberNodes;
2456 }
2457
2458 /* If we have entries to write, and room for it */
2459 if (Size >= FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory) &&
2460 MaxEntries != 0)
2461 {
2462 /* Already set size we return */
2463 *ReqSize = FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, AvailableMemory) +
2464 MaxEntries * sizeof(ULONGLONG);
2465
2466 /* If we have a single entry (us), directly return MM information */
2467 if (MaxEntries == 1)
2468 {
2469 NumaInformation->AvailableMemory[0] = MmAvailablePages << PAGE_SHIFT;
2470 }
2471 else
2472 {
2473 /* Otherwise, for each node, return available bytes */
2474 for (Node = 0; Node < MaxEntries; ++Node)
2475 {
2476 NumaInformation->AvailableMemory[Node] = (KeNodeBlock[Node]->FreeCount[0] + KeNodeBlock[Node]->FreeCount[1]) << PAGE_SHIFT;
2477 }
2478 }
2479 }
2480 else
2481 {
2482 /* We only returned highest node number */
2483 *ReqSize = sizeof(ULONG);
2484 }
2485
2486 return STATUS_SUCCESS;
2487}
union node Node
Definition: types.h:1255
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
struct _SYSTEM_NUMA_INFORMATION * PSYSTEM_NUMA_INFORMATION
PKNODE KeNodeBlock[1]
Definition: krnlinit.c:39
PFN_NUMBER MmAvailablePages
Definition: freelist.c:26
ULONG_PTR FreeCount[2]
Definition: ketypes.h:896
ULONGLONG AvailableMemory[MAXIMUM_NUMA_NODES]
Definition: extypes.h:1409
Definition: dlist.c:348

◆ QSI_DEF() [28/55]

QSI_DEF ( SystemNumaProcessorMap  )

Definition at line 2366 of file sysinfo.c.

2367{
2368 ULONG MaxEntries, Node;
2370
2371 /* Validate input size */
2372 if (Size < sizeof(ULONG))
2373 {
2375 }
2376
2377 /* Return highest node */
2378 NumaInformation->HighestNodeNumber = KeNumberNodes - 1;
2379
2380 /* Compute how much entries we will be able to put in output structure */
2381 MaxEntries = (Size - FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask)) / sizeof(ULONGLONG);
2382 /* Make sure we don't overflow KeNodeBlock */
2383 if (MaxEntries > KeNumberNodes)
2384 {
2385 MaxEntries = KeNumberNodes;
2386 }
2387
2388 /* If we have entries to write, and room for it */
2389 if (Size >= FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask) &&
2390 MaxEntries != 0)
2391 {
2392 /* Already set size we return */
2393 *ReqSize = FIELD_OFFSET(SYSTEM_NUMA_INFORMATION, ActiveProcessorsAffinityMask) +
2394 MaxEntries * sizeof(ULONGLONG);
2395
2396 /* For each node, return processor mask */
2397 for (Node = 0; Node < MaxEntries; ++Node)
2398 {
2400 }
2401 }
2402 else
2403 {
2404 /* We only returned highest node number */
2405 *ReqSize = sizeof(ULONG);
2406 }
2407
2408 return STATUS_SUCCESS;
2409}
KAFFINITY ProcessorMask
Definition: ketypes.h:887
ULONGLONG ActiveProcessorsAffinityMask[MAXIMUM_NUMA_NODES]
Definition: extypes.h:1408

◆ QSI_DEF() [29/55]

QSI_DEF ( SystemObjectInformation  )

Definition at line 1433 of file sysinfo.c.

1434{
1435 /* FIXME */
1436 DPRINT1("NtQuerySystemInformation - SystemObjectInformation not implemented\n");
1438}

◆ QSI_DEF() [30/55]

QSI_DEF ( SystemObjectSecurityMode  )

Definition at line 2621 of file sysinfo.c.

2622{
2623 PULONG ObjectSecurityInfo = (PULONG)Buffer;
2624
2625 /* Validate input size */
2626 if (Size != sizeof(ULONG))
2627 {
2629 }
2630
2631 *ObjectSecurityInfo = ObpObjectSecurityMode;
2632
2633 return STATUS_SUCCESS;
2634}
ULONG ObpObjectSecurityMode
Definition: obinit.c:56

◆ QSI_DEF() [31/55]

Definition at line 1288 of file sysinfo.c.

1289{
1290 /* FIXME */
1291 DPRINT1("NtQuerySystemInformation - SystemPagedPoolInformation not implemented\n");
1293}

◆ QSI_DEF() [32/55]

Definition at line 1441 of file sysinfo.c.

1442{
1443 UNICODE_STRING FileName; /* FIXME */
1445
1446 if (Size < sizeof(SYSTEM_PAGEFILE_INFORMATION))
1447 {
1448 * ReqSize = sizeof(SYSTEM_PAGEFILE_INFORMATION);
1450 }
1451
1452 RtlInitUnicodeString(&FileName, NULL); /* FIXME */
1453
1454 /* FIXME */
1455 Spfi->NextEntryOffset = 0;
1456
1459 Spfi->PeakUsage = MiUsedSwapPages; /* FIXME */
1460 Spfi->PageFileName = FileName;
1461 return STATUS_SUCCESS;
1462}
struct _FileName FileName
Definition: fatprocs.h:897
struct _SYSTEM_PAGEFILE_INFORMATION SYSTEM_PAGEFILE_INFORMATION
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
UNICODE_STRING PageFileName
Definition: extypes.h:1075

◆ QSI_DEF() [33/55]

QSI_DEF ( SystemPathInformation  )

Definition at line 862 of file sysinfo.c.

863{
864 /*
865 * Since NT 3.51, this information class is trivially implemented.
866 * The path to the NT directory is now stored in KUSER_SHARED_DATA
867 * as the NtSystemRoot member.
868 * Windows Checked builds show the following message and break to
869 * the debugger before failing the function as not implemented.
870 */
871#if DBG
872 DPRINT1("EX: SystemPathInformation now available via SharedUserData\n");
873 // DbgBreakPoint(); // Not needed in ReactOS.
874#endif
876}

◆ QSI_DEF() [34/55]

Definition at line 676 of file sysinfo.c.

677{
678 LONG i;
679 ULONG IdleUser, IdleKernel;
680 PKPRCB Prcb;
683
685
686 *ReqSize = sizeof(SYSTEM_PERFORMANCE_INFORMATION);
687
688 /* Check user buffer's size */
690 {
692 }
693
695
696 IdleKernel = KeQueryRuntimeProcess(&TheIdleProcess->Pcb, &IdleUser);
704 for (i = 0; i < KeNumberProcessors; i ++)
705 {
706 Prcb = KiProcessorBlock[i];
707 if (Prcb)
708 {
715 }
716 }
717
719
721 /*
722 * Add up the full system total + pagefile.
723 * All this make Taskmgr happy but not sure it is the right numbers.
724 * This too, fixes some of GlobalMemoryStatusEx numbers.
725 */
727
729 Spi->PageFaultCount = 0; /* FIXME */
730 Spi->CopyOnWriteCount = 0; /* FIXME */
731 Spi->TransitionCount = 0; /* FIXME */
732 Spi->CacheTransitionCount = 0; /* FIXME */
733 Spi->DemandZeroCount = 0; /* FIXME */
734 Spi->PageReadCount = 0; /* FIXME */
735 Spi->PageReadIoCount = 0; /* FIXME */
736 Spi->CacheReadCount = 0; /* FIXME */
737 Spi->CacheIoCount = 0; /* FIXME */
738 Spi->DirtyPagesWriteCount = 0; /* FIXME */
739 Spi->DirtyWriteIoCount = 0; /* FIXME */
740 Spi->MappedPagesWriteCount = 0; /* FIXME */
741 Spi->MappedWriteIoCount = 0; /* FIXME */
742
743 Spi->PagedPoolPages = 0;
744 Spi->NonPagedPoolPages = 0;
745 Spi->PagedPoolAllocs = 0;
746 Spi->PagedPoolFrees = 0;
747 Spi->PagedPoolLookasideHits = 0;
748 Spi->NonPagedPoolAllocs = 0;
749 Spi->NonPagedPoolFrees = 0;
752 &Spi->NonPagedPoolPages,
753 &Spi->PagedPoolAllocs,
754 &Spi->PagedPoolFrees,
756 &Spi->NonPagedPoolAllocs,
757 &Spi->NonPagedPoolFrees,
759 Spi->FreeSystemPtes = 0; /* FIXME */
760
761 Spi->ResidentSystemCodePage = 0; /* FIXME */
762
763 Spi->TotalSystemDriverPages = 0; /* FIXME */
764 Spi->Spare3Count = 0; /* FIXME */
765
767 Spi->ResidentPagedPoolPage = 0; /* FIXME */
768
769 Spi->ResidentSystemDriverPage = 0; /* FIXME */
770 Spi->CcFastReadNoWait = 0; /* FIXME */
771 Spi->CcFastReadWait = 0; /* FIXME */
772 Spi->CcFastReadResourceMiss = 0; /* FIXME */
773 Spi->CcFastReadNotPossible = 0; /* FIXME */
774
775 Spi->CcFastMdlReadNoWait = 0; /* FIXME */
776 Spi->CcFastMdlReadWait = 0; /* FIXME */
777 Spi->CcFastMdlReadResourceMiss = 0; /* FIXME */
778 Spi->CcFastMdlReadNotPossible = 0; /* FIXME */
779
782 Spi->CcMapDataNoWaitMiss = 0; /* FIXME */
783 Spi->CcMapDataWaitMiss = 0; /* FIXME */
784
788 Spi->CcPinReadNoWaitMiss = 0; /* FIXME */
789 Spi->CcPinReadWaitMiss = 0; /* FIXME */
790 Spi->CcCopyReadNoWait = 0; /* FIXME */
791 Spi->CcCopyReadWait = 0; /* FIXME */
792 Spi->CcCopyReadNoWaitMiss = 0; /* FIXME */
793 Spi->CcCopyReadWaitMiss = 0; /* FIXME */
794
795 Spi->CcMdlReadNoWait = 0; /* FIXME */
796 Spi->CcMdlReadWait = 0; /* FIXME */
797 Spi->CcMdlReadNoWaitMiss = 0; /* FIXME */
798 Spi->CcMdlReadWaitMiss = 0; /* FIXME */
799 Spi->CcReadAheadIos = 0; /* FIXME */
804
805 Spi->ContextSwitches = 0;
806 Spi->FirstLevelTbFills = 0;
807 Spi->SecondLevelTbFills = 0;
808 Spi->SystemCalls = 0;
809 for (i = 0; i < KeNumberProcessors; i ++)
810 {
811 Prcb = KiProcessorBlock[i];
812 if (Prcb)
813 {
815 Spi->FirstLevelTbFills += Prcb->KeFirstLevelTbFills;
816 Spi->SecondLevelTbFills += Prcb->KeSecondLevelTbFills;
817 Spi->SystemCalls += Prcb->KeSystemCalls;
818 }
819 }
820
821 return STATUS_SUCCESS;
822}
#define UInt32x32To64(a, b)
Definition: intsafe.h:252
ULONG IoWriteOperationCount
Definition: iomgr.c:41
LARGE_INTEGER IoReadTransferCount
Definition: iomgr.c:40
LARGE_INTEGER IoWriteTransferCount
Definition: iomgr.c:42
ULONG IoOtherOperationCount
Definition: iomgr.c:43
LARGE_INTEGER IoOtherTransferCount
Definition: iomgr.c:44
ULONG IoReadOperationCount
Definition: iomgr.c:39
ULONG CcLazyWritePages
Definition: lazywrite.c:20
ULONG CcLazyWriteIos
Definition: lazywrite.c:21
struct _SYSTEM_PERFORMANCE_INFORMATION * PSYSTEM_PERFORMANCE_INFORMATION
struct _SYSTEM_PERFORMANCE_INFORMATION SYSTEM_PERFORMANCE_INFORMATION
ULONG CcDataPages
Definition: copy.c:43
ULONG CcDataFlushes
Definition: copy.c:44
ULONG CcMapDataWait
Definition: pin.c:28
ULONG CcMapDataNoWait
Definition: pin.c:29
ULONG CcPinReadWait
Definition: pin.c:30
ULONG CcPinMappedDataCount
Definition: pin.c:32
ULONG CcPinReadNoWait
Definition: pin.c:31
VOID NTAPI ExQueryPoolUsage(OUT PULONG PagedPoolPages, OUT PULONG NonPagedPoolPages, OUT PULONG PagedPoolAllocs, OUT PULONG PagedPoolFrees, OUT PULONG PagedPoolLookasideHits, OUT PULONG NonPagedPoolAllocs, OUT PULONG NonPagedPoolFrees, OUT PULONG NonPagedPoolLookasideHits)
Definition: expool.c:1768
ULONG NTAPI KeQueryRuntimeProcess(IN PKPROCESS Process, OUT PULONG UserTime)
Definition: procobj.c:860
SIZE_T MmTotalCommittedPages
Definition: freelist.c:30
SIZE_T MmPeakCommitment
Definition: freelist.c:35
LARGE_INTEGER IoReadTransferCount
Definition: ketypes.h:736
LARGE_INTEGER IoOtherTransferCount
Definition: ketypes.h:738
ULONG KeSystemCalls
Definition: ketypes.h:720
LONG IoReadOperationCount
Definition: ketypes.h:733
LONG IoWriteOperationCount
Definition: ketypes.h:734
LONG IoOtherOperationCount
Definition: ketypes.h:735
LARGE_INTEGER IoWriteTransferCount
Definition: ketypes.h:737
LARGE_INTEGER IoOtherTransferCount
Definition: memtest.h:14
LARGE_INTEGER IoWriteTransferCount
Definition: memtest.h:13
LARGE_INTEGER IdleProcessTime
Definition: memtest.h:11
LARGE_INTEGER IoReadTransferCount
Definition: memtest.h:12
LONGLONG QuadPart
Definition: typedefs.h:114

◆ QSI_DEF() [35/55]

Definition at line 1761 of file sysinfo.c.

1762{
1763 /* FIXME */
1764 DPRINT1("NtQuerySystemInformation - SystemPerformanceTraceInformation not implemented\n");
1766}

◆ QSI_DEF() [36/55]

QSI_DEF ( SystemPoolTagInformation  )

Definition at line 1519 of file sysinfo.c.

1520{
1522 return ExGetPoolTagInfo(Buffer, Size, ReqSize);
1523}
NTSTATUS NTAPI ExGetPoolTagInfo(IN PSYSTEM_POOLTAG_INFORMATION SystemInformation, IN ULONG SystemInformationLength, IN OUT PULONG ReturnLength OPTIONAL)
Definition: expool.c:1356

◆ QSI_DEF() [37/55]

Definition at line 2412 of file sysinfo.c.

2413{
2414 /* FIXME */
2415 DPRINT1("NtQuerySystemInformation - SystemPrefetcherInformation not implemented\n");
2417}

◆ QSI_DEF() [38/55]

QSI_DEF ( SystemProcessInformation  )

Definition at line 879 of file sysinfo.c.

880{
883 PEPROCESS Process = NULL, SystemProcess;
884 PETHREAD CurrentThread;
886 ULONG CurrentSize;
887 USHORT ImageNameMaximumLength; // image name length in bytes
888 USHORT ImageNameLength;
889 PLIST_ENTRY CurrentEntry;
890 ULONG TotalSize = 0, ThreadsCount;
891 ULONG TotalUser, TotalKernel;
892 PUCHAR Current;
894 PUNICODE_STRING TempProcessImageName;
895 _SEH2_VOLATILE PUNICODE_STRING ProcessImageName = NULL;
896 PWCHAR szSrc;
897 BOOLEAN Overflow = FALSE;
898
900 {
901 /* scan the process list */
902
905
906 *ReqSize = sizeof(SYSTEM_PROCESS_INFORMATION);
907
908 /* Check for overflow */
909 if (Size < sizeof(SYSTEM_PROCESS_INFORMATION))
910 {
911 Overflow = TRUE;
912 }
913
914 /* Zero user's buffer */
915 if (!Overflow) RtlZeroMemory(Spi, Size);
916
917 SystemProcess = PsIdleProcess;
918 Process = SystemProcess;
919 Current = (PUCHAR) Spi;
920
921 do
922 {
923 SpiCurrent = (PSYSTEM_PROCESS_INFORMATION) Current;
924
925 /* Lock the Process */
927 ExAcquirePushLockShared(&Process->ProcessLock);
928
929 if ((Process->ProcessExiting) &&
930 (Process->Pcb.Header.SignalState) &&
931 !(Process->ActiveThreads) &&
932 (IsListEmpty(&Process->Pcb.ThreadListHead)))
933 {
934 DPRINT1("Process %p (%s:%p) is a zombie\n",
935 Process, Process->ImageFileName, Process->UniqueProcessId);
936 CurrentSize = 0;
937 ImageNameMaximumLength = 0;
938
939 /* Unlock the Process */
940 ExReleasePushLockShared(&Process->ProcessLock);
942 goto Skip;
943 }
944
945 ThreadsCount = 0;
946 CurrentEntry = Process->Pcb.ThreadListHead.Flink;
947 while (CurrentEntry != &Process->Pcb.ThreadListHead)
948 {
949 ThreadsCount++;
950 CurrentEntry = CurrentEntry->Flink;
951 }
952
953 // size of the structure for every process
954 CurrentSize = sizeof(SYSTEM_PROCESS_INFORMATION) + sizeof(SYSTEM_THREAD_INFORMATION) * ThreadsCount;
955 ImageNameLength = 0;
956 Status = SeLocateProcessImageName(Process, &TempProcessImageName);
957 ProcessImageName = TempProcessImageName;
958 szSrc = NULL;
959 if (NT_SUCCESS(Status) && (ProcessImageName->Length > 0))
960 {
961 szSrc = (PWCHAR)((PCHAR)ProcessImageName->Buffer + ProcessImageName->Length);
962 /* Loop the file name*/
963 while (szSrc > ProcessImageName->Buffer)
964 {
965 /* Make sure this isn't a backslash */
966 if (*--szSrc == OBJ_NAME_PATH_SEPARATOR)
967 {
968 szSrc++;
969 break;
970 }
971 else
972 {
973 ImageNameLength += sizeof(WCHAR);
974 }
975 }
976 }
977 if (!ImageNameLength && Process != PsIdleProcess)
978 {
979 ImageNameLength = (USHORT)strlen(Process->ImageFileName) * sizeof(WCHAR);
980 }
981
982 /* Round up the image name length as NT does */
983 if (ImageNameLength > 0)
984 ImageNameMaximumLength = ROUND_UP(ImageNameLength + sizeof(WCHAR), 8);
985 else
986 ImageNameMaximumLength = 0;
987
988 TotalSize += CurrentSize + ImageNameMaximumLength;
989
990 /* Check for overflow */
991 if (TotalSize > Size)
992 {
993 Overflow = TRUE;
994 }
995
996 /* Fill system information */
997 if (!Overflow)
998 {
999 SpiCurrent->NextEntryOffset = CurrentSize + ImageNameMaximumLength; // relative offset to the beginning of the next structure
1000 SpiCurrent->NumberOfThreads = ThreadsCount;
1001 SpiCurrent->CreateTime = Process->CreateTime;
1002 SpiCurrent->ImageName.Length = ImageNameLength;
1003 SpiCurrent->ImageName.MaximumLength = ImageNameMaximumLength;
1004 SpiCurrent->ImageName.Buffer = (void*)(Current + CurrentSize);
1005
1006 /* Copy name to the end of the struct */
1007 if(Process != PsIdleProcess)
1008 {
1009 if (szSrc)
1010 {
1011 RtlCopyMemory(SpiCurrent->ImageName.Buffer, szSrc, SpiCurrent->ImageName.Length);
1012 }
1013 else
1014 {
1015 RtlInitAnsiString(&ImageName, Process->ImageFileName);
1017 if (!NT_SUCCESS(Status))
1018 {
1019 SpiCurrent->ImageName.Length = 0;
1020 }
1021 }
1022 }
1023 else
1024 {
1025 RtlInitUnicodeString(&SpiCurrent->ImageName, NULL);
1026 }
1027
1028 SpiCurrent->BasePriority = Process->Pcb.BasePriority;
1029 SpiCurrent->UniqueProcessId = Process->UniqueProcessId;
1030 SpiCurrent->InheritedFromUniqueProcessId = Process->InheritedFromUniqueProcessId;
1031
1032 /* PsIdleProcess shares its handle table with PsInitialSystemProcess,
1033 * so return the handle count for System only, not Idle one. */
1035
1036 SpiCurrent->PeakVirtualSize = Process->PeakVirtualSize;
1037 SpiCurrent->VirtualSize = Process->VirtualSize;
1038 SpiCurrent->PageFaultCount = Process->Vm.PageFaultCount;
1039 SpiCurrent->PeakWorkingSetSize = Process->Vm.PeakWorkingSetSize;
1040 SpiCurrent->WorkingSetSize = Process->Vm.WorkingSetSize;
1041 SpiCurrent->QuotaPeakPagedPoolUsage = Process->QuotaPeak[PsPagedPool];
1042 SpiCurrent->QuotaPagedPoolUsage = Process->QuotaUsage[PsPagedPool];
1043 SpiCurrent->QuotaPeakNonPagedPoolUsage = Process->QuotaPeak[PsNonPagedPool];
1044 SpiCurrent->QuotaNonPagedPoolUsage = Process->QuotaUsage[PsNonPagedPool];
1045 SpiCurrent->PagefileUsage = Process->QuotaUsage[PsPageFile];
1046 SpiCurrent->PeakPagefileUsage = Process->QuotaPeak[PsPageFile];
1047 SpiCurrent->PrivatePageCount = Process->CommitCharge;
1048 ThreadInfo = (PSYSTEM_THREAD_INFORMATION)(SpiCurrent + 1);
1049
1050 CurrentEntry = Process->Pcb.ThreadListHead.Flink;
1051 while (CurrentEntry != &Process->Pcb.ThreadListHead)
1052 {
1053 CurrentThread = CONTAINING_RECORD(CurrentEntry, ETHREAD, Tcb.ThreadListEntry);
1054
1055 ThreadInfo->KernelTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.KernelTime, KeMaximumIncrement);
1056 ThreadInfo->UserTime.QuadPart = UInt32x32To64(CurrentThread->Tcb.UserTime, KeMaximumIncrement);
1057 ThreadInfo->CreateTime.QuadPart = CurrentThread->CreateTime.QuadPart;
1058 ThreadInfo->WaitTime = CurrentThread->Tcb.WaitTime;
1059 ThreadInfo->StartAddress = (PVOID) CurrentThread->StartAddress;
1060 ThreadInfo->ClientId = CurrentThread->Cid;
1061 ThreadInfo->Priority = CurrentThread->Tcb.Priority;
1062 ThreadInfo->BasePriority = CurrentThread->Tcb.BasePriority;
1063 ThreadInfo->ContextSwitches = CurrentThread->Tcb.ContextSwitches;
1064 ThreadInfo->ThreadState = CurrentThread->Tcb.State;
1065 ThreadInfo->WaitReason = CurrentThread->Tcb.WaitReason;
1066
1067 ThreadInfo++;
1068 CurrentEntry = CurrentEntry->Flink;
1069 }
1070
1071 /* Query total user/kernel times of a process */
1072 TotalKernel = KeQueryRuntimeProcess(&Process->Pcb, &TotalUser);
1073 SpiCurrent->UserTime.QuadPart = UInt32x32To64(TotalUser, KeMaximumIncrement);
1074 SpiCurrent->KernelTime.QuadPart = UInt32x32To64(TotalKernel, KeMaximumIncrement);
1075 }
1076
1077 if (ProcessImageName)
1078 {
1079 /* Release the memory allocated by SeLocateProcessImageName */
1080 ExFreePoolWithTag(ProcessImageName, TAG_SEPA);
1081 ProcessImageName = NULL;
1082 }
1083
1084 /* Unlock the Process */
1085 ExReleasePushLockShared(&Process->ProcessLock);
1087
1088 /* Handle idle process entry */
1089Skip:
1091
1093 ThreadsCount = 0;
1094 if ((Process == SystemProcess) || (Process == NULL))
1095 {
1096 if (!Overflow)
1097 SpiCurrent->NextEntryOffset = 0;
1098 break;
1099 }
1100 else
1101 Current += CurrentSize + ImageNameMaximumLength;
1102 } while ((Process != SystemProcess) && (Process != NULL));
1103
1104 if(Process != NULL)
1107 }
1109 {
1110 if(Process != NULL)
1112 if (ProcessImageName)
1113 {
1114 /* Release the memory allocated by SeLocateProcessImageName */
1115 ExFreePoolWithTag(ProcessImageName, TAG_SEPA);
1116 }
1117
1119 }
1120 _SEH2_END
1121
1122 if (Overflow)
1124
1125 *ReqSize = TotalSize;
1126 return Status;
1127}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
@ PsNonPagedPool
Definition: pstypes.h:1022
@ PsPageFile
Definition: pstypes.h:1024
@ PsPagedPool
Definition: pstypes.h:1023
struct _ThreadInfo ThreadInfo
static const char * ImageName
Definition: image.c:34
struct _SYSTEM_THREAD_INFORMATION * PSYSTEM_THREAD_INFORMATION
struct _SYSTEM_PROCESS_INFORMATION * PSYSTEM_PROCESS_INFORMATION
struct _SYSTEM_PROCESS_INFORMATION SYSTEM_PROCESS_INFORMATION
NTSTATUS NTAPI SeLocateProcessImageName(_In_ PEPROCESS Process, _Out_ PUNICODE_STRING *ProcessImageName)
Finds the process image name of a specific process.
Definition: audit.c:199
ULONG NTAPI ObGetProcessHandleCount(IN PEPROCESS Process)
Definition: obhandle.c:56
PEPROCESS NTAPI PsGetNextProcess(IN PEPROCESS OldProcess OPTIONAL)
Definition: process.c:128
#define _SEH2_VOLATILE
Definition: pseh2_64.h:169
PKSTART_ROUTINE StartAddress
Definition: pstypes.h:1156
KTHREAD Tcb
Definition: pstypes.h:1104
CLIENT_ID Cid
Definition: pstypes.h:1129
LARGE_INTEGER CreateTime
Definition: pstypes.h:1105
LIST_ENTRY ThreadListEntry
Definition: pstypes.h:1159
SCHAR Priority
Definition: ketypes.h:1782
ULONG KernelTime
Definition: ketypes.h:1987
CHAR BasePriority
Definition: ketypes.h:1917
ULONG WaitTime
Definition: ketypes.h:1875
UCHAR WaitReason
Definition: ketypes.h:1964
ULONG ContextSwitches
Definition: ketypes.h:1788
ULONG UserTime
Definition: ketypes.h:2003
volatile UCHAR State
Definition: ketypes.h:1789
LARGE_INTEGER UserTime
Definition: extypes.h:900
UNICODE_STRING ImageName
Definition: extypes.h:902
LARGE_INTEGER CreateTime
Definition: extypes.h:899
LARGE_INTEGER KernelTime
Definition: extypes.h:901
HANDLE InheritedFromUniqueProcessId
Definition: extypes.h:905
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TAG_SEPA
Definition: tag.h:156
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint16_t * PWCHAR
Definition: typedefs.h:56
unsigned char * PUCHAR
Definition: typedefs.h:53
#define ObDereferenceObject
Definition: obfuncs.h:203

◆ QSI_DEF() [39/55]

QSI_DEF ( SystemProcessorIdleInformation  )

Definition at line 2045 of file sysinfo.c.

2046{
2048
2050 {
2052 }
2053
2054 /* FIXME */
2055 DPRINT1("NtQuerySystemInformation - SystemPowerInformation not implemented\n");
2057}
struct _PROCESSOR_POWER_INFORMATION PROCESSOR_POWER_INFORMATION

◆ QSI_DEF() [40/55]

Definition at line 647 of file sysinfo.c.

648{
651
652 *ReqSize = sizeof(SYSTEM_PROCESSOR_INFORMATION);
653
654 /* Check user buffer's size */
656 {
658 }
662#if (NTDDI_VERSION < NTDDI_WIN8)
663 Spi->Reserved = 0;
664#else
665 Spi->MaximumProcessors = 0;
666#endif
668
669 DPRINT("Arch %u Level %u Rev 0x%x\n", Spi->ProcessorArchitecture,
671
672 return STATUS_SUCCESS;
673}
struct _SYSTEM_PROCESSOR_INFORMATION * PSYSTEM_PROCESSOR_INFORMATION
struct _SYSTEM_PROCESSOR_INFORMATION SYSTEM_PROCESSOR_INFORMATION
ULONG KeFeatureBits
Definition: krnlinit.c:22
USHORT KeProcessorLevel
Definition: krnlinit.c:20
USHORT KeProcessorRevision
Definition: krnlinit.c:21
USHORT KeProcessorArchitecture
Definition: krnlinit.c:19

◆ QSI_DEF() [41/55]

Definition at line 1165 of file sysinfo.c.

1166{
1169
1170 LONG i;
1171 ULONG TotalTime;
1172 PKPRCB Prcb;
1173
1175
1176 /* Check user buffer's size */
1177 if (Size < *ReqSize)
1178 {
1180 }
1181
1182 for (i = 0; i < KeNumberProcessors; i++)
1183 {
1184 /* Get the PRCB on this processor */
1185 Prcb = KiProcessorBlock[i];
1186
1187 /* Calculate total user and kernel times */
1188 TotalTime = Prcb->IdleThread->KernelTime + Prcb->IdleThread->UserTime;
1194 Spi->InterruptCount = Prcb->InterruptCount;
1195 Spi++;
1196 }
1197
1198 return STATUS_SUCCESS;
1199}
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION * PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
ULONG InterruptTime
Definition: ketypes.h:809
ULONG InterruptCount
Definition: ketypes.h:805
ULONG DpcTime
Definition: ketypes.h:808

◆ QSI_DEF() [42/55]

Definition at line 2314 of file sysinfo.c.

2315{
2316 /* Check user buffer's size */
2317 if (Size != sizeof(ULONG_PTR)) return STATUS_INFO_LENGTH_MISMATCH;
2318
2320
2321 if (ReqSize) *ReqSize = sizeof(ULONG_PTR);
2322
2323 return STATUS_SUCCESS;
2324}
#define MmSystemRangeStart
Definition: mm.h:32
uint32_t * PULONG_PTR
Definition: typedefs.h:65

◆ QSI_DEF() [43/55]

Definition at line 2428 of file sysinfo.c.

2429{
2430 /* FIXME */
2431 DPRINT1("NtQuerySystemInformation - SystemRecommendedSharedDataAlignment not implemented\n");
2433}

◆ QSI_DEF() [44/55]

Definition at line 1888 of file sysinfo.c.

1889{
1891
1892 *ReqSize = sizeof(SYSTEM_REGISTRY_QUOTA_INFORMATION);
1894 {
1896 }
1897
1898 DPRINT1("Faking max registry size of 32 MB\n");
1899 srqi->RegistryQuotaAllowed = 0x2000000;
1900 srqi->RegistryQuotaUsed = 0x200000;
1901 srqi->PagedPoolSize = 0x200000;
1902
1903 return STATUS_SUCCESS;
1904}
struct _SYSTEM_REGISTRY_QUOTA_INFORMATION SYSTEM_REGISTRY_QUOTA_INFORMATION
struct _SYSTEM_REGISTRY_QUOTA_INFORMATION * PSYSTEM_REGISTRY_QUOTA_INFORMATION

◆ QSI_DEF() [45/55]

QSI_DEF ( SystemSessionInformation  )

Definition at line 2306 of file sysinfo.c.

2307{
2308 /* FIXME */
2309 DPRINT1("NtQuerySystemInformation - SystemSessionInformation not implemented\n");
2311}

◆ QSI_DEF() [46/55]

Definition at line 2350 of file sysinfo.c.

2351{
2352 /* FIXME */
2353 DPRINT1("NtQuerySystemInformation - SystemSessionProcessInformation not implemented\n");
2355}

◆ QSI_DEF() [47/55]

Definition at line 1280 of file sysinfo.c.

1281{
1282 /* FIXME */
1283 DPRINT1("NtQuerySystemInformation - SystemStackTraceInformation not implemented\n");
1285}

◆ QSI_DEF() [48/55]

Definition at line 1745 of file sysinfo.c.

1746{
1747 /* FIXME */
1748 DPRINT1("NtQuerySystemInformation - SystemSummaryMemoryInformation not implemented\n");
1750}

◆ QSI_DEF() [49/55]

Definition at line 1684 of file sysinfo.c.

1685{
1688
1689 /* Check if enough storage was provided */
1691 {
1692 * ReqSize = sizeof(SYSTEM_QUERY_TIME_ADJUST_INFORMATION);
1694 }
1695
1696 /* Give time values to our caller */
1698 TimeInfo->TimeAdjustment = KeTimeAdjustment;
1699 TimeInfo->Enable = !KiTimeAdjustmentEnabled;
1700
1701 return STATUS_SUCCESS;
1702}
struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION * PSYSTEM_QUERY_TIME_ADJUST_INFORMATION
struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION SYSTEM_QUERY_TIME_ADJUST_INFORMATION
BOOLEAN KiTimeAdjustmentEnabled
Definition: time.c:19
ULONG KeTimeAdjustment
Definition: time.c:18

◆ QSI_DEF() [50/55]

Definition at line 825 of file sysinfo.c.

826{
828 LARGE_INTEGER CurrentTime;
829
830 /* Set amount of written information to 0 */
831 *ReqSize = 0;
832
833 /* Check user buffer's size */
835 {
837 }
838
839 /* Get current time */
840 KeQuerySystemTime(&CurrentTime);
841
842 /* Zero local buffer */
844
845 /* Fill local time structure */
846 Sti.BootTime= KeBootTime;
847 Sti.CurrentTime = CurrentTime;
850 Sti.Reserved = 0;
851
852 /* Copy as much as requested by caller */
853 RtlCopyMemory(Buffer, &Sti, Size);
854
855 /* Set amount of information we copied */
856 *ReqSize = Size;
857
858 return STATUS_SUCCESS;
859}
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
LARGE_INTEGER ExpTimeZoneBias
Definition: time.c:23
ULONG ExpTimeZoneId
Definition: time.c:25
LARGE_INTEGER KeBootTime
Definition: clock.c:17
LARGE_INTEGER TimeZoneBias
Definition: extypes.h:859
LARGE_INTEGER CurrentTime
Definition: extypes.h:858

◆ QSI_DEF() [51/55]

QSI_DEF ( SystemVdmBopInformation  )

Definition at line 1473 of file sysinfo.c.

1474{
1475 /* FIXME */
1476 DPRINT1("NtQuerySystemInformation - SystemVdmBopInformation not implemented\n");
1478}

◆ QSI_DEF() [52/55]

Definition at line 1465 of file sysinfo.c.

1466{
1467 /* FIXME */
1468 DPRINT1("NtQuerySystemInformation - SystemVdmInstemulInformation not implemented\n");
1470}

◆ QSI_DEF() [53/55]

QSI_DEF ( SystemVerifierAddDriverInformation  )

Definition at line 2029 of file sysinfo.c.

2030{
2031 /* FIXME */
2032 DPRINT1("NtQuerySystemInformation - SystemVerifierAddDriverInformation not implemented\n");
2034}

◆ QSI_DEF() [54/55]

Definition at line 2327 of file sysinfo.c.

2328{
2329 /* FIXME */
2330 DPRINT1("NtQuerySystemInformation - SystemVerifierInformation not implemented\n");
2332}

◆ QSI_DEF() [55/55]

QSI_DEF ( SystemVerifierRemoveDriverInformation  )

Definition at line 2037 of file sysinfo.c.

2038{
2039 /* FIXME */
2040 DPRINT1("NtQuerySystemInformation - SystemVerifierRemoveDriverInformation not implemented\n");
2042}

◆ SSI_DEF() [1/16]

Definition at line 2085 of file sysinfo.c.

2086{
2087 /* Check user buffer's size */
2088 if (Size < sizeof(RTL_TIME_ZONE_INFORMATION))
2089 {
2091 }
2092
2094}
NTSTATUS ExpSetTimeZoneInformation(PRTL_TIME_ZONE_INFORMATION TimeZoneInformation)
Definition: time.c:361

◆ SSI_DEF() [2/16]

Definition at line 1573 of file sysinfo.c.

1574{
1575 /* FIXME */
1576 DPRINT1("NtSetSystemInformation - SystemDpcBehaviourInformation not implemented\n");
1578}

◆ SSI_DEF() [3/16]

Definition at line 1914 of file sysinfo.c.

1915{
1918 PLDR_DATA_TABLE_ENTRY ModuleObject;
1920 PIMAGE_NT_HEADERS NtHeader;
1921 DRIVER_OBJECT Win32k;
1922 PDRIVER_INITIALIZE DriverInit;
1923 PVOID ImageBase;
1924 ULONG_PTR EntryPoint;
1925
1926 /* Validate the size */
1927 if (Size != sizeof(UNICODE_STRING)) return STATUS_INFO_LENGTH_MISMATCH;
1928
1929 /* Check who is calling */
1930 if (PreviousMode != KernelMode)
1931 {
1932 static const UNICODE_STRING Win32kName =
1933 RTL_CONSTANT_STRING(L"\\SystemRoot\\System32\\win32k.sys");
1934
1935 /* Make sure we can load drivers */
1937 {
1938 /* FIXME: We can't, fail */
1940 }
1941
1942 _SEH2_TRY
1943 {
1944 /* Probe and copy the unicode string */
1945 ProbeForRead(Buffer, sizeof(ImageName), 1);
1947
1948 /* Probe the string buffer */
1949 ProbeForRead(ImageName.Buffer, ImageName.Length, sizeof(WCHAR));
1950
1951 /* Check if we have the correct name (nothing else is allowed!) */
1952 if (!RtlEqualUnicodeString(&ImageName, &Win32kName, FALSE))
1953 {
1955 }
1956 }
1958 {
1960 }
1961 _SEH2_END;
1962
1963 /* Recursively call the function, so that we are from kernel mode */
1965 (PVOID)&Win32kName,
1966 sizeof(Win32kName));
1967 }
1968
1969 /* Load the image */
1971 NULL,
1972 NULL,
1973 0,
1974 (PVOID)&ModuleObject,
1975 &ImageBase);
1976
1977 if (!NT_SUCCESS(Status)) return Status;
1978
1979 /* Get the headers */
1980 NtHeader = RtlImageNtHeader(ImageBase);
1981 if (!NtHeader)
1982 {
1983 /* Fail */
1984 MmUnloadSystemImage(ModuleObject);
1986 }
1987
1988 /* Get the entrypoint */
1989 EntryPoint = NtHeader->OptionalHeader.AddressOfEntryPoint;
1990 EntryPoint += (ULONG_PTR)ImageBase;
1991 DriverInit = (PDRIVER_INITIALIZE)EntryPoint;
1992
1993 /* Create a dummy device */
1994 RtlZeroMemory(&Win32k, sizeof(Win32k));
1996 Win32k.DriverStart = ImageBase;
1997
1998 /* Call it */
1999 Status = (DriverInit)(&Win32k, NULL);
2001
2002 /* Unload if we failed */
2003 if (!NT_SUCCESS(Status)) MmUnloadSystemImage(ModuleObject);
2004 return Status;
2005}
#define SystemExtendServiceTableInformation
Definition: DriverTester.h:35
#define RtlImageNtHeader
Definition: compat.h:806
UNICODE_STRING * PUNICODE_STRING
Definition: env_spec_w32.h:373
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define UserMode
Definition: asm.h:35
NTSYSAPI NTSTATUS NTAPI ZwSetSystemInformation(_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass, _In_reads_bytes_(SystemInformationLength) PVOID SystemInformation, _In_ ULONG SystemInformationLength)
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
NTSTATUS NTAPI MmLoadSystemImage(IN PUNICODE_STRING FileName, IN PUNICODE_STRING NamePrefix OPTIONAL, IN PUNICODE_STRING LoadedName OPTIONAL, IN ULONG Flags, OUT PVOID *ModuleObject, OUT PVOID *ImageBaseAddress)
Definition: sysldr.c:2938
NTSTATUS NTAPI MmUnloadSystemImage(IN PVOID ImageHandle)
Definition: sysldr.c:945
const LUID SeLoadDriverPrivilege
Definition: priv.c:29
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:359
#define L(x)
Definition: ntvdm.h:50
PVOID DriverStart
Definition: iotypes.h:2279
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14
DRIVER_INITIALIZE * PDRIVER_INITIALIZE
Definition: iotypes.h:2235

◆ SSI_DEF() [4/16]

Definition at line 1507 of file sysinfo.c.

1508{
1509 if (Size < sizeof(SYSTEM_FILECACHE_INFORMATION))
1510 {
1512 }
1513 /* FIXME */
1514 DPRINT1("NtSetSystemInformation - SystemFileCacheInformation not implemented\n");
1516}

◆ SSI_DEF() [5/16]

SSI_DEF ( SystemFlagsInformation  )

Definition at line 1221 of file sysinfo.c.

1222{
1223 if (sizeof(SYSTEM_FLAGS_INFORMATION) != Size)
1224 {
1226 }
1227
1229 {
1230#if (NTDDI_VERSION < NTDDI_WIN7)
1232#else
1233 return STATUS_ACCESS_DENIED;
1234#endif
1235 }
1236
1238 return STATUS_SUCCESS;
1239}
const LUID SeDebugPrivilege
Definition: priv.c:39
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

◆ SSI_DEF() [6/16]

Definition at line 1610 of file sysinfo.c.

1611{
1614 PVOID ImageBase;
1615 PVOID SectionPointer;
1616 ULONG_PTR EntryPoint;
1618 ULONG DirSize;
1619 PIMAGE_NT_HEADERS NtHeader;
1620
1621 /* Validate size */
1622 if (Size != sizeof(SYSTEM_GDI_DRIVER_INFORMATION))
1623 {
1624 /* Incorrect buffer length, fail */
1626 }
1627
1628 /* Only kernel mode can call this function */
1630
1631 /* Load the driver */
1632 ImageName = DriverInfo->DriverName;
1634 NULL,
1635 NULL,
1636 0,
1637 &SectionPointer,
1638 &ImageBase);
1639 if (!NT_SUCCESS(Status)) return Status;
1640
1641 /* Return the export pointer */
1642 DriverInfo->ExportSectionPointer =
1644 TRUE,
1646 &DirSize);
1647
1648 /* Get the entrypoint */
1649 NtHeader = RtlImageNtHeader(ImageBase);
1650 EntryPoint = NtHeader->OptionalHeader.AddressOfEntryPoint;
1651 EntryPoint += (ULONG_PTR)ImageBase;
1652
1653 /* Save other data */
1654 DriverInfo->ImageAddress = ImageBase;
1655 DriverInfo->SectionPointer = SectionPointer;
1656 DriverInfo->EntryPoint = (PVOID)EntryPoint;
1657 DriverInfo->ImageLength = NtHeader->OptionalHeader.SizeOfImage;
1658
1659 /* All is good */
1660 return STATUS_SUCCESS;
1661}
#define IMAGE_DIRECTORY_ENTRY_EXPORT
Definition: compat.h:151
#define RtlImageDirectoryEntryToData
Definition: compat.h:809
DRIVER_INFORMATION DriverInfo
Definition: main.c:59

◆ SSI_DEF() [7/16]

Definition at line 2358 of file sysinfo.c.

2359{
2360 /* FIXME */
2361 DPRINT1("NtSetSystemInformation - SystemLoadGdiDriverInSystemSpaceInformation not implemented\n");
2363}

◆ SSI_DEF() [8/16]

SSI_DEF ( SystemPrioritySeperation  )

Definition at line 2008 of file sysinfo.c.

2009{
2010 /* Check if the size is correct */
2011 if (Size != sizeof(ULONG))
2012 {
2014 }
2015
2016 /* We need the TCB privilege */
2018 {
2020 }
2021
2022 /* Modify the quantum table */
2024
2025 return STATUS_SUCCESS;
2026}
const LUID SeTcbPrivilege
Definition: priv.c:26
VOID NTAPI PsChangeQuantumTable(IN BOOLEAN Immediate, IN ULONG PrioritySeparation)
Definition: process.c:235

◆ SSI_DEF() [9/16]

Definition at line 1906 of file sysinfo.c.

1907{
1908 /* FIXME */
1909 DPRINT1("NtSetSystemInformation - SystemRegistryQuotaInformation not implemented\n");
1911}

◆ SSI_DEF() [10/16]

SSI_DEF ( SystemSessionCreate  )

Definition at line 2260 of file sysinfo.c.

2261{
2265
2266 if (Size != sizeof(ULONG)) return STATUS_INFO_LENGTH_MISMATCH;
2267
2268 if (PreviousMode != KernelMode)
2269 {
2271 {
2273 }
2274
2276 }
2277
2280
2281 return Status;
2282}
NTSTATUS NTAPI MmSessionCreate(OUT PULONG SessionId)
Definition: session.c:827

◆ SSI_DEF() [11/16]

SSI_DEF ( SystemSessionDetach  )

Definition at line 2285 of file sysinfo.c.

2286{
2289
2290 if (Size != sizeof(ULONG)) return STATUS_INFO_LENGTH_MISMATCH;
2291
2292 if (PreviousMode != KernelMode)
2293 {
2295 {
2297 }
2298 }
2299
2301
2302 return MmSessionDelete(SessionId);
2303}
NTSTATUS NTAPI MmSessionDelete(IN ULONG SessionId)
Definition: session.c:887

◆ SSI_DEF() [12/16]

Definition at line 1704 of file sysinfo.c.

1705{
1709
1710 /* Check size of a buffer, it must match our expectations */
1713
1714 /* Check who is calling */
1715 if (PreviousMode != KernelMode)
1716 {
1717 /* Check access rights */
1719 {
1721 }
1722 }
1723
1724 /* FIXME: behaviour suggests the member be named 'Disable' */
1725 if (TimeInfo->Enable)
1726 {
1727 /* Disable time adjustment and set default value */
1730 }
1731 else
1732 {
1733 /* Check if a valid time adjustment value is given */
1734 if (TimeInfo->TimeAdjustment == 0) return STATUS_INVALID_PARAMETER_2;
1735
1736 /* Enable time adjustment and set the adjustment value */
1738 KeTimeAdjustment = TimeInfo->TimeAdjustment;
1739 }
1740
1741 return STATUS_SUCCESS;
1742}
struct _SYSTEM_SET_TIME_ADJUST_INFORMATION * PSYSTEM_SET_TIME_ADJUST_INFORMATION
const LUID SeSystemtimePrivilege
Definition: priv.c:31
#define STATUS_INVALID_PARAMETER_2
Definition: ntstatus.h:476

◆ SSI_DEF() [13/16]

Definition at line 2244 of file sysinfo.c.

2245{
2246 /* FIXME */
2247 DPRINT1("NtSetSystemInformation - SystemTimeSlipNotification not implemented\n");
2249}

◆ SSI_DEF() [14/16]

Definition at line 1664 of file sysinfo.c.

1665{
1666 PVOID *SectionPointer = Buffer;
1667
1668 /* Validate size */
1669 if (Size != sizeof(PVOID))
1670 {
1671 /* Incorrect length, fail */
1673 }
1674
1675 /* Only kernel mode can call this function */
1677
1678 /* Unload the image */
1679 MmUnloadSystemImage(*SectionPointer);
1680 return STATUS_SUCCESS;
1681}

◆ SSI_DEF() [15/16]

Definition at line 2334 of file sysinfo.c.

2335{
2336 /* FIXME */
2337 DPRINT1("NtSetSystemInformation - SystemVerifierInformation not implemented\n");
2339}

◆ SSI_DEF() [16/16]

SSI_DEF ( SystemVerifierThunkExtend  )

Definition at line 2342 of file sysinfo.c.

2343{
2344 /* FIXME */
2345 DPRINT1("NtSetSystemInformation - SystemVerifierThunkExtend not implemented\n");
2347}

Variable Documentation

◆ CallQS

QSSI_CALLS CallQS[]
static

Definition at line 2840 of file sysinfo.c.

Referenced by NtQuerySystemInformation(), and NtSetSystemInformation().

◆ ExpEnvironmentLock

FAST_MUTEX ExpEnvironmentLock

Definition at line 29 of file sysinfo.c.

Referenced by ExpInitSystemPhase0().

◆ ExpFirmwareTableProviderListHead

LIST_ENTRY ExpFirmwareTableProviderListHead

Definition at line 31 of file sysinfo.c.

Referenced by ExpInitSystemPhase0().

◆ ExpFirmwareTableResource

ERESOURCE ExpFirmwareTableResource

Definition at line 30 of file sysinfo.c.

Referenced by ExpInitSystemPhase0().

◆ HandleTableListHead

LIST_ENTRY HandleTableListHead
extern

Definition at line 18 of file handle.c.

Referenced by ExCreateHandleTable(), ExDupHandleTable(), ExpInitializeHandleTables(), and QSI_DEF().

◆ HandleTableListLock

EX_PUSH_LOCK HandleTableListLock
extern