Attached windows demo code and results run on windows as follows: [main.cpp](/uploads/80f085ee3930b921688ea13aa9d25dc4/main.cpp)
[ConsoleApplication1.exe](/uploads/1fdcbb14dfc38c3ecf109c438bfd21e5/ConsoleApplication1.exe)

and after add implementation , the running results in Wine are consistent with those in Windows.
Signed-off-by: chenjiangyi chenjiangyi@uniontech.com
From: chenjiangyi chenjiangyi@uniontech.com
Signed-off-by: chenjiangyi chenjiangyi@uniontech.com --- dlls/wintypes/main.c | 45 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index cb0a9b6fab0..e17e9ef3622 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -25,10 +25,15 @@ static const struct { const WCHAR *name; unsigned int max_major; + unsigned int max_minor; } present_contracts[] = { - { L"Windows.Foundation.UniversalApiContract", 10, }, + { L"Windows.Foundation.UniversalApiContract", 10, 0, }, + { L"Windows.Foundation.FoundationContract", 4, 0, }, + { L"Windows.Networking.Connectivity.WwanContract", 2, 0, }, + { L"Windows.Services.Store.StoreContract", 4, 0, }, + { L"Windows.System.SystemManagementContract", 7, 0, }, };
static BOOLEAN is_api_contract_present( const HSTRING hname, unsigned int version ) @@ -243,10 +248,14 @@ static HRESULT STDMETHODCALLTYPE api_information_statics_IsEnumNamedValuePresent static HRESULT STDMETHODCALLTYPE api_information_statics_IsApiContractPresentByMajor( IApiInformationStatics *iface, HSTRING contract_name, UINT16 major_version, BOOLEAN *value) { - FIXME("iface %p, contract_name %s, major_version %u, value %p semi-stub.\n", iface, + const WCHAR *name; + FIXME("iface %p, contract_name %s, major_version %u, value %p.\n", iface, debugstr_hstring(contract_name), major_version, value);
- if (!contract_name) + if (!contract_name || !value) + return E_INVALIDARG; + + if (!WindowsGetStringLen(contract_name)) return E_INVALIDARG;
*value = is_api_contract_present( contract_name, major_version ); @@ -257,13 +266,37 @@ static HRESULT STDMETHODCALLTYPE api_information_statics_IsApiContractPresentByM IApiInformationStatics *iface, HSTRING contract_name, UINT16 major_version, UINT16 minor_version, BOOLEAN *value) { - FIXME("iface %p, contract_name %s, major_version %u, minor_version %u, value %p stub!\n", iface, + const WCHAR *name; + unsigned int i; + + FIXME("iface %p, contract_name %s, major_version %u, minor_version %u, value %p semi-stub.\n", iface, debugstr_hstring(contract_name), major_version, minor_version, value);
- if (!contract_name) + if (!contract_name || !value) return E_INVALIDARG;
- return E_NOTIMPL; + if (!WindowsGetStringLen(contract_name)) + return E_INVALIDARG; + + name = WindowsGetStringRawBuffer(contract_name, NULL); + if (!name) + return E_FAIL; + + *value = FALSE; + + for (i = 0; i < ARRAY_SIZE(present_contracts); ++i) + { + if (!wcsicmp(name, present_contracts[i].name)) + { + if (major_version < present_contracts[i].max_major) + *value = TRUE; + else if (major_version == present_contracts[i].max_major) + *value = minor_version <= present_contracts[i].max_minor; + break; + } + } + + return S_OK; }
static const struct IApiInformationStaticsVtbl api_information_statics_vtbl =
What do you need this for? Do we know where this data is coming from on Windows? Is it likely static like that or collected from installed modules perhaps?
Api contract are in idl files, and should be stored in binary form in winmd files.
Version inside wine idl should be there: - UniversalApiContract & FoundationContract: https://gitlab.winehq.org/wine/wine/-/blob/master/include/windowscontracts.i... - Windows.Networking.Connectivity.WwanContract: https://gitlab.winehq.org/wine/wine/-/blob/master/include/windows.networking... - Windows.Services.Store.StoreContract: No file, a PR with the idl with the proper contract in it would be more future proof. - Windows.System.SystemManagementContract: No file, a PR with the idl with the proper contract in it would be more future proof.
@hans I suspect you might be the one to implement this method properly in the future, since you worked a lot on winmd stuff in widl, so I think you might have your own piece to say there.
@nsivov For enterprise-level cross-platform management tools, such as: Using SystemManagementContract to launch and monitor Win32 processes . Verifying enterprise application licenses through StoreContract .
@Fox2Code [Windows.System.idl](/uploads/8684c0162c7fb0bbeb6038379a48f4ec/Windows.System.idl) [Windows.Services.Store.idl](/uploads/717ddd3f2cd076fac43206525061fd22/Windows.Services.Store.idl)
The attached Windows.System.idl file contains Windows.System.SystemManagementContract, which I propose to append to Wine's include/windows.system.idl. The attached Windows.Services.Store.idl file includes Windows.Services.Store.StoreContract, but it requires importing Windows.Web.Http.idl. Due to recursive imports with missing files, this is currently omitted from Wine.
Thank you for the improvement suggestions. The current interface implementation is indeed incomplete and only temporarily meets the application's runtime requirements. Based on the files I provided, I hope to receive more of your improvement recommendations.