System information v0.1.0
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.
Fields
| Name | Type | Description |
|---|---|---|
length | uint32 | The structure's size in bytes, sizeof(MemoryStatusEx), which the caller sets before the call. |
memoryLoad | uint32 | How much of the physical memory is in use, as a percentage from 0 to 100. |
totalPhysical | uint64 | The physical memory the system can use. |
availablePhysical | uint64 | The physical memory that is free or can be freed at once. |
totalPageFile | uint64 | The memory the system can commit, physical memory and page file together. |
availablePageFile | uint64 | The part of that commit limit the calling process can still commit. |
totalVirtual | uint64 | The user-mode address space of the calling process. |
availableVirtual | uint64 | The part of that address space neither reserved nor committed. |
availableExtendedVirtual | uint64 | Reserved; 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.
Fields
| Name | Type | Description |
|---|---|---|
relationship | uint32 | What the record describes, such as RelationProcessorCore. |
size | uint32 | The 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.
RelationProcessorPackage
pub const RelationProcessorPackage: uint32 = 3;
RelationProcessorPackage: a record per physical processor package, the chip in a socket.
PROCESSOR_ARCHITECTURE_INTEL
pub const PROCESSOR_ARCHITECTURE_INTEL: uint16 = 0;
PROCESSOR_ARCHITECTURE_INTEL: 32-bit x86.
PROCESSOR_ARCHITECTURE_ARM64
pub const PROCESSOR_ARCHITECTURE_ARM64: uint16 = 12;
PROCESSOR_ARCHITECTURE_ARM64: 64-bit Arm.
PROCESSOR_ARCHITECTURE_AMD64
pub const PROCESSOR_ARCHITECTURE_AMD64: uint16 = 9;
PROCESSOR_ARCHITECTURE_AMD64: x86-64, from AMD or Intel.
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
Parameters
| Name | Type | Description |
|---|---|---|
status | *var MemoryStatusEx | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
relationship | uint32 | which records to write, such as RelationProcessorCore |
buffer | *var opaque | receives the records, each beginning with a ProcessorRelationshipHeader, or null to measure |
length | *var uint32 | how 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
Parameters
| Name | Type | Description |
|---|---|---|
info | *var SystemInfo | receives 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.
Parameters
| Name | Type | Description |
|---|---|---|
kilobytes | *var uint64 | receives the fitted memory in kibibytes |
Returns: non-zero on success, and zero on failure with the reason in GetLastError