Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/pro... --- dlls/ntdll/unix/system.c | 29 +++++++++++++++++++++++++++++ include/winternl.h | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index 491cdb37b8f..784fb6212a5 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -173,6 +173,31 @@ struct smbios_boot_info
SYSTEM_CPU_INFORMATION cpu_info = { 0 };
+static int get_possible_cpus(void) +{ + int ret = NtCurrentTeb()->Peb->NumberOfProcessors; +#ifdef linux + FILE *f = fopen("/sys/devices/system/cpu/possible", "r"); + char line[32]; + char *value; + if (f) + { + if (fgets(line, sizeof(line), f)) + { + value = strchr(line, '-'); + if (value) + { + *value = 0; + value++; + ret = atoi(value) - atoi(line) + 1; + } + } + fclose(f); + } +#endif + return ret; +} + /******************************************************************************* * Architecture specific feature detection for CPUs * @@ -246,6 +271,8 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) info->Architecture = PROCESSOR_ARCHITECTURE_AMD64; #endif
+ info->MaximumCpus = get_possible_cpus(); + /* We're at least a 386 */ info->FeatureSet = CPU_FEATURE_VME | CPU_FEATURE_X86 | CPU_FEATURE_PGE; info->Level = 3; @@ -400,6 +427,7 @@ static inline void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) FIXME("CPU Feature detection not implemented.\n"); #endif info->Architecture = PROCESSOR_ARCHITECTURE_ARM; + info->MaximumCpus = get_possible_cpus(); }
#elif defined(__aarch64__) @@ -448,6 +476,7 @@ static void get_cpuinfo( SYSTEM_CPU_INFORMATION *info ) #endif info->Level = max(info->Level, 8); info->Architecture = PROCESSOR_ARCHITECTURE_ARM64; + info->MaximumCpus = get_possible_cpus(); }
#endif /* End architecture specific feature detection for CPUs */ diff --git a/include/winternl.h b/include/winternl.h index dd2bdbbebbe..1104865a053 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -2132,7 +2132,7 @@ typedef struct _SYSTEM_CPU_INFORMATION { WORD Architecture; WORD Level; WORD Revision; /* combination of CPU model and stepping */ - WORD Reserved; /* always zero */ + WORD MaximumCpus; /* number of CPUs if as many as possible are hot-added */ DWORD FeatureSet; /* see bit flags below */ } SYSTEM_CPU_INFORMATION, *PSYSTEM_CPU_INFORMATION;