[PATCH 0/2] MR7864: windows.system.profile.systemid: Implement ISystemIdentificationInfo::get_Id().
From: Mohamad Al-Jaf <mohamadaljaf(a)gmail.com> --- .../tests/systemid.c | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dlls/windows.system.profile.systemid/tests/systemid.c b/dlls/windows.system.profile.systemid/tests/systemid.c index b34eae43994..e5979cc27d8 100644 --- a/dlls/windows.system.profile.systemid/tests/systemid.c +++ b/dlls/windows.system.profile.systemid/tests/systemid.c @@ -25,9 +25,13 @@ #include "roapi.h" +#define WIDL_using_Windows_Storage_Streams +#include "windows.storage.streams.h" #define WIDL_using_Windows_System_Profile #include "windows.system.profile.h" +#include "robuffer.h" + #include "wine/test.h" #define check_interface( obj, iid, supported ) check_interface_( __LINE__, obj, iid, supported ) @@ -49,8 +53,13 @@ static void test_SystemIdentification_Statics(void) ISystemIdentificationStatics *system_id_statics = (void *)0xdeadbeef; ISystemIdentificationInfo *system_id_info = (void *)0xdeadbeef; SystemIdentificationSource system_id_source = 0xdeadbeef; + IBufferByteAccess *byte_access = (void *)0xdeadbeef; IActivationFactory *factory = (void *)0xdeadbeef; + IBuffer *system_id_buffer2 = (void *)0xdeadbeef; + IBuffer *system_id_buffer = (void *)0xdeadbeef; + BYTE *system_id = (void *)0xdeadbeef; HSTRING str = NULL; + UINT32 capacity; HRESULT hr; LONG ref; @@ -86,6 +95,53 @@ static void test_SystemIdentification_Statics(void) todo_wine 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 + ok( ref == 3, "got ref %ld.\n", ref ); + + hr = IBuffer_get_Capacity( system_id_buffer, &capacity ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + todo_wine + ok( capacity != 0, "got 0 capacity.\n" ); + hr = IBuffer_QueryInterface( system_id_buffer, &IID_IBufferByteAccess, (void **)&byte_access ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = IBufferByteAccess_Buffer( byte_access, &system_id ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + if (capacity) + { + BOOL empty_id = TRUE; + + for ( UINT32 i = 0; i < capacity; i++ ) + { + if (system_id[i] != 0) + { + empty_id = FALSE; + break; + } + } + + todo_wine + ok( !empty_id, "got empty system_id.\n" ); + } + ref = IBufferByteAccess_Release( byte_access ); + todo_wine + ok( ref == 3, "got ref %ld.\n", ref ); + 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 ); ref = ISystemIdentificationStatics_Release( system_id_statics ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7864
From: Mohamad Al-Jaf <mohamadaljaf(a)gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55759 --- dlls/windows.system.profile.systemid/main.c | 50 +++++++++++++++++-- .../windows.system.profile.systemid/private.h | 1 + .../tests/systemid.c | 9 ---- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/dlls/windows.system.profile.systemid/main.c b/dlls/windows.system.profile.systemid/main.c index 5cef5982580..1281bb738cb 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,35 @@ 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)) + { + IBuffer_AddRef( *system_id ); + *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 +266,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..39299ae7005 100644 --- a/dlls/windows.system.profile.systemid/tests/systemid.c +++ b/dlls/windows.system.profile.systemid/tests/systemid.c @@ -96,18 +96,12 @@ 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 ok( ref == 3, "got ref %ld.\n", ref ); hr = IBuffer_get_Capacity( system_id_buffer, &capacity ); @@ -135,12 +129,9 @@ static void test_SystemIdentification_Statics(void) ok( !empty_id, "got empty system_id.\n" ); } ref = IBufferByteAccess_Release( byte_access ); - todo_wine ok( ref == 3, "got ref %ld.\n", ref ); 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 ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/7864
Rémi Bernon (@rbernon) commented about dlls/windows.system.profile.systemid/tests/systemid.c:
+ todo_wine + ok( ref == 3, "got ref %ld.\n", ref ); + + hr = IBuffer_get_Capacity( system_id_buffer, &capacity ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + todo_wine + ok( capacity != 0, "got 0 capacity.\n" ); + hr = IBuffer_QueryInterface( system_id_buffer, &IID_IBufferByteAccess, (void **)&byte_access ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = IBufferByteAccess_Buffer( byte_access, &system_id ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + if (capacity) + { + BOOL empty_id = TRUE; + + for ( UINT32 i = 0; i < capacity; i++ ) Sadly we don't use `for` inline declarations.
```suggestion:-2+0 BOOL empty_id = TRUE; UINT32 i; for (i = 0; i < capacity; i++) ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/7864#note_102014
On Mon Apr 28 10:45:45 2025 +0000, Rémi Bernon wrote:
Sadly we don't use `for` inline declarations. ```suggestion:-2+0 BOOL empty_id = TRUE; UINT32 i; for (i = 0; i < capacity; i++) ``` Actually we do now.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7864#note_102018
On Mon Apr 28 10:55:23 2025 +0000, Alexandre Julliard wrote:
Actually we do now. Amazing :smile:
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7864#note_102019
Rémi Bernon (@rbernon) commented about dlls/windows.system.profile.systemid/main.c:
+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)) + { + IBuffer_AddRef( *system_id ); You already own a reference to system_id here from `IBufferFactory_Create`, no need to add another one as you don't release it in this function.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/7864#note_102021
participants (4)
-
Alexandre Julliard (@julliard) -
Mohamad Al-Jaf -
Mohamad Al-Jaf (@maljaf) -
Rémi Bernon