v0.4.0

SystemInfo structv0.1.0

Source
What GetSystemInfo reports about the machine.
pub struct SystemInfo {
    pub processorArchitecture: uint32;
    pub pageSize: uint32;
    pub minimumApplicationAddress: *var opaque;
    pub maximumApplicationAddress: *var opaque;
    pub activeProcessorMask: uint64;
    pub numberOfProcessors: uint32;
    pub processorType: uint32;
    pub allocationGranularity: uint32;
    pub processorLevel: uint16;
    pub processorRevision: uint16;
}

The two granularities are not the same and the difference matters: pageSize is what protection is applied at, while allocationGranularity is what a reservation's base address is rounded to, and on every Windows release it is 64 KiB rather than a page. A reservation therefore wastes address space that a page-granular system would not.

Fields

NameTypeDescription
processorArchitectureuint32The processor architecture, such as PROCESSOR_ARCHITECTURE_AMD64, in the low 16 bits. The field is a union in C whose upper 16 bits are reserved, so the architecture is (processorArchitecture & 0xFFFF) as uint16.
pageSizeuint32The size of a page, which is what memory protection is applied at.
minimumApplicationAddress*var opaqueThe lowest address an application may have.
maximumApplicationAddress*var opaqueThe highest address an application may have.
activeProcessorMaskuint64A mask of the processors this process may run on.
numberOfProcessorsuint32How many logical processors the machine has in the calling process's processor group.
processorTypeuint32The processor type, obsolete; read processorArchitecture instead.
allocationGranularityuint32The granularity a reservation's base address is rounded to, which is not the page size.
processorLeveluint16The processor level, which depends on the architecture: the family on x86-64.
processorRevisionuint16The processor revision, which depends on the architecture: the model and stepping on x86-64.

GetSystemInfo

pub extern func GetSystemInfo(info: *var SystemInfo)

Reads what the system reports about the machine, including its page size. Cannot fail and reports nothing: the structure is always filled.

See also: https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo

Source

Parameters

NameTypeDescription
info*var SystemInforeceives the system information