From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55759 --- dlls/windows.system.profile.systemid/main.c | 46 +++++++++++++++++-- .../windows.system.profile.systemid/private.h | 1 + .../tests/systemid.c | 6 --- 3 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/dlls/windows.system.profile.systemid/main.c b/dlls/windows.system.profile.systemid/main.c index 5cef5982580..b00cbc5973e 100644 --- a/dlls/windows.system.profile.systemid/main.c +++ b/dlls/windows.system.profile.systemid/main.c @@ -119,6 +119,7 @@ struct system_identification_info ISystemIdentificationInfo ISystemIdentificationInfo_iface; LONG ref;
+ IBuffer *system_id; SystemIdentificationSource system_id_source; };
@@ -162,7 +163,11 @@ static ULONG WINAPI system_identification_info_Release( ISystemIdentificationInf
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
- if (!ref) free( impl ); + if (!ref) + { + IBuffer_Release( impl->system_id ); + free( impl ); + } return ref; }
@@ -186,8 +191,15 @@ static HRESULT WINAPI system_identification_info_GetTrustLevel( ISystemIdentific
static HRESULT WINAPI system_identification_info_get_Id( ISystemIdentificationInfo *iface, IBuffer **value ) { - FIXME( "iface %p, value %p stub!\n", iface, value ); - return E_NOTIMPL; + struct system_identification_info *impl = impl_from_ISystemIdentificationInfo( iface ); + + TRACE( "iface %p, value %p\n", iface, value ); + + if (!value) return E_INVALIDARG; + + *value = impl->system_id; + IBuffer_AddRef( *value ); + return S_OK; }
static HRESULT WINAPI system_identification_info_get_Source( ISystemIdentificationInfo *iface, SystemIdentificationSource *value ) @@ -218,9 +230,31 @@ static const struct ISystemIdentificationInfoVtbl system_identification_info_vtb
DEFINE_IINSPECTABLE( system_id_statics, ISystemIdentificationStatics, struct system_id_statics, IActivationFactory_iface )
+static HRESULT get_system_id( IBuffer **system_id, SystemIdentificationSource *system_id_source ) +{ + static const WCHAR *buffer_statics_name = L"Windows.Storage.Streams.Buffer"; + IBufferFactory *buffer_factory = NULL; + IActivationFactory *factory = NULL; + HSTRING str = NULL; + HRESULT hr = WindowsCreateString( buffer_statics_name, wcslen( buffer_statics_name ), &str ); + + FIXME( "returning empty ID.\n" ); + + if (SUCCEEDED(hr)) hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + if (SUCCEEDED(hr)) hr = IActivationFactory_QueryInterface( factory, &IID_IBufferFactory, (void **)&buffer_factory ); + if (SUCCEEDED(hr)) hr = IBufferFactory_Create( buffer_factory, 0, system_id ); + if (SUCCEEDED(hr)) *system_id_source = SystemIdentificationSource_None; + + if (buffer_factory) IBufferFactory_Release( buffer_factory ); + if (factory) IActivationFactory_Release( factory ); + WindowsDeleteString( str ); + return hr; +} + static HRESULT WINAPI system_id_statics_GetSystemIdForPublisher( ISystemIdentificationStatics *iface, ISystemIdentificationInfo **result ) { struct system_identification_info *impl; + HRESULT hr;
FIXME( "iface %p, result %p semi-stub!\n", iface, result );
@@ -228,8 +262,12 @@ static HRESULT WINAPI system_id_statics_GetSystemIdForPublisher( ISystemIdentifi if (!(impl = calloc( 1, sizeof( *impl ) ))) return E_OUTOFMEMORY;
impl->ISystemIdentificationInfo_iface.lpVtbl = &system_identification_info_vtbl; - impl->system_id_source = SystemIdentificationSource_None; impl->ref = 1; + if (FAILED(hr = get_system_id( &impl->system_id, &impl->system_id_source ))) + { + free( impl ); + return hr; + }
*result = &impl->ISystemIdentificationInfo_iface; TRACE( "created ISystemIdentificationInfo %p.\n", *result ); diff --git a/dlls/windows.system.profile.systemid/private.h b/dlls/windows.system.profile.systemid/private.h index 6e11787ab03..d1bcd395c56 100644 --- a/dlls/windows.system.profile.systemid/private.h +++ b/dlls/windows.system.profile.systemid/private.h @@ -26,6 +26,7 @@ #include "winstring.h"
#include "activation.h" +#include "roapi.h"
#include "wine/debug.h"
diff --git a/dlls/windows.system.profile.systemid/tests/systemid.c b/dlls/windows.system.profile.systemid/tests/systemid.c index e5979cc27d8..4141ecf5a3d 100644 --- a/dlls/windows.system.profile.systemid/tests/systemid.c +++ b/dlls/windows.system.profile.systemid/tests/systemid.c @@ -96,15 +96,10 @@ static void test_SystemIdentification_Statics(void) ok( system_id_source == SystemIdentificationSource_Uefi, "ISystemIdentificationInfo_get_Source returned %u.\n", system_id_source );
hr = ISystemIdentificationInfo_get_Id( system_id_info, NULL ); - todo_wine ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr ); hr = ISystemIdentificationInfo_get_Id( system_id_info, &system_id_buffer ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); - if (hr == S_OK) - { hr = ISystemIdentificationInfo_get_Id( system_id_info, &system_id_buffer2 ); - todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); ref = IBuffer_Release( system_id_buffer2 ); todo_wine @@ -140,7 +135,6 @@ static void test_SystemIdentification_Statics(void) ref = IBuffer_Release( system_id_buffer ); todo_wine ok( ref == 2, "got ref %ld.\n", ref ); - }
ref = ISystemIdentificationInfo_Release( system_id_info ); ok( ref == 0, "got ref %ld.\n", ref );