From: Alexandre Julliard julliard@winehq.org
--- dlls/wbemprox/builtin.c | 63 ++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 42 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 099b4481bfd..d1eaeef9e50 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -1663,47 +1663,20 @@ static UINT get_processor_count(void) return info.NumberOfProcessors; }
-static UINT get_logical_processor_count( UINT *num_physical, UINT *num_packages ) +static UINT get_physical_processor_count( const char *buf, UINT len, UINT *num_logical ) { - SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buf, *entry; - UINT core_relation_count = 0, package_relation_count = 0; - NTSTATUS status; - ULONG len, offset = 0; - BOOL smt_enabled = FALSE; - DWORD all = RelationAll; - - if (num_packages) *num_packages = 1; - status = NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx, &all, sizeof(all), NULL, 0, &len ); - if (status != STATUS_INFO_LENGTH_MISMATCH) return get_processor_count(); + const struct smbios_header *hdr; + const struct smbios_processor *proc; + UINT thread_count = 0, package_count = 0;
- if (!(buf = malloc( len ))) return get_processor_count(); - status = NtQuerySystemInformationEx( SystemLogicalProcessorInformationEx, &all, sizeof(all), buf, len, &len ); - if (status != STATUS_SUCCESS) + while ((hdr = find_smbios_entry( SMBIOS_TYPE_PROCESSOR, package_count, buf, len ))) { - free( buf ); - return get_processor_count(); + proc = (const struct smbios_processor *)hdr; + thread_count += proc->thread_count2; + package_count++; } - - while (offset < len) - { - entry = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)((char *)buf + offset); - - if (entry->Relationship == RelationProcessorCore) - { - core_relation_count++; - if (entry->Processor.Flags & LTP_PC_SMT) smt_enabled = TRUE; - } - else if (entry->Relationship == RelationProcessorPackage) - { - package_relation_count++; - } - offset += entry->Size; - } - - free( buf ); - if (num_physical) *num_physical = core_relation_count; - if (num_packages) *num_packages = package_relation_count; - return smt_enabled ? core_relation_count * 2 : core_relation_count; + if (num_logical) *num_logical = thread_count; + return package_count; }
static UINT64 get_total_physical_memory(void) @@ -1811,7 +1784,7 @@ static enum fill_status fill_compsys( struct table *table, const struct expr *co rec->manufacturer = get_compsysproduct_vendor( buf, len ); rec->model = get_compsysproduct_name( buf, len ); rec->name = get_computername(); - rec->num_logical_processors = get_logical_processor_count( NULL, &rec->num_processors ); + rec->num_processors = get_physical_processor_count( buf, len, &rec->num_logical_processors ); rec->systemtype = get_systemtype(); rec->total_physical_memory = get_total_physical_memory(); rec->username = get_username(); @@ -3540,8 +3513,10 @@ static UINT get_processor_maxclockspeed( UINT index ) static enum fill_status fill_processor( struct table *table, const struct expr *cond ) { WCHAR device_id[14], processor_id[17], version[50]; + const struct smbios_header *hdr; + const struct smbios_processor *proc; struct record_processor *rec; - UINT i, len, offset = 0, num_rows = 0, num_logical, num_physical, num_packages; + UINT i, len, offset = 0, num_rows = 0, num_packages; enum fill_status status = FILL_STATUS_UNFILTERED; char *buf;
@@ -3549,7 +3524,7 @@ static enum fill_status fill_processor( struct table *table, const struct expr * if (!(buf = malloc( len ))) return FILL_STATUS_FAILED; GetSystemFirmwareTable( RSMB, 0, buf, len );
- num_logical = get_logical_processor_count( &num_physical, &num_packages ); + num_packages = get_physical_processor_count( buf, len, NULL );
if (!resize_table( table, num_packages, sizeof(*rec) )) { @@ -3562,6 +3537,10 @@ static enum fill_status fill_processor( struct table *table, const struct expr *
for (i = 0; i < num_packages; i++) { + if (!(hdr = find_smbios_entry( SMBIOS_TYPE_PROCESSOR, i, buf, len )) || hdr->length < sizeof(*proc)) + continue; + proc = (const struct smbios_processor *)hdr; + rec = (struct record_processor *)(table->data + offset); rec->addresswidth = !wcscmp( get_osarchitecture(), L"32-bit" ) ? 32 : 64; rec->architecture = !wcscmp( get_osarchitecture(), L"32-bit" ) ? 0 : 9; @@ -3577,8 +3556,8 @@ static enum fill_status fill_processor( struct table *table, const struct expr * rec->manufacturer = get_processor_manufacturer( i, buf, len ); rec->maxclockspeed = get_processor_maxclockspeed( i ); rec->name = get_processor_name( i, buf, len ); - rec->num_cores = num_physical / num_packages; - rec->num_logical_processors = num_logical / num_packages; + rec->num_cores = proc->core_count2; + rec->num_logical_processors = proc->thread_count2; rec->processor_id = wcsdup( processor_id ); rec->processortype = 3; /* central processor */ rec->revision = get_processor_revision();