v0.4.0

System information v0.1.0

Source
Memory, processor architecture and logical processor information.

MemoryStatusEx

pub struct MemoryStatusEx {
    pub length: uint32;
    pub memoryLoad: uint32;
    pub totalPhysical: uint64;
    pub availablePhysical: uint64;
    pub totalPageFile: uint64;
    pub availablePageFile: uint64;
    pub totalVirtual: uint64;
    pub availableVirtual: uint64;
    pub availableExtendedVirtual: uint64;
}

The MEMORYSTATUSEX that GlobalMemoryStatusEx fills in, with every size in bytes.

Source

Fields

NameTypeDescription
lengthuint32The structure's size in bytes, sizeof(MemoryStatusEx), which the caller sets before the call.
memoryLoaduint32How much of the physical memory is in use, as a percentage from 0 to 100.
totalPhysicaluint64The physical memory the system can use.
availablePhysicaluint64The physical memory that is free or can be freed at once.
totalPageFileuint64The memory the system can commit, physical memory and page file together.
availablePageFileuint64The part of that commit limit the calling process can still commit.
totalVirtualuint64The user-mode address space of the calling process.
availableVirtualuint64The part of that address space neither reserved nor committed.
availableExtendedVirtualuint64Reserved; always zero.

ProcessorRelationshipHeader

pub struct ProcessorRelationshipHeader {
    pub relationship: uint32;
    pub size: uint32;
}

The header that begins every record GetLogicalProcessorInformationEx writes. The records differ in size, so the buffer is walked by adding each record's size to reach the next one; the rest of a record depends on its relationship and is not described here.

Source

Fields

NameTypeDescription
relationshipuint32What the record describes, such as RelationProcessorCore.
sizeuint32The record's size in bytes, header included.

RelationProcessorCore

pub const RelationProcessorCore: uint32 = 0;

RelationProcessorCore: a record per physical core, however many logical processors it runs.

Source

RelationProcessorPackage

pub const RelationProcessorPackage: uint32 = 3;

RelationProcessorPackage: a record per physical processor package, the chip in a socket.

Source

PROCESSOR_ARCHITECTURE_INTEL

pub const PROCESSOR_ARCHITECTURE_INTEL: uint16 = 0;

PROCESSOR_ARCHITECTURE_INTEL: 32-bit x86.

Source

PROCESSOR_ARCHITECTURE_ARM64

pub const PROCESSOR_ARCHITECTURE_ARM64: uint16 = 12;

PROCESSOR_ARCHITECTURE_ARM64: 64-bit Arm.

Source

PROCESSOR_ARCHITECTURE_AMD64

pub const PROCESSOR_ARCHITECTURE_AMD64: uint16 = 9;

PROCESSOR_ARCHITECTURE_AMD64: x86-64, from AMD or Intel.

Source

GlobalMemoryStatusEx

pub extern func GlobalMemoryStatusEx(status: *var MemoryStatusEx) -> bool32

Reports the machine's physical memory and how much of it, and of the commit limit, is in use.

See also: https://learn.microsoft.com/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

Source

Parameters

NameTypeDescription
status*var MemoryStatusExthe structure to fill, with length set to sizeof(MemoryStatusEx)

Returns: non-zero on success, and zero on failure with the reason in GetLastError

GetLogicalProcessorInformationEx

pub extern func GetLogicalProcessorInformationEx(
    relationship: uint32,
    buffer: *var opaque,
    length: *var uint32
) -> bool32

Reads the processor relationships of one kind, such as one record per core, into a caller's buffer. Asked with too small a buffer, or none, the call fails with ERROR_INSUFFICIENT_BUFFER and sets length to the bytes needed, so it is called once to measure and once to fill.

See also: https://learn.microsoft.com/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlogicalprocessorinformationex

Source

Parameters

NameTypeDescription
relationshipuint32which records to write, such as RelationProcessorCore
buffer*var opaquereceives the records, each beginning with a ProcessorRelationshipHeader, or null to measure
length*var uint32how many bytes buffer holds on entry, and how many were written or are needed on return

Returns: non-zero on success, and zero on failure with the reason in GetLastError

GetNativeSystemInfo

pub extern func GetNativeSystemInfo(info: *var SystemInfo)

Reads what GetSystemInfo does, but for the machine rather than for the calling process. The two differ only under emulation, where an x86-64 program on an Arm machine is told it runs on x86-64 by GetSystemInfo and on Arm by this call. It cannot fail, and the structure is always filled.

See also: https://learn.microsoft.com/windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativesysteminfo

Source

Parameters

NameTypeDescription
info*var SystemInforeceives the system information

GetPhysicallyInstalledSystemMemory

pub extern func GetPhysicallyInstalledSystemMemory(kilobytes: *var uint64) -> bool32

Reports the physical memory the firmware says is fitted, in kibibytes. This is more than GlobalMemoryStatusEx reports as total, by what the firmware and devices reserve. It fails with ERROR_INVALID_DATA when the firmware's memory tables are missing or malformed.

See also: https://learn.microsoft.com/windows/win32/api/sysinfoapi/nf-sysinfoapi-getphysicallyinstalledsystemmemory

Source

Parameters

NameTypeDescription
kilobytes*var uint64receives the fitted memory in kibibytes

Returns: non-zero on success, and zero on failure with the reason in GetLastError