wbemprox: Add RegisterdUser property to Win32_Operatingsystem.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52887
Signed-off-by: Louis Lenders <xerox.xerox2000x@gmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Louis Lenders 2022-04-28 12:43:20 +02:00 committed by Alexandre Julliard
parent 552ac96c6a
commit ef3df0e7e9
2 changed files with 23 additions and 5 deletions

View File

@ -250,6 +250,7 @@ static const struct column col_operatingsystem[] =
{ L"OSType", CIM_UINT16 },
{ L"Primary", CIM_BOOLEAN },
{ L"ProductType", CIM_UINT32 },
{ L"RegisteredUser", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"SerialNumber", CIM_STRING|COL_FLAG_DYNAMIC },
{ L"ServicePackMajorVersion", CIM_UINT16 },
{ L"ServicePackMinorVersion", CIM_UINT16 },
@ -682,6 +683,7 @@ struct record_operatingsystem
UINT16 ostype;
int primary;
UINT32 producttype;
const WCHAR *registereduser;
const WCHAR *serialnumber;
UINT16 servicepackmajor;
UINT16 servicepackminor;
@ -3571,27 +3573,35 @@ static WCHAR *get_osname( const WCHAR *caption )
memcpy( ret + len, partitionW, sizeof(partitionW) );
return ret;
}
static WCHAR *get_osserialnumber(void)
static WCHAR *get_reg_str( HKEY root, const WCHAR *path, const WCHAR *value )
{
HKEY hkey = 0;
DWORD size, type;
WCHAR *ret = NULL;
if (!RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &hkey ) &&
!RegQueryValueExW( hkey, L"ProductId", NULL, &type, NULL, &size ) && type == REG_SZ &&
if (!RegOpenKeyExW( root, path, 0, KEY_READ, &hkey ) &&
!RegQueryValueExW( hkey, value, NULL, &type, NULL, &size ) && type == REG_SZ &&
(ret = malloc( size + sizeof(WCHAR) )))
{
size += sizeof(WCHAR);
if (RegQueryValueExW( hkey, L"ProductId", NULL, NULL, (BYTE *)ret, &size ))
if (RegQueryValueExW( hkey, value, NULL, NULL, (BYTE *)ret, &size ))
{
free( ret );
ret = NULL;
}
}
if (hkey) RegCloseKey( hkey );
if (!ret) return wcsdup( L"12345-OEM-1234567-12345" );
return ret;
}
static WCHAR *get_osserialnumber(void)
{
WCHAR *ret = get_reg_str( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", L"ProductId" );
if (!ret) ret = wcsdup( L"12345-OEM-1234567-12345" );
return ret;
}
static WCHAR *get_osversion( OSVERSIONINFOEXW *ver )
{
WCHAR *ret = malloc( 33 * sizeof(WCHAR) );
@ -3604,6 +3614,12 @@ static DWORD get_operatingsystemsku(void)
GetProductInfo( 6, 0, 0, 0, &ret );
return ret;
}
static WCHAR *get_registereduser(void)
{
return get_reg_str( HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", L"RegisteredOwner" );
}
static INT16 get_currenttimezone(void)
{
TIME_ZONE_INFORMATION info;
@ -3648,6 +3664,7 @@ static enum fill_status fill_operatingsystem( struct table *table, const struct
rec->ostype = 18; /* WINNT */
rec->primary = -1;
rec->producttype = 1;
rec->registereduser = get_registereduser();
rec->serialnumber = get_osserialnumber();
rec->servicepackmajor = ver.wServicePackMajor;
rec->servicepackminor = ver.wServicePackMinor;

View File

@ -1430,6 +1430,7 @@ static void test_Win32_OperatingSystem( IWbemServices *services )
check_property( obj, L"Manufacturer", VT_BSTR, CIM_STRING );
check_property( obj, L"OSType", VT_I4, CIM_UINT16 );
check_property( obj, L"ProductType", VT_I4, CIM_UINT32 );
check_property( obj, L"RegisteredUser", VT_BSTR, CIM_STRING );
check_property( obj, L"ServicePackMajorVersion", VT_I4, CIM_UINT16 );
check_property( obj, L"ServicePackMinorVersion", VT_I4, CIM_UINT16 );
check_property( obj, L"SuiteMask", VT_I4, CIM_UINT32 );