Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/kernel32/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 41a5b34af19..46ccb04b133 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -620,7 +620,7 @@ DWORD WINAPI GetActiveProcessorCount(WORD group) { DWORD cpus = system_info.NumberOfProcessors;
- FIXME("semi-stub, returning %u\n", cpus); + FIXME("(0x%x): semi-stub, returning %u\n", group, cpus); return cpus; }
@@ -631,7 +631,7 @@ DWORD WINAPI GetMaximumProcessorCount(WORD group) { DWORD cpus = system_info.NumberOfProcessors;
- FIXME("semi-stub, returning %u\n", cpus); + FIXME("(0x%x): semi-stub, returning %u\n", group, cpus); return cpus; }
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 a889b2e020c..d34a3229816 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -170,6 +170,31 @@ struct smbios_boot_info
static SYSTEM_CPU_INFORMATION cpu_info;
+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 * @@ -267,6 +292,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; @@ -415,6 +442,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__) @@ -463,6 +491,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 61bcd0f1d92..22d75b748c4 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -1722,7 +1722,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;
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- This fixes the console spam when the Clinithink natural language processing software https://www.clinithink.com/ calls GetMaximumProcessorCount repeatedly. --- dlls/kernel32/kernel_main.c | 1 + dlls/kernel32/kernel_private.h | 1 + dlls/kernel32/process.c | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c index 89394e16430..531a580749f 100644 --- a/dlls/kernel32/kernel_main.c +++ b/dlls/kernel32/kernel_main.c @@ -123,6 +123,7 @@ static BOOL process_attach( HMODULE module ) RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter );
NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL ); + NtQuerySystemInformation( SystemCpuInformation, &cpu_info, sizeof(cpu_info), NULL );
copy_startup_info();
diff --git a/dlls/kernel32/kernel_private.h b/dlls/kernel32/kernel_private.h index 633511d6140..cbd23f52f10 100644 --- a/dlls/kernel32/kernel_private.h +++ b/dlls/kernel32/kernel_private.h @@ -30,6 +30,7 @@ static inline BOOL set_ntstatus( NTSTATUS status ) }
extern SYSTEM_BASIC_INFORMATION system_info DECLSPEC_HIDDEN; +extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
extern WCHAR *FILE_name_AtoW( LPCSTR name, BOOL alloc ) DECLSPEC_HIDDEN; extern DWORD FILE_name_WtoA( LPCWSTR src, INT srclen, LPSTR dest, INT destlen ) DECLSPEC_HIDDEN; diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 46ccb04b133..e29fff52ee2 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -52,6 +52,7 @@ typedef struct } LOADPARMS32;
SYSTEM_BASIC_INFORMATION system_info = { 0 }; +SYSTEM_CPU_INFORMATION cpu_info = { 0 };
/* Process flags */ #define PDB32_DEBUGGED 0x0001 /* Process is being debugged */ @@ -629,9 +630,13 @@ DWORD WINAPI GetActiveProcessorCount(WORD group) */ DWORD WINAPI GetMaximumProcessorCount(WORD group) { - DWORD cpus = system_info.NumberOfProcessors; + DWORD cpus = cpu_info.MaximumCpus; + + if (group == ALL_PROCESSOR_GROUPS) + TRACE("(0x%x): returning %u\n", group, cpus); + else + FIXME("(0x%x): processor groups not supported, returning %u\n", group, cpus);
- FIXME("(0x%x): semi-stub, returning %u\n", group, cpus); return cpus; }