From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- configure.ac | 2 + .../Makefile.in | 6 + .../classes.idl | 24 ++++ dlls/windows.system.profile.systemid/main.c | 136 ++++++++++++++++++ .../windows.system.profile.systemid/private.h | 33 +++++ .../tests/Makefile.in | 5 + .../tests/systemid.c | 83 +++++++++++ .../windows.system.profile.systemid.spec | 3 + include/windows.system.profile.idl | 2 + 9 files changed, 294 insertions(+) create mode 100644 dlls/windows.system.profile.systemid/Makefile.in create mode 100644 dlls/windows.system.profile.systemid/classes.idl create mode 100644 dlls/windows.system.profile.systemid/main.c create mode 100644 dlls/windows.system.profile.systemid/private.h create mode 100644 dlls/windows.system.profile.systemid/tests/Makefile.in create mode 100644 dlls/windows.system.profile.systemid/tests/systemid.c create mode 100644 dlls/windows.system.profile.systemid/windows.system.profile.systemid.spec
diff --git a/configure.ac b/configure.ac index 306cbe03146..91137b86484 100644 --- a/configure.ac +++ b/configure.ac @@ -3256,6 +3256,8 @@ WINE_CONFIG_MAKEFILE(dlls/windows.storage.applicationdata) WINE_CONFIG_MAKEFILE(dlls/windows.storage.applicationdata/tests) WINE_CONFIG_MAKEFILE(dlls/windows.storage) WINE_CONFIG_MAKEFILE(dlls/windows.storage/tests) +WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemid) +WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemid/tests) WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemmanufacturers) WINE_CONFIG_MAKEFILE(dlls/windows.system.profile.systemmanufacturers/tests) WINE_CONFIG_MAKEFILE(dlls/windows.ui.xaml) diff --git a/dlls/windows.system.profile.systemid/Makefile.in b/dlls/windows.system.profile.systemid/Makefile.in new file mode 100644 index 00000000000..d6b490e4784 --- /dev/null +++ b/dlls/windows.system.profile.systemid/Makefile.in @@ -0,0 +1,6 @@ +MODULE = windows.system.profile.systemid.dll +IMPORTS = combase + +SOURCES = \ + classes.idl \ + main.c diff --git a/dlls/windows.system.profile.systemid/classes.idl b/dlls/windows.system.profile.systemid/classes.idl new file mode 100644 index 00000000000..f143f50f092 --- /dev/null +++ b/dlls/windows.system.profile.systemid/classes.idl @@ -0,0 +1,24 @@ +/* + * Runtime Classes for windows.system.profile.systemid.dll + * + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#pragma makedep register + +#define _WINDOWS_SYSTEM_PROFILE_SYSTEM_ID +#include "windows.system.profile.idl" diff --git a/dlls/windows.system.profile.systemid/main.c b/dlls/windows.system.profile.systemid/main.c new file mode 100644 index 00000000000..af55ea204d3 --- /dev/null +++ b/dlls/windows.system.profile.systemid/main.c @@ -0,0 +1,136 @@ +/* WinRT Windows.System.Profile.SystemIdentification Implementation + * + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "initguid.h" +#include "private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(systemid); + +struct system_id_statics +{ + IActivationFactory IActivationFactory_iface; + LONG ref; +}; + +static inline struct system_id_statics *impl_from_IActivationFactory( IActivationFactory *iface ) +{ + return CONTAINING_RECORD( iface, struct system_id_statics, IActivationFactory_iface ); +} + +static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out ) +{ + struct system_id_statics *impl = impl_from_IActivationFactory( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IActivationFactory )) + { + *out = &impl->IActivationFactory_iface; + IInspectable_AddRef( *out ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI factory_AddRef( IActivationFactory *iface ) +{ + struct system_id_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI factory_Release( IActivationFactory *iface ) +{ + struct system_id_statics *impl = impl_from_IActivationFactory( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static HRESULT WINAPI factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance ) +{ + FIXME( "iface %p, instance %p stub!\n", iface, instance ); + return E_NOTIMPL; +} + +static const struct IActivationFactoryVtbl factory_vtbl = +{ + factory_QueryInterface, + factory_AddRef, + factory_Release, + /* IInspectable methods */ + factory_GetIids, + factory_GetRuntimeClassName, + factory_GetTrustLevel, + /* IActivationFactory methods */ + factory_ActivateInstance, +}; + +static struct system_id_statics system_id_statics = +{ + {&factory_vtbl}, + 1, +}; + +static IActivationFactory *system_id_factory = &system_id_statics.IActivationFactory_iface; + +HRESULT WINAPI DllGetClassObject( REFCLSID clsid, REFIID riid, void **out ) +{ + FIXME( "clsid %s, riid %s, out %p stub!\n", debugstr_guid( clsid ), debugstr_guid( riid ), out ); + return CLASS_E_CLASSNOTAVAILABLE; +} + +HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **factory ) +{ + const WCHAR *name = WindowsGetStringRawBuffer( classid, NULL ); + + TRACE( "classid %s, factory %p.\n", debugstr_hstring( classid ), factory ); + + *factory = NULL; + + if (!wcscmp( name, RuntimeClass_Windows_System_Profile_SystemIdentification )) + IActivationFactory_QueryInterface( system_id_factory, &IID_IActivationFactory, (void **)factory ); + + if (*factory) return S_OK; + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/dlls/windows.system.profile.systemid/private.h b/dlls/windows.system.profile.systemid/private.h new file mode 100644 index 00000000000..b55020a999f --- /dev/null +++ b/dlls/windows.system.profile.systemid/private.h @@ -0,0 +1,33 @@ +/* WinRT windows.system.profile.systemid.dll Implementation + * + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include <stddef.h> + +#define COBJMACROS +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "activation.h" + +#include "wine/debug.h" + +#define WIDL_using_Windows_System_Profile +#include "windows.system.profile.h" diff --git a/dlls/windows.system.profile.systemid/tests/Makefile.in b/dlls/windows.system.profile.systemid/tests/Makefile.in new file mode 100644 index 00000000000..9ff4f9b472e --- /dev/null +++ b/dlls/windows.system.profile.systemid/tests/Makefile.in @@ -0,0 +1,5 @@ +TESTDLL = windows.system.profile.systemid.dll +IMPORTS = combase + +SOURCES = \ + systemid.c diff --git a/dlls/windows.system.profile.systemid/tests/systemid.c b/dlls/windows.system.profile.systemid/tests/systemid.c new file mode 100644 index 00000000000..6e857bf331a --- /dev/null +++ b/dlls/windows.system.profile.systemid/tests/systemid.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2025 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ +#define COBJMACROS +#include "initguid.h" +#include <stdarg.h> + +#include "windef.h" +#include "winbase.h" +#include "winstring.h" + +#include "roapi.h" + +#define WIDL_using_Windows_System_Profile +#include "windows.system.profile.h" + +#include "wine/test.h" + +#define check_interface( obj, iid, supported ) check_interface_( __LINE__, obj, iid, supported ) +static void check_interface_( unsigned int line, void *obj, const IID *iid, BOOL supported ) +{ + IUnknown *iface = obj; + IUnknown *unk; + HRESULT hr; + + hr = IUnknown_QueryInterface( iface, iid, (void **)&unk ); + ok_(__FILE__, line)( hr == S_OK || (!supported && hr == E_NOINTERFACE), "got hr %#lx.\n", hr ); + if (SUCCEEDED(hr)) + IUnknown_Release( unk ); +} + +static void test_SystemIdentification_Statics(void) +{ + static const WCHAR *system_id_statics_name = L"Windows.System.Profile.SystemIdentification"; + IActivationFactory *factory = (void *)0xdeadbeef; + HSTRING str = NULL; + HRESULT hr; + LONG ref; + + hr = WindowsCreateString( system_id_statics_name, wcslen( system_id_statics_name ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory ); + WindowsDeleteString( str ); + ok( hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "got hr %#lx.\n", hr ); + if (hr == REGDB_E_CLASSNOTREG) + { + win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( system_id_statics_name ) ); + return; + } + + check_interface( factory, &IID_IUnknown, TRUE ); + check_interface( factory, &IID_IInspectable, TRUE ); + check_interface( factory, &IID_IAgileObject, FALSE ); + + ref = IActivationFactory_Release( factory ); + ok( ref == 1, "got ref %ld.\n", ref ); +} + +START_TEST(systemid) +{ + HRESULT hr; + + hr = RoInitialize( RO_INIT_MULTITHREADED ); + ok( hr == S_OK, "RoInitialize failed, hr %#lx\n", hr ); + + test_SystemIdentification_Statics(); + + RoUninitialize(); +} diff --git a/dlls/windows.system.profile.systemid/windows.system.profile.systemid.spec b/dlls/windows.system.profile.systemid/windows.system.profile.systemid.spec new file mode 100644 index 00000000000..31a5eafe950 --- /dev/null +++ b/dlls/windows.system.profile.systemid/windows.system.profile.systemid.spec @@ -0,0 +1,3 @@ +@ stdcall -private DllGetActivationFactory(ptr ptr) +@ stdcall -private DllCanUnloadNow() +@ stdcall -private DllGetClassObject(ptr ptr ptr) diff --git a/include/windows.system.profile.idl b/include/windows.system.profile.idl index ef99a8af730..9e0b0ed8411 100644 --- a/include/windows.system.profile.idl +++ b/include/windows.system.profile.idl @@ -97,6 +97,7 @@ namespace Windows.System.Profile { HRESULT GetSystemIdForUser([in] Windows.System.User *user, [out, retval] Windows.System.Profile.SystemIdentificationInfo **result); }
+#ifndef _WINDOWS_SYSTEM_PROFILE_SYSTEM_ID [ contract(Windows.Foundation.UniversalApiContract, 1.0), marshaling_behavior(agile), @@ -118,6 +119,7 @@ namespace Windows.System.Profile { runtimeclass AnalyticsInfo { } +#endif
#ifndef _TWINAPI_APPCORE [