12406 lines
502 KiB
C
12406 lines
502 KiB
C
/*
|
|
* Executive support library functions
|
|
*
|
|
* This file is part of System Informer.
|
|
*/
|
|
|
|
#ifndef _NTEXAPI_H
|
|
#define _NTEXAPI_H
|
|
|
|
typedef struct _TEB* PTEB;
|
|
typedef struct _COUNTED_REASON_CONTEXT* PCOUNTED_REASON_CONTEXT;
|
|
typedef struct _FILE_IO_COMPLETION_INFORMATION* PFILE_IO_COMPLETION_INFORMATION;
|
|
typedef struct _PORT_MESSAGE* PPORT_MESSAGE;
|
|
typedef struct _IMAGE_EXPORT_DIRECTORY* PIMAGE_EXPORT_DIRECTORY;
|
|
typedef struct _FILE_OBJECT* PFILE_OBJECT;
|
|
typedef struct _DEVICE_OBJECT* PDEVICE_OBJECT;
|
|
typedef struct _IRP* PIRP;
|
|
typedef struct _RTL_BITMAP* PRTL_BITMAP;
|
|
|
|
#if (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
//
|
|
// Thread execution
|
|
//
|
|
|
|
/**
|
|
* The NtDelayExecution routine delays the calling thread until a deadline or an allowed interruption.
|
|
* This is a scheduling delay, not a wait for an object's signal and not a precision clock.
|
|
*
|
|
* \param Alertable TRUE permits an alert or ordinary user APC to interrupt the
|
|
* delay; the APC runs on this thread. Retrying after an interruption is the caller's
|
|
* responsibility, including recomputing remaining time for a relative interval.
|
|
* \param DelayInterval Required readable LARGE_INTEGER; NULL does not mean an
|
|
* infinite delay. Units are 100 nanoseconds: negative values are relative intervals,
|
|
* positive values are absolute times since January 1, 1601 (UTC), and zero requests
|
|
* a scheduling yield. User input must be 4-byte aligned on x64 and its WoW64 forwarding path.
|
|
* The captured input is not updated with remaining time.
|
|
* \return STATUS_SUCCESS (0) on elapsed nonzero delay, STATUS_USER_APC (0xC0) or
|
|
* STATUS_ALERTED (0x101) for interruption. A zero interval can return either
|
|
* STATUS_SUCCESS or STATUS_NO_YIELD_PERFORMED (0x40000024). This also applies to
|
|
* an alertable zero interval when no APC or alert terminates it first.
|
|
* \remarks Expiration makes execution eligible, not necessarily immediate; other
|
|
* scheduling work can delay return. A yield does not prove another thread ran or
|
|
* completed useful work, and is not a replacement for synchronization. Do not
|
|
* treat STATUS_NO_YIELD_PERFORMED as failure or as a count of ready threads.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-sleepex
|
|
* \see RtlDelayExecution
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDelayExecution(
|
|
_In_ BOOLEAN Alertable,
|
|
_In_ PLARGE_INTEGER DelayInterval
|
|
);
|
|
|
|
//
|
|
// Firmware environment values
|
|
//
|
|
|
|
/**
|
|
* The NtQuerySystemEnvironmentValue routine retrieves the value of the specified firmware environment
|
|
* variable. The user account that the app is running under must have the SE_SYSTEM_ENVIRONMENT_NAME
|
|
* privilege.
|
|
*
|
|
* \param VariableName The name of the firmware environment variable. The pointer must not be NULL.
|
|
* \param VariableValue A pointer to a buffer that receives the value of the specified firmware environment variable.
|
|
* \param ValueLength The size of the \c VariableValue buffer, in bytes.
|
|
* \param ReturnLength If the function succeeds, the return length is the number of bytes stored in the \c VariableValue buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySystemEnvironmentValue(
|
|
_In_ PCUNICODE_STRING VariableName,
|
|
_Out_writes_bytes_(ValueLength) PWSTR VariableValue,
|
|
_In_ USHORT ValueLength,
|
|
_Out_opt_ PUSHORT ReturnLength
|
|
);
|
|
|
|
// The firmware environment variable is stored in non-volatile memory (e.g. NVRAM).
|
|
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
|
|
// The firmware environment variable can be accessed during boot service.
|
|
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
|
|
// The firmware environment variable can be accessed at runtime.
|
|
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
|
|
// Indicates hardware related errors encountered at runtime.
|
|
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
|
|
// Indicates an authentication requirement that must be met before writing to this firmware environment variable.
|
|
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
|
|
// Indicates authentication and time stamp requirements that must be met before writing to this firmware environment variable.
|
|
// When this attribute is set, the buffer, represented by Buffer, will begin with an instance of a complete (and serialized) EFI_VARIABLE_AUTHENTICATION_2 descriptor.
|
|
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
|
|
// Append an existing environment variable with the value of Buffer. If the firmware does not support the operation, the function returns ERROR_INVALID_FUNCTION.
|
|
#define EFI_VARIABLE_APPEND_WRITE 0x00000040
|
|
// The firmware environment variable will return metadata in addition to variable data.
|
|
#define EFI_VARIABLE_ENHANCED_AUTHENTICATED_ACCESS 0x00000080
|
|
|
|
/**
|
|
* The NtQuerySystemEnvironmentValueEx routine retrieves the value of the specified firmware environment
|
|
* variable and its attributes. The user account that the app is running under must have the
|
|
* SE_SYSTEM_ENVIRONMENT_NAME privilege.
|
|
*
|
|
* \param VariableName The name of the firmware environment variable. The pointer must not be NULL.
|
|
* \param VendorGuid The GUID that represents the namespace of the firmware environment variable.
|
|
* \param Buffer A pointer to a buffer that receives the value of the specified firmware environment variable.
|
|
* \param BufferLength The size of the \c Buffer, in bytes.
|
|
* \param Attributes Bitmask identifying UEFI variable attributes associated with the variable.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySystemEnvironmentValueEx(
|
|
_In_ PCUNICODE_STRING VariableName,
|
|
_In_ PCGUID VendorGuid,
|
|
_Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
|
|
_Inout_ PULONG BufferLength,
|
|
_Out_opt_ PULONG Attributes // EFI_VARIABLE_*
|
|
);
|
|
|
|
/**
|
|
* The NtSetSystemEnvironmentValue routine sets the value of the specified firmware environment variable. The
|
|
* user account that the app is running under must have the SE_SYSTEM_ENVIRONMENT_NAME privilege.
|
|
*
|
|
* \param VariableName The name of the firmware environment variable. The pointer must not be NULL.
|
|
* \param VariableValue A pointer to the new value for the firmware environment variable.
|
|
* If this parameter is zero, the firmware environment variable is deleted.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetSystemEnvironmentValue(
|
|
_In_ PCUNICODE_STRING VariableName,
|
|
_In_ PCUNICODE_STRING VariableValue
|
|
);
|
|
|
|
/**
|
|
* The NtSetSystemEnvironmentValueEx routine sets the value of the specified firmware environment variable and
|
|
* the attributes that indicate how this variable is stored and maintained. The user account that the app is
|
|
* running under must have the SE_SYSTEM_ENVIRONMENT_NAME privilege.
|
|
*
|
|
* \param VariableName The name of the firmware environment variable. The pointer must not be NULL.
|
|
* \param VendorGuid The GUID that represents the namespace of the firmware environment variable.
|
|
* \param Buffer A pointer to the new value for the firmware environment variable.
|
|
* \param BufferLength The size of the pValue buffer, in bytes.
|
|
* Unless the VARIABLE_ATTRIBUTE_APPEND_WRITE, VARIABLE_ATTRIBUTE_AUTHENTICATED_WRITE_ACCESS,
|
|
* or VARIABLE_ATTRIBUTE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS variable attribute is set via dwAttributes,
|
|
* setting this value to zero will result in the deletion of this variable.
|
|
* \param Attributes Bitmask to set UEFI variable attributes associated with the variable.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetSystemEnvironmentValueEx(
|
|
_In_ PCUNICODE_STRING VariableName,
|
|
_In_ PCGUID VendorGuid,
|
|
_In_reads_bytes_opt_(BufferLength) PVOID Buffer,
|
|
_In_ ULONG BufferLength, // 0 = delete variable
|
|
_In_ ULONG Attributes // EFI_VARIABLE_*
|
|
);
|
|
|
|
/**
|
|
* The SYSTEM_ENVIRONMENT_INFORMATION_CLASS enumeration defines the information classes for querying and setting firmware environment variables.
|
|
*/
|
|
typedef enum _SYSTEM_ENVIRONMENT_INFORMATION_CLASS
|
|
{
|
|
SystemEnvironmentNameInformation = 1, // q: VARIABLE_NAME
|
|
SystemEnvironmentValueInformation = 2, // q: VARIABLE_NAME_AND_VALUE
|
|
MaxSystemEnvironmentInfoClass
|
|
} SYSTEM_ENVIRONMENT_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The VARIABLE_NAME structure describes the name and vendor GUID of a firmware environment variable.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _VARIABLE_NAME
|
|
{
|
|
ULONG NextEntryOffset;
|
|
GUID VendorGuid;
|
|
WCHAR Name[ANYSIZE_ARRAY];
|
|
} VARIABLE_NAME, *PVARIABLE_NAME;
|
|
|
|
/**
|
|
* The VARIABLE_NAME_AND_VALUE structure describes the name, vendor GUID, and value of a firmware environment variable.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _VARIABLE_NAME_AND_VALUE
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG ValueOffset;
|
|
ULONG ValueLength;
|
|
ULONG Attributes;
|
|
GUID VendorGuid;
|
|
WCHAR Name[ANYSIZE_ARRAY];
|
|
//BYTE Value[ANYSIZE_ARRAY];
|
|
} VARIABLE_NAME_AND_VALUE, *PVARIABLE_NAME_AND_VALUE;
|
|
|
|
/**
|
|
* The NtEnumerateSystemEnvironmentValuesEx routine enumerates system environment values with extended information.
|
|
*
|
|
* \param InformationClass The class of system environment information to retrieve.
|
|
* \param Buffer Pointer to a buffer that receives the system environment values data.
|
|
* \param BufferLength Pointer to a ULONG variable that specifies the size of the Buffer on input.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtEnumerateSystemEnvironmentValuesEx(
|
|
_In_ ULONG InformationClass, // SYSTEM_ENVIRONMENT_INFORMATION_CLASS
|
|
_Out_ PVOID Buffer,
|
|
_Inout_ PULONG BufferLength
|
|
);
|
|
|
|
//
|
|
// EFI
|
|
//
|
|
|
|
// private
|
|
/**
|
|
* The BOOT_ENTRY structure describes a single boot entry in the firmware boot configuration.
|
|
*/
|
|
typedef struct _BOOT_ENTRY
|
|
{
|
|
ULONG Version;
|
|
ULONG Length;
|
|
ULONG Id;
|
|
ULONG Attributes;
|
|
ULONG FriendlyNameOffset;
|
|
ULONG BootFilePathOffset;
|
|
ULONG OsOptionsLength;
|
|
_Field_size_bytes_(OsOptionsLength) UCHAR OsOptions[1];
|
|
} BOOT_ENTRY, *PBOOT_ENTRY;
|
|
|
|
// private
|
|
/**
|
|
* The BOOT_ENTRY_LIST structure describes a linked list of boot entries.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _BOOT_ENTRY_LIST
|
|
{
|
|
ULONG NextEntryOffset;
|
|
BOOT_ENTRY BootEntry;
|
|
} BOOT_ENTRY_LIST, *PBOOT_ENTRY_LIST;
|
|
|
|
// private
|
|
/**
|
|
* The BOOT_OPTIONS structure describes the global boot options stored in the firmware boot configuration.
|
|
*/
|
|
typedef struct _BOOT_OPTIONS
|
|
{
|
|
ULONG Version;
|
|
ULONG Length;
|
|
ULONG Timeout;
|
|
ULONG CurrentBootEntryId;
|
|
ULONG NextBootEntryId;
|
|
_Field_size_bytes_(Length) WCHAR HeadlessRedirection[1];
|
|
} BOOT_OPTIONS, *PBOOT_OPTIONS;
|
|
|
|
// private
|
|
/**
|
|
* The FILE_PATH structure describes a file path used by the boot configuration.
|
|
*/
|
|
typedef struct _FILE_PATH
|
|
{
|
|
ULONG Version;
|
|
ULONG Length;
|
|
ULONG Type;
|
|
_Field_size_bytes_(Length) UCHAR FilePath[1];
|
|
} FILE_PATH, *PFILE_PATH;
|
|
|
|
// private
|
|
/**
|
|
* The EFI_DRIVER_ENTRY structure describes a single EFI driver entry in the firmware boot configuration.
|
|
*/
|
|
typedef struct _EFI_DRIVER_ENTRY
|
|
{
|
|
ULONG Version;
|
|
ULONG Length;
|
|
ULONG Id;
|
|
ULONG FriendlyNameOffset;
|
|
ULONG DriverFilePathOffset;
|
|
} EFI_DRIVER_ENTRY, *PEFI_DRIVER_ENTRY;
|
|
|
|
// private
|
|
/**
|
|
* The EFI_DRIVER_ENTRY_LIST structure describes a linked list of EFI driver entries.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _EFI_DRIVER_ENTRY_LIST
|
|
{
|
|
ULONG NextEntryOffset;
|
|
EFI_DRIVER_ENTRY DriverEntry;
|
|
} EFI_DRIVER_ENTRY_LIST, *PEFI_DRIVER_ENTRY_LIST;
|
|
|
|
/**
|
|
* The NtAddBootEntry routine adds a new boot entry to the system boot configuration.
|
|
*
|
|
* \param BootEntry A pointer to a BOOT_ENTRY structure that specifies the boot entry to be added.
|
|
* \param Id A pointer to a variable that receives the identifier of the new boot entry.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAddBootEntry(
|
|
_In_ PBOOT_ENTRY BootEntry,
|
|
_Out_opt_ PULONG Id
|
|
);
|
|
|
|
/**
|
|
* The NtDeleteBootEntry routine deletes an existing boot entry from the system boot configuration.
|
|
*
|
|
* \param Id The identifier of the boot entry to be deleted.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDeleteBootEntry(
|
|
_In_ ULONG Id
|
|
);
|
|
|
|
/**
|
|
* The NtModifyBootEntry routine modifies an existing boot entry in the system boot configuration.
|
|
*
|
|
* \param BootEntry A pointer to a BOOT_ENTRY structure that specifies the new boot entry information.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtModifyBootEntry(
|
|
_In_ PBOOT_ENTRY BootEntry
|
|
);
|
|
|
|
/**
|
|
* The NtEnumerateBootEntries routine retrieves information about all boot entries in the system boot configuration.
|
|
*
|
|
* \param Buffer A pointer to a buffer that receives the boot entries information.
|
|
* \param BufferLength A pointer to a variable that specifies the size of the buffer. On return, it contains the size of the data returned.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtEnumerateBootEntries(
|
|
_Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
|
|
_Inout_ PULONG BufferLength
|
|
);
|
|
|
|
/**
|
|
* The NtQueryBootEntryOrder routine retrieves the current boot entry order.
|
|
*
|
|
* \param Ids A pointer to a buffer that receives the identifiers of the boot entries in the current boot order.
|
|
* \param Count A pointer to a variable that specifies the number of entries in the buffer. On return, it contains the number of entries returned.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryBootEntryOrder(
|
|
_Out_writes_opt_(*Count) PULONG Ids,
|
|
_Inout_ PULONG Count
|
|
);
|
|
|
|
/**
|
|
* The NtSetBootEntryOrder routine sets the boot entry order.
|
|
*
|
|
* \param Ids A pointer to a buffer that specifies the identifiers of the boot entries in the desired boot order.
|
|
* \param Count The number of entries in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetBootEntryOrder(
|
|
_In_reads_(Count) PULONG Ids,
|
|
_In_ ULONG Count
|
|
);
|
|
|
|
/**
|
|
* The NtQueryBootOptions routine retrieves the current boot options.
|
|
*
|
|
* \param BootOptions A pointer to a buffer that receives the boot options.
|
|
* \param BootOptionsLength A pointer to a variable that specifies the size of the buffer. On return, it contains the size of the data returned.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryBootOptions(
|
|
_Out_writes_bytes_opt_(*BootOptionsLength) PBOOT_OPTIONS BootOptions,
|
|
_Inout_ PULONG BootOptionsLength
|
|
);
|
|
|
|
/**
|
|
* The NtSetBootOptions routine sets the boot options.
|
|
*
|
|
* \param BootOptions A pointer to a BOOT_OPTIONS structure that specifies the new boot options.
|
|
* \param FieldsToChange A bitmask that specifies which fields in the BOOT_OPTIONS structure are to be changed.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetBootOptions(
|
|
_In_ PBOOT_OPTIONS BootOptions,
|
|
_In_ ULONG FieldsToChange
|
|
);
|
|
|
|
/**
|
|
* The NtTranslateFilePath routine translates a file path from one format to another.
|
|
*
|
|
* \param InputFilePath A pointer to a FILE_PATH structure that specifies the input file path.
|
|
* \param OutputType The type of the output file path.
|
|
* \param OutputFilePath A pointer to a buffer that receives the translated file path.
|
|
* \param OutputFilePathLength A required pointer to the buffer size, in bytes. On return,
|
|
* it receives the required size even when OutputFilePath is NULL (a size-only query).
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtTranslateFilePath(
|
|
_In_ PFILE_PATH InputFilePath,
|
|
_In_ ULONG OutputType,
|
|
_Out_writes_bytes_opt_(*OutputFilePathLength) PFILE_PATH OutputFilePath,
|
|
_Inout_ PULONG OutputFilePathLength
|
|
);
|
|
|
|
/**
|
|
* The NtAddDriverEntry routine adds a new driver entry to the system boot configuration.
|
|
*
|
|
* \param DriverEntry A pointer to an EFI_DRIVER_ENTRY structure that specifies the driver entry to be added.
|
|
* \param Id A pointer to a variable that receives the identifier of the new driver entry.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAddDriverEntry(
|
|
_In_ PEFI_DRIVER_ENTRY DriverEntry,
|
|
_Out_opt_ PULONG Id
|
|
);
|
|
|
|
/**
|
|
* The NtDeleteDriverEntry routine deletes an existing driver entry from the system boot configuration.
|
|
*
|
|
* \param Id The identifier of the driver entry to be deleted.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDeleteDriverEntry(
|
|
_In_ ULONG Id
|
|
);
|
|
|
|
/**
|
|
* The NtModifyDriverEntry routine modifies an existing driver entry in the system boot configuration.
|
|
*
|
|
* \param DriverEntry A pointer to an EFI_DRIVER_ENTRY structure that specifies the new driver entry information.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtModifyDriverEntry(
|
|
_In_ PEFI_DRIVER_ENTRY DriverEntry
|
|
);
|
|
|
|
/**
|
|
* The NtEnumerateDriverEntries routine retrieves information about all driver entries in the system boot configuration.
|
|
*
|
|
* \param Buffer A pointer to a buffer that receives the driver entries information.
|
|
* \param BufferLength A pointer to a variable that specifies the size of the buffer. On return, it contains the size of the data returned.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtEnumerateDriverEntries(
|
|
_Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
|
|
_Inout_ PULONG BufferLength
|
|
);
|
|
|
|
/**
|
|
* The NtQueryDriverEntryOrder routine retrieves the current driver entry order.
|
|
*
|
|
* \param Ids A pointer to a buffer that receives the identifiers of the driver entries in the current driver order.
|
|
* \param Count A pointer to a variable that specifies the number of entries in the buffer. On return, it contains the number of entries returned.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryDriverEntryOrder(
|
|
_Out_writes_opt_(*Count) PULONG Ids,
|
|
_Inout_ PULONG Count
|
|
);
|
|
|
|
/**
|
|
* The NtSetDriverEntryOrder routine sets the driver entry order.
|
|
*
|
|
* \param Ids A pointer to a buffer that specifies the identifiers of the driver entries in the desired driver order.
|
|
* \param Count The number of entries in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetDriverEntryOrder(
|
|
_In_reads_(Count) PULONG Ids,
|
|
_In_ ULONG Count
|
|
);
|
|
|
|
/**
|
|
* The FILTER_BOOT_OPTION_OPERATION enumeration defines the operations that can be applied when filtering boot options.
|
|
*/
|
|
typedef enum _FILTER_BOOT_OPTION_OPERATION
|
|
{
|
|
FilterBootOptionOperationOpenSystemStore,
|
|
FilterBootOptionOperationSetElement,
|
|
FilterBootOptionOperationDeleteElement,
|
|
FilterBootOptionOperationMax
|
|
} FILTER_BOOT_OPTION_OPERATION;
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
/**
|
|
* The NtFilterBootOption routine filters boot options based on the specified operation, object type, and element type.
|
|
*
|
|
* \param FilterOperation The operation to be performed on the boot option. This can be one of the values from the FILTER_BOOT_OPTION_OPERATION enumeration.
|
|
* \param ObjectType The type of the object to be filtered.
|
|
* \param ElementType The type of the element within the object to be filtered.
|
|
* \param Data A pointer to a buffer that contains the data to be used in the filter operation. This parameter is optional and can be NULL.
|
|
* \param DataSize The size, in bytes, of the data buffer pointed to by the Data parameter.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtFilterBootOption(
|
|
_In_ FILTER_BOOT_OPTION_OPERATION FilterOperation,
|
|
_In_ ULONG ObjectType,
|
|
_In_ ULONG ElementType,
|
|
_In_reads_bytes_opt_(DataSize) PVOID Data,
|
|
_In_ ULONG DataSize
|
|
);
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
//
|
|
// Event
|
|
//
|
|
|
|
#ifndef EVENT_QUERY_STATE
|
|
#define EVENT_QUERY_STATE 0x0001
|
|
#endif
|
|
|
|
#ifndef EVENT_MODIFY_STATE
|
|
#define EVENT_MODIFY_STATE 0x0002
|
|
#endif
|
|
|
|
#ifndef EVENT_ALL_ACCESS
|
|
#define EVENT_ALL_ACCESS (EVENT_QUERY_STATE|EVENT_MODIFY_STATE|STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE)
|
|
#endif
|
|
|
|
/**
|
|
* The EVENT_INFORMATION_CLASS specifies the type of information to be retrieved about an event object.
|
|
*/
|
|
typedef enum _EVENT_INFORMATION_CLASS
|
|
{
|
|
EventBasicInformation
|
|
} EVENT_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The EVENT_BASIC_INFORMATION structure contains basic information about an event object.
|
|
*/
|
|
typedef struct _EVENT_BASIC_INFORMATION
|
|
{
|
|
EVENT_TYPE EventType; // The type of the event object (NotificationEvent or SynchronizationEvent).
|
|
LONG EventState; // The current state of the event object. Nonzero if the event is signaled; zero if not signaled.
|
|
} EVENT_BASIC_INFORMATION, *PEVENT_BASIC_INFORMATION;
|
|
|
|
/**
|
|
* The NtCreateEvent routine creates an event object, sets the initial state of the event to the specified value,
|
|
* and opens a handle to the object with the specified desired access.
|
|
*
|
|
* \param EventHandle A pointer to a variable that receives the event object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the event object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \param EventType The type of the event, which can be SynchronizationEvent or a NotificationEvent.
|
|
* \param InitialState The initial state of the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-zwcreateevent
|
|
* \remarks ObjectAttributes may be NULL to create an unnamed, process-owned event. The returned
|
|
* handle is closed with NtClose. NotificationEvent (0) is manual-reset: successful waits do
|
|
* not clear it. SynchronizationEvent (1) is auto-reset: a satisfied wait consumes the signal.
|
|
* Other EventType values return STATUS_INVALID_PARAMETER. With OBJ_OPENIF, an existing
|
|
* named event is returned with STATUS_OBJECT_NAME_EXISTS; its type and state are not
|
|
* reinitialized from EventType or InitialState.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateEvent(
|
|
_Out_ PHANDLE EventHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ EVENT_TYPE EventType,
|
|
_In_ BOOLEAN InitialState
|
|
);
|
|
|
|
/**
|
|
* The NtOpenEvent routine opens a handle to an existing event object.
|
|
*
|
|
* \param EventHandle A pointer to a variable that receives the event object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the event object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Opens an existing named object; it does not reset or acquire its signal. Request
|
|
* EVENT_QUERY_STATE (0x1) for NtQueryEvent, EVENT_MODIFY_STATE (0x2) for state changes, and
|
|
* SYNCHRONIZE (0x00100000) for waits. Close the returned handle with NtClose.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenEvent(
|
|
_Out_ PHANDLE EventHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtSetEvent routine sets an event object to the signaled state.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \param PreviousState A pointer to a variable that receives the previous state of the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires EVENT_MODIFY_STATE (0x2). For an ordinary event, PreviousState receives the
|
|
* state before signaling (0 or 1), not a count of awakened threads. Repeated sets do not
|
|
* accumulate signals. PreviousState may be NULL. A query-only handle is insufficient.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetEvent(
|
|
_In_ HANDLE EventHandle,
|
|
_Out_opt_ PLONG PreviousState
|
|
);
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_11)
|
|
/**
|
|
* The NtSetEventEx routine sets an event object to the signaled state and optionally acquires a lock.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \param PreviousState An optional pointer to a variable that receives the previous state of the event.
|
|
* \param LockAddress An optional user-mode lock address.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetEventEx(
|
|
_In_ HANDLE EventHandle,
|
|
_Out_opt_ PLONG PreviousState,
|
|
_In_opt_ PVOID LockAddress
|
|
);
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_11)
|
|
|
|
/**
|
|
* The NtSetEventBoostPriority routine sets an event object to the signaled state and boosts the priority of threads waiting on the event.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetEventBoostPriority(
|
|
_In_ HANDLE EventHandle
|
|
);
|
|
|
|
/**
|
|
* The NtClearEvent routine sets an event object to the not-signaled state.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires EVENT_MODIFY_STATE (0x2). For ordinary events, this uses
|
|
* the same KeResetEvent operation as NtResetEvent but has no previous-state output.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtClearEvent(
|
|
_In_ HANDLE EventHandle
|
|
);
|
|
|
|
/**
|
|
* The NtResetEvent routine sets an event object to the not-signaled state and optionally returns the previous state.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \param PreviousState A pointer to a variable that receives the previous state of the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-resetevent
|
|
* \remarks Requires EVENT_MODIFY_STATE (0x2). Clears the signal and optionally returns the state
|
|
* before resetting (0 or 1). Resetting an already nonsignaled event succeeds and reports 0.
|
|
* This does not cancel waits or return ownership of an auto-reset signal already consumed.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtResetEvent(
|
|
_In_ HANDLE EventHandle,
|
|
_Out_opt_ PLONG PreviousState
|
|
);
|
|
|
|
/**
|
|
* The NtPulseEvent routine sets an event object to the signaled state and then resets it to the not-signaled state after releasing the appropriate number of waiting threads.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \param PreviousState A pointer to a variable that receives the previous state of the event object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-pulseevent
|
|
* \remarks Requires EVENT_MODIFY_STATE (0x2). Optionally reports the state before the pulse.
|
|
* The signal is transient: when no eligible waiter is released immediately, the event
|
|
* is left nonsignaled; a later wait cannot consume a saved pulse. Do not use this as a
|
|
* persistent notification or as proof that another thread observed the event.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtPulseEvent(
|
|
_In_ HANDLE EventHandle,
|
|
_Out_opt_ PLONG PreviousState
|
|
);
|
|
|
|
/**
|
|
* The NtQueryEvent routine retrieves information about an event object.
|
|
*
|
|
* \param EventHandle A handle to the event object.
|
|
* \param EventInformationClass The type of information to be retrieved.
|
|
* \param EventInformation A pointer to a buffer that receives the requested information.
|
|
* \param EventInformationLength The size of the buffer pointed to by EventInformation.
|
|
* \param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires EVENT_QUERY_STATE (0x1). EventBasicInformation (0) is the supported class
|
|
* and requires exactly sizeof(EVENT_BASIC_INFORMATION), 8 bytes. Unsupported classes
|
|
* return STATUS_INVALID_INFO_CLASS; an incorrect size returns STATUS_INFO_LENGTH_MISMATCH.
|
|
* These validation failures leave ReturnLength unchanged, while success writes 8 when ReturnLength
|
|
* is non-NULL. Do not use a NULL/zero-size discovery call.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryEvent(
|
|
_In_ HANDLE EventHandle,
|
|
_In_ EVENT_INFORMATION_CLASS EventInformationClass,
|
|
_Out_writes_bytes_(EventInformationLength) PVOID EventInformation,
|
|
_In_ ULONG EventInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
//
|
|
// Event Pair
|
|
//
|
|
|
|
#define EVENT_PAIR_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE)
|
|
|
|
/**
|
|
* The NtCreateEventPair routine creates an event pair object and opens a handle to the object with the specified desired access.
|
|
*
|
|
* \remark Event Pairs are used to communicate with protected subsystems (see Context Switches).
|
|
* \param EventPairHandle A pointer to a variable that receives the event pair object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the event pair object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
* The native stub leaves EventPairHandle unchanged. With valid arguments, the
|
|
* WoW64 thunk instead copies its zero-initialized local handle to the output even
|
|
* on this failure; it can also fail earlier while converting ObjectAttributes.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateEventPair(
|
|
_Out_ PHANDLE EventPairHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtOpenEventPair routine opens a handle to an existing event pair object.
|
|
*
|
|
* \param EventPairHandle A pointer to a variable that receives the event pair object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the event pair object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
* The native stub leaves EventPairHandle unchanged. With valid arguments, the
|
|
* WoW64 thunk instead copies its zero-initialized local handle to the output even
|
|
* on this failure; it can also fail earlier while converting ObjectAttributes.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenEventPair(
|
|
_Out_ PHANDLE EventPairHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtSetLowEventPair routine sets the low event in an event pair to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetLowEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
/**
|
|
* The NtSetHighEventPair routine sets the high event in an event pair to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetHighEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
/**
|
|
* The NtWaitLowEventPair routine waits for the low event in an event pair to be set to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWaitLowEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
/**
|
|
* The NtWaitHighEventPair routine waits for the high event in an event pair to be set to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWaitHighEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
/**
|
|
* The NtSetLowWaitHighEventPair routine sets the low event in an event pair to the signaled state and waits for the high event to be set to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetLowWaitHighEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
/**
|
|
* The NtSetHighWaitLowEventPair routine sets the high event in an event pair to the signaled state and waits for the low event to be set to the signaled state.
|
|
*
|
|
* \param EventPairHandle A handle to the event pair object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Legacy event-pair API. Unsupported service-table entries
|
|
* return STATUS_NOT_IMPLEMENTED (0xC0000002) without performing the operation.
|
|
* A declaration or ntdll export does not establish that event pairs are supported.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetHighWaitLowEventPair(
|
|
_In_ HANDLE EventPairHandle
|
|
);
|
|
|
|
//
|
|
// Mutant
|
|
//
|
|
|
|
#ifndef MUTANT_QUERY_STATE
|
|
#define MUTANT_QUERY_STATE 0x0001
|
|
#endif
|
|
|
|
#ifndef MUTANT_ALL_ACCESS
|
|
#define MUTANT_ALL_ACCESS (MUTANT_QUERY_STATE|STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE)
|
|
#endif
|
|
|
|
/**
|
|
* The MUTANT_INFORMATION_CLASS enumeration defines the information classes for querying a mutant (mutex) object.
|
|
*/
|
|
typedef enum _MUTANT_INFORMATION_CLASS
|
|
{
|
|
MutantBasicInformation, // MUTANT_BASIC_INFORMATION
|
|
MutantOwnerInformation // MUTANT_OWNER_INFORMATION
|
|
} MUTANT_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The MUTANT_BASIC_INFORMATION structure contains basic information about a mutant object.
|
|
* The structure is 8 bytes, but NtQueryMutant writes only the 6 bytes occupied by
|
|
* these members. The 2 trailing padding bytes are not initialized;
|
|
* compare members rather than the complete structure, or pre-zero the output.
|
|
*/
|
|
typedef struct _MUTANT_BASIC_INFORMATION
|
|
{
|
|
LONG CurrentCount; // 1 when unowned; 0 for one acquisition; 1 minus the recursive acquisition count otherwise.
|
|
BOOLEAN OwnedByCaller; // TRUE only when the calling thread is the current owner.
|
|
BOOLEAN AbandonedState; // TRUE after an owner exits without releasing; cleared when ownership is acquired.
|
|
} MUTANT_BASIC_INFORMATION, *PMUTANT_BASIC_INFORMATION;
|
|
|
|
/**
|
|
* The MUTANT_OWNER_INFORMATION structure contains information about the owner of a mutant object.
|
|
* ClientId contains process and thread identifiers (not handles to close), or two
|
|
* NULL values when there is no owner. Use it for diagnostics, not synchronization.
|
|
*/
|
|
typedef struct _MUTANT_OWNER_INFORMATION
|
|
{
|
|
CLIENT_ID ClientId;
|
|
} MUTANT_OWNER_INFORMATION, *PMUTANT_OWNER_INFORMATION;
|
|
|
|
/**
|
|
* The NtCreateMutant routine creates a mutant object, sets the initial state of the mutant to the specified value,
|
|
* and opens a handle to the object with the specified desired access.
|
|
*
|
|
* \param MutantHandle A pointer to a variable that receives the mutant object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the mutant object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \param InitialOwner If TRUE, the calling thread is the initial owner of the mutant object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks A mutant is an ownership-tracked, recursively acquirable mutex. NULL ObjectAttributes
|
|
* creates an unnamed object. InitialOwner applies only to a newly created mutant. With
|
|
* OBJ_OPENIF, an existing named mutant is returned with STATUS_OBJECT_NAME_EXISTS; TRUE
|
|
* InitialOwner does not acquire it. Acquire an existing mutant by waiting instead.
|
|
* Release each acquired recursion level with NtReleaseMutant; NtClose closes the handle
|
|
* but is not a substitute for releasing ownership.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateMutant(
|
|
_Out_ PHANDLE MutantHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ BOOLEAN InitialOwner
|
|
);
|
|
|
|
/**
|
|
* The NtOpenMutant routine opens a handle to an existing mutant object.
|
|
*
|
|
* \param MutantHandle A pointer to a variable that receives the mutant object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the mutant object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Opening a handle does not acquire the mutant. Request MUTANT_QUERY_STATE (0x1) for
|
|
* queries and SYNCHRONIZE (0x00100000) for waits. A successful wait acquires ownership;
|
|
* an abandoned-wait result also acquires ownership but requires checking protected state.
|
|
* Close the returned handle with NtClose after balancing any acquisitions.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenMutant(
|
|
_Out_ PHANDLE MutantHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtReleaseMutant routine releases ownership of a mutant object.
|
|
*
|
|
* \param MutantHandle A handle to the mutant object.
|
|
* \param PreviousCount A pointer to a variable that receives the previous count of the mutant object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks For ordinary mutants no specific handle access right is required
|
|
* (the handle is referenced with desired access 0), but the calling thread must own it.
|
|
* Each release removes one recursion level. PreviousCount receives the prior dispatcher
|
|
* signal count, not a positive recursion depth: 0 for the final release and negative
|
|
* values for recursive ownership. A nonowner normally receives STATUS_MUTANT_NOT_OWNED.
|
|
* If the mutant is abandoned, a nonowner release returns STATUS_ABANDONED (0x80) without
|
|
* releasing/acquiring it or writing PreviousCount. This status is nonnegative: test for
|
|
* STATUS_SUCCESS, not merely NT_SUCCESS, when deciding whether a release occurred.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtReleaseMutant(
|
|
_In_ HANDLE MutantHandle,
|
|
_Out_opt_ PLONG PreviousCount
|
|
);
|
|
|
|
/**
|
|
* The NtQueryMutant routine retrieves information about a mutant object.
|
|
*
|
|
* \param MutantHandle A handle to the mutant object.
|
|
* \param MutantInformationClass The type of information to be retrieved.
|
|
* \param MutantInformation A pointer to a buffer that receives the requested information.
|
|
* \param MutantInformationLength The size of the buffer pointed to by MutantInformation.
|
|
* \param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires MUTANT_QUERY_STATE (0x1). MutantBasicInformation (0) requires exactly 8 bytes;
|
|
* MutantOwnerInformation (1) requires exactly sizeof(MUTANT_OWNER_INFORMATION), 16 bytes on x64 and 8 bytes
|
|
* for x86 callers. Unsupported classes return STATUS_INVALID_INFO_CLASS; incorrect sizes return
|
|
* STATUS_INFO_LENGTH_MISMATCH. Basic-query wrong-size failures leave ReturnLength unchanged on the native x64
|
|
* and x86/WoW64 paths; success reports the selected structure size. Querying never acquires ownership. The
|
|
* owner IDs and state are snapshots and may change immediately after the query.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryMutant(
|
|
_In_ HANDLE MutantHandle,
|
|
_In_ MUTANT_INFORMATION_CLASS MutantInformationClass,
|
|
_Out_writes_bytes_(MutantInformationLength) PVOID MutantInformation,
|
|
_In_ ULONG MutantInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
//
|
|
// Semaphore
|
|
//
|
|
|
|
#ifndef SEMAPHORE_QUERY_STATE
|
|
#define SEMAPHORE_QUERY_STATE 0x0001
|
|
#endif
|
|
|
|
#ifndef SEMAPHORE_MODIFY_STATE
|
|
#define SEMAPHORE_MODIFY_STATE 0x0002
|
|
#endif
|
|
|
|
#ifndef SEMAPHORE_ALL_ACCESS
|
|
#define SEMAPHORE_ALL_ACCESS (SEMAPHORE_QUERY_STATE|SEMAPHORE_MODIFY_STATE|STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE)
|
|
#endif
|
|
|
|
/**
|
|
* The SEMAPHORE_INFORMATION_CLASS enumeration defines the information classes for querying a semaphore object.
|
|
*/
|
|
typedef enum _SEMAPHORE_INFORMATION_CLASS
|
|
{
|
|
SemaphoreBasicInformation
|
|
} SEMAPHORE_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The SEMAPHORE_BASIC_INFORMATION structure contains basic information about a semaphore object.
|
|
*/
|
|
typedef struct _SEMAPHORE_BASIC_INFORMATION
|
|
{
|
|
LONG CurrentCount;
|
|
LONG MaximumCount;
|
|
} SEMAPHORE_BASIC_INFORMATION, *PSEMAPHORE_BASIC_INFORMATION;
|
|
|
|
/**
|
|
* The NtCreateSemaphore routine creates a semaphore object, sets the initial count of the semaphore to the specified value,
|
|
* and opens a handle to the object with the specified desired access.
|
|
*
|
|
* \param SemaphoreHandle A pointer to a variable that receives the semaphore object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the semaphore object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \param InitialCount The initial count of the semaphore object.
|
|
* \param MaximumCount The maximum count of the semaphore object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires MaximumCount > 0 and 0 <= InitialCount <= MaximumCount; invalid counts
|
|
* return STATUS_INVALID_PARAMETER. NULL ObjectAttributes creates an unnamed semaphore.
|
|
* A satisfied wait consumes one count; NtReleaseSemaphore adds a positive count. With
|
|
* OBJ_OPENIF, opening an existing named semaphore returns STATUS_OBJECT_NAME_EXISTS and
|
|
* does not replace its current or maximum count. Close the returned handle with NtClose.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateSemaphore(
|
|
_Out_ PHANDLE SemaphoreHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ LONG InitialCount,
|
|
_In_ LONG MaximumCount
|
|
);
|
|
|
|
/**
|
|
* The NtOpenSemaphore routine opens a handle to an existing semaphore object.
|
|
*
|
|
* \param SemaphoreHandle A pointer to a variable that receives the semaphore object handle.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the semaphore object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Does not consume a semaphore count. Request SEMAPHORE_QUERY_STATE (0x1) for queries,
|
|
* SEMAPHORE_MODIFY_STATE (0x2) for release, and SYNCHRONIZE (0x00100000) for waits.
|
|
* Close the returned handle with NtClose.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenSemaphore(
|
|
_Out_ PHANDLE SemaphoreHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtReleaseSemaphore routine increases the count of the specified semaphore object by a specified amount.
|
|
*
|
|
* \param SemaphoreHandle A handle to the semaphore object.
|
|
* \param ReleaseCount The amount by which the semaphore object's count is to be increased.
|
|
* \param PreviousCount A pointer to a variable that receives the previous count of the semaphore object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires SEMAPHORE_MODIFY_STATE (0x2). ReleaseCount must be positive; zero or a
|
|
* negative value returns STATUS_INVALID_PARAMETER. If the addition exceeds MaximumCount
|
|
* or overflows the signed count, STATUS_SEMAPHORE_LIMIT_EXCEEDED is returned without
|
|
* changing the count or writing PreviousCount. On success, PreviousCount receives the
|
|
* count before the addition and may be NULL. Release does not require prior acquisition.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtReleaseSemaphore(
|
|
_In_ HANDLE SemaphoreHandle,
|
|
_In_ LONG ReleaseCount,
|
|
_Out_opt_ PLONG PreviousCount
|
|
);
|
|
|
|
/**
|
|
* The NtQuerySemaphore routine retrieves information about a semaphore object.
|
|
*
|
|
* \param SemaphoreHandle A handle to the semaphore object.
|
|
* \param SemaphoreInformationClass The type of information to be retrieved.
|
|
* \param SemaphoreInformation A pointer to a buffer that receives the requested information.
|
|
* \param SemaphoreInformationLength The size of the buffer pointed to by SemaphoreInformation.
|
|
* \param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Requires SEMAPHORE_QUERY_STATE (0x1). SemaphoreBasicInformation (0) requires exactly
|
|
* sizeof(SEMAPHORE_BASIC_INFORMATION), 8 bytes. Unsupported classes return
|
|
* STATUS_INVALID_INFO_CLASS; other sizes return STATUS_INFO_LENGTH_MISMATCH. With a valid
|
|
* output buffer, these failures leave ReturnLength unchanged; success
|
|
* writes 8 if requested. The native x64 entry probes an 8-byte writable, 4-byte-aligned
|
|
* output buffer before class/length validation, so NULL/zero-length sizing is not supported.
|
|
* Counts are observational snapshots; another thread may consume a count immediately.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySemaphore(
|
|
_In_ HANDLE SemaphoreHandle,
|
|
_In_ SEMAPHORE_INFORMATION_CLASS SemaphoreInformationClass,
|
|
_Out_writes_bytes_(SemaphoreInformationLength) PVOID SemaphoreInformation,
|
|
_In_ ULONG SemaphoreInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
//
|
|
// Timer
|
|
//
|
|
|
|
#ifndef TIMER_QUERY_STATE
|
|
#define TIMER_QUERY_STATE 0x0001
|
|
#endif
|
|
|
|
#ifndef TIMER_MODIFY_STATE
|
|
#define TIMER_MODIFY_STATE 0x0002
|
|
#endif
|
|
|
|
#ifndef TIMER_ALL_ACCESS
|
|
#define TIMER_ALL_ACCESS (TIMER_QUERY_STATE|TIMER_MODIFY_STATE|STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE)
|
|
#endif
|
|
|
|
/**
|
|
* The TIMER_INFORMATION_CLASS enumeration defines the information classes for querying a timer object.
|
|
*/
|
|
typedef enum _TIMER_INFORMATION_CLASS
|
|
{
|
|
TimerBasicInformation // q: TIMER_BASIC_INFORMATION
|
|
} TIMER_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The TIMER_SET_INFORMATION_CLASS enumeration defines the information classes for setting timer object information.
|
|
*/
|
|
typedef enum _TIMER_SET_INFORMATION_CLASS
|
|
{
|
|
TimerSetCoalescableTimer, // s: TIMER_SET_COALESCABLE_TIMER_INFO
|
|
MaxTimerInfoClass
|
|
} TIMER_SET_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* Snapshot returned by NtQueryTimer(TimerBasicInformation), not a reservation of
|
|
* the timer signal. Size is 16 bytes on x64 and x86. The query
|
|
* writes only bytes 0 through 8; the 7 trailing padding bytes remain unchanged.
|
|
* Compare members, or initialize the output first, rather than comparing all bytes.
|
|
*/
|
|
typedef struct _TIMER_BASIC_INFORMATION
|
|
{
|
|
LARGE_INTEGER RemainingTime; // Signed 100-nanosecond difference; positive for a future queued due time, not clamped to zero when inactive.
|
|
BOOLEAN TimerState; // Current signal state, not whether the timer is armed or periodic.
|
|
} TIMER_BASIC_INFORMATION, *PTIMER_BASIC_INFORMATION;
|
|
|
|
/**
|
|
* Optional timer completion routine, delivered as a user APC to the thread that
|
|
* last set the ordinary timer with this callback. That thread must enter an
|
|
* alertable wait; waiting nonalertably on the timer does not dispatch the callback.
|
|
* TimerContext is the caller-supplied value and may be NULL. TimerLowValue and
|
|
* TimerHighValue contain the low and high 32-bit halves of the system-time stamp
|
|
* sampled when the timer DPC queues the APC, in 100-nanosecond FILETIME units;
|
|
* they are not the relative interval originally supplied to NtSetTimer.
|
|
*/
|
|
typedef _Function_class_(TIMER_APC_ROUTINE)
|
|
VOID NTAPI TIMER_APC_ROUTINE(
|
|
_In_opt_ PVOID TimerContext,
|
|
_In_ ULONG TimerLowValue,
|
|
_In_ LONG TimerHighValue
|
|
);
|
|
typedef TIMER_APC_ROUTINE* PTIMER_APC_ROUTINE;
|
|
|
|
/**
|
|
* Input for NtSetTimerEx(TimerSetCoalescableTimer). Coalescing permits expiration
|
|
* to be delayed so wakeups can be combined; it is not a timer-resolution request.
|
|
* The record is 48 bytes on x64 and 32 bytes on x86. The record itself is read-only
|
|
* to the syscall; PreviousState, when non-NULL, points to a separate writable byte.
|
|
* Use the native pointer-width layout, not the other architecture's record.
|
|
*/
|
|
typedef struct _TIMER_SET_COALESCABLE_TIMER_INFO
|
|
{
|
|
_In_ LARGE_INTEGER DueTime; // 100-nanosecond units: negative relative interval; nonnegative absolute UTC deadline.
|
|
_In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine; // APC to the setting thread; see TIMER_APC_ROUTINE.
|
|
_In_opt_ PVOID TimerContext; // Opaque callback context; NULL is permitted.
|
|
_In_opt_ PCOUNTED_REASON_CONTEXT WakeContext; // Optional reason for requesting system wake; captured by the kernel.
|
|
_In_opt_ ULONG Period; // Milliseconds, 0 for one-shot; values above 0x7FFFFFFF return STATUS_INVALID_PARAMETER_3.
|
|
_In_ ULONG TolerableDelay; // Milliseconds of permitted coalescing delay; 0 requests no additional tolerance.
|
|
_Out_opt_ PBOOLEAN PreviousState; // Receives the previous signal state, not whether the timer was armed.
|
|
} TIMER_SET_COALESCABLE_TIMER_INFO, *PTIMER_SET_COALESCABLE_TIMER_INFO;
|
|
|
|
/**
|
|
* The NtCreateTimer routine creates an initially inactive, nonsignaled ordinary waitable timer.
|
|
*
|
|
* \param TimerHandle Receives a caller-owned handle; release it with NtClose.
|
|
* \param DesiredAccess Requested access. TIMER_QUERY_STATE (0x1) permits queries,
|
|
* TIMER_MODIFY_STATE (0x2) permits setting/canceling, and SYNCHRONIZE permits waits.
|
|
* \param ObjectAttributes Optional name, root directory and security attributes.
|
|
* \param TimerType NotificationTimer (0) retains its signal across waits;
|
|
* SynchronizationTimer (1) consumes the signal on a successful wait.
|
|
* \return STATUS_SUCCESS for a new timer. With OBJ_OPENIF, an existing named timer
|
|
* is opened with STATUS_OBJECT_NAME_EXISTS without changing its type or state.
|
|
* An unsupported TimerType returns STATUS_INVALID_PARAMETER_4.
|
|
* \remarks On x64, a failed type check leaves TimerHandle
|
|
* unchanged. WoW64 copies a zero-initialized local handle after the native call,
|
|
* including on this failure. Only use the returned handle on a successful status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateTimer(
|
|
_Out_ PHANDLE TimerHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ TIMER_TYPE TimerType
|
|
);
|
|
|
|
/**
|
|
* The NtOpenTimer routine opens an existing named ordinary timer without arming it or consuming its signal.
|
|
*
|
|
* \param TimerHandle Receives a caller-owned handle; release it with NtClose.
|
|
* \param DesiredAccess Requested access: TIMER_QUERY_STATE (0x1),
|
|
* TIMER_MODIFY_STATE (0x2), and/or SYNCHRONIZE for waits.
|
|
* \param ObjectAttributes Identifies the timer by name and optional root directory.
|
|
* \return NTSTATUS indicating whether a handle was opened.
|
|
* \remarks Native x64 name-lookup failure leaves TimerHandle
|
|
* unchanged; the WoW64 thunk copies its zero-initialized local handle on that failure.
|
|
* Attribute conversion may fail earlier. Do not treat output preservation as portable.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenTimer(
|
|
_Out_ PHANDLE TimerHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtSetTimer routine arms or replaces an ordinary timer's due time and optional periodic/APC behavior.
|
|
* Rearming clears the previous signal and removes pending completion APCs; it does not signal threads waiting
|
|
* for the old deadline. An already-due deadline can signal the timer again immediately.
|
|
*
|
|
* \param TimerHandle Handle with TIMER_MODIFY_STATE (0x2).
|
|
* \param DueTime Required pointer to a time in 100-nanosecond units. Negative values
|
|
* specify a relative interval; nonnegative values specify an absolute UTC deadline
|
|
* in FILETIME units. A deadline in the past expires immediately.
|
|
* \param TimerApcRoutine Optional completion APC delivered to the setting thread
|
|
* when it enters an alertable wait. See TIMER_APC_ROUTINE for arguments and context.
|
|
* \param TimerContext Optional opaque value passed to TimerApcRoutine.
|
|
* \param ResumeTimer Requests that expiration wake the system from a suspended
|
|
* power state. This does not mean resume a paused timer. Support depends on the
|
|
* platform and wake policy; STATUS_TIMER_RESUME_IGNORED can accompany an armed timer.
|
|
* \param Period Milliseconds between periodic expirations, in the range 0 through
|
|
* 0x7FFFFFFF. Zero selects one-shot operation; negative values return
|
|
* STATUS_INVALID_PARAMETER_6.
|
|
* \param PreviousState Optional writable byte receiving the previous signal state,
|
|
* not an armed-state indicator or a count of pending expirations.
|
|
* \return NTSTATUS. STATUS_TIMER_RESUME_IGNORED (0x40000025) is informational:
|
|
* the timer was set, but its wake request could not be honored.
|
|
* \remarks Ordinary timers created by NtCreateTimer are described here. Timer2/IR
|
|
* compatibility paths have additional restrictions on callbacks, context and state
|
|
* output; do not assume those object types support the complete ordinary-timer contract.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetTimer(
|
|
_In_ HANDLE TimerHandle,
|
|
_In_ PLARGE_INTEGER DueTime,
|
|
_In_opt_ PTIMER_APC_ROUTINE TimerApcRoutine,
|
|
_In_opt_ PVOID TimerContext,
|
|
_In_ BOOLEAN ResumeTimer,
|
|
_In_opt_ LONG Period,
|
|
_Out_opt_ PBOOLEAN PreviousState
|
|
);
|
|
|
|
/**
|
|
* The NtSetTimerEx routine arms an ordinary timer with coalescing tolerance and an optional wake-reason
|
|
* context. Its rearming, signal-state and APC semantics are the same as NtSetTimer.
|
|
*
|
|
* \param TimerHandle Handle with TIMER_MODIFY_STATE (0x2).
|
|
* \param TimerSetInformationClass TimerSetCoalescableTimer (0). Other classes return
|
|
* STATUS_INVALID_INFO_CLASS.
|
|
* \param TimerSetInformation Required readable TIMER_SET_COALESCABLE_TIMER_INFO
|
|
* record. The record itself is not modified, even if supplied from read-only memory.
|
|
* Its optional PreviousState member points to a separately writable BOOLEAN output.
|
|
* \param TimerSetInformationLength Use sizeof(TIMER_SET_COALESCABLE_TIMER_INFO):
|
|
* exactly 48 bytes on native x64, 32 bytes on x86. The WoW64
|
|
* thunk accepts lengths of at least 32 bytes, converts that prefix, and ignores the
|
|
* excess; the native x64 entry rejects any length other than 48 bytes.
|
|
* \return NTSTATUS. A Period above 0x7FFFFFFF returns STATUS_INVALID_PARAMETER_3;
|
|
* invalid sizing returns STATUS_INFO_LENGTH_MISMATCH. STATUS_TIMER_RESUME_IGNORED
|
|
* (0x40000025) can indicate that the timer was armed without honoring a wake request.
|
|
* \remarks Native user-mode input must be 4-byte aligned. The
|
|
* WoW64 thunk copies an unaligned x86 record into an aligned native local,
|
|
* so the original x86 buffer does not receive the same alignment check. Supply a
|
|
* naturally aligned record for portability. Timer2/IR objects have additional restrictions.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetTimerEx(
|
|
_In_ HANDLE TimerHandle,
|
|
_In_ TIMER_SET_INFORMATION_CLASS TimerSetInformationClass,
|
|
_In_reads_bytes_(TimerSetInformationLength) PVOID TimerSetInformation,
|
|
_In_ ULONG TimerSetInformationLength
|
|
);
|
|
|
|
/**
|
|
* The NtCancelTimer routine deactivates an ordinary timer and removes pending timer completion APCs without
|
|
* clearing its current signal state. Canceling an inactive timer is also successful.
|
|
*
|
|
* \param TimerHandle Handle with TIMER_MODIFY_STATE (0x2).
|
|
* \param CurrentState Optional writable byte receiving the timer's signal state,
|
|
* not whether an active timer was removed. A canceled, signaled notification timer
|
|
* remains signaled; rearm it to clear the signal.
|
|
* \return NTSTATUS indicating whether cancellation completed.
|
|
* \remarks Cancellation is not a join for a user callback already executing on
|
|
* another thread; synchronize callback/context lifetime separately. For a Timer2/IR
|
|
* compatibility object, CurrentState must be NULL; the ordinary
|
|
* timer's state-output contract does not apply to those objects.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCancelTimer(
|
|
_In_ HANDLE TimerHandle,
|
|
_Out_opt_ PBOOLEAN CurrentState
|
|
);
|
|
|
|
/**
|
|
* The NtQueryTimer routine retrieves a snapshot of an ordinary timer's signal state and remaining time.
|
|
* Querying neither consumes the signal nor arms or cancels the timer.
|
|
*
|
|
* \param TimerHandle Handle with TIMER_QUERY_STATE (0x1).
|
|
* \param TimerInformationClass TimerBasicInformation (0), the supported class.
|
|
* \param TimerInformation Writable TIMER_BASIC_INFORMATION, 4-byte aligned for
|
|
* user-mode callers on native x64 and WoW64.
|
|
* \param TimerInformationLength Exactly 16 bytes on x64 and x86/WoW64.
|
|
* \param ReturnLength Optional ULONG receiving 16 on success. Invalid class/size
|
|
* checks leave it unchanged; NULL/zero-size discovery is
|
|
* not a supported sizing protocol.
|
|
* \return STATUS_INVALID_INFO_CLASS for an unsupported class,
|
|
* STATUS_INFO_LENGTH_MISMATCH for an incorrect size, or the query's NTSTATUS.
|
|
* \remarks Only 9 member bytes are written; 7 trailing padding bytes are untouched.
|
|
* RemainingTime is a signed 100-nanosecond difference, not clamped to zero when
|
|
* inactive. The state and due time are sampled separately and can change concurrently;
|
|
* this information is diagnostic, not a substitute for waiting on the timer.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryTimer(
|
|
_In_ HANDLE TimerHandle,
|
|
_In_ TIMER_INFORMATION_CLASS TimerInformationClass,
|
|
_Out_writes_bytes_(TimerInformationLength) PVOID TimerInformation,
|
|
_In_ ULONG TimerInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
// rev: ExpIRTimerDescs, ExpCheckIRTimerAccess and ExCheckValidIRTimerId
|
|
/**
|
|
* Identifies the provider encoded in the low word of an IR timer identifier.
|
|
* The high word selects a timer within that provider. ExCheckValidIRTimerId
|
|
* requires that selector to be less than the ID count shown below.
|
|
* Provider zero is not a usable provider for NtCreateIRTimer/NtCreateTimer2.
|
|
* User-mode creation also checks the provider service SID, or the wake-timer
|
|
* security descriptor when the provider has no service SID.
|
|
*/
|
|
typedef enum _IR_TIMER_PROVIDER_INDEX
|
|
{
|
|
IR_TIMER_PROVIDER_UNKNOWN = 0, // Not a valid creation provider.
|
|
IR_TIMER_PROVIDER_TESTIDENTIFIER = 1, // 1 ID; wake-timer access check.
|
|
IR_TIMER_PROVIDER_BROKERINFRASTRUCTURE = 2, // 1 ID; service SID.
|
|
IR_TIMER_PROVIDER_TIMEBROKERSVC = 3, // 1 ID; service SID.
|
|
IR_TIMER_PROVIDER_LFSVC = 4, // 11 IDs; service SID.
|
|
IR_TIMER_PROVIDER_WINLOGON = 5, // 1 ID.
|
|
IR_TIMER_PROVIDER_POWER = 6, // 2 IDs; service SID.
|
|
IR_TIMER_PROVIDER_SENSORSERVICE = 7, // 1 ID; service SID.
|
|
IR_TIMER_PROVIDER_NTOSPO = 8, // 7 IDs.
|
|
IR_TIMER_PROVIDER_ACPI = 9, // 1 ID.
|
|
IR_TIMER_PROVIDER_BUTTON = 10, // 1 ID.
|
|
IR_TIMER_PROVIDER_MSGPIOCLX = 11, // 2 IDs.
|
|
IR_TIMER_PROVIDER_BUTTONCONVERTER = 12, // 1 ID.
|
|
IR_TIMER_PROVIDER_MSGPIOWIN32 = 13, // 2 IDs.
|
|
IR_TIMER_PROVIDER_KNETPWRDEPBROKER = 14, // 2 IDs.
|
|
IR_TIMER_PROVIDER_CMBATT = 15, // 1 ID.
|
|
IR_TIMER_PROVIDER_BTHPORT = 16, // 2 IDs.
|
|
IR_TIMER_PROVIDER_AUDIOSRV = 17, // 1 ID; service SID.
|
|
IR_TIMER_PROVIDER_ARTESTIDENTIFIER = 18, // 1 ID; wake-timer access check.
|
|
IR_TIMER_PROVIDER_BATTC = 19, // 1 ID.
|
|
IR_TIMER_PROVIDER_MAXINDEX = 20
|
|
} IR_TIMER_PROVIDER_INDEX;
|
|
|
|
// rev
|
|
#define IR_TIMERID_PROVIDER(TimerId) ((USHORT)LOWORD((ULONG)(TimerId)))
|
|
#define IR_TIMERID_ID(TimerId) ((USHORT)HIWORD((ULONG)(TimerId)))
|
|
#define IR_TIMERID_IS_NONZERO(TimerId) (IR_TIMERID_PROVIDER(TimerId) != 0)
|
|
#define IR_TIMERID_ATTRIBUTES(ProviderIndex, ProviderId) \
|
|
((ULONG)MAKELONG((USHORT)(ProviderIndex), (USHORT)(ProviderId)))
|
|
|
|
/**
|
|
* The NtCreateIRTimer routine creates an IR timer object.
|
|
* Associates a timer with an IR_TIMER_PROVIDER_INDEX provider and its timer selector.
|
|
* This wrapper requests TIMER2_ATTRIBUTE_IR_TIMER, not TIMER2_ATTRIBUTE_HIGH_RESOLUTION.
|
|
*
|
|
* \param TimerHandle A pointer to a variable that receives the handle to the IR timer object.
|
|
* \param TimerId A pointer to a timer identifier that specifies the provider.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the timer object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks The TimerId must be non-NULL and point to a valid timer identifier.
|
|
* \remarks Forwards to NtCreateTimer2 with attribute 0x2 and no object attributes. TimerId is a
|
|
* caller-supplied 4-byte identifier, not an output handle; its low word must be in the range 1 through 19
|
|
* before additional descriptor and access checks. Identifier zero is rejected, not assigned automatically.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateIRTimer(
|
|
_Out_ PHANDLE TimerHandle,
|
|
_In_ PULONG TimerId,
|
|
_In_ ACCESS_MASK DesiredAccess
|
|
);
|
|
|
|
/**
|
|
* The NtSetIRTimer routine sets an IR timer object.
|
|
*
|
|
* \param TimerHandle A handle to the IR timer object.
|
|
* \param DueTime An optional pointer to a LARGE_INTEGER that specifies
|
|
* the time at which the timer is to be set to the signaled state. NULL cancels the timer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Shares the Timer2 set/cancel helper. A NULL DueTime selects cancellation, unlike NtSetTimer2,
|
|
* which rejects NULL. The wrapper supplies no periodic interval or parameter block; it does not provide a general
|
|
* interface for changing the IR timer identity or ownership.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetIRTimer(
|
|
_In_ HANDLE TimerHandle,
|
|
_In_opt_ PLARGE_INTEGER DueTime
|
|
);
|
|
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
//
|
|
// NtCreateTimer2 Attributes
|
|
// ExpExTimerAttributesAreValid accepts 0, 2, 4, 8, 6 or 12,
|
|
// optionally ORed with 0x80000000. IR_TIMER and NO_WAKE cannot be combined.
|
|
//
|
|
#define TIMER2_ATTRIBUTE_IR_TIMER 0x00000002UL
|
|
#define TIMER2_ATTRIBUTE_HIGH_RESOLUTION 0x00000004UL
|
|
#define TIMER2_ATTRIBUTE_NO_WAKE 0x00000008UL
|
|
#define TIMER2_ATTRIBUTE_NOTIFICATION 0x80000000UL
|
|
// rev
|
|
#define TIMER2_ATTRIBUTE_KNOWN_MASK (TIMER2_ATTRIBUTE_IR_TIMER | TIMER2_ATTRIBUTE_HIGH_RESOLUTION | TIMER2_ATTRIBUTE_NO_WAKE | TIMER2_ATTRIBUTE_NOTIFICATION)
|
|
#define TIMER2_ATTRIBUTE_RESERVED_MASK (~TIMER2_ATTRIBUTE_KNOWN_MASK)
|
|
|
|
#define TIMER2_ATTRIBUTE_FOR_TYPE(T) \
|
|
(((T) == NotificationTimer) ? TIMER2_ATTRIBUTE_NOTIFICATION : 0)
|
|
|
|
// Build attributes for a *non-IR* timer
|
|
// - T: TIMER_TYPE (NotificationTimer/SynchronizationTimer)
|
|
// - R: bool for HighResolution
|
|
//
|
|
#define TIMER2_BUILD_ATTRIBUTES(T, R) \
|
|
(TIMER2_ATTRIBUTE_FOR_TYPE(T) | ((R) ? TIMER2_ATTRIBUTE_HIGH_RESOLUTION : 0))
|
|
|
|
// Build attributes for an *IR* timer
|
|
// - R: bool for HighResolution
|
|
//
|
|
#define TIMER2_BUILD_IR_ATTRIBUTES(R) \
|
|
(TIMER2_ATTRIBUTE_IR_TIMER | ((R) ? TIMER2_ATTRIBUTE_HIGH_RESOLUTION : 0))
|
|
|
|
// rev
|
|
/**
|
|
* The TIMER2_ATTRIBUTES union describes the attributes used when creating a Timer2 object.
|
|
*/
|
|
typedef union _TIMER2_ATTRIBUTES
|
|
{
|
|
ULONG Value;
|
|
struct
|
|
{
|
|
ULONG Reserved0 : 1; // bit 0 (reserved)
|
|
ULONG IrTimer : 1; // bit 1 == TIMER2_ATTRIBUTE_IR_TIMER
|
|
ULONG HighResolution : 1; // bit 2 == TIMER2_ATTRIBUTE_HIGH_RESOLUTION
|
|
ULONG NoWake : 1; // bit 3 == TIMER2_ATTRIBUTE_NO_WAKE
|
|
ULONG Reserved1 : 27; // bits [4..30] (reserved)
|
|
ULONG NotificationType : 1; // TIMER_TYPE, bit 31 == TIMER2_ATTRIBUTE_NOTIFICATION
|
|
} DUMMYSTRUCTNAME;
|
|
} TIMER2_ATTRIBUTES;
|
|
|
|
/**
|
|
* The NtCreateTimer2 routine creates a timer object.
|
|
*
|
|
* \param TimerHandle A pointer to a variable that receives the handle to the timer object.
|
|
* \param TimerId For IR timers: A pointer to ULONG TIMERID (non-NULL). For non-IR timers: must be NULL.
|
|
* \param ObjectAttributes Reserved; must be NULL. This entry point creates unnamed timers.
|
|
* A non-NULL value returns STATUS_INVALID_PARAMETER_3.
|
|
* \param Attributes A combination of TIMER2_ATTRIBUTE_* flags, not a TIMER_TYPE value.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the timer object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerexw
|
|
* \remarks Use for an unnamed second-generation timer, not for opening a named legacy timer. The attribute validator accepts base combinations 0, 2, 4, 8, 6 and 12, optionally with bit 0x80000000.
|
|
* The IR bit 0x2 adds TimerId access checks. Successful creation does not arm the timer; close its handle with NtClose.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateTimer2(
|
|
_Out_ PHANDLE TimerHandle,
|
|
_In_opt_ PULONG TimerId,
|
|
_Reserved_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ ULONG Attributes,
|
|
_In_ ACCESS_MASK DesiredAccess
|
|
);
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
|
|
// rev
|
|
#define TIMER2_SET_PARAMETERS_CURRENT_VERSION 0
|
|
|
|
// rev
|
|
/**
|
|
* Supplies the versioned coalescing policy to NtSetTimer2.
|
|
* The ExpSetTimer2 implementation copies 16 bytes, checks Version == 0,
|
|
* and rejects NoWakeTolerance values below -1 with STATUS_INVALID_PARAMETER_3.
|
|
* Timer resolution is selected when the timer is created; changing this
|
|
* tolerance does not turn a normal timer into a high-resolution timer.
|
|
*/
|
|
typedef struct _T2_SET_PARAMETERS_V0
|
|
{
|
|
ULONG Version; // TIMER2_SET_PARAMETERS_CURRENT_VERSION (0).
|
|
ULONG Reserved; // Alignment padding; copied but not interpreted by ExpSetTimer2/KeSetTimer2.
|
|
/**
|
|
* Delay beyond DueTime, in 100-nanosecond units, allowed before a wake is
|
|
* required. Zero gives no additional tolerance; a positive value gives a
|
|
* finite tolerance; -1 sets an unlimited no-wake deadline.
|
|
* This does not guarantee a particular scheduling latency or resolution.
|
|
*/
|
|
LONGLONG NoWakeTolerance;
|
|
} T2_SET_PARAMETERS, *PT2_SET_PARAMETERS;
|
|
|
|
typedef PVOID PT2_CANCEL_PARAMETERS;
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
/**
|
|
* The NtSetTimer2 routine activates the timer object for a specified interval with optional periodic behavior.
|
|
*
|
|
* \param TimerHandle A handle to the timer object to set.
|
|
* \param DueTime A pointer to a LARGE_INTEGER specifying the absolute or relative time when the timer should expire.
|
|
* \param Period An optional pointer to a LARGE_INTEGER specifying the period for periodic timer notifications, in 100-nanosecond intervals. If NULL, the timer is non-periodic.
|
|
* \param Parameters A pointer to a T2_SET_PARAMETERS structure containing additional timer configuration parameters.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-setwaitabletimer
|
|
* \remarks Requires timer modify access 0x2. A NULL DueTime returns STATUS_INVALID_PARAMETER_2.
|
|
* The optional parameter block is 16 bytes; Version must be zero and NoWakeTolerance must be at least -1.
|
|
* The native helper rejects an invalid block with STATUS_INVALID_PARAMETER_3. Period and due time use
|
|
* 100-nanosecond units; no APC routine or callback pointer is present in T2_SET_PARAMETERS.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetTimer2(
|
|
_In_ HANDLE TimerHandle,
|
|
_In_ PLARGE_INTEGER DueTime,
|
|
_In_opt_ PLARGE_INTEGER Period,
|
|
_In_opt_ PT2_SET_PARAMETERS Parameters
|
|
);
|
|
|
|
/**
|
|
* The NtCancelTimer2 routine sets the specified waitable timer to the inactive state.
|
|
*
|
|
* \param TimerHandle A handle to the timer object to set.
|
|
* \param Parameters Reserved; pass NULL. Do not rely on NtCancelTimer2 interpreting this argument.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-cancelwaitabletimer
|
|
* \remarks Cancels the timer using the same modify access 0x2 as NtSetTimer2. The native entry clears the
|
|
* due-time, period and parameter arguments before calling the common helper, without consuming Parameters.
|
|
* Pass NULL for portability. Cancellation does not close the handle or undo an expiration that was already
|
|
* observed.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCancelTimer2(
|
|
_In_ HANDLE TimerHandle,
|
|
_Reserved_ PT2_CANCEL_PARAMETERS Parameters
|
|
);
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
|
|
//
|
|
// Profile
|
|
//
|
|
|
|
#define PROFILE_CONTROL 0x0001
|
|
#define PROFILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | PROFILE_CONTROL)
|
|
|
|
/**
|
|
* The NtCreateProfile routine creates a profile object for performance monitoring.
|
|
*
|
|
* \param ProfileHandle A pointer to a variable that receives the handle to the profile object.
|
|
* \param Process Optional handle to the process to be profiled. If NULL, the current process is used.
|
|
* \param ProfileBase The base address of the region to be profiled.
|
|
* \param ProfileSize The size, in bytes, of the region to be profiled.
|
|
* \param BucketSize The size, in bytes, of each bucket in the profile buffer.
|
|
* \param Buffer A pointer to a buffer that receives the profile data.
|
|
* \param BufferSize The size, in bytes, of the buffer.
|
|
* \param ProfileSource The source of the profiling data (KPROFILE_SOURCE).
|
|
* \param Affinity The processor affinity mask indicating which processors to profile.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateProfile(
|
|
_Out_ PHANDLE ProfileHandle,
|
|
_In_opt_ HANDLE Process,
|
|
_In_ PVOID ProfileBase,
|
|
_In_ SIZE_T ProfileSize,
|
|
_In_ ULONG BucketSize,
|
|
_In_reads_bytes_(BufferSize) PULONG Buffer,
|
|
_In_ ULONG BufferSize,
|
|
_In_ KPROFILE_SOURCE ProfileSource,
|
|
_In_ KAFFINITY Affinity
|
|
);
|
|
|
|
/**
|
|
* The NtCreateProfileEx routine creates a profile object for performance monitoring with group affinity.
|
|
*
|
|
* \param ProfileHandle A pointer to a variable that receives the handle to the profile object.
|
|
* \param Process Optional handle to the process to be profiled. If NULL, the current process is used.
|
|
* \param ProfileBase The base address of the region to be profiled.
|
|
* \param ProfileSize The size, in bytes, of the region to be profiled.
|
|
* \param BucketSize The size, in bytes, of each bucket in the profile buffer.
|
|
* \param Buffer A pointer to a buffer that receives the profile data.
|
|
* \param BufferSize The size, in bytes, of the buffer.
|
|
* \param ProfileSource The source of the profiling data (KPROFILE_SOURCE).
|
|
* \param GroupCount The number of group affinities provided.
|
|
* \param GroupAffinity A pointer to an array of GROUP_AFFINITY structures specifying processor groups to profile.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateProfileEx(
|
|
_Out_ PHANDLE ProfileHandle,
|
|
_In_opt_ HANDLE Process,
|
|
_In_ PVOID ProfileBase,
|
|
_In_ SIZE_T ProfileSize,
|
|
_In_ ULONG BucketSize,
|
|
_In_reads_bytes_(BufferSize) PULONG Buffer,
|
|
_In_ ULONG BufferSize,
|
|
_In_ KPROFILE_SOURCE ProfileSource,
|
|
_In_ USHORT GroupCount,
|
|
_In_reads_(GroupCount) PGROUP_AFFINITY GroupAffinity
|
|
);
|
|
|
|
/**
|
|
* The NtStartProfile routine starts the specified profile object.
|
|
*
|
|
* \param ProfileHandle A handle to the profile object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtStartProfile(
|
|
_In_ HANDLE ProfileHandle
|
|
);
|
|
|
|
/**
|
|
* The NtStopProfile routine stops the specified profile object.
|
|
*
|
|
* \param ProfileHandle A handle to the profile object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtStopProfile(
|
|
_In_ HANDLE ProfileHandle
|
|
);
|
|
|
|
/**
|
|
* The NtQueryIntervalProfile routine retrieves the interval for the specified profile source.
|
|
*
|
|
* \param ProfileSource The profile source (KPROFILE_SOURCE) to query.
|
|
* \param Interval A pointer to a variable that receives the interval, in 100-nanosecond units.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Returns a 4-byte interval selected by ProfileSource through KeQueryIntervalProfile.
|
|
* A successful interval query does not create or start profiling and does not establish that a corresponding
|
|
* hardware source can be enabled by this caller.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryIntervalProfile(
|
|
_In_ KPROFILE_SOURCE ProfileSource,
|
|
_Out_ PULONG Interval
|
|
);
|
|
|
|
/**
|
|
* The NtSetIntervalProfile routine sets the interval for the specified profile source.
|
|
*
|
|
* \param Interval The interval, in 100-nanosecond units, to set.
|
|
* \param Source The profile source (KPROFILE_SOURCE) to set the interval for.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Changes profiling policy rather than querying it. The entry checks
|
|
* SeSystemProfilePrivilege before calling KeSetIntervalProfile. Do not change the global sampling interval
|
|
* merely to discover the interval; use NtQueryIntervalProfile.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetIntervalProfile(
|
|
_In_ ULONG Interval,
|
|
_In_ KPROFILE_SOURCE Source
|
|
);
|
|
|
|
//
|
|
// Keyed Event
|
|
//
|
|
|
|
#define KEYEDEVENT_WAIT 0x0001
|
|
#define KEYEDEVENT_WAKE 0x0002
|
|
#define KEYEDEVENT_ALL_ACCESS \
|
|
(STANDARD_RIGHTS_REQUIRED | KEYEDEVENT_WAIT | KEYEDEVENT_WAKE)
|
|
|
|
/**
|
|
* The NtCreateKeyedEvent routine creates a keyed event for multiplexing thread rendezvous by opaque key
|
|
* values. It can back multiple user-mode synchronization objects without allocating a separate kernel event
|
|
* for each key. A release pairs with one wait, rather than setting a persistent event signal or accumulating
|
|
* a semaphore count.
|
|
*
|
|
* \param KeyedEventHandle Receives a handle owned by the caller; close it with NtClose.
|
|
* \param DesiredAccess Requested access, including KEYEDEVENT_WAIT (0x1) and/or
|
|
* KEYEDEVENT_WAKE (0x2). KEYEDEVENT_ALL_ACCESS is 0xF0003 and excludes SYNCHRONIZE.
|
|
* \param ObjectAttributes Optional name, root directory and security attributes.
|
|
* \param Flags Reserved. Must be zero; nonzero values return STATUS_INVALID_PARAMETER_4.
|
|
* \return STATUS_SUCCESS for a new object, or STATUS_OBJECT_NAME_EXISTS when
|
|
* OBJ_OPENIF opens an existing named object. Other failures are returned as NTSTATUS.
|
|
* \remarks On x64, a valid output slot is cleared before Flags
|
|
* validation. Matching requires the same keyed-event object, key value and process;
|
|
* sharing a named object or handle does not make equal keys match across processes.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateKeyedEvent(
|
|
_Out_ PHANDLE KeyedEventHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_Reserved_ ULONG Flags
|
|
);
|
|
|
|
/**
|
|
* The NtOpenKeyedEvent routine opens an existing named keyed event without performing a wait or release.
|
|
*
|
|
* \param KeyedEventHandle Receives a handle owned by the caller; close it with NtClose.
|
|
* \param DesiredAccess Requested access. KEYEDEVENT_WAIT (0x1) permits waits;
|
|
* KEYEDEVENT_WAKE (0x2) permits releases. Opening does not perform either operation.
|
|
* \param ObjectAttributes Identifies the existing object by name and optional root directory.
|
|
* \return NTSTATUS indicating whether the object was opened.
|
|
* \remarks On x64, a valid output slot is cleared before name lookup.
|
|
* Even with a shared object, matching waits and releases must belong to the same process.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtOpenKeyedEvent(
|
|
_Out_ PHANDLE KeyedEventHandle,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_ PCOBJECT_ATTRIBUTES ObjectAttributes
|
|
);
|
|
|
|
/**
|
|
* The NtReleaseKeyedEvent routine pairs with one matching keyed-event wait, blocking if no matching waiter is
|
|
* present. Unlike NtSetEvent, this is a rendezvous operation, not a persistent signal: a release that times
|
|
* out does not leave a wake credit for a later wait.
|
|
*
|
|
* \param KeyedEventHandle Handle with KEYEDEVENT_WAKE (0x2), or NULL for the system's
|
|
* default keyed event (ExpCritSecOutOfMemoryEvent).
|
|
* \param KeyValue Opaque pointer-sized matching key, not an object handle (including a
|
|
* registry key handle). An address may be used as the key, but the kernel does not
|
|
* dereference it or inspect the memory contents, unlike the Address parameter of
|
|
* WaitOnAddress.
|
|
* Its low bit must be zero; NULL is a valid zero key, not a wildcard. The matching
|
|
* wait must use the same object and key and belong to the same process.
|
|
* \param Alertable Whether a blocking release can be interrupted by an alert or user APC.
|
|
* \param Timeout Optional timeout in 100-nanosecond units: negative for a relative
|
|
* interval, positive for an absolute deadline, zero for polling, or NULL for no deadline.
|
|
* \return STATUS_SUCCESS only when paired with a matching wait; STATUS_TIMEOUT,
|
|
* STATUS_ALERTED or STATUS_USER_APC can end an unmatched blocking release.
|
|
* On x64, an odd KeyValue returns STATUS_INVALID_PARAMETER_1
|
|
* (despite KeyValue being the second parameter), before handle validation.
|
|
* \remarks NT_SUCCESS alone does not establish a match: STATUS_TIMEOUT, STATUS_ALERTED
|
|
* and STATUS_USER_APC are nonnegative. A successful release pairs with one waiter,
|
|
* not all waiters for the key. If the match wins a timeout/APC race, the kernel
|
|
* completes the rendezvous and may return STATUS_SUCCESS instead of the interrupt.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtReleaseKeyedEvent(
|
|
_In_opt_ HANDLE KeyedEventHandle,
|
|
_In_opt_ PVOID KeyValue,
|
|
_In_ BOOLEAN Alertable,
|
|
_In_opt_ PLARGE_INTEGER Timeout
|
|
);
|
|
|
|
/**
|
|
* The NtWaitForKeyedEvent routine pairs with one matching keyed-event release, blocking until a match or
|
|
* interruption. Use it as the wait half of a user-mode synchronization protocol, not to wait on a persistent
|
|
* signal state; a matching release may arrive before or after this call.
|
|
*
|
|
* \param KeyedEventHandle Handle with KEYEDEVENT_WAIT (0x1), or NULL for the system's
|
|
* default keyed event (ExpCritSecOutOfMemoryEvent).
|
|
* \param KeyValue Opaque pointer-sized matching key, not an object handle (including a
|
|
* registry key handle). An address may be used as the key, but the kernel does not
|
|
* dereference it or inspect the memory contents, unlike the Address parameter of
|
|
* WaitOnAddress.
|
|
* Its low bit must be zero; NULL is a valid zero key, not a wildcard. The matching
|
|
* release must use the same object and key and belong to the same process.
|
|
* \param Alertable Whether a blocking wait can be interrupted by an alert or user APC.
|
|
* \param Timeout Optional timeout in 100-nanosecond units: negative for a relative
|
|
* interval, positive for an absolute deadline, zero for polling, or NULL for no deadline.
|
|
* \return STATUS_SUCCESS only when paired with a matching release; STATUS_TIMEOUT,
|
|
* STATUS_ALERTED or STATUS_USER_APC can end an unmatched blocking wait.
|
|
* On x64, an odd KeyValue returns STATUS_INVALID_PARAMETER_1
|
|
* (despite KeyValue being the second parameter), before handle validation.
|
|
* \remarks Test for STATUS_SUCCESS, not just NT_SUCCESS, to distinguish a match
|
|
* from timeout or interruption. A successful wait consumes one matching release.
|
|
* If the match wins a timeout/APC race, the kernel completes the rendezvous and
|
|
* may return STATUS_SUCCESS instead of the interrupt.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWaitForKeyedEvent(
|
|
_In_opt_ HANDLE KeyedEventHandle,
|
|
_In_opt_ PVOID KeyValue,
|
|
_In_ BOOLEAN Alertable,
|
|
_In_opt_ PLARGE_INTEGER Timeout
|
|
);
|
|
|
|
//
|
|
// UMS
|
|
//
|
|
|
|
/**
|
|
* The NtUmsThreadYield routine yields control to the user-mode scheduling (UMS) scheduler thread on which the calling UMS worker thread is running.
|
|
* Note: As of Windows 11, user-mode scheduling is not supported. All calls fail with the error STATUS_NOT_SUPPORTED.
|
|
*
|
|
* \param SchedulerParam Optional handle to the keyed event object. If NULL, the default keyed event is used.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-umsthreadyield
|
|
* \remarks The native x64 service returns STATUS_NOT_SUPPORTED (0xC00000BB).
|
|
* Export presence is not proof that UMS scheduling is available. The WoW64 entry uses a different dispatch path;
|
|
* this native status must not be generalized into a supported 32-bit UMS contract.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtUmsThreadYield(
|
|
_In_ PVOID SchedulerParam
|
|
);
|
|
|
|
//
|
|
// WNF
|
|
//
|
|
|
|
// begin_private
|
|
|
|
/**
|
|
* The WNF_STATE_NAME structure identifies a Windows Notification Facility (WNF) state name.
|
|
*/
|
|
typedef struct _WNF_STATE_NAME
|
|
{
|
|
union
|
|
{
|
|
ULONGLONG Value;
|
|
ULONG Data[2];
|
|
struct
|
|
{
|
|
ULONG64 Version : 4;
|
|
ULONG64 NameLifetime : 2;
|
|
ULONG64 DataScope : 4;
|
|
ULONG64 PermanentData : 1;
|
|
ULONG64 Unique : 53;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} WNF_STATE_NAME, *PWNF_STATE_NAME;
|
|
|
|
typedef const WNF_STATE_NAME *PCWNF_STATE_NAME;
|
|
|
|
/**
|
|
* The WNF_STATE_NAME_LIFETIME enumeration defines the lifetime of a Windows Notification Facility (WNF) state name.
|
|
*/
|
|
typedef enum _WNF_STATE_NAME_LIFETIME
|
|
{
|
|
WnfWellKnownStateName,
|
|
WnfPermanentStateName,
|
|
WnfPersistentStateName,
|
|
WnfTemporaryStateName
|
|
} WNF_STATE_NAME_LIFETIME;
|
|
|
|
/**
|
|
* The WNF_STATE_NAME_INFORMATION enumeration defines the queryable information about a WNF state name.
|
|
*/
|
|
typedef enum _WNF_STATE_NAME_INFORMATION
|
|
{
|
|
WnfInfoStateNameExist, // q: ULONG boolean; ExplicitScope must be NULL.
|
|
WnfInfoSubscribersPresent, // q: ULONG boolean.
|
|
WnfInfoIsQuiescent // q: ULONG boolean.
|
|
} WNF_STATE_NAME_INFORMATION;
|
|
|
|
/**
|
|
* Defines the scope in which a WNF state's data is maintained.
|
|
* For the Nt*WnfStateData and NtQueryWnfStateNameInformation ExplicitScope
|
|
* arguments, NULL selects the caller's implicit scope. Explicit scope values use:
|
|
* - WnfDataScopeSession: a pointer to a 4-byte ULONG session ID.
|
|
* - WnfDataScopeUser: a pointer to a SID (not a pointer to a SID pointer).
|
|
* - WnfDataScopeProcess: the process HANDLE value itself, not a PHANDLE.
|
|
* - System, Machine and PhysicalMachine: a non-NULL explicit scope is rejected.
|
|
* User-mode explicit-scope requests are also subject to cross-scope access checks.
|
|
* See ExpWnfCaptureScopeInstanceId and ExpWnfCheckCrossScopeAccess.
|
|
*/
|
|
typedef enum _WNF_DATA_SCOPE
|
|
{
|
|
WnfDataScopeSystem,
|
|
WnfDataScopeSession,
|
|
WnfDataScopeUser,
|
|
WnfDataScopeProcess,
|
|
WnfDataScopeMachine, // REDSTONE3
|
|
WnfDataScopePhysicalMachine, // WIN11
|
|
} WNF_DATA_SCOPE;
|
|
|
|
/**
|
|
* The WNF_TYPE_ID structure identifies the type of data associated with a WNF state.
|
|
*/
|
|
typedef struct _WNF_TYPE_ID
|
|
{
|
|
GUID TypeId;
|
|
} WNF_TYPE_ID, *PWNF_TYPE_ID;
|
|
|
|
typedef const WNF_TYPE_ID *PCWNF_TYPE_ID;
|
|
|
|
// rev
|
|
typedef ULONG WNF_CHANGE_STAMP, *PWNF_CHANGE_STAMP;
|
|
|
|
/**
|
|
* Describes one delivered WNF subscription notification. The 48-byte header is
|
|
* followed by state data in the same caller-owned buffer. StateDataOffset is a byte
|
|
* offset from this header (48 in the described delivery layout); StateDataSize is the payload length.
|
|
* NtGetCompleteWnfStateSubscription requires more space than sizeof this header.
|
|
*/
|
|
typedef struct _WNF_DELIVERY_DESCRIPTOR
|
|
{
|
|
ULONGLONG SubscriptionId;
|
|
WNF_STATE_NAME StateName;
|
|
WNF_CHANGE_STAMP ChangeStamp;
|
|
ULONG StateDataSize;
|
|
ULONG EventMask;
|
|
WNF_TYPE_ID TypeId;
|
|
ULONG StateDataOffset;
|
|
} WNF_DELIVERY_DESCRIPTOR, *PWNF_DELIVERY_DESCRIPTOR;
|
|
|
|
// rev: minimum nonzero DescriptorSize checked by NtGetCompleteWnfStateSubscription.
|
|
#define WNF_DELIVERY_DESCRIPTOR_MINIMUM_BUFFER_SIZE 0x1030UL // 48-byte header + 4096 bytes; 8-byte aligned on x64.
|
|
|
|
// end_private
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
/**
|
|
* The NtCreateWnfStateName routine creates a new WNF state name with a caller-supplied security descriptor.
|
|
* MaximumStateSize cannot exceed 4096 bytes. Creation rejects WnfWellKnownStateName,
|
|
* WnfDataScopePhysicalMachine, and the combination of WnfTemporaryStateName with WnfDataScopeProcess.
|
|
* Non-temporary creation requires SeCreatePermanentPrivilege. PersistData is accepted only for
|
|
* WnfPermanentStateName with WnfDataScopeSystem or WnfDataScopeMachine.
|
|
*
|
|
* \param StateName Pointer to a WNF_STATE_NAME structure that receives the created state name.
|
|
* \param NameLifetime The lifetime of the state name (see WNF_STATE_NAME_LIFETIME).
|
|
* \param DataScope The data scope for the state name (see WNF_DATA_SCOPE).
|
|
* \param PersistData If TRUE, the state data is persistent.
|
|
* \param TypeId Optional pointer to a WNF_TYPE_ID structure specifying the type of the state data.
|
|
* \param MaximumStateSize The maximum size, in bytes, of the state data.
|
|
* \param SecurityDescriptor Pointer to a security descriptor for the state name.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks For disposable application state, use a temporary name with an allowed scope and a
|
|
* descriptor granting only the intended principals access. Query/update rights 0x1/0x2 do not include DELETE
|
|
* (0x00010000), which is needed for explicit name deletion. A state name is an identifier, not an NtClose handle.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateWnfStateName(
|
|
_Out_ PWNF_STATE_NAME StateName,
|
|
_In_ WNF_STATE_NAME_LIFETIME NameLifetime,
|
|
_In_ WNF_DATA_SCOPE DataScope,
|
|
_In_ BOOLEAN PersistData,
|
|
_In_opt_ PCWNF_TYPE_ID TypeId,
|
|
_In_ ULONG MaximumStateSize,
|
|
_In_ PSECURITY_DESCRIPTOR SecurityDescriptor
|
|
);
|
|
|
|
/**
|
|
* The NtDeleteWnfStateName routine deletes an existing WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to delete.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Explicit name deletion checks DELETE (0x00010000) against the WNF security descriptor.
|
|
* Possessing the identifier or having permission to update/delete its data is not sufficient. A temporary name
|
|
* also has creator-process ownership checks; do not confuse name deletion with NtDeleteWnfStateData.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDeleteWnfStateName(
|
|
_In_ PCWNF_STATE_NAME StateName
|
|
);
|
|
|
|
/**
|
|
* The NtUpdateWnfStateData routine updates the data associated with a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to update.
|
|
* \param Buffer Pointer to the data buffer to write.
|
|
* \param Length Length, in bytes, of the data buffer.
|
|
* \param TypeId Optional pointer to a WNF_TYPE_ID structure specifying the type of the state data.
|
|
* \param ExplicitScope Optional scope selector: a session-ID pointer, SID pointer, or process HANDLE
|
|
* value, according to the state name's WNF_DATA_SCOPE. NULL selects the implicit scope.
|
|
* \param MatchingChangeStamp The change stamp to match for update.
|
|
* \param CheckStamp If TRUE, the change stamp is checked before updating.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks For conditional updates, CheckStamp enables comparison against MatchingChangeStamp.
|
|
* The state-data helper returns STATUS_UNSUCCESSFUL for a mismatch without publishing a new value.
|
|
* Successful updates advance the change stamp; retry logic should re-query and re-evaluate the intended change,
|
|
* not blindly overwrite after a mismatch. Length remains bounded by the name's MaximumStateSize.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtUpdateWnfStateData(
|
|
_In_ PCWNF_STATE_NAME StateName,
|
|
_In_reads_bytes_opt_(Length) const VOID* Buffer,
|
|
_In_opt_ ULONG Length,
|
|
_In_opt_ PCWNF_TYPE_ID TypeId,
|
|
_In_opt_ PCVOID ExplicitScope,
|
|
_In_ WNF_CHANGE_STAMP MatchingChangeStamp,
|
|
_In_ LOGICAL CheckStamp
|
|
);
|
|
|
|
/**
|
|
* The NtDeleteWnfStateData routine deletes the data associated with a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME whose data is to be deleted.
|
|
* \param ExplicitScope Optional scope selector: a session-ID pointer, SID pointer, or process HANDLE
|
|
* value, according to the state name's WNF_DATA_SCOPE. NULL selects the implicit scope.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Deletes the payload, not the state name or subscriptions. An owned temporary name remains
|
|
* queryable with an empty payload afterwards. Explicit name deletion is a separate operation with DELETE access;
|
|
* publishing rights alone do not confer that permission.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDeleteWnfStateData(
|
|
_In_ PCWNF_STATE_NAME StateName,
|
|
_In_opt_ PCVOID ExplicitScope
|
|
);
|
|
|
|
/**
|
|
* The NtQueryWnfStateData routine queries the data associated with a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to query.
|
|
* \param TypeId Optional pointer to a WNF_TYPE_ID structure specifying the type of the state data.
|
|
* \param ExplicitScope Optional scope selector: a session-ID pointer, SID pointer, or process HANDLE
|
|
* value, according to the state name's WNF_DATA_SCOPE. NULL selects the implicit scope.
|
|
* \param ChangeStamp Pointer to a variable that receives the change stamp.
|
|
* \param Buffer Pointer to a buffer that receives the state data.
|
|
* \param BufferLength On input, the capacity in bytes; on output, the current payload size, including
|
|
* the required capacity when the buffer is too small.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks For an existing payload, a short output buffer returns STATUS_BUFFER_TOO_SMALL and
|
|
* reports the required byte length and current change stamp without copying a partial payload. Thus BufferLength
|
|
* is not always the number of bytes written. A size/query retry can race another publisher; recheck the final status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryWnfStateData(
|
|
_In_ PCWNF_STATE_NAME StateName,
|
|
_In_opt_ PCWNF_TYPE_ID TypeId,
|
|
_In_opt_ PCVOID ExplicitScope,
|
|
_Out_ PWNF_CHANGE_STAMP ChangeStamp,
|
|
_Out_writes_bytes_opt_(*BufferLength) PVOID Buffer,
|
|
_Inout_ PULONG BufferLength
|
|
);
|
|
|
|
/**
|
|
* The NtQueryWnfStateNameInformation routine queries information about a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to query.
|
|
* \param NameInfoClass The information class to query (see WNF_STATE_NAME_INFORMATION).
|
|
* \param ExplicitScope Optional scope selector: a session-ID pointer, SID pointer, or process HANDLE
|
|
* value, according to the state name's WNF_DATA_SCOPE. NULL selects the implicit scope.
|
|
* \param Buffer Pointer to a buffer that receives the requested information.
|
|
* \param BufferLength The buffer size in bytes; at least 4. Each class returns a ULONG boolean.
|
|
* WnfInfoStateNameExist requires ExplicitScope == NULL even for session/user/process names.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks The entry accepts classes 0, 1 and 2 and requires at least 4 output
|
|
* bytes; a shorter buffer returns STATUS_INVALID_PARAMETER, not STATUS_INFO_LENGTH_MISMATCH. These are
|
|
* ULONG boolean results, not BOOLEAN-sized stores. Subscriber presence is not proof of delivery or callback completion.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryWnfStateNameInformation(
|
|
_In_ PCWNF_STATE_NAME StateName,
|
|
_In_ WNF_STATE_NAME_INFORMATION NameInfoClass,
|
|
_In_opt_ PCVOID ExplicitScope,
|
|
_Out_writes_bytes_(BufferLength) PVOID Buffer,
|
|
_In_ ULONG BufferLength
|
|
);
|
|
|
|
/**
|
|
* The NtSubscribeWnfStateChange routine subscribes to state change notifications for a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to subscribe to.
|
|
* \param ChangeStamp Optional change stamp to start receiving notifications from.
|
|
* \param EventMask Bitmask specifying which events to subscribe to.
|
|
* \param SubscriptionId Optional pointer to a variable that receives the subscription ID.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Registers a subscription for the calling process rather than installing a user
|
|
* callback supplied to this syscall. SubscriptionId, when requested, is an 8-byte identifier on both architectures.
|
|
* Native registration and the higher-level Rtl callback dispatcher are separate layers; pair registration with
|
|
* NtUnsubscribeWnfStateChange and do not free callback state merely because data publication returned.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSubscribeWnfStateChange(
|
|
_In_ PCWNF_STATE_NAME StateName,
|
|
_In_opt_ WNF_CHANGE_STAMP ChangeStamp,
|
|
_In_ ULONG EventMask,
|
|
_Out_opt_ PULONG64 SubscriptionId
|
|
);
|
|
|
|
/**
|
|
* The NtUnsubscribeWnfStateChange routine unsubscribes from state change notifications for a WNF state name.
|
|
*
|
|
* \param StateName Pointer to the WNF_STATE_NAME to unsubscribe from.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Removes the current process's subscription selected by StateName. This operation
|
|
* does not delete the published data or the name. An owned subscription can be checked with
|
|
* WnfInfoSubscribersPresent, but that observation is not a cross-process delivery synchronization primitive.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtUnsubscribeWnfStateChange(
|
|
_In_ PCWNF_STATE_NAME StateName
|
|
);
|
|
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
|
|
/**
|
|
* The NtGetCompleteWnfStateSubscription routine completes a previously delivered WNF notification and
|
|
* optionally retrieves the next one. To acknowledge a delivery, supply both old pointers, a nonzero old event
|
|
* mask, and an OldDescriptorStatus of STATUS_SUCCESS or STATUS_RETRY (0xC000022D). A nonzero DescriptorSize
|
|
* must be at least 0x1030 (4144) and NewDeliveryDescriptor must be 8-byte aligned. A zero size skips
|
|
* retrieval.
|
|
*
|
|
* \param OldDescriptorStateName Optional pointer to the previous state name.
|
|
* \param OldSubscriptionId Optional pointer to the previous subscription ID.
|
|
* \param OldDescriptorEventMask Optional previous event mask.
|
|
* \param OldDescriptorStatus Optional previous descriptor status.
|
|
* \param NewDeliveryDescriptor Pointer to a buffer that receives the new delivery descriptor.
|
|
* \param DescriptorSize The size, in bytes, of the delivery descriptor buffer.
|
|
* \return NTSTATUS code indicating success or failure.
|
|
* \remarks Combines completion of an earlier delivery descriptor with retrieval of further thread
|
|
* notifications. The minimum nonzero DescriptorSize is 0x1030 bytes, not just the 48-byte header. A buffer is
|
|
* not an executable callback registration; respect returned StateDataOffset and StateDataSize when
|
|
* interpreting the inline payload. Full dispatcher/rundown behavior requires separate lifetime analysis.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtGetCompleteWnfStateSubscription(
|
|
_In_opt_ PCWNF_STATE_NAME OldDescriptorStateName,
|
|
_In_opt_ const ULONG64 *OldSubscriptionId,
|
|
_In_opt_ ULONG OldDescriptorEventMask,
|
|
_In_opt_ NTSTATUS OldDescriptorStatus,
|
|
_Out_writes_bytes_opt_(DescriptorSize) PWNF_DELIVERY_DESCRIPTOR NewDeliveryDescriptor,
|
|
_In_ ULONG DescriptorSize
|
|
);
|
|
|
|
/**
|
|
* The NtSetWnfProcessNotificationEvent routine sets a process notification event for WNF state changes.
|
|
*
|
|
* \param NotificationEvent Handle to the event object to be signaled on state change.
|
|
* \return NTSTATUS code indicating success or failure.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetWnfProcessNotificationEvent(
|
|
_In_ HANDLE NotificationEvent
|
|
);
|
|
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_10)
|
|
|
|
//
|
|
// Worker factory
|
|
//
|
|
|
|
// begin_rev
|
|
|
|
#define WORKER_FACTORY_RELEASE_WORKER 0x0001
|
|
#define WORKER_FACTORY_WAIT 0x0002
|
|
#define WORKER_FACTORY_SET_INFORMATION 0x0004
|
|
#define WORKER_FACTORY_QUERY_INFORMATION 0x0008
|
|
#define WORKER_FACTORY_READY_WORKER 0x0010
|
|
#define WORKER_FACTORY_SHUTDOWN 0x0020
|
|
|
|
#define WORKER_FACTORY_ALL_ACCESS ( \
|
|
STANDARD_RIGHTS_REQUIRED | \
|
|
WORKER_FACTORY_RELEASE_WORKER | \
|
|
WORKER_FACTORY_WAIT | \
|
|
WORKER_FACTORY_SET_INFORMATION | \
|
|
WORKER_FACTORY_QUERY_INFORMATION | \
|
|
WORKER_FACTORY_READY_WORKER | \
|
|
WORKER_FACTORY_SHUTDOWN \
|
|
)
|
|
|
|
// end_rev
|
|
|
|
// begin_private
|
|
|
|
/**
|
|
* Selects worker-factory configuration and status operations.
|
|
* NtQueryInformationWorkerFactory accepts only
|
|
* WorkerFactoryBasicInformation (7); individual configuration selectors are not query classes.
|
|
* NtSetInformationWorkerFactory requires WORKER_FACTORY_SET_INFORMATION;
|
|
* the basic query requires WORKER_FACTORY_QUERY_INFORMATION.
|
|
*/
|
|
typedef enum _WORKERFACTORYINFOCLASS
|
|
{
|
|
WorkerFactoryTimeout, // Historical; may be rejected with STATUS_INVALID_INFO_CLASS
|
|
WorkerFactoryRetryTimeout, // Historical; may be rejected with STATUS_INVALID_INFO_CLASS
|
|
WorkerFactoryIdleTimeout, // s: LARGE_INTEGER
|
|
WorkerFactoryBindingCount, // s: LONG (signed adjustment, not an absolute count)
|
|
WorkerFactoryThreadMinimum, // s: ULONG
|
|
WorkerFactoryThreadMaximum, // s: ULONG
|
|
WorkerFactoryPaused, // Historical; setting this class may return STATUS_NOT_IMPLEMENTED
|
|
WorkerFactoryBasicInformation, // q: WORKER_FACTORY_BASIC_INFORMATION
|
|
WorkerFactoryAdjustThreadGoal, // s: ULONG
|
|
WorkerFactoryCallbackType, // s: ULONG
|
|
WorkerFactoryStackInformation, // s: ULONG/ULONG_PTR // 10
|
|
WorkerFactoryThreadBasePriority, // s: ULONG
|
|
WorkerFactoryTimeoutWaiters, // s: ULONG // since THRESHOLD
|
|
WorkerFactoryFlags, // s: ULONG
|
|
WorkerFactoryThreadSoftMaximum, // s: ULONG
|
|
WorkerFactoryThreadCpuSets, // s: ULONG[] // since REDSTONE5
|
|
MaxWorkerFactoryInfoClass
|
|
} WORKERFACTORYINFOCLASS, *PWORKERFACTORYINFOCLASS;
|
|
|
|
/**
|
|
* Returns worker counts, thread entry-point parameters and stack sizes for a worker factory.
|
|
* NtQueryInformationWorkerFactory requires exactly 120 bytes on x64.
|
|
* Timeout, RetryTimeout, Paused, TimerSet and InfiniteWaitGoal are returned as zero
|
|
* in this implementation; IdleTimeout contains the active relative timeout.
|
|
*/
|
|
typedef struct _WORKER_FACTORY_BASIC_INFORMATION
|
|
{
|
|
LARGE_INTEGER Timeout;
|
|
LARGE_INTEGER RetryTimeout;
|
|
LARGE_INTEGER IdleTimeout;
|
|
BOOLEAN Paused;
|
|
BOOLEAN TimerSet;
|
|
BOOLEAN QueuedToExWorker;
|
|
BOOLEAN MayCreate;
|
|
BOOLEAN CreateInProgress;
|
|
BOOLEAN InsertedIntoQueue;
|
|
BOOLEAN Shutdown;
|
|
ULONG BindingCount;
|
|
ULONG ThreadMinimum;
|
|
ULONG ThreadMaximum;
|
|
ULONG PendingWorkerCount;
|
|
ULONG WaitingWorkerCount;
|
|
ULONG TotalWorkerCount;
|
|
ULONG ReleaseCount;
|
|
LONGLONG InfiniteWaitGoal;
|
|
PVOID StartRoutine;
|
|
PVOID StartParameter;
|
|
HANDLE ProcessId;
|
|
SIZE_T StackReserve;
|
|
SIZE_T StackCommit;
|
|
NTSTATUS LastThreadCreationStatus;
|
|
} WORKER_FACTORY_BASIC_INFORMATION, *PWORKER_FACTORY_BASIC_INFORMATION;
|
|
|
|
// end_private
|
|
|
|
/**
|
|
* The NtCreateWorkerFactory routine creates a worker factory object that manages a pool of worker threads bound to an I/O completion port.
|
|
*
|
|
* \param WorkerFactoryHandleReturn A pointer to a variable that receives a handle to the new worker factory object.
|
|
* \param DesiredAccess The access mask that specifies the requested access to the worker factory object.
|
|
* \param ObjectAttributes A pointer to an OBJECT_ATTRIBUTES structure that specifies the object attributes. This parameter is optional.
|
|
* \param CompletionPortHandle A handle to the I/O completion port that the worker factory is associated with.
|
|
* \param WorkerProcessHandle A handle to the process in which the worker threads are created.
|
|
* \param StartRoutine A pointer to the routine that is executed by each worker thread.
|
|
* \param StartParameter A pointer to the parameter passed to the start routine. This parameter is optional.
|
|
* \param MaxThreadCount The maximum number of worker threads that the factory can create. This parameter is optional.
|
|
* \param StackReserve The amount of stack space to reserve for each worker thread, in bytes. This parameter is optional.
|
|
* \param StackCommit The amount of stack space to commit for each worker thread, in bytes. This parameter is optional.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtCreateWorkerFactory(
|
|
_Out_ PHANDLE WorkerFactoryHandleReturn,
|
|
_In_ ACCESS_MASK DesiredAccess,
|
|
_In_opt_ PCOBJECT_ATTRIBUTES ObjectAttributes,
|
|
_In_ HANDLE CompletionPortHandle,
|
|
_In_ HANDLE WorkerProcessHandle,
|
|
_In_ PVOID StartRoutine,
|
|
_In_opt_ PVOID StartParameter,
|
|
_In_opt_ ULONG MaxThreadCount,
|
|
_In_opt_ SIZE_T StackReserve,
|
|
_In_opt_ SIZE_T StackCommit
|
|
);
|
|
|
|
/**
|
|
* The NtQueryInformationWorkerFactory routine retrieves information about the specified worker factory.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \param WorkerFactoryInformationClass The type of information to be retrieved.
|
|
* \param WorkerFactoryInformation A pointer to a buffer that receives the requested information.
|
|
* \param WorkerFactoryInformationLength The size of the \c WorkerFactoryInformation buffer, in bytes.
|
|
* \param ReturnLength A pointer to a variable that receives the number of bytes written to the \c WorkerFactoryInformation buffer. This parameter is optional.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks The native entry supports WorkerFactoryBasicInformation (7),
|
|
* requires exactly 120 bytes and worker-factory query access 0x8. It probes the fixed native record before
|
|
* testing the supplied length, so a short-length test must still use valid backing storage. WoW64 converts the
|
|
* basic record to 96 bytes; the mere presence of a thunk for another class does not establish native support.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryInformationWorkerFactory(
|
|
_In_ HANDLE WorkerFactoryHandle,
|
|
_In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass,
|
|
_Out_writes_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation,
|
|
_In_ ULONG WorkerFactoryInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
/**
|
|
* The NtSetInformationWorkerFactory routine sets information for the specified worker factory.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \param WorkerFactoryInformationClass The type of information to be set.
|
|
* \param WorkerFactoryInformation A pointer to a buffer that contains the information to set.
|
|
* \param WorkerFactoryInformationLength The size of the \c WorkerFactoryInformation buffer, in bytes.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetInformationWorkerFactory(
|
|
_In_ HANDLE WorkerFactoryHandle,
|
|
_In_ WORKERFACTORYINFOCLASS WorkerFactoryInformationClass,
|
|
_In_reads_bytes_(WorkerFactoryInformationLength) PVOID WorkerFactoryInformation,
|
|
_In_ ULONG WorkerFactoryInformationLength
|
|
);
|
|
|
|
/**
|
|
* The NtShutdownWorkerFactory routine shuts down the specified worker factory and wakes its worker threads.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \param PendingWorkerCount A pointer to a variable that receives the number of worker threads that are still pending.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtShutdownWorkerFactory(
|
|
_In_ HANDLE WorkerFactoryHandle,
|
|
_Inout_ volatile LONG *PendingWorkerCount
|
|
);
|
|
|
|
/**
|
|
* The NtReleaseWorkerFactoryWorker routine releases a worker thread of the worker factory so that it can process work.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtReleaseWorkerFactoryWorker(
|
|
_In_ HANDLE WorkerFactoryHandle
|
|
);
|
|
|
|
/**
|
|
* The NtWorkerFactoryWorkerReady routine notifies the worker factory that the calling worker thread has finished its current work and is ready for more.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWorkerFactoryWorkerReady(
|
|
_In_ HANDLE WorkerFactoryHandle
|
|
);
|
|
|
|
/**
|
|
* The WORKER_FACTORY_DEFERRED_WORK structure describes deferred work to be submitted to a worker factory.
|
|
*/
|
|
typedef struct _WORKER_FACTORY_DEFERRED_WORK
|
|
{
|
|
PPORT_MESSAGE AlpcSendMessage;
|
|
PVOID AlpcSendMessagePort;
|
|
ULONG AlpcSendMessageFlags;
|
|
ULONG Flags;
|
|
} WORKER_FACTORY_DEFERRED_WORK, *PWORKER_FACTORY_DEFERRED_WORK;
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
/**
|
|
* The NtWaitForWorkViaWorkerFactory routine waits for work to be dispatched to the calling worker thread through the worker factory and retrieves the completion packets.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \param MiniPackets A pointer to a buffer that receives the I/O completion packets associated with the dispatched work.
|
|
* \param Count The number of entries in the \c MiniPackets buffer.
|
|
* \param PacketsReturned A pointer to a variable that receives the number of completion packets returned.
|
|
* \param DeferredWork A pointer to a WORKER_FACTORY_DEFERRED_WORK structure that describes deferred work to be performed.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWaitForWorkViaWorkerFactory(
|
|
_In_ HANDLE WorkerFactoryHandle,
|
|
_Out_writes_to_(Count, *PacketsReturned) PFILE_IO_COMPLETION_INFORMATION MiniPackets,
|
|
_In_ ULONG Count,
|
|
_Out_ PULONG PacketsReturned,
|
|
_In_ PVOID DeferredWork // PWORKER_FACTORY_DEFERRED_WORK
|
|
);
|
|
|
|
#else
|
|
|
|
/**
|
|
* The NtWaitForWorkViaWorkerFactory routine waits for work to be dispatched to the calling worker thread through the worker factory and retrieves the completion packet.
|
|
*
|
|
* \param WorkerFactoryHandle A handle to the worker factory object.
|
|
* \param MiniPacket A pointer to a variable that receives the I/O completion packet associated with the dispatched work.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtWaitForWorkViaWorkerFactory(
|
|
_In_ HANDLE WorkerFactoryHandle,
|
|
_Out_ PFILE_IO_COMPLETION_INFORMATION MiniPacket
|
|
);
|
|
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
//
|
|
// Time
|
|
//
|
|
|
|
/**
|
|
* The NtQuerySystemTime routine obtains the current system time.
|
|
*
|
|
* \param SystemTime A pointer to a LARGE_INTEGER structure that receives the system time. This is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysystemtime
|
|
* \remarks The ntdll export is not an ordinary syscall stub, although a kernel routine
|
|
* with this name also exists. Do not attribute user-mode export behavior solely to that kernel entry. Use this
|
|
* wall-clock result for timestamps, not monotonic elapsed-time measurement; NtQueryPerformanceCounter serves
|
|
* a different purpose.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySystemTime(
|
|
_Out_ PLARGE_INTEGER SystemTime
|
|
);
|
|
|
|
/**
|
|
* The NtSetSystemTime routine sets the current system time and date. The system time is expressed in Coordinated Universal Time (UTC).
|
|
*
|
|
* \param SystemTime A pointer to a LARGE_INTEGER structure that that contains the new system date and time.
|
|
* \param PreviousTime A pointer to a LARGE_INTEGER structure that that contains the previous system time.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks The calling process must have the SE_SYSTEMTIME_NAME privilege.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-setsystemtime
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetSystemTime(
|
|
_In_opt_ PLARGE_INTEGER SystemTime,
|
|
_Out_opt_ PLARGE_INTEGER PreviousTime
|
|
);
|
|
|
|
/**
|
|
* The NtQueryTimerResolution routine retrieves the range and current value of the system interrupt timer.
|
|
*
|
|
* \param MaximumTime The maximum timer resolution, in 100-nanosecond units.
|
|
* \param MinimumTime The minimum timer resolution, in 100-nanosecond units.
|
|
* \param CurrentTime The current timer resolution, in 100-nanosecond units.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Returns three 4-byte values without acquiring a resolution request. The duration values are
|
|
* expressed in 100-ns units; compare the numeric values rather than their names. Querying these values does
|
|
* not change the current resolution or prove a particular timer-delivery latency.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryTimerResolution(
|
|
_Out_ PULONG MaximumTime,
|
|
_Out_ PULONG MinimumTime,
|
|
_Out_ PULONG CurrentTime
|
|
);
|
|
|
|
/**
|
|
* The NtSetTimerResolution routine sets the system interrupt timer resolution to the specified value.
|
|
*
|
|
* \param DesiredTime The desired timer resolution, in 100-nanosecond units.
|
|
* \param SetResolution If TRUE, the timer resolution is set to the value specified by DesiredTime. If FALSE, the timer resolution is reset to the default value.
|
|
* \param ActualTime The actual timer resolution, in 100-nanosecond units.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetTimerResolution(
|
|
_In_ ULONG DesiredTime,
|
|
_In_ BOOLEAN SetResolution,
|
|
_Out_ PULONG ActualTime
|
|
);
|
|
|
|
//
|
|
// Performance Counters
|
|
//
|
|
|
|
/**
|
|
* The NtQueryPerformanceCounter routine retrieves the current value of the performance counter,
|
|
* which is a high resolution (<1us) time stamp that can be used for time-interval measurements.
|
|
*
|
|
* \param PerformanceCounter A pointer to a variable that receives the current performance-counter value, in 100-nanosecond units.
|
|
* \param PerformanceFrequency A pointer to a variable that receives the current performance-frequency value, in 100-nanosecond units.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks On systems that run Windows XP or later, the function will always succeed and will thus never return zero. Use RtlQueryPerformanceCounter instead since no system calls are required.
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter
|
|
* \remarks Returns a counter with an optional frequency, each in an 8-byte LARGE_INTEGER.
|
|
* Use the frequency to interpret deltas; these values are not system-time timestamps. The native
|
|
* entry checks 4-byte pointer alignment and forwards to KeQueryPerformanceCounter.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryPerformanceCounter(
|
|
_Out_ PLARGE_INTEGER PerformanceCounter,
|
|
_Out_opt_ PLARGE_INTEGER PerformanceFrequency
|
|
);
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_10_RS2)
|
|
// rev
|
|
/**
|
|
* The NtQueryAuxiliaryCounterFrequency routine queries the auxiliary counter frequency. (The auxiliary counter is generally the HPET hardware timer).
|
|
*
|
|
* \param AuxiliaryCounterFrequency A pointer to an output buffer that contains the specified auxiliary counter frequency. If the auxiliary counter is not supported, the value in the output buffer will be undefined.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryauxiliarycounterfrequency
|
|
* \remarks Queries a hardware-dependent auxiliary counter, not a guaranteed
|
|
* substitute for NtQueryPerformanceCounter. STATUS_NOT_SUPPORTED is a meaningful platform result; inspect
|
|
* status before consuming the output frequency or attempting counter conversion.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryAuxiliaryCounterFrequency(
|
|
_Out_ PULONG64 AuxiliaryCounterFrequency
|
|
);
|
|
|
|
// rev
|
|
/**
|
|
* The NtConvertBetweenAuxiliaryCounterAndPerformanceCounter routine converts the specified performance counter value to the corresponding auxiliary counter value;
|
|
* optionally provides the estimated conversion error in nanoseconds due to latencies and maximum possible drift.
|
|
*
|
|
* \param ConvertAuxiliaryToPerformanceCounter If TRUE, the value will be converted from AUX to QPC. If FALSE, the value will be converted from QPC to AUX.
|
|
* \param PerformanceOrAuxiliaryCounterValue The performance counter value to convert.
|
|
* \param ConvertedValue On success, contains the converted auxiliary counter value. Will be undefined if the function fails.
|
|
* \param ConversionError On success, contains the estimated conversion error, in nanoseconds. Will be undefined if the function fails.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-convertperformancecountertoauxiliarycounter
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtConvertBetweenAuxiliaryCounterAndPerformanceCounter(
|
|
_In_ BOOLEAN ConvertAuxiliaryToPerformanceCounter,
|
|
_In_ PULONG64 PerformanceOrAuxiliaryCounterValue,
|
|
_Out_ PULONG64 ConvertedValue,
|
|
_Out_opt_ PULONG64 ConversionError
|
|
);
|
|
#endif // (PHNT_VERSION >= PHNT_WINDOWS_10_RS2)
|
|
|
|
//
|
|
// LUIDs
|
|
//
|
|
|
|
/**
|
|
* The NtAllocateLocallyUniqueId routine allocates a locally unique identifier (LUID).
|
|
*
|
|
* \param Luid A pointer to a variable that receives the allocated locally unique identifier.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/securitybaseapi/nf-securitybaseapi-allocatelocallyuniqueid
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAllocateLocallyUniqueId(
|
|
_Out_ PLUID Luid
|
|
);
|
|
|
|
//
|
|
// UUIDs
|
|
//
|
|
|
|
/**
|
|
* The NtSetUuidSeed routine sets the seed value used by the system to generate universally unique identifiers (UUIDs).
|
|
*
|
|
* \param Seed A pointer to the seed value used as the node identifier when generating UUIDs.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetUuidSeed(
|
|
_In_ PCHAR Seed
|
|
);
|
|
|
|
/**
|
|
* The NtAllocateUuids routine allocates a block of universally unique identifiers (UUIDs).
|
|
*
|
|
* \param Time A pointer to a variable that receives the timestamp used for the allocated UUIDs.
|
|
* \param Range A pointer to a variable that receives the number of UUIDs available in the allocated range.
|
|
* \param Sequence A pointer to a variable that receives the clock sequence value.
|
|
* \param Seed A pointer to a variable that receives the seed (node identifier) value.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/rpcdce/nf-rpcdce-uuidcreatesequential
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAllocateUuids(
|
|
_Out_ PULARGE_INTEGER Time,
|
|
_Out_ PULONG Range,
|
|
_Out_ PULONG Sequence,
|
|
_Out_ PCHAR Seed
|
|
);
|
|
|
|
#endif // (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
//
|
|
// System Information
|
|
//
|
|
|
|
// rev
|
|
// private
|
|
/**
|
|
* The SYSTEM_INFORMATION_CLASS enumeration defines the information classes used with NtQuerySystemInformation and NtSetSystemInformation.
|
|
*/
|
|
typedef enum _SYSTEM_INFORMATION_CLASS
|
|
{
|
|
SystemBasicInformation, // q: SYSTEM_BASIC_INFORMATION
|
|
SystemProcessorInformation, // q: SYSTEM_PROCESSOR_INFORMATION
|
|
SystemPerformanceInformation, // q: SYSTEM_PERFORMANCE_INFORMATION
|
|
SystemTimeOfDayInformation, // q: SYSTEM_TIMEOFDAY_INFORMATION
|
|
SystemPathInformation, // q: not implemented
|
|
SystemProcessInformation, // q: SYSTEM_PROCESS_INFORMATION
|
|
SystemCallCountInformation, // q: SYSTEM_CALL_COUNT_INFORMATION
|
|
SystemDeviceInformation, // q: SYSTEM_DEVICE_INFORMATION
|
|
SystemProcessorPerformanceInformation, // q: SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION (EX in: USHORT ProcessorGroup)
|
|
SystemFlagsInformation, // qs: SYSTEM_FLAGS_INFORMATION
|
|
SystemCallTimeInformation, // q: SYSTEM_CALL_TIME_INFORMATION // not implemented // 10
|
|
SystemModuleInformation, // q: RTL_PROCESS_MODULES
|
|
SystemLocksInformation, // q: RTL_PROCESS_LOCKS
|
|
SystemStackTraceInformation, // q: RTL_PROCESS_BACKTRACES
|
|
SystemPagedPoolInformation, // q: not implemented
|
|
SystemNonPagedPoolInformation, // q: not implemented
|
|
SystemHandleInformation, // q: SYSTEM_HANDLE_INFORMATION
|
|
SystemObjectInformation, // q: SYSTEM_OBJECTTYPE_INFORMATION mixed with SYSTEM_OBJECT_INFORMATION
|
|
SystemPageFileInformation, // q: SYSTEM_PAGEFILE_INFORMATION
|
|
SystemVdmInstemulInformation, // q: SYSTEM_VDM_INSTEMUL_INFO
|
|
SystemVdmBopInformation, // q: not implemented // 20
|
|
SystemFileCacheInformation, // qs: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypeSystemCache)
|
|
SystemPoolTagInformation, // q: SYSTEM_POOLTAG_INFORMATION
|
|
SystemInterruptInformation, // q: SYSTEM_INTERRUPT_INFORMATION (EX in: USHORT ProcessorGroup)
|
|
SystemDpcBehaviorInformation, // qs: SYSTEM_DPC_BEHAVIOR_INFORMATION; s: SYSTEM_DPC_BEHAVIOR_INFORMATION (requires SeLoadDriverPrivilege)
|
|
SystemFullMemoryInformation, // q: SYSTEM_MEMORY_USAGE_INFORMATION // not implemented
|
|
SystemLoadGdiDriverInformation, // s: SYSTEM_GDI_DRIVER_INFORMATION (kernel-mode only)
|
|
SystemUnloadGdiDriverInformation, // s: SYSTEM_GDI_DRIVER_UNLOAD_INFORMATION (kernel-mode only)
|
|
SystemTimeAdjustmentInformation, // qs: SYSTEM_QUERY_TIME_ADJUST_INFORMATION; s: SYSTEM_SET_TIME_ADJUST_INFORMATION (requires SeSystemtimePrivilege)
|
|
SystemSummaryMemoryInformation, // q: SYSTEM_MEMORY_USAGE_INFORMATION // not implemented
|
|
SystemMirrorMemoryInformation, // qs: (requires license value "Kernel-MemoryMirroringSupported") (requires SeShutdownPrivilege) // 30
|
|
SystemPerformanceTraceInformation, // qs: (type depends on EVENT_TRACE_INFORMATION_CLASS)
|
|
SystemObsolete0, // q: not implemented
|
|
SystemExceptionInformation, // q: SYSTEM_EXCEPTION_INFORMATION
|
|
SystemCrashDumpStateInformation, // s: SYSTEM_CRASH_DUMP_STATE_INFORMATION (requires SeDebugPrivilege)
|
|
SystemKernelDebuggerInformation, // q: SYSTEM_KERNEL_DEBUGGER_INFORMATION
|
|
SystemContextSwitchInformation, // q: SYSTEM_CONTEXT_SWITCH_INFORMATION
|
|
SystemRegistryQuotaInformation, // qs: SYSTEM_REGISTRY_QUOTA_INFORMATION; s (requires SeIncreaseQuotaPrivilege)
|
|
SystemExtendServiceTableInformation, // s: SYSTEM_EXTEND_SERVICE_TABLE_INFORMATION (requires SeLoadDriverPrivilege) // loads win32k only
|
|
SystemPrioritySeparation, // s: SYSTEM_PRIORITY_SEPARATION_INFORMATION (requires SeTcbPrivilege)
|
|
SystemVerifierAddDriverInformation, // s: UNICODE_STRING (requires SeDebugPrivilege) // 40
|
|
SystemVerifierRemoveDriverInformation, // s: UNICODE_STRING (requires SeDebugPrivilege)
|
|
SystemProcessorIdleInformation, // q: SYSTEM_PROCESSOR_IDLE_INFORMATION (EX in: USHORT ProcessorGroup)
|
|
SystemLegacyDriverInformation, // q: SYSTEM_LEGACY_DRIVER_INFORMATION
|
|
SystemCurrentTimeZoneInformation, // qs: RTL_TIME_ZONE_INFORMATION
|
|
SystemLookasideInformation, // q: SYSTEM_LOOKASIDE_INFORMATION
|
|
SystemTimeSlipNotification, // s: HANDLE (NtCreateEvent) (requires SeSystemtimePrivilege)
|
|
SystemSessionCreate, // q: not implemented
|
|
SystemSessionDetach, // q: not implemented
|
|
SystemSessionInformation, // q: not implemented (SYSTEM_SESSION_INFORMATION)
|
|
SystemRangeStartInformation, // q: SYSTEM_RANGE_START_INFORMATION // 50
|
|
SystemVerifierInformation, // qs: SYSTEM_VERIFIER_INFORMATION; s (requires SeDebugPrivilege)
|
|
SystemVerifierThunkExtend, // qs: (kernel-mode only)
|
|
SystemSessionProcessInformation, // q: SYSTEM_SESSION_PROCESS_INFORMATION
|
|
SystemLoadGdiDriverInSystemSpace, // qs: SYSTEM_GDI_DRIVER_INFORMATION (kernel-mode only) (same handler as SystemLoadGdiDriverInformation)
|
|
SystemNumaProcessorMap, // q: SYSTEM_NUMA_INFORMATION
|
|
SystemPrefetcherInformation, // qs: PREFETCHER_INFORMATION // PfSnQueryPrefetcherInformation
|
|
SystemExtendedProcessInformation, // q: SYSTEM_EXTENDED_PROCESS_INFORMATION
|
|
SystemRecommendedSharedDataAlignment, // q: SYSTEM_RECOMMENDED_SHARED_DATA_ALIGNMENT_INFORMATION // KeGetRecommendedSharedDataAlignment
|
|
SystemComPlusPackage, // qs: SYSTEM_COMPLUS_PACKAGE_INFORMATION
|
|
SystemNumaAvailableMemory, // q: SYSTEM_NUMA_INFORMATION // 60
|
|
SystemProcessorPowerInformation, // q: SYSTEM_PROCESSOR_POWER_INFORMATION (EX in: USHORT ProcessorGroup)
|
|
SystemEmulationBasicInformation, // q: SYSTEM_BASIC_INFORMATION
|
|
SystemEmulationProcessorInformation, // q: SYSTEM_PROCESSOR_INFORMATION
|
|
SystemExtendedHandleInformation, // q: SYSTEM_HANDLE_INFORMATION_EX
|
|
SystemLostDelayedWriteInformation, // q: SYSTEM_LOST_DELAYED_WRITE_INFORMATION
|
|
SystemBigPoolInformation, // q: SYSTEM_BIGPOOL_INFORMATION
|
|
SystemSessionPoolTagInformation, // q: SYSTEM_SESSION_POOLTAG_INFORMATION
|
|
SystemSessionMappedViewInformation, // q: SYSTEM_SESSION_MAPPED_VIEW_INFORMATION
|
|
SystemHotpatchInformation, // qs: SYSTEM_HOTPATCH_CODE_INFORMATION
|
|
SystemObjectSecurityMode, // q: SYSTEM_OBJECT_SECURITY_MODE_INFORMATION // 70
|
|
SystemWatchdogTimerHandler, // s: SYSTEM_WATCHDOG_HANDLER_INFORMATION // (kernel-mode only)
|
|
SystemWatchdogTimerInformation, // qs: out: SYSTEM_WATCHDOG_TIMER_INFORMATION (EX in: ULONG WATCHDOG_INFORMATION_CLASS) // NtQuerySystemInformationEx
|
|
SystemLogicalProcessorInformation, // q: SYSTEM_LOGICAL_PROCESSOR_INFORMATION (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx
|
|
SystemWow64SharedInformationObsolete, // q: not implemented
|
|
SystemRegisterFirmwareTableInformationHandler, // s: SYSTEM_FIRMWARE_TABLE_HANDLER // (kernel-mode only)
|
|
SystemFirmwareTableInformation, // q: SYSTEM_FIRMWARE_TABLE_INFORMATION
|
|
SystemModuleInformationEx, // q: RTL_PROCESS_MODULE_INFORMATION_EX // since VISTA
|
|
SystemVerifierTriageInformation, // q: not implemented
|
|
SystemSuperfetchInformation, // qs: SUPERFETCH_INFORMATION // PfQuerySuperfetchInformation
|
|
SystemMemoryListInformation, // q: SYSTEM_MEMORY_LIST_INFORMATION; s: SYSTEM_MEMORY_LIST_COMMAND (requires SeProfileSingleProcessPrivilege) // 80
|
|
SystemFileCacheInformationEx, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (same as SystemFileCacheInformation)
|
|
SystemThreadPriorityClientIdInformation, // s: SYSTEM_THREAD_CID_PRIORITY_INFORMATION (requires SeIncreaseBasePriorityPrivilege) // NtQuerySystemInformationEx
|
|
SystemProcessorIdleCycleTimeInformation, // q: SYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION[] (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx
|
|
SystemVerifierCancellationInformation, // q: SYSTEM_VERIFIER_CANCELLATION_INFORMATION // name:wow64:whNT32QuerySystemVerifierCancellationInformation
|
|
SystemProcessorPowerInformationEx, // q: not implemented
|
|
SystemRefTraceInformation, // qs: SYSTEM_REF_TRACE_INFORMATION // ObQueryRefTraceInformation
|
|
SystemSpecialPoolInformation, // qs: SYSTEM_SPECIAL_POOL_INFORMATION (requires SeDebugPrivilege) // MmSpecialPoolTag, then MmSpecialPoolCatchOverruns != 0
|
|
SystemProcessIdInformation, // q: SYSTEM_PROCESS_ID_INFORMATION
|
|
SystemErrorPortInformation, // s: HANDLE (requires SeTcbPrivilege)
|
|
SystemBootEnvironmentInformation, // q: SYSTEM_BOOT_ENVIRONMENT_INFORMATION // 90
|
|
SystemHypervisorInformation, // q: SYSTEM_HYPERVISOR_QUERY_INFORMATION
|
|
SystemVerifierInformationEx, // qs: SYSTEM_VERIFIER_INFORMATION_EX
|
|
SystemTimeZoneInformation, // qs: RTL_TIME_ZONE_INFORMATION (requires SeTimeZonePrivilege)
|
|
SystemImageFileExecutionOptionsInformation, // s: SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION (requires SeTcbPrivilege)
|
|
SystemCoverageInformation, // q: COVERAGE_MODULES s: COVERAGE_MODULE_REQUEST // ExpCovQueryInformation (requires SeDebugPrivilege)
|
|
SystemPrefetchPatchInformation, // q: SYSTEM_PREFETCH_PATCH_INFORMATION
|
|
SystemVerifierFaultsInformation, // s: SYSTEM_VERIFIER_FAULTS_INFORMATION (requires SeDebugPrivilege)
|
|
SystemSystemPartitionInformation, // q: SYSTEM_SYSTEM_PARTITION_INFORMATION
|
|
SystemSystemDiskInformation, // q: SYSTEM_SYSTEM_DISK_INFORMATION
|
|
SystemProcessorPerformanceDistribution, // q: SYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx // 100
|
|
SystemNumaProximityNodeInformation, // qs: SYSTEM_NUMA_PROXIMITY_MAP
|
|
SystemDynamicTimeZoneInformation, // qs: RTL_DYNAMIC_TIME_ZONE_INFORMATION (requires SeTimeZonePrivilege)
|
|
SystemCodeIntegrityInformation, // q: SYSTEM_CODEINTEGRITY_INFORMATION // SeCodeIntegrityQueryInformation
|
|
SystemProcessorMicrocodeUpdateInformation, // s: SYSTEM_PROCESSOR_MICROCODE_UPDATE_INFORMATION (requires SeLoadDriverPrivilege)
|
|
SystemProcessorBrandString, // q: SYSTEM_PROCESSOR_BRAND_STRING // HaliQuerySystemInformation -> HalpGetProcessorBrandString, info class 23
|
|
SystemVirtualAddressInformation, // q: SYSTEM_VA_LIST_INFORMATION[]; s: SYSTEM_VA_LIST_INFORMATION[] (requires SeIncreaseQuotaPrivilege) // MmQuerySystemVaInformation
|
|
SystemLogicalProcessorAndGroupInformation, // q: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX (EX in: LOGICAL_PROCESSOR_RELATIONSHIP RelationshipType) // since WIN7 // NtQuerySystemInformationEx // KeQueryLogicalProcessorRelationship
|
|
SystemProcessorCycleTimeInformation, // q: SYSTEM_PROCESSOR_CYCLE_TIME_INFORMATION[] (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx
|
|
SystemStoreInformation, // qs: SYSTEM_STORE_INFORMATION (requires SeProfileSingleProcessPrivilege) // SmQueryStoreInformation
|
|
SystemRegistryAppendString, // s: SYSTEM_REGISTRY_APPEND_STRING_PARAMETERS // 110
|
|
SystemAitSamplingValue, // s: SYSTEM_AIT_SAMPLING_VALUE_INFORMATION (requires SeProfileSingleProcessPrivilege)
|
|
SystemVhdBootInformation, // q: SYSTEM_VHD_BOOT_INFORMATION
|
|
SystemCpuQuotaInformation, // qs: PS_CPU_QUOTA_QUERY_INFORMATION
|
|
SystemNativeBasicInformation, // q: SYSTEM_BASIC_INFORMATION
|
|
SystemErrorPortTimeouts, // q: SYSTEM_ERROR_PORT_TIMEOUTS
|
|
SystemLowPriorityIoInformation, // q: SYSTEM_LOW_PRIORITY_IO_INFORMATION
|
|
SystemTpmBootEntropyInformation, // q: BOOT_ENTROPY_NT_RESULT // ExQueryBootEntropyInformation
|
|
SystemVerifierCountersInformation, // q: SYSTEM_VERIFIER_COUNTERS_INFORMATION
|
|
SystemPagedPoolInformationEx, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypePagedPool)
|
|
SystemSystemPtesInformationEx, // q: SYSTEM_FILECACHE_INFORMATION; s (requires SeIncreaseQuotaPrivilege) (info for WorkingSetTypeSystemPtes) // 120
|
|
SystemNodeDistanceInformation, // q: USHORT[4*NumaNodes] // (EX in: USHORT NodeNumber) // NtQuerySystemInformationEx
|
|
SystemAcpiAuditInformation, // q: SYSTEM_ACPI_AUDIT_INFORMATION // HaliQuerySystemInformation -> HalpAuditQueryResults, info class 26
|
|
SystemBasicPerformanceInformation, // q: SYSTEM_BASIC_PERFORMANCE_INFORMATION // name:wow64:whNtQuerySystemInformation_SystemBasicPerformanceInformation
|
|
SystemQueryPerformanceCounterInformation, // q: SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION // since WIN7 SP1
|
|
SystemSessionBigPoolInformation, // q: SYSTEM_SESSION_POOLTAG_INFORMATION // since WIN8
|
|
SystemBootGraphicsInformation, // qs: SYSTEM_BOOT_GRAPHICS_INFORMATION (kernel-mode only)
|
|
SystemScrubPhysicalMemoryInformation, // qs: MEMORY_SCRUB_INFORMATION
|
|
SystemBadPageInformation, // q: SYSTEM_BAD_PAGE_INFORMATION[] (non-pending pages; Poisoned cleared)
|
|
SystemProcessorProfileControlArea, // qs: SYSTEM_PROCESSOR_PROFILE_CONTROL_AREA
|
|
SystemCombinePhysicalMemoryInformation, // s: MEMORY_COMBINE_INFORMATION, MEMORY_COMBINE_INFORMATION_EX, MEMORY_COMBINE_INFORMATION_EX2 // 130
|
|
SystemEntropyInterruptTimingInformation, // qs: SYSTEM_ENTROPY_TIMING_INFORMATION
|
|
SystemConsoleInformation, // qs: SYSTEM_CONSOLE_INFORMATION // (requires SeLoadDriverPrivilege)
|
|
SystemPlatformBinaryInformation, // q: SYSTEM_PLATFORM_BINARY_INFORMATION (requires SeTcbPrivilege)
|
|
SystemPolicyInformation, // q: SYSTEM_POLICY_INFORMATION
|
|
SystemHypervisorProcessorCountInformation, // q: SYSTEM_HYPERVISOR_PROCESSOR_COUNT_INFORMATION
|
|
SystemDeviceDataInformation, // q: SYSTEM_DEVICE_DATA_INFORMATION
|
|
SystemDeviceDataEnumerationInformation, // q: SYSTEM_DEVICE_DATA_INFORMATION
|
|
SystemMemoryTopologyInformation, // q: SYSTEM_MEMORY_TOPOLOGY_INFORMATION
|
|
SystemMemoryChannelInformation, // q: SYSTEM_MEMORY_CHANNEL_INFORMATION
|
|
SystemBootLogoInformation, // q: SYSTEM_BOOT_LOGO_INFORMATION // 140
|
|
SystemProcessorPerformanceInformationEx, // q: SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX // (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx // since WINBLUE
|
|
SystemCriticalProcessErrorLogInformation, // q: SYSTEM_CRITICAL_PROCESS_EXCEPTION_INFORMATION
|
|
SystemSecureBootPolicyInformation, // q: SYSTEM_SECUREBOOT_POLICY_INFORMATION
|
|
SystemPageFileInformationEx, // q: SYSTEM_PAGEFILE_INFORMATION_EX
|
|
SystemSecureBootInformation, // q: SYSTEM_SECUREBOOT_INFORMATION
|
|
SystemEntropyInterruptTimingRawInformation, // qs: SYSTEM_ENTROPY_TIMING_INFORMATION
|
|
SystemPortableWorkspaceEfiLauncherInformation, // q: SYSTEM_PORTABLE_WORKSPACE_EFI_LAUNCHER_INFORMATION
|
|
SystemFullProcessInformation, // q: SYSTEM_EXTENDED_PROCESS_INFORMATION with SYSTEM_PROCESS_INFORMATION_EXTENSION (requires admin)
|
|
SystemKernelDebuggerInformationEx, // q: SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX
|
|
SystemBootMetadataInformation, // q: SYSTEM_BOOT_METADATA_INFORMATION // (requires SeTcbPrivilege) // 150
|
|
SystemSoftRebootInformation, // qs: SYSTEM_SOFT_REBOOT_INFORMATION (s requires SeTcbPrivilege) // query returns ExSoftRebootFlags; set calls ExpSetSoftRebootFlags
|
|
SystemElamCertificateInformation, // s: SYSTEM_ELAM_CERTIFICATE_INFORMATION
|
|
SystemOfflineDumpConfigInformation, // q: OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V2
|
|
SystemProcessorFeaturesInformation, // q: SYSTEM_PROCESSOR_FEATURES_INFORMATION
|
|
SystemRegistryReconciliationInformation, // s: NULL (requires admin) (flushes registry hives)
|
|
SystemEdidInformation, // q: SYSTEM_EDID_INFORMATION
|
|
SystemManufacturingInformation, // q: SYSTEM_MANUFACTURING_INFORMATION // since THRESHOLD
|
|
SystemEnergyEstimationConfigInformation, // q: SYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION
|
|
SystemHypervisorDetailInformation, // q: SYSTEM_HYPERVISOR_DETAIL_INFORMATION
|
|
SystemProcessorCycleStatsInformation, // q: SYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION (EX in: USHORT ProcessorGroup) // NtQuerySystemInformationEx // 160
|
|
SystemVmGenerationCountInformation, // s: PHYSICAL_ADDRESS (kernel-mode only) (vmgencounter.sys)
|
|
SystemTrustedPlatformModuleInformation, // q: SYSTEM_TPM_INFORMATION
|
|
SystemKernelDebuggerFlags, // q: SYSTEM_KERNEL_DEBUGGER_FLAGS
|
|
SystemCodeIntegrityPolicyInformation, // qs: SYSTEM_CODEINTEGRITY_POLICY_INFORMATION
|
|
SystemIsolatedUserModeInformation, // q: SYSTEM_ISOLATED_USER_MODE_INFORMATION
|
|
SystemHardwareSecurityTestInterfaceResultsInformation, // q: SYSTEM_HARDWARE_SECURITY_TEST_INTERFACE_RESULTS_INFORMATION
|
|
SystemSingleModuleInformation, // q: SYSTEM_SINGLE_MODULE_INFORMATION
|
|
SystemAllowedCpuSetsInformation, // s: SYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION
|
|
SystemVsmProtectionInformation, // q: SYSTEM_VSM_PROTECTION_INFORMATION (previously SystemDmaProtectionInformation)
|
|
SystemInterruptCpuSetsInformation, // q: SYSTEM_INTERRUPT_CPU_SET_INFORMATION // 170
|
|
SystemSecureBootPolicyFullInformation, // q: SYSTEM_SECUREBOOT_POLICY_FULL_INFORMATION
|
|
SystemCodeIntegrityPolicyFullInformation, // q: SYSTEM_CODE_INTEGRITY_POLICY_FULL_INFORMATION
|
|
SystemAffinitizedInterruptProcessorInformation, // q: KAFFINITY_EX // (requires SeIncreaseBasePriorityPrivilege)
|
|
SystemRootSiloInformation, // q: SYSTEM_ROOT_SILO_INFORMATION
|
|
SystemCpuSetInformation, // q: SYSTEM_CPU_SET_INFORMATION // since THRESHOLD2
|
|
SystemCpuSetTagInformation, // q: SYSTEM_CPU_SET_TAG_INFORMATION
|
|
SystemWin32WerStartCallout, // s: SYSTEM_WIN32_WER_START_CALLOUT (optional; 0-length uses current process)
|
|
SystemSecureKernelProfileInformation, // q: SYSTEM_SECURE_KERNEL_HYPERGUARD_PROFILE_INFORMATION
|
|
SystemCodeIntegrityPlatformManifestInformation, // q: SYSTEM_SECUREBOOT_PLATFORM_MANIFEST_INFORMATION // NtQuerySystemInformationEx // since REDSTONE
|
|
SystemInterruptSteeringInformation, // q: in: SYSTEM_INTERRUPT_STEERING_INFORMATION_INPUT, out: SYSTEM_INTERRUPT_STEERING_INFORMATION_OUTPUT // NtQuerySystemInformationEx // 180
|
|
SystemSupportedProcessorArchitectures, // p: in opt: HANDLE, out: SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION[] // NtQuerySystemInformationEx
|
|
SystemMemoryUsageInformation, // q: SYSTEM_MEMORY_USAGE_INFORMATION
|
|
SystemCodeIntegrityCertificateInformation, // q: SYSTEM_CODEINTEGRITY_CERTIFICATE_INFORMATION
|
|
SystemPhysicalMemoryInformation, // q: SYSTEM_PHYSICAL_MEMORY_INFORMATION // since REDSTONE2
|
|
SystemControlFlowTransition, // qs: SYSTEM_CONTROL_FLOW_TRANSITION // operation-tagged Warbird control-flow transition request
|
|
SystemKernelDebuggingAllowed, // s: ULONG
|
|
SystemActivityModerationExeState, // s: SYSTEM_ACTIVITY_MODERATION_EXE_STATE
|
|
SystemActivityModerationUserSettings, // q: SYSTEM_ACTIVITY_MODERATION_USER_SETTINGS
|
|
SystemCodeIntegrityPoliciesFullInformation, // qs: SYSTEM_CODE_INTEGRITY_POLICIES_FULL_INFORMATION // NtQuerySystemInformationEx
|
|
SystemCodeIntegrityUnlockInformation, // q: SYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION // 190
|
|
SystemIntegrityQuotaInformation, // s: SYSTEM_INTEGRITY_QUOTA_INFORMATION (requires SeDebugPrivilege)
|
|
SystemFlushInformation, // q: SYSTEM_FLUSH_INFORMATION
|
|
SystemProcessorIdleMaskInformation, // q: ULONG_PTR[ActiveGroupCount] // since REDSTONE3
|
|
SystemSecureDumpEncryptionInformation, // qs: SYSTEM_SECURE_DUMP_ENCRYPTION_INFORMATION // NtQuerySystemInformationEx // opaque dump-key transform buffer (q: requires SeDebugPrivilege) (s: 0-length only, requires SeTcbPrivilege)
|
|
SystemWriteConstraintInformation, // q: SYSTEM_WRITE_CONSTRAINT_INFORMATION
|
|
SystemKernelVaShadowInformation, // q: SYSTEM_KERNEL_VA_SHADOW_INFORMATION
|
|
SystemHypervisorSharedPageInformation, // q: SYSTEM_HYPERVISOR_SHARED_PAGE_INFORMATION // since REDSTONE4
|
|
SystemFirmwareBootPerformanceInformation, // q: SYSTEM_FIRMWARE_BOOT_PERFORMANCE_INFORMATION // HaliQuerySystemInformation -> HalpFwBootPerformanceTable, info class 34
|
|
SystemCodeIntegrityVerificationInformation, // q: SYSTEM_CODEINTEGRITY_VERIFICATION_INFORMATION
|
|
SystemFirmwarePartitionInformation, // q: SYSTEM_FIRMWARE_PARTITION_INFORMATION // 200
|
|
SystemSpeculationControlInformation, // q: SYSTEM_SPECULATION_CONTROL_INFORMATION // (CVE-2017-5715) REDSTONE3 and above.
|
|
SystemDmaGuardPolicyInformation, // q: SYSTEM_DMA_GUARD_POLICY_INFORMATION
|
|
SystemEnclaveLaunchControlInformation, // q: SYSTEM_ENCLAVE_LAUNCH_CONTROL_INFORMATION
|
|
SystemWorkloadAllowedCpuSetsInformation, // q: SYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION // since REDSTONE5
|
|
SystemCodeIntegrityUnlockModeInformation, // q: SYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION
|
|
SystemLeapSecondInformation, // qs: SYSTEM_LEAP_SECOND_INFORMATION // (s: requires SeSystemtimePrivilege)
|
|
SystemFlags2Information, // q: SYSTEM_FLAGS_INFORMATION // (s: requires SeDebugPrivilege)
|
|
SystemSecurityModelInformation, // q: SYSTEM_SECURITY_MODEL_INFORMATION // since 19H1
|
|
SystemCodeIntegritySyntheticCacheInformation, // qs: NtQuerySystemInformationEx
|
|
SystemFeatureConfigurationInformation, // q: in: SYSTEM_FEATURE_CONFIGURATION_QUERY, out: SYSTEM_FEATURE_CONFIGURATION_INFORMATION; s: SYSTEM_FEATURE_CONFIGURATION_UPDATE // NtQuerySystemInformationEx // since 20H1 // 210
|
|
SystemFeatureConfigurationSectionInformation, // q: in: SYSTEM_FEATURE_CONFIGURATION_SECTIONS_REQUEST, out: SYSTEM_FEATURE_CONFIGURATION_SECTIONS_INFORMATION // NtQuerySystemInformationEx
|
|
SystemFeatureUsageSubscriptionInformation, // q: SYSTEM_FEATURE_USAGE_SUBSCRIPTION_DETAILS; s: SYSTEM_FEATURE_USAGE_SUBSCRIPTION_UPDATE
|
|
SystemSecureSpeculationControlInformation, // q: SECURE_SPECULATION_CONTROL_INFORMATION
|
|
SystemSpacesBootInformation, // q: SYSTEM_SPACES_BOOT_INFORMATION // variable-length opaque blob copied from ExpSpacesBootInformation (kernel mode only) // since 20H2
|
|
SystemFwRamdiskInformation, // q: SYSTEM_FIRMWARE_RAMDISK_INFORMATION
|
|
SystemWheaIpmiHardwareInformation, // q: SYSTEM_WHEA_IPMI_HARDWARE_INFORMATION
|
|
SystemDifSetRuleClassInformation, // s: SYSTEM_DIF_VOLATILE_INFORMATION (requires SeDebugPrivilege)
|
|
SystemDifClearRuleClassInformation, // s: NULL (requires SeDebugPrivilege)
|
|
SystemDifApplyPluginVerificationOnDriver, // q: SYSTEM_DIF_PLUGIN_DRIVER_INFORMATION (requires SeDebugPrivilege)
|
|
SystemDifRemovePluginVerificationOnDriver, // q: SYSTEM_DIF_PLUGIN_DRIVER_INFORMATION (requires SeDebugPrivilege) // 220
|
|
SystemShadowStackInformation, // q: SYSTEM_SHADOW_STACK_INFORMATION
|
|
SystemBuildVersionInformation, // q: in: SYSTEM_BUILD_VERSION_INFORMATION_INPUT, out: SYSTEM_BUILD_VERSION_INFORMATION // NtQuerySystemInformationEx // CmQueryBuildVersionInformation
|
|
SystemPoolLimitInformation, // q: SYSTEM_POOL_LIMIT_INFORMATION (requires SeIncreaseQuotaPrivilege) // NtQuerySystemInformationEx
|
|
SystemCodeIntegrityAddDynamicStore, // q: SYSTEM_CODE_INTEGRITY_DYNAMIC_STORE // CodeIntegrity-AllowConfigurablePolicy-CustomKernelSigners
|
|
SystemCodeIntegrityClearDynamicStores, // q: SYSTEM_CODE_INTEGRITY_DYNAMIC_STORE // CodeIntegrity-AllowConfigurablePolicy-CustomKernelSigners
|
|
SystemDifPoolTrackingInformation, // s: SYSTEM_DIF_POOL_TRACKING_INFORMATION (requires SeDebugPrivilege)
|
|
SystemPoolZeroingInformation, // q: SYSTEM_POOL_ZEROING_INFORMATION
|
|
SystemDpcWatchdogInformation, // qs: SYSTEM_DPC_WATCHDOG_CONFIGURATION_INFORMATION
|
|
SystemDpcWatchdogInformation2, // qs: SYSTEM_DPC_WATCHDOG_CONFIGURATION_INFORMATION_V2
|
|
SystemSupportedProcessorArchitectures2, // q: in opt: HANDLE, out: SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION[] // NtQuerySystemInformationEx // 230
|
|
SystemSingleProcessorRelationshipInformation, // q: SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX // (EX in: PROCESSOR_NUMBER Processor) // NtQuerySystemInformationEx
|
|
SystemXfgCheckFailureInformation, // q: SYSTEM_XFG_FAILURE_INFORMATION
|
|
SystemIommuStateInformation, // q: SYSTEM_IOMMU_STATE_INFORMATION // since 22H1
|
|
SystemHypervisorMinrootInformation, // q: SYSTEM_HYPERVISOR_MINROOT_INFORMATION
|
|
SystemHypervisorBootPagesInformation, // q: SYSTEM_HYPERVISOR_BOOT_PAGES_INFORMATION
|
|
SystemPointerAuthInformation, // q: SYSTEM_POINTER_AUTH_INFORMATION
|
|
SystemSecureKernelDebuggerInformation, // q: in: SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION_INPUT, out: SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION // NtQuerySystemInformationEx // kernel mode only
|
|
SystemOriginalImageFeatureInformation, // q: in: SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_INPUT, out: SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_OUTPUT // NtQuerySystemInformationEx
|
|
SystemMemoryNumaInformation, // q: SYSTEM_MEMORY_NUMA_INFORMATION_INPUT, SYSTEM_MEMORY_NUMA_INFORMATION_OUTPUT // NtQuerySystemInformationEx
|
|
SystemMemoryNumaPerformanceInformation, // q: SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_INPUT, SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_OUTPUT // since 24H2 // 240
|
|
SystemCodeIntegritySignedPoliciesFullInformation, // qs: SYSTEM_CODE_INTEGRITY_SIGNED_POLICIES // NtQuerySystemInformationEx
|
|
SystemSecureCoreInformation, // qs: SYSTEM_SECURE_CORE_INFORMATION // SystemSecureSecretsInformation
|
|
SystemTrustedAppsRuntimeInformation, // q: SYSTEM_TRUSTEDAPPS_RUNTIME_INFORMATION
|
|
SystemBadPageInformationEx, // q: SYSTEM_BAD_PAGE_INFORMATION[] (includes Pending and Poisoned)
|
|
SystemResourceDeadlockTimeout, // q: ULONG
|
|
SystemBreakOnContextUnwindFailureInformation, // q: ULONG (requires SeDebugPrivilege)
|
|
SystemOslRamdiskInformation, // q: SYSTEM_OSL_RAMDISK_INFORMATION
|
|
SystemCodeIntegrityPolicyManagementInformation, // q: SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT // since 25H2
|
|
SystemMemoryNumaCacheInformation, // q: SYSTEM_MEMORY_NUMA_CACHE_INFORMATION
|
|
SystemProcessorFeaturesBitMapInformation, // q: ULONG64[2] // RTL_BITMAP_EX // RtlInitializeBitMapEx // 250
|
|
SystemRefTraceInformationEx, // q: SYSTEM_REF_TRACE_INFORMATION_EX
|
|
SystemBasicProcessInformation, // q: SYSTEM_BASICPROCESS_INFORMATION
|
|
SystemHandleCountInformation, // q: SYSTEM_HANDLECOUNT_INFORMATION
|
|
SystemRuntimeAttestationReport, // q: in: SYSTEM_RUNTIME_REPORT_INPUT (48 bytes on x64), out: report package // NtQuerySystemInformationEx
|
|
SystemPoolTagInformation2, // q: SYSTEM_POOLTAG_INFORMATION2 // since 26H1
|
|
SystemCodeIntegrityEndpointSecurityInformation, // q: SYSTEM_CODE_INTEGRITY_ENDPOINT_SECURITY_INFORMATION
|
|
MaxSystemInfoClass
|
|
} SYSTEM_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The SYSTEM_BASIC_INFORMATION structure contains basic information about the current system.
|
|
*/
|
|
typedef struct _SYSTEM_BASIC_INFORMATION
|
|
{
|
|
ULONG Reserved; // Reserved
|
|
ULONG TimerResolution; // The resolution of the system clock, in 100-nanosecond units. // NtQueryTimerResolution
|
|
ULONG PageSize; // The page size and the granularity of page protection and commitment.
|
|
ULONG NumberOfPhysicalPages; // The number of physical pages in the system. // KUSER_SHARED_DATA->NumberOfPhysicalPages
|
|
ULONG LowestPhysicalPageNumber; // The lowest memory page accessible to applications and dynamic-link libraries (DLLs).
|
|
ULONG HighestPhysicalPageNumber; // The highest memory page accessible to applications and dynamic-link libraries (DLLs).
|
|
ULONG AllocationGranularity; // The granularity for the starting address at which virtual memory can be allocated.
|
|
ULONG_PTR MinimumUserModeAddress; // A pointer to the lowest memory address accessible to applications and dynamic-link libraries (DLLs).
|
|
ULONG_PTR MaximumUserModeAddress; // A pointer to the highest memory address accessible to applications and dynamic-link libraries (DLLs).
|
|
KAFFINITY ActiveProcessorsAffinityMask; // A mask representing the set of processors configured in the current processor group. // deprecated
|
|
UCHAR NumberOfProcessors; // The number of logical processors in the current processor group. // deprecated
|
|
} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION;
|
|
|
|
// SYSTEM_PROCESSOR_INFORMATION // ProcessorFeatureBits (see also SYSTEM_PROCESSOR_FEATURES_INFORMATION)
|
|
#define KF32_V86_VIS 0x00000001 // Virtual 8086 mode.
|
|
#define KF32_RDTSC 0x00000002 // RDTSC (Read Time-Stamp Counter) instruction.
|
|
#define KF32_CR4 0x00000004 // CR4 (Control Register 4) register.
|
|
#define KF32_CMOV 0x00000008 // CMOV (Conditional Move) instruction.
|
|
#define KF32_GLOBAL_PAGE 0x00000010 // Global memory pages.
|
|
#define KF32_LARGE_PAGE 0x00000020 // Large memory pages.
|
|
#define KF32_MTRR 0x00000040 // MTRR (Memory Type Range Registers).
|
|
#define KF32_CMPXCHG8B 0x00000080 // CMPXCHG8B (CompareExchange) instruction.
|
|
#define KF32_MMX 0x00000100 // MMX (MultiMedia eXtensions).
|
|
#define KF32_WORKING_PTE 0x00000200 // PTE (Page Table Entries).
|
|
#define KF32_PAT 0x00000400 // PAT (Page Attribute Table).
|
|
#define KF32_FXSR 0x00000800 // FXSR (Floating Point Extended Save and Restore).
|
|
#define KF32_FAST_SYSCALL 0x00001000 // Fast system calls.
|
|
#define KF32_XMMI 0x00002000 // XMMI (Streaming SIMD Extensions - 32-bit).
|
|
#define KF32_3DNOW 0x00004000 // AMD 3DNow! technology.
|
|
#define KF32_AMDK6MTRR 0x00008000 // AMD K6 MTRR.
|
|
#define KF32_XMMI64 0x00010000 // XMMI (Streaming SIMD Extensions - 64-bit).
|
|
#define KF32_DTS 0x00020000 // DTS (Digital Thermal Sensor).
|
|
#define KF32_TM2 0x00040000 // TM2 (Thermal Monitor 2).
|
|
#define KF32_EST 0x00080000 // EST (Enhanced SpeedStep Technology).
|
|
#define KF32_IA64 0x00100000 // Intel Itanium architecture.
|
|
#define KF32_3DNOW2 0x00200000 // AMD 3DNow! technology, version 2.
|
|
#define KF32_VMX 0x00400000 // VMX (Virtual Machine Extensions).
|
|
#define KF32_SMX 0x00800000 // SMX (Safer Mode Extensions).
|
|
#define KF32_EST2 0x01000000 // EST (Enhanced SpeedStep Technology), version 2.
|
|
#define KF32_SSSE3 0x02000000 // SSSE3 (Supplemental Streaming SIMD Extensions 3).
|
|
#define KF32_CX16 0x04000000 // CMPXCHG16B instruction.
|
|
#define KF32_ETPRD 0x08000000 // ETPRD (Enhanced Time-Stamp Counter Priority Rotation Disable).
|
|
#define KF32_PDCM 0x10000000 // PDCM (Performance and Debug Capability MSR).
|
|
#define KF32_NOEXECUTE 0x20000000 // No-Execute (NX) bit.
|
|
#define KF32_GLOBAL_32BIT_EXECUTE 0x40000000
|
|
#define KF32_GLOBAL_32BIT_NOEXECUTE 0x80000000
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_INFORMATION structure contains information about the current processor.
|
|
*
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_INFORMATION
|
|
{
|
|
USHORT ProcessorArchitecture;
|
|
USHORT ProcessorLevel;
|
|
USHORT ProcessorRevision;
|
|
USHORT MaximumProcessors;
|
|
ULONG ProcessorFeatureBits;
|
|
} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PERFORMANCE_INFORMATION structure contains detailed system-wide performance statistics.
|
|
*/
|
|
typedef struct _SYSTEM_PERFORMANCE_INFORMATION
|
|
{
|
|
LARGE_INTEGER IdleProcessTime; // Total time spent by the idle process (in 100ns units). Used to calculate overall CPU idle percentage; combine with per-processor stats for system CPU usage.
|
|
LARGE_INTEGER IoReadTransferCount; // Total bytes read by all I/O operations system-wide. Combine with IoWriteTransferCount and IoOtherTransferCount for total I/O throughput.
|
|
LARGE_INTEGER IoWriteTransferCount; // Total bytes written by all I/O operations system-wide. Use with IoReadTransferCount for disk throughput analysis.
|
|
LARGE_INTEGER IoOtherTransferCount; // Total bytes transferred by non-read/write I/O operations (e.g., device control). Add to above for total I/O.
|
|
ULONG IoReadOperationCount; // Number of read I/O operations. Use with IoReadTransferCount to get average read size per operation.
|
|
ULONG IoWriteOperationCount; // Number of write I/O operations. Use with IoWriteTransferCount for average write size per operation.
|
|
ULONG IoOtherOperationCount; // Number of non-read/write I/O operations. Combine with above for total I/O operation count. */
|
|
ULONG AvailablePages; // Number of free physical memory pages available for immediate allocation to processes. (Display: Value * PageSize for bytes). Indicates instantly available RAM.
|
|
ULONG CommittedPages; // Number of committed virtual memory pages (backed by RAM or pagefile). Use with CommitLimit to assess memory pressure and overcommit risk.
|
|
ULONG CommitLimit; // Maximum number of pages that can be committed (RAM + pagefile). Compare with CommittedPages to determine available commit space.
|
|
ULONG PeakCommitment; // Highest number of committed pages since boot. Tracks historical maximum memory commitment.
|
|
ULONG PageFaultCount; // Total number of page faults (both soft and hard) since boot. Includes all types of faults.
|
|
ULONG CopyOnWriteCount; // Number of page faults due to copy-on-write events. Subset of PageFaultCount. Indicates process memory sharing and forking activity.
|
|
ULONG TransitionCount; // Number of page faults due to transition from standby to active. Subset of PageFaultCount. Indicates memory reactivation from standby lists.
|
|
ULONG CacheTransitionCount; // Number of page faults due to cache transitions. Subset of TransitionCount. Indicates faults resolved from the system cache.
|
|
ULONG DemandZeroCount; // Number of page faults resolved by zeroing a page (demand-zero). Subset of PageFaultCount. Indicates new memory allocations.
|
|
ULONG PageReadCount; // Number of pages read from disk to resolve faults. Use with PageReadIoCount for read efficiency (pages per I/O).
|
|
ULONG PageReadIoCount; // Number of I/O operations for page reads. Compare with PageReadCount for average pages per I/O.
|
|
ULONG CacheReadCount; // Number of pages read from the system cache. Use with CacheIoCount for cache hit/miss analysis.
|
|
ULONG CacheIoCount; // Number of I/O operations for cache reads. Compare with CacheReadCount for average pages per cache I/O.
|
|
ULONG DirtyPagesWriteCount; // Number of dirty pages written to disk (writeback). Use with DirtyWriteIoCount for write efficiency.
|
|
ULONG DirtyWriteIoCount; // Number of I/O operations for dirty page writes. Compare with DirtyPagesWriteCount for average pages per write I/O.
|
|
ULONG MappedPagesWriteCount; // Number of mapped pages written (e.g., memory-mapped files). Use with MappedWriteIoCount for mapped file activity.
|
|
ULONG MappedWriteIoCount; // Number of I/O operations for mapped page writes. Compare with MappedPagesWriteCount for average mapped write size.
|
|
ULONG PagedPoolPages; // Number of pages used by the paged pool (kernel memory that can be paged out). Combine with NonPagedPoolPages for total pool usage.
|
|
ULONG NonPagedPoolPages; // Number of pages used by the nonpaged pool (kernel memory that must remain resident). Combine with PagedPoolPages for total pool usage.
|
|
ULONG PagedPoolAllocs; // Number of paged pool allocations. Use with PagedPoolFrees for leak detection and pool usage trends.
|
|
ULONG PagedPoolFrees; // Number of paged pool frees. Compare with PagedPoolAllocs to detect leaks or fragmentation.
|
|
ULONG NonPagedPoolAllocs; // Number of nonpaged pool allocations. Use with NonPagedPoolFrees for leak detection.
|
|
ULONG NonPagedPoolFrees; // Number of nonpaged pool frees. Compare with NonPagedPoolAllocs for pool usage.
|
|
ULONG FreeSystemPtes; // Number of free system page table entries (PTEs). Low values may indicate kernel memory exhaustion or fragmentation.
|
|
ULONG ResidentSystemCodePage; // Number of resident pages for system code (kernel and drivers). Use with TotalSystemCodePages for residency ratio.
|
|
ULONG TotalSystemDriverPages; // Total pages used by system drivers. Combine with TotalSystemCodePages for total kernel code usage.
|
|
ULONG TotalSystemCodePages; // Total pages used by system code (kernel + drivers). Use with ResidentSystemCodePage for residency analysis.
|
|
ULONG NonPagedPoolLookasideHits; // Hits in nonpaged pool lookaside lists. Higher values indicate efficient small nonpaged allocations.
|
|
ULONG PagedPoolLookasideHits; // Hits in paged pool lookaside lists. Higher values indicate efficient small paged allocations.
|
|
ULONG AvailablePagedPoolPages; // Number of free pages in the paged pool. Monitor for pool exhaustion or fragmentation.
|
|
ULONG ResidentSystemCachePage; // Resident pages in the system cache. Use with ResidentPagedPoolPage for cache residency analysis.
|
|
ULONG ResidentPagedPoolPage; // Resident pages in the paged pool. Indicates how much of the paged pool is currently resident in RAM.
|
|
ULONG ResidentSystemDriverPage; // Resident pages for system drivers. Use with TotalSystemDriverPages for residency ratio.
|
|
ULONG CcFastReadNoWait; // Fast cache reads completed without waiting. Use with CcFastReadWait for cache performance analysis.
|
|
ULONG CcFastReadWait; // Fast cache reads that required waiting. Compare with CcFastReadNoWait to assess cache latency.
|
|
ULONG CcFastReadResourceMiss; // Fast cache read misses due to resource contention. Indicates cache bottlenecks.
|
|
ULONG CcFastReadNotPossible; // Fast cache reads not possible (e.g., file not cached). Indicates cache limitations or bypasses.
|
|
ULONG CcFastMdlReadNoWait; // Fast MDL (Memory Descriptor List) reads completed without waiting. Use with CcFastMdlReadWait.
|
|
ULONG CcFastMdlReadWait; // Fast MDL reads that required waiting. Compare with CcFastMdlReadNoWait.
|
|
ULONG CcFastMdlReadResourceMiss; // Fast MDL read misses due to resource contention. Indicates MDL bottlenecks.
|
|
ULONG CcFastMdlReadNotPossible; // Fast MDL reads not possible. Indicates MDL limitations or cache bypass.
|
|
ULONG CcMapDataNoWait; // Cache map data operations completed without waiting. Use with CcMapDataWait for mapping efficiency.
|
|
ULONG CcMapDataWait; // Cache map data operations that required waiting. Compare with CcMapDataNoWait.
|
|
ULONG CcMapDataNoWaitMiss; // Cache map data misses without waiting. Indicates mapping bottlenecks.
|
|
ULONG CcMapDataWaitMiss; // Cache map data misses with waiting. Indicates mapping bottlenecks under contention.
|
|
ULONG CcPinMappedDataCount; // Number of pinned mapped data pages. Indicates how much data is locked in cache for I/O.
|
|
ULONG CcPinReadNoWait; // Pin reads completed without waiting. Use with CcPinReadWait for pinning efficiency.
|
|
ULONG CcPinReadWait; // Pin reads that required waiting. Compare with CcPinReadNoWait.
|
|
ULONG CcPinReadNoWaitMiss; // Pin read misses without waiting. Indicates pinning bottlenecks.
|
|
ULONG CcPinReadWaitMiss; // Pin read misses with waiting. Indicates pinning bottlenecks under contention.
|
|
ULONG CcCopyReadNoWait; // Copy reads completed without waiting. Use with CcCopyReadWait for copy efficiency.
|
|
ULONG CcCopyReadWait; // Copy reads that required waiting. Compare with CcCopyReadNoWait.
|
|
ULONG CcCopyReadNoWaitMiss; // Copy read misses without waiting. Indicates copy bottlenecks.
|
|
ULONG CcCopyReadWaitMiss; // Copy read misses with waiting. Indicates copy bottlenecks under contention.
|
|
ULONG CcMdlReadNoWait; // MDL reads completed without waiting. Use with CcMdlReadWait for MDL efficiency.
|
|
ULONG CcMdlReadWait; // MDL reads that required waiting. Compare with CcMdlReadNoWait.
|
|
ULONG CcMdlReadNoWaitMiss; // MDL read misses without waiting. Indicates MDL bottlenecks.
|
|
ULONG CcMdlReadWaitMiss; // MDL read misses with waiting. Indicates MDL bottlenecks under contention.
|
|
ULONG CcReadAheadIos; // Number of read-ahead I/O operations. Indicates cache prefetching activity.
|
|
ULONG CcLazyWriteIos; // Number of lazy write I/O operations. Indicates deferred write activity by the cache manager.
|
|
ULONG CcLazyWritePages; // Number of pages written by the lazy writer. Use with CcLazyWriteIos for writeback efficiency.
|
|
ULONG CcDataFlushes; // Number of cache data flushes. Indicates cache consistency operations (e.g., file close).
|
|
ULONG CcDataPages; // Number of pages flushed from cache. Use with CcDataFlushes for average flush size.
|
|
ULONG ContextSwitches; // Number of context switches system-wide. Use for CPU scheduling and multitasking analysis.
|
|
ULONG FirstLevelTbFills; // First-level translation buffer (TLB) fills. Indicates TLB efficiency and memory access patterns.
|
|
ULONG SecondLevelTbFills; // Second-level TLB fills. Indicates deeper TLB misses and memory access patterns.
|
|
ULONG SystemCalls; // Number of system calls made. Use for syscall activity and system workload analysis.
|
|
ULONGLONG CcTotalDirtyPages; // Total number of dirty pages in the cache (since Windows 10/Threshold). Use with CcDirtyPageThreshold for writeback policy. // since THRESHOLD
|
|
ULONGLONG CcDirtyPageThreshold; // Dirty page threshold for the cache. Compare with CcTotalDirtyPages to determine if writeback is needed.
|
|
LONGLONG ResidentAvailablePages; // Number of available pages that are resident in memory. Combine with AvailablePages for residency analysis.
|
|
ULONGLONG SharedCommittedPages; // Number of committed pages that are shared (e.g., mapped by multiple processes). Useful for shared memory analysis.
|
|
ULONGLONG MdlPagesAllocated; // Number of pages allocated for MDLs (since Windows 11 24H2). Indicates MDL resource usage. // since 24H2
|
|
ULONGLONG PfnDatabaseCommittedPages; // Number of pages committed for the PFN (Page Frame Number) database. Kernel memory usage for tracking physical pages.
|
|
ULONGLONG SystemPageTableCommittedPages; // Number of pages committed for system page tables. Kernel memory usage for virtual-to-physical mapping structures.
|
|
ULONGLONG ContiguousPagesAllocated; // Number of contiguous pages allocated. Indicates large memory allocations (e.g., for DMA or drivers).
|
|
} SYSTEM_PERFORMANCE_INFORMATION, *PSYSTEM_PERFORMANCE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_TIMEOFDAY_INFORMATION structure contains information about the system uptime.
|
|
*/
|
|
typedef struct _SYSTEM_TIMEOFDAY_INFORMATION
|
|
{
|
|
LARGE_INTEGER BootTime; // Number of 100-nanosecond intervals since the system was started.
|
|
LARGE_INTEGER CurrentTime; // The current system date and time.
|
|
LARGE_INTEGER TimeZoneBias; // Number of 100-nanosecond intervals between local time and Coordinated Universal Time (UTC).
|
|
ULONG TimeZoneId; // The current system time zone identifier.
|
|
ULONG Reserved; // Reserved
|
|
ULONGLONG BootTimeBias; // Number of 100-nanosecond intervals between the boot time and Coordinated Universal Time (UTC).
|
|
ULONGLONG SleepTimeBias; // Number of 100-nanosecond intervals between the sleep time and Coordinated Universal Time (UTC).
|
|
} SYSTEM_TIMEOFDAY_INFORMATION, *PSYSTEM_TIMEOFDAY_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_THREAD_INFORMATION structure contains information about a thread running on a system.
|
|
* https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsts/e82d73e4-cedb-4077-9099-d58f3459722f
|
|
*/
|
|
typedef struct _SYSTEM_THREAD_INFORMATION
|
|
{
|
|
LARGE_INTEGER KernelTime; // Number of 100-nanosecond intervals spent executing kernel code.
|
|
LARGE_INTEGER UserTime; // Number of 100-nanosecond intervals spent executing user code.
|
|
LARGE_INTEGER CreateTime; // The date and time when the thread was created.
|
|
ULONG WaitTime; // The current time spent in ready queue or waiting (depending on the thread state).
|
|
PVOID StartAddress; // The initial start address of the thread.
|
|
CLIENT_ID ClientId; // The identifier of the thread and the process owning the thread.
|
|
KPRIORITY Priority; // The dynamic priority of the thread.
|
|
KPRIORITY BasePriority; // The starting priority of the thread.
|
|
ULONG ContextSwitches; // The total number of context switches performed.
|
|
KTHREAD_STATE ThreadState; // The current state of the thread.
|
|
KWAIT_REASON WaitReason; // The current reason the thread is waiting.
|
|
} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESS_INFORMATION structure contains information about a process running on a system.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_PROCESS_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset; // The address of the previous item plus the value in the NextEntryOffset member. For the last item in the array, NextEntryOffset is 0.
|
|
ULONG NumberOfThreads; // The NumberOfThreads member contains the number of threads in the process.
|
|
ULONGLONG WorkingSetPrivateSize; // The total private memory that a process currently has allocated and is physically resident in memory. // since VISTA
|
|
ULONG HardFaultCount; // The total number of hard faults for data from disk rather than from in-memory pages. // since WIN7
|
|
ULONG NumberOfThreadsHighWatermark; // The peak number of threads that were running at any given point in time, indicative of potential performance bottlenecks related to thread management.
|
|
ULONGLONG CycleTime; // The sum of the cycle time of all threads in the process.
|
|
LARGE_INTEGER CreateTime; // Number of 100-nanosecond intervals since the creation time of the process. Not updated during system timezone changes.
|
|
LARGE_INTEGER UserTime; // Number of 100-nanosecond intervals the process has executed in user mode.
|
|
LARGE_INTEGER KernelTime; // Number of 100-nanosecond intervals the process has executed in kernel mode.
|
|
UNICODE_STRING ImageName; // The file name of the executable image.
|
|
KPRIORITY BasePriority; // The starting priority of the process.
|
|
HANDLE UniqueProcessId; // The identifier of the process.
|
|
HANDLE InheritedFromUniqueProcessId; // The identifier of the process that created this process. Not updated and incorrectly refers to processes with recycled identifiers.
|
|
ULONG HandleCount; // The current number of open handles used by the process.
|
|
ULONG SessionId; // The identifier of the Remote Desktop Services session under which the specified process is running.
|
|
ULONG_PTR UniqueProcessKey; // since VISTA (requires SystemExtendedProcessInformation)
|
|
SIZE_T PeakVirtualSize; // The peak size, in bytes, of the virtual memory used by the process.
|
|
SIZE_T VirtualSize; // The current size, in bytes, of virtual memory used by the process.
|
|
ULONG PageFaultCount; // The total number of page faults for data that is not currently in memory. The value wraps around to zero on average 24 hours.
|
|
SIZE_T PeakWorkingSetSize; // The peak size, in kilobytes, of the working set of the process.
|
|
SIZE_T WorkingSetSize; // The number of pages visible to the process in physical memory. These pages are resident and available for use without triggering a page fault.
|
|
SIZE_T QuotaPeakPagedPoolUsage; // The peak quota charged to the process for pool usage, in bytes.
|
|
SIZE_T QuotaPagedPoolUsage; // The quota charged to the process for paged pool usage, in bytes.
|
|
SIZE_T QuotaPeakNonPagedPoolUsage; // The peak quota charged to the process for nonpaged pool usage, in bytes.
|
|
SIZE_T QuotaNonPagedPoolUsage; // The current quota charged to the process for nonpaged pool usage.
|
|
SIZE_T PagefileUsage; // The total number of bytes of page file storage in use by the process.
|
|
SIZE_T PeakPagefileUsage; // The maximum number of bytes of page-file storage used by the process.
|
|
SIZE_T PrivatePageCount; // The number of memory pages allocated for the use by the process.
|
|
LARGE_INTEGER ReadOperationCount; // The total number of read operations performed.
|
|
LARGE_INTEGER WriteOperationCount; // The total number of write operations performed.
|
|
LARGE_INTEGER OtherOperationCount; // The total number of I/O operations performed other than read and write operations.
|
|
LARGE_INTEGER ReadTransferCount; // The total number of bytes read during a read operation.
|
|
LARGE_INTEGER WriteTransferCount; // The total number of bytes written during a write operation.
|
|
LARGE_INTEGER OtherTransferCount; // The total number of bytes transferred during operations other than read and write operations.
|
|
SYSTEM_THREAD_INFORMATION Threads[1]; // This type is not defined in the structure but was added for convenience.
|
|
} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_EXTENDED_THREAD_INFORMATION structure contains extended information about a thread in the system.
|
|
*/
|
|
typedef struct _SYSTEM_EXTENDED_THREAD_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
SYSTEM_THREAD_INFORMATION ThreadInfo;
|
|
struct
|
|
{
|
|
ULONGLONG KernelTime; // Number of 100-nanosecond intervals spent executing kernel code.
|
|
ULONGLONG UserTime; // Number of 100-nanosecond intervals spent executing user code.
|
|
ULONGLONG CreateTime; // The date and time when the thread was created.
|
|
ULONG WaitTime; // The current time spent in ready queue or waiting (depending on the thread state).
|
|
PVOID StartAddress; // The initial start address of the thread.
|
|
CLIENT_ID ClientId; // The identifier of the thread and the process owning the thread.
|
|
KPRIORITY Priority; // The dynamic priority of the thread.
|
|
KPRIORITY BasePriority; // The starting priority of the thread.
|
|
ULONG ContextSwitches; // The total number of context switches performed.
|
|
KTHREAD_STATE ThreadState; // The current state of the thread.
|
|
KWAIT_REASON WaitReason; // The current reason the thread is waiting.
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
PVOID StackBase; // The lower boundary of the current thread stack.
|
|
PVOID StackLimit; // The upper boundary of the current thread stack.
|
|
PVOID Win32StartAddress; // The thread's Win32 start address.
|
|
PVOID TebBaseAddress; // The base address of the memory region containing the TEB structure. // since VISTA
|
|
ULONG_PTR Reserved2;
|
|
ULONG_PTR Reserved3;
|
|
ULONG_PTR Reserved4;
|
|
} SYSTEM_EXTENDED_THREAD_INFORMATION, *PSYSTEM_EXTENDED_THREAD_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_EXTENDED_PROCESS_INFORMATION structure contains extended information about a process running on a system.
|
|
* https://learn.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-system_extended_process_information
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_EXTENDED_PROCESS_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset; // The address of the previous item plus the value in the NextEntryOffset member. For the last item in the array, NextEntryOffset is 0.
|
|
ULONG NumberOfThreads; // The NumberOfThreads member contains the number of threads in the process.
|
|
ULONGLONG WorkingSetPrivateSize; // The total private memory that a process currently has allocated and is physically resident in memory. // since VISTA
|
|
ULONG HardFaultCount; // The total number of hard faults for data from disk rather than from in-memory pages. // since WIN7
|
|
ULONG NumberOfThreadsHighWatermark; // The peak number of threads that were running at any given point in time, indicative of potential performance bottlenecks related to thread management.
|
|
ULONGLONG CycleTime; // The sum of the cycle time of all threads in the process.
|
|
ULONGLONG CreateTime; // Number of 100-nanosecond intervals since the creation time of the process. Not updated during system timezone changes.
|
|
ULONGLONG UserTime; // Number of 100-nanosecond intervals the process has executed in user mode.
|
|
ULONGLONG KernelTime; // Number of 100-nanosecond intervals the process has executed in kernel mode.
|
|
UNICODE_STRING ImageName; // The file name of the executable image.
|
|
KPRIORITY BasePriority; // The starting priority of the process.
|
|
HANDLE UniqueProcessId; // The identifier of the process.
|
|
HANDLE InheritedFromUniqueProcessId; // The identifier of the process that created this process. Not updated and incorrectly refers to processes with recycled identifiers.
|
|
ULONG HandleCount; // The current number of open handles used by the process.
|
|
ULONG SessionId; // The identifier of the Remote Desktop Services session under which the specified process is running.
|
|
HANDLE UniqueProcessKey; // since VISTA (requires SystemExtendedProcessInformation)
|
|
SIZE_T PeakVirtualSize; // The peak size, in bytes, of the virtual memory used by the process.
|
|
SIZE_T VirtualSize; // The current size, in bytes, of virtual memory used by the process.
|
|
ULONG PageFaultCount; // The total number of page faults for data that is not currently in memory. The value wraps around to zero on average 24 hours.
|
|
SIZE_T PeakWorkingSetSize; // The peak size, in kilobytes, of the working set of the process.
|
|
SIZE_T WorkingSetSize; // The number of pages visible to the process in physical memory. These pages are resident and available for use without triggering a page fault.
|
|
SIZE_T QuotaPeakPagedPoolUsage; // The peak quota charged to the process for pool usage, in bytes.
|
|
SIZE_T QuotaPagedPoolUsage; // The quota charged to the process for paged pool usage, in bytes.
|
|
SIZE_T QuotaPeakNonPagedPoolUsage; // The peak quota charged to the process for nonpaged pool usage, in bytes.
|
|
SIZE_T QuotaNonPagedPoolUsage; // The current quota charged to the process for nonpaged pool usage.
|
|
SIZE_T PagefileUsage; // The total number of bytes of page file storage in use by the process.
|
|
SIZE_T PeakPagefileUsage; // The maximum number of bytes of page-file storage used by the process.
|
|
SIZE_T PrivatePageCount; // The number of memory pages allocated for the use by the process.
|
|
ULONGLONG ReadOperationCount; // The total number of read operations performed.
|
|
ULONGLONG WriteOperationCount; // The total number of write operations performed.
|
|
ULONGLONG OtherOperationCount; // The total number of I/O operations performed other than read and write operations.
|
|
ULONGLONG ReadTransferCount; // The total number of bytes read during a read operation.
|
|
ULONGLONG WriteTransferCount; // The total number of bytes written during a write operation.
|
|
ULONGLONG OtherTransferCount; // The total number of bytes transferred during operations other than read and write operations.
|
|
SYSTEM_THREAD_INFORMATION Threads[1]; // This type is not defined in the structure but was added for convenience.
|
|
// SYSTEM_PROCESS_INFORMATION_EXTENSION // SystemFullProcessInformation
|
|
} SYSTEM_EXTENDED_PROCESS_INFORMATION, *PSYSTEM_EXTENDED_PROCESS_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_CALL_COUNT_INFORMATION structure contains per-processor system service call counts.
|
|
*/
|
|
typedef struct _SYSTEM_CALL_COUNT_INFORMATION
|
|
{
|
|
ULONG Length;
|
|
ULONG NumberOfTables;
|
|
} SYSTEM_CALL_COUNT_INFORMATION, *PSYSTEM_CALL_COUNT_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_DEVICE_INFORMATION structure contains information about the devices in the system.
|
|
*/
|
|
typedef struct _SYSTEM_DEVICE_INFORMATION
|
|
{
|
|
ULONG NumberOfDisks;
|
|
ULONG NumberOfFloppies;
|
|
ULONG NumberOfCdRoms;
|
|
ULONG NumberOfTapes;
|
|
ULONG NumberOfSerialPorts;
|
|
ULONG NumberOfParallelPorts;
|
|
} SYSTEM_DEVICE_INFORMATION, *PSYSTEM_DEVICE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION structure contains information about the performance of each processor installed in the system.
|
|
* https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation#system_processor_performance_information
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
|
|
{
|
|
LARGE_INTEGER IdleTime; // The IdleTime member contains the amount of time that the system has been idle, in 100-nanosecond intervals.
|
|
LARGE_INTEGER KernelTime; // The KernelTime member contains the amount of time that the system has spent executing in Kernel mode (including all threads in all processes, on all processors), in 100-nanosecond intervals.
|
|
LARGE_INTEGER UserTime; // The UserTime member contains the amount of time that the system has spent executing in User mode (including all threads in all processes, on all processors), in 100-nanosecond intervals.
|
|
LARGE_INTEGER DpcTime; // The DpcTime member contains the amount of time that the system has spent processing deferred procedure calls (DPCs), in 100-nanosecond intervals.
|
|
LARGE_INTEGER InterruptTime; // The InterruptTime member contains the amount of time that the system has spent processing hardware interrupts, in 100-nanosecond intervals.
|
|
ULONG InterruptCount; // The InterruptCount member contains the number of interrupts that have occurred, as counted by the system.
|
|
ULONG Spare0;
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_FLAGS_INFORMATION structure contains the global NT flags that control kernel debugging and instrumentation.
|
|
*/
|
|
typedef struct _SYSTEM_FLAGS_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG Flags; // NtGlobalFlag
|
|
struct
|
|
{
|
|
ULONG StopOnException : 1; // FLG_STOP_ON_EXCEPTION
|
|
ULONG ShowLoaderSnaps : 1; // FLG_SHOW_LDR_SNAPS
|
|
ULONG DebugInitialCommand : 1; // FLG_DEBUG_INITIAL_COMMAND
|
|
ULONG StopOnHungGUI : 1; // FLG_STOP_ON_HUNG_GUI
|
|
ULONG HeapEnableTailCheck : 1; // FLG_HEAP_ENABLE_TAIL_CHECK
|
|
ULONG HeapEnableFreeCheck : 1; // FLG_HEAP_ENABLE_FREE_CHECK
|
|
ULONG HeapValidateParameters : 1; // FLG_HEAP_VALIDATE_PARAMETERS
|
|
ULONG HeapValidateAll : 1; // FLG_HEAP_VALIDATE_ALL
|
|
ULONG ApplicationVerifier : 1; // FLG_APPLICATION_VERIFIER
|
|
ULONG MonitorSilentProcessExit : 1; // FLG_MONITOR_SILENT_PROCESS_EXIT
|
|
ULONG PoolEnableTagging : 1; // FLG_POOL_ENABLE_TAGGING
|
|
ULONG HeapEnableTagging : 1; // FLG_HEAP_ENABLE_TAGGING
|
|
ULONG UserStackTraceDb : 1; // FLG_USER_STACK_TRACE_DB
|
|
ULONG KernelStackTraceDb : 1; // FLG_KERNEL_STACK_TRACE_DB
|
|
ULONG MaintainObjectTypeList : 1; // FLG_MAINTAIN_OBJECT_TYPELIST
|
|
ULONG HeapEnableTagByDll : 1; // FLG_HEAP_ENABLE_TAG_BY_DLL
|
|
ULONG DisableStackExtension : 1; // FLG_DISABLE_STACK_EXTENSION
|
|
ULONG EnableCsrDebug : 1; // FLG_ENABLE_CSRDEBUG
|
|
ULONG EnableKDebugSymbolLoad : 1; // FLG_ENABLE_KDEBUG_SYMBOL_LOAD
|
|
ULONG DisablePageKernelStacks : 1; // FLG_DISABLE_PAGE_KERNEL_STACKS
|
|
ULONG EnableSystemCritBreaks : 1; // FLG_ENABLE_SYSTEM_CRIT_BREAKS
|
|
ULONG HeapDisableCoalescing : 1; // FLG_HEAP_DISABLE_COALESCING
|
|
ULONG EnableCloseExceptions : 1; // FLG_ENABLE_CLOSE_EXCEPTIONS
|
|
ULONG EnableExceptionLogging : 1; // FLG_ENABLE_EXCEPTION_LOGGING
|
|
ULONG EnableHandleTypeTagging : 1; // FLG_ENABLE_HANDLE_TYPE_TAGGING
|
|
ULONG HeapPageAllocs : 1; // FLG_HEAP_PAGE_ALLOCS
|
|
ULONG DebugInitialCommandEx : 1; // FLG_DEBUG_INITIAL_COMMAND_EX
|
|
ULONG DisableDbgPrint : 1; // FLG_DISABLE_DBGPRINT
|
|
ULONG CritSecEventCreation : 1; // FLG_CRITSEC_EVENT_CREATION
|
|
ULONG LdrTopDown : 1; // FLG_LDR_TOP_DOWN
|
|
ULONG EnableHandleExceptions : 1; // FLG_ENABLE_HANDLE_EXCEPTIONS
|
|
ULONG DisableProtDlls : 1; // FLG_DISABLE_PROTDLLS
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_FLAGS_INFORMATION, *PSYSTEM_FLAGS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CALL_TIME_INFORMATION structure contains timing information for system service calls.
|
|
*/
|
|
typedef struct _SYSTEM_CALL_TIME_INFORMATION
|
|
{
|
|
ULONG Length;
|
|
ULONG TotalCalls;
|
|
LARGE_INTEGER TimeOfCalls[1];
|
|
} SYSTEM_CALL_TIME_INFORMATION, *PSYSTEM_CALL_TIME_INFORMATION;
|
|
|
|
// RTL_PROCESS_LOCK_INFORMATION Type
|
|
#define RTL_CRITSECT_TYPE 0
|
|
#define RTL_RESOURCE_TYPE 1
|
|
|
|
// private
|
|
/**
|
|
* The RTL_PROCESS_LOCK_INFORMATION structure describes a single critical section or resource lock in a process.
|
|
*/
|
|
typedef struct _RTL_PROCESS_LOCK_INFORMATION
|
|
{
|
|
PVOID Address;
|
|
USHORT Type;
|
|
USHORT CreatorBackTraceIndex;
|
|
HANDLE OwningThread;
|
|
LONG LockCount;
|
|
ULONG ContentionCount;
|
|
ULONG EntryCount;
|
|
LONG RecursionCount;
|
|
ULONG NumberOfWaitingShared;
|
|
ULONG NumberOfWaitingExclusive;
|
|
} RTL_PROCESS_LOCK_INFORMATION, *PRTL_PROCESS_LOCK_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The RTL_PROCESS_LOCKS structure contains information about all locks held within a process.
|
|
*/
|
|
typedef struct _RTL_PROCESS_LOCKS
|
|
{
|
|
ULONG NumberOfLocks;
|
|
_Field_size_(NumberOfLocks) RTL_PROCESS_LOCK_INFORMATION Locks[1];
|
|
} RTL_PROCESS_LOCKS, *PRTL_PROCESS_LOCKS;
|
|
|
|
// private
|
|
/**
|
|
* The RTL_PROCESS_BACKTRACE_INFORMATION structure describes a single stack back trace captured for a process.
|
|
*/
|
|
typedef struct _RTL_PROCESS_BACKTRACE_INFORMATION
|
|
{
|
|
PCHAR SymbolicBackTrace;
|
|
ULONG TraceCount;
|
|
USHORT Index;
|
|
USHORT Depth;
|
|
PVOID BackTrace[32];
|
|
} RTL_PROCESS_BACKTRACE_INFORMATION, *PRTL_PROCESS_BACKTRACE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The RTL_PROCESS_BACKTRACES structure contains the stack back traces captured for a process.
|
|
*/
|
|
typedef struct _RTL_PROCESS_BACKTRACES
|
|
{
|
|
SIZE_T CommittedMemory;
|
|
SIZE_T ReservedMemory;
|
|
ULONG NumberOfBackTraceLookups;
|
|
ULONG NumberOfBackTraces;
|
|
_Field_size_(NumberOfBackTraces) RTL_PROCESS_BACKTRACE_INFORMATION BackTraces[1];
|
|
} RTL_PROCESS_BACKTRACES, *PRTL_PROCESS_BACKTRACES;
|
|
|
|
// Note: This information class is deprecated since values are limited to 65535. Use SystemExtendedHandleInformation instead.
|
|
/**
|
|
* The SYSTEM_HANDLE_TABLE_ENTRY_INFO structure describes a single open handle in the system-wide handle table.
|
|
*/
|
|
typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO
|
|
{
|
|
USHORT UniqueProcessId;
|
|
USHORT CreatorBackTraceIndex;
|
|
UCHAR ObjectTypeIndex;
|
|
UCHAR HandleAttributes;
|
|
USHORT HandleValue;
|
|
PVOID Object;
|
|
ACCESS_MASK GrantedAccess;
|
|
} SYSTEM_HANDLE_TABLE_ENTRY_INFO, *PSYSTEM_HANDLE_TABLE_ENTRY_INFO;
|
|
|
|
/**
|
|
* The SYSTEM_HANDLE_INFORMATION structure contains information about the open handles in the system.
|
|
*/
|
|
typedef struct _SYSTEM_HANDLE_INFORMATION
|
|
{
|
|
ULONG NumberOfHandles;
|
|
_Field_size_(NumberOfHandles) SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[1];
|
|
} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_OBJECTTYPE_INFORMATION structure contains information about an object type in the system.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_OBJECTTYPE_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG NumberOfObjects;
|
|
ULONG NumberOfHandles;
|
|
ULONG TypeIndex;
|
|
ULONG InvalidAttributes;
|
|
GENERIC_MAPPING GenericMapping;
|
|
ACCESS_MASK ValidAccessMask;
|
|
ULONG PoolType;
|
|
BOOLEAN SecurityRequired;
|
|
BOOLEAN WaitableObject;
|
|
UNICODE_STRING TypeName;
|
|
} SYSTEM_OBJECTTYPE_INFORMATION, *PSYSTEM_OBJECTTYPE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_OBJECT_INFORMATION structure contains information about an object in the system.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_OBJECT_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset;
|
|
PVOID Object;
|
|
HANDLE CreatorUniqueProcess;
|
|
USHORT CreatorBackTraceIndex;
|
|
USHORT Flags;
|
|
LONG PointerCount;
|
|
LONG HandleCount;
|
|
ULONG PagedPoolCharge;
|
|
ULONG NonPagedPoolCharge;
|
|
HANDLE ExclusiveProcessId;
|
|
PSECURITY_DESCRIPTOR SecurityDescriptor;
|
|
UNICODE_STRING NameInfo;
|
|
} SYSTEM_OBJECT_INFORMATION, *PSYSTEM_OBJECT_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PAGEFILE_INFORMATION structure contains information about a paging file in the system.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_PAGEFILE_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG TotalSize;
|
|
ULONG TotalInUse;
|
|
ULONG PeakUsage;
|
|
UNICODE_STRING PageFileName;
|
|
} SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_VDM_INSTEMUL_INFO structure contains statistics about VDM instruction emulation.
|
|
*/
|
|
typedef struct _SYSTEM_VDM_INSTEMUL_INFO
|
|
{
|
|
ULONG SegmentNotPresent;
|
|
ULONG VdmOpcode0F;
|
|
ULONG OpcodeESPrefix;
|
|
ULONG OpcodeCSPrefix;
|
|
ULONG OpcodeSSPrefix;
|
|
ULONG OpcodeDSPrefix;
|
|
ULONG OpcodeFSPrefix;
|
|
ULONG OpcodeGSPrefix;
|
|
ULONG OpcodeOPER32Prefix;
|
|
ULONG OpcodeADDR32Prefix;
|
|
ULONG OpcodeINSB;
|
|
ULONG OpcodeINSW;
|
|
ULONG OpcodeOUTSB;
|
|
ULONG OpcodeOUTSW;
|
|
ULONG OpcodePUSHF;
|
|
ULONG OpcodePOPF;
|
|
ULONG OpcodeINTnn;
|
|
ULONG OpcodeINTO;
|
|
ULONG OpcodeIRET;
|
|
ULONG OpcodeINBimm;
|
|
ULONG OpcodeINWimm;
|
|
ULONG OpcodeOUTBimm;
|
|
ULONG OpcodeOUTWimm;
|
|
ULONG OpcodeINB;
|
|
ULONG OpcodeINW;
|
|
ULONG OpcodeOUTB;
|
|
ULONG OpcodeOUTW;
|
|
ULONG OpcodeLOCKPrefix;
|
|
ULONG OpcodeREPNEPrefix;
|
|
ULONG OpcodeREPPrefix;
|
|
ULONG OpcodeHLT;
|
|
ULONG OpcodeCLI;
|
|
ULONG OpcodeSTI;
|
|
ULONG BopCount;
|
|
} SYSTEM_VDM_INSTEMUL_INFO, *PSYSTEM_VDM_INSTEMUL_INFO;
|
|
|
|
#define MM_WORKING_SET_MAX_HARD_ENABLE 0x1
|
|
#define MM_WORKING_SET_MAX_HARD_DISABLE 0x2
|
|
#define MM_WORKING_SET_MIN_HARD_ENABLE 0x4
|
|
#define MM_WORKING_SET_MIN_HARD_DISABLE 0x8
|
|
|
|
// SYSTEM_FILECACHE_INFORMATION.Flags / SetSystemFileCacheSize flags
|
|
// #define FILE_CACHE_MAX_HARD_ENABLE MM_WORKING_SET_MAX_HARD_ENABLE
|
|
// #define FILE_CACHE_MAX_HARD_DISABLE MM_WORKING_SET_MAX_HARD_DISABLE
|
|
// #define FILE_CACHE_MIN_HARD_ENABLE MM_WORKING_SET_MIN_HARD_ENABLE
|
|
// #define FILE_CACHE_MIN_HARD_DISABLE MM_WORKING_SET_MIN_HARD_DISABLE
|
|
|
|
/**
|
|
* The SYSTEM_FILECACHE_INFORMATION structure contains information about the system file cache.
|
|
*/
|
|
typedef struct _SYSTEM_FILECACHE_INFORMATION
|
|
{
|
|
SIZE_T CurrentSize;
|
|
SIZE_T PeakSize;
|
|
ULONG PageFaultCount;
|
|
SIZE_T MinimumWorkingSet;
|
|
SIZE_T MaximumWorkingSet;
|
|
SIZE_T CurrentSizeIncludingTransitionInPages;
|
|
SIZE_T PeakSizeIncludingTransitionInPages;
|
|
ULONG TransitionRePurposeCount;
|
|
ULONG Flags; // FILE_CACHE_* / MM_WORKING_SET_* flags
|
|
} SYSTEM_FILECACHE_INFORMATION, *PSYSTEM_FILECACHE_INFORMATION;
|
|
|
|
// Can be used instead of SYSTEM_FILECACHE_INFORMATION
|
|
/**
|
|
* The SYSTEM_BASIC_WORKING_SET_INFORMATION structure contains basic working set information for the system.
|
|
*/
|
|
typedef struct _SYSTEM_BASIC_WORKING_SET_INFORMATION
|
|
{
|
|
SIZE_T CurrentSize;
|
|
SIZE_T PeakSize;
|
|
ULONG PageFaultCount;
|
|
} SYSTEM_BASIC_WORKING_SET_INFORMATION, *PSYSTEM_BASIC_WORKING_SET_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_POOLTAG structure describes pool allocation statistics for a single pool tag.
|
|
*/
|
|
typedef struct _SYSTEM_POOLTAG
|
|
{
|
|
union
|
|
{
|
|
UCHAR Tag[4];
|
|
ULONG TagUlong;
|
|
} DUMMYUNIONNAME;
|
|
ULONG PagedAllocs;
|
|
ULONG PagedFrees;
|
|
SIZE_T PagedUsed;
|
|
ULONG NonPagedAllocs;
|
|
ULONG NonPagedFrees;
|
|
SIZE_T NonPagedUsed;
|
|
} SYSTEM_POOLTAG, *PSYSTEM_POOLTAG;
|
|
|
|
/**
|
|
* The SYSTEM_POOLTAG_INFORMATION structure contains pool allocation statistics for all pool tags in the system.
|
|
*/
|
|
typedef struct _SYSTEM_POOLTAG_INFORMATION
|
|
{
|
|
ULONG Count;
|
|
_Field_size_(Count) SYSTEM_POOLTAG TagInfo[1];
|
|
} SYSTEM_POOLTAG_INFORMATION, *PSYSTEM_POOLTAG_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_INTERRUPT_INFORMATION structure contains interrupt statistics for a processor.
|
|
*/
|
|
typedef struct _SYSTEM_INTERRUPT_INFORMATION
|
|
{
|
|
ULONG ContextSwitches;
|
|
ULONG DpcCount;
|
|
ULONG DpcRate;
|
|
ULONG TimeIncrement;
|
|
ULONG DpcBypassCount;
|
|
ULONG ApcBypassCount;
|
|
} SYSTEM_INTERRUPT_INFORMATION, *PSYSTEM_INTERRUPT_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_DPC_BEHAVIOR_INFORMATION structure contains the deferred procedure call (DPC) timeout and behavior settings.
|
|
*/
|
|
typedef struct _SYSTEM_DPC_BEHAVIOR_INFORMATION
|
|
{
|
|
ULONG Spare;
|
|
ULONG DpcQueueDepth;
|
|
ULONG MinimumDpcRate;
|
|
ULONG AdjustDpcThreshold;
|
|
ULONG IdealDpcRate;
|
|
} SYSTEM_DPC_BEHAVIOR_INFORMATION, *PSYSTEM_DPC_BEHAVIOR_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_QUERY_TIME_ADJUST_INFORMATION structure contains the current time adjustment settings.
|
|
*/
|
|
typedef struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION
|
|
{
|
|
ULONG TimeAdjustment;
|
|
ULONG TimeIncrement;
|
|
BOOLEAN Enable;
|
|
} SYSTEM_QUERY_TIME_ADJUST_INFORMATION, *PSYSTEM_QUERY_TIME_ADJUST_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_QUERY_TIME_ADJUST_INFORMATION_PRECISE structure contains the current high-precision time adjustment settings.
|
|
*/
|
|
typedef struct _SYSTEM_QUERY_TIME_ADJUST_INFORMATION_PRECISE
|
|
{
|
|
ULONGLONG TimeAdjustment;
|
|
ULONGLONG TimeIncrement;
|
|
BOOLEAN Enable;
|
|
} SYSTEM_QUERY_TIME_ADJUST_INFORMATION_PRECISE, *PSYSTEM_QUERY_TIME_ADJUST_INFORMATION_PRECISE;
|
|
|
|
/**
|
|
* The SYSTEM_SET_TIME_ADJUST_INFORMATION structure specifies the time adjustment settings to apply.
|
|
*/
|
|
typedef struct _SYSTEM_SET_TIME_ADJUST_INFORMATION
|
|
{
|
|
ULONG TimeAdjustment;
|
|
BOOLEAN Enable;
|
|
} SYSTEM_SET_TIME_ADJUST_INFORMATION, *PSYSTEM_SET_TIME_ADJUST_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_SET_TIME_ADJUST_INFORMATION_PRECISE structure specifies the high-precision time adjustment settings to apply.
|
|
*/
|
|
typedef struct _SYSTEM_SET_TIME_ADJUST_INFORMATION_PRECISE
|
|
{
|
|
ULONGLONG TimeAdjustment;
|
|
BOOLEAN Enable;
|
|
} SYSTEM_SET_TIME_ADJUST_INFORMATION_PRECISE, *PSYSTEM_SET_TIME_ADJUST_INFORMATION_PRECISE;
|
|
|
|
/**
|
|
* The EVENT_TRACE_INFORMATION_CLASS enumeration defines the information classes used with event tracing (ETW).
|
|
*/
|
|
typedef enum _EVENT_TRACE_INFORMATION_CLASS
|
|
{
|
|
EventTraceKernelVersionInformation, // q: EVENT_TRACE_VERSION_INFORMATION
|
|
EventTraceGroupMaskInformation, // qs: EVENT_TRACE_GROUPMASK_INFORMATION
|
|
EventTracePerformanceInformation, // q: EVENT_TRACE_PERFORMANCE_INFORMATION
|
|
EventTraceTimeProfileInformation, // qs: EVENT_TRACE_TIME_PROFILE_INFORMATION
|
|
EventTraceSessionSecurityInformation, // s: EVENT_TRACE_SESSION_SECURITY_INFORMATION
|
|
EventTraceSpinlockInformation, // s: EVENT_TRACE_SPINLOCK_INFORMATION
|
|
EventTraceStackTracingInformation, // s: EVENT_TRACE_STACK_TRACING_INFORMATION
|
|
EventTraceExecutiveResourceInformation, // s: EVENT_TRACE_EXECUTIVE_RESOURCE_INFORMATION
|
|
EventTraceHeapTracingInformation, // s: EVENT_TRACE_HEAP_TRACING_INFORMATION
|
|
EventTraceHeapSummaryTracingInformation, // s: EVENT_TRACE_HEAP_TRACING_INFORMATION
|
|
EventTracePoolTagFilterInformation, // s: EVENT_TRACE_POOLTAG_FILTER_INFORMATION
|
|
EventTracePebsTracingInformation, // s: EVENT_TRACE_PEBS_TRACING_INFORMATION
|
|
EventTraceProfileConfigInformation, // s: EVENT_TRACE_PROFILE_CONFIG_INFORMATION
|
|
EventTraceProfileSourceListInformation, // q: EVENT_TRACE_PROFILE_LIST_INFORMATION
|
|
EventTraceProfileEventListInformation, // s: EVENT_TRACE_PROFILE_EVENT_INFORMATION
|
|
EventTraceProfileCounterListInformation, // s: EVENT_TRACE_PROFILE_COUNTER_INFORMATION
|
|
EventTraceStackCachingInformation, // s: EVENT_TRACE_STACK_CACHING_INFORMATION
|
|
EventTraceObjectTypeFilterInformation, // s: EVENT_TRACE_OBJECT_TYPE_FILTER_INFORMATION
|
|
EventTraceSoftRestartInformation, // s: EVENT_TRACE_SOFT_RESTART_INFORMATION
|
|
EventTraceLastBranchConfigurationInformation, // s: EVENT_TRACE_LAST_BRANCH_CONFIGURATION_INFORMATION // REDSTONE3
|
|
EventTraceLastBranchEventListInformation, // s: EVENT_TRACE_PROFILE_EVENT_INFORMATION
|
|
EventTraceProfileSourceAddInformation, // s: EVENT_TRACE_PROFILE_ADD_INFORMATION // REDSTONE4
|
|
EventTraceProfileSourceRemoveInformation, // s: EVENT_TRACE_PROFILE_REMOVE_INFORMATION
|
|
EventTraceProcessorTraceConfigurationInformation, // s: EVENT_TRACE_PROCESSOR_TRACE_CONFIGURATION_INFORMATION
|
|
EventTraceProcessorTraceEventListInformation, // s: EVENT_TRACE_PROFILE_EVENT_INFORMATION
|
|
EventTraceCoverageSamplerInformation, // s: EVENT_TRACE_COVERAGE_SAMPLER_INFORMATION
|
|
EventTraceUnifiedStackCachingInformation, // s: EVENT_TRACE_STACK_CACHING_INFORMATION // since 21H1
|
|
EventTraceContextRegisterTraceInformation, // s: EVENT_TRACE_CONTEXT_REGISTER_INFO // 24H2
|
|
MaxEventTraceInfoClass
|
|
} EVENT_TRACE_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The EVENT_TRACE_VERSION_INFORMATION structure contains event trace version information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_VERSION_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG EventTraceKernelVersion;
|
|
} EVENT_TRACE_VERSION_INFORMATION, *PEVENT_TRACE_VERSION_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_GROUPMASK_INFORMATION structure contains event trace groupmask information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_GROUPMASK_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
ULONG Masks[8]; // PERFINFO_GROUPMASK
|
|
} EVENT_TRACE_GROUPMASK_INFORMATION, *PEVENT_TRACE_GROUPMASK_INFORMATION;
|
|
|
|
#define EVENT_TRACE_LAST_BRANCH_EVENT_OPCODE 0x20
|
|
#define EVENT_TRACE_LAST_BRANCH_MAXIMUM_EVENTS 4
|
|
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_NONE 0x00000000
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_KERNEL 0x00000001
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_USER 0x00000002
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_JCC 0x00000004
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_NEAR_REL_CALL 0x00000008
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_NEAR_IND_CALL 0x00000010
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_NEAR_RET 0x00000020
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_NEAR_IND_JMP 0x00000040
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_NEAR_REL_JMP 0x00000080
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_EXCLUDE_FAR_BRANCH 0x00000100
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_CALLSTACK_ENABLE 0x00000200
|
|
#define EVENT_TRACE_LAST_BRANCH_CONFIGURATION_SAMPLED 0x00000400
|
|
|
|
/**
|
|
* The EVENT_TRACE_LAST_BRANCH_EVENT_ID structure describes the event trace last branch event id.
|
|
*/
|
|
typedef struct _EVENT_TRACE_LAST_BRANCH_EVENT_ID
|
|
{
|
|
GUID EventGuid;
|
|
UCHAR Type;
|
|
UCHAR Reserved[7];
|
|
} EVENT_TRACE_LAST_BRANCH_EVENT_ID, *PEVENT_TRACE_LAST_BRANCH_EVENT_ID;
|
|
|
|
/**
|
|
* The EVENT_TRACE_LAST_BRANCH_CONFIGURATION_INFORMATION structure contains event trace last branch configuration information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_LAST_BRANCH_CONFIGURATION_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG LbrConfiguration; // EVENT_TRACE_LAST_BRANCH_CONFIGURATION_* flags
|
|
ULONG EventCount; // Number of valid entries in Events, up to EVENT_TRACE_LAST_BRANCH_MAXIMUM_EVENTS.
|
|
EVENT_TRACE_LAST_BRANCH_EVENT_ID Events[EVENT_TRACE_LAST_BRANCH_MAXIMUM_EVENTS];
|
|
} EVENT_TRACE_LAST_BRANCH_CONFIGURATION_INFORMATION, *PEVENT_TRACE_LAST_BRANCH_CONFIGURATION_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROCESSOR_TRACE_CONFIGURATION_INFORMATION structure contains event trace processor trace configuration information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PROCESSOR_TRACE_CONFIGURATION_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
PVOID Callback; // Kernel-mode processor trace configuration callback passed to the ETW hardware trace extension.
|
|
} EVENT_TRACE_PROCESSOR_TRACE_CONFIGURATION_INFORMATION, *PEVENT_TRACE_PROCESSOR_TRACE_CONFIGURATION_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PERFORMANCE_INFORMATION structure contains event trace performance information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PERFORMANCE_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
LARGE_INTEGER LogfileBytesWritten;
|
|
} EVENT_TRACE_PERFORMANCE_INFORMATION, *PEVENT_TRACE_PERFORMANCE_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_TIME_PROFILE_INFORMATION structure contains event trace time profile information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_TIME_PROFILE_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG ProfileInterval;
|
|
} EVENT_TRACE_TIME_PROFILE_INFORMATION, *PEVENT_TRACE_TIME_PROFILE_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_SESSION_SECURITY_INFORMATION structure contains event trace session security information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_SESSION_SECURITY_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG SecurityInformation;
|
|
TRACEHANDLE TraceHandle;
|
|
UCHAR SecurityDescriptor[1];
|
|
} EVENT_TRACE_SESSION_SECURITY_INFORMATION, *PEVENT_TRACE_SESSION_SECURITY_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_SPINLOCK_INFORMATION structure contains event trace spinlock information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_SPINLOCK_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG SpinLockSpinThreshold;
|
|
ULONG SpinLockAcquireSampleRate;
|
|
ULONG SpinLockContentionSampleRate;
|
|
ULONG SpinLockHoldThreshold;
|
|
} EVENT_TRACE_SPINLOCK_INFORMATION, *PEVENT_TRACE_SPINLOCK_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_SYSTEM_EVENT_INFORMATION structure contains event trace system event information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_SYSTEM_EVENT_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
ULONG HookId[1];
|
|
} EVENT_TRACE_SYSTEM_EVENT_INFORMATION, *PEVENT_TRACE_SYSTEM_EVENT_INFORMATION;
|
|
|
|
typedef EVENT_TRACE_SYSTEM_EVENT_INFORMATION EVENT_TRACE_STACK_TRACING_INFORMATION, *PEVENT_TRACE_STACK_TRACING_INFORMATION;
|
|
typedef EVENT_TRACE_SYSTEM_EVENT_INFORMATION EVENT_TRACE_PEBS_TRACING_INFORMATION, *PEVENT_TRACE_PEBS_TRACING_INFORMATION;
|
|
typedef EVENT_TRACE_SYSTEM_EVENT_INFORMATION EVENT_TRACE_PROFILE_EVENT_INFORMATION, *PEVENT_TRACE_PROFILE_EVENT_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_EXECUTIVE_RESOURCE_INFORMATION structure contains event trace executive resource information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_EXECUTIVE_RESOURCE_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG ReleaseSamplingRate;
|
|
ULONG ContentionSamplingRate;
|
|
ULONG NumberOfExcessiveTimeouts;
|
|
} EVENT_TRACE_EXECUTIVE_RESOURCE_INFORMATION, *PEVENT_TRACE_EXECUTIVE_RESOURCE_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_HEAP_TRACING_INFORMATION structure contains event trace heap tracing information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_HEAP_TRACING_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG ProcessId[1];
|
|
} EVENT_TRACE_HEAP_TRACING_INFORMATION, *PEVENT_TRACE_HEAP_TRACING_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_TAG_FILTER_INFORMATION structure contains event trace tag filter information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_TAG_FILTER_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
ULONG Filter[1];
|
|
} EVENT_TRACE_TAG_FILTER_INFORMATION, *PEVENT_TRACE_TAG_FILTER_INFORMATION;
|
|
|
|
typedef EVENT_TRACE_TAG_FILTER_INFORMATION EVENT_TRACE_POOLTAG_FILTER_INFORMATION, *PEVENT_TRACE_POOLTAG_FILTER_INFORMATION;
|
|
typedef EVENT_TRACE_TAG_FILTER_INFORMATION EVENT_TRACE_OBJECT_TYPE_FILTER_INFORMATION, *PEVENT_TRACE_OBJECT_TYPE_FILTER_INFORMATION;
|
|
|
|
// ProfileSource
|
|
#define ETW_MAX_PROFILING_SOURCES 4
|
|
#define ETW_MAX_PMC_EVENTS 4
|
|
#define ETW_MAX_PMC_COUNTERS 4
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_COUNTER_INFORMATION structure contains event trace profile counter information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PROFILE_COUNTER_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
ULONG ProfileSource[1];
|
|
} EVENT_TRACE_PROFILE_COUNTER_INFORMATION, *PEVENT_TRACE_PROFILE_COUNTER_INFORMATION;
|
|
|
|
typedef EVENT_TRACE_PROFILE_COUNTER_INFORMATION EVENT_TRACE_PROFILE_CONFIG_INFORMATION, *PEVENT_TRACE_PROFILE_CONFIG_INFORMATION;
|
|
|
|
//_Struct_size_bytes_(NextEntryOffset)
|
|
//typedef struct _PROFILE_SOURCE_INFO
|
|
//{
|
|
// ULONG NextEntryOffset;
|
|
// ULONG Source;
|
|
// ULONG MinInterval;
|
|
// ULONG MaxInterval;
|
|
// PVOID Reserved;
|
|
// WCHAR Description[1];
|
|
//} PROFILE_SOURCE_INFO, *PPROFILE_SOURCE_INFO;
|
|
|
|
typedef struct _PROFILE_SOURCE_INFO *PPROFILE_SOURCE_INFO;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_LIST_INFORMATION structure contains event trace profile list information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PROFILE_LIST_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
ULONG Spare;
|
|
PPROFILE_SOURCE_INFO Profile[1];
|
|
} EVENT_TRACE_PROFILE_LIST_INFORMATION, *PEVENT_TRACE_PROFILE_LIST_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_STACK_CACHING_INFORMATION structure contains event trace stack caching information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_STACK_CACHING_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
BOOLEAN Enabled;
|
|
UCHAR Reserved[3];
|
|
ULONG CacheSize;
|
|
ULONG BucketCount;
|
|
} EVENT_TRACE_STACK_CACHING_INFORMATION, *PEVENT_TRACE_STACK_CACHING_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_SOFT_RESTART_INFORMATION structure contains event trace soft restart information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_SOFT_RESTART_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
TRACEHANDLE TraceHandle;
|
|
BOOLEAN PersistTraceBuffers;
|
|
WCHAR FileName[1];
|
|
} EVENT_TRACE_SOFT_RESTART_INFORMATION, *PEVENT_TRACE_SOFT_RESTART_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_ADD_INFORMATION_VERSIONS enumeration defines the supported versions of event trace profile add information.
|
|
*/
|
|
typedef enum _EVENT_TRACE_PROFILE_ADD_INFORMATION_VERSIONS
|
|
{
|
|
EventTraceProfileAddInformationMinVersion = 0x2,
|
|
EventTraceProfileAddInformationV2 = 0x2,
|
|
EventTraceProfileAddInformationV3 = 0x3,
|
|
EventTraceProfileAddInformationMaxVersion = 0x3,
|
|
} EVENT_TRACE_PROFILE_ADD_INFORMATION_VERSIONS;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_ADD_INFORMATION_V2 union contains event trace profile add information.
|
|
*/
|
|
typedef union _EVENT_TRACE_PROFILE_ADD_INFORMATION_V2
|
|
{
|
|
struct
|
|
{
|
|
UCHAR PerfEvtEventSelect;
|
|
UCHAR PerfEvtUnitSelect;
|
|
UCHAR PerfEvtCMask;
|
|
UCHAR PerfEvtCInv;
|
|
UCHAR PerfEvtAnyThread;
|
|
UCHAR PerfEvtEdgeDetect;
|
|
} Intel;
|
|
struct
|
|
{
|
|
UCHAR PerfEvtEventSelect;
|
|
UCHAR PerfEvtUnitSelect;
|
|
} Amd;
|
|
struct
|
|
{
|
|
ULONG PerfEvtType;
|
|
UCHAR AllowsHalt;
|
|
} Arm;
|
|
} EVENT_TRACE_PROFILE_ADD_INFORMATION_V2;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_ADD_INFORMATION_V3 union contains event trace profile add information.
|
|
*/
|
|
typedef union _EVENT_TRACE_PROFILE_ADD_INFORMATION_V3
|
|
{
|
|
struct
|
|
{
|
|
UCHAR PerfEvtEventSelect;
|
|
UCHAR PerfEvtUnitSelect;
|
|
UCHAR PerfEvtCMask;
|
|
UCHAR PerfEvtCInv;
|
|
UCHAR PerfEvtAnyThread;
|
|
UCHAR PerfEvtEdgeDetect;
|
|
} Intel;
|
|
struct
|
|
{
|
|
USHORT PerfEvtEventSelect;
|
|
UCHAR PerfEvtUnitSelect;
|
|
UCHAR PerfEvtCMask;
|
|
UCHAR PerfEvtCInv;
|
|
UCHAR PerfEvtEdgeDetect;
|
|
UCHAR PerfEvtHostGuest;
|
|
UCHAR PerfPmuType;
|
|
} Amd;
|
|
struct
|
|
{
|
|
ULONG PerfEvtType;
|
|
UCHAR AllowsHalt;
|
|
} Arm;
|
|
} EVENT_TRACE_PROFILE_ADD_INFORMATION_V3;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_ADD_INFORMATION structure contains event trace profile add information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PROFILE_ADD_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
UCHAR Version;
|
|
union
|
|
{
|
|
EVENT_TRACE_PROFILE_ADD_INFORMATION_V2 V2;
|
|
EVENT_TRACE_PROFILE_ADD_INFORMATION_V3 V3;
|
|
} DUMMYUNIONNAME;
|
|
ULONG CpuInfoHierarchy[0x3];
|
|
ULONG InitialInterval;
|
|
BOOLEAN Persist;
|
|
WCHAR ProfileSourceDescription[0x1];
|
|
} EVENT_TRACE_PROFILE_ADD_INFORMATION, *PEVENT_TRACE_PROFILE_ADD_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_PROFILE_REMOVE_INFORMATION structure contains event trace profile remove information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_PROFILE_REMOVE_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
KPROFILE_SOURCE ProfileSource;
|
|
ULONG CpuInfoHierarchy[0x3];
|
|
} EVENT_TRACE_PROFILE_REMOVE_INFORMATION, *PEVENT_TRACE_PROFILE_REMOVE_INFORMATION;
|
|
|
|
/**
|
|
* The EVENT_TRACE_COVERAGE_SAMPLER_INFORMATION structure contains event trace coverage sampler information.
|
|
*/
|
|
typedef struct _EVENT_TRACE_COVERAGE_SAMPLER_INFORMATION
|
|
{
|
|
EVENT_TRACE_INFORMATION_CLASS EventTraceInformationClass;
|
|
UCHAR CoverageSamplerInformationClass;
|
|
UCHAR MajorVersion;
|
|
UCHAR MinorVersion;
|
|
UCHAR Reserved;
|
|
HANDLE SamplerHandle;
|
|
} EVENT_TRACE_COVERAGE_SAMPLER_INFORMATION, *PEVENT_TRACE_COVERAGE_SAMPLER_INFORMATION;
|
|
|
|
// typedef enum _ETW_CONTEXT_REGISTER_TYPES
|
|
// {
|
|
// EtwContextRegisterTypeNone = 0,
|
|
// EtwContextRegisterTypeControl = 0x1,
|
|
// EtwContextRegisterTypeInteger = 0x2
|
|
// } ETW_CONTEXT_REGISTER_TYPES;
|
|
//
|
|
// typedef struct _EVENT_TRACE_CONTEXT_REGISTER_INFO
|
|
// {
|
|
// ETW_CONTEXT_REGISTER_TYPES RegisterTypes;
|
|
// ULONG Reserved;
|
|
// } EVENT_TRACE_CONTEXT_REGISTER_INFO, *PEVENT_TRACE_CONTEXT_REGISTER_INFO;
|
|
|
|
/**
|
|
* The SYSTEM_EXCEPTION_INFORMATION structure contains system-wide exception dispatching statistics.
|
|
*/
|
|
typedef struct _SYSTEM_EXCEPTION_INFORMATION
|
|
{
|
|
ULONG AlignmentFixupCount;
|
|
ULONG ExceptionDispatchCount;
|
|
ULONG FloatingEmulationCount;
|
|
ULONG ByteWordEmulationCount;
|
|
} SYSTEM_EXCEPTION_INFORMATION, *PSYSTEM_EXCEPTION_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_CRASH_DUMP_CONFIGURATION_CLASS enumeration defines the system crash dump configuration classes.
|
|
*/
|
|
typedef enum _SYSTEM_CRASH_DUMP_CONFIGURATION_CLASS
|
|
{
|
|
SystemCrashDumpDisable,
|
|
SystemCrashDumpReconfigure,
|
|
SystemCrashDumpInitializationComplete
|
|
} SYSTEM_CRASH_DUMP_CONFIGURATION_CLASS, *PSYSTEM_CRASH_DUMP_CONFIGURATION_CLASS;
|
|
|
|
/**
|
|
* The SYSTEM_CRASH_DUMP_STATE_INFORMATION structure contains system crash dump state information.
|
|
*/
|
|
typedef struct _SYSTEM_CRASH_DUMP_STATE_INFORMATION
|
|
{
|
|
SYSTEM_CRASH_DUMP_CONFIGURATION_CLASS CrashDumpConfigurationClass;
|
|
} SYSTEM_CRASH_DUMP_STATE_INFORMATION, *PSYSTEM_CRASH_DUMP_STATE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_KERNEL_DEBUGGER_INFORMATION structure indicates whether a kernel debugger is present and enabled.
|
|
*/
|
|
typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION
|
|
{
|
|
BOOLEAN KernelDebuggerEnabled;
|
|
BOOLEAN KernelDebuggerNotPresent;
|
|
} SYSTEM_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_CONTEXT_SWITCH_INFORMATION structure contains system-wide context switch statistics.
|
|
*/
|
|
typedef struct _SYSTEM_CONTEXT_SWITCH_INFORMATION
|
|
{
|
|
ULONG ContextSwitches;
|
|
ULONG FindAny;
|
|
ULONG FindLast;
|
|
ULONG FindIdeal;
|
|
ULONG IdleAny;
|
|
ULONG IdleCurrent;
|
|
ULONG IdleLast;
|
|
ULONG IdleIdeal;
|
|
ULONG PreemptAny;
|
|
ULONG PreemptCurrent;
|
|
ULONG PreemptLast;
|
|
ULONG SwitchToIdle;
|
|
} SYSTEM_CONTEXT_SWITCH_INFORMATION, *PSYSTEM_CONTEXT_SWITCH_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_REGISTRY_QUOTA_INFORMATION structure contains the registry quota limits and current usage.
|
|
*/
|
|
typedef struct _SYSTEM_REGISTRY_QUOTA_INFORMATION
|
|
{
|
|
ULONG RegistryQuotaAllowed;
|
|
ULONG RegistryQuotaUsed;
|
|
SIZE_T PagedPoolSize;
|
|
} SYSTEM_REGISTRY_QUOTA_INFORMATION, *PSYSTEM_REGISTRY_QUOTA_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_IDLE_INFORMATION structure contains per-processor idle time statistics.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_IDLE_INFORMATION
|
|
{
|
|
ULONGLONG IdleTime;
|
|
ULONGLONG C1Time;
|
|
ULONGLONG C2Time;
|
|
ULONGLONG C3Time;
|
|
ULONG C1Transitions;
|
|
ULONG C2Transitions;
|
|
ULONG C3Transitions;
|
|
ULONG Padding;
|
|
} SYSTEM_PROCESSOR_IDLE_INFORMATION, *PSYSTEM_PROCESSOR_IDLE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_LEGACY_DRIVER_INFORMATION structure contains information about legacy drivers in the system.
|
|
*/
|
|
typedef struct _SYSTEM_LEGACY_DRIVER_INFORMATION
|
|
{
|
|
ULONG VetoType;
|
|
UNICODE_STRING VetoList;
|
|
} SYSTEM_LEGACY_DRIVER_INFORMATION, *PSYSTEM_LEGACY_DRIVER_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_LOOKASIDE_INFORMATION structure contains statistics for the system lookaside lists.
|
|
*/
|
|
typedef struct _SYSTEM_LOOKASIDE_INFORMATION
|
|
{
|
|
USHORT CurrentDepth;
|
|
USHORT MaximumDepth;
|
|
ULONG TotalAllocates;
|
|
ULONG AllocateMisses;
|
|
ULONG TotalFrees;
|
|
ULONG FreeMisses;
|
|
ULONG Type;
|
|
ULONG Tag;
|
|
ULONG Size;
|
|
} SYSTEM_LOOKASIDE_INFORMATION, *PSYSTEM_LOOKASIDE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_RANGE_START_INFORMATION structure contains the start address of the system virtual address range.
|
|
*/
|
|
typedef struct _SYSTEM_RANGE_START_INFORMATION
|
|
{
|
|
ULONG_PTR SystemRangeStart;
|
|
} SYSTEM_RANGE_START_INFORMATION, *PSYSTEM_RANGE_START_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_VERIFIER_INFORMATION_LEGACY structure describes the system verifier information legacy.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_VERIFIER_INFORMATION_LEGACY // pre-19H1
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG Level;
|
|
UNICODE_STRING DriverName;
|
|
ULONG RaiseIrqls;
|
|
ULONG AcquireSpinLocks;
|
|
ULONG SynchronizeExecutions;
|
|
ULONG AllocationsAttempted;
|
|
ULONG AllocationsSucceeded;
|
|
ULONG AllocationsSucceededSpecialPool;
|
|
ULONG AllocationsWithNoTag;
|
|
ULONG TrimRequests;
|
|
ULONG Trims;
|
|
ULONG AllocationsFailed;
|
|
ULONG AllocationsFailedDeliberately;
|
|
ULONG Loads;
|
|
ULONG Unloads;
|
|
ULONG UnTrackedPool;
|
|
ULONG CurrentPagedPoolAllocations;
|
|
ULONG CurrentNonPagedPoolAllocations;
|
|
ULONG PeakPagedPoolAllocations;
|
|
ULONG PeakNonPagedPoolAllocations;
|
|
SIZE_T PagedPoolUsageInBytes;
|
|
SIZE_T NonPagedPoolUsageInBytes;
|
|
SIZE_T PeakPagedPoolUsageInBytes;
|
|
SIZE_T PeakNonPagedPoolUsageInBytes;
|
|
} SYSTEM_VERIFIER_INFORMATION_LEGACY, *PSYSTEM_VERIFIER_INFORMATION_LEGACY;
|
|
|
|
/**
|
|
* The SYSTEM_VERIFIER_INFORMATION structure contains system verifier information.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_VERIFIER_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG Level;
|
|
ULONG RuleClasses[2];
|
|
ULONG TriageContext;
|
|
ULONG AreAllDriversBeingVerified;
|
|
UNICODE_STRING DriverName;
|
|
ULONG RaiseIrqls;
|
|
ULONG AcquireSpinLocks;
|
|
ULONG SynchronizeExecutions;
|
|
ULONG AllocationsAttempted;
|
|
ULONG AllocationsSucceeded;
|
|
ULONG AllocationsSucceededSpecialPool;
|
|
ULONG AllocationsWithNoTag;
|
|
ULONG TrimRequests;
|
|
ULONG Trims;
|
|
ULONG AllocationsFailed;
|
|
ULONG AllocationsFailedDeliberately;
|
|
ULONG Loads;
|
|
ULONG Unloads;
|
|
ULONG UnTrackedPool;
|
|
ULONG CurrentPagedPoolAllocations;
|
|
ULONG CurrentNonPagedPoolAllocations;
|
|
ULONG PeakPagedPoolAllocations;
|
|
ULONG PeakNonPagedPoolAllocations;
|
|
SIZE_T PagedPoolUsageInBytes;
|
|
SIZE_T NonPagedPoolUsageInBytes;
|
|
SIZE_T PeakPagedPoolUsageInBytes;
|
|
SIZE_T PeakNonPagedPoolUsageInBytes;
|
|
} SYSTEM_VERIFIER_INFORMATION, *PSYSTEM_VERIFIER_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SESSION_PROCESS_INFORMATION structure contains system session process information.
|
|
*/
|
|
typedef struct _SYSTEM_SESSION_PROCESS_INFORMATION
|
|
{
|
|
ULONG SessionId;
|
|
ULONG BufferSize;
|
|
PVOID Buffer;
|
|
} SYSTEM_SESSION_PROCESS_INFORMATION, *PSYSTEM_SESSION_PROCESS_INFORMATION;
|
|
|
|
#if (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
// private
|
|
// Validates that ServiceTableName is exactly "\\SystemRoot\\System32\\win32k.sys"
|
|
// and forwards it to ZwSetSystemInformation(SystemLoadGdiDriverInSystemSpace, ...).
|
|
/**
|
|
* The SYSTEM_EXTEND_SERVICE_TABLE_INFORMATION structure contains system extend service table information.
|
|
*/
|
|
typedef struct _SYSTEM_EXTEND_SERVICE_TABLE_INFORMATION
|
|
{
|
|
UNICODE_STRING ServiceTableName;
|
|
} SYSTEM_EXTEND_SERVICE_TABLE_INFORMATION, *PSYSTEM_EXTEND_SERVICE_TABLE_INFORMATION;
|
|
|
|
// private
|
|
// Consumed by PsChangeQuantumTable(ApplyToProcesses = TRUE, PrioritySeparation).
|
|
#define PSPRIORITYSEPARATION_MASK 0x03
|
|
#define PSQUANTUMTYPE_MASK 0x0C
|
|
#define PSFOREGROUNDQUANTUM_MASK 0x30
|
|
|
|
#define PSQUANTUMTYPE_DEFAULT 0x00 // Product-type default: variable on workstation, fixed on server.
|
|
#define PSQUANTUMTYPE_VARIABLE 0x04 // Sets KiVariableQuantumEnabled = TRUE and uses PspVariableQuantums or PspVariableQuantums_With_ShortQuantum.
|
|
#define PSQUANTUMTYPE_FIXED 0x08 // Sets KiVariableQuantumEnabled = FALSE and uses PspFixedQuantums.
|
|
|
|
#define PSFOREGROUNDQUANTUM_DEFAULT 0x00
|
|
#define PSFOREGROUNDQUANTUM_ALTERNATE 0x10
|
|
#define PSFOREGROUNDQUANTUM_BASE 0x20
|
|
|
|
/**
|
|
* The SYSTEM_PRIORITY_SEPARATION_INFORMATION structure contains system priority separation information.
|
|
*/
|
|
typedef struct _SYSTEM_PRIORITY_SEPARATION_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG PrioritySeparation;
|
|
struct
|
|
{
|
|
ULONG PrioritySeparationValue : 2;
|
|
ULONG QuantumType : 2;
|
|
ULONG ForegroundQuantum : 2;
|
|
ULONG Reserved : 26;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_PRIORITY_SEPARATION_INFORMATION, *PSYSTEM_PRIORITY_SEPARATION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The recommended alignment equals the system's largest cache-line size, in bytes.
|
|
*
|
|
* So the returned value is simply:
|
|
* - KeLargestCacheLine
|
|
*/
|
|
typedef struct _SYSTEM_RECOMMENDED_SHARED_DATA_ALIGNMENT_INFORMATION
|
|
{
|
|
ULONG RecommendedSharedDataAlignment;
|
|
} SYSTEM_RECOMMENDED_SHARED_DATA_ALIGNMENT_INFORMATION, *PSYSTEM_RECOMMENDED_SHARED_DATA_ALIGNMENT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Used by SystemComPlusPackage.
|
|
*
|
|
* NtSetSystemInformation(SystemComPlusPackage, ...) expects a 4-byte value,
|
|
* passes it to ExpUpdateComPlusPackage, and mirrors the result into
|
|
* KUSER_SHARED_DATA.ComPlusPackage.
|
|
*/
|
|
typedef struct _SYSTEM_COMPLUS_PACKAGE_INFORMATION
|
|
{
|
|
ULONG ComPlusPackage;
|
|
} SYSTEM_COMPLUS_PACKAGE_INFORMATION, *PSYSTEM_COMPLUS_PACKAGE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_LOST_DELAYED_WRITE_INFORMATION structure contains system lost delayed write information.
|
|
*/
|
|
typedef struct _SYSTEM_LOST_DELAYED_WRITE_INFORMATION
|
|
{
|
|
ULONG LostDelayedWrites;
|
|
} SYSTEM_LOST_DELAYED_WRITE_INFORMATION, *PSYSTEM_LOST_DELAYED_WRITE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Used by SystemObjectSecurityMode.
|
|
*
|
|
* SeSecurityModelQueryInformation returns a 4-byte mode value.
|
|
* The value is initialized to 0 and set to 2 when
|
|
* SepIsDeviceOwnerProtectionDowngradeAllowed() returns TRUE.
|
|
*/
|
|
typedef struct _SYSTEM_OBJECT_SECURITY_MODE_INFORMATION
|
|
{
|
|
ULONG ObjectSecurityMode;
|
|
} SYSTEM_OBJECT_SECURITY_MODE_INFORMATION, *PSYSTEM_OBJECT_SECURITY_MODE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Used by SystemAitSamplingValue.
|
|
*
|
|
* AIT refers to Application Impact Telemetry.
|
|
*
|
|
* NtSetSystemInformation(SystemAitSamplingValue, ...) expects a 4-byte value
|
|
* and mirrors it into KUSER_SHARED_DATA.AitSamplingValue.
|
|
*/
|
|
typedef struct _SYSTEM_AIT_SAMPLING_VALUE_INFORMATION
|
|
{
|
|
ULONG AitSamplingValue;
|
|
} SYSTEM_AIT_SAMPLING_VALUE_INFORMATION, *PSYSTEM_AIT_SAMPLING_VALUE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_GDI_DRIVER_INFORMATION_V0 structure contains system GDI driver information.
|
|
*/
|
|
typedef struct _SYSTEM_GDI_DRIVER_INFORMATION_V0
|
|
{
|
|
UNICODE_STRING DriverName;
|
|
PVOID ImageAddress;
|
|
PVOID SectionPointer;
|
|
PVOID EntryPoint;
|
|
ULONG ImageLength;
|
|
} SYSTEM_GDI_DRIVER_INFORMATION_V0, *PSYSTEM_GDI_DRIVER_INFORMATION_V0;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_GDI_DRIVER_INFORMATION_V1 structure contains system GDI driver information.
|
|
*/
|
|
typedef struct _SYSTEM_GDI_DRIVER_INFORMATION_V1
|
|
{
|
|
UNICODE_STRING DriverName;
|
|
PVOID ImageAddress;
|
|
PVOID SectionPointer;
|
|
PVOID EntryPoint;
|
|
PIMAGE_EXPORT_DIRECTORY ExportSectionPointer;
|
|
ULONG ImageLength;
|
|
} SYSTEM_GDI_DRIVER_INFORMATION_V1, *PSYSTEM_GDI_DRIVER_INFORMATION_V1;
|
|
|
|
#define SYSTEM_GDI_DRIVER_INFORMATION SYSTEM_GDI_DRIVER_INFORMATION_V1
|
|
#define PSYSTEM_GDI_DRIVER_INFORMATION PSYSTEM_GDI_DRIVER_INFORMATION_V1
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_GDI_DRIVER_UNLOAD_INFORMATION structure contains system GDI driver unload information.
|
|
*/
|
|
typedef struct _SYSTEM_GDI_DRIVER_UNLOAD_INFORMATION
|
|
{
|
|
PVOID SectionPointer;
|
|
} SYSTEM_GDI_DRIVER_UNLOAD_INFORMATION, *PSYSTEM_GDI_DRIVER_UNLOAD_INFORMATION;
|
|
#endif // (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
// geoffchappell
|
|
#ifdef _WIN64
|
|
#define MAXIMUM_NODE_COUNT 0x40
|
|
#else
|
|
#define MAXIMUM_NODE_COUNT 0x10
|
|
#endif
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_NUMA_INFORMATION structure contains system NUMA information.
|
|
*/
|
|
typedef struct _SYSTEM_NUMA_INFORMATION
|
|
{
|
|
ULONG HighestNodeNumber;
|
|
ULONG Reserved;
|
|
union
|
|
{
|
|
GROUP_AFFINITY ActiveProcessorsGroupAffinity[MAXIMUM_NODE_COUNT];
|
|
ULONGLONG AvailableMemory[MAXIMUM_NODE_COUNT];
|
|
ULONGLONG Pad[MAXIMUM_NODE_COUNT * 2];
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_NUMA_INFORMATION, *PSYSTEM_NUMA_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_POWER_INFORMATION structure contains system processor power information.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_POWER_INFORMATION
|
|
{
|
|
UCHAR CurrentFrequency;
|
|
UCHAR ThermalLimitFrequency;
|
|
UCHAR ConstantThrottleFrequency;
|
|
UCHAR DegradedThrottleFrequency;
|
|
UCHAR LastBusyFrequency;
|
|
UCHAR LastC3Frequency;
|
|
UCHAR LastAdjustedBusyFrequency;
|
|
UCHAR ProcessorMinThrottle;
|
|
UCHAR ProcessorMaxThrottle;
|
|
ULONG NumberOfFrequencies;
|
|
ULONG PromotionCount;
|
|
ULONG DemotionCount;
|
|
ULONG ErrorCount;
|
|
ULONG RetryCount;
|
|
ULONGLONG CurrentFrequencyTime;
|
|
ULONGLONG CurrentProcessorTime;
|
|
ULONGLONG CurrentProcessorIdleTime;
|
|
ULONGLONG LastProcessorTime;
|
|
ULONGLONG LastProcessorIdleTime;
|
|
ULONGLONG Energy;
|
|
} SYSTEM_PROCESSOR_POWER_INFORMATION, *PSYSTEM_PROCESSOR_POWER_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX structure describes a single open handle in the system, with extended information.
|
|
*/
|
|
typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX
|
|
{
|
|
PVOID Object;
|
|
HANDLE UniqueProcessId;
|
|
HANDLE HandleValue;
|
|
ACCESS_MASK GrantedAccess;
|
|
USHORT CreatorBackTraceIndex;
|
|
USHORT ObjectTypeIndex;
|
|
ULONG HandleAttributes;
|
|
ULONG Reserved;
|
|
} SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX, *PSYSTEM_HANDLE_TABLE_ENTRY_INFO_EX;
|
|
|
|
/**
|
|
* The SYSTEM_HANDLE_INFORMATION_EX structure contains extended information about the open handles in the system.
|
|
*/
|
|
typedef struct _SYSTEM_HANDLE_INFORMATION_EX
|
|
{
|
|
ULONG_PTR NumberOfHandles;
|
|
ULONG_PTR Reserved;
|
|
_Field_size_(NumberOfHandles) SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handles[1];
|
|
} SYSTEM_HANDLE_INFORMATION_EX, *PSYSTEM_HANDLE_INFORMATION_EX;
|
|
|
|
/**
|
|
* The SYSTEM_BIGPOOL_ENTRY structure describes a single large pool allocation.
|
|
*/
|
|
typedef struct _SYSTEM_BIGPOOL_ENTRY
|
|
{
|
|
union
|
|
{
|
|
PVOID VirtualAddress;
|
|
ULONG_PTR NonPaged : 1;
|
|
} DUMMYUNIONNAME;
|
|
SIZE_T SizeInBytes;
|
|
union
|
|
{
|
|
UCHAR Tag[4];
|
|
ULONG TagUlong;
|
|
} DUMMYUNIONNAME2;
|
|
} SYSTEM_BIGPOOL_ENTRY, *PSYSTEM_BIGPOOL_ENTRY;
|
|
|
|
/**
|
|
* The SYSTEM_BIGPOOL_INFORMATION structure contains information about the system's large pool allocations.
|
|
*/
|
|
typedef struct _SYSTEM_BIGPOOL_INFORMATION
|
|
{
|
|
ULONG Count;
|
|
_Field_size_(Count) SYSTEM_BIGPOOL_ENTRY AllocatedInfo[1];
|
|
} SYSTEM_BIGPOOL_INFORMATION, *PSYSTEM_BIGPOOL_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_POOL_ENTRY structure describes a single pool allocation.
|
|
*/
|
|
typedef struct _SYSTEM_POOL_ENTRY
|
|
{
|
|
BOOLEAN Allocated;
|
|
BOOLEAN Spare0;
|
|
USHORT AllocatorBackTraceIndex;
|
|
ULONG Size;
|
|
union
|
|
{
|
|
UCHAR Tag[4];
|
|
ULONG TagUlong;
|
|
PVOID ProcessChargedQuota;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_POOL_ENTRY, *PSYSTEM_POOL_ENTRY;
|
|
|
|
/**
|
|
* The SYSTEM_POOL_INFORMATION structure contains information about the system pool allocations.
|
|
*/
|
|
typedef struct _SYSTEM_POOL_INFORMATION
|
|
{
|
|
SIZE_T TotalSize;
|
|
PVOID FirstEntry;
|
|
USHORT EntryOverhead;
|
|
BOOLEAN PoolTagPresent;
|
|
BOOLEAN Spare0;
|
|
ULONG NumberOfEntries;
|
|
_Field_size_(NumberOfEntries) SYSTEM_POOL_ENTRY Entries[1];
|
|
} SYSTEM_POOL_INFORMATION, *PSYSTEM_POOL_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_SESSION_POOLTAG_INFORMATION structure contains system session pooltag information.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_SESSION_POOLTAG_INFORMATION
|
|
{
|
|
SIZE_T NextEntryOffset;
|
|
ULONG SessionId;
|
|
ULONG Count;
|
|
_Field_size_(Count) SYSTEM_POOLTAG TagInfo[1];
|
|
} SYSTEM_SESSION_POOLTAG_INFORMATION, *PSYSTEM_SESSION_POOLTAG_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_SESSION_MAPPED_VIEW_INFORMATION structure contains system session mapped view information.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_SESSION_MAPPED_VIEW_INFORMATION
|
|
{
|
|
SIZE_T NextEntryOffset;
|
|
ULONG SessionId;
|
|
ULONG ViewFailures;
|
|
SIZE_T NumberOfBytesAvailable;
|
|
SIZE_T NumberOfBytesAvailableContiguous;
|
|
} SYSTEM_SESSION_MAPPED_VIEW_INFORMATION, *PSYSTEM_SESSION_MAPPED_VIEW_INFORMATION;
|
|
|
|
/**
|
|
* The WATCHDOG_HANDLER_ACTION enumeration defines the actions for watchdog handler.
|
|
*/
|
|
typedef enum _WATCHDOG_HANDLER_ACTION
|
|
{
|
|
WdActionSetTimeoutValue,
|
|
WdActionQueryTimeoutValue,
|
|
WdActionResetTimer,
|
|
WdActionStopTimer,
|
|
WdActionStartTimer,
|
|
WdActionSetTriggerAction,
|
|
WdActionQueryTriggerAction,
|
|
WdActionQueryState
|
|
} WATCHDOG_HANDLER_ACTION;
|
|
|
|
typedef _Function_class_(SYSTEM_WATCHDOG_HANDLER)
|
|
NTSTATUS NTAPI SYSTEM_WATCHDOG_HANDLER(
|
|
_In_ WATCHDOG_HANDLER_ACTION Action,
|
|
_In_ PVOID Context,
|
|
_Inout_ PULONG DataValue,
|
|
_In_ BOOLEAN NoLocks
|
|
);
|
|
typedef SYSTEM_WATCHDOG_HANDLER* PSYSTEM_WATCHDOG_HANDLER;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_WATCHDOG_HANDLER_INFORMATION structure contains system watchdog handler information.
|
|
*/
|
|
typedef struct _SYSTEM_WATCHDOG_HANDLER_INFORMATION
|
|
{
|
|
PSYSTEM_WATCHDOG_HANDLER WdHandler;
|
|
PVOID Context;
|
|
} SYSTEM_WATCHDOG_HANDLER_INFORMATION, *PSYSTEM_WATCHDOG_HANDLER_INFORMATION;
|
|
|
|
/**
|
|
* The WATCHDOG_INFORMATION_CLASS enumeration defines the information classes for querying and setting watchdog information.
|
|
*/
|
|
typedef enum _WATCHDOG_INFORMATION_CLASS
|
|
{
|
|
WdInfoTimeoutValue = 0,
|
|
WdInfoResetTimer = 1,
|
|
WdInfoStopTimer = 2,
|
|
WdInfoStartTimer = 3,
|
|
WdInfoTriggerAction = 4,
|
|
WdInfoState = 5,
|
|
WdInfoTriggerReset = 6,
|
|
WdInfoNop = 7,
|
|
WdInfoGeneratedLastReset = 8,
|
|
WdInfoInvalid = 9,
|
|
} WATCHDOG_INFORMATION_CLASS;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_WATCHDOG_TIMER_INFORMATION structure contains system watchdog timer information.
|
|
*/
|
|
typedef struct _SYSTEM_WATCHDOG_TIMER_INFORMATION
|
|
{
|
|
WATCHDOG_INFORMATION_CLASS WdInfoClass;
|
|
ULONG DataValue;
|
|
} SYSTEM_WATCHDOG_TIMER_INFORMATION, *PSYSTEM_WATCHDOG_TIMER_INFORMATION;
|
|
|
|
#if (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_TABLE_ACTION enumeration defines the actions for enumerating or retrieving firmware tables.
|
|
*/
|
|
typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION
|
|
{
|
|
SystemFirmwareTableEnumerate,
|
|
SystemFirmwareTableGet,
|
|
SystemFirmwareTableMax
|
|
} SYSTEM_FIRMWARE_TABLE_ACTION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_TABLE_INFORMATION structure specifies a firmware table request and receives its data.
|
|
*/
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION
|
|
{
|
|
ULONG ProviderSignature; // (same as the GetSystemFirmwareTable function)
|
|
SYSTEM_FIRMWARE_TABLE_ACTION Action;
|
|
ULONG TableID;
|
|
ULONG TableBufferLength;
|
|
_Field_size_bytes_(TableBufferLength) UCHAR TableBuffer[1];
|
|
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
|
|
#endif // (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
#if (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
// private
|
|
typedef _Function_class_(FNFTH)
|
|
NTSTATUS STDAPIVCALLTYPE FNFTH(
|
|
_Inout_ PSYSTEM_FIRMWARE_TABLE_INFORMATION SystemFirmwareTableInfo
|
|
);
|
|
typedef FNFTH* PFNFTH;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_TABLE_HANDLER structure describes the system firmware table handler.
|
|
*/
|
|
typedef struct _SYSTEM_FIRMWARE_TABLE_HANDLER
|
|
{
|
|
ULONG ProviderSignature;
|
|
BOOLEAN Register;
|
|
PFNFTH FirmwareTableHandler;
|
|
PVOID DriverObject;
|
|
} SYSTEM_FIRMWARE_TABLE_HANDLER, *PSYSTEM_FIRMWARE_TABLE_HANDLER;
|
|
#endif // (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_LIST_INFORMATION structure contains system memory list information.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_LIST_INFORMATION
|
|
{
|
|
SIZE_T ZeroPageCount;
|
|
SIZE_T FreePageCount;
|
|
SIZE_T ModifiedPageCount;
|
|
SIZE_T ModifiedNoWritePageCount;
|
|
SIZE_T BadPageCount;
|
|
SIZE_T PageCountByPriority[8];
|
|
SIZE_T RepurposedPagesByPriority[8];
|
|
SIZE_T ModifiedPageCountPageFile;
|
|
} SYSTEM_MEMORY_LIST_INFORMATION, *PSYSTEM_MEMORY_LIST_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_LIST_COMMAND enumeration defines the commands for manipulating the system memory lists.
|
|
*/
|
|
typedef enum _SYSTEM_MEMORY_LIST_COMMAND
|
|
{
|
|
MemoryCaptureAccessedBits,
|
|
MemoryCaptureAndResetAccessedBits,
|
|
MemoryEmptyWorkingSets,
|
|
MemoryFlushModifiedList,
|
|
MemoryPurgeStandbyList,
|
|
MemoryPurgeLowPriorityStandbyList,
|
|
MemoryCommandMax
|
|
} SYSTEM_MEMORY_LIST_COMMAND;
|
|
|
|
/**
|
|
* The SYSTEM_THREAD_CID_PRIORITY_INFORMATION structure is used with NtSetSystemInformation
|
|
* to set the priority of a thread by its client ID (process ID and thread ID) without
|
|
* requiring a thread handle.
|
|
* \remarks This structure is used with the SystemThreadPriorityClientIdInformation
|
|
* information class (0x52). The caller must have SeIncreaseBasePriorityPrivilege
|
|
* to raise a thread's priority above normal.
|
|
*/
|
|
typedef struct _SYSTEM_THREAD_CID_PRIORITY_INFORMATION
|
|
{
|
|
CLIENT_ID ClientId; // The process and thread identifiers of the target thread.
|
|
KPRIORITY Priority; // The new priority value to assign to the thread.
|
|
} SYSTEM_THREAD_CID_PRIORITY_INFORMATION, *PSYSTEM_THREAD_CID_PRIORITY_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION structure contains the cumulative number of clock cycles a logical processor
|
|
* has spent running its idle thread, deferred procedure calls (DPCs) and interrupt service routines (ISRs) since it became active.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/realtimeapiset/nf-realtimeapiset-queryidleprocessorcycletimeex
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION
|
|
{
|
|
ULONGLONG CycleTime;
|
|
} SYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION, *PSYSTEM_PROCESSOR_IDLE_CYCLE_TIME_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VERIFIER_ISSUE structure describes the system verifier issue.
|
|
*/
|
|
typedef struct _SYSTEM_VERIFIER_ISSUE
|
|
{
|
|
ULONGLONG IssueType;
|
|
PVOID Address;
|
|
ULONGLONG Parameters[2];
|
|
} SYSTEM_VERIFIER_ISSUE, *PSYSTEM_VERIFIER_ISSUE;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VERIFIER_CANCELLATION_INFORMATION structure contains system verifier cancellation information.
|
|
*/
|
|
typedef struct _SYSTEM_VERIFIER_CANCELLATION_INFORMATION
|
|
{
|
|
ULONG CancelProbability;
|
|
ULONG CancelThreshold;
|
|
ULONG CompletionThreshold;
|
|
ULONG CancellationVerifierDisabled;
|
|
ULONG AvailableIssues;
|
|
SYSTEM_VERIFIER_ISSUE Issues[128];
|
|
} SYSTEM_VERIFIER_CANCELLATION_INFORMATION, *PSYSTEM_VERIFIER_CANCELLATION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_REF_TRACE_INFORMATION structure contains system ref trace information.
|
|
*/
|
|
typedef struct _SYSTEM_REF_TRACE_INFORMATION
|
|
{
|
|
BOOLEAN TraceEnable;
|
|
BOOLEAN TracePermanent;
|
|
UNICODE_STRING TraceProcessName;
|
|
UNICODE_STRING TracePoolTags;
|
|
} SYSTEM_REF_TRACE_INFORMATION, *PSYSTEM_REF_TRACE_INFORMATION;
|
|
|
|
// private
|
|
#define SYSTEM_SPECIAL_POOL_CATCH_OVERRUNS 0x1 // MmSpecialPoolCatchOverruns
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SPECIAL_POOL_INFORMATION structure contains system special pool information.
|
|
*/
|
|
typedef struct _SYSTEM_SPECIAL_POOL_INFORMATION
|
|
{
|
|
ULONG PoolTag;
|
|
ULONG Flags; // SYSTEM_SPECIAL_POOL_* flags
|
|
} SYSTEM_SPECIAL_POOL_INFORMATION, *PSYSTEM_SPECIAL_POOL_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESS_ID_INFORMATION structure retrieves the executable image
|
|
* name associated with a specific process ID. The caller supplies a process ID,
|
|
* and on return the system fills the UNICODE_STRING with the corresponding image path.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESS_ID_INFORMATION
|
|
{
|
|
HANDLE ProcessId;
|
|
UNICODE_STRING ImageName;
|
|
} SYSTEM_PROCESS_ID_INFORMATION, *PSYSTEM_PROCESS_ID_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_QUERY_INFORMATION structure contains system hypervisor query information.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_QUERY_INFORMATION
|
|
{
|
|
BOOLEAN HypervisorConnected;
|
|
BOOLEAN HypervisorDebuggingEnabled;
|
|
BOOLEAN HypervisorPresent;
|
|
BOOLEAN Spare0[5];
|
|
ULONGLONG EnabledEnlightenments;
|
|
} SYSTEM_HYPERVISOR_QUERY_INFORMATION, *PSYSTEM_HYPERVISOR_QUERY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BOOT_ENVIRONMENT_INFORMATION structure contains system boot environment information.
|
|
*/
|
|
typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION
|
|
{
|
|
GUID BootIdentifier;
|
|
FIRMWARE_TYPE FirmwareType;
|
|
union
|
|
{
|
|
ULONGLONG BootFlags;
|
|
struct
|
|
{
|
|
ULONGLONG DbgMenuOsSelection : 1; // REDSTONE4
|
|
ULONGLONG DbgHiberBoot : 1;
|
|
ULONGLONG DbgSoftBoot : 1;
|
|
ULONGLONG DbgMeasuredLaunch : 1;
|
|
ULONGLONG DbgMeasuredLaunchCapable : 1; // 19H1
|
|
ULONGLONG DbgSystemHiveReplace : 1;
|
|
ULONGLONG DbgMeasuredLaunchSmmProtections : 1;
|
|
ULONGLONG DbgMeasuredLaunchSmmLevel : 7; // 20H1
|
|
ULONGLONG DbgBugCheckRecovery : 1; // 24H2
|
|
ULONGLONG DbgFASR : 1;
|
|
ULONGLONG DbgUseCachedBcd : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_BOOT_ENVIRONMENT_INFORMATION, *PSYSTEM_BOOT_ENVIRONMENT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION structure contains system image file execution options information.
|
|
*/
|
|
typedef struct _SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION
|
|
{
|
|
ULONG FlagsToEnable; // FLG_* bits to add to the image's execution options.
|
|
ULONG FlagsToDisable; // FLG_* bits to clear from the image's execution options.
|
|
} SYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION, *PSYSTEM_IMAGE_FILE_EXECUTION_OPTIONS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The COVERAGE_REQUEST_CODES enumeration defines the request codes for coverage request.
|
|
*/
|
|
typedef enum _COVERAGE_REQUEST_CODES
|
|
{
|
|
CoverageAllModules = 0,
|
|
CoverageSearchByHash = 1,
|
|
CoverageSearchByName = 2
|
|
} COVERAGE_REQUEST_CODES;
|
|
|
|
// private
|
|
/**
|
|
* The COVERAGE_MODULE_REQUEST structure describes a coverage module request.
|
|
*/
|
|
typedef struct _COVERAGE_MODULE_REQUEST
|
|
{
|
|
COVERAGE_REQUEST_CODES RequestType;
|
|
union
|
|
{
|
|
UCHAR MD5Hash[16];
|
|
UNICODE_STRING ModuleName;
|
|
} SearchInfo;
|
|
} COVERAGE_MODULE_REQUEST, *PCOVERAGE_MODULE_REQUEST;
|
|
|
|
// private
|
|
/**
|
|
* The COVERAGE_MODULE_INFO structure contains coverage module information.
|
|
*/
|
|
typedef struct _COVERAGE_MODULE_INFO
|
|
{
|
|
ULONG ModuleInfoSize;
|
|
ULONG IsBinaryLoaded;
|
|
UNICODE_STRING ModulePathName;
|
|
ULONG CoverageSectionSize;
|
|
_Field_size_bytes_(CoverageSectionSize) UCHAR CoverageSection[1];
|
|
} COVERAGE_MODULE_INFO, *PCOVERAGE_MODULE_INFO;
|
|
|
|
// private
|
|
/**
|
|
* The COVERAGE_MODULES structure describes the coverage modules.
|
|
*/
|
|
typedef struct _COVERAGE_MODULES
|
|
{
|
|
ULONG ListAndReset;
|
|
ULONG NumberOfModules;
|
|
COVERAGE_MODULE_REQUEST ModuleRequestInfo;
|
|
COVERAGE_MODULE_INFO Modules[1];
|
|
} COVERAGE_MODULES, *PCOVERAGE_MODULES;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PREFETCH_PATCH_INFORMATION structure contains system prefetch patch information.
|
|
*/
|
|
typedef struct _SYSTEM_PREFETCH_PATCH_INFORMATION
|
|
{
|
|
ULONG PrefetchPatchCount;
|
|
} SYSTEM_PREFETCH_PATCH_INFORMATION, *PSYSTEM_PREFETCH_PATCH_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VERIFIER_FAULTS_INFORMATION structure contains system verifier faults information.
|
|
*/
|
|
typedef struct _SYSTEM_VERIFIER_FAULTS_INFORMATION
|
|
{
|
|
ULONG Probability;
|
|
ULONG MaxProbability;
|
|
UNICODE_STRING PoolTags;
|
|
UNICODE_STRING Applications;
|
|
} SYSTEM_VERIFIER_FAULTS_INFORMATION, *PSYSTEM_VERIFIER_FAULTS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VERIFIER_INFORMATION_EX structure contains system verifier information.
|
|
*/
|
|
typedef struct _SYSTEM_VERIFIER_INFORMATION_EX
|
|
{
|
|
ULONG VerifyMode;
|
|
ULONG OptionChanges;
|
|
UNICODE_STRING PreviousBucketName;
|
|
ULONG IrpCancelTimeoutMsec;
|
|
ULONG VerifierExtensionEnabled;
|
|
#ifdef _WIN64
|
|
ULONG Reserved[1];
|
|
#else
|
|
ULONG Reserved[3];
|
|
#endif
|
|
} SYSTEM_VERIFIER_INFORMATION_EX, *PSYSTEM_VERIFIER_INFORMATION_EX;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SYSTEM_PARTITION_INFORMATION structure contains system system partition information.
|
|
*/
|
|
typedef struct _SYSTEM_SYSTEM_PARTITION_INFORMATION
|
|
{
|
|
UNICODE_STRING SystemPartition;
|
|
} SYSTEM_SYSTEM_PARTITION_INFORMATION, *PSYSTEM_SYSTEM_PARTITION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SYSTEM_DISK_INFORMATION structure contains system system disk information.
|
|
*/
|
|
typedef struct _SYSTEM_SYSTEM_DISK_INFORMATION
|
|
{
|
|
UNICODE_STRING SystemDisk;
|
|
} SYSTEM_SYSTEM_DISK_INFORMATION, *PSYSTEM_SYSTEM_DISK_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_NUMA_PROXIMITY_MAP structure describes the system NUMA proximity map.
|
|
*/
|
|
typedef struct _SYSTEM_NUMA_PROXIMITY_MAP
|
|
{
|
|
ULONG NodeProximityId;
|
|
USHORT NodeNumber;
|
|
} SYSTEM_NUMA_PROXIMITY_MAP, *PSYSTEM_NUMA_PROXIMITY_MAP;
|
|
|
|
// private (Windows 8.1 and above)
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT structure describes the system processor performance hitcount.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT
|
|
{
|
|
ULONGLONG Hits;
|
|
UCHAR PercentFrequency;
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT, *PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT;
|
|
|
|
// private (Windows 8.1 and above)
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION structure describes the system processor performance state distribution.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION
|
|
{
|
|
ULONG ProcessorNumber;
|
|
ULONG StateCount;
|
|
_Field_size_(StateCount) SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT States[1];
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION, *PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION;
|
|
|
|
// private (Windows 7 and Windows 8)
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8 structure describes the system processor performance hitcount WIN8.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8
|
|
{
|
|
ULONG Hits;
|
|
UCHAR PercentFrequency;
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8, *PSYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8;
|
|
|
|
// private (Windows 7 and Windows 8)
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION_WIN8 structure describes the system processor performance state distribution WIN8.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION_WIN8
|
|
{
|
|
ULONG ProcessorNumber;
|
|
ULONG StateCount;
|
|
_Field_size_(StateCount) SYSTEM_PROCESSOR_PERFORMANCE_HITCOUNT_WIN8 States[1];
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION_WIN8, *PSYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION_WIN8;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION structure describes the system processor performance distribution.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION
|
|
{
|
|
ULONG ProcessorCount;
|
|
ULONG Offsets[1];
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION, *PSYSTEM_PROCESSOR_PERFORMANCE_DISTRIBUTION;
|
|
|
|
//
|
|
// The hit counts in SYSTEM_PROCESSOR_PERFORMANCE_STATE_DISTRIBUTION are the raw data behind the
|
|
// "Processor Information" counter set (counter set {b4fc721a-0378-476f-89ba-a5a79f810b36}).
|
|
//
|
|
// The weighted mean of the hit counts is "% Processor Performance" (counter 24), the average
|
|
// performance of the processor while it is executing instructions, as a percentage of its nominal
|
|
// performance:
|
|
//
|
|
// PercentPerformance = SUM(dHits[i] * PercentFrequency[i]) / SUM(dHits[i])
|
|
//
|
|
// On hardware performance state (HWP/CPPC) systems the table is a two entry pseudo distribution
|
|
// with PercentFrequency values of 0 and 255, encoded so the ordinary weighted mean above yields the
|
|
// correct answer. The result may exceed 100 percent when the processor is above its nominal
|
|
// frequency, and callers must not clamp it. "Actual Frequency" (counter 33) is:
|
|
//
|
|
// ActualFrequency = PercentPerformance * NominalFrequency / 100
|
|
//
|
|
// where NominalFrequency comes from PowerInternalProcessorBrandedFrequency. Note that
|
|
// PROCESSOR_POWER_INFORMATION.CurrentMhz is a performance state value and does not track the
|
|
// delivered frequency on turbo capable processors.
|
|
//
|
|
// The hit counts do not count events. They accumulate unhalted reference time, advancing only while
|
|
// the processor is executing, which is what makes "% Processor Utility" (counter 26) recoverable.
|
|
// Utility and performance share one numerator in the kernel and differ only in their divisor:
|
|
// performance divides by unhalted time, utility divides by elapsed time. So:
|
|
//
|
|
// UnhaltedTime100ns = SUM(dHits[i]) * HITCOUNT_UNIT_NUMERATOR / HITCOUNT_UNIT_DENOMINATOR
|
|
// PercentUtility = PercentPerformance * UnhaltedTime100ns / dElapsed100ns
|
|
//
|
|
// which reduces to SUM(dHits[i] * PercentFrequency[i]) * 512 / (255 * dElapsed100ns).
|
|
//
|
|
// The unit was measured against the counter set on an x64 HWP system and agreed to within 0.03%
|
|
// across idle and saturated processors, and confirmed on AMD (Zen 5, CPPC) where the unit implied by
|
|
// the counter set matched 512/255 to within 0.01% and the recovered utility tracked "% Processor
|
|
// Utility" to within 0.06 percentage points. Both report the two entry pseudo distribution. It is
|
|
// unvalidated on ARM64 and on legacy performance state tables, which report an occurrence count
|
|
// rather than these accumulators and have no PercentFrequency == 0 entry; the presence of that entry
|
|
// discriminates between the two forms.
|
|
//
|
|
#define SYSTEM_PROCESSOR_HITCOUNT_UNIT_NUMERATOR 512 // 512/255 of a 100ns interval, ~200.8ns
|
|
#define SYSTEM_PROCESSOR_HITCOUNT_UNIT_DENOMINATOR 255
|
|
|
|
#define CODEINTEGRITY_OPTION_ENABLED 0x01
|
|
#define CODEINTEGRITY_OPTION_TESTSIGN 0x02
|
|
#define CODEINTEGRITY_OPTION_UMCI_ENABLED 0x04
|
|
#define CODEINTEGRITY_OPTION_UMCI_AUDITMODE_ENABLED 0x08
|
|
#define CODEINTEGRITY_OPTION_UMCI_EXCLUSIONPATHS_ENABLED 0x10
|
|
#define CODEINTEGRITY_OPTION_TEST_BUILD 0x20
|
|
#define CODEINTEGRITY_OPTION_PREPRODUCTION_BUILD 0x40
|
|
#define CODEINTEGRITY_OPTION_DEBUGMODE_ENABLED 0x80
|
|
#define CODEINTEGRITY_OPTION_FLIGHT_BUILD 0x100
|
|
#define CODEINTEGRITY_OPTION_FLIGHTING_ENABLED 0x200
|
|
#define CODEINTEGRITY_OPTION_HVCI_KMCI_ENABLED 0x400
|
|
#define CODEINTEGRITY_OPTION_HVCI_KMCI_AUDITMODE_ENABLED 0x800
|
|
#define CODEINTEGRITY_OPTION_HVCI_KMCI_STRICTMODE_ENABLED 0x1000
|
|
#define CODEINTEGRITY_OPTION_HVCI_IUM_ENABLED 0x2000
|
|
#define CODEINTEGRITY_OPTION_WHQL_ENFORCEMENT_ENABLED 0x4000
|
|
#define CODEINTEGRITY_OPTION_WHQL_AUDITMODE_ENABLED 0x8000
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_INFORMATION structure contains the current Code Integrity policy options.
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_INFORMATION
|
|
{
|
|
ULONG Length;
|
|
union
|
|
{
|
|
ULONG CodeIntegrityOptions;
|
|
struct
|
|
{
|
|
ULONG Enabled : 1; // CODEINTEGRITY_OPTION_ENABLED
|
|
ULONG TestSign : 1; // CODEINTEGRITY_OPTION_TESTSIGN
|
|
ULONG UmciEnabled : 1; // CODEINTEGRITY_OPTION_UMCI_ENABLED
|
|
ULONG UmciAuditModeEnabled : 1; // CODEINTEGRITY_OPTION_UMCI_AUDITMODE_ENABLED
|
|
ULONG UmciExclusionPathsEnabled : 1; // CODEINTEGRITY_OPTION_UMCI_EXCLUSIONPATHS_ENABLED
|
|
ULONG TestBuild : 1; // CODEINTEGRITY_OPTION_TEST_BUILD
|
|
ULONG PreproductionBuild : 1; // CODEINTEGRITY_OPTION_PREPRODUCTION_BUILD
|
|
ULONG DebugModeEnabled : 1; // CODEINTEGRITY_OPTION_DEBUGMODE_ENABLE
|
|
ULONG FlightBuild : 1; // CODEINTEGRITY_OPTION_FLIGHT_BUILD
|
|
ULONG FlightingEnabled : 1; // CODEINTEGRITY_OPTION_FLIGHTING_ENABLED
|
|
ULONG HvciKmciEnabled : 1; // CODEINTEGRITY_OPTION_HVCI_KMCI_ENABLED
|
|
ULONG HvciKmciAuditModeEnabled : 1; // CODEINTEGRITY_OPTION_HVCI_KMCI_AUDITMODE_ENABLED
|
|
ULONG HvciKmciStrictModeEnabled : 1; // CODEINTEGRITY_OPTION_HVCI_KMCI_STRICTMODE_ENABLED
|
|
ULONG HvciIumEnabled : 1; // CODEINTEGRITY_OPTION_HVCI_IUM_ENABLED
|
|
ULONG WhqlEnforcementEnabled : 1; // CODEINTEGRITY_OPTION_WHQL_ENFORCEMENT_ENABLED
|
|
ULONG WhqlAuditModeEnabled : 1; // CODEINTEGRITY_OPTION_WHQL_AUDITMODE_ENABLED
|
|
ULONG Spare : 16;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_CODEINTEGRITY_INFORMATION, *PSYSTEM_CODEINTEGRITY_INFORMATION;
|
|
|
|
// rev
|
|
// Loads mcupdate.dll via ntosext.sys to perform microcode updates.
|
|
#define PROCESSOR_MICROCODE_OPERATION_LOAD 0x01
|
|
// rev
|
|
// Unloads mcupdate.dll via ntosext.sys to preform microcode updates.
|
|
#define PROCESSOR_MICROCODE_OPERATION_UNLOAD 0x02
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_MICROCODE_UPDATE_INFORMATION structure contains system processor microcode update information.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_MICROCODE_UPDATE_INFORMATION
|
|
{
|
|
ULONG Operation;
|
|
} SYSTEM_PROCESSOR_MICROCODE_UPDATE_INFORMATION, *PSYSTEM_PROCESSOR_MICROCODE_UPDATE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_BRAND_STRING structure contains the processor brand string.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_BRAND_STRING
|
|
{
|
|
CHAR BrandString[49];
|
|
} SYSTEM_PROCESSOR_BRAND_STRING, *PSYSTEM_PROCESSOR_BRAND_STRING;
|
|
|
|
// private
|
|
typedef HANDLE SYSTEM_WIN32_WER_START_CALLOUT, *PSYSTEM_WIN32_WER_START_CALLOUT;
|
|
|
|
// private
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_ENCRYPT 0x01 // SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0/V1
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_DECRYPT 0x02 // SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0/V1
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_EXECUTE 0x03 // variable execute request
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_FLUSH 0x04 // no payload
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_RESERVED5 0x05 // rejected
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_RESERVED6 0x06 // rejected
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_QUERY 0x07 // no payload
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_SET_DYNAMIC_ENFORCEMENT 0x08 // sub_140A6375C, SYSTEM_CONTROL_FLOW_TRANSITION_OP8
|
|
#define SYSTEM_CONTROL_FLOW_TRANSITION_OPERATION_UNLOAD_MODULE 0x09 // WbHeapExecutionUnloadModule/sub_140A50E08, SYSTEM_CONTROL_FLOW_TRANSITION_OP9
|
|
|
|
// private
|
|
/**
|
|
* \brief Warbird control-flow transition request header.
|
|
*
|
|
* Used with \c SystemControlFlowTransition to dispatch an operation-tagged
|
|
* request into the kernel's Warbird control-flow transition handlers.
|
|
*
|
|
* Warbird is Windows' internal code/data protection and controlled execution
|
|
* mechanism used by protected components to transition memory between encrypted,
|
|
* decrypted, and executable states under policy.
|
|
*
|
|
* \a Parameters points to an operation-specific payload determined by
|
|
* \a Operation.
|
|
*/
|
|
typedef struct _SYSTEM_CONTROL_FLOW_TRANSITION
|
|
{
|
|
ULONG Operation;
|
|
ULONG Reserved;
|
|
PVOID Parameters; // User pointer to an operation-specific payload.
|
|
} SYSTEM_CONTROL_FLOW_TRANSITION, *PSYSTEM_CONTROL_FLOW_TRANSITION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0 structure describes the system control flow transition segment V0.
|
|
*/
|
|
typedef struct _SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0
|
|
{
|
|
UCHAR Data[0xF4]; // Opaque Warbird segment descriptor for operations 1/2, format selector 0.
|
|
} SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0, *PSYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V0;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V1 structure describes the system control flow transition segment V1.
|
|
*/
|
|
typedef struct _SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V1
|
|
{
|
|
UCHAR Data[0xF8]; // Opaque Warbird segment descriptor for operations 1/2, format selector 1.
|
|
} SYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V1, *PSYSTEM_CONTROL_FLOW_TRANSITION_SEGMENT_V1;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CONTROL_FLOW_TRANSITION_OP8 structure describes the system control flow transition OP8.
|
|
*/
|
|
typedef struct _SYSTEM_CONTROL_FLOW_TRANSITION_OP8
|
|
{
|
|
ULONG ReservedMustBeZero;
|
|
ULONG LengthOrFlags;
|
|
ULONGLONG Reserved2;
|
|
PVOID PointerOrHandle;
|
|
} SYSTEM_CONTROL_FLOW_TRANSITION_OP8, *PSYSTEM_CONTROL_FLOW_TRANSITION_OP8;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CONTROL_FLOW_TRANSITION_OP9 structure describes the system control flow transition OP9.
|
|
*/
|
|
typedef struct _SYSTEM_CONTROL_FLOW_TRANSITION_OP9
|
|
{
|
|
ULONG ReservedMustBeZero;
|
|
ULONG Reserved;
|
|
PVOID ModuleBase;
|
|
} SYSTEM_CONTROL_FLOW_TRANSITION_OP9, *PSYSTEM_CONTROL_FLOW_TRANSITION_OP9;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECURE_DUMP_ENCRYPTION_INFORMATION structure contains system secure dump encryption information.
|
|
*/
|
|
typedef struct _SYSTEM_SECURE_DUMP_ENCRYPTION_INFORMATION
|
|
{
|
|
UCHAR Data[ANYSIZE_ARRAY]; // Opaque input/output buffer used by VslTransformDumpKey via NtQuerySystemInformationEx.
|
|
} SYSTEM_SECURE_DUMP_ENCRYPTION_INFORMATION, *PSYSTEM_SECURE_DUMP_ENCRYPTION_INFORMATION;
|
|
|
|
// private
|
|
#define SYSTEM_FIRMWARE_BOOT_PERFORMANCE_SIGNATURE 0x54504246u // "FBPT"
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_BOOT_PERFORMANCE_INFORMATION structure contains system firmware boot performance information.
|
|
*/
|
|
typedef struct _SYSTEM_FIRMWARE_BOOT_PERFORMANCE_INFORMATION
|
|
{
|
|
ULONG Signature; // SYSTEM_FIRMWARE_BOOT_PERFORMANCE_SIGNATURE
|
|
ULONG Length; // Total size of the copied ACPI FBPT, including trailing records.
|
|
UCHAR Data[ANYSIZE_ARRAY]; // Firmware boot performance records.
|
|
} SYSTEM_FIRMWARE_BOOT_PERFORMANCE_INFORMATION, *PSYSTEM_FIRMWARE_BOOT_PERFORMANCE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VA_TYPE enumeration defines the system VA types.
|
|
*/
|
|
typedef enum _SYSTEM_VA_TYPE
|
|
{
|
|
SystemVaTypeAll,
|
|
SystemVaTypeNonPagedPool,
|
|
SystemVaTypePagedPool,
|
|
SystemVaTypeSystemCache,
|
|
SystemVaTypeSystemPtes,
|
|
SystemVaTypeSessionSpace,
|
|
SystemVaTypeMax
|
|
} SYSTEM_VA_TYPE, *PSYSTEM_VA_TYPE;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VA_LIST_INFORMATION structure contains system VA list information.
|
|
*/
|
|
typedef struct _SYSTEM_VA_LIST_INFORMATION
|
|
{
|
|
SIZE_T VirtualSize;
|
|
SIZE_T VirtualPeak;
|
|
SIZE_T VirtualLimit;
|
|
SIZE_T AllocationFailures;
|
|
} SYSTEM_VA_LIST_INFORMATION, *PSYSTEM_VA_LIST_INFORMATION;
|
|
|
|
// private
|
|
//typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP
|
|
//{
|
|
// RelationProcessorCore,
|
|
// RelationNumaNode,
|
|
// RelationCache,
|
|
// RelationProcessorPackage,
|
|
// RelationGroup,
|
|
// RelationProcessorDie,
|
|
// RelationNumaNodeEx,
|
|
// RelationProcessorModule,
|
|
// RelationAll = 0xffff
|
|
//} LOGICAL_PROCESSOR_RELATIONSHIP;
|
|
//
|
|
// private
|
|
//typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION
|
|
//{
|
|
// ULONG_PTR ProcessorMask;
|
|
// LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
|
|
// union
|
|
// {
|
|
// struct
|
|
// {
|
|
// UCHAR Flags;
|
|
// } ProcessorCore;
|
|
// struct
|
|
// {
|
|
// ULONG NodeNumber;
|
|
// } NumaNode;
|
|
// CACHE_DESCRIPTOR Cache;
|
|
// ULONGLONG Reserved[2];
|
|
// };
|
|
//} SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION;
|
|
//
|
|
// private
|
|
//typedef struct _PROCESSOR_RELATIONSHIP
|
|
//{
|
|
// UCHAR Flags;
|
|
// UCHAR EfficiencyClass;
|
|
// UCHAR Reserved[20];
|
|
// USHORT GroupCount;
|
|
// _Field_size_(GroupCount) GROUP_AFFINITY GroupMask[ANYSIZE_ARRAY];
|
|
//} PROCESSOR_RELATIONSHIP, *PPROCESSOR_RELATIONSHIP;
|
|
//
|
|
// private
|
|
//typedef struct _NUMA_NODE_RELATIONSHIP
|
|
//{
|
|
// ULONG NodeNumber;
|
|
// UCHAR Reserved[18];
|
|
// USHORT GroupCount;
|
|
// union
|
|
// {
|
|
// GROUP_AFFINITY GroupMask;
|
|
// _Field_size_(GroupCount) GROUP_AFFINITY GroupMasks[ANYSIZE_ARRAY];
|
|
// };
|
|
//} NUMA_NODE_RELATIONSHIP, *PNUMA_NODE_RELATIONSHIP;
|
|
//
|
|
// private
|
|
//typedef struct _CACHE_RELATIONSHIP
|
|
//{
|
|
// UCHAR Level;
|
|
// UCHAR Associativity;
|
|
// USHORT LineSize;
|
|
// ULONG CacheSize;
|
|
// PROCESSOR_CACHE_TYPE Type;
|
|
// UCHAR Reserved[18];
|
|
// USHORT GroupCount;
|
|
// union
|
|
// {
|
|
// GROUP_AFFINITY GroupMask;
|
|
// _Field_size_(GroupCount) GROUP_AFFINITY GroupMasks[ANYSIZE_ARRAY];
|
|
// };
|
|
//} CACHE_RELATIONSHIP, *PCACHE_RELATIONSHIP;
|
|
//
|
|
// private
|
|
//typedef struct _PROCESSOR_GROUP_INFO
|
|
//{
|
|
// UCHAR MaximumProcessorCount;
|
|
// UCHAR ActiveProcessorCount;
|
|
// UCHAR Reserved[38];
|
|
// KAFFINITY ActiveProcessorMask;
|
|
//} PROCESSOR_GROUP_INFO, *PPROCESSOR_GROUP_INFO;
|
|
//
|
|
// private
|
|
//typedef struct _GROUP_RELATIONSHIP
|
|
//{
|
|
// USHORT MaximumGroupCount;
|
|
// USHORT ActiveGroupCount;
|
|
// UCHAR Reserved[20];
|
|
// _Field_size_(ActiveGroupCount) PROCESSOR_GROUP_INFO GroupInfo[ANYSIZE_ARRAY];
|
|
//} GROUP_RELATIONSHIP, *PGROUP_RELATIONSHIP;
|
|
//
|
|
// private
|
|
//typedef _Struct_size_bytes_(Size) struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX
|
|
//{
|
|
// LOGICAL_PROCESSOR_RELATIONSHIP Relationship;
|
|
// ULONG Size;
|
|
// _Field_size_bytes_(Size - (sizeof(LOGICAL_PROCESSOR_RELATIONSHIP) + sizeof(ULONG))) union
|
|
// {
|
|
// PROCESSOR_RELATIONSHIP Processor;
|
|
// NUMA_NODE_RELATIONSHIP NumaNode;
|
|
// CACHE_RELATIONSHIP Cache;
|
|
// GROUP_RELATIONSHIP Group;
|
|
// };
|
|
//} SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX;
|
|
|
|
// rev
|
|
/**
|
|
* The STORE_INFORMATION_CLASS enumeration defines the information classes for querying and setting store information.
|
|
*/
|
|
typedef enum _STORE_INFORMATION_CLASS
|
|
{
|
|
StorePageRequest = 1, // q: Not implemented
|
|
StoreStatsRequest = 2, // q: SM_STATS_REQUEST // SmProcessStatsRequest
|
|
StoreCreateRequest = 3, // s: SM_CREATE_REQUEST (requires SeProfileSingleProcessPrivilege)
|
|
StoreDeleteRequest = 4, // s: SM_DELETE_REQUEST (requires SeProfileSingleProcessPrivilege)
|
|
StoreListRequest = 5, // q: SM_STORE_LIST_REQUEST // SM_STORE_LIST_REQUEST_EX // SmProcessListRequest
|
|
|
|
StoreEmptyRequest = 7, // q: Not implemented
|
|
CacheListRequest = 8, // q: SMC_CACHE_LIST_REQUEST // SmcProcessListRequest
|
|
CacheCreateRequest = 9, // s: SMC_CACHE_CREATE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmcProcessCreateRequest
|
|
CacheDeleteRequest = 10, // s: SMC_CACHE_DELETE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmcProcessDeleteRequest
|
|
CacheStoreCreateRequest = 11, // s: SMC_STORE_CREATE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmcProcessStoreCreateRequest
|
|
CacheStoreDeleteRequest = 12, // s: SMC_STORE_DELETE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmcProcessStoreDeleteRequest
|
|
CacheStatsRequest = 13, // q: SMC_CACHE_STATS_REQUEST // SmcProcessStatsRequest
|
|
|
|
RegistrationRequest = 15, // q: SM_REGISTRATION_REQUEST (requires SeProfileSingleProcessPrivilege) // SmProcessRegistrationRequest
|
|
GlobalCacheStatsRequest = 16, // q: Not implemented
|
|
StoreResizeRequest = 17, // s: SM_STORE_RESIZE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmProcessResizeRequest
|
|
CacheStoreResizeRequest = 18, // s: SM_STORE_CACHE_RESIZE_REQUEST (requires SeProfileSingleProcessPrivilege) // SmcProcessResizeRequest
|
|
SmConfigRequest = 19, // s: SM_CONFIG_REQUEST (requires SeProfileSingleProcessPrivilege)
|
|
StoreHighMemoryPriorityRequest = 20, // s: SM_STORE_HIGH_MEMORY_PRIORITY_REQUEST (requires SeProfileSingleProcessPrivilege)
|
|
SystemStoreTrimRequest = 21, // s: SM_SYSTEM_STORE_TRIM_REQUEST (requires SeProfileSingleProcessPrivilege) // SmProcessSystemStoreTrimRequest
|
|
MemCompressionInfoRequest = 22, // q: SM_STORE_COMPRESSION_INFORMATION_REQUEST // SmProcessCompressionInfoRequest
|
|
StoreExistsForProcess = 23, // q: SM_SYSTEM_STORE_EXISTS_FOR_PROCESS // SmProcessProcessStoreInfoRequest // 25H2
|
|
CompressionReadStatsRequest = 24, // q: SM_COMPRESSION_READ_STATS_REQUEST // SmProcessCompressionReadStatsRequest
|
|
CompressionAcceleratorRequest = 25, // q: SM_COMPRESSION_ACCELERATOR_REQUEST // SmProcessCompressionAcceleratorRequest
|
|
StoreInformationMax
|
|
} STORE_INFORMATION_CLASS;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_INFORMATION_VERSION 1
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_STORE_INFORMATION structure wraps a store manager request issued through NtQuerySystemInformation with SystemStoreInformation.
|
|
*/
|
|
typedef struct _SYSTEM_STORE_INFORMATION
|
|
{
|
|
_In_ ULONG Version;
|
|
_In_ STORE_INFORMATION_CLASS StoreInformationClass;
|
|
_Inout_ PVOID Data;
|
|
_Inout_ ULONG Length;
|
|
} SYSTEM_STORE_INFORMATION, *PSYSTEM_STORE_INFORMATION;
|
|
|
|
#define SYSTEM_STORE_STATS_INFORMATION_VERSION 2
|
|
|
|
/**
|
|
* The ST_STATS_LEVEL enumeration defines the level of detail requested for store statistics.
|
|
*/
|
|
typedef enum _ST_STATS_LEVEL
|
|
{
|
|
StStatsLevelBasic = 0,
|
|
StStatsLevelIoStats = 1,
|
|
StStatsLevelRegionSpace = 2, // requires SeProfileSingleProcessPrivilege
|
|
StStatsLevelSpaceBitmap = 3, // requires SeProfileSingleProcessPrivilege
|
|
StStatsLevelMax = 4
|
|
} ST_STATS_LEVEL;
|
|
|
|
/**
|
|
* The SM_STATS_REQUEST structure describes a request for store manager statistics.
|
|
*/
|
|
typedef struct _SM_STATS_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_STATS_INFORMATION_VERSION
|
|
ULONG DetailLevel : 8; // ST_STATS_LEVEL
|
|
ULONG StoreId : 16;
|
|
ULONG BufferSize;
|
|
PVOID Buffer; // PST_STATS
|
|
} SM_STATS_REQUEST, *PSM_STATS_REQUEST;
|
|
|
|
/**
|
|
* The ST_DATA_MGR_STATS structure contains statistics for the store data manager.
|
|
*/
|
|
typedef struct _ST_DATA_MGR_STATS
|
|
{
|
|
ULONG RegionCount;
|
|
ULONG PagesStored;
|
|
ULONG UniquePagesStored;
|
|
ULONG LazyCleanupRegionCount;
|
|
struct {
|
|
ULONG RegionsInUse;
|
|
ULONG SpaceUsed;
|
|
} Space[8]; // IDA: SmpProcessQueryStoreStats iterates all 8 buckets and sums RegionSize * RegionsInUse
|
|
} ST_DATA_MGR_STATS, *PST_DATA_MGR_STATS;
|
|
|
|
/**
|
|
* The ST_IO_STATS_PERIOD structure contains store I/O statistics for a single time period.
|
|
*/
|
|
typedef struct _ST_IO_STATS_PERIOD
|
|
{
|
|
ULONG PageCounts[5]; // one 20-byte IO period sample copied from the store's internal ring buffer
|
|
} ST_IO_STATS_PERIOD, *PST_IO_STATS_PERIOD;
|
|
|
|
/**
|
|
* The ST_IO_STATS structure contains store I/O statistics.
|
|
*/
|
|
typedef struct _ST_IO_STATS
|
|
{
|
|
ULONG PeriodCount; // number of valid exported periods, capped at 64
|
|
ST_IO_STATS_PERIOD Periods[64]; // IDA: StCopyIoStats flattens the internal ring buffer into chronological order
|
|
} ST_IO_STATS, *PST_IO_STATS;
|
|
|
|
/**
|
|
* The ST_READ_LATENCY_BUCKET structure describes a single store read-latency histogram bucket.
|
|
*/
|
|
typedef struct _ST_READ_LATENCY_BUCKET
|
|
{
|
|
ULONG LatencyUs;
|
|
ULONG Count;
|
|
} ST_READ_LATENCY_BUCKET, *PST_READ_LATENCY_BUCKET;
|
|
|
|
/**
|
|
* The ST_READ_LATENCY_STATS structure contains store read-latency statistics.
|
|
*/
|
|
typedef struct _ST_READ_LATENCY_STATS
|
|
{
|
|
ST_READ_LATENCY_BUCKET Buckets[8];
|
|
} ST_READ_LATENCY_STATS, *PST_READ_LATENCY_STATS;
|
|
|
|
// rev
|
|
/**
|
|
* The ST_STATS_REGION_INFO structure contains statistics about a store region.
|
|
*/
|
|
typedef struct _ST_STATS_REGION_INFO
|
|
{
|
|
USHORT SpaceUsed;
|
|
UCHAR Priority;
|
|
UCHAR Spare;
|
|
} ST_STATS_REGION_INFO, *PST_STATS_REGION_INFO;
|
|
|
|
// rev
|
|
/**
|
|
* The ST_STATS_SPACE_BITMAP structure describes the store space-usage bitmap.
|
|
*/
|
|
typedef struct _ST_STATS_SPACE_BITMAP
|
|
{
|
|
SIZE_T CompressedBytes;
|
|
ULONG BytesPerBit;
|
|
UCHAR StoreBitmap[1];
|
|
} ST_STATS_SPACE_BITMAP, *PST_STATS_SPACE_BITMAP;
|
|
|
|
// rev
|
|
/**
|
|
* The ST_STATS structure contains store statistics.
|
|
*/
|
|
typedef struct _ST_STATS
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_STATS_INFORMATION_VERSION
|
|
ULONG Level : 4; // ST_STATS_LEVEL
|
|
ULONG StoreType : 4; // SM_STORE_TYPE
|
|
ULONG NoDuplication : 1;
|
|
ULONG NoCompression : 1;
|
|
ULONG EncryptionStrength : 12;
|
|
ULONG VirtualRegions : 1;
|
|
ULONG Spare0 : 1;
|
|
ULONG Size; // total bytes returned in the caller-supplied stats buffer
|
|
USHORT CompressionFormat;
|
|
USHORT Spare;
|
|
|
|
struct
|
|
{
|
|
ULONG RegionSize;
|
|
ULONG RegionCount;
|
|
ULONG RegionCountMax;
|
|
ULONG Granularity;
|
|
ST_DATA_MGR_STATS UserData;
|
|
ST_DATA_MGR_STATS Metadata;
|
|
} Basic; // present for StStatsLevelBasic and higher
|
|
|
|
struct
|
|
{
|
|
ST_IO_STATS IoStats;
|
|
ST_READ_LATENCY_STATS ReadLatencyStats;
|
|
} Io; // present for StStatsLevelIoStats and higher
|
|
|
|
// For StStatsLevelRegionSpace, variable-length ST_STATS_REGION_INFO[Basic.RegionCountMax] follows.
|
|
// For StStatsLevelSpaceBitmap, ST_STATS_SPACE_BITMAP follows after the fixed header.
|
|
} ST_STATS, *PST_STATS;
|
|
|
|
// rev
|
|
/**
|
|
* The ST_STATS_REGION_SPACE structure describes the space usage of a store region.
|
|
*/
|
|
typedef struct _ST_STATS_REGION_SPACE
|
|
{
|
|
ST_STATS Stats;
|
|
ST_STATS_REGION_INFO Regions[1]; // variable-length ST_STATS_REGION_INFO[Stats.Basic.RegionCountMax]
|
|
} ST_STATS_REGION_SPACE, *PST_STATS_REGION_SPACE;
|
|
|
|
// rev
|
|
/**
|
|
* The ST_STATS_SPACE_BITMAP_EX structure describes the extended store space-usage bitmap.
|
|
*/
|
|
typedef struct _ST_STATS_SPACE_BITMAP_EX
|
|
{
|
|
ST_STATS Stats;
|
|
ST_STATS_SPACE_BITMAP SpaceBitmap; // variable-length bitmap payload follows in SpaceBitmap.StoreBitmap
|
|
} ST_STATS_SPACE_BITMAP_EX, *PST_STATS_SPACE_BITMAP_EX;
|
|
|
|
#define SYSTEM_STORE_CREATE_INFORMATION_VERSION 6
|
|
|
|
/**
|
|
* The SM_STORE_TYPE enumeration defines the store manager store types.
|
|
*/
|
|
typedef enum _SM_STORE_TYPE
|
|
{
|
|
StoreTypeInMemory=0,
|
|
StoreTypeFile=1,
|
|
StoreTypeMax=2
|
|
} SM_STORE_TYPE;
|
|
|
|
// rev
|
|
#define SM_STORE_FLAG_NO_DUPLICATION 0x00000100u
|
|
#define SM_STORE_FLAG_FAIL_NO_COMPRESSION 0x00000200u
|
|
#define SM_STORE_FLAG_NO_COMPRESSION 0x00000400u
|
|
#define SM_STORE_FLAG_NO_ENCRYPTION 0x00000800u
|
|
#define SM_STORE_FLAG_NO_EVICT_ON_ADD 0x00001000u
|
|
#define SM_STORE_FLAG_PERFORMS_FILE_IO 0x00002000u
|
|
#define SM_STORE_FLAG_VDL_NOT_SET 0x00004000u
|
|
#define SM_STORE_FLAG_USE_INTERMEDIATE_ADD_BUFFER 0x00008000u
|
|
#define SM_STORE_FLAG_COMPRESS_NO_HUFF 0x00010000u
|
|
#define SM_STORE_FLAG_LOCK_ACTIVE_REGIONS 0x00020000u
|
|
#define SM_STORE_FLAG_VIRTUAL_REGIONS 0x00040000u
|
|
|
|
// rev
|
|
/**
|
|
* The SM_STORE_BASIC_PARAMS structure specifies the basic parameters of a store manager store.
|
|
*/
|
|
typedef struct _SM_STORE_BASIC_PARAMS
|
|
{
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
ULONG StoreType : 8; // SM_STORE_TYPE
|
|
ULONG NoDuplication : 1; // SM_STORE_FLAG_NO_DUPLICATION // rejected by SmProcessCreateRequest
|
|
ULONG FailNoCompression : 1; // SM_STORE_FLAG_FAIL_NO_COMPRESSION // rejected by SmProcessCreateRequest
|
|
ULONG NoCompression : 1; // SM_STORE_FLAG_NO_COMPRESSION
|
|
ULONG NoEncryption : 1; // SM_STORE_FLAG_NO_ENCRYPTION
|
|
ULONG NoEvictOnAdd : 1; // SM_STORE_FLAG_NO_EVICT_ON_ADD
|
|
ULONG PerformsFileIo : 1; // SM_STORE_FLAG_PERFORMS_FILE_IO
|
|
ULONG VdlNotSet : 1; // SM_STORE_FLAG_VDL_NOT_SET
|
|
ULONG UseIntermediateAddBuffer : 1; // SM_STORE_FLAG_USE_INTERMEDIATE_ADD_BUFFER
|
|
ULONG CompressNoHuff : 1; // SM_STORE_FLAG_COMPRESS_NO_HUFF
|
|
ULONG LockActiveRegions : 1; // SM_STORE_FLAG_LOCK_ACTIVE_REGIONS // required for the in-memory create path observed in SmProcessCreateRequest
|
|
ULONG VirtualRegions : 1; // SM_STORE_FLAG_VIRTUAL_REGIONS
|
|
ULONG Spare : 13;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONG StoreFlags; // low 8 bits: SM_STORE_TYPE, high bits: SM_STORE_FLAG_*
|
|
} DUMMYUNIONNAME;
|
|
ULONG Granularity; // store granularity; SmpDirtyStoreCreate uses 0x80 for dirty-store creation
|
|
ULONG RegionSize; // region size; SmProcessCreateRequest rejects some in-memory create requests above 0x20000
|
|
ULONG RegionCountMax; // maximum region count for the store
|
|
} SM_STORE_BASIC_PARAMS, *PSM_STORE_BASIC_PARAMS;
|
|
|
|
/**
|
|
* The SMKM_REGION_EXTENT structure describes a region extent within the kernel-mode store manager.
|
|
*/
|
|
typedef struct _SMKM_REGION_EXTENT
|
|
{
|
|
ULONG RegionCount;
|
|
SIZE_T ByteOffset;
|
|
} SMKM_REGION_EXTENT, *PSMKM_REGION_EXTENT;
|
|
|
|
/**
|
|
* The SMKM_FILE_INFO structure contains information about a store manager backing file.
|
|
*/
|
|
typedef struct _SMKM_FILE_INFO
|
|
{
|
|
HANDLE FileHandle;
|
|
PFILE_OBJECT FileObject;
|
|
PFILE_OBJECT VolumeFileObject;
|
|
PDEVICE_OBJECT VolumeDeviceObject;
|
|
HANDLE VolumePnpHandle;
|
|
PIRP UsageNotificationIrp;
|
|
PSMKM_REGION_EXTENT Extents;
|
|
ULONG ExtentCount;
|
|
} SMKM_FILE_INFO, *PSMKM_FILE_INFO;
|
|
|
|
/**
|
|
* The SM_STORE_CACHE_BACKED_PARAMS structure specifies the parameters for a cache-backed store manager store.
|
|
*/
|
|
typedef struct _SM_STORE_CACHE_BACKED_PARAMS
|
|
{
|
|
ULONG SectorSize;
|
|
PCHAR EncryptionKey;
|
|
ULONG EncryptionKeySize;
|
|
PSMKM_FILE_INFO FileInfo;
|
|
PVOID EtaContext;
|
|
PRTL_BITMAP StoreRegionBitmap;
|
|
} SM_STORE_CACHE_BACKED_PARAMS, *PSM_STORE_CACHE_BACKED_PARAMS;
|
|
|
|
/**
|
|
* The SM_STORE_PARAMETERS structure specifies the parameters of a store manager store.
|
|
*/
|
|
typedef struct _SM_STORE_PARAMETERS
|
|
{
|
|
SM_STORE_BASIC_PARAMS Store;
|
|
ULONG Priority;
|
|
ULONG Flags;
|
|
SM_STORE_CACHE_BACKED_PARAMS CacheBacked;
|
|
} SM_STORE_PARAMETERS, *PSM_STORE_PARAMETERS;
|
|
|
|
/**
|
|
* The SM_CREATE_REQUEST structure describes a request to create a store manager store.
|
|
*/
|
|
typedef struct _SM_CREATE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_CREATE_INFORMATION_VERSION
|
|
ULONG AcquireReference : 1;
|
|
ULONG KeyedStore : 1;
|
|
ULONG Spare : 22;
|
|
SM_STORE_PARAMETERS Params;
|
|
ULONG StoreId;
|
|
} SM_CREATE_REQUEST, *PSM_CREATE_REQUEST;
|
|
|
|
#define SYSTEM_STORE_DELETE_INFORMATION_VERSION 1
|
|
|
|
/**
|
|
* The SM_DELETE_REQUEST structure describes a request to delete a store manager store.
|
|
*/
|
|
typedef struct _SM_DELETE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_DELETE_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG StoreId;
|
|
} SM_DELETE_REQUEST, *PSM_DELETE_REQUEST;
|
|
|
|
#define SYSTEM_STORE_LIST_INFORMATION_VERSION 2
|
|
|
|
/**
|
|
* The SM_STORE_LIST_REQUEST structure describes a request to enumerate store manager stores.
|
|
*/
|
|
typedef struct _SM_STORE_LIST_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_LIST_INFORMATION_VERSION
|
|
ULONG StoreCount : 8; // = 0
|
|
ULONG ExtendedRequest : 1; // SM_STORE_LIST_REQUEST_EX if set
|
|
ULONG Spare : 15;
|
|
ULONG StoreId[32];
|
|
} SM_STORE_LIST_REQUEST, *PSM_STORE_LIST_REQUEST;
|
|
|
|
/**
|
|
* The SM_STORE_LIST_REQUEST_EX structure describes an extended request to enumerate store manager stores.
|
|
*/
|
|
typedef struct _SM_STORE_LIST_REQUEST_EX
|
|
{
|
|
SM_STORE_LIST_REQUEST Request;
|
|
WCHAR NameBuffer[32][64];
|
|
} SM_STORE_LIST_REQUEST_EX, *PSM_STORE_LIST_REQUEST_EX;
|
|
|
|
#define SYSTEM_CACHE_LIST_INFORMATION_VERSION 2
|
|
|
|
/**
|
|
* The SMC_CACHE_LIST_REQUEST structure describes a request to enumerate store manager caches.
|
|
*/
|
|
typedef struct _SMC_CACHE_LIST_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_LIST_INFORMATION_VERSION
|
|
ULONG CacheCount : 8; // = 0
|
|
ULONG Spare : 16;
|
|
ULONG CacheId[16];
|
|
} SMC_CACHE_LIST_REQUEST, *PSMC_CACHE_LIST_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_CREATE_INFORMATION_VERSION 3
|
|
|
|
/**
|
|
* The SMC_CACHE_PARAMETERS structure specifies the parameters of a store manager cache.
|
|
*/
|
|
typedef struct _SMC_CACHE_PARAMETERS
|
|
{
|
|
SIZE_T CacheFileSize;
|
|
ULONG StoreAlignment;
|
|
ULONG PerformsFileIo : 1;
|
|
ULONG VdlNotSet : 1;
|
|
ULONG Spare : 30;
|
|
ULONG CacheFlags;
|
|
ULONG Priority;
|
|
} SMC_CACHE_PARAMETERS, *PSMC_CACHE_PARAMETERS;
|
|
|
|
/**
|
|
* The SMC_CACHE_CREATE_PARAMETERS structure specifies the parameters used to create a store manager cache.
|
|
*/
|
|
typedef struct _SMC_CACHE_CREATE_PARAMETERS
|
|
{
|
|
SMC_CACHE_PARAMETERS CacheParameters;
|
|
WCHAR TemplateFilePath[512];
|
|
} SMC_CACHE_CREATE_PARAMETERS, *PSMC_CACHE_CREATE_PARAMETERS;
|
|
|
|
/**
|
|
* The SMC_CACHE_CREATE_REQUEST structure describes a request to create a store manager cache.
|
|
*/
|
|
typedef struct _SMC_CACHE_CREATE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_CREATE_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG CacheId;
|
|
SMC_CACHE_CREATE_PARAMETERS CacheCreateParams;
|
|
} SMC_CACHE_CREATE_REQUEST, *PSMC_CACHE_CREATE_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_DELETE_INFORMATION_VERSION 1
|
|
|
|
/**
|
|
* The SMC_CACHE_DELETE_REQUEST structure describes a request to delete a store manager cache.
|
|
*/
|
|
typedef struct _SMC_CACHE_DELETE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_DELETE_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG CacheId;
|
|
} SMC_CACHE_DELETE_REQUEST, *PSMC_CACHE_DELETE_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_STORE_CREATE_INFORMATION_VERSION 2
|
|
|
|
/**
|
|
* The SM_STORE_MANAGER_TYPE enumeration defines the store manager types.
|
|
*/
|
|
typedef enum _SM_STORE_MANAGER_TYPE
|
|
{
|
|
SmStoreManagerTypePhysical = 0,
|
|
SmStoreManagerTypeVirtual = 1,
|
|
SmStoreManagerTypeMax = 2
|
|
} SM_STORE_MANAGER_TYPE;
|
|
|
|
/**
|
|
* The SMC_STORE_CREATE_REQUEST structure describes a request to create a store within a store manager cache.
|
|
*/
|
|
typedef struct _SMC_STORE_CREATE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_STORE_CREATE_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
SM_STORE_BASIC_PARAMS StoreParams;
|
|
ULONG CacheId;
|
|
SM_STORE_MANAGER_TYPE StoreManagerType;
|
|
ULONG StoreId;
|
|
} SMC_STORE_CREATE_REQUEST, *PSMC_STORE_CREATE_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_STORE_DELETE_INFORMATION_VERSION 1
|
|
|
|
/**
|
|
* The SMC_STORE_DELETE_REQUEST structure describes a request to delete a store within a store manager cache.
|
|
*/
|
|
typedef struct _SMC_STORE_DELETE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_STORE_DELETE_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG CacheId;
|
|
SM_STORE_MANAGER_TYPE StoreManagerType;
|
|
ULONG StoreId;
|
|
} SMC_STORE_DELETE_REQUEST, *PSMC_STORE_DELETE_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_STATS_INFORMATION_VERSION 3
|
|
|
|
/**
|
|
* The SMC_CACHE_STATS structure contains statistics for a store manager cache.
|
|
*/
|
|
typedef struct _SMC_CACHE_STATS
|
|
{
|
|
SIZE_T TotalFileSize;
|
|
ULONG StoreCount;
|
|
ULONG RegionCount;
|
|
ULONG RegionSizeBytes;
|
|
ULONG FileCount : 6;
|
|
ULONG PerformsFileIo : 1;
|
|
ULONG Spare : 25;
|
|
ULONG StoreIds[16];
|
|
ULONG PhysicalStoreBitmap;
|
|
ULONG Priority;
|
|
WCHAR TemplateFilePath[512];
|
|
} SMC_CACHE_STATS, *PSMC_CACHE_STATS;
|
|
|
|
/**
|
|
* The SMC_CACHE_STATS_REQUEST structure describes a request for store manager cache statistics.
|
|
*/
|
|
typedef struct _SMC_CACHE_STATS_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_STATS_INFORMATION_VERSION
|
|
ULONG NoFilePath : 1; // Skip TemplateFilePath when set
|
|
ULONG Spare : 23;
|
|
ULONG CacheId; // cache to query for statistics
|
|
SMC_CACHE_STATS CacheStats;
|
|
} SMC_CACHE_STATS_REQUEST, *PSMC_CACHE_STATS_REQUEST;
|
|
|
|
#define SYSTEM_STORE_REGISTRATION_INFORMATION_VERSION 2
|
|
|
|
/**
|
|
* The SM_REGISTRATION_INFO structure contains store manager registration information.
|
|
*/
|
|
typedef struct _SM_REGISTRATION_INFO
|
|
{
|
|
HANDLE CachesUpdatedEvent;
|
|
} SM_REGISTRATION_INFO, *PSM_REGISTRATION_INFO;
|
|
|
|
/**
|
|
* The SM_REGISTRATION_REQUEST structure describes a store manager registration request.
|
|
*/
|
|
typedef struct _SM_REGISTRATION_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_REGISTRATION_INFORMATION_VERSION
|
|
ULONG Spare : 24;
|
|
SM_REGISTRATION_INFO RegInfo;
|
|
} SM_REGISTRATION_REQUEST, *PSM_REGISTRATION_REQUEST;
|
|
|
|
#define SYSTEM_STORE_RESIZE_INFORMATION_VERSION 6
|
|
|
|
/**
|
|
* The SM_STORE_RESIZE_REQUEST structure describes a request to resize a store manager store.
|
|
*/
|
|
typedef struct _SM_STORE_RESIZE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_RESIZE_INFORMATION_VERSION
|
|
ULONG AddRegions : 1; // Clear to remove regions, set to add regions. Current handler rejects user-mode callers.
|
|
ULONG Spare : 23;
|
|
ULONG StoreId;
|
|
ULONG NumberOfRegions;
|
|
PRTL_BITMAP RegionBitmap; // Kernel-mode only bitmap pointer consumed by SmProcessResizeRequest.
|
|
} SM_STORE_RESIZE_REQUEST, *PSM_STORE_RESIZE_REQUEST;
|
|
|
|
#define SYSTEM_CACHE_STORE_RESIZE_INFORMATION_VERSION 1
|
|
|
|
/**
|
|
* The SM_STORE_CACHE_RESIZE_REQUEST structure describes a request to resize a store manager cache.
|
|
*/
|
|
typedef struct _SM_STORE_CACHE_RESIZE_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_CACHE_STORE_RESIZE_INFORMATION_VERSION
|
|
ULONG AddRegions : 1;
|
|
ULONG Spare : 23;
|
|
ULONG CacheId;
|
|
ULONG StoreId;
|
|
SM_STORE_MANAGER_TYPE StoreManagerType;
|
|
ULONG RegionCount;
|
|
} SM_STORE_CACHE_RESIZE_REQUEST, *PSM_STORE_CACHE_RESIZE_REQUEST;
|
|
|
|
#define SYSTEM_STORE_CONFIG_INFORMATION_VERSION 4
|
|
|
|
/**
|
|
* The SM_CONFIG_TYPE enumeration defines the store manager configuration types.
|
|
*/
|
|
typedef enum _SM_CONFIG_TYPE
|
|
{
|
|
SmConfigDirtyPageCompression = 0,
|
|
SmConfigAsyncInswap = 1,
|
|
SmConfigPrefetchSeekThreshold = 2,
|
|
SmConfigTypeMax = 3
|
|
} SM_CONFIG_TYPE;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_CONFIG_REQUEST structure describes a store manager configuration request.
|
|
*/
|
|
typedef struct _SM_CONFIG_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_CONFIG_INFORMATION_VERSION
|
|
ULONG Spare : 16;
|
|
ULONG ConfigType : 8; // SM_CONFIG_TYPE
|
|
ULONG ConfigValue;
|
|
} SM_CONFIG_REQUEST, *PSM_CONFIG_REQUEST;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_PRIORITY_REQUEST_VERSION 1
|
|
// rev
|
|
#define SYSTEM_STORE_PRIORITY_FLAG_REQUIRE_HANDLE 0x00000100u // required
|
|
#define SYSTEM_STORE_PRIORITY_FLAG_SET_PRIORITY 0x00000200u
|
|
|
|
// rev
|
|
/**
|
|
* The SM_STORE_MEMORY_PRIORITY_REQUEST structure describes a request to set the memory priority of a store manager store.
|
|
*/
|
|
typedef struct _SM_STORE_MEMORY_PRIORITY_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_PRIORITY_REQUEST_VERSION
|
|
ULONG Flags : 24; // SYSTEM_STORE_PRIORITY_FLAG_*; handler currently validates Flags <= 0x3ff.
|
|
HANDLE ProcessHandle; // Required when SYSTEM_STORE_PRIORITY_FLAG_REQUIRE_HANDLE is set; PROCESS_SET_INFORMATION access required.
|
|
} SM_STORE_MEMORY_PRIORITY_REQUEST, *PSM_STORE_MEMORY_PRIORITY_REQUEST;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_SYSTEM_STORE_TRIM_REQUEST structure describes a request to trim the system store.
|
|
*/
|
|
typedef struct _SM_SYSTEM_STORE_TRIM_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_TRIM_INFORMATION_VERSION_V1 or _V2
|
|
ULONG Spare : 24;
|
|
SIZE_T PagesToTrim; // Must be non-zero.
|
|
HANDLE PartitionHandle; // Optional in V2 (24H2+); absent in V1.
|
|
} SM_SYSTEM_STORE_TRIM_REQUEST, *PSM_SYSTEM_STORE_TRIM_REQUEST;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_VERSION_V1 1 // WIN10
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_VERSION_V2 2 // 24H2
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_VERSION SYSTEM_STORE_TRIM_INFORMATION_VERSION_V2
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_SIZE_V1 RTL_SIZEOF_THROUGH_FIELD(SM_SYSTEM_STORE_TRIM_REQUEST, PagesToTrim) // Version 1 input size
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2 RTL_SIZEOF_THROUGH_FIELD(SM_SYSTEM_STORE_TRIM_REQUEST, PartitionHandle) // Version 2 input size (24H2+)
|
|
#define SYSTEM_STORE_TRIM_INFORMATION_SIZE SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2
|
|
|
|
#ifdef _WIN64
|
|
static_assert(SYSTEM_STORE_TRIM_INFORMATION_SIZE_V1 == 16, "SYSTEM_STORE_TRIM_INFORMATION_SIZE_V1 must equal 16");
|
|
static_assert(SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2 == 24, "SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2 must equal 24");
|
|
#else
|
|
static_assert(SYSTEM_STORE_TRIM_INFORMATION_SIZE_V1 == 8, "SYSTEM_STORE_TRIM_INFORMATION_SIZE_V1 must equal 8");
|
|
static_assert(SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2 == 12, "SYSTEM_STORE_TRIM_INFORMATION_SIZE_V2 must equal 12");
|
|
#endif
|
|
|
|
// rev
|
|
/**
|
|
* The SM_STORE_COMPRESSION_INFORMATION_REQUEST structure describes a request for store compression information.
|
|
*/
|
|
typedef struct _SM_STORE_COMPRESSION_INFORMATION_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_COMPRESSION_INFORMATION_VERSION_V1 or _V2
|
|
ULONG Spare : 24;
|
|
ULONG CompressionPid;
|
|
ULONG WorkingSetSize;
|
|
SIZE_T TotalDataCompressed;
|
|
SIZE_T TotalCompressedSize;
|
|
SIZE_T TotalUniqueDataCompressed;
|
|
HANDLE PartitionHandle; // Optional in V2 (24H2+); absent in V1.
|
|
} SM_STORE_COMPRESSION_INFORMATION_REQUEST, *PSM_STORE_COMPRESSION_INFORMATION_REQUEST;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_VERSION_V1 3 // WIN10
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_VERSION_V2 4 // 24H2
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_VERSION SYSTEM_STORE_COMPRESSION_INFORMATION_VERSION_V2
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V1 RTL_SIZEOF_THROUGH_FIELD(SM_STORE_COMPRESSION_INFORMATION_REQUEST, TotalUniqueDataCompressed) // Version 3 input/output size
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V2 RTL_SIZEOF_THROUGH_FIELD(SM_STORE_COMPRESSION_INFORMATION_REQUEST, PartitionHandle) // Version 4 input/output size (24H2+)
|
|
#define SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V2
|
|
|
|
#ifdef _WIN64
|
|
static_assert(SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V1 == 40, "SM_STORE_COMPRESSION_INFORMATION_REQUEST_V1 must equal 40");
|
|
static_assert(SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V2 == 48, "SM_STORE_COMPRESSION_INFORMATION_REQUEST_V2 must equal 48");
|
|
#else
|
|
static_assert(SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V1 == 24, "SM_STORE_COMPRESSION_INFORMATION_REQUEST_V1 must equal 24");
|
|
static_assert(SYSTEM_STORE_COMPRESSION_INFORMATION_SIZE_V2 == 28, "SM_STORE_COMPRESSION_INFORMATION_REQUEST_V2 must equal 28");
|
|
#endif
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_EXISTS_FOR_PROCESS_VERSION 1
|
|
|
|
// rev
|
|
/**
|
|
* The SM_SYSTEM_STORE_EXISTS_FOR_PROCESS structure describes a query for whether a system store exists for a process.
|
|
*/
|
|
typedef struct _SM_SYSTEM_STORE_EXISTS_FOR_PROCESS
|
|
{
|
|
ULONG Version : 8;
|
|
ULONG Spare : 24;
|
|
HANDLE ProcessHandle; // in // PROCESS_QUERY_INFORMATION access required
|
|
BOOLEAN StoreExists; // out
|
|
} SM_SYSTEM_STORE_EXISTS_FOR_PROCESS, *PSM_SYSTEM_STORE_EXISTS_FOR_PROCESS;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_PFN_UNION1_Q0 union describes the page frame number (PFN) bitfields used in compression read statistics.
|
|
*/
|
|
typedef union _SM_COMPRESSION_READ_STATS_PFN_UNION1_Q0
|
|
{
|
|
ULONGLONG EntireField;
|
|
PVOID NextSlistPfn;
|
|
PVOID Next;
|
|
struct
|
|
{
|
|
ULONGLONG Flink : 40;
|
|
ULONGLONG NodeFlinkLow : 24;
|
|
} Active;
|
|
} SM_COMPRESSION_READ_STATS_PFN_UNION1_Q0, *PSM_COMPRESSION_READ_STATS_PFN_UNION1_Q0;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_PFN_UNION1 union describes the page frame number (PFN) fields used in compression read statistics.
|
|
*/
|
|
typedef union _SM_COMPRESSION_READ_STATS_PFN_UNION1
|
|
{
|
|
struct
|
|
{
|
|
LIST_ENTRY ListEntry;
|
|
ULONGLONG OriginalPte;
|
|
} DUMMYSTRUCTNAME;
|
|
struct
|
|
{
|
|
SM_COMPRESSION_READ_STATS_PFN_UNION1_Q0 U1;
|
|
PVOID PteAddress;
|
|
ULONGLONG PteLong;
|
|
} DUMMYSTRUCTNAME2;
|
|
ULONGLONG EntireField[3];
|
|
} SM_COMPRESSION_READ_STATS_PFN_UNION1, *PSM_COMPRESSION_READ_STATS_PFN_UNION1;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_PFN_BLINK union describes the backward-link page frame number (PFN) field used in compression read statistics.
|
|
*/
|
|
typedef union _SM_COMPRESSION_READ_STATS_PFN_BLINK
|
|
{
|
|
struct
|
|
{
|
|
ULONGLONG Blink : 40;
|
|
ULONGLONG NodeBlinkLow : 19;
|
|
ULONGLONG TbFlushStamp : 3;
|
|
ULONGLONG PageBlinkDeleteBit : 1;
|
|
ULONGLONG PageBlinkLockBit : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONGLONG EntireField;
|
|
} SM_COMPRESSION_READ_STATS_PFN_BLINK, *PSM_COMPRESSION_READ_STATS_PFN_BLINK;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_PFN_FLAGS union defines the page frame number (PFN) flags used in compression read statistics.
|
|
*/
|
|
typedef union _SM_COMPRESSION_READ_STATS_PFN_FLAGS
|
|
{
|
|
struct
|
|
{
|
|
USHORT ReferenceCount;
|
|
UCHAR PageLocation : 3;
|
|
UCHAR WriteInProgress : 1;
|
|
UCHAR Modified : 1;
|
|
UCHAR ReadInProgress : 1;
|
|
UCHAR CacheAttribute : 2;
|
|
UCHAR Priority : 3;
|
|
UCHAR OnProtectedStandby : 1;
|
|
UCHAR InPageError : 1;
|
|
UCHAR SystemChargedPage : 1;
|
|
UCHAR RemovalRequested : 1;
|
|
UCHAR ParityError : 1;
|
|
ULONG StateFlags2; // _MMPFN.u5, state-dependent
|
|
} DUMMYSTRUCTNAME;
|
|
ULONGLONG EntireField;
|
|
} SM_COMPRESSION_READ_STATS_PFN_FLAGS, *PSM_COMPRESSION_READ_STATS_PFN_FLAGS;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_PFN_FLAGS4 union defines additional page frame number (PFN) flags used in compression read statistics.
|
|
*/
|
|
typedef union _SM_COMPRESSION_READ_STATS_PFN_FLAGS4
|
|
{
|
|
struct
|
|
{
|
|
ULONGLONG PteFrame : 40;
|
|
ULONGLONG ResidentPage : 1;
|
|
ULONGLONG ResidentPageContainsBadPages : 1;
|
|
ULONGLONG Unused1 : 1;
|
|
ULONGLONG Partition : 10;
|
|
ULONGLONG FileOnly : 1;
|
|
ULONGLONG PfnExists : 1;
|
|
ULONGLONG NodeFlinkHigh : 5;
|
|
ULONGLONG PageIdentity : 3;
|
|
ULONGLONG PrototypePte : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONGLONG EntireField;
|
|
} SM_COMPRESSION_READ_STATS_PFN_FLAGS4, *PSM_COMPRESSION_READ_STATS_PFN_FLAGS4;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_EMBEDDED_PFN structure describes an embedded page frame number (PFN) entry in compression read statistics.
|
|
*/
|
|
typedef struct _SM_COMPRESSION_READ_STATS_EMBEDDED_PFN
|
|
{
|
|
SM_COMPRESSION_READ_STATS_PFN_UNION1 Union1; // _MMPFN.___u0, state-dependent
|
|
SM_COMPRESSION_READ_STATS_PFN_BLINK BlinkField;
|
|
SM_COMPRESSION_READ_STATS_PFN_FLAGS ReferenceCountAndFlags;
|
|
SM_COMPRESSION_READ_STATS_PFN_FLAGS4 PfnFlags4;
|
|
} SM_COMPRESSION_READ_STATS_EMBEDDED_PFN, *PSM_COMPRESSION_READ_STATS_EMBEDDED_PFN;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_LIST_HEAD structure describes the list head for compression read statistics.
|
|
*/
|
|
typedef struct _SM_COMPRESSION_READ_STATS_LIST_HEAD
|
|
{
|
|
ULONGLONG Total;
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
ULONG Color;
|
|
ULONG ListName;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONGLONG ColorAndListName;
|
|
} DUMMYUNIONNAME;
|
|
ULONGLONG Flink;
|
|
ULONGLONG Blink;
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
LONG Lock;
|
|
ULONG Reserved;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONGLONG LockValue;
|
|
} DUMMYUNIONNAME2;
|
|
SM_COMPRESSION_READ_STATS_EMBEDDED_PFN EmbeddedPfn;
|
|
} SM_COMPRESSION_READ_STATS_LIST_HEAD, *PSM_COMPRESSION_READ_STATS_LIST_HEAD;
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS structure contains store compression read statistics.
|
|
*/
|
|
typedef struct _SM_COMPRESSION_READ_STATS
|
|
{
|
|
SM_COMPRESSION_READ_STATS_LIST_HEAD ZeroedPageListHead;
|
|
ULONGLONG Alignment[5];
|
|
ULONGLONG FreePageListHeadTotal;
|
|
ULONGLONG FreePageListHeadColorAndListName;
|
|
} SM_COMPRESSION_READ_STATS, * PSM_COMPRESSION_READ_STATS;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_COMPRESSION_READ_STATS_VERSION 1
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_READ_STATS_REQUEST structure describes a request for store compression read statistics.
|
|
*/
|
|
typedef struct _SM_COMPRESSION_READ_STATS_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_COMPRESSION_READ_STATS_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG Flags; // must be zero
|
|
HANDLE PartitionHandle; // optional
|
|
SM_COMPRESSION_READ_STATS Stats; // output
|
|
} SM_COMPRESSION_READ_STATS_REQUEST, *PSM_COMPRESSION_READ_STATS_REQUEST;
|
|
|
|
// rev
|
|
#define SYSTEM_STORE_ACCELERATOR_REQUEST_VERSION 1
|
|
|
|
// rev
|
|
/**
|
|
* The SM_COMPRESSION_ACCELERATOR_REQUEST structure describes a store compression accelerator request.
|
|
*/
|
|
typedef struct _SM_COMPRESSION_ACCELERATOR_REQUEST
|
|
{
|
|
ULONG Version : 8; // SYSTEM_STORE_ACCELERATOR_REQUEST_VERSION
|
|
ULONG Spare : 24;
|
|
ULONG Flags; // must be zero
|
|
HANDLE PartitionHandle; // optional
|
|
ULONG AcceleratorValue; // output
|
|
} SM_COMPRESSION_ACCELERATOR_REQUEST, *PSM_COMPRESSION_ACCELERATOR_REQUEST;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_REGISTRY_APPEND_STRING_PARAMETERS structure specifies the parameters for system registry append string.
|
|
*/
|
|
typedef struct _SYSTEM_REGISTRY_APPEND_STRING_PARAMETERS
|
|
{
|
|
HANDLE KeyHandle;
|
|
PUNICODE_STRING ValueNamePointer;
|
|
PULONG RequiredLengthPointer;
|
|
PUCHAR Buffer;
|
|
ULONG BufferLength;
|
|
ULONG Type;
|
|
PUCHAR AppendBuffer;
|
|
ULONG AppendBufferLength;
|
|
BOOLEAN CreateIfDoesntExist;
|
|
BOOLEAN TruncateExistingValue;
|
|
} SYSTEM_REGISTRY_APPEND_STRING_PARAMETERS, *PSYSTEM_REGISTRY_APPEND_STRING_PARAMETERS;
|
|
|
|
// msdn
|
|
/**
|
|
* The SYSTEM_VHD_BOOT_INFORMATION structure contains system VHD boot information.
|
|
*/
|
|
typedef struct _SYSTEM_VHD_BOOT_INFORMATION
|
|
{
|
|
BOOLEAN OsDiskIsVhd;
|
|
ULONG OsVhdFilePathOffset;
|
|
WCHAR OsVhdParentVolume[1];
|
|
} SYSTEM_VHD_BOOT_INFORMATION, *PSYSTEM_VHD_BOOT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The PS_CPU_QUOTA_QUERY_ENTRY structure describes a single PS CPU quota query entry.
|
|
*/
|
|
typedef struct _PS_CPU_QUOTA_QUERY_ENTRY
|
|
{
|
|
ULONG SessionId;
|
|
ULONG Weight;
|
|
} PS_CPU_QUOTA_QUERY_ENTRY, *PPS_CPU_QUOTA_QUERY_ENTRY;
|
|
|
|
// private
|
|
/**
|
|
* The PS_CPU_QUOTA_QUERY_INFORMATION structure contains PS CPU quota query information.
|
|
*/
|
|
typedef struct _PS_CPU_QUOTA_QUERY_INFORMATION
|
|
{
|
|
ULONG SessionCount;
|
|
PS_CPU_QUOTA_QUERY_ENTRY SessionInformation[1];
|
|
} PS_CPU_QUOTA_QUERY_INFORMATION, *PPS_CPU_QUOTA_QUERY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ERROR_PORT_TIMEOUTS structure contains the system error port timeout values.
|
|
*/
|
|
typedef struct _SYSTEM_ERROR_PORT_TIMEOUTS
|
|
{
|
|
ULONG StartTimeout;
|
|
ULONG CommTimeout;
|
|
} SYSTEM_ERROR_PORT_TIMEOUTS, *PSYSTEM_ERROR_PORT_TIMEOUTS;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_LOW_PRIORITY_IO_INFORMATION structure contains system low priority IO information.
|
|
*/
|
|
typedef struct _SYSTEM_LOW_PRIORITY_IO_INFORMATION
|
|
{
|
|
ULONG LowPriorityReadOperationCount;
|
|
ULONG LowPriorityWriteOperationCount;
|
|
ULONG KernelBumpedToNormalOperations;
|
|
ULONG LowPriorityPagingReadOperations;
|
|
ULONG KernelPagingReadsBumpedToNormal;
|
|
ULONG LowPriorityPagingWriteOperations;
|
|
ULONG KernelPagingWritesBumpedToNormal;
|
|
ULONG BoostedThreadedIrpCount;
|
|
ULONG BoostedPagingIrpCount;
|
|
ULONG BlanketBoostCount;
|
|
} SYSTEM_LOW_PRIORITY_IO_INFORMATION, *PSYSTEM_LOW_PRIORITY_IO_INFORMATION;
|
|
|
|
// symbols
|
|
/**
|
|
* The BOOT_ENTROPY_SOURCE_RESULT_CODE enumeration defines the boot entropy source result code values.
|
|
*/
|
|
typedef enum _BOOT_ENTROPY_SOURCE_RESULT_CODE
|
|
{
|
|
BootEntropySourceStructureUninitialized,
|
|
BootEntropySourceDisabledByPolicy,
|
|
BootEntropySourceNotPresent,
|
|
BootEntropySourceError,
|
|
BootEntropySourceSuccess
|
|
} BOOT_ENTROPY_SOURCE_RESULT_CODE;
|
|
|
|
/**
|
|
* The BOOT_ENTROPY_SOURCE_ID enumeration identifies a boot entropy source.
|
|
*/
|
|
typedef enum _BOOT_ENTROPY_SOURCE_ID
|
|
{
|
|
BootEntropySourceNone = 0,
|
|
BootEntropySourceSeedfile = 1,
|
|
BootEntropySourceExternal = 2,
|
|
BootEntropySourceTpm = 3,
|
|
BootEntropySourceRdrand = 4,
|
|
BootEntropySourceTime = 5,
|
|
BootEntropySourceAcpiOem0 = 6,
|
|
BootEntropySourceUefi = 7,
|
|
BootEntropySourceCng = 8,
|
|
BootEntropySourceTcbTpm = 9,
|
|
BootEntropySourceTcbRdrand = 10,
|
|
BootMaxEntropySources = 10
|
|
} BOOT_ENTROPY_SOURCE_ID, *PBOOT_ENTROPY_SOURCE_ID;
|
|
|
|
// Contents of KeLoaderBlock->Extension->TpmBootEntropyResult (TPM_BOOT_ENTROPY_LDR_RESULT).
|
|
// EntropyData is truncated to 40 bytes.
|
|
|
|
// private
|
|
/**
|
|
* The TPM_BOOT_ENTROPY_NT_RESULT structure contains the TPM boot entropy nt result.
|
|
*/
|
|
typedef struct _TPM_BOOT_ENTROPY_NT_RESULT
|
|
{
|
|
ULONGLONG Policy;
|
|
BOOT_ENTROPY_SOURCE_RESULT_CODE ResultCode;
|
|
NTSTATUS ResultStatus;
|
|
ULONGLONG Time;
|
|
ULONG EntropyLength;
|
|
UCHAR EntropyData[40];
|
|
} TPM_BOOT_ENTROPY_NT_RESULT, *PTPM_BOOT_ENTROPY_NT_RESULT;
|
|
|
|
// private
|
|
/**
|
|
* The BOOT_ENTROPY_SOURCE_NT_RESULT structure contains the boot entropy source nt result.
|
|
*/
|
|
typedef struct _BOOT_ENTROPY_SOURCE_NT_RESULT
|
|
{
|
|
BOOT_ENTROPY_SOURCE_ID SourceId;
|
|
ULONG64 Policy;
|
|
BOOT_ENTROPY_SOURCE_RESULT_CODE ResultCode;
|
|
NTSTATUS ResultStatus;
|
|
ULONGLONG Time;
|
|
ULONG EntropyLength;
|
|
UCHAR EntropyData[64];
|
|
} BOOT_ENTROPY_SOURCE_NT_RESULT, *PBOOT_ENTROPY_SOURCE_NT_RESULT;
|
|
|
|
// private
|
|
/**
|
|
* The BOOT_ENTROPY_NT_RESULT structure contains the boot entropy nt result.
|
|
*/
|
|
typedef struct _BOOT_ENTROPY_NT_RESULT
|
|
{
|
|
ULONG MaxEntropySources;
|
|
BOOT_ENTROPY_SOURCE_NT_RESULT EntropySourceResult[10];
|
|
UCHAR SeedBytesForCng[48];
|
|
} BOOT_ENTROPY_NT_RESULT, *PBOOT_ENTROPY_NT_RESULT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VERIFIER_COUNTERS_INFORMATION structure contains system verifier counters information.
|
|
*/
|
|
typedef struct _SYSTEM_VERIFIER_COUNTERS_INFORMATION
|
|
{
|
|
SYSTEM_VERIFIER_INFORMATION Legacy;
|
|
ULONG RaiseIrqls;
|
|
ULONG AcquireSpinLocks;
|
|
ULONG SynchronizeExecutions;
|
|
ULONG AllocationsWithNoTag;
|
|
ULONG AllocationsFailed;
|
|
ULONG AllocationsFailedDeliberately;
|
|
SIZE_T LockedBytes;
|
|
SIZE_T PeakLockedBytes;
|
|
SIZE_T MappedLockedBytes;
|
|
SIZE_T PeakMappedLockedBytes;
|
|
SIZE_T MappedIoSpaceBytes;
|
|
SIZE_T PeakMappedIoSpaceBytes;
|
|
SIZE_T PagesForMdlBytes;
|
|
SIZE_T PeakPagesForMdlBytes;
|
|
SIZE_T ContiguousMemoryBytes;
|
|
SIZE_T PeakContiguousMemoryBytes;
|
|
ULONG ExecutePoolTypes; // REDSTONE2
|
|
ULONG ExecutePageProtections;
|
|
ULONG ExecutePageMappings;
|
|
ULONG ExecuteWriteSections;
|
|
ULONG SectionAlignmentFailures;
|
|
ULONG UnsupportedRelocs;
|
|
ULONG IATInExecutableSection;
|
|
} SYSTEM_VERIFIER_COUNTERS_INFORMATION, *PSYSTEM_VERIFIER_COUNTERS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ACPI_AUDIT_INFORMATION structure contains system ACPI audit information.
|
|
*/
|
|
typedef struct _SYSTEM_ACPI_AUDIT_INFORMATION
|
|
{
|
|
ULONG RsdpCount;
|
|
ULONG SameRsdt : 1;
|
|
ULONG SlicPresent : 1;
|
|
ULONG SlicDifferent : 1;
|
|
} SYSTEM_ACPI_AUDIT_INFORMATION, *PSYSTEM_ACPI_AUDIT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BASIC_PERFORMANCE_INFORMATION structure contains system basic performance information.
|
|
*/
|
|
typedef struct _SYSTEM_BASIC_PERFORMANCE_INFORMATION
|
|
{
|
|
SIZE_T AvailablePages;
|
|
SIZE_T CommittedPages;
|
|
SIZE_T CommitLimit;
|
|
SIZE_T PeakCommitment;
|
|
} SYSTEM_BASIC_PERFORMANCE_INFORMATION, *PSYSTEM_BASIC_PERFORMANCE_INFORMATION;
|
|
|
|
// begin_msdn
|
|
|
|
/**
|
|
* The QUERY_PERFORMANCE_COUNTER_FLAGS structure defines the query performance counter flags.
|
|
*/
|
|
typedef struct _QUERY_PERFORMANCE_COUNTER_FLAGS
|
|
{
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
ULONG KernelTransition : 1;
|
|
ULONG Reserved : 31;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONG ul;
|
|
} DUMMYUNIONNAME;
|
|
} QUERY_PERFORMANCE_COUNTER_FLAGS;
|
|
|
|
/**
|
|
* The SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION structure contains system query performance counter information.
|
|
*/
|
|
typedef struct _SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION
|
|
{
|
|
ULONG Version;
|
|
QUERY_PERFORMANCE_COUNTER_FLAGS Flags;
|
|
QUERY_PERFORMANCE_COUNTER_FLAGS ValidFlags;
|
|
} SYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION, *PSYSTEM_QUERY_PERFORMANCE_COUNTER_INFORMATION;
|
|
|
|
// end_msdn
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PIXEL_FORMAT enumeration defines the system pixel format values.
|
|
*/
|
|
typedef enum _SYSTEM_PIXEL_FORMAT
|
|
{
|
|
SystemPixelFormatUnknown,
|
|
SystemPixelFormatR8G8B8,
|
|
SystemPixelFormatR8G8B8X8,
|
|
SystemPixelFormatB8G8R8,
|
|
SystemPixelFormatB8G8R8X8
|
|
} SYSTEM_PIXEL_FORMAT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BOOT_GRAPHICS_INFORMATION structure contains system boot graphics information.
|
|
*/
|
|
typedef struct _SYSTEM_BOOT_GRAPHICS_INFORMATION
|
|
{
|
|
LARGE_INTEGER FrameBuffer;
|
|
ULONG Width;
|
|
ULONG Height;
|
|
ULONG PixelStride;
|
|
ULONG Flags;
|
|
SYSTEM_PIXEL_FORMAT Format;
|
|
ULONG DisplayRotation;
|
|
} SYSTEM_BOOT_GRAPHICS_INFORMATION, *PSYSTEM_BOOT_GRAPHICS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The MEMORY_SCRUB_INFORMATION structure contains memory scrub information.
|
|
*/
|
|
typedef struct _MEMORY_SCRUB_INFORMATION
|
|
{
|
|
HANDLE Handle;
|
|
SIZE_T PagesScrubbed;
|
|
} MEMORY_SCRUB_INFORMATION, *PMEMORY_SCRUB_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Describes one page returned in the flat array for SystemBadPageInformationEx (244).
|
|
* On x64, bits 0-51 are the page number, bit 62 is Pending, and bit 63 is Poisoned.
|
|
* SystemBadPageInformation (128) omits pending entries and clears the poisoned bit.
|
|
* There is no count prefix in the returned buffer; divide ReturnLength by the entry size.
|
|
* ExpQuerySystemInformation and MiGetListOfPendingBadPages use 8-byte entries on x64.
|
|
*/
|
|
typedef union _SYSTEM_BAD_PAGE_INFORMATION
|
|
{
|
|
ULONG_PTR Value;
|
|
struct
|
|
{
|
|
#ifdef _WIN64
|
|
ULONG_PTR PhysicalPageNumber : 52;
|
|
#else
|
|
ULONG PhysicalPageNumber : 20;
|
|
#endif
|
|
ULONG_PTR Reserved : 10;
|
|
ULONG_PTR Pending : 1;
|
|
ULONG_PTR Poisoned : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
} SYSTEM_BAD_PAGE_INFORMATION, *PSYSTEM_BAD_PAGE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Describes the 32-bit-address Intel BTS/PEBS debug-store save area. The address
|
|
* fields are ULONGs, but all counter-reset values are 64-bit. The layout occupies
|
|
* 0x80 bytes, with GP resets at 0x20 and fixed resets at 0x60.
|
|
*/
|
|
typedef struct _PEBS_DS_SAVE_AREA32
|
|
{
|
|
ULONG BtsBufferBase;
|
|
ULONG BtsIndex;
|
|
ULONG BtsAbsoluteMaximum;
|
|
ULONG BtsInterruptThreshold;
|
|
ULONG PebsBufferBase;
|
|
ULONG PebsIndex;
|
|
ULONG PebsAbsoluteMaximum;
|
|
ULONG PebsInterruptThreshold;
|
|
ULONGLONG PebsGpCounterReset[8]; // 64-bit reset values even in the 32-bit DS format.
|
|
ULONGLONG PebsFixedCounterReset[4];
|
|
} PEBS_DS_SAVE_AREA32, *PPEBS_DS_SAVE_AREA32;
|
|
|
|
// private
|
|
/**
|
|
* The PEBS_DS_SAVE_AREA64 structure describes the PEBS ds save area64.
|
|
*/
|
|
typedef struct _PEBS_DS_SAVE_AREA64
|
|
{
|
|
ULONGLONG BtsBufferBase;
|
|
ULONGLONG BtsIndex;
|
|
ULONGLONG BtsAbsoluteMaximum;
|
|
ULONGLONG BtsInterruptThreshold;
|
|
ULONGLONG PebsBufferBase;
|
|
ULONGLONG PebsIndex;
|
|
ULONGLONG PebsAbsoluteMaximum;
|
|
ULONGLONG PebsInterruptThreshold;
|
|
ULONGLONG PebsGpCounterReset[8];
|
|
ULONGLONG PebsFixedCounterReset[4];
|
|
} PEBS_DS_SAVE_AREA64, *PPEBS_DS_SAVE_AREA64;
|
|
|
|
// private
|
|
/**
|
|
* The PEBS_DS_SAVE_AREA union describes the PEBS ds save area.
|
|
*/
|
|
typedef union _PEBS_DS_SAVE_AREA
|
|
{
|
|
PEBS_DS_SAVE_AREA32 As32Bit;
|
|
PEBS_DS_SAVE_AREA64 As64Bit;
|
|
} PEBS_DS_SAVE_AREA, *PPEBS_DS_SAVE_AREA;
|
|
|
|
// private
|
|
/**
|
|
* The PROCESSOR_PROFILE_CONTROL_AREA structure describes the processor profile control area.
|
|
*/
|
|
typedef struct _PROCESSOR_PROFILE_CONTROL_AREA
|
|
{
|
|
PEBS_DS_SAVE_AREA PebsDsSaveArea;
|
|
} PROCESSOR_PROFILE_CONTROL_AREA, *PPROCESSOR_PROFILE_CONTROL_AREA;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PROFILE_CONTROL_AREA structure describes the system processor profile control area.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PROFILE_CONTROL_AREA
|
|
{
|
|
PROCESSOR_PROFILE_CONTROL_AREA ProcessorProfileControlArea;
|
|
BOOLEAN Allocate;
|
|
} SYSTEM_PROCESSOR_PROFILE_CONTROL_AREA, *PSYSTEM_PROCESSOR_PROFILE_CONTROL_AREA;
|
|
|
|
// private
|
|
/**
|
|
* The MEMORY_COMBINE_INFORMATION structure contains memory combine information.
|
|
*/
|
|
typedef struct _MEMORY_COMBINE_INFORMATION
|
|
{
|
|
HANDLE EventHandle; // Optional event handle.
|
|
SIZE_T PagesCombined;
|
|
} MEMORY_COMBINE_INFORMATION, *PMEMORY_COMBINE_INFORMATION;
|
|
|
|
// rev
|
|
#define MEMORY_COMBINE_FLAGS_COMMON_PAGES_ONLY 0x1 // MiCombineIdenticalPages only accepts bits 0 and 1; this bit selects the legacy/common-page path.
|
|
#define MEMORY_COMBINE_FLAGS_COMBINE_WORKING_SET 0x2 // Enables the working-set combine path; required when ProcessHandle is specified.
|
|
|
|
// private
|
|
/**
|
|
* The MEMORY_COMBINE_INFORMATION_EX structure contains memory combine information.
|
|
*/
|
|
typedef struct _MEMORY_COMBINE_INFORMATION_EX
|
|
{
|
|
HANDLE EventHandle; // Optional event handle.
|
|
SIZE_T PagesCombined;
|
|
ULONG Flags; // MEMORY_COMBINE_FLAGS_*
|
|
} MEMORY_COMBINE_INFORMATION_EX, *PMEMORY_COMBINE_INFORMATION_EX;
|
|
|
|
// private
|
|
/**
|
|
* The MEMORY_COMBINE_INFORMATION_EX2 structure contains memory combine information.
|
|
*/
|
|
typedef struct _MEMORY_COMBINE_INFORMATION_EX2
|
|
{
|
|
HANDLE EventHandle; // Optional event handle.
|
|
SIZE_T PagesCombined;
|
|
ULONG Flags; // MEMORY_COMBINE_FLAGS_*
|
|
HANDLE ProcessHandle; // Requires MEMORY_COMBINE_FLAGS_COMBINE_WORKING_SET.
|
|
} MEMORY_COMBINE_INFORMATION_EX2, *PMEMORY_COMBINE_INFORMATION_EX2;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ENTROPY_TIMING_INFORMATION structure contains system entropy timing information.
|
|
*/
|
|
typedef struct _SYSTEM_ENTROPY_TIMING_INFORMATION
|
|
{
|
|
VOID (NTAPI *EntropyRoutine)(PVOID, ULONG);
|
|
VOID (NTAPI *InitializationRoutine)(PVOID, ULONG, PVOID);
|
|
PVOID InitializationContext;
|
|
} SYSTEM_ENTROPY_TIMING_INFORMATION, *PSYSTEM_ENTROPY_TIMING_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CONSOLE_INFORMATION structure contains system console information.
|
|
*/
|
|
typedef struct _SYSTEM_CONSOLE_INFORMATION
|
|
{
|
|
ULONG DriverLoaded : 1;
|
|
ULONG Spare : 31;
|
|
} SYSTEM_CONSOLE_INFORMATION, *PSYSTEM_CONSOLE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PLATFORM_BINARY_INFORMATION structure contains system platform binary information.
|
|
*/
|
|
typedef struct _SYSTEM_PLATFORM_BINARY_INFORMATION
|
|
{
|
|
ULONG64 PhysicalAddress;
|
|
PVOID HandoffBuffer;
|
|
PVOID CommandLineBuffer;
|
|
ULONG HandoffBufferSize;
|
|
ULONG CommandLineBufferSize;
|
|
} SYSTEM_PLATFORM_BINARY_INFORMATION, *PSYSTEM_PLATFORM_BINARY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_POLICY_INFORMATION structure contains system policy information.
|
|
*/
|
|
typedef struct _SYSTEM_POLICY_INFORMATION
|
|
{
|
|
PVOID InputData;
|
|
PVOID OutputData;
|
|
ULONG InputDataSize;
|
|
ULONG OutputDataSize;
|
|
ULONG Version;
|
|
} SYSTEM_POLICY_INFORMATION, *PSYSTEM_POLICY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_PROCESSOR_COUNT_INFORMATION structure contains system hypervisor processor count information.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_PROCESSOR_COUNT_INFORMATION
|
|
{
|
|
ULONG NumberOfLogicalProcessors;
|
|
ULONG NumberOfCores;
|
|
} SYSTEM_HYPERVISOR_PROCESSOR_COUNT_INFORMATION, *PSYSTEM_HYPERVISOR_PROCESSOR_COUNT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_DEVICE_DATA_INFORMATION structure contains system device data information.
|
|
*/
|
|
typedef struct _SYSTEM_DEVICE_DATA_INFORMATION
|
|
{
|
|
UNICODE_STRING DeviceId;
|
|
UNICODE_STRING DataName;
|
|
ULONG DataType;
|
|
ULONG DataBufferLength;
|
|
PVOID DataBuffer;
|
|
} SYSTEM_DEVICE_DATA_INFORMATION, *PSYSTEM_DEVICE_DATA_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The PHYSICAL_CHANNEL_RUN structure describes the physical channel run.
|
|
*/
|
|
typedef struct _PHYSICAL_CHANNEL_RUN
|
|
{
|
|
ULONG NodeNumber;
|
|
ULONG ChannelNumber;
|
|
ULONGLONG BasePage;
|
|
ULONGLONG PageCount;
|
|
ULONG Flags;
|
|
} PHYSICAL_CHANNEL_RUN, *PPHYSICAL_CHANNEL_RUN;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_TOPOLOGY_INFORMATION structure contains system memory topology information.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_TOPOLOGY_INFORMATION
|
|
{
|
|
ULONGLONG NumberOfRuns;
|
|
ULONG NumberOfNodes;
|
|
ULONG NumberOfChannels;
|
|
PHYSICAL_CHANNEL_RUN Run[1];
|
|
} SYSTEM_MEMORY_TOPOLOGY_INFORMATION, *PSYSTEM_MEMORY_TOPOLOGY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_CHANNEL_INFORMATION structure contains system memory channel information.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_CHANNEL_INFORMATION
|
|
{
|
|
ULONG ChannelNumber;
|
|
ULONG ChannelHeatIndex;
|
|
ULONGLONG TotalPageCount;
|
|
ULONGLONG ZeroPageCount;
|
|
ULONGLONG FreePageCount;
|
|
ULONGLONG StandbyPageCount;
|
|
} SYSTEM_MEMORY_CHANNEL_INFORMATION, *PSYSTEM_MEMORY_CHANNEL_INFORMATION;
|
|
|
|
// private
|
|
#define SYSTEM_BOOT_LOGO_FLAG_INTERNAL_0x800000 0x1 // Set when BgpFwQueryBootGraphicsInformation sees boot graphics state flag 0x800000.
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BOOT_LOGO_INFORMATION structure contains system boot logo information.
|
|
*/
|
|
typedef struct _SYSTEM_BOOT_LOGO_INFORMATION
|
|
{
|
|
ULONG Flags; // SYSTEM_BOOT_LOGO_FLAG_*
|
|
ULONG BitmapOffset; // Offset to the trailing boot logo bitmap data; currently 8 in the query path.
|
|
} SYSTEM_BOOT_LOGO_INFORMATION, *PSYSTEM_BOOT_LOGO_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX structure contains system processor performance information.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX
|
|
{
|
|
LARGE_INTEGER IdleTime;
|
|
LARGE_INTEGER KernelTime;
|
|
LARGE_INTEGER UserTime;
|
|
LARGE_INTEGER DpcTime;
|
|
LARGE_INTEGER InterruptTime;
|
|
ULONG InterruptCount;
|
|
ULONG Spare0;
|
|
//
|
|
// The amount of time that the processor has spent executing low priority (background) threads,
|
|
// in 100-nanosecond intervals. This is the remainder of the "% Priority Time" raw counter
|
|
// (counter set {b4fc721a-0378-476f-89ba-a5a79f810b36}, counter 15), whose raw value is exactly
|
|
// IdleTime + AvailableTime. That counter is a PERF_100NSEC_TIMER_INV, so:
|
|
//
|
|
// PercentPriorityTime = 100 * (1 - d(IdleTime + AvailableTime) / dElapsed100ns)
|
|
//
|
|
// giving the percentage of elapsed time spent executing threads that are not low priority.
|
|
//
|
|
LARGE_INTEGER AvailableTime;
|
|
LARGE_INTEGER Spare1;
|
|
LARGE_INTEGER Spare2;
|
|
} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX, *PSYSTEM_PROCESSOR_PERFORMANCE_INFORMATION_EX;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CRITICAL_PROCESS_EXCEPTION_INFORMATION structure contains system critical process exception information.
|
|
*/
|
|
typedef struct _SYSTEM_CRITICAL_PROCESS_EXCEPTION_INFORMATION // CRITICAL_PROCESS_EXCEPTION_DATA
|
|
{
|
|
GUID ReportId;
|
|
UNICODE_STRING ModuleName;
|
|
ULONG ModuleTimestamp;
|
|
ULONG ModuleSize;
|
|
ULONG_PTR Offset;
|
|
} SYSTEM_CRITICAL_PROCESS_EXCEPTION_INFORMATION, *PSYSTEM_CRITICAL_PROCESS_EXCEPTION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECUREBOOT_POLICY_INFORMATION structure contains system secureboot policy information.
|
|
*/
|
|
typedef struct _SYSTEM_SECUREBOOT_POLICY_INFORMATION
|
|
{
|
|
GUID PolicyPublisher;
|
|
ULONG PolicyVersion;
|
|
ULONG PolicyOptions;
|
|
} SYSTEM_SECUREBOOT_POLICY_INFORMATION, *PSYSTEM_SECUREBOOT_POLICY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PAGEFILE_INFORMATION_EX structure contains system pagefile information.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_PAGEFILE_INFORMATION_EX
|
|
{
|
|
union // union declaration for convenience (dmex)
|
|
{
|
|
SYSTEM_PAGEFILE_INFORMATION Info;
|
|
struct
|
|
{
|
|
ULONG NextEntryOffset;
|
|
ULONG TotalSize;
|
|
ULONG TotalInUse;
|
|
ULONG PeakUsage;
|
|
UNICODE_STRING PageFileName;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
ULONG MinimumSize;
|
|
ULONG MaximumSize;
|
|
} SYSTEM_PAGEFILE_INFORMATION_EX, *PSYSTEM_PAGEFILE_INFORMATION_EX;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECUREBOOT_INFORMATION structure indicates whether Secure Boot is enabled and capable.
|
|
*/
|
|
typedef struct _SYSTEM_SECUREBOOT_INFORMATION
|
|
{
|
|
BOOLEAN SecureBootEnabled;
|
|
BOOLEAN SecureBootCapable;
|
|
} SYSTEM_SECUREBOOT_INFORMATION, *PSYSTEM_SECUREBOOT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The PROCESS_DISK_COUNTERS structure contains the process disk counters.
|
|
*/
|
|
typedef struct _PROCESS_DISK_COUNTERS
|
|
{
|
|
ULONGLONG BytesRead;
|
|
ULONGLONG BytesWritten;
|
|
ULONGLONG ReadOperationCount;
|
|
ULONGLONG WriteOperationCount;
|
|
ULONGLONG FlushOperationCount;
|
|
} PROCESS_DISK_COUNTERS, *PPROCESS_DISK_COUNTERS;
|
|
|
|
// private
|
|
/**
|
|
* The ENERGY_STATE_DURATION union describes the energy state duration.
|
|
*/
|
|
typedef union _ENERGY_STATE_DURATION
|
|
{
|
|
ULONGLONG Value;
|
|
struct
|
|
{
|
|
ULONG LastChangeTime;
|
|
ULONG Duration : 31;
|
|
ULONG IsInState : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
} ENERGY_STATE_DURATION, *PENERGY_STATE_DURATION;
|
|
|
|
/**
|
|
* The PROCESS_ENERGY_VALUES_QOS_INDEX type represents the QoS (Quality of Service) /
|
|
* thread-context bucket used as the first index of the Cycles, AttributedCycles, and
|
|
* WorkOnBehalfCycles arrays in PROCESS_ENERGY_VALUES.
|
|
*/
|
|
typedef enum _PROCESS_ENERGY_VALUES_QOS_INDEX
|
|
{
|
|
// Foreground / High QoS — threads running at foreground or high quality-of-service priority.
|
|
ProcessEnergyValuesQoSHighForeground = 0,
|
|
// Above-normal — threads running at above-normal priority.
|
|
ProcessEnergyValuesQoSAboveNormal = 1,
|
|
// Normal — threads running at normal priority.
|
|
ProcessEnergyValuesQoSNormal = 2,
|
|
// Background / Low QoS — threads running at background or low quality-of-service priority.
|
|
ProcessEnergyValuesQoSLowBackground = 3,
|
|
// The maximum number of QoS buckets.
|
|
ProcessEnergyValuesQoSMax = 4
|
|
} PROCESS_ENERGY_VALUES_QOS_INDEX, *PPROCESS_ENERGY_VALUES_QOS_INDEX;
|
|
|
|
/**
|
|
* The PROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX type represents the cycle type (user vs. kernel)
|
|
* used as the second index of the Cycles, AttributedCycles, and WorkOnBehalfCycles.
|
|
*/
|
|
typedef enum _PROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX
|
|
{
|
|
// User-mode cycles accumulated by threads in this QoS bucket.
|
|
ProcessEnergyValuesCycleTypeUser = 0,
|
|
// Kernel-mode cycles accumulated by threads in this QoS bucket.
|
|
ProcessEnergyValuesCycleTypeKernel = 1,
|
|
// The maximum number of cycle types.
|
|
ProcessEnergyValuesCycleTypeMax = 2
|
|
} PROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX, *PPROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX;
|
|
|
|
/**
|
|
* \brief Energy accounting values for a process, broken down by QoS bucket and cycle type.
|
|
*
|
|
* \details Contains CPU cycle counts, energy estimates, network/MBB byte counts,
|
|
* activity durations, and DWM composition statistics accumulated for a process.
|
|
* CPU cycles are indexed by QoS bucket (see PROCESS_ENERGY_VALUES_QOS_INDEX) and
|
|
* cycle type (see PROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX).
|
|
*/
|
|
typedef struct _PROCESS_ENERGY_VALUES
|
|
{
|
|
/**
|
|
* CPU cycles accumulated per QoS bucket and cycle type.
|
|
* First index: QoS bucket (PROCESS_ENERGY_VALUES_QOS_INDEX).
|
|
* Second index: cycle type — user [0] or kernel [1] (PROCESS_ENERGY_VALUES_CYCLE_TYPE_INDEX).
|
|
*/
|
|
ULONGLONG Cycles[ProcessEnergyValuesQoSMax][ProcessEnergyValuesCycleTypeMax];
|
|
/**
|
|
* Energy consumed by disk I/O, in arbitrary energy units.
|
|
*/
|
|
ULONGLONG DiskEnergy;
|
|
/**
|
|
* Tail energy attributed to network activity.
|
|
*/
|
|
ULONGLONG NetworkTailEnergy;
|
|
/**
|
|
* Tail energy attributed to Mobile Broadband (MBB) activity.
|
|
*/
|
|
ULONGLONG MBBTailEnergy;
|
|
/**
|
|
* Total bytes transmitted and received over network interfaces.
|
|
*/
|
|
ULONGLONG NetworkTxRxBytes;
|
|
/**
|
|
* Total bytes transmitted and received over Mobile Broadband (MBB) interfaces.
|
|
*/
|
|
ULONGLONG MBBTxRxBytes;
|
|
union
|
|
{
|
|
/**
|
|
* Activity state durations: [0] foreground, [1] desktop visible, [2] PSM foreground.
|
|
*/
|
|
ENERGY_STATE_DURATION Durations[3];
|
|
struct
|
|
{
|
|
/**
|
|
* Duration the process was in the foreground.
|
|
*/
|
|
ENERGY_STATE_DURATION ForegroundDuration;
|
|
/**
|
|
* Duration the process was visible on the desktop.
|
|
*/
|
|
ENERGY_STATE_DURATION DesktopVisibleDuration;
|
|
/**
|
|
* Duration the process was in the PSM (Process State Manager) foreground state.
|
|
*/
|
|
ENERGY_STATE_DURATION PSMForegroundDuration;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
/**
|
|
* Number of frames rendered by the DWM compositor on behalf of this process.
|
|
*/
|
|
ULONG CompositionRendered;
|
|
/**
|
|
* Number of dirty regions generated by this process during DWM composition.
|
|
*/
|
|
ULONG CompositionDirtyGenerated;
|
|
/**
|
|
* Number of dirty regions propagated from this process to other windows during DWM composition.
|
|
*/
|
|
ULONG CompositionDirtyPropagated;
|
|
ULONG Reserved1;
|
|
/**
|
|
* CPU cycles attributed to this process (e.g. from work performed on its behalf).
|
|
* Indexed identically to Cycles: [QoS bucket][cycle type].
|
|
*/
|
|
ULONGLONG AttributedCycles[ProcessEnergyValuesQoSMax][ProcessEnergyValuesCycleTypeMax];
|
|
/**
|
|
* CPU cycles consumed while performing work on behalf of another process.
|
|
* Indexed identically to Cycles: [QoS bucket][cycle type].
|
|
*/
|
|
ULONGLONG WorkOnBehalfCycles[ProcessEnergyValuesQoSMax][ProcessEnergyValuesCycleTypeMax];
|
|
} PROCESS_ENERGY_VALUES, *PPROCESS_ENERGY_VALUES;
|
|
|
|
/**
|
|
* \brief A compact activity timeline encoded as a bitmap with an end-time anchor.
|
|
*
|
|
* \details Each bit in the Bitmap field represents a fixed-size time slot.
|
|
* A set bit indicates the process was active during that slot.
|
|
* Each slot is 4096 milliseconds (~4.1 seconds) in duration.
|
|
* The 32-bit bitmap covers approximately 131 seconds of recent history.
|
|
* EndTime is a slot index (not wall-clock seconds); multiply by 4096 to get elapsed milliseconds.
|
|
*
|
|
* Timeline bitmap calculations:
|
|
* - To compute active duration from a bitmap: popcount(Bitmap) * 4096 milliseconds
|
|
* - To convert EndTime to elapsed time: EndTime * 4096 milliseconds
|
|
* - Total bitmap window: 32 slots * 4096 ms = 131,072 ms ~ 131 seconds
|
|
*
|
|
* The slot index comes from kernel timer accounting:
|
|
* KiTimelineBitmapTime = elapsed_ms >> 12,
|
|
* where elapsed_ms is the time since boot in milliseconds
|
|
* (from KUSER_SHARED_DATA.TickCountQuad).
|
|
*/
|
|
typedef union _TIMELINE_BITMAP
|
|
{
|
|
/** Raw 64-bit value combining EndTime and Bitmap. */
|
|
ULONGLONG Value;
|
|
struct
|
|
{
|
|
/**
|
|
* The slot index of the most recent time slot represented by the bitmap.
|
|
* Real time ~ EndTime * 4096 milliseconds.
|
|
*/
|
|
ULONG EndTime;
|
|
/**
|
|
* Bit-mask of activity slots; bit 0 is the most recent slot.
|
|
* One set bit represents approximately 4.096 seconds of activity.
|
|
* popcount(Bitmap) * 4096 ms ~ total active duration within window.
|
|
*/
|
|
ULONG Bitmap;
|
|
} DUMMYSTRUCTNAME;
|
|
} TIMELINE_BITMAP, *PTIMELINE_BITMAP;
|
|
|
|
/**
|
|
* \brief Extended energy accounting values for a process, providing activity timelines
|
|
* and additional duration/input statistics not present in PROCESS_ENERGY_VALUES.
|
|
*
|
|
* \details Added in REDSTONE2; the Timelines array grew from 9 to 14 entries in REDSTONE3.
|
|
* The Durations union and the input/audio fields are REDSTONE3+.
|
|
*/
|
|
typedef struct _PROCESS_ENERGY_VALUES_EXTENSION
|
|
{
|
|
union
|
|
{
|
|
/** Activity timelines indexed by resource type (9 entries pre-RS3, 14 entries RS3+). */
|
|
TIMELINE_BITMAP Timelines[14]; // 9 for REDSTONE2, 14 for REDSTONE3/4/5
|
|
struct
|
|
{
|
|
/**
|
|
* CPU activity timeline.
|
|
*/
|
|
TIMELINE_BITMAP CpuTimeline;
|
|
/**
|
|
* Disk I/O activity timeline.
|
|
*/
|
|
TIMELINE_BITMAP DiskTimeline;
|
|
/**
|
|
* Network activity timeline.
|
|
*/
|
|
TIMELINE_BITMAP NetworkTimeline;
|
|
/**
|
|
* Mobile Broadband (MBB) activity timeline.
|
|
*/
|
|
TIMELINE_BITMAP MBBTimeline;
|
|
/**
|
|
* Foreground visibility timeline.
|
|
*/
|
|
TIMELINE_BITMAP ForegroundTimeline;
|
|
/**
|
|
* Desktop visible timeline.
|
|
*/
|
|
TIMELINE_BITMAP DesktopVisibleTimeline;
|
|
/**
|
|
* DWM composition rendered timeline.
|
|
*/
|
|
TIMELINE_BITMAP CompositionRenderedTimeline;
|
|
/**
|
|
* DWM composition dirty-generated timeline.
|
|
*/
|
|
TIMELINE_BITMAP CompositionDirtyGeneratedTimeline;
|
|
/**
|
|
* DWM composition dirty-propagated timeline.
|
|
*/
|
|
TIMELINE_BITMAP CompositionDirtyPropagatedTimeline;
|
|
/**
|
|
* Input activity timeline (REDSTONE3+).
|
|
*/
|
|
TIMELINE_BITMAP InputTimeline; // REDSTONE3
|
|
/**
|
|
* Audio input (microphone) activity timeline (REDSTONE3+).
|
|
*/
|
|
TIMELINE_BITMAP AudioInTimeline;
|
|
/**
|
|
* Audio output (speaker/headphone) activity timeline (REDSTONE3+).
|
|
*/
|
|
TIMELINE_BITMAP AudioOutTimeline;
|
|
/**
|
|
* Display-required (screen-on prevention) timeline (REDSTONE3+).
|
|
*/
|
|
TIMELINE_BITMAP DisplayRequiredTimeline;
|
|
/**
|
|
* Keyboard input activity timeline (REDSTONE3+).
|
|
*/
|
|
TIMELINE_BITMAP KeyboardInputTimeline;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
union // REDSTONE3
|
|
{
|
|
/**
|
|
* Activity state durations for extended resource types (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION Durations[5];
|
|
struct
|
|
{
|
|
/**
|
|
* Duration the process received user input (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION InputDuration;
|
|
/**
|
|
* Duration the process used audio input (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION AudioInDuration;
|
|
/**
|
|
* Duration the process used audio output (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION AudioOutDuration;
|
|
/**
|
|
* Duration the process prevented display power-off (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION DisplayRequiredDuration;
|
|
/**
|
|
* Duration the process ran in PSM background state (REDSTONE3+).
|
|
*/
|
|
ENERGY_STATE_DURATION PSMBackgroundDuration;
|
|
} DUMMYSTRUCTNAME2;
|
|
} DUMMYUNIONNAME2;
|
|
|
|
/**
|
|
* Number of keyboard input events attributed to the process (REDSTONE3+).
|
|
*/
|
|
ULONG KeyboardInput;
|
|
/**
|
|
* Number of mouse input events attributed to the process (REDSTONE3+).
|
|
*/
|
|
ULONG MouseInput;
|
|
} PROCESS_ENERGY_VALUES_EXTENSION, *PPROCESS_ENERGY_VALUES_EXTENSION;
|
|
|
|
/**
|
|
* The PROCESS_EXTENDED_ENERGY_VALUES structure describes the process extended energy values.
|
|
*/
|
|
typedef struct _PROCESS_EXTENDED_ENERGY_VALUES
|
|
{
|
|
PROCESS_ENERGY_VALUES Base;
|
|
PROCESS_ENERGY_VALUES_EXTENSION Extension;
|
|
} PROCESS_EXTENDED_ENERGY_VALUES, *PPROCESS_EXTENDED_ENERGY_VALUES;
|
|
|
|
/**
|
|
* The PROCESS_EXTENDED_ENERGY_VALUES_V1 structure describes the process extended energy values V1.
|
|
*/
|
|
typedef struct _PROCESS_EXTENDED_ENERGY_VALUES_V1
|
|
{
|
|
PROCESS_ENERGY_VALUES Base;
|
|
PROCESS_ENERGY_VALUES_EXTENSION Extension;
|
|
ULONG64 NpuWorkUnits;
|
|
} PROCESS_EXTENDED_ENERGY_VALUES_V1, *PPROCESS_EXTENDED_ENERGY_VALUES_V1;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESS_CLASSIFICATION enumeration defines the system process classification values.
|
|
*/
|
|
typedef enum _SYSTEM_PROCESS_CLASSIFICATION
|
|
{
|
|
SystemProcessClassificationNormal,
|
|
SystemProcessClassificationSystem,
|
|
SystemProcessClassificationSecureSystem,
|
|
SystemProcessClassificationMemCompression,
|
|
SystemProcessClassificationRegistry, // REDSTONE4
|
|
SystemProcessClassificationMaximum
|
|
} SYSTEM_PROCESS_CLASSIFICATION;
|
|
|
|
/**
|
|
* Extended process information appended to SYSTEM_PROCESS_INFORMATION in full process enumeration queries.
|
|
*
|
|
* \details This structure provides additional process accounting, classification, and energy metrics
|
|
* not present in the base SYSTEM_PROCESS_INFORMATION structure. It is returned when querying
|
|
* SystemFullProcessInformation (information class 148) or SystemExtendedProcessInformation (information class 57)
|
|
* via NtQuerySystemInformation.
|
|
*
|
|
* The structure is appended immediately after the SYSTEM_THREAD_INFORMATION array in
|
|
* SYSTEM_EXTENDED_PROCESS_INFORMATION, and the offsets are relative to the start of this extension structure.
|
|
*
|
|
* \since Windows 10 Threshold (version 1507, build 10240)
|
|
* \remarks This structure contains variable-length data. The UserSidOffset, PackageFullNameOffset,
|
|
* and AppIdOffset fields point to data stored immediately after this structure in memory.
|
|
* Callers must use these offsets to locate the actual strings and SID data.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESS_INFORMATION_EXTENSION
|
|
{
|
|
/**
|
|
* Cumulative disk I/O counters for the process (reads, writes, flushes).
|
|
* Includes total bytes transferred and operation counts for read, write, and flush operations.
|
|
*/
|
|
PROCESS_DISK_COUNTERS DiskCounters;
|
|
|
|
/**
|
|
* Total number of context switches performed by all threads in the process since creation.
|
|
* Use this to measure scheduling overhead and CPU time-sharing behavior.
|
|
*/
|
|
ULONGLONG ContextSwitches;
|
|
|
|
/**
|
|
* Process classification flags and security attributes.
|
|
*/
|
|
union
|
|
{
|
|
/**
|
|
* Raw flags value containing all classification bits.
|
|
*/
|
|
ULONG Flags;
|
|
|
|
struct
|
|
{
|
|
/**
|
|
* If set, the process has a strong identity (e.g., packaged app with cryptographic signing).
|
|
* Strong identities are used for security policy enforcement and resource isolation.
|
|
*/
|
|
ULONG HasStrongId : 1;
|
|
|
|
/**
|
|
* Process classification type (SYSTEM_PROCESS_CLASSIFICATION).
|
|
* Indicates whether this is a normal user process, system process, secure system process,
|
|
* memory compression process, or registry process. Used by the kernel for resource
|
|
* management, security policy, and scheduling decisions.
|
|
*/
|
|
ULONG Classification : 4; // SYSTEM_PROCESS_CLASSIFICATION
|
|
|
|
/**
|
|
* If set, the process has had background activity moderation applied to it.
|
|
* The system may throttle CPU, I/O, or network resources when the process is not in the foreground.
|
|
* \since Windows 10 Redstone 2 (version 1703)
|
|
*/
|
|
ULONG BackgroundActivityModerated : 1;
|
|
|
|
/**
|
|
* Reserved for future use.
|
|
*/
|
|
ULONG Spare : 26;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
/**
|
|
* Offset, in bytes, from the start of this structure to the user SID (Security Identifier).
|
|
* If zero, no user SID is available. The SID data is stored in standard binary format.
|
|
* Use this offset to locate the process owner's security identifier for access control
|
|
* and auditing purposes.
|
|
*/
|
|
ULONG UserSidOffset;
|
|
|
|
/**
|
|
* Offset, in bytes, from the start of this structure to a null-terminated WCHAR string
|
|
* containing the full package name (e.g., "Contoso.App_1.0.0.0_x64__8wekyb3d8bbwe").
|
|
* If zero, the process is not packaged (classic Win32 application).
|
|
* \since Windows 10 Threshold (version 1507)
|
|
*/
|
|
ULONG PackageFullNameOffset; // since THRESHOLD
|
|
|
|
/**
|
|
* Detailed energy accounting values for the process, including CPU cycles, disk energy,
|
|
* network/MBB tail energy, DWM composition metrics, and activity state durations.
|
|
* Provides per-QoS-bucket breakdowns of energy consumption for foreground/background
|
|
* resource usage analysis.
|
|
* \since Windows 10 Threshold (version 1507)
|
|
*/
|
|
PROCESS_ENERGY_VALUES EnergyValues; // since THRESHOLD
|
|
|
|
/**
|
|
* Offset, in bytes, from the start of this structure to a null-terminated WCHAR string
|
|
* containing the Application User Model ID (AUMID) for packaged applications.
|
|
* If zero, the process does not have an AppId (either not packaged or not a UWP app).
|
|
* \since Windows 10 Threshold (version 1507)
|
|
*/
|
|
ULONG AppIdOffset; // since THRESHOLD
|
|
|
|
/**
|
|
* Number of bytes of committed memory shared between this process and other processes
|
|
* (e.g., memory-mapped sections, shared DLLs, or copy-on-write pages).
|
|
* Use this to measure memory overhead due to sharing and to calculate true private bytes.
|
|
* SharedCommitCharge + PrivatePageCount gives a more accurate picture of process memory usage.
|
|
* \since Windows 10 Threshold 2 (version 1511)
|
|
*/
|
|
SIZE_T SharedCommitCharge; // since THRESHOLD2
|
|
|
|
/**
|
|
* Identifier of the job object to which the process belongs, if any.
|
|
* If zero, the process is not assigned to a job object. Job objects are used to group
|
|
* processes and apply resource limits, accounting, and management policies.
|
|
* \since Windows 10 Redstone (version 1607)
|
|
*/
|
|
ULONG JobObjectId; // since REDSTONE
|
|
|
|
/**
|
|
* Reserved for future use.
|
|
* \since Windows 10 Redstone (version 1607)
|
|
*/
|
|
ULONG SpareUlong; // since REDSTONE
|
|
|
|
/**
|
|
* Unique monotonically-increasing sequence number assigned when the process was created.
|
|
* Unlike ProcessId (which can be recycled), this value is never reused and provides
|
|
* a stable identifier for correlation across logs and telemetry even after process termination.
|
|
* \since Windows 10 Redstone (version 1607)
|
|
*/
|
|
ULONGLONG ProcessSequenceNumber;
|
|
} SYSTEM_PROCESS_INFORMATION_EXTENSION, *PSYSTEM_PROCESS_INFORMATION_EXTENSION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PORTABLE_WORKSPACE_EFI_LAUNCHER_INFORMATION structure contains system portable workspace EFI launcher information.
|
|
*/
|
|
typedef struct _SYSTEM_PORTABLE_WORKSPACE_EFI_LAUNCHER_INFORMATION
|
|
{
|
|
BOOLEAN EfiLauncherEnabled;
|
|
} SYSTEM_PORTABLE_WORKSPACE_EFI_LAUNCHER_INFORMATION, *PSYSTEM_PORTABLE_WORKSPACE_EFI_LAUNCHER_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX structure contains system kernel debugger information.
|
|
*/
|
|
typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX
|
|
{
|
|
BOOLEAN DebuggerAllowed;
|
|
BOOLEAN DebuggerEnabled;
|
|
BOOLEAN DebuggerPresent;
|
|
} SYSTEM_KERNEL_DEBUGGER_INFORMATION_EX, *PSYSTEM_KERNEL_DEBUGGER_INFORMATION_EX;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_BOOT_METADATA_INFORMATION structure contains system boot metadata information.
|
|
*/
|
|
typedef struct _SYSTEM_BOOT_METADATA_INFORMATION
|
|
{
|
|
ULONG Size;
|
|
UCHAR Data[1];
|
|
} SYSTEM_BOOT_METADATA_INFORMATION, *PSYSTEM_BOOT_METADATA_INFORMATION;
|
|
|
|
// rev
|
|
#define SYSTEM_SOFT_REBOOT_FLAGS_STATE_MASK 0x000000BBu // State-selection bits consumed by ExpSetSoftRebootFlags.
|
|
#define SYSTEM_SOFT_REBOOT_FLAGS_OPTION_MASK 0x25000000u // User-settable option bits accepted by ExpSetSoftRebootFlags.
|
|
#define SYSTEM_SOFT_REBOOT_FLAGS_USER_MASK 0x250000BBu // Accepted user input mask.
|
|
#define SYSTEM_SOFT_REBOOT_FLAGS_INTERNAL_PERSIST 0x40000000u // Kernel-managed bit preserved across transitions.
|
|
#define SYSTEM_SOFT_REBOOT_FLAGS_INTERNAL_TRANSITION 0x80000000u // Kernel-managed transition-in-progress bit.
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_SOFT_REBOOT_INFORMATION structure contains system soft reboot information.
|
|
*/
|
|
typedef struct _SYSTEM_SOFT_REBOOT_INFORMATION
|
|
{
|
|
ULONG Flags; // SYSTEM_SOFT_REBOOT_FLAGS_*
|
|
} SYSTEM_SOFT_REBOOT_INFORMATION, *PSYSTEM_SOFT_REBOOT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ELAM_CERTIFICATE_INFORMATION structure contains system ELAM certificate information.
|
|
*/
|
|
typedef struct _SYSTEM_ELAM_CERTIFICATE_INFORMATION
|
|
{
|
|
HANDLE ElamDriverFile;
|
|
} SYSTEM_ELAM_CERTIFICATE_INFORMATION, *PSYSTEM_ELAM_CERTIFICATE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V2 structure describes the offline crashdump configuration table V2.
|
|
*/
|
|
typedef struct _OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V2
|
|
{
|
|
ULONG Version;
|
|
ULONG AbnormalResetOccurred;
|
|
ULONG OfflineMemoryDumpCapable;
|
|
PVOID ResetDataAddress;
|
|
ULONG ResetDataSize;
|
|
} OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V2, *POFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V2;
|
|
|
|
// private
|
|
/**
|
|
* The OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V1 structure describes the offline crashdump configuration table V1.
|
|
*/
|
|
typedef struct _OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V1
|
|
{
|
|
ULONG Version;
|
|
ULONG AbnormalResetOccurred;
|
|
ULONG OfflineMemoryDumpCapable;
|
|
} OFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V1, *POFFLINE_CRASHDUMP_CONFIGURATION_TABLE_V1;
|
|
|
|
// SYSTEM_PROCESSOR_FEATURES_INFORMATION // ProcessorFeatureBits
|
|
// Processor feature bits (31 flags spanning bits 0-55 with documented gaps at bits 18-22)
|
|
// These flags indicate CPU capabilities detected by the kernel via CPUID and other detection mechanisms.
|
|
// Allocated bit ranges:
|
|
// Bits 0-17 : Base CPU features (MMX, SSE, branch prediction, etc.) - 18 flags
|
|
// Bits 18-22 : Reserved/unused (5 bit gap)
|
|
// Bits 23-31 : Extended states and additional features (1 flag)
|
|
// Bits 32-34 : Advanced features (RDRAND, SMAP, RDTSCP) - 3 flags
|
|
// Bits 35-44 : Reserved/unused (10 bit gap)
|
|
// Bits 45-46 : Huge pages and extended saves - 2 flags
|
|
// Bits 47-51 : Reserved/unused (5 bit gap)
|
|
// Bits 52-58 : Security and extended features (FPU_LEAKAGE, CAT, CET_SS, SSSE3, SSE4.x) - 7 flags
|
|
// Bits 59-62 : Reserved/unused (4 bit gap)
|
|
// Bit 63 : XFD (extended FPU data) - 1 flag
|
|
#define KF64_SMEP 0x0000000000000001ULL // Supervisor Mode Execution Protection
|
|
#define KF64_RDTSC 0x0000000000000002ULL // Read Time-Stamp Counter
|
|
#define KF64_CR4 0x0000000000000004ULL // CR4 Register Features
|
|
#define KF64_CMOV 0x0000000000000008ULL // Conditional Move Instructions
|
|
#define KF64_GLOBAL_PAGE 0x0000000000000010ULL // Global Pages Support
|
|
#define KF64_LARGE_PAGE 0x0000000000000020ULL // Large Page Support
|
|
#define KF64_MTRR 0x0000000000000040ULL // Memory Type Range Registers
|
|
#define KF64_CMPXCHG8B 0x0000000000000080ULL // CMPXCHG8B Instruction
|
|
#define KF64_MMX 0x0000000000000100ULL // MMX Instructions
|
|
#define KF64_DTS 0x0000000000000200ULL // Debug Store
|
|
#define KF64_PAT 0x0000000000000400ULL // Page Attribute Table
|
|
#define KF64_FXSR 0x0000000000000800ULL // FXSAVE and FXRSTOR Instructions
|
|
#define KF64_FAST_SYSCALL 0x0000000000001000ULL // Fast System Call
|
|
#define KF64_XMMI 0x0000000000002000ULL // Streaming SIMD Extensions
|
|
#define KF64_3DNOW 0x0000000000004000ULL // 3DNow! Instructions
|
|
#define KF64_AMDK6MTRR 0x0000000000008000ULL // AMD K6 Memory Type Range Registers
|
|
#define KF64_XMMI64 0x0000000000010000ULL // Streaming SIMD Extensions 2
|
|
#define KF64_BRANCH 0x0000000000020000ULL // Branch Prediction
|
|
#define KF64_XSTATE 0x0000000000800000ULL // Extended States
|
|
#define KF64_RDRAND 0x0000000100000000ULL // RDRAND Instruction
|
|
#define KF64_SMAP 0x0000000200000000ULL // Supervisor Mode Access Prevention
|
|
#define KF64_RDTSCP 0x0000000400000000ULL // RDTSCP Instruction
|
|
#define KF64_HUGEPAGE 0x0000002000000000ULL // Huge Page Support
|
|
#define KF64_XSAVES 0x0000004000000000ULL // XSAVES and XRSTORS Instructions
|
|
#define KF64_FPU_LEAKAGE 0x0000020000000000ULL // FPU Data Leakage Mitigations
|
|
#define KF64_CAT 0x0000100000000000ULL // Cache Allocation Technology
|
|
#define KF64_CET_SS 0x0000400000000000ULL // Control-flow Enforcement Technology - Shadow Stack
|
|
#define KF64_SSSE3 0x0000800000000000ULL // Supplemental Streaming SIMD Extensions 3
|
|
#define KF64_SSE4_1 0x0001000000000000ULL // Streaming SIMD Extensions 4.1
|
|
#define KF64_SSE4_2 0x0002000000000000ULL // Streaming SIMD Extensions 4.2
|
|
#define KF64_XFD 0x0080000000000000ULL // eXtended FPU Data
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_PROCESSOR_FEATURES_INFORMATION structure contains system processor features information.
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_FEATURES_INFORMATION
|
|
{
|
|
ULONGLONG ProcessorFeatureBits;
|
|
ULONGLONG Reserved[3];
|
|
} SYSTEM_PROCESSOR_FEATURES_INFORMATION, *PSYSTEM_PROCESSOR_FEATURES_INFORMATION;
|
|
|
|
// EDID v1.4 detailed timing descriptor (18 bytes)
|
|
/**
|
|
* The SYSTEM_EDID_DETAILED_TIMING_DESCRIPTOR structure describes the system EDID detailed timing descriptor.
|
|
*/
|
|
typedef struct _SYSTEM_EDID_DETAILED_TIMING_DESCRIPTOR
|
|
{
|
|
USHORT PixelClock; // Pixel clock in 10 kHz units
|
|
UCHAR HorizontalActiveLo; // Horizontal active pixels (low 8 bits)
|
|
UCHAR HorizontalBlankLo; // Horizontal blanking pixels (low 8 bits)
|
|
UCHAR HorizontalActiveBlankHi; // High bits for horizontal active/blanking
|
|
UCHAR VerticalActiveLo; // Vertical active lines (low 8 bits)
|
|
UCHAR VerticalBlankLo; // Vertical blanking lines (low 8 bits)
|
|
UCHAR VerticalActiveBlankHi; // High bits for vertical active/blanking
|
|
UCHAR HorizontalSyncOffsetLo;// Horizontal sync offset (low 8 bits)
|
|
UCHAR HorizontalSyncPulseWidthLo; // Horizontal sync pulse width (low 8 bits)
|
|
UCHAR VerticalSyncOffsetPulseWidthLo; // Vertical sync offset/pulse width (low 4 bits each)
|
|
UCHAR SyncOffsetPulseWidthHi; // High bits for sync offset/pulse width
|
|
UCHAR HorizontalImageSizeLo; // Horizontal image size in mm (low 8 bits)
|
|
UCHAR VerticalImageSizeLo; // Vertical image size in mm (low 8 bits)
|
|
UCHAR ImageSizeHi; // High bits for image size
|
|
UCHAR HorizontalBorder; // Horizontal border in pixels
|
|
UCHAR VerticalBorder; // Vertical border in lines
|
|
UCHAR Flags; // Flags (interlaced, stereo, sync, etc.)
|
|
} SYSTEM_EDID_DETAILED_TIMING_DESCRIPTOR, *PSYSTEM_EDID_DETAILED_TIMING_DESCRIPTOR;
|
|
|
|
// EDID v1.4 standard data format
|
|
/**
|
|
* The SYSTEM_EDID_INFORMATION structure contains system EDID information.
|
|
*/
|
|
typedef struct _SYSTEM_EDID_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
UCHAR Edid[128];
|
|
struct
|
|
{
|
|
UCHAR Header[8]; // 00h: EDID header (00 FF FF FF FF FF FF 00)
|
|
UCHAR ManufacturerId[2]; // 08h: Manufacturer ID (big endian)
|
|
UCHAR ProductCode[2]; // 0Ah: Product code (little endian)
|
|
UCHAR SerialNumber[4]; // 0Ch: Serial number
|
|
UCHAR WeekOfManufacture; // 10h: Week of manufacture
|
|
UCHAR YearOfManufacture; // 11h: Year of manufacture (offset from 1990)
|
|
UCHAR EdidVersion; // 12h: EDID version (should be 1)
|
|
UCHAR EdidRevision; // 13h: EDID revision (should be 4)
|
|
UCHAR VideoInputDefinition; // 14h: Video input parameters
|
|
UCHAR MaxHorizontalImageSize; // 15h: Max horizontal image size (cm)
|
|
UCHAR MaxVerticalImageSize; // 16h: Max vertical image size (cm)
|
|
UCHAR DisplayGamma; // 17h: Display gamma (gamma*100 - 100)
|
|
UCHAR FeatureSupport; // 18h: DPMS features, color encoding, etc.
|
|
UCHAR Chromaticity[10]; // 19h: Chromaticity coordinates
|
|
UCHAR EstablishedTimings[3]; // 23h: Established timings
|
|
UCHAR StandardTimings[16]; // 26h: Standard timings (8x2 bytes)
|
|
SYSTEM_EDID_DETAILED_TIMING_DESCRIPTOR DetailedTiming[4]; // 36h: 4 detailed timing descriptors (18 bytes each)
|
|
UCHAR ExtensionFlag; // 7Eh: Number of (optional) 128-byte extension blocks
|
|
UCHAR Checksum; // 7Fh: Checksum (sum of all 128 bytes = 0)
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_EDID_INFORMATION, *PSYSTEM_EDID_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MANUFACTURING_INFORMATION structure contains system manufacturing information.
|
|
*/
|
|
typedef struct _SYSTEM_MANUFACTURING_INFORMATION
|
|
{
|
|
ULONG Options;
|
|
UNICODE_STRING ProfileName;
|
|
} SYSTEM_MANUFACTURING_INFORMATION, *PSYSTEM_MANUFACTURING_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION structure contains the system energy estimation configuration.
|
|
*/
|
|
typedef struct _SYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION
|
|
{
|
|
BOOLEAN Enabled;
|
|
} SYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION, *PSYSTEM_ENERGY_ESTIMATION_CONFIG_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The HV_DETAILS structure describes the HV details.
|
|
*/
|
|
typedef struct _HV_DETAILS
|
|
{
|
|
ULONG Data[4];
|
|
} HV_DETAILS, *PHV_DETAILS;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_DETAIL_INFORMATION structure contains system hypervisor detail information.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_DETAIL_INFORMATION
|
|
{
|
|
HV_DETAILS HvVendorAndMaxFunction;
|
|
HV_DETAILS HypervisorInterface;
|
|
HV_DETAILS HypervisorVersion;
|
|
HV_DETAILS HvFeatures;
|
|
HV_DETAILS HwFeatures;
|
|
HV_DETAILS EnlightenmentInfo;
|
|
HV_DETAILS ImplementationLimits;
|
|
} SYSTEM_HYPERVISOR_DETAIL_INFORMATION, *PSYSTEM_HYPERVISOR_DETAIL_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_CYCLE_STATS_BUCKET_INDEX type represents a frequency bucket
|
|
* for processor cycle statistics, selected by PoGetFrequencyBucket based on the current
|
|
* processor frequency relative to thresholds in _KPRCB.PowerState.FrequencyBucketThresholds.
|
|
*/
|
|
typedef enum _SYSTEM_PROCESSOR_CYCLE_STATS_BUCKET_INDEX
|
|
{
|
|
// Lowest frequency bucket — processor running at or below the first frequency threshold.
|
|
SystemProcessorCycleStatsBucketLowestFrequency = 0,
|
|
// Low frequency bucket — processor running between the first and second frequency thresholds.
|
|
SystemProcessorCycleStatsBucketLowFrequency = 1,
|
|
// High frequency bucket — processor running between the second and third frequency thresholds.
|
|
SystemProcessorCycleStatsBucketHighFrequency = 2,
|
|
// Highest frequency bucket — processor running above the third frequency threshold.
|
|
SystemProcessorCycleStatsBucketHighestFrequency = 3,
|
|
// The maximum number of frequency buckets.
|
|
SystemProcessorCycleStatsBucketMax = 4
|
|
} SYSTEM_PROCESSOR_CYCLE_STATS_BUCKET_INDEX, *PSYSTEM_PROCESSOR_CYCLE_STATS_BUCKET_INDEX;
|
|
|
|
/**
|
|
* The SYSTEM_PROCESSOR_CYCLE_STATS_EFFICIENCY_CLASS_INDEX type represents the baseline architectural-efficiency group.
|
|
*
|
|
* \note In current kernel accounting this is effectively binary grouping (0/1), not an open-ended N-class index.
|
|
* So think of it as Group A vs Group B for heterogeneity tracking.
|
|
* It is not guaranteed to mean exactly “P-core vs E-core” on every platform, even though that may often correlate.
|
|
*/
|
|
typedef enum _SYSTEM_PROCESSOR_CYCLE_STATS_EFFICIENCY_CLASS_INDEX
|
|
{
|
|
// Represents the baseline architectural-efficiency group (the group with the minimum class value in current kernel logic)
|
|
// Baseline efficiency-class group (minimum architectural efficiency class).
|
|
SystemProcessorCycleStatsEfficiencyClassPrimary = 0,
|
|
// Represents processors not in that baseline group (all non-min class values are folded into this second bucket)
|
|
// Non-baseline efficiency-class group (all other architectural efficiency classes).
|
|
SystemProcessorCycleStatsEfficiencyClassSecondary = 1,
|
|
// The current maximum number of architectural-efficiency classes (subject to change).
|
|
SystemProcessorCycleStatsEfficiencyClassMax = 2
|
|
} SYSTEM_PROCESSOR_CYCLE_STATS_EFFICIENCY_CLASS_INDEX, *PSYSTEM_PROCESSOR_CYCLE_STATS_EFFICIENCY_CLASS_INDEX;
|
|
|
|
// private
|
|
//
|
|
// Query notes:
|
|
//
|
|
// This class is only serviced by NtQuerySystemInformationEx. The plain NtQuerySystemInformation
|
|
// form fails with STATUS_INVALID_PARAMETER at every buffer size. The input buffer is a
|
|
// USHORT ProcessorGroup.
|
|
//
|
|
// The output is a bare array of one structure per active processor in the group, with no header and
|
|
// no offset table. An undersized buffer fails with either STATUS_INFO_LENGTH_MISMATCH or
|
|
// STATUS_BUFFER_TOO_SMALL depending on how short it is, so a retry loop must accept both. Both set
|
|
// ReturnLength to the required size.
|
|
//
|
|
// The cycle counts are attributed to a coarse frequency band and efficiency class for heterogeneous
|
|
// scheduler telemetry. They are not a continuous unhalted cycle counter and carry no delivered
|
|
// frequency resolution, so they cannot be used to compute processor utility or performance; use
|
|
// SystemProcessorPerformanceDistribution for that. On a homogeneous processor every cycle lands in
|
|
// Cycles[SystemProcessorCycleStatsBucketHighestFrequency][SystemProcessorCycleStatsEfficiencyClassPrimary]
|
|
// and the remaining cells stay zero.
|
|
//
|
|
/**
|
|
* The SYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION structure contains per-processor cycle counts bucketed by frequency band and architectural efficiency class for heterogeneous scheduler telemetry (SystemProcessorCycleStatsInformation, queried via NtQuerySystemInformationEx).
|
|
*/
|
|
typedef struct _SYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION
|
|
{
|
|
//
|
|
// First index is bucket (see: PoGetFrequencyBucket) selected based on latest frequency percent
|
|
// using _KPRCB.PowerState.FrequencyBucketThresholds.
|
|
//
|
|
// Second index is _KPRCB.PowerState.ArchitecturalEfficiencyClass, accounting for architecture
|
|
// dependent KeHeteroSystem and using _KPRCB.PowerState.EarlyBootArchitecturalEfficiencyClass
|
|
// instead, when appropriate.
|
|
//
|
|
ULONGLONG Cycles[SystemProcessorCycleStatsBucketMax][SystemProcessorCycleStatsEfficiencyClassMax];
|
|
} SYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION, *PSYSTEM_PROCESSOR_CYCLE_STATS_INFORMATION;
|
|
|
|
// private
|
|
#define SYSTEM_TPM_FLAG_BOOT_DRIVER_LOADED 0x1 // SepOsLoaderTpmDriverLoaded
|
|
#define SYSTEM_TPM_FLAG_READY 0x2 // PnpCoreDriverGroupLoadPhase > 2
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_TPM_INFORMATION structure contains system TPM information.
|
|
*/
|
|
typedef struct _SYSTEM_TPM_INFORMATION
|
|
{
|
|
ULONG Flags; // SYSTEM_TPM_FLAG_*
|
|
} SYSTEM_TPM_INFORMATION, *PSYSTEM_TPM_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_VSM_PROTECTION_INFORMATION structure contains system VSM protection information.
|
|
*/
|
|
typedef struct _SYSTEM_VSM_PROTECTION_INFORMATION
|
|
{
|
|
BOOLEAN DmaProtectionsAvailable;
|
|
BOOLEAN DmaProtectionsInUse;
|
|
BOOLEAN HardwareMbecAvailable; // REDSTONE4 (CVE-2018-3639)
|
|
BOOLEAN ApicVirtualizationAvailable; // 20H1
|
|
} SYSTEM_VSM_PROTECTION_INFORMATION, *PSYSTEM_VSM_PROTECTION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_KERNEL_DEBUGGER_FLAGS structure defines the system kernel debugger flags.
|
|
*/
|
|
typedef struct _SYSTEM_KERNEL_DEBUGGER_FLAGS
|
|
{
|
|
BOOLEAN KernelDebuggerIgnoreUmExceptions;
|
|
} SYSTEM_KERNEL_DEBUGGER_FLAGS, *PSYSTEM_KERNEL_DEBUGGER_FLAGS;
|
|
|
|
// SYSTEM_CODEINTEGRITYPOLICY_INFORMATION Options
|
|
#define CODEINTEGRITYPOLICY_OPTION_ENABLED 0x01
|
|
#define CODEINTEGRITYPOLICY_OPTION_AUDIT 0x02
|
|
#define CODEINTEGRITYPOLICY_OPTION_REQUIRE_WHQL 0x04
|
|
#define CODEINTEGRITYPOLICY_OPTION_DISABLED_FLIGHTSIGNING 0x08
|
|
#define CODEINTEGRITYPOLICY_OPTION_ENABLED_UMCI 0x10
|
|
#define CODEINTEGRITYPOLICY_OPTION_ENABLED_UPDATE_POLICY_NOREBOOT 0x20
|
|
#define CODEINTEGRITYPOLICY_OPTION_ENABLED_SECURE_SETTING_POLICY 0x40
|
|
#define CODEINTEGRITYPOLICY_OPTION_ENABLED_UNSIGNED_SYSTEMINTEGRITY_POLICY 0x80
|
|
#define CODEINTEGRITYPOLICY_OPTION_DYNAMIC_CODE_POLICY_ENABLED 0x100
|
|
#define CODEINTEGRITYPOLICY_OPTION_RELOAD_POLICY_NO_REBOOT 0x10000000 // NtSetSystemInformation reloads SiPolicy.p7b
|
|
#define CODEINTEGRITYPOLICY_OPTION_CONDITIONAL_LOCKDOWN 0x20000000
|
|
#define CODEINTEGRITYPOLICY_OPTION_NOLOCKDOWN 0x40000000
|
|
#define CODEINTEGRITYPOLICY_OPTION_LOCKDOWN 0x80000000
|
|
|
|
// SYSTEM_CODEINTEGRITYPOLICY_INFORMATION HVCIOptions
|
|
#define CODEINTEGRITYPOLICY_HVCIOPTION_ENABLED 0x01
|
|
#define CODEINTEGRITYPOLICY_HVCIOPTION_STRICT 0x02
|
|
#define CODEINTEGRITYPOLICY_HVCIOPTION_DEBUG 0x04
|
|
|
|
// private
|
|
/**
|
|
* \brief Code Integrity Policy configuration and HVCI (Hypervisor-enforced Code Integrity) settings.
|
|
*
|
|
* Contains the kernel's code integrity policy enforcement options and Hardware-enforced Code Integrity (HVCI)
|
|
* configuration state. Enables applications to query the security posture of code integrity enforcement and
|
|
* virtualization-based security features. Available via NtQuerySystemInformation(SystemCodeIntegrityInformation).
|
|
*
|
|
* \since Windows 10
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_POLICY_INFORMATION
|
|
{
|
|
/**
|
|
* \brief Code integrity policy options (Options union).
|
|
*
|
|
* Union providing both raw 32-bit access and bitfield access to policy flags:
|
|
* - Enabled: Code integrity enforcement is active
|
|
* - Audit: Code integrity operates in audit mode (violations logged, not blocked)
|
|
* - RequireWHQL: Windows Hardware Quality Labs certification required for drivers
|
|
* - DisabledFlightSigning: Flight-signed binaries are blocked from loading
|
|
* - EnabledUMCI: User-mode Code Integrity enforcement enabled (signed DLL requirement)
|
|
* - EnabledUpdatePolicyNoReboot: Code integrity policy updates without system reboot
|
|
* - EnabledSecureSettingPolicy: Secure settings policy enforcement enabled
|
|
* - EnabledUnsignedSystemIntegrityPolicy: Unsigned system integrity policies allowed
|
|
* - DynamicCodePolicyEnabled: Dynamic code generation and modification is restricted
|
|
* - Spare: 19 reserved bits for future expansion
|
|
* - ReloadPolicyNoReboot: Policy reloaded without reboot (bit 28)
|
|
* - ConditionalLockdown: Conditional code integrity lockdown mode (bit 29)
|
|
* - NoLockdown: Code integrity lockdown is not active (bit 30)
|
|
* - Lockdown: Code integrity lockdown mode is enforced (bit 31)
|
|
*/
|
|
union
|
|
{
|
|
ULONG Options;
|
|
struct
|
|
{
|
|
ULONG Enabled : 1; ///< Code integrity enforcement enabled
|
|
ULONG Audit : 1; ///< Audit mode (log violations, don't block)
|
|
ULONG RequireWHQL : 1; ///< Require WHQL certification
|
|
ULONG DisabledFlightSigning : 1; ///< Block flight-signed binaries
|
|
ULONG EnabledUMCI : 1; ///< User-mode code integrity enabled
|
|
ULONG EnabledUpdatePolicyNoReboot : 1; ///< Update policy without reboot
|
|
ULONG EnabledSecureSettingPolicy : 1; ///< Secure settings policy active
|
|
ULONG EnabledUnsignedSystemIntegrityPolicy : 1; ///< Allow unsigned system integrity policies
|
|
ULONG DynamicCodePolicyEnabled : 1; ///< Restrict dynamic code/JIT
|
|
ULONG Spare : 19; ///< Reserved for future use
|
|
ULONG ReloadPolicyNoReboot : 1; ///< Policy reloaded without reboot
|
|
ULONG ConditionalLockdown : 1; ///< Conditional lockdown mode
|
|
ULONG NoLockdown : 1; ///< Lockdown not enforced
|
|
ULONG Lockdown : 1; ///< Lockdown mode enforced
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
/**
|
|
* \brief Hardware-enforced Code Integrity (HVCI) options.
|
|
*
|
|
* Union providing both raw access and bitfield access to HVCI/VBS configuration:
|
|
* - HVCIEnabled: HVCI is active (code integrity enforcement via hypervisor)
|
|
* - HVCIStrict: Strict mode enforcement (higher security, lower performance)
|
|
* - HVCIDebug: Debug mode enabled (diagnostic/troubleshooting)
|
|
* - HVCISpare: 29 reserved bits for future HVCI expansion
|
|
*/
|
|
union
|
|
{
|
|
ULONG HVCIOptions;
|
|
struct
|
|
{
|
|
ULONG HVCIEnabled : 1; ///< HVCI enforced by hypervisor
|
|
ULONG HVCIStrict : 1; ///< Strict HVCI mode enforcement
|
|
ULONG HVCIDebug : 1; ///< HVCI debug mode active
|
|
ULONG HVCISpare : 29; ///< Reserved for future use
|
|
} DUMMYSTRUCTNAME2;
|
|
} DUMMYUNIONNAME2;
|
|
/**
|
|
* \brief Code integrity policy version.
|
|
*
|
|
* Version number incremented when the kernel reloads/updates the code integrity policy.
|
|
* Used to detect policy changes without requiring system restart.
|
|
*/
|
|
ULONGLONG Version;
|
|
/**
|
|
* \brief Code integrity policy GUID.
|
|
*
|
|
* Uniquely identifies the loaded code integrity policy file. Changes when a different
|
|
* policy becomes active; can be used to correlate policy audit logs.
|
|
*/
|
|
GUID PolicyGuid;
|
|
} SYSTEM_CODEINTEGRITY_POLICY_INFORMATION, *PSYSTEM_CODEINTEGRITY_POLICY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* \brief Isolated User Mode (IUM) and virtualization-based security (VBS) status.
|
|
*
|
|
* Queries the state of Virtualization-Based Security (VBS) infrastructure, including Hyper-V Code Integrity (HVCI),
|
|
* Secure Kernel, trustlets, and hardware-enforced security features. Enables applications to detect when running
|
|
* in a hardened security posture and to determine available cryptographic protections.
|
|
* Available via NtQuerySystemInformation(SystemIsolatedUserModeInformation).
|
|
*
|
|
* \since Windows 10 (RS2+)
|
|
*/
|
|
typedef struct _SYSTEM_ISOLATED_USER_MODE_INFORMATION
|
|
{
|
|
///< \brief Virtualization-based Security core status (byte 0):
|
|
BOOLEAN SecureKernelRunning : 1; ///< Secure Kernel (hypervisor-based isolation) is active
|
|
BOOLEAN HvciEnabled : 1; ///< Hypervisor-enforced Code Integrity enabled
|
|
BOOLEAN HvciStrictMode : 1; ///< HVCI in strict enforcement mode
|
|
BOOLEAN DebugEnabled : 1; ///< Kernel debugger enabled (may weaken security)
|
|
BOOLEAN FirmwarePageProtection : 1; ///< UEFI Secure Boot firmware page protection active
|
|
BOOLEAN EncryptionKeyAvailable : 1; ///< Isolation-backed encryption key available from Secure Kernel
|
|
BOOLEAN SpareFlags : 2; ///< Reserved for future VBS flags (bits 6-7)
|
|
|
|
///< \brief Isolated execution and security features (byte 1):
|
|
BOOLEAN TrustletRunning : 1; ///< Trustlet (isolated edge function) is running
|
|
BOOLEAN HvciDisableAllowed : 1; ///< HVCI can be disabled without reboot (policy-driven)
|
|
BOOLEAN HardwareEnforcedVbs : 1; ///< VBS enforced by processor/platform (e.g., AMD SME, Intel TXT)
|
|
BOOLEAN NoSecrets : 1; ///< No cryptographic secrets loaded in isolated user mode
|
|
BOOLEAN EncryptionKeyPersistent : 1; ///< Encryption key persists across reboots
|
|
BOOLEAN HardwareEnforcedHvpt : 1; ///< Hardware enforces Hypervisor Page Table (HVPT) isolation
|
|
BOOLEAN HardwareHvptAvailable : 1; ///< CPU supports hardware-enforced HVPT (architectural feature)
|
|
BOOLEAN SpareFlags2 : 1; ///< Reserved for future feature flag (bit 15)
|
|
BOOLEAN EncryptionKeyTpmBound : 1; ///< Encryption key bound to TPM (Trusted Platform Module)
|
|
|
|
///< \brief Reserved for future expansion (binary compatibility):
|
|
BOOLEAN Spare0[5]; ///< Reserved bytes for future isolated user mode flags
|
|
ULONGLONG Spare1; ///< Reserved 8 bytes for future isolated user mode expansion
|
|
} SYSTEM_ISOLATED_USER_MODE_INFORMATION, *PSYSTEM_ISOLATED_USER_MODE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HARDWARE_SECURITY_TEST_INTERFACE_RESULTS_INFORMATION structure contains system hardware security test interface results information.
|
|
*/
|
|
typedef struct _SYSTEM_HARDWARE_SECURITY_TEST_INTERFACE_RESULTS_INFORMATION
|
|
{
|
|
UCHAR Results[1];
|
|
} SYSTEM_HARDWARE_SECURITY_TEST_INTERFACE_RESULTS_INFORMATION, *PSYSTEM_HARDWARE_SECURITY_TEST_INTERFACE_RESULTS_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SINGLE_MODULE_INFORMATION structure contains system single module information.
|
|
*/
|
|
typedef struct _SYSTEM_SINGLE_MODULE_INFORMATION
|
|
{
|
|
PVOID TargetModuleAddress;
|
|
RTL_PROCESS_MODULE_INFORMATION_EX ExInfo;
|
|
} SYSTEM_SINGLE_MODULE_INFORMATION, *PSYSTEM_SINGLE_MODULE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_INTERRUPT_CPU_SET_INFORMATION structure contains system interrupt CPU set information.
|
|
*/
|
|
typedef struct _SYSTEM_INTERRUPT_CPU_SET_INFORMATION
|
|
{
|
|
ULONG Gsiv;
|
|
USHORT Group;
|
|
ULONGLONG CpuSets;
|
|
} SYSTEM_INTERRUPT_CPU_SET_INFORMATION, *PSYSTEM_INTERRUPT_CPU_SET_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECUREBOOT_POLICY_FULL_INFORMATION structure contains system secureboot policy full information.
|
|
*/
|
|
typedef struct _SYSTEM_SECUREBOOT_POLICY_FULL_INFORMATION
|
|
{
|
|
SYSTEM_SECUREBOOT_POLICY_INFORMATION PolicyInformation;
|
|
ULONG PolicySize;
|
|
_Field_size_bytes_(PolicySize) UCHAR Policy[1];
|
|
} SYSTEM_SECUREBOOT_POLICY_FULL_INFORMATION, *PSYSTEM_SECUREBOOT_POLICY_FULL_INFORMATION;
|
|
|
|
// rev
|
|
#define SYSTEM_CODE_INTEGRITY_POLICY_HEADER_VERSION 8
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICY_HEADER structure describes the header of a Code Integrity policy.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICY_HEADER
|
|
{
|
|
UCHAR Magic[4]; // "WDAC"
|
|
ULONG Version; // Policy version/format number
|
|
ULONG TypeAndOptions; // Policy type flags and options
|
|
ULONG TimestampLow; // Creation/modification timestamp (low)
|
|
ULONG TimestampHigh; // Creation/modification timestamp (high)
|
|
UCHAR Hash[32]; // SHA-256 policy hash/identifier
|
|
} SYSTEM_CODE_INTEGRITY_POLICY_HEADER, *PSYSTEM_CODE_INTEGRITY_POLICY_HEADER;
|
|
|
|
// rev // Hash Rule Entry (Variable length)
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICY_RULE_ENTRY structure describes a single rule in a Code Integrity policy.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICY_RULE_ENTRY
|
|
{
|
|
ULONG Marker; // 8-byte marker (part of rule identification)
|
|
ULONG RuleMarkerHigh;
|
|
ULONG DataLength; // 4-byte length of hash data
|
|
UCHAR FixedPrefix[12]; // 12-byte fixed prefix (rule type, attributes)
|
|
UCHAR Hash[ANYSIZE_ARRAY]; // Variable-length hash (SHA-256, SHA-1, etc.)
|
|
} SYSTEM_CODE_INTEGRITY_POLICY_RULE_ENTRY, *PSYSTEM_CODE_INTEGRITY_POLICY_RULE_ENTRY;
|
|
|
|
// rev // String Table Entry (Variable length, 4-byte aligned)
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICY_STRING_ENTRY structure describes a single string entry in a Code Integrity policy.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICY_STRING_ENTRY
|
|
{
|
|
USHORT Length; // Length in bytes (not including null terminator)
|
|
WCHAR String[ANYSIZE_ARRAY]; // UTF-16LE string
|
|
// UCHAR Padding[ANYSIZE_ARRAY] // Followed by Padding[] to align to 4-byte boundary
|
|
} SYSTEM_CODE_INTEGRITY_POLICY_STRING_ENTRY, *PSYSTEM_CODE_INTEGRITY_POLICY_STRING_ENTRY;
|
|
|
|
// rev // Numeric Index Table (used for Signers, FileRules, etc.)
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICY_INDEX_TABLE_ENTRY structure describes a single index-table entry in a Code Integrity policy.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICY_INDEX_TABLE_ENTRY
|
|
{
|
|
// Width determines interpretation:
|
|
// Width=8: Signer entry {StringIndex(2), RuleRefCount(2), RuleRefs[RuleRefCount](4 each)}
|
|
// Width=4: FileRule index referencing a string from string table
|
|
UCHAR Entry[ANYSIZE_ARRAY];
|
|
} SYSTEM_CODE_INTEGRITY_POLICY_INDEX_TABLE_ENTRY, *PSYSTEM_CODE_INTEGRITY_POLICY_INDEX_TABLE_ENTRY;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICY_FULL_INFORMATION structure contains full information about a Code Integrity policy.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICY_FULL_INFORMATION
|
|
{
|
|
SYSTEM_CODE_INTEGRITY_POLICY_HEADER Header;
|
|
UCHAR RuleBody[ANYSIZE_ARRAY]; // Followed by sections (offsets determined by header)
|
|
// UCHAR StringTable[ANYSIZE_ARRAY]; // Followed by StringTable
|
|
// UCHAR IndexTables[ANYSIZE_ARRAY]; // Followed by NumericTables (Signers, FileRules, etc.)
|
|
} SYSTEM_CODE_INTEGRITY_POLICY_FULL_INFORMATION, *PSYSTEM_CODE_INTEGRITY_POLICY_FULL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The KAFFINITY_EX structure represents an extended processor affinity mask that spans multiple processor groups.
|
|
*/
|
|
typedef struct _KAFFINITY_EX
|
|
{
|
|
USHORT Count;
|
|
USHORT Size;
|
|
ULONG Reserved;
|
|
union
|
|
{
|
|
ULONG_PTR Bitmap[1];
|
|
ULONG_PTR StaticBitmap[32];
|
|
} DUMMYUNIONNAME;
|
|
} KAFFINITY_EX, *PKAFFINITY_EX;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ROOT_SILO_INFORMATION structure contains system root silo information.
|
|
*/
|
|
typedef struct _SYSTEM_ROOT_SILO_INFORMATION
|
|
{
|
|
ULONG NumberOfSilos;
|
|
ULONG SiloIdList[1];
|
|
} SYSTEM_ROOT_SILO_INFORMATION, *PSYSTEM_ROOT_SILO_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CPU_SET_TAG_INFORMATION structure contains system CPU set tag information.
|
|
*/
|
|
typedef struct _SYSTEM_CPU_SET_TAG_INFORMATION
|
|
{
|
|
ULONGLONG Tag;
|
|
ULONGLONG CpuSets[1];
|
|
} SYSTEM_CPU_SET_TAG_INFORMATION, *PSYSTEM_CPU_SET_TAG_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECURE_KERNEL_HYPERGUARD_PROFILE_INFORMATION structure contains system secure kernel hyperguard profile information.
|
|
*/
|
|
typedef struct _SYSTEM_SECURE_KERNEL_HYPERGUARD_PROFILE_INFORMATION
|
|
{
|
|
ULONG ExtentCount;
|
|
ULONG ValidStructureSize;
|
|
ULONG NextExtentIndex;
|
|
ULONG ExtentRestart;
|
|
ULONG CycleCount;
|
|
ULONG TimeoutCount;
|
|
ULONGLONG CycleTime;
|
|
ULONGLONG CycleTimeMax;
|
|
ULONGLONG ExtentTime;
|
|
ULONG ExtentTimeIndex;
|
|
ULONG ExtentTimeMaxIndex;
|
|
ULONGLONG ExtentTimeMax;
|
|
ULONGLONG HyperFlushTimeMax;
|
|
ULONGLONG TranslateVaTimeMax;
|
|
ULONGLONG DebugExemptionCount;
|
|
ULONGLONG TbHitCount;
|
|
ULONGLONG TbMissCount;
|
|
ULONGLONG VinaPendingYield;
|
|
ULONGLONG HashCycles;
|
|
ULONG HistogramOffset;
|
|
ULONG HistogramBuckets;
|
|
ULONG HistogramShift;
|
|
ULONG Reserved1;
|
|
ULONGLONG PageNotPresentCount;
|
|
} SYSTEM_SECURE_KERNEL_HYPERGUARD_PROFILE_INFORMATION, *PSYSTEM_SECURE_KERNEL_HYPERGUARD_PROFILE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECUREBOOT_PLATFORM_MANIFEST_INFORMATION structure contains system secureboot platform manifest information.
|
|
*/
|
|
typedef struct _SYSTEM_SECUREBOOT_PLATFORM_MANIFEST_INFORMATION
|
|
{
|
|
ULONG PlatformManifestSize;
|
|
_Field_size_bytes_(PlatformManifestSize) UCHAR PlatformManifest[1];
|
|
} SYSTEM_SECUREBOOT_PLATFORM_MANIFEST_INFORMATION, *PSYSTEM_SECUREBOOT_PLATFORM_MANIFEST_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_INTERRUPT_STEERING_INFORMATION_INPUT structure specifies the input parameters for a system interrupt steering information query.
|
|
*/
|
|
typedef struct _SYSTEM_INTERRUPT_STEERING_INFORMATION_INPUT
|
|
{
|
|
ULONG Gsiv;
|
|
UCHAR ControllerInterrupt;
|
|
UCHAR EdgeInterrupt;
|
|
UCHAR IsPrimaryInterrupt;
|
|
GROUP_AFFINITY TargetAffinity;
|
|
} SYSTEM_INTERRUPT_STEERING_INFORMATION_INPUT, *PSYSTEM_INTERRUPT_STEERING_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_INTERRUPT_STEERING_INFORMATION_OUTPUT union receives the output of a system interrupt steering information query.
|
|
*/
|
|
typedef union _SYSTEM_INTERRUPT_STEERING_INFORMATION_OUTPUT
|
|
{
|
|
ULONG AsULONG;
|
|
struct
|
|
{
|
|
ULONG Enabled : 1;
|
|
ULONG Reserved : 31;
|
|
} DUMMYSTRUCTNAME;
|
|
} SYSTEM_INTERRUPT_STEERING_INFORMATION_OUTPUT, *PSYSTEM_INTERRUPT_STEERING_INFORMATION_OUTPUT;
|
|
|
|
#if !defined(NTDDI_WIN10_FE) || (NTDDI_VERSION < NTDDI_WIN10_FE)
|
|
// private
|
|
/**
|
|
* The SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION structure contains system supported processor architectures information.
|
|
*/
|
|
typedef struct _SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION
|
|
{
|
|
ULONG Machine : 16;
|
|
ULONG KernelMode : 1;
|
|
ULONG UserMode : 1;
|
|
ULONG Native : 1;
|
|
ULONG Process : 1;
|
|
ULONG WoW64Container : 1;
|
|
ULONG ReservedZero0 : 11;
|
|
} SYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION, *PSYSTEM_SUPPORTED_PROCESSOR_ARCHITECTURES_INFORMATION;
|
|
#endif // NTDDI_WIN10_FE
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_USAGE_INFORMATION structure contains information about the memory usage of the system.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_USAGE_INFORMATION
|
|
{
|
|
ULONGLONG TotalPhysicalBytes;
|
|
ULONGLONG AvailableBytes;
|
|
LONGLONG ResidentAvailableBytes;
|
|
ULONGLONG CommittedBytes;
|
|
ULONGLONG SharedCommittedBytes;
|
|
ULONGLONG CommitLimitBytes;
|
|
ULONGLONG PeakCommitmentBytes;
|
|
} SYSTEM_MEMORY_USAGE_INFORMATION, *PSYSTEM_MEMORY_USAGE_INFORMATION;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_IMAGE_TYPE constant is used for validating user-mode images (EXE/DLL).
|
|
*/
|
|
typedef enum _SYSTEM_CODEINTEGRITY_IMAGE_TYPE
|
|
{
|
|
SystemCodeIntegrityImageTypeUser,
|
|
SystemCodeIntegrityImageTypeKernel,
|
|
SystemCodeIntegrityImageTypeBoot
|
|
} SYSTEM_CODEINTEGRITY_IMAGE_TYPE;
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_IMAGE_TYPE_USER constant is used for validating user-mode images (EXE/DLL).
|
|
*
|
|
* Validation includes:
|
|
* - Digital signature
|
|
* - User-mode certificate chain validity.
|
|
* - Compliance policies for user-mode binaries.
|
|
*/
|
|
#define SYSTEM_CODEINTEGRITY_IMAGE_TYPE_USER 0
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_IMAGE_TYPE_KERNEL constant is used for validating kernel-mode images (SYS/Native).
|
|
*
|
|
* Validation includes:
|
|
* - Signed by a trusted certificate authority (or cross-signed).
|
|
* - Compliance policies for kernel-mode binaries.
|
|
*/
|
|
#define SYSTEM_CODEINTEGRITY_IMAGE_TYPE_KERNEL 1
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_IMAGE_TYPE_BOOT constant is used for validating boot-critical images (SYS/Native).
|
|
*
|
|
* Validation includes:
|
|
* - Signed only by Microsoft.
|
|
* - Compliance policies for boot-critical binaries (Strict WHQL, Secure Boot requirements).
|
|
*/
|
|
#define SYSTEM_CODEINTEGRITY_IMAGE_TYPE_BOOT 2
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_CERTIFICATE_INFORMATION structure contains information to validate the integrity of an image.
|
|
*
|
|
* \note The return status of NtQuerySystemInformation indicates the result of the code integrity validation as determined by the type specified.
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_CERTIFICATE_INFORMATION
|
|
{
|
|
HANDLE ImageFile; // in: Handle to a file or image to validate.
|
|
ULONG Type; // in: The type of code integrity policy. // REDSTONE4
|
|
} SYSTEM_CODEINTEGRITY_CERTIFICATE_INFORMATION, *PSYSTEM_CODEINTEGRITY_CERTIFICATE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_PHYSICAL_MEMORY_INFORMATION structure retrieves the physical memory layout of the system.
|
|
* \remarks The addresses are physical, not virtual.
|
|
*/
|
|
typedef struct _SYSTEM_PHYSICAL_MEMORY_INFORMATION
|
|
{
|
|
ULONGLONG TotalPhysicalBytes; // Total amount of physical RAM present, in bytes.
|
|
ULONGLONG LowestPhysicalAddress; // Lowest accessible physical address (byte address).
|
|
ULONGLONG HighestPhysicalAddress; // Highest accessible physical address (byte address, inclusive).
|
|
} SYSTEM_PHYSICAL_MEMORY_INFORMATION, *PSYSTEM_PHYSICAL_MEMORY_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_STATE type contains the moderation state applied to an application,
|
|
* with respect to background throttling, resource reduction, and related heuristics.
|
|
* \remarks The state may be assigned automatically by the system or explicitly overridden by the user.
|
|
*/
|
|
typedef enum _SYSTEM_ACTIVITY_MODERATION_STATE
|
|
{
|
|
SystemActivityModerationStateSystemManaged, // The system applies heuristics based on the appropriate moderation behavior.
|
|
SystemActivityModerationStateUserManagedAllowThrottling, // User allows the system to throttle the application.
|
|
SystemActivityModerationStateUserManagedDisableThrottling, // User disables throttling for the application.
|
|
MaxSystemActivityModerationState // Upper bound for validation; not a real state.
|
|
} SYSTEM_ACTIVITY_MODERATION_STATE;
|
|
|
|
// private - REDSTONE2
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_EXE_STATE structure describes the system activity moderation exe state.
|
|
*/
|
|
typedef struct _SYSTEM_ACTIVITY_MODERATION_EXE_STATE // REDSTONE3: Renamed SYSTEM_ACTIVITY_MODERATION_INFO
|
|
{
|
|
UNICODE_STRING ExePathNt;
|
|
SYSTEM_ACTIVITY_MODERATION_STATE ModerationState;
|
|
} SYSTEM_ACTIVITY_MODERATION_EXE_STATE, *PSYSTEM_ACTIVITY_MODERATION_EXE_STATE;
|
|
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_APP_TYPE enumeration defines the system activity moderation app types.
|
|
*/
|
|
typedef enum _SYSTEM_ACTIVITY_MODERATION_APP_TYPE
|
|
{
|
|
SystemActivityModerationAppTypeClassic,
|
|
SystemActivityModerationAppTypePackaged,
|
|
MaxSystemActivityModerationAppType
|
|
} SYSTEM_ACTIVITY_MODERATION_APP_TYPE;
|
|
|
|
// private - REDSTONE3
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_INFO structure contains system activity moderation information.
|
|
*/
|
|
typedef struct _SYSTEM_ACTIVITY_MODERATION_INFO
|
|
{
|
|
UNICODE_STRING Identifier;
|
|
SYSTEM_ACTIVITY_MODERATION_STATE ModerationState;
|
|
SYSTEM_ACTIVITY_MODERATION_APP_TYPE AppType;
|
|
} SYSTEM_ACTIVITY_MODERATION_INFO, *PSYSTEM_ACTIVITY_MODERATION_INFO;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_APP_SETTINGS structure describes the moderation state
|
|
* and classification of an application as used by the system's activity moderation framework.
|
|
* These settings influence how aggressively the system may throttle, defer, or
|
|
* suppress certain background activities for the application.
|
|
*
|
|
* The structure maintains a stable binary layout because it is stored in
|
|
* serialized policy blobs and consumed by system components that expect
|
|
* fixed field offsets.
|
|
*/
|
|
typedef struct _SYSTEM_ACTIVITY_MODERATION_APP_SETTINGS
|
|
{
|
|
LARGE_INTEGER LastUpdatedTime; // Timestamp of the last update to this settings block.
|
|
SYSTEM_ACTIVITY_MODERATION_STATE ModerationState; // Current moderation state assigned to the application.
|
|
UCHAR Reserved[4]; // Reserved for future expansion
|
|
SYSTEM_ACTIVITY_MODERATION_APP_TYPE AppType; // Current application type for moderation purposes.
|
|
ULONG Flags; // Additional moderation flags.
|
|
} SYSTEM_ACTIVITY_MODERATION_APP_SETTINGS, *PSYSTEM_ACTIVITY_MODERATION_APP_SETTINGS;
|
|
|
|
/**
|
|
* The SYSTEM_ACTIVITY_MODERATION_USER_SETTINGS structure provides the activity-moderation
|
|
* registry location where moderation policies or overrides may be stored.
|
|
*/
|
|
typedef struct _SYSTEM_ACTIVITY_MODERATION_USER_SETTINGS
|
|
{
|
|
HANDLE UserKeyHandle; // Handle to the user registry key for activity moderation settings.
|
|
} SYSTEM_ACTIVITY_MODERATION_USER_SETTINGS, *PSYSTEM_ACTIVITY_MODERATION_USER_SETTINGS;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_POLICIES_FULL_INFORMATION structure contains full information about the active Code Integrity policies.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_POLICIES_FULL_INFORMATION
|
|
{
|
|
ULONG PolicyCount;
|
|
UCHAR PolicyBlobs[ANYSIZE_ARRAY];
|
|
} SYSTEM_CODE_INTEGRITY_POLICIES_FULL_INFORMATION, *PSYSTEM_CODE_INTEGRITY_POLICIES_FULL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION structure contains Code Integrity unlock state and validation token.
|
|
*
|
|
* **Purpose:**
|
|
*
|
|
* The UnlockId field is a 32-byte cryptographic validation token used to authenticate requests to temporarily
|
|
* disable Code Integrity (CI) enforcement. It works in conjunction with the three flag bits (Locked, UnlockApplied, UnlockIdValid)
|
|
* to control the application of code integrity bypass authorization.
|
|
*
|
|
* **Mechanism:**
|
|
*
|
|
* \b Token \b Generation: When needing to disable CI, a component (bootloader, recovery environment, or factory process)
|
|
* computes a 32-byte UnlockId using:
|
|
* - HMAC-SHA256 or similar cryptographic hash function
|
|
* - A kernel-embedded or TPM-stored secret key
|
|
* - Machine-specific data (boot state, firmware version, hardware configuration, etc.)
|
|
*
|
|
* \b Validation: The kernel validates the UnlockId by:
|
|
* - Recomputing the expected HMAC-SHA256 using its stored secret and machine state
|
|
* - Comparing against the provided UnlockId (32-byte comparison)
|
|
* - Setting the UnlockIdValid flag if the cryptographic match succeeds
|
|
* - Rejecting any token that fails validation
|
|
*
|
|
* \b Application: Once validated:
|
|
* - UnlockApplied flag is set (unlock request accepted by the kernel)
|
|
* - Locked flag may be cleared (CI enforcement disabled for this session)
|
|
* - Temporary bypass of code integrity checks is granted for authorized operations
|
|
*
|
|
* **Security Properties:**
|
|
*
|
|
* - \b 256-bit \b Token: The 32-byte (256-bit) size is standard for HMAC-SHA256 output, providing strong cryptographic security
|
|
* - \b Microsoft-Controlled \b Secret: UnlockId tokens are derived from a Microsoft-controlled secret key, preventing unauthorized bypasses
|
|
* - \b Machine \b Binding: Machine-specific data ensures tokens are valid only for the intended system
|
|
* - \b Temporal \b Scope: Unlock is session-scoped and typically used during controlled recovery or factory processes
|
|
*
|
|
* **Use Cases:**
|
|
*
|
|
* - \b Factory \b Reset (OOBE): Allow boot in non-secure mode during device initial setup and provisioning
|
|
* - \b Recovery \b Environment: Enable recovery tools to bypass CI during authorized system repairs
|
|
* - \b Secure \b Boot \b Bypass: Controlled disabling of code verification during authorized recovery scenarios
|
|
* - \b Development/Debugging: Microsoft-signed tokens for internal kernel validation and testing on development systems
|
|
*
|
|
* \note The UnlockId prevents unauthorized bypasses of code integrity protection and is only trusted after cryptographic validation succeeds.
|
|
* \note This structure is private to the kernel and not part of the public API.
|
|
* \note Available since Windows Redstone 4 (Windows 10 version 1803).
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
/** \brief Code Integrity is currently locked (enforced).
|
|
*
|
|
* When set (1), Code Integrity enforcement is active and code execution restrictions are applied.
|
|
* When clear (0), Code Integrity may be disabled if UnlockApplied is set and a valid token was provided.
|
|
*/
|
|
ULONG Locked : 1;
|
|
|
|
/** \brief Unlock request has been validated and applied.
|
|
*
|
|
* Set by the kernel when the provided UnlockId passes cryptographic validation and the unlock is authorized.
|
|
* When set, this flag indicates that CI enforcement has been temporarily disabled for this session.
|
|
* Field removed after Windows 10 v1909 (19H1) in newer releases.
|
|
*/
|
|
ULONG UnlockApplied : 1;
|
|
|
|
/** \brief UnlockId contains a valid, authenticated cryptographic token.
|
|
*
|
|
* Set by the kernel when the provided UnlockId passes HMAC-SHA256 validation against the kernel's stored secret.
|
|
* This flag indicates that the token is cryptographically valid and can authorize CI bypass.
|
|
*/
|
|
ULONG UnlockIdValid : 1;
|
|
|
|
/** \brief Reserved flag bits for future use. */
|
|
ULONG Reserved : 29;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
/** \brief 32-byte cryptographic validation token for Code Integrity unlock requests.
|
|
*
|
|
* This HMAC-SHA256 token authorizes temporary disabling of Code Integrity enforcement.
|
|
* The token is computed using a kernel-embedded secret key, machine-specific data, and cryptographic derivation.
|
|
*
|
|
* **Format:**
|
|
* - Size: 32 bytes (256 bits)
|
|
* - Algorithm: HMAC-SHA256
|
|
* - Derivation: Microsoft-controlled secret key + machine state
|
|
* - Validation: Kernel verifies token before granting CI bypass
|
|
*
|
|
* **Validation Process:**
|
|
* 1. Kernel recomputes expected HMAC-SHA256 from stored secret and current machine state
|
|
* 2. Compares computed HMAC against the provided UnlockId (byte-for-byte)
|
|
* 3. Sets UnlockIdValid flag if match succeeds; fails otherwise
|
|
* 4. If validation succeeds, kernel sets UnlockApplied and may clear Locked flag
|
|
*
|
|
* **Authorization Scenarios:**
|
|
* - Factory Reset (OOBE): Token allows non-secure boot during device provisioning
|
|
* - Recovery Mode: Token allows recovery environment to bypass code verification checks
|
|
* - Development/Debug: Microsoft-signed tokens for test systems and kernel development
|
|
*
|
|
* \note Available since Windows 10 Redstone 4 (version 1803, NTDDI_WIN10_RS4).
|
|
*/
|
|
UCHAR UnlockId[32];
|
|
} SYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION, *PSYSTEM_CODEINTEGRITY_UNLOCK_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FLUSH_INFORMATION structure contains system flush information.
|
|
*/
|
|
typedef struct _SYSTEM_FLUSH_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG SupportedFlushMethods;
|
|
struct
|
|
{
|
|
ULONG MethodAlwaysPresent : 1; // 0x1
|
|
ULONG MethodProcessorFeatureBit35 : 1; // 0x2
|
|
ULONG MethodProcessorFeatureBit36 : 1; // 0x4
|
|
ULONG ReservedMethods : 29;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
ULONG ProcessorCacheFlushSize;
|
|
|
|
union
|
|
{
|
|
ULONGLONG SystemFlushCapabilities;
|
|
struct
|
|
{
|
|
ULONGLONG NfitType7FlushCapable : 1; // 0x1
|
|
ULONGLONG ReservedCapabilities : 63;
|
|
} DUMMYSTRUCTNAME2;
|
|
} DUMMYUNIONNAME2;
|
|
|
|
ULONGLONG Reserved[2];
|
|
} SYSTEM_FLUSH_INFORMATION, *PSYSTEM_FLUSH_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_WRITE_CONSTRAINT_INFORMATION structure contains system write constraint information.
|
|
*/
|
|
typedef struct _SYSTEM_WRITE_CONSTRAINT_INFORMATION
|
|
{
|
|
ULONG WriteConstraintPolicy;
|
|
ULONG Reserved;
|
|
} SYSTEM_WRITE_CONSTRAINT_INFORMATION, *PSYSTEM_WRITE_CONSTRAINT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_KERNEL_VA_SHADOW_INFORMATION structure contains the state of kernel virtual address (KVA) shadowing.
|
|
*/
|
|
typedef struct _SYSTEM_KERNEL_VA_SHADOW_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG KvaShadowFlags;
|
|
struct
|
|
{
|
|
ULONG KvaShadowEnabled : 1;
|
|
ULONG KvaShadowUserGlobal : 1;
|
|
ULONG KvaShadowPcid : 1;
|
|
ULONG KvaShadowInvpcid : 1;
|
|
ULONG KvaShadowRequired : 1; // REDSTONE4
|
|
ULONG KvaShadowRequiredAvailable : 1;
|
|
ULONG InvalidPteBit : 6;
|
|
ULONG L1DataCacheFlushSupported : 1;
|
|
ULONG L1TerminalFaultMitigationPresent : 1;
|
|
ULONG Reserved : 18;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_KERNEL_VA_SHADOW_INFORMATION, *PSYSTEM_KERNEL_VA_SHADOW_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_VERIFICATION_INFORMATION structure contains information
|
|
* required for code integrity verification of an image.
|
|
*
|
|
* Two verification modes are supported:
|
|
* - File-backed: supply a non-null FileHandle (handle to an open file); Image and ImageSize are ignored.
|
|
* - Memory-backed: supply a null FileHandle, set Image to the base address of a mapped/loaded PE image
|
|
* in memory, and ImageSize to its size in bytes. The kernel reads image content directly from the buffer.
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_VERIFICATION_INFORMATION
|
|
{
|
|
HANDLE FileHandle; // Handle to an open file for file-backed verification, or NULL for memory-backed verification.
|
|
ULONG ImageSize; // Size in bytes of the image buffer; used only when FileHandle is NULL.
|
|
PVOID Image; // Base address of the PE image buffer for memory-backed verification; ignored when FileHandle is non-null.
|
|
} SYSTEM_CODEINTEGRITY_VERIFICATION_INFORMATION, *PSYSTEM_CODEINTEGRITY_VERIFICATION_INFORMATION;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_USER_SHARED_DATA structure contains information shared with the hypervisor and user-mode.
|
|
*
|
|
* This structure is populated by the hypervisor (when present) to allow user-mode components to perform
|
|
* high-resolution time calculations without requiring a hypercall or kernel transition.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_USER_SHARED_DATA
|
|
{
|
|
/**
|
|
* Lock used to synchronize updates to the timing fields.
|
|
*
|
|
* The hypervisor increments this value before and after updating the
|
|
* QPC multiplier and bias. User-mode callers can sample this value
|
|
* before and after reading the timing fields to detect whether an
|
|
* update occurred mid-read and retry if necessary.
|
|
*/
|
|
volatile ULONG TimeUpdateLock;
|
|
|
|
/**
|
|
* Reserved field - The hypervisor does not assign this field.
|
|
*/
|
|
ULONG Reserved0;
|
|
|
|
/**
|
|
* Multiplier used to convert hypervisor QPC ticks to host time.
|
|
*
|
|
* This value is applied to the hypervisor's virtualized performance
|
|
* counter to compute a stable, high-resolution timebase. The multiplier
|
|
* is chosen by the hypervisor based on the underlying hardware timer
|
|
* source and virtualization mode.
|
|
*/
|
|
ULONGLONG QpcMultiplier;
|
|
|
|
/**
|
|
* Bias applied after QPC multiplication to produce final time.
|
|
*
|
|
* The hypervisor uses this bias to align the virtualized QPC value with
|
|
* the host's notion of system time. Combined with QpcMultiplier, this
|
|
* allows user-mode components to compute consistent time values even
|
|
* under virtualization.
|
|
*/
|
|
ULONGLONG QpcBias;
|
|
|
|
ULONGLONG InterruptTimeQpcBaseline;
|
|
ULONGLONG QpcMultiplierFactor; // ARM64
|
|
} SYSTEM_HYPERVISOR_USER_SHARED_DATA, *PSYSTEM_HYPERVISOR_USER_SHARED_DATA;
|
|
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_SHARED_PAGE_INFORMATION structure describes
|
|
* the user-mode mapping of the hypervisor shared page.
|
|
*
|
|
* This structure provides the virtual address at which the hypervisor's
|
|
* user-accessible shared data page is mapped. When a hypervisor is present,
|
|
* the kernel maps a read-only page into user mode containing timing and
|
|
* virtualization-related information (see SYSTEM_HYPERVISOR_USER_SHARED_DATA).
|
|
*
|
|
* User-mode components can read this page directly to obtain high-resolution
|
|
* time conversion parameters or other hypervisor-provided data without
|
|
* requiring a hypercall or kernel transition.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_SHARED_PAGE_INFORMATION
|
|
{
|
|
/**
|
|
* User-mode virtual address of the hypervisor shared data page.
|
|
* If no hypervisor is present, this pointer is NULL.
|
|
*/
|
|
PSYSTEM_HYPERVISOR_USER_SHARED_DATA HypervisorSharedUserVa;
|
|
} SYSTEM_HYPERVISOR_SHARED_PAGE_INFORMATION, *PSYSTEM_HYPERVISOR_SHARED_PAGE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_PARTITION_INFORMATION structure contains system firmware partition information.
|
|
*/
|
|
typedef struct _SYSTEM_FIRMWARE_PARTITION_INFORMATION
|
|
{
|
|
UNICODE_STRING FirmwarePartition;
|
|
} SYSTEM_FIRMWARE_PARTITION_INFORMATION, *PSYSTEM_FIRMWARE_PARTITION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SPECULATION_CONTROL_INFORMATION structure contains the state of the processor speculation-control mitigations.
|
|
*/
|
|
typedef struct _SYSTEM_SPECULATION_CONTROL_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
ULONG BpbEnabled : 1;
|
|
ULONG BpbDisabledSystemPolicy : 1;
|
|
ULONG BpbDisabledNoHardwareSupport : 1;
|
|
ULONG SpecCtrlEnumerated : 1;
|
|
ULONG SpecCmdEnumerated : 1;
|
|
ULONG IbrsPresent : 1;
|
|
ULONG StibpPresent : 1;
|
|
ULONG SmepPresent : 1;
|
|
ULONG SpeculativeStoreBypassDisableAvailable : 1; // REDSTONE4 (CVE-2018-3639)
|
|
ULONG SpeculativeStoreBypassDisableSupported : 1;
|
|
ULONG SpeculativeStoreBypassDisabledSystemWide : 1;
|
|
ULONG SpeculativeStoreBypassDisabledKernel : 1;
|
|
ULONG SpeculativeStoreBypassDisableRequired : 1;
|
|
ULONG BpbDisabledKernelToUser : 1;
|
|
ULONG SpecCtrlRetpolineEnabled : 1;
|
|
ULONG SpecCtrlImportOptimizationEnabled : 1;
|
|
ULONG EnhancedIbrs : 1; // since 19H1
|
|
ULONG HvL1tfStatusAvailable : 1;
|
|
ULONG HvL1tfProcessorNotAffected : 1;
|
|
ULONG HvL1tfMigitationEnabled : 1;
|
|
ULONG HvL1tfMigitationNotEnabled_Hardware : 1;
|
|
ULONG HvL1tfMigitationNotEnabled_LoadOption : 1;
|
|
ULONG HvL1tfMigitationNotEnabled_CoreScheduler : 1;
|
|
ULONG EnhancedIbrsReported : 1;
|
|
ULONG MdsHardwareProtected : 1; // since 19H2
|
|
ULONG MbClearEnabled : 1;
|
|
ULONG MbClearReported : 1;
|
|
ULONG ReservedTaa : 4;
|
|
ULONG Reserved : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
} SpeculationControlFlags;
|
|
union
|
|
{
|
|
ULONG Flags; // since 23H2
|
|
struct
|
|
{
|
|
ULONG SbdrSsdpHardwareProtected : 1;
|
|
ULONG FbsdpHardwareProtected : 1;
|
|
ULONG PsdpHardwareProtected : 1;
|
|
ULONG FbClearEnabled : 1;
|
|
ULONG FbClearReported : 1;
|
|
ULONG BhbEnabled : 1;
|
|
ULONG BhbDisabledSystemPolicy : 1;
|
|
ULONG BhbDisabledNoHardwareSupport : 1;
|
|
ULONG BranchConfusionStatus : 2;
|
|
ULONG BranchConfusionReported : 1;
|
|
ULONG RdclHardwareProtectedReported : 1;
|
|
ULONG RdclHardwareProtected : 1;
|
|
ULONG Reserved3 : 4;
|
|
ULONG Reserved4 : 3;
|
|
ULONG DivideByZeroReported : 1;
|
|
ULONG DivideByZeroStatus : 1;
|
|
ULONG Reserved5 : 3;
|
|
ULONG Reserved : 7;
|
|
} DUMMYSTRUCTNAME;
|
|
} SpeculationControlFlags2;
|
|
} SYSTEM_SPECULATION_CONTROL_INFORMATION, *PSYSTEM_SPECULATION_CONTROL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_DMA_GUARD_POLICY_INFORMATION structure contains the kernel DMA protection policy state.
|
|
*/
|
|
typedef struct _SYSTEM_DMA_GUARD_POLICY_INFORMATION
|
|
{
|
|
BOOLEAN DmaGuardPolicyEnabled;
|
|
} SYSTEM_DMA_GUARD_POLICY_INFORMATION, *PSYSTEM_DMA_GUARD_POLICY_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ENCLAVE_LAUNCH_CONTROL_INFORMATION structure contains system enclave launch control information.
|
|
*/
|
|
typedef struct _SYSTEM_ENCLAVE_LAUNCH_CONTROL_INFORMATION
|
|
{
|
|
UCHAR EnclaveLaunchSigner[32];
|
|
} SYSTEM_ENCLAVE_LAUNCH_CONTROL_INFORMATION, *PSYSTEM_ENCLAVE_LAUNCH_CONTROL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION structure contains system workload allowed CPU set information.
|
|
*/
|
|
typedef struct _SYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION
|
|
{
|
|
ULONGLONG WorkloadClass;
|
|
ULONGLONG CpuSets[1];
|
|
} SYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION, *PSYSTEM_WORKLOAD_ALLOWED_CPU_SET_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECURITY_MODEL_INFORMATION structure contains system security model information.
|
|
*/
|
|
typedef struct _SYSTEM_SECURITY_MODEL_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG SecurityModelFlags;
|
|
struct
|
|
{
|
|
ULONG ReservedFlag : 1; // SModeAdminlessEnabled
|
|
ULONG AllowDeviceOwnerProtectionDowngrade : 1;
|
|
ULONG Reserved : 30;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_SECURITY_MODEL_INFORMATION, *PSYSTEM_SECURITY_MODEL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* Decodes secure-kernel speculation mitigations returned by SystemSecureSpeculationControlInformation (213).
|
|
* Flags is the raw first ULONG; the named fields occupy consecutive bits, not overlapping union members.
|
|
* On x64, KeQuerySecureSpeculationInformation accepts at least 4 bytes,
|
|
* clears the supplied output buffer, and populates bits 0-15. It reports ReturnLength == 8
|
|
* even for a successful 4-byte query; additional returned bytes are zero in this implementation.
|
|
* The Ssbs fields describe architecture-specific state; do not infer ARM behavior from x64 results.
|
|
*/
|
|
typedef union _SECURE_SPECULATION_CONTROL_INFORMATION
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
ULONG KvaShadowSupported : 1;
|
|
ULONG KvaShadowEnabled : 1;
|
|
ULONG KvaShadowUserGlobal : 1;
|
|
ULONG KvaShadowPcid : 1;
|
|
ULONG MbClearEnabled : 1;
|
|
ULONG L1TFMitigated : 1; // since 20H2
|
|
ULONG BpbEnabled : 1;
|
|
ULONG IbrsPresent : 1;
|
|
ULONG EnhancedIbrs : 1;
|
|
ULONG StibpPresent : 1;
|
|
ULONG SsbdSupported : 1;
|
|
ULONG SsbdRequired : 1;
|
|
ULONG BpbKernelToUser : 1;
|
|
ULONG BpbUserToKernel : 1;
|
|
ULONG ReturnSpeculate : 1;
|
|
ULONG BranchConfusionSafe : 1;
|
|
ULONG SsbsEnabledAlways : 1; // 24H2
|
|
ULONG SsbsEnabledKernel : 1;
|
|
ULONG Reserved : 14;
|
|
} DUMMYSTRUCTNAME;
|
|
} SECURE_SPECULATION_CONTROL_INFORMATION, *PSECURE_SPECULATION_CONTROL_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_FIRMWARE_RAMDISK_INFORMATION structure contains system firmware ramdisk information.
|
|
*/
|
|
typedef struct _SYSTEM_FIRMWARE_RAMDISK_INFORMATION
|
|
{
|
|
ULONG Version;
|
|
ULONG BlockSize;
|
|
ULONG_PTR BaseAddress;
|
|
SIZE_T Size;
|
|
} SYSTEM_FIRMWARE_RAMDISK_INFORMATION, *PSYSTEM_FIRMWARE_RAMDISK_INFORMATION;
|
|
|
|
// rev
|
|
/**
|
|
* Legacy WHEA/IPMI declaration retained from the existing header; its Windows 10
|
|
* layout was not established. It is NOT the 32-byte SystemWheaIpmiHardwareInformation
|
|
* output described below.
|
|
*/
|
|
typedef struct _SYSTEM_WHEA_IPMI_HARDWARE_INFORMATION_WIN10
|
|
{
|
|
ULONGLONG RecordId; // IPMI SEL (System Event Log) record identifier
|
|
UCHAR EventType; // IPMI event/reading type code
|
|
UCHAR SensorType; // IPMI sensor type (e.g. temperature, voltage, processor)
|
|
USHORT GeneratorId; // ID of the entity that logged the event
|
|
UCHAR EvmRevision; // Event Message format revision
|
|
UCHAR RecordType; // SEL record type (e.g. system event vs OEM)
|
|
UCHAR Data[4]; // Event-specific data bytes
|
|
} SYSTEM_WHEA_IPMI_HARDWARE_INFORMATION_WIN10, *PSYSTEM_WHEA_IPMI_HARDWARE_INFORMATION_WIN10;
|
|
|
|
// rev: WheaQuerySystemInformation, IpmiHwpParseSpmiTable, IpmiLibpParseDeviceInfo
|
|
/**
|
|
* Describes the IPMI controller used by WHEA, not an IPMI SEL event record.
|
|
* The x64 SystemWheaIpmiHardwareInformation (216) query requires
|
|
* exactly 32 output bytes. WheaQuerySystemInformation copies the first
|
|
* 32 bytes of WheaIpmiContext after checking that the context is initialized.
|
|
* Use this information to identify the firmware-described IPMI interface.
|
|
* The mapped register VA, MMIO mapping length and initialization flag belong
|
|
* to the larger private context and are NOT part of this query result.
|
|
* Field names below are descriptive reconstructions from the parser/consumer.
|
|
*/
|
|
typedef struct _SYSTEM_WHEA_IPMI_HARDWARE_INFORMATION
|
|
{
|
|
USHORT IpmiSpecVersion; // packed major/minor nibbles; 0x15 = 1.5, 0x20 = 2.0.
|
|
USHORT Reserved02; // alignment padding; no field access found.
|
|
ULONG InterfaceType; // firmware interface code; the KCS handler requires 1.
|
|
UCHAR RegisterSpacing; // SPMI maps 1/2/3/4 to 1/2/4/8; SMBIOS maps 0/1/2 to 1/4/16.
|
|
UCHAR Reserved09[7]; // alignment padding; no field access found.
|
|
ULONGLONG BaseAddress; // physical MMIO or I/O-port base, not a mapped virtual address.
|
|
UCHAR AddressSpaceType; // zero selects MMIO; nonzero selects port I/O in the KCS consumer.
|
|
UCHAR BmcSlaveAddress; // SPMI default 0x20, or SMBIOS type-38 byte 6 & 0xFE; SEL request destination.
|
|
UCHAR Reserved1A[6]; // tail padding; no field access found.
|
|
} SYSTEM_WHEA_IPMI_HARDWARE_INFORMATION, *PSYSTEM_WHEA_IPMI_HARDWARE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SHADOW_STACK_INFORMATION structure contains hardware-enforced shadow stack (CET) capability and enablement flags for user and kernel mode.
|
|
*/
|
|
typedef struct _SYSTEM_SHADOW_STACK_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
ULONG CetCapable : 1;
|
|
ULONG UserCetAllowed : 1;
|
|
ULONG ReservedForUserCet : 6;
|
|
ULONG KernelCetEnabled : 1;
|
|
ULONG KernelCetAuditModeEnabled : 1;
|
|
ULONG ReservedForKernelCet : 6; // since Windows 10 build 21387
|
|
ULONG Reserved : 16;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_SHADOW_STACK_INFORMATION, *PSYSTEM_SHADOW_STACK_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SPACES_BOOT_INFORMATION structure contains system spaces boot information.
|
|
*/
|
|
typedef struct _SYSTEM_SPACES_BOOT_INFORMATION
|
|
{
|
|
/**
|
|
* Opaque variable-length blob copied from ExpSpacesBootInformation.
|
|
*
|
|
* The returned byte count is reported via ReturnLength.
|
|
* NtQuerySystemInformationEx rejects user-mode callers for this class.
|
|
*/
|
|
UCHAR Data[1];
|
|
} SYSTEM_SPACES_BOOT_INFORMATION, *PSYSTEM_SPACES_BOOT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BUILD_VERSION_INFORMATION_INPUT structure specifies the input parameters for a system build version information query.
|
|
*/
|
|
typedef struct _SYSTEM_BUILD_VERSION_INFORMATION_INPUT
|
|
{
|
|
ULONG LayerNumber;
|
|
} SYSTEM_BUILD_VERSION_INFORMATION_INPUT, *PSYSTEM_BUILD_VERSION_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BUILD_VERSION_INFORMATION_FLAGS union defines the system build version information flags.
|
|
*/
|
|
typedef union _SYSTEM_BUILD_VERSION_INFORMATION_FLAGS
|
|
{
|
|
ULONG Value32;
|
|
struct
|
|
{
|
|
ULONG IsTopLevel : 1;
|
|
ULONG IsChecked : 1;
|
|
|
|
ULONG Reserved : 1;
|
|
ULONG HasMajorVersion : 1; // MajorVersion present
|
|
ULONG HasMinorVersion : 1; // MinorVersion present
|
|
ULONG HasBuildNumber : 1; // BuildNumber present
|
|
ULONG HasBuildQfe : 1; // BuildQfe present
|
|
ULONG HasString0 : 1; // optional string #1 present
|
|
ULONG HasString1 : 1; // optional string #2 present
|
|
ULONG HasString2 : 1; // optional string #3 present
|
|
ULONG HasString3 : 1; // optional string #4 present
|
|
ULONG HasString4 : 1; // optional string #5 present
|
|
ULONG Spare : 20;
|
|
} DUMMYSTRUCTNAME;
|
|
} SYSTEM_BUILD_VERSION_INFORMATION_FLAGS, *PSYSTEM_BUILD_VERSION_INFORMATION_FLAGS;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_BUILD_VERSION_INFORMATION structure contains system build version information.
|
|
*/
|
|
typedef struct _SYSTEM_BUILD_VERSION_INFORMATION
|
|
{
|
|
USHORT LayerNumber;
|
|
USHORT LayerCount;
|
|
ULONG OsMajorVersion;
|
|
ULONG OsMinorVersion;
|
|
ULONG NtBuildNumber;
|
|
ULONG NtBuildQfe;
|
|
UCHAR LayerName[128];
|
|
UCHAR NtBuildBranch[128];
|
|
UCHAR NtBuildLab[128];
|
|
UCHAR NtBuildLabEx[128];
|
|
UCHAR NtBuildStamp[26];
|
|
UCHAR NtBuildArch[16];
|
|
SYSTEM_BUILD_VERSION_INFORMATION_FLAGS Flags;
|
|
} SYSTEM_BUILD_VERSION_INFORMATION, *PSYSTEM_BUILD_VERSION_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION_INPUT structure specifies the input parameters for a system secure kernel debugger information query.
|
|
*/
|
|
typedef struct _SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION_INPUT
|
|
{
|
|
ULONG Version;
|
|
ULONG Reserved[3];
|
|
ULONG MinimumImageVersion;
|
|
} SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION_INPUT, *PSYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION structure contains system secure kernel debugger information.
|
|
*/
|
|
typedef struct _SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION
|
|
{
|
|
ULONG Version;
|
|
BOOLEAN Enabled;
|
|
} SYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION, *PSYSTEM_SECURE_KERNEL_DEBUGGER_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_POOL_LIMIT_MEM_INFO structure contains system pool limit mem information.
|
|
*/
|
|
typedef struct _SYSTEM_POOL_LIMIT_MEM_INFO
|
|
{
|
|
ULONGLONG MemoryLimit;
|
|
ULONGLONG NotificationLimit;
|
|
} SYSTEM_POOL_LIMIT_MEM_INFO, *PSYSTEM_POOL_LIMIT_MEM_INFO;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_POOL_LIMIT_INFO structure contains system pool limit information.
|
|
*/
|
|
typedef struct _SYSTEM_POOL_LIMIT_INFO
|
|
{
|
|
ULONG PoolTag;
|
|
SYSTEM_POOL_LIMIT_MEM_INFO MemLimits[2];
|
|
WNF_STATE_NAME NotificationHandle;
|
|
} SYSTEM_POOL_LIMIT_INFO, *PSYSTEM_POOL_LIMIT_INFO;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_POOL_LIMIT_INFORMATION structure contains system pool limit information.
|
|
*/
|
|
typedef struct _SYSTEM_POOL_LIMIT_INFORMATION
|
|
{
|
|
ULONG Version;
|
|
ULONG EntryCount;
|
|
_Field_size_(EntryCount) SYSTEM_POOL_LIMIT_INFO LimitEntries[1];
|
|
} SYSTEM_POOL_LIMIT_INFORMATION, *PSYSTEM_POOL_LIMIT_INFORMATION;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_DYNAMIC_STORE structure describes the Code Integrity dynamic policy store.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_DYNAMIC_STORE
|
|
{
|
|
HANDLE StoreHandle;
|
|
ULONG StoreFlags;
|
|
PVOID StoreData;
|
|
SIZE_T StoreSize;
|
|
} SYSTEM_CODE_INTEGRITY_DYNAMIC_STORE, *PSYSTEM_CODE_INTEGRITY_DYNAMIC_STORE;
|
|
|
|
// private
|
|
//typedef struct _SYSTEM_POOL_ZEROING_INFORMATION
|
|
//{
|
|
// BOOLEAN PoolZeroingSupportPresent;
|
|
//} SYSTEM_POOL_ZEROING_INFORMATION, *PSYSTEM_POOL_ZEROING_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The HV_MINROOT_NUMA_LPS structure describes the HV minroot NUMA lps.
|
|
*/
|
|
typedef struct _HV_MINROOT_NUMA_LPS
|
|
{
|
|
ULONG NodeIndex;
|
|
ULONG_PTR Mask[16];
|
|
} HV_MINROOT_NUMA_LPS, *PHV_MINROOT_NUMA_LPS;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_XFG_FAILURE_INFORMATION structure contains system XFG failure information.
|
|
*/
|
|
typedef struct _SYSTEM_XFG_FAILURE_INFORMATION
|
|
{
|
|
PVOID ReturnAddress;
|
|
PVOID TargetAddress;
|
|
ULONG DispatchMode;
|
|
ULONGLONG XfgValue;
|
|
} SYSTEM_XFG_FAILURE_INFORMATION, *PSYSTEM_XFG_FAILURE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_IOMMU_STATE enumeration defines the possible system IOMMU states.
|
|
*/
|
|
typedef enum _SYSTEM_IOMMU_STATE
|
|
{
|
|
IommuStateBlock,
|
|
IommuStateUnblock
|
|
} SYSTEM_IOMMU_STATE;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_IOMMU_STATE_INFORMATION structure contains system IOMMU state information.
|
|
*/
|
|
typedef struct _SYSTEM_IOMMU_STATE_INFORMATION
|
|
{
|
|
SYSTEM_IOMMU_STATE State;
|
|
PVOID Pdo;
|
|
} SYSTEM_IOMMU_STATE_INFORMATION, *PSYSTEM_IOMMU_STATE_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_MINROOT_INFORMATION structure contains system hypervisor minroot information.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_MINROOT_INFORMATION
|
|
{
|
|
ULONG NumProc;
|
|
ULONG RootProc;
|
|
ULONG RootProcNumaNodesSpecified;
|
|
USHORT RootProcNumaNodes[64];
|
|
ULONG RootProcPerCore;
|
|
ULONG RootProcPerNode;
|
|
ULONG RootProcNumaNodesLpsSpecified;
|
|
HV_MINROOT_NUMA_LPS RootProcNumaNodeLps[64];
|
|
} SYSTEM_HYPERVISOR_MINROOT_INFORMATION, *PSYSTEM_HYPERVISOR_MINROOT_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_HYPERVISOR_BOOT_PAGES_INFORMATION structure contains system hypervisor boot pages information.
|
|
*/
|
|
typedef struct _SYSTEM_HYPERVISOR_BOOT_PAGES_INFORMATION
|
|
{
|
|
ULONG RangeCount;
|
|
ULONG_PTR RangeArray[1];
|
|
} SYSTEM_HYPERVISOR_BOOT_PAGES_INFORMATION, *PSYSTEM_HYPERVISOR_BOOT_PAGES_INFORMATION;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_POINTER_AUTH_INFORMATION structure contains system pointer auth information.
|
|
*/
|
|
typedef struct _SYSTEM_POINTER_AUTH_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
USHORT SupportedFlags;
|
|
struct
|
|
{
|
|
USHORT AddressAuthSupported : 1;
|
|
USHORT AddressAuthQarma : 1;
|
|
USHORT GenericAuthSupported : 1;
|
|
USHORT GenericAuthQarma : 1;
|
|
USHORT AddressAuthFaulting : 1;
|
|
USHORT SupportedReserved : 11;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
union
|
|
{
|
|
USHORT EnabledFlags;
|
|
struct
|
|
{
|
|
USHORT UserPerProcessIpAuthEnabled : 1;
|
|
USHORT UserGlobalIpAuthEnabled : 1;
|
|
USHORT UserEnabledReserved : 6;
|
|
USHORT KernelIpAuthEnabled : 1;
|
|
USHORT KernelEnabledReserved : 7;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME2;
|
|
} SYSTEM_POINTER_AUTH_INFORMATION, *PSYSTEM_POINTER_AUTH_INFORMATION;
|
|
|
|
// rev
|
|
#define SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_VERSION 1 // Current protocol version for input/output structures.
|
|
|
|
/**
|
|
* Query interface for checking whether a named Windows feature flag is enabled for an image's
|
|
* "born-on" Windows version — the OS version the image was originally built or linked against.
|
|
* In observed logic, the decision is based on OriginalImageVersion for the image context plus the
|
|
* caller-provided BornOnVersion. This is image-compat metadata, not simply current OS version.
|
|
* A plain OS upgrade does not automatically guarantee the result flips to enabled for an existing
|
|
* old image. It can become enabled if the relevant image/component is updated or replaced so its
|
|
* original-image version context is newer and passes the threshold. The code path only reports
|
|
* eligibility in FeatureIsEnabled and does not directly enable a feature system-wide.
|
|
* So think of it as compatibility gating tied to image provenance, not a global switch that turns on when Windows version increases.
|
|
*/
|
|
typedef struct _SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_INPUT
|
|
{
|
|
ULONG Version; // Must be set to SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_VERSION (1).
|
|
PWSTR FeatureName; // Wide string naming the feature to query. Not consulted by the kernel in observed builds; reserved for future use.
|
|
ULONG BornOnVersion; // Windows version number the image was originally targeted at; compared against OriginalImageVersion.
|
|
} SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_INPUT, *PSYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_OUTPUT structure receives the output of a system original image feature information query.
|
|
*/
|
|
typedef struct _SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_OUTPUT
|
|
{
|
|
ULONG Version; // Echoes back the protocol version.
|
|
BOOLEAN FeatureIsEnabled; // Eligibility result only; TRUE/FALSE does not directly toggle a system-wide feature state.
|
|
} SYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_OUTPUT, *PSYSTEM_ORIGINAL_IMAGE_FEATURE_INFORMATION_OUTPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_INFORMATION_INPUT structure specifies the input parameters for a system memory NUMA information query.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_INFORMATION_INPUT
|
|
{
|
|
ULONG Version;
|
|
ULONG TargetNodeNumber;
|
|
ULONG Flags;
|
|
} SYSTEM_MEMORY_NUMA_INFORMATION_INPUT, *PSYSTEM_MEMORY_NUMA_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_INFORMATION_OUTPUT structure receives the output of a system memory NUMA information query.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_INFORMATION_OUTPUT
|
|
{
|
|
ULONG Version;
|
|
ULONG Size;
|
|
ULONG InitiatorNode;
|
|
union
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
ULONG IsAttached : 1;
|
|
ULONG Reserved : 31;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
} SYSTEM_MEMORY_NUMA_INFORMATION_OUTPUT, *PSYSTEM_MEMORY_NUMA_INFORMATION_OUTPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_PERFORMANCE_QUERY_DATA_TYPES enumeration defines the system memory NUMA performance query data types values.
|
|
*/
|
|
typedef enum _SYSTEM_MEMORY_NUMA_PERFORMANCE_QUERY_DATA_TYPES
|
|
{
|
|
SystemMemoryNumaPerformanceQuery_ReadLatency,
|
|
SystemMemoryNumaPerformanceQuery_ReadBandwidth,
|
|
SystemMemoryNumaPerformanceQuery_WriteLatency,
|
|
SystemMemoryNumaPerformanceQuery_WriteBandwidth,
|
|
SystemMemoryNumaPerformanceQuery_Latency,
|
|
SystemMemoryNumaPerformanceQuery_Bandwidth,
|
|
SystemMemoryNumaPerformanceQuery_AllDataTypes,
|
|
SystemMemoryNumaPerformanceQuery_MaxDataType
|
|
} SYSTEM_MEMORY_NUMA_PERFORMANCE_QUERY_DATA_TYPES;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_INPUT structure specifies the input parameters for a system memory NUMA performance information query.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_INPUT
|
|
{
|
|
ULONG Version;
|
|
ULONG TargetNodeNumber;
|
|
SYSTEM_MEMORY_NUMA_PERFORMANCE_QUERY_DATA_TYPES QueryDataType;
|
|
ULONG Flags;
|
|
} SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_INPUT, *PSYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_INPUT;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_PERFORMANCE_ENTRY structure describes a single system memory NUMA performance entry.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_PERFORMANCE_ENTRY
|
|
{
|
|
ULONG InitiatorNodeNumber;
|
|
ULONG TargetNodeNumber;
|
|
SYSTEM_MEMORY_NUMA_PERFORMANCE_QUERY_DATA_TYPES DataType;
|
|
union
|
|
{
|
|
BOOLEAN Flags;
|
|
struct
|
|
{
|
|
BOOLEAN MinTransferSizeToAchieveValues : 1;
|
|
BOOLEAN NonSequentialTransfers : 1;
|
|
BOOLEAN Reserved : 6;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
SIZE_T MinTransferSizeInBytes;
|
|
ULONG_PTR EntryValue;
|
|
} SYSTEM_MEMORY_NUMA_PERFORMANCE_ENTRY, *PSYSTEM_MEMORY_NUMA_PERFORMANCE_ENTRY;
|
|
|
|
// private
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_OUTPUT structure receives the output of a system memory NUMA performance information query.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_OUTPUT
|
|
{
|
|
ULONG Version;
|
|
ULONG Size;
|
|
ULONG EntryCount;
|
|
SYSTEM_MEMORY_NUMA_PERFORMANCE_ENTRY PerformanceEntries[1];
|
|
} SYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_OUTPUT, *PSYSTEM_MEMORY_NUMA_PERFORMANCE_INFORMATION_OUTPUT;
|
|
|
|
/**
|
|
* The SYSTEM_OSL_RAMDISK_ENTRY structure describes a single RAM disk region
|
|
* used by the operating system loader.
|
|
*/
|
|
typedef struct _SYSTEM_OSL_RAMDISK_ENTRY
|
|
{
|
|
ULONG BlockSize;
|
|
PVOID BaseAddress;
|
|
SIZE_T Size;
|
|
} SYSTEM_OSL_RAMDISK_ENTRY, *PSYSTEM_OSL_RAMDISK_ENTRY;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_SIGNED_POLICIES structure describes the signed Code Integrity policies.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_SIGNED_POLICIES
|
|
{
|
|
BOOLEAN EnabledPolicies;
|
|
ULONGLONG SignedPoliciesData;
|
|
ULONG PolicySize;
|
|
ULONG SignatureSize;
|
|
UCHAR SignatureBuffer[0x100];
|
|
} SYSTEM_CODE_INTEGRITY_SIGNED_POLICIES, *PSYSTEM_CODE_INTEGRITY_SIGNED_POLICIES;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_SECURE_CORE_INFORMATION structure contains system secure core information.
|
|
*/
|
|
typedef struct _SYSTEM_SECURE_CORE_INFORMATION
|
|
{
|
|
BOOLEAN IsSecureCore;
|
|
ULONGLONG SecureKernelRunning;
|
|
ULONGLONG VslFeatures;
|
|
} SYSTEM_SECURE_CORE_INFORMATION, *PSYSTEM_SECURE_CORE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_TRUSTEDAPPS_RUNTIME_INFORMATION structure describes runtime
|
|
* information related to Trusted Apps support.
|
|
*/
|
|
typedef struct _SYSTEM_TRUSTEDAPPS_RUNTIME_INFORMATION
|
|
{
|
|
union
|
|
{
|
|
ULONGLONG Flags;
|
|
struct
|
|
{
|
|
ULONGLONG Supported : 1;
|
|
ULONGLONG Spare : 63;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
PVOID RemoteBreakingRoutine;
|
|
} SYSTEM_TRUSTEDAPPS_RUNTIME_INFORMATION, *PSYSTEM_TRUSTEDAPPS_RUNTIME_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_OSL_RAMDISK_INFORMATION structure describes a variable-length
|
|
* array of RAM disk entries used by the operating system loader.
|
|
*/
|
|
typedef struct _SYSTEM_OSL_RAMDISK_INFORMATION
|
|
{
|
|
ULONG Version;
|
|
ULONG Count;
|
|
SYSTEM_OSL_RAMDISK_ENTRY Entries[1];
|
|
} SYSTEM_OSL_RAMDISK_INFORMATION, *PSYSTEM_OSL_RAMDISK_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION enumeration specifies the type of Code Integrity
|
|
* policy management operation requested.
|
|
*/
|
|
typedef enum _SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION
|
|
{
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_NONE = 0,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_OPEN_TX = 1,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_COMMIT_TX = 2,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_CLOSE_TX = 3,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_ADD_POLICY = 4,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_REMOVE_POLICY = 5,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_GET_POLICY = 6,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_GET_POLICY_IDS = 7,
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION_MAX = 8
|
|
} SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION;
|
|
|
|
/**
|
|
* The SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT structure describes parameters
|
|
* used to manage Code Integrity policies through the system information
|
|
* interface.
|
|
*/
|
|
typedef struct _SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT
|
|
{
|
|
SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT_OPERATION Operation;
|
|
UCHAR UseInProgressState;
|
|
ULONG Arg1Len;
|
|
PUCHAR Arg1;
|
|
ULONG Arg2Len;
|
|
PUCHAR Arg2;
|
|
} SYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT, *PSYSTEM_CODEINTEGRITY_POLICY_MANAGEMENT;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_CACHE_ENTRY structure describes a single system memory NUMA cache entry.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_CACHE_ENTRY
|
|
{
|
|
ULONG CacheNode;
|
|
ULONG CacheLevel;
|
|
ULONG CacheSize;
|
|
ULONG CacheLineSize;
|
|
ULONG CacheType;
|
|
ULONG CacheAttributes;
|
|
ULONG CacheFlags;
|
|
UCHAR Present;
|
|
UCHAR Reserved[3];
|
|
} SYSTEM_MEMORY_NUMA_CACHE_ENTRY, *PSYSTEM_MEMORY_NUMA_CACHE_ENTRY;
|
|
|
|
// rev
|
|
/**
|
|
* The SYSTEM_MEMORY_NUMA_CACHE_INFORMATION structure contains system memory NUMA cache information.
|
|
*/
|
|
typedef struct _SYSTEM_MEMORY_NUMA_CACHE_INFORMATION
|
|
{
|
|
ULONG Version; // always 1
|
|
ULONG Size; // total bytes written, aligned to 0x20
|
|
ULONG EntryCount; // number of cache entries
|
|
ULONG Reserved; // appears to stay zero
|
|
SYSTEM_MEMORY_NUMA_CACHE_ENTRY Entries[1]; // Followed by EntryCount records, each 0x20 bytes
|
|
} SYSTEM_MEMORY_NUMA_CACHE_INFORMATION, *PSYSTEM_MEMORY_NUMA_CACHE_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_REF_TRACE_INFORMATION_EX structure describes configuration
|
|
* parameters for object reference tracing.
|
|
*/
|
|
typedef struct _SYSTEM_REF_TRACE_INFORMATION_EX
|
|
{
|
|
ULONG Version;
|
|
ULONGLONG MemoryLimits;
|
|
union
|
|
{
|
|
ULONG Flags;
|
|
struct
|
|
{
|
|
ULONG TraceEnable : 1;
|
|
ULONG TracePermanent : 1;
|
|
ULONG UseTracePoolTags : 1;
|
|
ULONG TraceByStacksOnly : 1;
|
|
ULONG ReservedFlags : 28;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
UNICODE_STRING TraceProcessName;
|
|
UNICODE_STRING TracePoolTags;
|
|
ULONG MaxObjectRefTraces;
|
|
ULONG TracedObjectLimit;
|
|
} SYSTEM_REF_TRACE_INFORMATION_EX, *PSYSTEM_REF_TRACE_INFORMATION_EX;
|
|
|
|
/**
|
|
* The SYSTEM_BASICPROCESS_INFORMATION structure describes basic process
|
|
* information returned when enumerating processes.
|
|
*/
|
|
_Struct_size_bytes_(NextEntryOffset)
|
|
typedef struct _SYSTEM_BASICPROCESS_INFORMATION
|
|
{
|
|
ULONG NextEntryOffset;
|
|
HANDLE UniqueProcessId;
|
|
HANDLE InheritedFromUniqueProcessId;
|
|
ULONG64 SequenceNumber;
|
|
UNICODE_STRING ImageName;
|
|
} SYSTEM_BASICPROCESS_INFORMATION, *PSYSTEM_BASICPROCESS_INFORMATION;
|
|
|
|
/**
|
|
* The SYSTEM_HANDLECOUNT_INFORMATION structure provides global counts of
|
|
* processes, threads, and handles in the system.
|
|
*/
|
|
typedef struct _SYSTEM_HANDLECOUNT_INFORMATION
|
|
{
|
|
ULONG ProcessCount;
|
|
ULONG ThreadCount;
|
|
ULONG HandleCount;
|
|
} SYSTEM_HANDLECOUNT_INFORMATION, *PSYSTEM_HANDLECOUNT_INFORMATION;
|
|
|
|
//
|
|
// Runtime Report Definitions
|
|
//
|
|
|
|
#define SYSTEM_RUNTIME_REPORT_INPUT_VERSION_1 1
|
|
#define SYSTEM_RUNTIME_REPORT_INPUT_PACKAGE_VERSION_1 1
|
|
|
|
// private
|
|
/**
|
|
* Requests a signed runtime-attestation report through NtQuerySystemInformationEx
|
|
* with SystemRuntimeAttestationReport (254). InputBufferLength must be exactly 48
|
|
* bytes on x64. InputVersion and PackageVersion must both be 1,
|
|
* and the implementation accepts only ReportTypesBitmap == 1. Nonce supplies 32 caller bytes.
|
|
* A NULL output buffer with zero output length requests the required report size;
|
|
* a non-NULL output buffer must have a nonzero length. The output is a report-package
|
|
* byte buffer, not another SYSTEM_RUNTIME_REPORT_INPUT.
|
|
*/
|
|
typedef struct _SYSTEM_RUNTIME_REPORT_INPUT
|
|
{
|
|
USHORT InputVersion;
|
|
USHORT PackageVersion;
|
|
ULONG Reserved;
|
|
ULONG_PTR ReportTypesBitmap;
|
|
UCHAR Nonce[32];
|
|
} SYSTEM_RUNTIME_REPORT_INPUT, *PSYSTEM_RUNTIME_REPORT_INPUT;
|
|
|
|
#if defined(SYSTEM_RUNTIME_REPORT)
|
|
//
|
|
// ===============================================
|
|
// Runtime Report Package Format:
|
|
//
|
|
// ------------------------------------- Signed part Begin
|
|
//
|
|
// RUNTIME_REPORT_PACKAGE_HEADER
|
|
//
|
|
// BYTE Nonce[RUNTIME_REPORT_NONCE_SIZE]
|
|
//
|
|
// RUNTIME_REPORT_DIGEST_HEADER_A
|
|
//
|
|
// RUNTIME_REPORT_DIGEST_HEADER_B
|
|
// ...
|
|
// ...
|
|
//
|
|
// ------------------------------------- Signed part End
|
|
//
|
|
// Signature Blob
|
|
//
|
|
// ------------------------------------- Authenticated part Begin
|
|
//
|
|
// RUNTIME_REPORT_HEADER
|
|
// REPORT_A
|
|
//
|
|
// RUNTIME_REPORT_HEADER
|
|
// REPORT_B
|
|
//
|
|
// ------------------------------------- Authenticated part End
|
|
//
|
|
// ===============================================
|
|
//
|
|
|
|
#define RUNTIME_REPORT_PACKAGE_MAGIC 0x52545250 // = "RTRP"
|
|
#define RUNTIME_REPORT_PACKAGE_VERSION_CURRENT (1)
|
|
#define RUNTIME_REPORT_NONCE_SIZE 32
|
|
#define RUNTIME_REPORT_DIGEST_MAX_SIZE 64
|
|
#define RUNTIME_REPORT_SIGNATURE_SCHEME_SHA512_RSA_PSS_SHA512 (1)
|
|
|
|
//
|
|
// Runtime Report Type Enumeration
|
|
//
|
|
|
|
/**
|
|
* The RUNTIME_REPORT_TYPE enumeration defines the runtime report types.
|
|
*/
|
|
typedef enum _RUNTIME_REPORT_TYPE
|
|
{
|
|
RuntimeReportTypeDriver = 0,
|
|
RuntimeReportTypeCodeIntegrity = 1,
|
|
RuntimeReportTypeMax
|
|
} RUNTIME_REPORT_TYPE;
|
|
|
|
//
|
|
// Macro to convert a report type enum value to a bitmap mask
|
|
//
|
|
|
|
#define RUNTIME_REPORT_TYPE_TO_MASK(type) (1ULL << (type))
|
|
|
|
//
|
|
// Bitmap mask containing all valid report types
|
|
//
|
|
|
|
#define RUNTIME_REPORT_TYPE_MASK_ALL ((1ULL << RuntimeReportTypeMax) - 1)
|
|
|
|
/**
|
|
* The RUNTIME_REPORT_PACKAGE_HEADER structure describes the header of a runtime report package.
|
|
*/
|
|
typedef struct _RUNTIME_REPORT_PACKAGE_HEADER
|
|
{
|
|
//
|
|
// Set to RUNTIME_REPORT_PACKAGE_MAGIC = 0x52545250 ("RTRP")
|
|
//
|
|
|
|
ULONG Magic;
|
|
|
|
//
|
|
// The version of the package format
|
|
//
|
|
|
|
USHORT PackageVersion;
|
|
|
|
//
|
|
// Number of different report types contained in the package.
|
|
//
|
|
|
|
USHORT NumberOfReports;
|
|
|
|
//
|
|
// A bitmap of all the report types in the package.
|
|
//
|
|
// Use RUNTIME_REPORT_TYPE_TO_MASK macro to convert enum values to bitmap masks.
|
|
// Current valid report types:
|
|
// RuntimeReportTypeDriver = 0
|
|
// RuntimeReportTypeCodeIntegrity = 1
|
|
//
|
|
|
|
ULONG_PTR ReportTypesBitmap;
|
|
|
|
//
|
|
// The size of the total package including the package header,
|
|
// various runtime reports, their digests, and the signature blob.
|
|
//
|
|
|
|
ULONG PackageSize;
|
|
|
|
//
|
|
// The type of digest contained in the report digest headers.
|
|
//
|
|
// Current valid values:
|
|
// CALG_SHA_512 (see wincrypt.h)
|
|
//
|
|
|
|
USHORT ReportDigestType;
|
|
|
|
//
|
|
// Total size of the signed runtime report digest headers
|
|
// following the package header.
|
|
//
|
|
|
|
USHORT TotalReportDigestsSize;
|
|
|
|
//
|
|
// Reserved field. Must be set to zero.
|
|
//
|
|
|
|
USHORT Reserved;
|
|
|
|
//
|
|
// The signature scheme used to sign the runtime reports.
|
|
//
|
|
// Current valid values:
|
|
// RUNTIME_REPORT_SIGNATURE_SCHEME_SHA512_RSA_PSS_SHA512 = 1
|
|
//
|
|
|
|
USHORT SignatureScheme;
|
|
|
|
//
|
|
// Size of the signature blob following the runtime report digests.
|
|
//
|
|
|
|
ULONG SignatureSize;
|
|
|
|
//
|
|
// Total size of the authenticated (but unsigned) runtime reports
|
|
// following the signature blob.
|
|
//
|
|
|
|
ULONG TotalAuthenticatedReportsSize;
|
|
|
|
} RUNTIME_REPORT_PACKAGE_HEADER, *PRUNTIME_REPORT_PACKAGE_HEADER;
|
|
|
|
/**
|
|
* The RUNTIME_REPORT_DIGEST_HEADER structure describes the header of a runtime report digest.
|
|
*/
|
|
typedef struct _RUNTIME_REPORT_DIGEST_HEADER
|
|
{
|
|
//
|
|
// Indicates the type of report that was hashed.
|
|
//
|
|
// Current valid values:
|
|
// RuntimeReportTypeDriver = 0
|
|
// RuntimeReportTypeCodeIntegrity = 1
|
|
//
|
|
|
|
USHORT ReportType;
|
|
|
|
//
|
|
// Reserved field.
|
|
//
|
|
|
|
USHORT Reserved;
|
|
|
|
//
|
|
// Digest of the report including the report header.
|
|
// This is a SHA-512 digest.
|
|
//
|
|
|
|
UCHAR ReportDigest[RUNTIME_REPORT_DIGEST_MAX_SIZE];
|
|
|
|
} RUNTIME_REPORT_DIGEST_HEADER, *PRUNTIME_REPORT_DIGEST_HEADER;
|
|
|
|
/**
|
|
* The RUNTIME_REPORT_HEADER structure describes the header of a runtime report.
|
|
*/
|
|
typedef struct _RUNTIME_REPORT_HEADER
|
|
{
|
|
//
|
|
// Indicates the type of report.
|
|
//
|
|
// Current valid values:
|
|
// RuntimeReportTypeDriver = 0
|
|
// RuntimeReportTypeCodeIntegrity = 1
|
|
//
|
|
|
|
USHORT ReportType;
|
|
|
|
//
|
|
// Reserved field.
|
|
//
|
|
|
|
USHORT Reserved;
|
|
|
|
//
|
|
// The number of bytes consumed by this report, including the header.
|
|
//
|
|
|
|
ULONG ReportSize;
|
|
|
|
} RUNTIME_REPORT_HEADER, *PRUNTIME_REPORT_HEADER;
|
|
|
|
//
|
|
// Driver Report Definitions
|
|
//
|
|
|
|
#define DRIVER_REPORT_DIGEST_MAX_SIZE RUNTIME_REPORT_DIGEST_MAX_SIZE
|
|
#define DRIVER_REPORT_NAME_MAX_LENGTH 32
|
|
|
|
/**
|
|
* The DRIVER_INFO_ENTRY structure describes a single driver information entry.
|
|
*/
|
|
typedef struct _DRIVER_INFO_ENTRY
|
|
{
|
|
//
|
|
// Internal name of the driver from the resource section.
|
|
//
|
|
|
|
CHAR InternalName[DRIVER_REPORT_NAME_MAX_LENGTH];
|
|
|
|
//
|
|
// Hash algorithm used to calculate the image digest.
|
|
//
|
|
|
|
USHORT ImageHashAlgorithm;
|
|
|
|
//
|
|
// Hash algorithm used to calculate the thumbprint of the leaf certificate
|
|
// that validates the entire image.
|
|
//
|
|
|
|
USHORT PublisherThumbprintHashAlgorithm;
|
|
|
|
//
|
|
// Offset from the start of the driver report to a buffer containing the
|
|
// digest of the driver image on disk.
|
|
//
|
|
|
|
ULONG ImageHashOffset;
|
|
|
|
//
|
|
// Offset from the start of the driver report to a buffer containing the
|
|
// thumbprint of the leaf certificate validating the entire image
|
|
//
|
|
|
|
ULONG PublisherThumbprintOffset;
|
|
|
|
//
|
|
// Number of times that this driver image has been loaded into the system.
|
|
//
|
|
|
|
USHORT NumberOfLoadingTimes;
|
|
|
|
//
|
|
// Size and Offset of a string indicating the OEM name stored in the
|
|
// authenticated OPUS block of the image digital signature.
|
|
// There is no OEM name for inbox Windows signed drivers. The size does *NOT*
|
|
// include the NULL terminator (even though the string is NULL-terminated).
|
|
//
|
|
|
|
USHORT OemNameSize;
|
|
ULONG OemNameOffset;
|
|
|
|
//
|
|
// Flags indicating various properties of the current driver image:
|
|
// - Unloaded - Set to 1 in case the driver is current unloaded.
|
|
//
|
|
// - BootDriver - Set to 1 in case the image is a Boot Driver;
|
|
// 0 otherwise (the image is a Runtime driver).
|
|
//
|
|
// - HotPatch - Set to 1 in case the image can be also loaded as Hotpatch;
|
|
//
|
|
// - Reserved - Reserved flags bits.
|
|
//
|
|
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
USHORT Unloaded : 1;
|
|
USHORT BootDriver : 1;
|
|
USHORT HotPatch : 1;
|
|
USHORT Reserved : 13;
|
|
} DUMMYSTRUCTNAME;
|
|
USHORT AsUInt16;
|
|
} Flags;
|
|
|
|
USHORT Padding;
|
|
} DRIVER_INFO_ENTRY, *PDRIVER_INFO_ENTRY;
|
|
|
|
/**
|
|
* The DRIVER_RUNTIME_REPORT structure describes the driver runtime report.
|
|
*/
|
|
typedef struct _DRIVER_RUNTIME_REPORT
|
|
{
|
|
//
|
|
// The driver runtime report header.
|
|
//
|
|
|
|
RUNTIME_REPORT_HEADER Header;
|
|
|
|
//
|
|
// The current number of unique drivers in the report.
|
|
//
|
|
|
|
USHORT NumberOfDrivers;
|
|
|
|
//
|
|
// Flags indicating various properties of the report:
|
|
// - ReportOverflowed - Secure Kernel places a limit on the number of
|
|
// drivers it can list in the report. If this is set, it indicates
|
|
// that some loaded drivers might be missing from the report.
|
|
//
|
|
// - PartialReport - Indicates whether the report contains only a
|
|
// subset of NT loaded drivers.
|
|
//
|
|
// - IncludeBootDrivers - Set to 1 in case the report includes
|
|
// boot-loaded drivers; 0 otherwise (in that case the information
|
|
// is stored in the TCG Log).
|
|
//
|
|
// - Reserved - Reserved flags bits.
|
|
//
|
|
|
|
union
|
|
{
|
|
struct
|
|
{
|
|
USHORT ReportOverflowed : 1;
|
|
USHORT PartialReport : 1;
|
|
USHORT IncludeBootDrivers : 1;
|
|
USHORT Reserved : 13;
|
|
} DUMMYSTRUCTNAME;
|
|
USHORT AsUInt16;
|
|
} Flags;
|
|
|
|
//
|
|
// A list, of size zero up to MaximumDriversRecorded, containing driver entries.
|
|
// Unloaded drivers are not removed from the list.
|
|
//
|
|
|
|
DRIVER_INFO_ENTRY DriverEntries[ANYSIZE_ARRAY];
|
|
|
|
//
|
|
// After the driver info array the driver runtime report store hashes,
|
|
// strings and information that are dynamic in size.
|
|
//
|
|
// BYTE DynamicBuffer[ANYSIZE_ARRAY];
|
|
//
|
|
// The dynamic buffer, for each driver is composed off:
|
|
// ImageHash - PublisherHash - OemName.
|
|
//
|
|
|
|
} DRIVER_RUNTIME_REPORT, *PDRIVER_RUNTIME_REPORT;
|
|
|
|
//
|
|
// Code Integrity Report Definitions.
|
|
//
|
|
|
|
/**
|
|
* The CODE_INTEGRITY_RUNTIME_REPORT structure contains a Code Integrity runtime report.
|
|
*/
|
|
typedef struct _CODE_INTEGRITY_RUNTIME_REPORT
|
|
{
|
|
//
|
|
// The Code Integrity runtime report header.
|
|
//
|
|
|
|
RUNTIME_REPORT_HEADER Header;
|
|
|
|
//
|
|
// The number of generations (updates) of policy there have been since boot.
|
|
// The initial generation at boot is 1.
|
|
//
|
|
|
|
UINT64 CurrentGeneration;
|
|
|
|
//
|
|
// The number of generations of policy that are in this report. This is
|
|
// non-zero with the current generation reported first, followed by prior
|
|
// generations in order of ascending age.
|
|
//
|
|
|
|
ULONG NumberOfGenerations;
|
|
|
|
} CODE_INTEGRITY_RUNTIME_REPORT;
|
|
|
|
#define CODE_INTEGRITY_REPORT_GENERATION_VERSION_CURRENT (1)
|
|
|
|
/**
|
|
* The CODE_INTEGRITY_REPORT_GENERATION_HEADER structure describes the header of a Code Integrity report generation.
|
|
*/
|
|
typedef struct _CODE_INTEGRITY_REPORT_GENERATION_HEADER
|
|
{
|
|
//
|
|
// Version of this structure.
|
|
//
|
|
|
|
USHORT Version;
|
|
|
|
//
|
|
// Reserved Field.
|
|
//
|
|
|
|
USHORT Reserved;
|
|
|
|
//
|
|
// The number of bytes consumed by this generation, including this header
|
|
// and all CODE_INTEGRITY_REPORT_RECORD_HEADER structures and payloads.
|
|
//
|
|
|
|
ULONG RecordSize;
|
|
|
|
//
|
|
// Secure Kernel / Hypervisor secure time reference when this policy was
|
|
// committed.
|
|
//
|
|
|
|
ULONG64 CommitTime;
|
|
|
|
} CODE_INTEGRITY_REPORT_GENERATION_HEADER;
|
|
|
|
#define CODE_INTEGRITY_REPORT_RECORD_VERSION_CURRENT (1)
|
|
|
|
/**
|
|
* The CODE_INTEGRITY_REPORT_RECORD_HEADER structure describes the header of a Code Integrity report record.
|
|
*/
|
|
typedef struct _CODE_INTEGRITY_REPORT_RECORD_HEADER
|
|
{
|
|
//
|
|
// Version of this structure.
|
|
//
|
|
|
|
USHORT Version;
|
|
|
|
//
|
|
// Reserved Field.
|
|
//
|
|
|
|
USHORT Reserved;
|
|
|
|
//
|
|
// The number of bytes consumed by this record, including this header.
|
|
//
|
|
|
|
ULONG RecordSize;
|
|
|
|
//
|
|
// The event code (type) of this record. The same codes as the Measured
|
|
// Boot TCG Log are used, for example SIPAEVENT_OS_REVOCATION_LIST, and
|
|
// indicate the structure type of the payload that immediately follows
|
|
// this header.
|
|
//
|
|
|
|
ULONG SipaEventCode;
|
|
|
|
} CODE_INTEGRITY_REPORT_RECORD_HEADER;
|
|
#endif // #if defined(SYSTEM_RUNTIME_REPORT)
|
|
|
|
/**
|
|
* The SYSTEM_POOLTAG2 structure describes allocation statistics for a single
|
|
* pool tag, including paged and nonpaged usage.
|
|
*/
|
|
typedef struct _SYSTEM_POOLTAG2
|
|
{
|
|
union
|
|
{
|
|
UCHAR Tag[4];
|
|
ULONG TagUlong;
|
|
} DUMMYUNIONNAME;
|
|
SIZE_T PagedAllocs;
|
|
SIZE_T PagedFrees;
|
|
SIZE_T PagedUsed;
|
|
SIZE_T NonPagedAllocs;
|
|
SIZE_T NonPagedFrees;
|
|
SIZE_T NonPagedUsed;
|
|
} SYSTEM_POOLTAG2, *PSYSTEM_POOLTAG2;
|
|
|
|
/**
|
|
* The SYSTEM_POOLTAG_INFORMATION2 structure describes a variable-length array
|
|
* of SYSTEM_POOLTAG2 entries representing pool tag usage statistics.
|
|
*/
|
|
typedef struct _SYSTEM_POOLTAG_INFORMATION2
|
|
{
|
|
ULONG Count;
|
|
_Field_size_(Count) SYSTEM_POOLTAG2 TagInfo[ANYSIZE_ARRAY];
|
|
} SYSTEM_POOLTAG_INFORMATION2, *PSYSTEM_POOLTAG_INFORMATION2;
|
|
|
|
/**
|
|
* The CI_ENDPOINT_SECURITY_OPERATION enumeration defines the operations for CI endpoint security.
|
|
*/
|
|
typedef enum _CI_ENDPOINT_SECURITY_OPERATION
|
|
{
|
|
CI_ENDPOINT_SECURITY_OPERATION_SET = 0,
|
|
CI_ENDPOINT_SECURITY_OPERATION_REMOVE = 1,
|
|
CI_ENDPOINT_SECURITY_OPERATION_MAX = 2
|
|
} CI_ENDPOINT_SECURITY_OPERATION;
|
|
|
|
/**
|
|
* The SYSTEM_CODE_INTEGRITY_ENDPOINT_SECURITY_INFORMATION structure contains Code Integrity endpoint security information.
|
|
*/
|
|
typedef struct _SYSTEM_CODE_INTEGRITY_ENDPOINT_SECURITY_INFORMATION
|
|
{
|
|
USHORT Version;
|
|
CI_ENDPOINT_SECURITY_OPERATION Operation;
|
|
USHORT PolicyPathOffset;
|
|
USHORT PolicyPathNumBytes;
|
|
USHORT TssIdOffset;
|
|
USHORT TssIdNumBytes;
|
|
UCHAR Data[ANYSIZE_ARRAY];
|
|
} SYSTEM_CODE_INTEGRITY_ENDPOINT_SECURITY_INFORMATION, *PSYSTEM_CODE_INTEGRITY_ENDPOINT_SECURITY_INFORMATION;
|
|
|
|
#if (PHNT_MODE != PHNT_MODE_KERNEL)
|
|
|
|
/**
|
|
* The NtQuerySystemInformation routine queries information about the system.
|
|
*
|
|
* \param SystemInformationClass The type of information to be retrieved.
|
|
* \param SystemInformation A pointer to a buffer that receives the requested information.
|
|
* \param SystemInformationLength The size of the buffer pointed to by SystemInformation.
|
|
* \param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/sysinfo/zwquerysysteminformation
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySystemInformation(
|
|
_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
|
_Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
|
|
_In_ ULONG SystemInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
/**
|
|
* The NtQuerySystemInformationEx routine queries information about the system.
|
|
*
|
|
* \param SystemInformationClass The type of information to be retrieved.
|
|
* \param InputBuffer Pointer to a caller-allocated input buffer that contains class-specific information.
|
|
* \param InputBufferLength The size of the buffer pointed to by InputBuffer.
|
|
* \param SystemInformation A pointer to a buffer that receives the requested information.
|
|
* \param SystemInformationLength The size of the buffer pointed to by SystemInformation.
|
|
* \param ReturnLength A pointer to a variable that receives the size of the data returned in the buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/sysinfo/zwquerysysteminformation
|
|
* \remarks Uses class-specific input as well as output contracts. Native rejection of
|
|
* a NULL/zero input pair can occur before class dispatch; WoW64 can instead reject an unsupported selector first.
|
|
* For example, SystemBasicInformation with NULL/zero input returns STATUS_INVALID_PARAMETER natively and
|
|
* STATUS_INVALID_INFO_CLASS through the WoW64 path. Use the ordinary query for that class.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQuerySystemInformationEx(
|
|
_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
|
_In_reads_bytes_(InputBufferLength) PVOID InputBuffer,
|
|
_In_ ULONG InputBufferLength,
|
|
_Out_writes_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
|
|
_In_ ULONG SystemInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
/**
|
|
* The NtSetSystemInformation routine sets information about the system.
|
|
*
|
|
* \param SystemInformationClass The type of information to be set.
|
|
* \param SystemInformation A pointer to a buffer that receives the requested information.
|
|
* \param SystemInformationLength The size of the buffer pointed to by SystemInformation.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetSystemInformation(
|
|
_In_ SYSTEM_INFORMATION_CLASS SystemInformationClass,
|
|
_In_reads_bytes_opt_(SystemInformationLength) PVOID SystemInformation,
|
|
_In_ ULONG SystemInformationLength
|
|
);
|
|
|
|
//
|
|
// SysDbg APIs
|
|
//
|
|
|
|
/**
|
|
* The SYSDBG_COMMAND enumeration specifies the type of system debugger
|
|
* operation requested through NtSystemDebugControl.
|
|
*/
|
|
typedef enum _SYSDBG_COMMAND
|
|
{
|
|
SysDbgQueryModuleInformation, // q: DBGKD_DEBUG_DATA_HEADER64
|
|
SysDbgQueryTraceInformation, // q: DBGKD_TRACE_DATA
|
|
SysDbgSetTracepoint, // s: PVOID
|
|
SysDbgSetSpecialCall, // s: PVOID
|
|
SysDbgClearSpecialCalls, // s: void
|
|
SysDbgQuerySpecialCalls, // q: PVOID[]
|
|
SysDbgBreakPoint, // s: void
|
|
SysDbgQueryVersion, // q: DBGKD_GET_VERSION64
|
|
SysDbgReadVirtual, // q: SYSDBG_VIRTUAL
|
|
SysDbgWriteVirtual, // s: SYSDBG_VIRTUAL
|
|
SysDbgReadPhysical, // q: SYSDBG_PHYSICAL // 10
|
|
SysDbgWritePhysical, // s: SYSDBG_PHYSICAL
|
|
SysDbgReadControlSpace, // q: SYSDBG_CONTROL_SPACE
|
|
SysDbgWriteControlSpace, // s: SYSDBG_CONTROL_SPACE
|
|
SysDbgReadIoSpace, // q: SYSDBG_IO_SPACE
|
|
SysDbgWriteIoSpace, // s: SYSDBG_IO_SPACE
|
|
SysDbgReadMsr, // q: SYSDBG_MSR
|
|
SysDbgWriteMsr, // s: SYSDBG_MSR
|
|
SysDbgReadBusData, // q: SYSDBG_BUS_DATA
|
|
SysDbgWriteBusData, // s: SYSDBG_BUS_DATA
|
|
SysDbgCheckLowMemory, // q: ULONG // 20
|
|
SysDbgEnableKernelDebugger, // s: void
|
|
SysDbgDisableKernelDebugger, // s: void
|
|
SysDbgGetAutoKdEnable, // q: ULONG
|
|
SysDbgSetAutoKdEnable, // s: ULONG
|
|
SysDbgGetPrintBufferSize, // q: ULONG
|
|
SysDbgSetPrintBufferSize, // s: ULONG
|
|
SysDbgGetKdUmExceptionEnable, // q: ULONG
|
|
SysDbgSetKdUmExceptionEnable, // s: ULONG
|
|
SysDbgGetTriageDump, // q: SYSDBG_TRIAGE_DUMP
|
|
SysDbgGetKdBlockEnable, // q: ULONG // 30
|
|
SysDbgSetKdBlockEnable, // s: ULONG
|
|
SysDbgRegisterForUmBreakInfo, // s: HANDLE
|
|
SysDbgGetUmBreakPid, // q: ULONG
|
|
SysDbgClearUmBreakPid, // s: void
|
|
SysDbgGetUmAttachPid, // q: ULONG
|
|
SysDbgClearUmAttachPid, // s: void
|
|
SysDbgGetLiveKernelDump, // q: SYSDBG_LIVEDUMP_CONTROL
|
|
SysDbgKdPullRemoteFile, // q: SYSDBG_KD_PULL_REMOTE_FILE
|
|
SysDbgMaxInfoClass
|
|
} SYSDBG_COMMAND, *PSYSDBG_COMMAND;
|
|
|
|
/**
|
|
* The SYSDBG_VIRTUAL structure describes a request to read or write virtual
|
|
* memory through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_VIRTUAL
|
|
{
|
|
PVOID Address;
|
|
PVOID Buffer;
|
|
ULONG Request;
|
|
} SYSDBG_VIRTUAL, *PSYSDBG_VIRTUAL;
|
|
|
|
/**
|
|
* The SYSDBG_PHYSICAL structure describes a request to read or write physical
|
|
* memory through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_PHYSICAL
|
|
{
|
|
PHYSICAL_ADDRESS Address;
|
|
PVOID Buffer;
|
|
ULONG Request;
|
|
} SYSDBG_PHYSICAL, *PSYSDBG_PHYSICAL;
|
|
|
|
/**
|
|
* The SYSDBG_CONTROL_SPACE structure describes a request to access processor
|
|
* control space through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_CONTROL_SPACE
|
|
{
|
|
ULONG64 Address;
|
|
PVOID Buffer;
|
|
ULONG Request;
|
|
ULONG Processor;
|
|
} SYSDBG_CONTROL_SPACE, *PSYSDBG_CONTROL_SPACE;
|
|
|
|
typedef enum _INTERFACE_TYPE INTERFACE_TYPE;
|
|
|
|
/**
|
|
* The SYSDBG_IO_SPACE structure describes a request to access I/O space
|
|
* through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_IO_SPACE
|
|
{
|
|
ULONG64 Address;
|
|
PVOID Buffer;
|
|
ULONG Request;
|
|
INTERFACE_TYPE InterfaceType;
|
|
ULONG BusNumber;
|
|
ULONG AddressSpace;
|
|
} SYSDBG_IO_SPACE, *PSYSDBG_IO_SPACE;
|
|
|
|
/**
|
|
* The SYSDBG_MSR structure describes a request to read or write a model-specific
|
|
* register (MSR) through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_MSR
|
|
{
|
|
ULONG Msr;
|
|
ULONG64 Data;
|
|
} SYSDBG_MSR, *PSYSDBG_MSR;
|
|
|
|
typedef enum _BUS_DATA_TYPE BUS_DATA_TYPE;
|
|
|
|
/**
|
|
* The SYSDBG_BUS_DATA structure describes a request to access bus-specific
|
|
* configuration data through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_BUS_DATA
|
|
{
|
|
ULONG Address;
|
|
PVOID Buffer;
|
|
ULONG Request;
|
|
BUS_DATA_TYPE BusDataType;
|
|
ULONG BusNumber;
|
|
ULONG SlotNumber;
|
|
} SYSDBG_BUS_DATA, *PSYSDBG_BUS_DATA;
|
|
|
|
/**
|
|
* The SYSDBG_TRIAGE_DUMP structure describes parameters used when generating
|
|
* a triage dump through the system debugger interface.
|
|
*/
|
|
typedef struct _SYSDBG_TRIAGE_DUMP
|
|
{
|
|
ULONG Flags;
|
|
ULONG BugCheckCode;
|
|
ULONG_PTR BugCheckParam1;
|
|
ULONG_PTR BugCheckParam2;
|
|
ULONG_PTR BugCheckParam3;
|
|
ULONG_PTR BugCheckParam4;
|
|
ULONG ProcessHandles;
|
|
ULONG ThreadHandles;
|
|
PHANDLE Handles;
|
|
} SYSDBG_TRIAGE_DUMP, *PSYSDBG_TRIAGE_DUMP;
|
|
|
|
/**
|
|
* The SYSDBG_LIVEDUMP_CONTROL_FLAGS union specifies control flags used when
|
|
* generating a live kernel dump.
|
|
*/
|
|
typedef union _SYSDBG_LIVEDUMP_CONTROL_FLAGS
|
|
{
|
|
struct
|
|
{
|
|
ULONG UseDumpStorageStack : 1;
|
|
ULONG CompressMemoryPagesData : 1;
|
|
ULONG IncludeUserSpaceMemoryPages : 1;
|
|
ULONG AbortIfMemoryPressure : 1; // REDSTONE4
|
|
ULONG SelectiveDump : 1; // WIN11
|
|
ULONG Reserved : 27;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONG AsUlong;
|
|
} SYSDBG_LIVEDUMP_CONTROL_FLAGS, *PSYSDBG_LIVEDUMP_CONTROL_FLAGS;
|
|
|
|
/**
|
|
* The SYSDBG_LIVEDUMP_CONTROL_ADDPAGES union specifies additional page
|
|
* categories to include when generating a live kernel dump.
|
|
*/
|
|
typedef union _SYSDBG_LIVEDUMP_CONTROL_ADDPAGES
|
|
{
|
|
struct
|
|
{
|
|
ULONG HypervisorPages : 1;
|
|
ULONG NonEssentialHypervisorPages : 1; // since WIN11
|
|
ULONG Reserved : 30;
|
|
} DUMMYSTRUCTNAME;
|
|
ULONG AsUlong;
|
|
} SYSDBG_LIVEDUMP_CONTROL_ADDPAGES, *PSYSDBG_LIVEDUMP_CONTROL_ADDPAGES;
|
|
|
|
#define SYSDBG_LIVEDUMP_SELECTIVE_CONTROL_VERSION 1
|
|
|
|
// rev
|
|
/**
|
|
* The SYSDBG_LIVEDUMP_SELECTIVE_CONTROL structure specifies selective dump
|
|
* options for live kernel dump generation.
|
|
*/
|
|
typedef struct _SYSDBG_LIVEDUMP_SELECTIVE_CONTROL
|
|
{
|
|
ULONG Version;
|
|
ULONG Size;
|
|
union
|
|
{
|
|
ULONGLONG Flags;
|
|
struct
|
|
{
|
|
ULONGLONG ThreadKernelStacks : 1;
|
|
ULONGLONG ReservedFlags : 63;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
ULONGLONG Reserved[4];
|
|
} SYSDBG_LIVEDUMP_SELECTIVE_CONTROL, *PSYSDBG_LIVEDUMP_SELECTIVE_CONTROL;
|
|
|
|
#define SYSDBG_LIVEDUMP_CONTROL_VERSION_1 1
|
|
#define SYSDBG_LIVEDUMP_CONTROL_VERSION_2 2
|
|
#define SYSDBG_LIVEDUMP_CONTROL_VERSION SYSDBG_LIVEDUMP_CONTROL_VERSION_2
|
|
|
|
/**
|
|
* The SYSDBG_LIVEDUMP_CONTROL_V1 structure describes parameters used when
|
|
* generating a live kernel dump (version 1).
|
|
*/
|
|
typedef struct _SYSDBG_LIVEDUMP_CONTROL_V1
|
|
{
|
|
ULONG Version;
|
|
ULONG BugCheckCode;
|
|
ULONG_PTR BugCheckParam1;
|
|
ULONG_PTR BugCheckParam2;
|
|
ULONG_PTR BugCheckParam3;
|
|
ULONG_PTR BugCheckParam4;
|
|
HANDLE DumpFileHandle;
|
|
HANDLE CancelEventHandle;
|
|
SYSDBG_LIVEDUMP_CONTROL_FLAGS Flags;
|
|
SYSDBG_LIVEDUMP_CONTROL_ADDPAGES AddPagesControl;
|
|
} SYSDBG_LIVEDUMP_CONTROL_V1, *PSYSDBG_LIVEDUMP_CONTROL_V1;
|
|
|
|
/**
|
|
* The SYSDBG_LIVEDUMP_CONTROL structure describes parameters used when
|
|
* generating a live kernel dump (current version).
|
|
*/
|
|
typedef struct _SYSDBG_LIVEDUMP_CONTROL
|
|
{
|
|
ULONG Version;
|
|
ULONG BugCheckCode;
|
|
ULONG_PTR BugCheckParam1;
|
|
ULONG_PTR BugCheckParam2;
|
|
ULONG_PTR BugCheckParam3;
|
|
ULONG_PTR BugCheckParam4;
|
|
HANDLE DumpFileHandle;
|
|
HANDLE CancelEventHandle;
|
|
SYSDBG_LIVEDUMP_CONTROL_FLAGS Flags;
|
|
SYSDBG_LIVEDUMP_CONTROL_ADDPAGES AddPagesControl;
|
|
PSYSDBG_LIVEDUMP_SELECTIVE_CONTROL SelectiveControl; // since WIN11
|
|
} SYSDBG_LIVEDUMP_CONTROL, *PSYSDBG_LIVEDUMP_CONTROL;
|
|
|
|
/**
|
|
* The SYSDBG_KD_PULL_REMOTE_FILE structure describes a request to retrieve
|
|
* a remote file through the kernel debugger transport.
|
|
*/
|
|
typedef struct _SYSDBG_KD_PULL_REMOTE_FILE
|
|
{
|
|
UNICODE_STRING ImageFileName;
|
|
} SYSDBG_KD_PULL_REMOTE_FILE, *PSYSDBG_KD_PULL_REMOTE_FILE;
|
|
|
|
/**
|
|
* The NtSystemDebugControl routine provides system debugging and diagnostic control of the system.
|
|
*
|
|
* \param[in] Command The debug control command to execute (of type SYSDBG_COMMAND).
|
|
* \param[in] InputBuffer Optional pointer to a buffer containing input data for the command.
|
|
* \param[in] InputBufferLength Length, in bytes, of the input buffer.
|
|
* \param[out] OutputBuffer Optional pointer to a buffer that receives output data from the command.
|
|
* \param[in] OutputBufferLength Length, in bytes, of the output buffer.
|
|
* \param[out] ReturnLength Optional pointer to a variable that receives the number of bytes returned in the output buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSystemDebugControl(
|
|
_In_ SYSDBG_COMMAND Command,
|
|
_Inout_updates_bytes_opt_(InputBufferLength) PVOID InputBuffer,
|
|
_In_ ULONG InputBufferLength,
|
|
_Out_writes_bytes_opt_(OutputBufferLength) PVOID OutputBuffer,
|
|
_In_ ULONG OutputBufferLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
//
|
|
// Hard errors
|
|
//
|
|
|
|
/**
|
|
* The HARDERROR_RESPONSE_OPTION enumeration specifies the type of user
|
|
* interface prompt that may be displayed when a hard error occurs.
|
|
*/
|
|
typedef enum _HARDERROR_RESPONSE_OPTION
|
|
{
|
|
OptionAbortRetryIgnore,
|
|
OptionOk,
|
|
OptionOkCancel,
|
|
OptionRetryCancel,
|
|
OptionYesNo,
|
|
OptionYesNoCancel,
|
|
OptionShutdownSystem,
|
|
OptionOkNoWait,
|
|
OptionCancelTryContinue
|
|
} HARDERROR_RESPONSE_OPTION;
|
|
|
|
/**
|
|
* The HARDERROR_RESPONSE enumeration specifies the response returned by the
|
|
* caller or user when handling a hard error condition.
|
|
*/
|
|
typedef enum _HARDERROR_RESPONSE
|
|
{
|
|
ResponseReturnToCaller,
|
|
ResponseNotHandled,
|
|
ResponseAbort,
|
|
ResponseCancel,
|
|
ResponseIgnore,
|
|
ResponseNo,
|
|
ResponseOk,
|
|
ResponseRetry,
|
|
ResponseYes,
|
|
ResponseTryAgain,
|
|
ResponseContinue
|
|
} HARDERROR_RESPONSE;
|
|
|
|
/**
|
|
* HARDERROR_OVERRIDE_ERRORMODE indicates that the system should ignore the
|
|
* calling process's error mode when processing a hard error.
|
|
*/
|
|
#define HARDERROR_OVERRIDE_ERRORMODE 0x10000000
|
|
|
|
/**
|
|
* The NtRaiseHardError routine raises a hard error or serious error dialog box being displayed to the user.
|
|
*
|
|
* \param[in] ErrorStatus The NTSTATUS code that describes the error condition.
|
|
* \param[in] NumberOfParameters The number of parameters in the Parameters array.
|
|
* \param[in] UnicodeStringParameterMask A bitmask indicating which entries in the Parameters array are Unicode strings.
|
|
* \param[in] Parameters An array of parameters to be used in the error message.
|
|
* \param[in] ValidResponseOptions Specifies the valid responses that the user can select in the error dialog.
|
|
* \param[out] Response Receives the user's response to the error dialog.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Analysis_noreturn_
|
|
DECLSPEC_NORETURN
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtRaiseHardError(
|
|
_In_ NTSTATUS ErrorStatus,
|
|
_In_ ULONG NumberOfParameters,
|
|
_In_ ULONG UnicodeStringParameterMask,
|
|
_In_reads_(NumberOfParameters) PULONG_PTR Parameters,
|
|
_In_ ULONG ValidResponseOptions,
|
|
_Out_ PULONG Response
|
|
);
|
|
|
|
//
|
|
// Kernel-user shared data
|
|
//
|
|
|
|
/**
|
|
* The ALTERNATIVE_ARCHITECTURE_TYPE enumeration specifies the hardware
|
|
* architecture variant used by the system.
|
|
* \remarks NEC98x86 represents the NEC PC-98 architecture,
|
|
* supported only on very early Windows releases.
|
|
*/
|
|
typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
|
|
{
|
|
StandardDesign,
|
|
NEC98x86,
|
|
EndAlternatives
|
|
} ALTERNATIVE_ARCHITECTURE_TYPE;
|
|
|
|
/**
|
|
* PROCESSOR_FEATURE_MAX defines the maximum number of processor feature flags
|
|
* that may be reported by the system.
|
|
*/
|
|
#define PROCESSOR_FEATURE_MAX 64
|
|
|
|
//
|
|
// Processor features (IsProcessorFeaturePresent)
|
|
//
|
|
#define PF_FLOATING_POINT_PRECISION_ERRATA 0
|
|
#define PF_FLOATING_POINT_EMULATED 1
|
|
#define PF_COMPARE_EXCHANGE_DOUBLE 2
|
|
#define PF_MMX_INSTRUCTIONS_AVAILABLE 3
|
|
#define PF_PPC_MOVEMEM_64BIT_OK 4
|
|
#define PF_ALPHA_BYTE_INSTRUCTIONS 5
|
|
#define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
|
|
#define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
|
|
#define PF_RDTSC_INSTRUCTION_AVAILABLE 8
|
|
#define PF_PAE_ENABLED 9
|
|
#define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
|
|
#define PF_SSE_DAZ_MODE_AVAILABLE 11
|
|
#define PF_NX_ENABLED 12
|
|
#define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
|
|
#define PF_COMPARE_EXCHANGE128 14
|
|
#define PF_COMPARE64_EXCHANGE128 15
|
|
#define PF_CHANNELS_ENABLED 16
|
|
#define PF_XSAVE_ENABLED 17
|
|
#define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
|
|
#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
|
|
#define PF_SECOND_LEVEL_ADDRESS_TRANSLATION 20
|
|
#define PF_VIRT_FIRMWARE_ENABLED 21
|
|
#define PF_RDWRFSGSBASE_AVAILABLE 22
|
|
#define PF_FASTFAIL_AVAILABLE 23
|
|
#define PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE 24
|
|
#define PF_ARM_64BIT_LOADSTORE_ATOMIC 25
|
|
#define PF_ARM_EXTERNAL_CACHE_AVAILABLE 26
|
|
#define PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE 27
|
|
#define PF_RDRAND_INSTRUCTION_AVAILABLE 28
|
|
#define PF_ARM_V8_INSTRUCTIONS_AVAILABLE 29
|
|
#define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
|
|
#define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
|
|
#define PF_RDTSCP_INSTRUCTION_AVAILABLE 32
|
|
#define PF_RDPID_INSTRUCTION_AVAILABLE 33
|
|
#define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
|
|
#define PF_MONITORX_INSTRUCTION_AVAILABLE 35
|
|
#define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
|
|
#define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
|
|
#define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
|
|
#define PF_AVX_INSTRUCTIONS_AVAILABLE 39
|
|
#define PF_AVX2_INSTRUCTIONS_AVAILABLE 40
|
|
#define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41
|
|
#define PF_ERMS_AVAILABLE 42
|
|
#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43
|
|
#define PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE 44
|
|
#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45
|
|
#define PF_ARM_SVE_INSTRUCTIONS_AVAILABLE 46
|
|
#define PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE 47
|
|
#define PF_ARM_SVE2_1_INSTRUCTIONS_AVAILABLE 48
|
|
#define PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE 49
|
|
#define PF_ARM_SVE_PMULL128_INSTRUCTIONS_AVAILABLE 50
|
|
#define PF_ARM_SVE_BITPERM_INSTRUCTIONS_AVAILABLE 51
|
|
#define PF_ARM_SVE_BF16_INSTRUCTIONS_AVAILABLE 52
|
|
#define PF_ARM_SVE_EBF16_INSTRUCTIONS_AVAILABLE 53
|
|
#define PF_ARM_SVE_B16B16_INSTRUCTIONS_AVAILABLE 54
|
|
#define PF_ARM_SVE_SHA3_INSTRUCTIONS_AVAILABLE 55
|
|
#define PF_ARM_SVE_SM4_INSTRUCTIONS_AVAILABLE 56
|
|
#define PF_ARM_SVE_I8MM_INSTRUCTIONS_AVAILABLE 57
|
|
#define PF_ARM_SVE_F32MM_INSTRUCTIONS_AVAILABLE 58
|
|
#define PF_ARM_SVE_F64MM_INSTRUCTIONS_AVAILABLE 59
|
|
#define PF_BMI2_INSTRUCTIONS_AVAILABLE 60
|
|
#define PF_MOVDIR64B_INSTRUCTION_AVAILABLE 61
|
|
#define PF_ARM_LSE2_AVAILABLE 62
|
|
#define PF_RESERVED_FEATURE 63
|
|
// SystemProcessorFeaturesBitMapInformation
|
|
#define PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE 64
|
|
#define PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE 65
|
|
#define PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE 66
|
|
#define PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE 67
|
|
#define PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE 68
|
|
#define PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE 69
|
|
#define PF_ARM_SME_INSTRUCTIONS_AVAILABLE 70
|
|
#define PF_ARM_SME2_INSTRUCTIONS_AVAILABLE 71
|
|
#define PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE 72
|
|
#define PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE 73
|
|
#define PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE 74
|
|
#define PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE 75
|
|
#define PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE 76
|
|
#define PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE 77
|
|
#define PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE 78
|
|
#define PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE 79
|
|
#define PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE 80
|
|
#define PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE 81
|
|
#define PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE 82
|
|
#define PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE 83
|
|
#define PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE 84
|
|
#define PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE 85
|
|
#define PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE 86
|
|
#define PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE 87
|
|
#define PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE 88
|
|
#define PF_UMONITOR_INSTRUCTION_AVAILABLE 89
|
|
|
|
/**
|
|
* MAX_WOW64_SHARED_ENTRIES defines the number of shared entries available to
|
|
* the WOW64 (Windows-on-Windows 64-bit) subsystem.
|
|
*/
|
|
#define MAX_WOW64_SHARED_ENTRIES 16
|
|
|
|
//
|
|
// Define NX support policy values.
|
|
//
|
|
|
|
#define NX_SUPPORT_POLICY_ALWAYSOFF 0
|
|
#define NX_SUPPORT_POLICY_ALWAYSON 1
|
|
#define NX_SUPPORT_POLICY_OPTIN 2
|
|
#define NX_SUPPORT_POLICY_OPTOUT 3
|
|
|
|
//
|
|
// SEH chain validation policies.
|
|
//
|
|
|
|
#define SEH_VALIDATION_POLICY_ON 0
|
|
#define SEH_VALIDATION_POLICY_OFF 1
|
|
#define SEH_VALIDATION_POLICY_TELEMETRY 2
|
|
#define SEH_VALIDATION_POLICY_DEFER 3
|
|
|
|
//
|
|
// Global shared data flags and manipulation macros.
|
|
//
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT_V 0x0
|
|
#define SHARED_GLOBAL_FLAGS_ERROR_PORT \
|
|
(1UL << SHARED_GLOBAL_FLAGS_ERROR_PORT_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V 0x1
|
|
#define SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_ELEVATION_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V 0x2
|
|
#define SHARED_GLOBAL_FLAGS_VIRT_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_VIRT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V 0x3
|
|
#define SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_INSTALLER_DETECT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_LKG_ENABLED_V 0x4
|
|
#define SHARED_GLOBAL_FLAGS_LKG_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_LKG_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V 0x5
|
|
#define SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_DYNAMIC_PROC_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_CONSOLE_BROKER_ENABLED_V 0x6
|
|
#define SHARED_GLOBAL_FLAGS_CONSOLE_BROKER_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_CONSOLE_BROKER_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SECURE_BOOT_ENABLED_V 0x7
|
|
#define SHARED_GLOBAL_FLAGS_SECURE_BOOT_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SECURE_BOOT_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_MULTI_SESSION_SKU_V 0x8
|
|
#define SHARED_GLOBAL_FLAGS_MULTI_SESSION_SKU \
|
|
(1UL << SHARED_GLOBAL_FLAGS_MULTI_SESSION_SKU_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_MULTIUSERS_IN_SESSION_SKU_V 0x9
|
|
#define SHARED_GLOBAL_FLAGS_MULTIUSERS_IN_SESSION_SKU \
|
|
(1UL << SHARED_GLOBAL_FLAGS_MULTIUSERS_IN_SESSION_SKU_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_STATE_SEPARATION_ENABLED_V 0xA
|
|
#define SHARED_GLOBAL_FLAGS_STATE_SEPARATION_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_STATE_SEPARATION_ENABLED_V)
|
|
|
|
// rev
|
|
#define SHARED_GLOBAL_FLAGS_SPLIT_TOKEN_ENABLED_V 0xB
|
|
#define SHARED_GLOBAL_FLAGS_SPLIT_TOKEN_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SPLIT_TOKEN_ENABLED_V)
|
|
|
|
// rev
|
|
#define SHARED_GLOBAL_FLAGS_SHADOW_ADMIN_ENABLED_V 0xC
|
|
#define SHARED_GLOBAL_FLAGS_SHADOW_ADMIN_ENABLED \
|
|
(1UL << SHARED_GLOBAL_FLAGS_SHADOW_ADMIN_ENABLED_V)
|
|
|
|
#define SHARED_GLOBAL_FLAGS_SET_GLOBAL_DATA_FLAG 0x40000000
|
|
#define SHARED_GLOBAL_FLAGS_CLEAR_GLOBAL_DATA_FLAG 0x80000000
|
|
|
|
//
|
|
// Define legal values for the SystemCall member.
|
|
//
|
|
|
|
#define SYSTEM_CALL_SYSCALL 0
|
|
#define SYSTEM_CALL_INT_2E 1
|
|
|
|
//
|
|
// Define flags for QPC bypass information. None of these flags may be set
|
|
// unless bypass is enabled. This is for compat with existing code which
|
|
// compares this value to zero to detect bypass enablement.
|
|
//
|
|
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_ENABLED (0x01)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_HV_PAGE (0x02)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_DISABLE_32BIT (0x04)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_MFENCE (0x10)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_LFENCE (0x20)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_A73_ERRATA (0x40)
|
|
#define SHARED_GLOBAL_FLAGS_QPC_BYPASS_USE_RDTSCP (0x80)
|
|
|
|
/**
|
|
* Windows 11 24H2 shared-page XSTATE configuration, independent of the installed SDK.
|
|
* The 24H2 kernel and ntdll layout occupies 0x348 bytes. Newer SDKs
|
|
* enlarge XSTATE_CONFIGURATION, which must not shift the trailing KUSER fields
|
|
* when PHNT_VERSION explicitly targets PHNT_WINDOWS_11_24H2.
|
|
* Feature arrays are indexed by XSTATE feature number (64 entries).
|
|
*/
|
|
typedef struct _XSTATE_CONFIGURATION_24H2
|
|
{
|
|
ULONG64 EnabledFeatures;
|
|
ULONG64 EnabledVolatileFeatures;
|
|
ULONG Size;
|
|
union
|
|
{
|
|
ULONG ControlFlags;
|
|
struct
|
|
{
|
|
ULONG OptimizedSave : 1;
|
|
ULONG CompactionEnabled : 1;
|
|
ULONG ExtendedFeatureDisable : 1;
|
|
ULONG ReservedControlFlags : 29;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
XSTATE_FEATURE Features[64];
|
|
ULONG64 EnabledSupervisorFeatures;
|
|
ULONG64 AlignedFeatures;
|
|
ULONG AllFeatureSize;
|
|
ULONG AllFeatures[64];
|
|
ULONG64 EnabledUserVisibleSupervisorFeatures;
|
|
ULONG64 ExtendedFeatureDisableFeatures;
|
|
ULONG AllNonLargeFeatureSize;
|
|
USHORT MaxSveVectorLength;
|
|
USHORT Spare1;
|
|
} XSTATE_CONFIGURATION_24H2, *PXSTATE_CONFIGURATION_24H2;
|
|
|
|
static_assert(sizeof(XSTATE_CONFIGURATION_24H2) == 0x348, "XSTATE_CONFIGURATION_24H2 size is incorrect");
|
|
|
|
/**
|
|
* The KUSER_SHARED_DATA structure contains information shared with user-mode.
|
|
* Define PHNT_VERSION for the target OS before including phnt.h; the default
|
|
* PHNT_WINDOWS_NEW follows the installed SDK XSTATE layout.
|
|
*
|
|
* \sa https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-kuser_shared_data
|
|
*/
|
|
typedef struct _KUSER_SHARED_DATA
|
|
{
|
|
//
|
|
// Current low 32-bit of tick count and tick count multiplier.
|
|
//
|
|
// N.B. The tick count is updated each time the clock ticks.
|
|
//
|
|
|
|
ULONG TickCountLowDeprecated;
|
|
ULONG TickCountMultiplier;
|
|
|
|
//
|
|
// Current 64-bit interrupt time in 100ns units.
|
|
//
|
|
|
|
volatile KSYSTEM_TIME InterruptTime;
|
|
|
|
//
|
|
// Current 64-bit system time in 100ns units.
|
|
//
|
|
|
|
volatile KSYSTEM_TIME SystemTime;
|
|
|
|
//
|
|
// Current 64-bit time zone bias.
|
|
//
|
|
|
|
volatile KSYSTEM_TIME TimeZoneBias;
|
|
|
|
//
|
|
// Support image magic number range for the host system.
|
|
//
|
|
// N.B. This is an inclusive range.
|
|
//
|
|
|
|
USHORT ImageNumberLow;
|
|
USHORT ImageNumberHigh;
|
|
|
|
//
|
|
// Copy of system root in unicode.
|
|
//
|
|
// N.B. This field must be accessed via the RtlGetNtSystemRoot API for
|
|
// an accurate result.
|
|
//
|
|
|
|
WCHAR NtSystemRoot[260];
|
|
|
|
//
|
|
// Maximum stack trace depth if tracing enabled.
|
|
//
|
|
|
|
ULONG MaxStackTraceDepth;
|
|
|
|
//
|
|
// Crypto exponent value.
|
|
//
|
|
|
|
ULONG CryptoExponent;
|
|
|
|
//
|
|
// Time zone ID.
|
|
//
|
|
|
|
ULONG TimeZoneId;
|
|
|
|
//
|
|
// Minimum size of a large page on the system, in bytes.
|
|
//
|
|
// N.B. Returned by GetLargePageMinimum() function.
|
|
//
|
|
|
|
ULONG LargePageMinimum;
|
|
|
|
//
|
|
// This value controls the Application Impact Telemetry (AIT) Sampling rate.
|
|
//
|
|
// This value determines how frequently the system records AIT events,
|
|
// which are used by the Application Experience and compatibility
|
|
// subsystems to evaluate application behavior, performance, and
|
|
// potential compatibility issues.
|
|
//
|
|
// Lower values increase sampling frequency, while higher values reduce it.
|
|
// The kernel updates this field as part of its internal telemetry and
|
|
// heuristics logic.
|
|
//
|
|
|
|
ULONG AitSamplingValue;
|
|
|
|
//
|
|
// This value controls Application Compatibility (AppCompat) switchback processing.
|
|
//
|
|
|
|
union
|
|
{
|
|
ULONG AppCompatFlag;
|
|
struct
|
|
{
|
|
ULONG SwitchbackEnabled : 1; // Basic switchback processing
|
|
ULONG ExtendedHeuristics : 1; // Extended switchback heuristics
|
|
ULONG TelemetryFallback : 1; // Telemetry-driven fallback
|
|
ULONG Reserved : 29;
|
|
} AppCompatFlags;
|
|
} DUMMYUNIONNAME;
|
|
|
|
//
|
|
// Current Kernel Root RNG state seed version
|
|
//
|
|
|
|
ULONGLONG RNGSeedVersion;
|
|
|
|
//
|
|
// This value controls assertion failure handling.
|
|
//
|
|
// Historically (prior to Windows 10), this value was also used by
|
|
// Code Integrity (CI), AppLocker, and related security components to
|
|
// determine the minimum validation requirements for executable images,
|
|
// drivers, and privileged operations.
|
|
//
|
|
// In modern Windows versions, this field is used primarily by the kernel's
|
|
// diagnostic and validation infrastructure to decide how assertion failures
|
|
// should be handled (e.g., logging, debugger break-in, or bugcheck).
|
|
|
|
ULONG GlobalValidationRunlevel;
|
|
|
|
//
|
|
// Monotonic stamp incremented by the kernel whenever the system's
|
|
// time zone bias value changes.
|
|
//
|
|
// N.B. This field must be accessed via the RtlGetSystemTimeAndBias API for
|
|
// an accurate result.
|
|
// This value is read before and after accessing the bias fields to determine
|
|
// whether the time zone data changed during the read. If the stamp differs,
|
|
// the caller must re-read the bias values to ensure consistency.
|
|
//
|
|
|
|
volatile LONG TimeZoneBiasStamp;
|
|
|
|
//
|
|
// The shared collective build number undecorated with C or F.
|
|
// GetVersionEx hides the real number
|
|
//
|
|
|
|
ULONG NtBuildNumber;
|
|
|
|
//
|
|
// Product type.
|
|
//
|
|
// N.B. This field must be accessed via the RtlGetNtProductType API for
|
|
// an accurate result.
|
|
//
|
|
|
|
NT_PRODUCT_TYPE NtProductType;
|
|
BOOLEAN ProductTypeIsValid;
|
|
BOOLEAN Reserved0[1];
|
|
|
|
//
|
|
// Native hardware processor architecture of the running system.
|
|
//
|
|
// N.B. User-mode components read this field to determine the true system
|
|
// architecture, especially in WOW64 scenarios where the process architecture
|
|
// differs from the native one.
|
|
//
|
|
|
|
USHORT NativeProcessorArchitecture;
|
|
|
|
//
|
|
// The NT Version.
|
|
//
|
|
// N. B. Note that each process sees a version from its PEB, but if the
|
|
// process is running with an altered view of the system version,
|
|
// the following two fields are used to correctly identify the
|
|
// version
|
|
//
|
|
|
|
ULONG NtMajorVersion;
|
|
ULONG NtMinorVersion;
|
|
|
|
//
|
|
// Processor features.
|
|
//
|
|
|
|
BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
|
|
|
|
//
|
|
// Reserved fields - do not use.
|
|
//
|
|
|
|
ULONG MaximumUserModeAddressDeprecated; // Deprecated, use SystemBasicInformation instead.
|
|
ULONG SystemRangeStartDeprecated; // Deprecated, use SystemRangeStartInformation instead.
|
|
|
|
//
|
|
// Time slippage while in debugger.
|
|
//
|
|
|
|
volatile ULONG TimeSlip;
|
|
|
|
//
|
|
// Alternative system architecture, e.g., NEC PC98xx on x86.
|
|
//
|
|
|
|
ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
|
|
|
|
//
|
|
// Boot sequence, incremented for each boot attempt by the OS loader.
|
|
//
|
|
|
|
ULONG BootId;
|
|
|
|
//
|
|
// If the system is an evaluation unit, the following field contains the
|
|
// date and time that the evaluation unit expires. A value of 0 indicates
|
|
// that there is no expiration. A non-zero value is the UTC absolute time
|
|
// that the system expires.
|
|
//
|
|
|
|
LARGE_INTEGER SystemExpirationDate;
|
|
|
|
//
|
|
// Suite support.
|
|
//
|
|
// N.B. This field must be accessed via the RtlGetSuiteMask API for
|
|
// an accurate result.
|
|
//
|
|
|
|
ULONG SuiteMask;
|
|
|
|
//
|
|
// TRUE if a kernel debugger is connected/enabled.
|
|
//
|
|
|
|
BOOLEAN KdDebuggerEnabled;
|
|
|
|
//
|
|
// Mitigation policies.
|
|
//
|
|
|
|
union
|
|
{
|
|
UCHAR MitigationPolicies;
|
|
struct
|
|
{
|
|
UCHAR NXSupportPolicy : 2;
|
|
UCHAR SEHValidationPolicy : 2;
|
|
UCHAR CurDirDevicesSkippedForDlls : 2;
|
|
UCHAR Reserved : 2;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
//
|
|
// Measured duration of a single processor yield, in cycles. This is used by
|
|
// lock packages to determine how many times to spin waiting for a state
|
|
// change before blocking.
|
|
//
|
|
|
|
USHORT CyclesPerYield;
|
|
|
|
//
|
|
// Current console session Id. Always zero on non-TS systems.
|
|
//
|
|
// N.B. This field must be accessed via the RtlGetActiveConsoleId API for an
|
|
// accurate result.
|
|
//
|
|
|
|
volatile ULONG ActiveConsoleId;
|
|
|
|
//
|
|
// Force-dismounts cause handles to become invalid. Rather than always
|
|
// probe handles, a serial number of dismounts is maintained that clients
|
|
// can use to see if they need to probe handles.
|
|
//
|
|
|
|
volatile ULONG DismountCount;
|
|
|
|
//
|
|
// This field indicates the status of the 64-bit COM+ package on the
|
|
// system. It indicates whether the Intermediate Language (IL) COM+
|
|
// images need to use the 64-bit COM+ runtime or the 32-bit COM+ runtime.
|
|
//
|
|
|
|
ULONG ComPlusPackage;
|
|
|
|
//
|
|
// Time in tick count for system-wide last user input across all terminal
|
|
// sessions. For MP performance, it is not updated all the time (e.g. once
|
|
// a minute per session). It is used for idle detection.
|
|
//
|
|
|
|
ULONG LastSystemRITEventTickCount;
|
|
|
|
//
|
|
// Number of physical pages in the system. This can dynamically change as
|
|
// physical memory can be added or removed from a running system. This
|
|
// cell is too small to hold the non-truncated value on very large memory
|
|
// machines so code that needs the full value should access
|
|
// FullNumberOfPhysicalPages instead.
|
|
//
|
|
|
|
ULONG NumberOfPhysicalPages;
|
|
|
|
//
|
|
// True if the system was booted in safe boot mode.
|
|
//
|
|
|
|
BOOLEAN SafeBootMode;
|
|
|
|
//
|
|
// Virtualization flags.
|
|
//
|
|
|
|
union
|
|
{
|
|
UCHAR VirtualizationFlags;
|
|
|
|
#if defined(_ARM64_)
|
|
|
|
//
|
|
// N.B. Keep this bitfield in sync with the one in arc.w.
|
|
//
|
|
|
|
struct
|
|
{
|
|
UCHAR ArchStartedInEl2 : 1;
|
|
UCHAR QcSlIsSupported : 1;
|
|
UCHAR : 6;
|
|
} DUMMYSTRUCTNAME;
|
|
|
|
#endif
|
|
|
|
} DUMMYUNIONNAME;
|
|
|
|
//
|
|
// Reserved (available for reuse).
|
|
//
|
|
|
|
UCHAR Reserved12[2];
|
|
|
|
//
|
|
// This is a packed bitfield that contains various flags concerning
|
|
// the system state. They must be manipulated using interlocked
|
|
// operations.
|
|
//
|
|
// N.B. DbgMultiSessionSku must be accessed via the RtlIsMultiSessionSku
|
|
// API for an accurate result
|
|
//
|
|
|
|
union
|
|
{
|
|
ULONG SharedDataFlags;
|
|
struct
|
|
{
|
|
//
|
|
// The following bit fields are for the debugger only. Do not use.
|
|
// Use the bit definitions instead.
|
|
//
|
|
|
|
ULONG DbgErrorPortPresent : 1;
|
|
ULONG DbgElevationEnabled : 1;
|
|
ULONG DbgVirtEnabled : 1;
|
|
ULONG DbgInstallerDetectEnabled : 1;
|
|
ULONG DbgLkgEnabled : 1;
|
|
ULONG DbgDynProcessorEnabled : 1;
|
|
ULONG DbgConsoleBrokerEnabled : 1;
|
|
ULONG DbgSecureBootEnabled : 1;
|
|
ULONG DbgMultiSessionSku : 1;
|
|
ULONG DbgMultiUsersInSessionSku : 1;
|
|
ULONG DbgStateSeparationEnabled : 1;
|
|
ULONG DbgSplitTokenEnabled : 1;
|
|
ULONG DbgShadowAdminEnabled : 1;
|
|
ULONG SpareBits : 19;
|
|
} DUMMYSTRUCTNAME2;
|
|
} DUMMYUNIONNAME2;
|
|
|
|
//
|
|
// Reserved padding field to preserve structure alignment and compatibility.
|
|
//
|
|
|
|
ULONG DataFlagsPad[1];
|
|
|
|
//
|
|
// Depending on the processor, the code for fast system call will differ,
|
|
// Stub code is provided pointers below to access the appropriate code.
|
|
//
|
|
// N.B. The following field is only used on 32-bit systems.
|
|
//
|
|
|
|
ULONGLONG TestRetInstruction;
|
|
|
|
//
|
|
// Query-performance counter (QPC) frequency, in counts per second.
|
|
//
|
|
// N.B. This value represents the fixed frequency of the system's high-resolution
|
|
// performance counter. It is used by user-mode time routines to convert QPC
|
|
// ticks into elapsed time without requiring a system call. The frequency is
|
|
// constant for the lifetime of the system and reflects the hardware or
|
|
// virtualized timer source selected by the kernel.
|
|
//
|
|
|
|
LONGLONG QpcFrequency;
|
|
|
|
//
|
|
// On AMD64, this value is initialized to a nonzero value if the system
|
|
// operates with an altered view of the system service call mechanism.
|
|
//
|
|
|
|
ULONG SystemCall;
|
|
|
|
//
|
|
// Reserved field - do not use. Used to be UserCetAvailableEnvironments.
|
|
//
|
|
|
|
ULONG Reserved2;
|
|
|
|
//
|
|
// Full 64 bit version of the number of physical pages in the system.
|
|
// This can dynamically change as physical memory can be added or removed
|
|
// from a running system.
|
|
//
|
|
|
|
ULONGLONG FullNumberOfPhysicalPages;
|
|
|
|
//
|
|
// Reserved, available for reuse.
|
|
//
|
|
|
|
ULONGLONG SystemCallPad[1];
|
|
|
|
//
|
|
// The 64-bit tick count.
|
|
//
|
|
|
|
union
|
|
{
|
|
volatile KSYSTEM_TIME TickCount;
|
|
volatile ULONG64 TickCountQuad;
|
|
struct
|
|
{
|
|
ULONG ReservedTickCountOverlay[3];
|
|
ULONG TickCountPad[1];
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME3;
|
|
|
|
//
|
|
// Cookie for encoding pointers system wide.
|
|
//
|
|
|
|
ULONG Cookie;
|
|
ULONG CookiePad[1];
|
|
|
|
//
|
|
// Client id of the process having the focus in the current
|
|
// active console session id.
|
|
//
|
|
// N.B. This field must be accessed via the
|
|
// RtlGetConsoleSessionForegroundProcessId API for an accurate result.
|
|
//
|
|
|
|
LONGLONG ConsoleSessionForegroundProcessId;
|
|
|
|
//
|
|
// N.B. The following data is used to implement the precise time
|
|
// services. It is aligned on a 64-byte cache-line boundary and
|
|
// arranged in the order of typical accesses.
|
|
//
|
|
// Placeholder for the (internal) time update lock.
|
|
//
|
|
|
|
ULONGLONG TimeUpdateLock;
|
|
|
|
//
|
|
// The performance counter value used to establish the current system time.
|
|
//
|
|
|
|
ULONGLONG BaselineSystemTimeQpc;
|
|
|
|
//
|
|
// The performance counter value used to compute the last interrupt time.
|
|
//
|
|
|
|
ULONGLONG BaselineInterruptTimeQpc;
|
|
|
|
//
|
|
// The scaled number of system time seconds represented by a single
|
|
// performance count (this value may vary to achieve time synchronization).
|
|
//
|
|
|
|
ULONGLONG QpcSystemTimeIncrement;
|
|
|
|
//
|
|
// The scaled number of interrupt time seconds represented by a single
|
|
// performance count (this value is constant after the system is booted).
|
|
//
|
|
|
|
ULONGLONG QpcInterruptTimeIncrement;
|
|
|
|
//
|
|
// The scaling shift count applied to the performance counter system time
|
|
// increment.
|
|
//
|
|
|
|
UCHAR QpcSystemTimeIncrementShift;
|
|
|
|
//
|
|
// The scaling shift count applied to the performance counter interrupt time
|
|
// increment.
|
|
//
|
|
|
|
UCHAR QpcInterruptTimeIncrementShift;
|
|
|
|
//
|
|
// The count of unparked processors.
|
|
//
|
|
|
|
USHORT UnparkedProcessorCount;
|
|
|
|
//
|
|
// A bitmask of enclave features supported on this system.
|
|
//
|
|
// N.B. This field must be accessed via the RtlIsEnclaveFeaturePresent API for an
|
|
// accurate result.
|
|
//
|
|
|
|
ULONG EnclaveFeatureMask[4];
|
|
|
|
//
|
|
// Current coverage round for telemetry based coverage.
|
|
//
|
|
|
|
ULONG TelemetryCoverageRound;
|
|
|
|
//
|
|
// The following field is used for ETW user mode global logging
|
|
// (UMGL).
|
|
//
|
|
|
|
USHORT UserModeGlobalLogger[16];
|
|
|
|
//
|
|
// Settings that can enable the use of Image File Execution Options
|
|
// from HKCU in addition to the original HKLM.
|
|
//
|
|
|
|
ULONG ImageFileExecutionOptions;
|
|
|
|
//
|
|
// Generation of the kernel structure holding system language information
|
|
//
|
|
|
|
ULONG LangGenerationCount;
|
|
|
|
//
|
|
// Reserved (available for reuse).
|
|
//
|
|
|
|
ULONGLONG Reserved4;
|
|
|
|
//
|
|
// Current 64-bit interrupt time bias in 100ns units.
|
|
//
|
|
|
|
volatile ULONGLONG InterruptTimeBias;
|
|
|
|
//
|
|
// Current 64-bit performance counter bias, in performance counter units
|
|
// before the shift is applied.
|
|
//
|
|
|
|
volatile ULONGLONG QpcBias;
|
|
|
|
//
|
|
// Number of active logical processors.
|
|
//
|
|
|
|
ULONG ActiveProcessorCount;
|
|
|
|
//
|
|
// Number of active processor groups.
|
|
//
|
|
// N.B. This value is volatile because group membership and processor
|
|
// availability may change dynamically due to hot-add, hot-remove,
|
|
// or power management events.
|
|
//
|
|
|
|
volatile UCHAR ActiveGroupCount;
|
|
|
|
//
|
|
// Reserved (available for re-use).
|
|
//
|
|
|
|
UCHAR Reserved9;
|
|
|
|
union
|
|
{
|
|
USHORT QpcData;
|
|
struct
|
|
{
|
|
//
|
|
// A bitfield indicating whether performance counter queries can
|
|
// read the counter directly (bypassing the system call) and flags.
|
|
//
|
|
|
|
union
|
|
{
|
|
|
|
volatile UCHAR QpcBypassEnabled;
|
|
|
|
struct
|
|
{
|
|
//
|
|
// QPC may bypass the syscall and use a fast user-mode path.
|
|
//
|
|
volatile UCHAR BypassAllowed : 1;
|
|
|
|
//
|
|
// Hypervisor-assisted QPC conversion.
|
|
//
|
|
volatile UCHAR HypervisorAssist : 1;
|
|
|
|
//
|
|
// Reserved/unused
|
|
//
|
|
volatile UCHAR Reserved_2_3 : 2;
|
|
|
|
//
|
|
// MFENCE before RDTSC in relevant paths.
|
|
//
|
|
volatile UCHAR UseMfence : 1;
|
|
|
|
//
|
|
// LFENCE before RDTSC in relevant paths.
|
|
//
|
|
volatile UCHAR UseLfence : 1;
|
|
|
|
//
|
|
// Reserved/unused
|
|
//
|
|
volatile UCHAR Reserved_6 : 1;
|
|
|
|
//
|
|
// RDTSCP instead of RDTSC in the fast path.
|
|
//
|
|
volatile UCHAR UseRdtscp : 1;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
//
|
|
// Reserved, leave as zero for backward compatibility. Was shift
|
|
// applied to the raw counter value to derive QPC count.
|
|
//
|
|
|
|
UCHAR QpcReserved;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
|
|
//
|
|
// Reserved for future use.
|
|
//
|
|
|
|
LARGE_INTEGER TimeZoneBiasEffectiveStart;
|
|
LARGE_INTEGER TimeZoneBiasEffectiveEnd;
|
|
|
|
//
|
|
// Extended processor state configuration (AMD64 and x86).
|
|
//
|
|
|
|
#if (PHNT_VERSION == PHNT_WINDOWS_11_24H2)
|
|
XSTATE_CONFIGURATION_24H2 XState;
|
|
#else
|
|
XSTATE_CONFIGURATION XState;
|
|
#endif
|
|
|
|
KSYSTEM_TIME FeatureConfigurationChangeStamp;
|
|
ULONG Spare;
|
|
|
|
ULONG64 UserPointerAuthMask;
|
|
|
|
//
|
|
// Extended processor state configuration (ARM64). The reserved space for
|
|
// other architectures is not available for reuse.
|
|
//
|
|
|
|
#if defined(_ARM64_)
|
|
#if (PHNT_VERSION == PHNT_WINDOWS_11_24H2)
|
|
XSTATE_CONFIGURATION_24H2 XStateArm64;
|
|
#else
|
|
XSTATE_CONFIGURATION XStateArm64;
|
|
#endif
|
|
#else
|
|
ULONG Reserved10[210];
|
|
#endif
|
|
|
|
} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
|
|
|
|
#if (PHNT_VERSION == PHNT_WINDOWS_11_24H2)
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, FeatureConfigurationChangeStamp) == 0x720, "KUSER_SHARED_DATA feature stamp offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, UserPointerAuthMask) == 0x730, "KUSER_SHARED_DATA pointer auth mask offset is incorrect");
|
|
#endif
|
|
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountLowDeprecated) == 0x000, "KUSER_SHARED_DATA.TickCountLowDeprecated offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountMultiplier) == 0x004, "KUSER_SHARED_DATA.TickCountMultiplier offset is incorrect");
|
|
static_assert(__alignof(KSYSTEM_TIME) == 0X004, "KSYSTEM_TIME alignment is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, InterruptTime) == 0x008, "KUSER_SHARED_DATA.InterruptTime offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SystemTime) == 0x014, "KUSER_SHARED_DATA.SystemTime offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneBias) == 0x020, "KUSER_SHARED_DATA.TimeZoneBias offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ImageNumberLow) == 0x02c, "KUSER_SHARED_DATA.ImageNumberLow offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ImageNumberHigh) == 0x02e, "KUSER_SHARED_DATA.ImageNumberHigh offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NtSystemRoot) == 0x030, "KUSER_SHARED_DATA.NtSystemRoot offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, MaxStackTraceDepth) == 0x238, "KUSER_SHARED_DATA.MaxStackTraceDepth offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, CryptoExponent) == 0x23c, "KUSER_SHARED_DATA.CryptoExponent offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneId) == 0x240, "KUSER_SHARED_DATA.TimeZoneId offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, LargePageMinimum) == 0x244, "KUSER_SHARED_DATA.LargePageMinimum offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, AitSamplingValue) == 0x248, "KUSER_SHARED_DATA.AitSamplingValue offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, AppCompatFlag) == 0x24c, "KUSER_SHARED_DATA.AppCompatFlag offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, RNGSeedVersion) == 0x250, "KUSER_SHARED_DATA.RNGSeedVersion offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, GlobalValidationRunlevel) == 0x258, "KUSER_SHARED_DATA.GlobalValidationRunlevel offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneBiasStamp) == 0x25c, "KUSER_SHARED_DATA.TimeZoneBiasStamp offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NtBuildNumber) == 0x260, "KUSER_SHARED_DATA.NtBuildNumber offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NtProductType) == 0x264, "KUSER_SHARED_DATA.NtProductType offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ProductTypeIsValid) == 0x268, "KUSER_SHARED_DATA.ProductTypeIsValid offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NativeProcessorArchitecture) == 0x26a, "KUSER_SHARED_DATA.NativeProcessorArchitecture offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NtMajorVersion) == 0x26c, "KUSER_SHARED_DATA.NtMajorVersion offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NtMinorVersion) == 0x270, "KUSER_SHARED_DATA.NtMinorVersion offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ProcessorFeatures) == 0x274, "KUSER_SHARED_DATA.ProcessorFeatures offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, MaximumUserModeAddressDeprecated) == 0x2b4, "KUSER_SHARED_DATA.MaximumUserModeAddressDeprecated offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SystemRangeStartDeprecated) == 0x2b8, "KUSER_SHARED_DATA.SystemRangeStartDeprecated offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeSlip) == 0x2bc, "KUSER_SHARED_DATA.TimeSlip offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, AlternativeArchitecture) == 0x2c0, "KUSER_SHARED_DATA.AlternativeArchitecture offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SystemExpirationDate) == 0x2c8, "KUSER_SHARED_DATA.SystemExpirationDate offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SuiteMask) == 0x2d0, "KUSER_SHARED_DATA.SuiteMask offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, KdDebuggerEnabled) == 0x2d4, "KUSER_SHARED_DATA.KdDebuggerEnabled offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, MitigationPolicies) == 0x2d5, "KUSER_SHARED_DATA.MitigationPolicies offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, CyclesPerYield) == 0x2d6, "KUSER_SHARED_DATA.CyclesPerYield offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveConsoleId) == 0x2d8, "KUSER_SHARED_DATA.ActiveConsoleId offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, DismountCount) == 0x2dc, "KUSER_SHARED_DATA.DismountCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ComPlusPackage) == 0x2e0, "KUSER_SHARED_DATA.ComPlusPackage offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, LastSystemRITEventTickCount) == 0x2e4, "KUSER_SHARED_DATA.LastSystemRITEventTickCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, NumberOfPhysicalPages) == 0x2e8, "KUSER_SHARED_DATA.NumberOfPhysicalPages offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SafeBootMode) == 0x2ec, "KUSER_SHARED_DATA.SafeBootMode offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, VirtualizationFlags) == 0x2ed, "KUSER_SHARED_DATA.VirtualizationFlags offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved12) == 0x2ee, "KUSER_SHARED_DATA.Reserved12 offset is incorrect");
|
|
#if defined(_MSC_EXTENSIONS)
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SharedDataFlags) == 0x2f0, "KUSER_SHARED_DATA.SharedDataFlags offset is incorrect");
|
|
#endif
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TestRetInstruction) == 0x2f8, "KUSER_SHARED_DATA.TestRetInstruction offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcFrequency) == 0x300, "KUSER_SHARED_DATA.QpcFrequency offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCall) == 0x308, "KUSER_SHARED_DATA.SystemCall offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved2) == 0x30c, "KUSER_SHARED_DATA.Reserved2 offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, SystemCallPad) == 0x318, "KUSER_SHARED_DATA.SystemCallPad offset is incorrect (previously 0x310)");
|
|
#if defined(_MSC_EXTENSIONS)
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TickCount) == 0x320, "KUSER_SHARED_DATA.TickCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TickCountQuad) == 0x320, "KUSER_SHARED_DATA.TickCountQuad offset is incorrect");
|
|
#endif
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Cookie) == 0x330, "KUSER_SHARED_DATA.Cookie offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ConsoleSessionForegroundProcessId) == 0x338, "KUSER_SHARED_DATA.ConsoleSessionForegroundProcessId offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeUpdateLock) == 0x340, "KUSER_SHARED_DATA.TimeUpdateLock offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, BaselineSystemTimeQpc) == 0x348, "KUSER_SHARED_DATA.BaselineSystemTimeQpc offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, BaselineInterruptTimeQpc) == 0x350, "KUSER_SHARED_DATA.BaselineInterruptTimeQpc offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcSystemTimeIncrement) == 0x358, "KUSER_SHARED_DATA.QpcSystemTimeIncrement offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcInterruptTimeIncrement) == 0x360, "KUSER_SHARED_DATA.QpcInterruptTimeIncrement offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcSystemTimeIncrementShift) == 0x368, "KUSER_SHARED_DATA.QpcSystemTimeIncrementShift offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcInterruptTimeIncrementShift) == 0x369, "KUSER_SHARED_DATA.QpcInterruptTimeIncrementShift offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, UnparkedProcessorCount) == 0x36a, "KUSER_SHARED_DATA.UnparkedProcessorCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, EnclaveFeatureMask) == 0x36c, "KUSER_SHARED_DATA.EnclaveFeatureMask offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TelemetryCoverageRound) == 0x37c, "KUSER_SHARED_DATA.TelemetryCoverageRound offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, UserModeGlobalLogger) == 0x380, "KUSER_SHARED_DATA.UserModeGlobalLogger offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ImageFileExecutionOptions) == 0x3a0, "KUSER_SHARED_DATA.ImageFileExecutionOptions offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, LangGenerationCount) == 0x3a4, "KUSER_SHARED_DATA.LangGenerationCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved4) == 0x3a8, "KUSER_SHARED_DATA.Reserved4 offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, InterruptTimeBias) == 0x3b0, "KUSER_SHARED_DATA.InterruptTimeBias offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcBias) == 0x3b8, "KUSER_SHARED_DATA.QpcBias offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveProcessorCount) == 0x3c0, "KUSER_SHARED_DATA.ActiveProcessorCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, ActiveGroupCount) == 0x3c4, "KUSER_SHARED_DATA.ActiveGroupCount offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Reserved9) == 0x3c5, "KUSER_SHARED_DATA.Reserved9 offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcData) == 0x3c6, "KUSER_SHARED_DATA.QpcData offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcBypassEnabled) == 0x3c6, "KUSER_SHARED_DATA.QpcBypassEnabled offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, QpcReserved) == 0x3c7, "KUSER_SHARED_DATA.QpcReserved offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneBiasEffectiveStart) == 0x3c8, "KUSER_SHARED_DATA.TimeZoneBiasEffectiveStart offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, TimeZoneBiasEffectiveEnd) == 0x3d0, "KUSER_SHARED_DATA.TimeZoneBiasEffectiveEnd offset is incorrect");
|
|
static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, XState) == 0x3d8, "KUSER_SHARED_DATA.XState offset is incorrect");
|
|
//static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, FeatureConfigurationChangeStamp) == 0x720, "KUSER_SHARED_DATA.FeatureConfigurationChangeStamp offset is incorrect");
|
|
//static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, Spare) == 0x72c, "KUSER_SHARED_DATA.Spare offset is incorrect");
|
|
//static_assert(FIELD_OFFSET(KUSER_SHARED_DATA, UserPointerAuthMask) == 0x730, "KUSER_SHARED_DATA.UserPointerAuthMask offset is incorrect");
|
|
//#if !defined(WINDOWS_IGNORE_PACKING_MISMATCH)
|
|
//static_assert(sizeof(KUSER_SHARED_DATA) == 0xa80, "KUSER_SHARED_DATA size is incorrect (expected 0xa80)");
|
|
//#endif
|
|
|
|
/**
|
|
* USER_SHARED_DATA pointer to the Windows KUSER_SHARED_DATA structure at its fixed
|
|
* user-mode mapping address (0x7FFE0000).
|
|
*
|
|
* The Windows kernel exposes a read-only data structure, mapped into every user-mode
|
|
* process at the fixed virtual address `0x7FFE0000`. This region contains frequently
|
|
* accessed system information and avoids the overhead of system calls for data that
|
|
* the kernel updates frequently. The mapping is always present and identical across
|
|
* all user processes, it provides a fast and efficient way to retrieve system state.
|
|
*/
|
|
#define USER_SHARED_DATA ((KUSER_SHARED_DATA * const)0x7ffe0000)
|
|
|
|
/**
|
|
* The NtGetTickCount64 routine retrieves the number of milliseconds that have elapsed since the system was started.
|
|
*
|
|
* \return ULONGLONG The return value is the number of milliseconds that have elapsed since the system was started.
|
|
* \remarks The resolution of the NtGetTickCount64 function is limited to the resolution of the system timer,
|
|
* which is typically in the range of 10 milliseconds to 16 milliseconds. The resolution of the NtGetTickCount64
|
|
* function is not affected by adjustments made by the GetSystemTimeAdjustment function.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount64
|
|
*/
|
|
FORCEINLINE
|
|
ULONGLONG
|
|
NtGetTickCount64(
|
|
VOID
|
|
)
|
|
{
|
|
ULARGE_INTEGER tickCount;
|
|
|
|
#ifdef _WIN64
|
|
|
|
tickCount.QuadPart = USER_SHARED_DATA->TickCountQuad;
|
|
|
|
#else
|
|
|
|
while (TRUE)
|
|
{
|
|
// ARM64 builds default to /volatile:iso, where volatile loads have no ordering guarantee
|
|
// and the CPU can reorder them. Without acquire semantics it could read High2Time or LowPart
|
|
// before High1Time, and a torn value could pass the check because a stale High1Time would
|
|
// still match High2Time. The window is rare, but it exists. The kernel writes High2Time,
|
|
// LowPart, then High1Time, so read High1Time, LowPart, then High2Time with acquire ordering.
|
|
tickCount.HighPart = (ULONG)ReadAcquire(&USER_SHARED_DATA->TickCount.High1Time);
|
|
tickCount.LowPart = (ULONG)ReadAcquire((volatile LONG*)&USER_SHARED_DATA->TickCount.LowPart);
|
|
|
|
if (tickCount.HighPart == (ULONG)ReadNoFence(&USER_SHARED_DATA->TickCount.High2Time))
|
|
break;
|
|
|
|
YieldProcessor();
|
|
}
|
|
|
|
#endif
|
|
|
|
return (UInt32x32To64(tickCount.LowPart, USER_SHARED_DATA->TickCountMultiplier) >> 24) +
|
|
(UInt32x32To64(tickCount.HighPart, USER_SHARED_DATA->TickCountMultiplier) << 8);
|
|
}
|
|
|
|
/**
|
|
* The NtGetTickCount routine retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
|
|
*
|
|
* \return ULONG The return value is the number of milliseconds that have elapsed since the system was started.
|
|
* \remarks The elapsed time is stored as a ULONG value. Therefore, the time will wrap around to zero if the system
|
|
* is run continuously for 49.7 days. To avoid this problem, use the NtGetTickCount64 function. Otherwise, check
|
|
* for an overflow condition when comparing times. The resolution of the NtGetTickCount function is limited to
|
|
* the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds.
|
|
* The resolution of the NtGetTickCount function is not affected by adjustments made by the GetSystemTimeAdjustment function.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount
|
|
*/
|
|
FORCEINLINE
|
|
ULONG
|
|
NtGetTickCount(
|
|
VOID
|
|
)
|
|
{
|
|
#ifdef _WIN64
|
|
|
|
return (ULONG)((USER_SHARED_DATA->TickCountQuad * USER_SHARED_DATA->TickCountMultiplier) >> 24);
|
|
|
|
#else
|
|
|
|
ULARGE_INTEGER tickCount;
|
|
|
|
while (TRUE)
|
|
{
|
|
// ARM64 builds default to /volatile:iso, where volatile loads have no ordering guarantee
|
|
// and the CPU can reorder them. Without acquire semantics it could read High2Time or LowPart
|
|
// before High1Time, and a torn value could pass the check because a stale High1Time would
|
|
// still match High2Time. The window is rare, but it exists. The kernel writes High2Time,
|
|
// LowPart, then High1Time, so read High1Time, LowPart, then High2Time with acquire ordering.
|
|
tickCount.HighPart = (ULONG)ReadAcquire(&USER_SHARED_DATA->TickCount.High1Time);
|
|
tickCount.LowPart = (ULONG)ReadAcquire((volatile LONG*)&USER_SHARED_DATA->TickCount.LowPart);
|
|
|
|
if (tickCount.HighPart == (ULONG)ReadNoFence(&USER_SHARED_DATA->TickCount.High2Time))
|
|
break;
|
|
|
|
YieldProcessor();
|
|
}
|
|
|
|
return (ULONG)((UInt32x32To64(tickCount.LowPart, USER_SHARED_DATA->TickCountMultiplier) >> 24) +
|
|
UInt32x32To64((tickCount.HighPart << 8) & 0xffffffff, USER_SHARED_DATA->TickCountMultiplier));
|
|
|
|
#endif
|
|
}
|
|
|
|
//
|
|
// Locale
|
|
//
|
|
|
|
/**
|
|
* The NtQueryDefaultLocale routine retrieves the default locale identifier for either the user profile or the system.
|
|
*
|
|
* \param UserProfile If TRUE, retrieves the user default locale; otherwise, retrieves the system default locale.
|
|
* \param DefaultLocaleId A pointer that receives the resulting locale identifier (LCID).
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getsystemdefaultlocale
|
|
* \sa https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getuserdefaultlocale
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryDefaultLocale(
|
|
_In_ BOOLEAN UserProfile,
|
|
_Out_ PLCID DefaultLocaleId
|
|
);
|
|
|
|
/**
|
|
* The NtSetDefaultLocale routine sets the default locale identifier for either
|
|
* the user profile or the system.
|
|
*
|
|
* \param UserProfile If TRUE, sets the user default locale; otherwise, sets the system default locale.
|
|
* \param DefaultLocaleId The locale identifier (LCID) to set.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-setthreadlocale
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetDefaultLocale(
|
|
_In_ BOOLEAN UserProfile,
|
|
_In_ LCID DefaultLocaleId
|
|
);
|
|
|
|
/**
|
|
* The NtQueryInstallUILanguage routine retrieves the system's installed UI language identifier.
|
|
*
|
|
* \param InstallUILanguageId A pointer that receives the installed UI language identifier (LANGID).
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getsystemdefaultuilanguage
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryInstallUILanguage(
|
|
_Out_ LANGID *InstallUILanguageId
|
|
);
|
|
|
|
/**
|
|
* The NtFlushInstallUILanguage routine updates the system's installed UI
|
|
* language and optionally commits the change.
|
|
*
|
|
* \param InstallUILanguage The UI language identifier (LANGID) to set.
|
|
* \param SetComittedFlag If nonzero, commits the language change.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtFlushInstallUILanguage(
|
|
_In_ LANGID InstallUILanguage,
|
|
_In_ ULONG SetComittedFlag
|
|
);
|
|
|
|
/**
|
|
* The NtQueryDefaultUILanguage routine retrieves the system's default UI language identifier.
|
|
*
|
|
* \param DefaultUILanguageId A pointer that receives the default UI language identifier (LANGID).
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winnls/nf-winnls-getsystemdefaultuilanguage
|
|
* \remarks On native this entry forwards to NtQueryInstallUILanguage.
|
|
* Do not infer a distinct per-thread UI-language selection from this syscall name. The output remains a
|
|
* 2-byte LANGID, not a locale-name string or a 4-byte LCID.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryDefaultUILanguage(
|
|
_Out_ LANGID *DefaultUILanguageId
|
|
);
|
|
|
|
/**
|
|
* The NtSetDefaultUILanguage routine sets the system's default UI language identifier.
|
|
*
|
|
* \param DefaultUILanguageId The UI language identifier (LANGID) to set.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetDefaultUILanguage(
|
|
_In_ LANGID DefaultUILanguageId
|
|
);
|
|
|
|
/**
|
|
* The NtIsUILanguageComitted routine determines whether the system UI language has been committed.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks Returns an NTSTATUS result: STATUS_SUCCESS when the global committed state is set,
|
|
* otherwise STATUS_OBJECT_NAME_NOT_FOUND (0xC0000034). It is not a BOOLEAN return
|
|
* despite its predicate-style name; retain the exported spelling Comitted.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtIsUILanguageComitted(
|
|
VOID
|
|
);
|
|
|
|
//
|
|
// NLS
|
|
//
|
|
|
|
// begin_private
|
|
|
|
/**
|
|
* The NtInitializeNlsFiles routine maps the National Language Support (NLS) data files into memory.
|
|
*
|
|
* \param BaseAddress A pointer to a variable that receives the base address of the mapped NLS data.
|
|
* \param DefaultLocaleId A pointer to a variable that receives the default locale identifier.
|
|
* \param DefaultCasingTableSize A pointer to a variable that receives the size of the default casing table, in bytes. This parameter is optional.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtInitializeNlsFiles(
|
|
_Out_ PVOID *BaseAddress,
|
|
_Out_ PLCID DefaultLocaleId,
|
|
_Out_opt_ PLARGE_INTEGER DefaultCasingTableSize
|
|
);
|
|
|
|
/**
|
|
* The NtGetNlsSectionPtr routine retrieves a pointer to a National Language Support (NLS) section of the specified type.
|
|
*
|
|
* \param SectionType The type of the NLS section to retrieve.
|
|
* \param SectionData The data identifying the NLS section to retrieve.
|
|
* \param ContextData A pointer to a variable that receives context data. This must be NULL for user-mode callers. This parameter is optional.
|
|
* \param SectionPointer A pointer to a variable that receives the pointer to the NLS section.
|
|
* \param SectionSize A pointer to a variable that receives the size of the NLS section, in bytes. This parameter is optional.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtGetNlsSectionPtr(
|
|
_In_ ULONG SectionType,
|
|
_In_ ULONG SectionData,
|
|
_Out_opt_ PVOID *ContextData, // Must be NULL for user-mode callers.
|
|
_When_(ContextData == NULL, _Out_) _When_(ContextData != NULL, _Out_opt_) PVOID *SectionPointer,
|
|
_Out_opt_ PSIZE_T SectionSize
|
|
);
|
|
|
|
#if (PHNT_VERSION < PHNT_WINDOWS_7)
|
|
/**
|
|
* The NtAcquireCMFViewOwnership routine acquires ownership of the Code Map
|
|
* File (CMF) view and optionally replaces an existing ownership token.
|
|
*
|
|
* \param TimeStamp A pointer that receives the timestamp associated with the
|
|
* CMF view ownership.
|
|
* \param tokenTaken A pointer that receives TRUE if the caller successfully
|
|
* acquired the ownership token, or FALSE if another owner already held it.
|
|
* \param replaceExisting If TRUE, replaces any existing ownership token.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAcquireCMFViewOwnership(
|
|
_Out_ PULONGLONG TimeStamp,
|
|
_Out_ PBOOLEAN tokenTaken,
|
|
_In_ BOOLEAN replaceExisting
|
|
);
|
|
|
|
/**
|
|
* The NtReleaseCMFViewOwnership routine releases ownership of the Code Map
|
|
* File (CMF) view previously acquired by NtAcquireCMFViewOwnership.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtReleaseCMFViewOwnership(
|
|
VOID
|
|
);
|
|
#endif // PHNT_VERSION < PHNT_WINDOWS_7
|
|
|
|
/**
|
|
* The `What` flags for NtMapCMFModule.
|
|
* The `What` parameter is a bitfield controlling:
|
|
* - Which CMF section to map
|
|
* - Access rights for CMFCheckAccess()
|
|
* - Whether to update CMF global flags
|
|
* - Page protection mode
|
|
* - CMF cache mode bits (propagate into CMFFlagsCache)
|
|
*
|
|
* These determine what access rights are checked and influence whether the mapping is allowed.
|
|
*/
|
|
#define CMF_ACCESS_DIRECTORY 0x00000002 // Access check for directory section.
|
|
#define CMF_ACCESS_SEGMENT 0x00000004 // Access check for segment section.
|
|
#define CMF_ACCESS_HITS 0x00000008 // Access check for hits section.
|
|
/**
|
|
* The `What` flags for NtMapCMFModule.
|
|
* These determine which CMF section is mapped and directly control the BaseAddress and ViewSizeOut outputs.
|
|
*/
|
|
#define CMF_OP_DIRECTORY 0x00000010 // Map directory section (Index ignored) // Affects: BaseAddress, ViewSizeOut
|
|
#define CMF_OP_SEGMENT 0x00000020 // Map segment section at Index // Affects: BaseAddress, ViewSizeOut
|
|
#define CMF_OP_HITS 0x00000100 // Map hits section (Index ignored) // Affects: BaseAddress, ViewSizeOut
|
|
/**
|
|
* The `What` flags for NtMapCMFModule.
|
|
* This affects the protection flags passed to MmMapViewOfSection,
|
|
* which ultimately influences the memory protections of the BaseAddress parameter.
|
|
*/
|
|
#define CMF_PROTECT_SPECIAL 0x00000040 // Changes protection from PAGE_READONLY to PAGE_WRITECOPY
|
|
/**
|
|
* The `What` flags for NtMapCMFModule.
|
|
* When this bit is set, the function does not map anything.
|
|
* Instead, it updates CMFFlagsCache and optionally modifies the directory header.
|
|
*/
|
|
#define CMF_UPDATE_FLAGS 0x00020000 // Enter flag-update mode // CacheFlagsOut parameter
|
|
/**
|
|
* The `What` flags for NtMapCMFModule.
|
|
* These bits are extracted from What and written into CMFFlagsCache.
|
|
* They determine global CMF behavior, including which modules are valid.
|
|
*/
|
|
#define CMF_FLAG_A 0x00040000 // May trigger directory header update
|
|
#define CMF_FLAG_B 0x00080000 // Enables directory update path
|
|
#define CMF_FLAG_C 0x00100000 // Enables segment unmap path
|
|
/**
|
|
* Flags for NtMapCMFModule.
|
|
* These bits strip all bits outside this mask:
|
|
*/
|
|
#define CMF_ALLOWED_MASK 0xFFFFFECF // All valid bits for What
|
|
/**
|
|
* Flags for NtMapCMFModule.
|
|
*/
|
|
typedef enum _CMF_WHAT_FLAGS
|
|
{
|
|
// ---- Access rights (used by CMFCheckAccess) ----
|
|
CmfAccessDirectory = 0x00000002, // Access check for directory
|
|
CmfAccessSegment = 0x00000004, // Access check for segment[Index]
|
|
CmfAccessHits = 0x00000008, // Access check for hits
|
|
// ---- Operation selection (controls BaseAddress + ViewSizeOut) ----
|
|
CmfDirectoryOp = 0x00000010, // Map directory section
|
|
CmfSegmentOp = 0x00000020, // Map segment section at Index
|
|
CmfHitsOp = 0x00000100, // Map hits section
|
|
// ---- Memory protection modifier ----
|
|
CmfSpecialProtect = 0x00000040, // Changes protection for MmMapViewOfSection
|
|
// ---- Flag update mode (affects CacheFlagsOut only) ----
|
|
CmfUpdateFlags = 0x00020000, // Update CMFFlagsCache instead of mapping
|
|
// ---- CMF cache mode bits (propagate into CMFFlagsCache) ----
|
|
CmfFlagA = 0x00040000, // May trigger directory header update
|
|
CmfFlagB = 0x00080000, // Enables directory update path
|
|
CmfFlagC = 0x00100000, // Enables segment unmap path
|
|
} CMF_WHAT_FLAGS;
|
|
DEFINE_ENUM_FLAG_OPERATORS(CMF_WHAT_FLAGS);
|
|
|
|
/**
|
|
* The NtMapCMFModule routine maps a Code Map File (CMF) module into memory
|
|
* and returns information about the cached view.
|
|
*
|
|
* \param What Specifies the CMF operation to perform.
|
|
* \param Index The module index to map. Only valid for CmfSegmentOp operations.
|
|
* \param CacheIndexOut Optional pointer that receives the cache index.
|
|
* \param CacheFlagsOut Optional pointer that receives cache flags.
|
|
* \param ViewSizeOut Optional pointer that receives the size of the mapped view.
|
|
* \param BaseAddress Optional pointer that receives the base address of the mapped module.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtMapCMFModule(
|
|
_In_ ULONG What,
|
|
_In_ ULONG Index,
|
|
_Out_opt_ PULONG CacheIndexOut,
|
|
_Out_opt_ PULONG CacheFlagsOut,
|
|
_Out_opt_ PULONG ViewSizeOut,
|
|
_Out_opt_ PVOID *BaseAddress
|
|
);
|
|
|
|
/**
|
|
* Flags for NtGetMUIRegistryInfo.
|
|
* Only the values below are supported. Any other bit results in STATUS_INVALID_PARAMETER.
|
|
*/
|
|
typedef enum _MUI_REGISTRY_INFO_FLAGS
|
|
{
|
|
MUIRegInfoQuery = 0x1, // Query or load the MUI registry info.
|
|
MUIRegInfoClear = 0x2, // Clear the cached MUI registry info.
|
|
MUIRegInfoCommit = 0x8 // Commit/update state (increments counter).
|
|
} MUI_REGISTRY_INFO_FLAGS;
|
|
DEFINE_ENUM_FLAG_OPERATORS(MUI_REGISTRY_INFO_FLAGS);
|
|
|
|
/**
|
|
* Flags for NtGetMUIRegistryInfo.
|
|
* Only the values below are supported. Any other bit results in STATUS_INVALID_PARAMETER.
|
|
*/
|
|
#define MUI_REGINFO_QUERY 0x1 // Query or load the MUI registry info.
|
|
#define MUI_REGINFO_CLEAR 0x2 // Clear the cached MUI registry info.
|
|
#define MUI_REGINFO_COMMIT 0x8 // Commit/update state (increments counter).
|
|
|
|
/**
|
|
* The NtGetMUIRegistryInfo routine retrieves Multilingual User Interface (MUI)
|
|
* configuration data from the system registry.
|
|
*
|
|
* \param Flags Flags that control the type of MUI information returned.
|
|
* \param DataSize On input, the size of the buffer pointed to by Data.
|
|
* On output, the required or actual size of the data returned.
|
|
* \param Data A pointer to the MUI registry information.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks This routine is private and subject to change.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtGetMUIRegistryInfo(
|
|
_In_ ULONG Flags,
|
|
_Inout_ PULONG DataSize,
|
|
_Out_ PVOID Data
|
|
);
|
|
|
|
// end_private
|
|
|
|
//
|
|
// Global atoms
|
|
//
|
|
|
|
/**
|
|
* The NtAddAtom routine adds or references a name in the atom table obtained from the current session's Win32
|
|
* callout. This is not the per-process local table managed by AddAtomW. The x64 entry forwards to NtAddAtomEx
|
|
* with Flags = 0.
|
|
*
|
|
* \param AtomName Readable UTF-16 name. User-mode input is captured by Length and
|
|
* terminated by the kernel; a source terminator need not be included. An embedded
|
|
* NUL ends the effective name. NULL does not create an unnamed atom.
|
|
* \param Length Bytes to capture, at most 510 (255 WCHARs). Supply an even length
|
|
* excluding the source terminator. An odd trailing byte is
|
|
* discarded when the captured buffer is terminated; nonzero input requires 2-byte alignment.
|
|
* \param Atom Optional output for the 16-bit identifier. Omitting it does not
|
|
* suppress the addition or its reference-count increment.
|
|
* \return NTSTATUS. Empty names return STATUS_OBJECT_NAME_INVALID; Length above
|
|
* 510 and a NULL name return STATUS_INVALID_PARAMETER.
|
|
* \remarks Ordinary string matching is case-insensitive and preserves the first
|
|
* inserted spelling. Each successful string addition owns a reference to balance
|
|
* with NtDeleteAtom; the identifier is not a handle for NtClose. Integer strings
|
|
* such as L"#123" select integer atoms without allocating a string entry.
|
|
* Kernel-mode callers are not covered by the user-buffer capture rules above.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaladdatomw
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAddAtom(
|
|
_In_reads_bytes_opt_(Length) PCWSTR AtomName,
|
|
_In_ ULONG Length,
|
|
_Out_opt_ PRTL_ATOM Atom
|
|
);
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_8)
|
|
|
|
/**
|
|
* No extra entry-visibility flag. NtAddAtom uses this value. Both 0 and 0x2
|
|
* operate on the table selected by the session Win32 callout; this is not a
|
|
* selector for the per-process local atom table.
|
|
*/
|
|
#define ATOM_FLAG_NONE 0x0
|
|
/**
|
|
* Marks a newly allocated entry with bit 0x2, which permits the global-entry
|
|
* path in RtlpAllowsLowBoxAccess on x64. It does not select a separate
|
|
* machine-global table, and re-adding a name does not update this flag.
|
|
* Lowbox/AppContainer behavior is distinct from cross-session visibility.
|
|
*/
|
|
#define ATOM_FLAG_GLOBAL 0x2
|
|
|
|
// rev
|
|
/**
|
|
* The NtAddAtomEx routine adds or references an atom with an optional entry-visibility flag. The name capture
|
|
* and reference-ownership rules are those of NtAddAtom.
|
|
*
|
|
* \param AtomName Readable UTF-16 name; the kernel terminates the user-mode copy.
|
|
* \param Length Bytes to capture, at most 510 (255 WCHARs). Use an even byte count;
|
|
* nonzero user input requires 2-byte alignment on x64 and WoW64.
|
|
* \param Atom Optional 16-bit output. NULL still performs the addition.
|
|
* \param Flags ATOM_FLAG_NONE (0) or ATOM_FLAG_GLOBAL (0x2); other bits return
|
|
* STATUS_INVALID_PARAMETER. The flag is stored only when a new entry is allocated.
|
|
* \return NTSTATUS describing the addition. A successful string add creates a
|
|
* reference that the caller must balance with NtDeleteAtom.
|
|
* \remarks Both flag values use the table obtained from the same session Win32
|
|
* callout. Bit 0x2 is an entry flag consulted by RtlpAllowsLowBoxAccess, not a switch
|
|
* to a separate machine-global table. Re-adding an existing name with different
|
|
* Flags increments its reference count but does not change its stored flag.
|
|
* Lowbox/AppContainer visibility and accounting are context-sensitive; do not
|
|
* infer cross-session visibility or access to every existing atom from this flag.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaladdatomexw
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtAddAtomEx(
|
|
_In_reads_bytes_opt_(Length) PCWSTR AtomName,
|
|
_In_ ULONG Length,
|
|
_Out_opt_ PRTL_ATOM Atom,
|
|
_In_ ULONG Flags
|
|
);
|
|
|
|
#endif // PHNT_VERSION >= PHNT_WINDOWS_8
|
|
|
|
/**
|
|
* The NtFindAtom routine looks up a name in the atom table selected by the session Win32 callout. Use
|
|
* NtAddAtom when a new ordinary string reference is required, not merely lookup.
|
|
*
|
|
* \param AtomName Readable UTF-16 name. The user-mode copy is terminated after capture; matching is
|
|
* case-insensitive and an embedded NUL ends the effective name.
|
|
* \param Length Bytes to capture, at most 510 (255 WCHARs). Use an even count and 2-byte-aligned source. The
|
|
* kernel discards an odd trailing byte.
|
|
* \param Atom Optional 16-bit output; NULL performs a lookup without returning the ID.
|
|
* \return STATUS_OBJECT_NAME_NOT_FOUND if absent, STATUS_OBJECT_NAME_INVALID for an empty captured name, or
|
|
* the lookup's NTSTATUS. On the native x64 path and WoW64, failure paths leave a supplied output identifier
|
|
* unchanged.
|
|
* \remarks For ordinary non-AppContainer callers, lookup does not add a reference: do not delete an atom
|
|
* merely because lookup found it. Lowbox lookup can establish internal bookkeeping references; that
|
|
* implementation detail is not a caller-owned NtAddAtom reference. Integer strings in the range L"#1" through
|
|
* L"#49151" resolve without a prior string-table insertion.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globalfindatomw
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtFindAtom(
|
|
_In_reads_bytes_opt_(Length) PCWSTR AtomName,
|
|
_In_ ULONG Length,
|
|
_Out_opt_ PRTL_ATOM Atom
|
|
);
|
|
|
|
/**
|
|
* The NtDeleteAtom routine releases one caller-owned ordinary string-atom reference. The table entry is
|
|
* removed when its unpinned reference count reaches zero; identifiers may be reused.
|
|
*
|
|
* \param Atom A 16-bit atom identifier, not an object handle. Balance additions,
|
|
* not lookups, and do not delete references owned by unrelated code.
|
|
* \return NTSTATUS. Integer atoms 1 through 0xBFFF return STATUS_SUCCESS without
|
|
* removing a string entry. Zero or an invalid string identifier returns
|
|
* STATUS_INVALID_HANDLE. A pinned string entry returns
|
|
* informational STATUS_WAS_LOCKED (0x40000019) without being decremented or removed.
|
|
* \remarks NT_SUCCESS does not prove that an entry disappeared. Other references,
|
|
* pinning and lowbox accounting can retain it. The pin/saturation paths are distinct
|
|
* from the ordinary balanced-add/delete lifetime.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-globaldeleteatom
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDeleteAtom(
|
|
_In_ RTL_ATOM Atom
|
|
);
|
|
|
|
/**
|
|
* The ATOM_INFORMATION_CLASS enumeration specifies the type of information
|
|
* returned when querying atom table data.
|
|
*/
|
|
typedef enum _ATOM_INFORMATION_CLASS
|
|
{
|
|
AtomBasicInformation, // 0: ATOM_BASIC_INFORMATION, 6-byte prefix plus name and terminator.
|
|
AtomTableInformation // 1: ATOM_TABLE_INFORMATION; Atom input is ignored.
|
|
} ATOM_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* Basic atom snapshot. The fixed prefix is 6 bytes; sizeof is 8 because Name[1]
|
|
* includes a WCHAR. On the native x64 and WoW64 paths, successful queries append
|
|
* a NUL after the copied name. They can return STATUS_SUCCESS after truncation,
|
|
* so NameLength is the copied byte count, not necessarily the complete name length.
|
|
* Reserve 518 bytes (6 + 255 WCHARs + terminator) for an untruncated maximum name.
|
|
*/
|
|
typedef struct _ATOM_BASIC_INFORMATION
|
|
{
|
|
USHORT UsageCount; // Reference snapshot; integer atoms report 1. Not an ownership grant.
|
|
USHORT Flags; // Bit 0x1: pinned; bit 0x2: global-entry lowbox access flag. Not NtAddAtomEx input flags in general.
|
|
USHORT NameLength; // Bytes copied into Name, excluding the trailing WCHAR NUL; may be truncated.
|
|
_Field_size_bytes_(NameLength) WCHAR Name[1]; // Variable-length name, followed by a NUL on successful query.
|
|
} ATOM_BASIC_INFORMATION, *PATOM_BASIC_INFORMATION;
|
|
|
|
/**
|
|
* Visible string-atom identifiers for AtomTableInformation. The array starts at
|
|
* byte 4 and each RTL_ATOM is 2 bytes. On insufficient capacity the query copies
|
|
* the prefix that fits and returns STATUS_INFO_LENGTH_MISMATCH; NumberOfAtoms
|
|
* still reports the total visible count, not how many entries were copied.
|
|
* On that failure read at most (buffer length - 4) / 2 entries, not NumberOfAtoms.
|
|
* The table can change between calls, so allocation from the count may need retry.
|
|
*/
|
|
typedef struct _ATOM_TABLE_INFORMATION
|
|
{
|
|
ULONG NumberOfAtoms; // Total visible string-atom count; can exceed the returned array capacity on failure.
|
|
_Field_size_(NumberOfAtoms) RTL_ATOM Atoms[1]; // Complete array only on success; no acquired atom references.
|
|
} ATOM_TABLE_INFORMATION, *PATOM_TABLE_INFORMATION;
|
|
|
|
/**
|
|
* The NtQueryInformationAtom routine retrieves an atom's name/reference snapshot or a list of visible string
|
|
* atoms. The layouts contain no pointers and are shared by native x64 and WoW64 callers.
|
|
*
|
|
* \param Atom Identifier for AtomBasicInformation (0); ignored for AtomTableInformation (1).
|
|
* \param AtomInformationClass Basic information (0) or table enumeration (1).
|
|
* \param AtomInformation Writable, 4-byte-aligned user buffer on x64 and its WoW64 path.
|
|
* See the selected structure for partial-result semantics.
|
|
* \param AtomInformationLength Bytes available. Basic information requires at least
|
|
* the 6-byte prefix; table information requires at least the 4-byte count prefix.
|
|
* A shorter buffer returns STATUS_INFO_LENGTH_MISMATCH without updating ReturnLength.
|
|
* \param ReturnLength Optional ULONG. For successful basic queries receives
|
|
* 8 + NameLength (6-byte prefix, copied name, 2-byte terminator), not necessarily
|
|
* the size required for the full name. On basic-query failure after the minimum
|
|
* length check it receives 6. For table enumeration it receives 4 on insufficient
|
|
* capacity, or 4 + 2 * NumberOfAtoms on success; it is not a universal sizing oracle.
|
|
* \return NTSTATUS. Basic queries can succeed with a truncated name. A buffer with
|
|
* no room for at least one WCHAR plus its terminator returns STATUS_BUFFER_TOO_SMALL
|
|
* for a nonempty name. Table queries can return a partial array with
|
|
* STATUS_INFO_LENGTH_MISMATCH and the total count in NumberOfAtoms.
|
|
* \remarks Allocate enough for the maximum name when a complete string is needed:
|
|
* 6 + 510 + 2 = 518 bytes. NULL/zero-length discovery does not report that size.
|
|
* An unsupported class returns STATUS_INVALID_INFO_CLASS; native x64 writes
|
|
* ReturnLength = 0, whereas the WoW64 thunk rejects it before the kernel
|
|
* and leaves ReturnLength unchanged. Buffer probing can fail before class validation.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryInformationAtom(
|
|
_In_ RTL_ATOM Atom,
|
|
_In_ ATOM_INFORMATION_CLASS AtomInformationClass,
|
|
_Out_writes_bytes_(AtomInformationLength) PVOID AtomInformation,
|
|
_In_ ULONG AtomInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
|
|
//
|
|
// Global flags (NtGlobalFlag)
|
|
//
|
|
// \see https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/gflags-flag-table
|
|
//
|
|
|
|
#define FLG_STOP_ON_EXCEPTION 0x00000001 // Stop on exception (R,K,I)
|
|
#define FLG_SHOW_LDR_SNAPS 0x00000002 // Show loader snaps (R,K,I)
|
|
#define FLG_DEBUG_INITIAL_COMMAND 0x00000004 // Debug initial command (R)
|
|
#define FLG_STOP_ON_HUNG_GUI 0x00000008 // Stop on hung GUI (K)
|
|
#define FLG_HEAP_ENABLE_TAIL_CHECK 0x00000010 // Enable heap tail checking (R,K,I)
|
|
#define FLG_HEAP_ENABLE_FREE_CHECK 0x00000020 // Enable heap free checking (R,K,I)
|
|
#define FLG_HEAP_VALIDATE_PARAMETERS 0x00000040 // Enable heap parameter checking (R,K,I)
|
|
#define FLG_HEAP_VALIDATE_ALL 0x00000080 // Enable heap validation on call (R,K,I)
|
|
#define FLG_APPLICATION_VERIFIER 0x00000100 // Enable application verifier (R,K,I)
|
|
#define FLG_MONITOR_SILENT_PROCESS_EXIT 0x00000200 // Enable silent process exit monitoring (R)
|
|
#define FLG_POOL_ENABLE_TAGGING 0x00000400 // Enable pool tagging (R)
|
|
#define FLG_HEAP_ENABLE_TAGGING 0x00000800 // Enable heap tagging (R,K,I)
|
|
#define FLG_USER_STACK_TRACE_DB 0x00001000 // Create user mode stack trace database (R,K,I)
|
|
#define FLG_KERNEL_STACK_TRACE_DB 0x00002000 // Create kernel mode stack trace database (R)
|
|
#define FLG_MAINTAIN_OBJECT_TYPELIST 0x00004000 // Maintain a list of objects for each type (R)
|
|
#define FLG_HEAP_ENABLE_TAG_BY_DLL 0x00008000 // Enable heap tagging by DLL (R,K,I)
|
|
#define FLG_DISABLE_STACK_EXTENSION 0x00010000 // Disable stack extension (I)
|
|
#define FLG_ENABLE_CSRDEBUG 0x00020000 // Enable debugging of Win32 subsystem (R)
|
|
#define FLG_ENABLE_KDEBUG_SYMBOL_LOAD 0x00040000 // Enable loading of kernel debugger symbols (R,K)
|
|
#define FLG_DISABLE_PAGE_KERNEL_STACKS 0x00080000 // Disable paging of kernel stacks (R)
|
|
#define FLG_ENABLE_SYSTEM_CRIT_BREAKS 0x00100000 // Enable system critical breaks (R,K,I)
|
|
#define FLG_HEAP_DISABLE_COALESCING 0x00200000 // Disable heap coalesce on free (R,K,I)
|
|
#define FLG_ENABLE_CLOSE_EXCEPTIONS 0x00400000 // Enable close exception (R,K)
|
|
#define FLG_ENABLE_EXCEPTION_LOGGING 0x00800000 // Enable exception logging (R,K)
|
|
#define FLG_ENABLE_HANDLE_TYPE_TAGGING 0x01000000 // Enable object handle type tagging (R,K)
|
|
#define FLG_HEAP_PAGE_ALLOCS 0x02000000 // Enable page heap (R,K,I)
|
|
#define FLG_DEBUG_INITIAL_COMMAND_EX 0x04000000 // Debug WinLogon (R)
|
|
#define FLG_DISABLE_DBGPRINT 0x08000000 // Buffer DbgPrint Output (R,K)
|
|
#define FLG_CRITSEC_EVENT_CREATION 0x10000000 // Early critical section event creation (R,K,I)
|
|
#define FLG_STOP_ON_UNHANDLED_EXCEPTION 0x20000000 // Stop on unhandled user-mode exception (R,K,I)
|
|
#define FLG_LDR_TOP_DOWN 0x20000000 // Load image using large pages if possible (I)
|
|
#define FLG_ENABLE_HANDLE_EXCEPTIONS 0x40000000 // Enable bad handles detection (R,K)
|
|
#define FLG_DISABLE_PROTDLLS 0x80000000 // Disable protected DLL verification (R,K,I)
|
|
#define FLG_VALID_BITS 0xffffffff
|
|
|
|
#define FLG_USERMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
|
|
FLG_SHOW_LDR_SNAPS | \
|
|
FLG_HEAP_ENABLE_TAIL_CHECK | \
|
|
FLG_HEAP_ENABLE_FREE_CHECK | \
|
|
FLG_HEAP_VALIDATE_PARAMETERS | \
|
|
FLG_HEAP_VALIDATE_ALL | \
|
|
FLG_APPLICATION_VERIFIER | \
|
|
FLG_MONITOR_SILENT_PROCESS_EXIT | \
|
|
FLG_HEAP_ENABLE_TAGGING | \
|
|
FLG_USER_STACK_TRACE_DB | \
|
|
FLG_HEAP_ENABLE_TAG_BY_DLL | \
|
|
FLG_DISABLE_STACK_EXTENSION | \
|
|
FLG_ENABLE_SYSTEM_CRIT_BREAKS | \
|
|
FLG_HEAP_DISABLE_COALESCING | \
|
|
FLG_DISABLE_PROTDLLS | \
|
|
FLG_HEAP_PAGE_ALLOCS | \
|
|
FLG_CRITSEC_EVENT_CREATION | \
|
|
FLG_STOP_ON_UNHANDLED_EXCEPTION | \
|
|
FLG_LDR_TOP_DOWN)
|
|
|
|
#define FLG_BOOTONLY_VALID_BITS (FLG_KERNEL_STACK_TRACE_DB | \
|
|
FLG_MAINTAIN_OBJECT_TYPELIST | \
|
|
FLG_ENABLE_CSRDEBUG | \
|
|
FLG_DEBUG_INITIAL_COMMAND | \
|
|
FLG_DEBUG_INITIAL_COMMAND_EX | \
|
|
FLG_DISABLE_PAGE_KERNEL_STACKS)
|
|
|
|
#define FLG_KERNELMODE_VALID_BITS (FLG_STOP_ON_EXCEPTION | \
|
|
FLG_SHOW_LDR_SNAPS | \
|
|
FLG_STOP_ON_HUNG_GUI | \
|
|
FLG_POOL_ENABLE_TAGGING | \
|
|
FLG_ENABLE_KDEBUG_SYMBOL_LOAD | \
|
|
FLG_ENABLE_CLOSE_EXCEPTIONS | \
|
|
FLG_ENABLE_EXCEPTION_LOGGING | \
|
|
FLG_ENABLE_HANDLE_TYPE_TAGGING | \
|
|
FLG_DISABLE_DBGPRINT | \
|
|
FLG_ENABLE_HANDLE_EXCEPTIONS)
|
|
|
|
//
|
|
// Licensing
|
|
//
|
|
|
|
/**
|
|
* The NtQueryLicenseValue routine retrieves a licensing-related value from the
|
|
* system licensing database.
|
|
*
|
|
* \param ValueName A pointer to a UNICODE_STRING structure that contains the name of the license value to query.
|
|
* \param Type An optional pointer that receives the type of the returned data.
|
|
* \param Data An optional buffer that receives the value data.
|
|
* \param DataSize The size, in bytes, of the buffer pointed to by Data.
|
|
* \param ResultDataSize A pointer that receives the number of bytes required to store the complete value data.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \see https://learn.microsoft.com/en-us/windows/win32/api/slpublic/nf-slpublic-slquerylicensevaluefromapp
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtQueryLicenseValue(
|
|
_In_ PCUNICODE_STRING ValueName,
|
|
_Out_opt_ PULONG Type,
|
|
_Out_writes_bytes_to_opt_(DataSize, *ResultDataSize) PVOID Data,
|
|
_In_ ULONG DataSize,
|
|
_Out_ PULONG ResultDataSize
|
|
);
|
|
|
|
//
|
|
// Misc.
|
|
//
|
|
|
|
/**
|
|
* The NtSetDefaultHardErrorPort routine sets the system's default hard error
|
|
* port, which is used by the kernel to deliver hard error notifications to a
|
|
* user-mode process.
|
|
*
|
|
* \param DefaultHardErrorPort A handle to a port object that will receive
|
|
* hard error messages generated by the system.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtSetDefaultHardErrorPort(
|
|
_In_ HANDLE DefaultHardErrorPort
|
|
);
|
|
|
|
/**
|
|
* The SHUTDOWN_ACTION enumeration specifies the type of system shutdown to perform.
|
|
*/
|
|
typedef enum _SHUTDOWN_ACTION
|
|
{
|
|
ShutdownNoReboot,
|
|
ShutdownReboot,
|
|
ShutdownPowerOff,
|
|
ShutdownRebootForRecovery // since WIN11
|
|
} SHUTDOWN_ACTION;
|
|
|
|
/**
|
|
* The NtShutdownSystem routine initiates a system shutdown using the specified
|
|
* shutdown action.
|
|
*
|
|
* \param Action A SHUTDOWN_ACTION value that specifies whether the system
|
|
* should halt, reboot, power off, or reboot for recovery.
|
|
* \return NTSTATUS Successful or errant status.
|
|
* \remarks The calling process must have the SE_SHUTDOWN_NAME privilege.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtShutdownSystem(
|
|
_In_ SHUTDOWN_ACTION Action
|
|
);
|
|
|
|
/**
|
|
* The NtDisplayString routine displays a Unicode string on the system display
|
|
* during early boot or in environments where a console is not yet available.
|
|
*
|
|
* \param String A pointer to a UNICODE_STRING structure that contains the text to display.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDisplayString(
|
|
_In_ PCUNICODE_STRING String
|
|
);
|
|
|
|
//
|
|
// Boot graphics
|
|
//
|
|
|
|
// rev
|
|
/**
|
|
* The NtDrawText routine displays a Unicode string on the system display during
|
|
* early boot or in environments where a standard console is not yet available.
|
|
*
|
|
* \param Text A pointer to a UNICODE_STRING structure that contains the text to draw on the screen.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtDrawText(
|
|
_In_ PCUNICODE_STRING Text
|
|
);
|
|
|
|
//
|
|
// Hot patching
|
|
//
|
|
|
|
/**
|
|
* The HOT_PATCH_INFORMATION_CLASS enumeration defines the information classes for querying and setting hot patch information.
|
|
*/
|
|
typedef enum _HOT_PATCH_INFORMATION_CLASS
|
|
{
|
|
ManageHotPatchLoadPatch = 0, // MANAGE_HOT_PATCH_LOAD_PATCH
|
|
ManageHotPatchUnloadPatch = 1, // MANAGE_HOT_PATCH_UNLOAD_PATCH
|
|
ManageHotPatchQueryPatches = 2, // MANAGE_HOT_PATCH_QUERY_PATCHES
|
|
ManageHotPatchLoadPatchForUser = 3, // MANAGE_HOT_PATCH_LOAD_PATCH
|
|
ManageHotPatchUnloadPatchForUser = 4, // MANAGE_HOT_PATCH_UNLOAD_PATCH
|
|
ManageHotPatchQueryPatchesForUser = 5, // MANAGE_HOT_PATCH_QUERY_PATCHES
|
|
ManageHotPatchQueryActivePatches = 6, // MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES
|
|
ManageHotPatchApplyImagePatch = 7, // MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH
|
|
ManageHotPatchQuerySinglePatch = 8, // MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH
|
|
ManageHotPatchCheckEnabled = 9, // MANAGE_HOT_PATCH_CHECK_ENABLED
|
|
ManageHotPatchCreatePatchSection = 10, // MANAGE_HOT_PATCH_CREATE_PATCH_SECTION
|
|
ManageHotPatchMax
|
|
} HOT_PATCH_INFORMATION_CLASS;
|
|
|
|
/**
|
|
* The HOT_PATCH_IMAGE_INFO structure contains identifying information about a hot patch image.
|
|
*/
|
|
typedef struct _HOT_PATCH_IMAGE_INFO
|
|
{
|
|
ULONG CheckSum; // The checksum of the hot patch image.
|
|
ULONG TimeDateStamp; // The time/date stamp of the hot patch image.
|
|
} HOT_PATCH_IMAGE_INFO, *PHOT_PATCH_IMAGE_INFO;
|
|
|
|
#define MANAGE_HOT_PATCH_LOAD_PATCH_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_LOAD_PATCH structure describes parameters for loading a hot patch.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_LOAD_PATCH
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_LOAD_PATCH_VERSION.
|
|
UNICODE_STRING PatchPath; // The path to the hot patch file.
|
|
union
|
|
{
|
|
SID Sid; // The SID of the user for whom the patch is being loaded.
|
|
UCHAR Buffer[SECURITY_MAX_SID_SIZE]; // Buffer for the SID.
|
|
} UserSid;
|
|
HOT_PATCH_IMAGE_INFO BaseInfo; // Identifying information about the base image to patch.
|
|
} MANAGE_HOT_PATCH_LOAD_PATCH, *PMANAGE_HOT_PATCH_LOAD_PATCH;
|
|
|
|
#define MANAGE_HOT_PATCH_UNLOAD_PATCH_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_UNLOAD_PATCH structure describes parameters for unloading a hot patch.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_UNLOAD_PATCH
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_UNLOAD_PATCH_VERSION.
|
|
HOT_PATCH_IMAGE_INFO BaseInfo; // Identifying information about the base image to unpatch.
|
|
union
|
|
{
|
|
SID Sid; // The SID of the user for whom the patch is being unloaded.
|
|
UCHAR Buffer[SECURITY_MAX_SID_SIZE]; // Buffer for the SID.
|
|
} UserSid;
|
|
} MANAGE_HOT_PATCH_UNLOAD_PATCH, *PMANAGE_HOT_PATCH_UNLOAD_PATCH;
|
|
|
|
#define MANAGE_HOT_PATCH_QUERY_PATCHES_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_QUERY_PATCHES structure is used to query information about loaded hot patches.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_QUERY_PATCHES
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_QUERY_PATCHES_VERSION.
|
|
union
|
|
{
|
|
SID Sid; // The SID of the user whose patches are being queried.
|
|
UCHAR Buffer[SECURITY_MAX_SID_SIZE]; // Buffer for the SID.
|
|
} UserSid;
|
|
ULONG PatchCount; // The number of patches found.
|
|
PUNICODE_STRING PatchPathStrings; // Pointer to an array of patch path strings.
|
|
PHOT_PATCH_IMAGE_INFO BaseInfos; // Pointer to an array of patch image info structures.
|
|
} MANAGE_HOT_PATCH_QUERY_PATCHES, *PMANAGE_HOT_PATCH_QUERY_PATCHES;
|
|
|
|
#define MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES structure is used to query active hot patches for a process.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES_VERSION.
|
|
HANDLE ProcessHandle; // Handle to the process being queried.
|
|
ULONG PatchCount; // The number of active patches.
|
|
PUNICODE_STRING PatchPathStrings; // Pointer to an array of patch path strings.
|
|
PHOT_PATCH_IMAGE_INFO BaseInfos; // Pointer to an array of patch image info structures.
|
|
PULONG PatchSequenceNumbers; // Pointer to an array of patch sequence numbers.
|
|
} MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES, *PMANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES;
|
|
|
|
#define MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH structure describes parameters for applying a hot patch to an image.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH_VERSION.
|
|
union
|
|
{
|
|
ULONG AllFlags; // All flags as a ULONG.
|
|
struct
|
|
{
|
|
ULONG ApplyReversePatches : 1; // If set, apply reverse patches.
|
|
ULONG ApplyForwardPatches : 1; // If set, apply forward patches.
|
|
ULONG Spare : 29;
|
|
} DUMMYSTRUCTNAME;
|
|
} DUMMYUNIONNAME;
|
|
HANDLE ProcessHandle; // Handle to the process to patch.
|
|
PVOID BaseImageAddress; // Base address of the image to patch.
|
|
PVOID PatchImageAddress; // Address of the patch image.
|
|
} MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH, *PMANAGE_HOT_PATCH_APPLY_IMAGE_PATCH;
|
|
|
|
#define MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH structure is used to query a single hot patch.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH_VERSION.
|
|
HANDLE ProcessHandle; // Handle to the process being queried.
|
|
PVOID BaseAddress; // Base address of the image being queried.
|
|
ULONG Flags; // Query flags.
|
|
UNICODE_STRING PatchPathString; // The path to the patch being queried.
|
|
} MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH, *PMANAGE_HOT_PATCH_QUERY_SINGLE_PATCH;
|
|
|
|
#define MANAGE_HOT_PATCH_CHECK_ENABLED_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_CHECK_ENABLED structure is used to check if hot patching is enabled.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_CHECK_ENABLED
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_CHECK_ENABLED_VERSION.
|
|
ULONG Flags; // Flags for the check operation.
|
|
} MANAGE_HOT_PATCH_CHECK_ENABLED, *PMANAGE_HOT_PATCH_CHECK_ENABLED;
|
|
|
|
#define MANAGE_HOT_PATCH_CREATE_PATCH_SECTION_VERSION 1
|
|
|
|
/**
|
|
* The MANAGE_HOT_PATCH_CREATE_PATCH_SECTION structure describes parameters for creating a hot patch section.
|
|
*/
|
|
typedef struct _MANAGE_HOT_PATCH_CREATE_PATCH_SECTION
|
|
{
|
|
ULONG Version; // Structure version. Must be MANAGE_HOT_PATCH_CREATE_PATCH_SECTION_VERSION.
|
|
ULONG Flags; // Creation flags.
|
|
ACCESS_MASK DesiredAccess; // Desired access mask for the section.
|
|
ULONG PageProtection; // Page protection flags.
|
|
ULONG AllocationAttributes; // Allocation attributes.
|
|
PVOID BaseImageAddress; // Base address of the image for the patch section.
|
|
HANDLE SectionHandle; // Handle to the created section.
|
|
} MANAGE_HOT_PATCH_CREATE_PATCH_SECTION, *PMANAGE_HOT_PATCH_CREATE_PATCH_SECTION;
|
|
|
|
#if defined(_WIN64)
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_LOAD_PATCH) == 0x68, "Size of MANAGE_HOT_PATCH_LOAD_PATCH is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_UNLOAD_PATCH) == 0x50, "Size of MANAGE_HOT_PATCH_UNLOAD_PATCH is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_QUERY_PATCHES) == 0x60, "Size of MANAGE_HOT_PATCH_QUERY_PATCHES is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES) == 0x30, "Size of MANAGE_HOT_PATCH_QUERY_ACTIVE_PATCHES is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH) == 0x20, "Size of MANAGE_HOT_PATCH_APPLY_IMAGE_PATCH is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH) == 0x30, "Size of MANAGE_HOT_PATCH_QUERY_SINGLE_PATCH is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_CHECK_ENABLED) == 0x8, "Size of MANAGE_HOT_PATCH_CHECK_ENABLED is incorrect");
|
|
static_assert(sizeof(MANAGE_HOT_PATCH_CREATE_PATCH_SECTION) == 0x28, "Size of MANAGE_HOT_PATCH_CREATE_PATCH_SECTION is incorrect");
|
|
#endif // WIN64
|
|
|
|
#if (PHNT_VERSION >= PHNT_WINDOWS_11)
|
|
// rev
|
|
/**
|
|
* The NtManageHotPatch routine manages hot patching operations in the system.
|
|
*
|
|
* \param[in] HotPatchInformationClass Specifies the type of hot patch information being queried or set.
|
|
* \param[out] HotPatchInformation A pointer to a buffer that receives or contains the hot patch information, depending on the operation.
|
|
* \param[in] HotPatchInformationLength The size, in bytes, of the HotPatchInformation buffer.
|
|
* \param[out] ReturnLength Optional pointer to a variable that receives the number of bytes written to the HotPatchInformation buffer.
|
|
* \return NTSTATUS Successful or errant status.
|
|
*/
|
|
_Kernel_entry_
|
|
NTSYSCALLAPI
|
|
NTSTATUS
|
|
NTAPI
|
|
NtManageHotPatch(
|
|
_In_ HOT_PATCH_INFORMATION_CLASS HotPatchInformationClass,
|
|
_Out_writes_bytes_opt_(HotPatchInformationLength) PVOID HotPatchInformation,
|
|
_In_ ULONG HotPatchInformationLength,
|
|
_Out_opt_ PULONG ReturnLength
|
|
);
|
|
#endif // PHNT_VERSION >= PHNT_WINDOWS_11
|
|
|
|
#endif
|
|
|
|
#endif // _NTEXAPI_H
|