From 0ea5639a22e177f251c07701d75c9dc3fe52ccc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 18 Feb 2026 20:13:14 +0800 Subject: [PATCH] Platform (Windows): prefers Nt* APIs --- src/common/impl/FFPlatform_windows.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/common/impl/FFPlatform_windows.c b/src/common/impl/FFPlatform_windows.c index c09cdc277..d7c256aed 100644 --- a/src/common/impl/FFPlatform_windows.c +++ b/src/common/impl/FFPlatform_windows.c @@ -248,13 +248,22 @@ static void getSystemReleaseAndVersion(FFPlatformSysinfo* info) } } -static void getSystemArchitectureAndPageSize(FFPlatformSysinfo* info) +static void getSystemPageSize(FFPlatformSysinfo* info) { - SYSTEM_INFO sysInfo; - GetNativeSystemInfo(&sysInfo); + SYSTEM_BASIC_INFORMATION sbi; + if (NT_SUCCESS(NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL))) + info->pageSize = sbi.PhysicalPageSize; + else + info->pageSize = 4096; +} - switch(sysInfo.wProcessorArchitecture) +static void getSystemArchitecture(FFPlatformSysinfo* info) +{ + SYSTEM_PROCESSOR_INFORMATION spi; + if (NT_SUCCESS(NtQuerySystemInformation(SystemProcessorInformation, &spi, sizeof(spi), NULL))) { + switch (spi.ProcessorArchitecture) + { case PROCESSOR_ARCHITECTURE_AMD64: ffStrbufSetStatic(&info->architecture, "x86_64"); break; @@ -262,7 +271,7 @@ static void getSystemArchitectureAndPageSize(FFPlatformSysinfo* info) ffStrbufSetStatic(&info->architecture, "ia64"); break; case PROCESSOR_ARCHITECTURE_INTEL: - switch (sysInfo.wProcessorLevel) + switch (spi.ProcessorLevel) { case 4: ffStrbufSetStatic(&info->architecture, "i486"); @@ -300,9 +309,8 @@ static void getSystemArchitectureAndPageSize(FFPlatformSysinfo* info) default: ffStrbufSetStatic(&info->architecture, "unknown"); break; + } } - - info->pageSize = sysInfo.dwPageSize; } void ffPlatformInitImpl(FFPlatform* platform) @@ -319,5 +327,6 @@ void ffPlatformInitImpl(FFPlatform* platform) getUserShell(platform); getSystemReleaseAndVersion(&platform->sysinfo); - getSystemArchitectureAndPageSize(&platform->sysinfo); + getSystemArchitecture(&platform->sysinfo); + getSystemPageSize(&platform->sysinfo); }