Commit e1169dfa authored by Mohamad Al-Jaf's avatar Mohamad Al-Jaf Committed by Alexandre Julliard

windows.system.profile.systemmanufacturers: Implement ISmbiosInformationStatics_get_SerialNumber.

parent d58a24d9
MODULE = windows.system.profile.systemmanufacturers.dll MODULE = windows.system.profile.systemmanufacturers.dll
IMPORTS = combase IMPORTS = combase oleaut32
C_SRCS = \ C_SRCS = \
main.c main.c
......
...@@ -128,10 +128,68 @@ static const struct IActivationFactoryVtbl factory_vtbl = ...@@ -128,10 +128,68 @@ static const struct IActivationFactoryVtbl factory_vtbl =
DEFINE_IINSPECTABLE( statics, ISmbiosInformationStatics, struct smbios_statics, IActivationFactory_iface ) DEFINE_IINSPECTABLE( statics, ISmbiosInformationStatics, struct smbios_statics, IActivationFactory_iface )
static HRESULT get_bios_serialnumber( BSTR *value )
{
const WCHAR *class = L"Win32_BIOS";
IEnumWbemClassObject *wbem_enum;
IWbemClassObject *wbem_class;
IWbemServices *wbem_service;
IWbemLocator *wbem_locator;
VARIANT serial;
ULONG count;
HRESULT hr;
BSTR bstr;
hr = CoCreateInstance( &CLSID_WbemLocator, NULL, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (void**)&wbem_locator );
if (FAILED(hr)) return hr;
bstr = SysAllocString( L"ROOT\\CIMV2" );
if (!bstr)
{
IWbemLocator_Release( wbem_locator );
return E_OUTOFMEMORY;
}
hr = IWbemLocator_ConnectServer( wbem_locator, bstr, NULL, NULL, NULL, 0, NULL, NULL, &wbem_service );
IWbemLocator_Release( wbem_locator );
SysFreeString( bstr );
if (FAILED(hr)) return hr;
bstr = SysAllocString( class );
if (!bstr)
{
IWbemServices_Release( wbem_service );
return E_OUTOFMEMORY;
}
hr = IWbemServices_CreateInstanceEnum( wbem_service, bstr, WBEM_FLAG_SYSTEM_ONLY, NULL, &wbem_enum );
IWbemServices_Release( wbem_service );
SysFreeString( bstr );
if (FAILED(hr)) return hr;
hr = IEnumWbemClassObject_Next( wbem_enum, 1000, 1, &wbem_class, &count );
IEnumWbemClassObject_Release( wbem_enum );
if (FAILED(hr)) return hr;
hr = IWbemClassObject_Get( wbem_class, L"SerialNumber", 0, &serial, NULL, NULL );
IWbemClassObject_Release( wbem_class );
if (FAILED(hr)) return hr;
*value = V_BSTR( &serial );
VariantClear( &serial );
return hr;
}
static HRESULT WINAPI statics_get_SerialNumber( ISmbiosInformationStatics *iface, HSTRING *value ) static HRESULT WINAPI statics_get_SerialNumber( ISmbiosInformationStatics *iface, HSTRING *value )
{ {
FIXME( "iface %p, value %p stub!\n", iface, value ); BSTR serial;
return E_NOTIMPL; HRESULT hr;
TRACE( "iface %p, value %p.\n", iface, value );
if (FAILED( hr = get_bios_serialnumber( &serial ) )) return hr;
if (FAILED( hr = WindowsCreateString( serial, wcslen(serial), value ) )) return hr;
TRACE( "Returning serial number: %s.\n", debugstr_w( serial ) );
return hr;
} }
static const struct ISmbiosInformationStaticsVtbl statics_vtbl = static const struct ISmbiosInformationStaticsVtbl statics_vtbl =
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#define WIDL_using_Windows_System_Profile_SystemManufacturers #define WIDL_using_Windows_System_Profile_SystemManufacturers
#include "windows.system.profile.systemmanufacturers.h" #include "windows.system.profile.systemmanufacturers.h"
#include "wbemcli.h"
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ #define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
static inline impl_type *impl_from( iface_type *iface ) \ static inline impl_type *impl_from( iface_type *iface ) \
{ \ { \
......
...@@ -75,11 +75,11 @@ static void test_Smbios_Statics(void) ...@@ -75,11 +75,11 @@ static void test_Smbios_Statics(void)
if (0) /* Win8 Crash */ if (0) /* Win8 Crash */
{ {
hr = ISmbiosInformationStatics_get_SerialNumber( smbios_statics, &serial ); hr = ISmbiosInformationStatics_get_SerialNumber( smbios_statics, &serial );
todo_wine ok( hr == S_OK || broken(hr == E_UNEXPECTED), "got hr %#lx.\n", hr ); ok( hr == S_OK || broken(hr == E_UNEXPECTED), "got hr %#lx.\n", hr );
if (hr == S_OK) if (hr == S_OK)
{ {
buf = WindowsGetStringRawBuffer( serial, &len ); buf = WindowsGetStringRawBuffer( serial, &len );
todo_wine ok( buf != NULL && len > 0, "WindowsGetStringRawBuffer returned buf %p, len %u\n", buf, len ); ok( buf != NULL && len > 0, "WindowsGetStringRawBuffer returned buf %p, len %u\n", buf, len );
WindowsDeleteString( serial ); WindowsDeleteString( serial );
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment