From 7fc89b9c5e9752ff76ffc093d466bfbf8e71fca3 Mon Sep 17 00:00:00 2001 From: mingkuang Date: Wed, 30 Jun 2021 13:01:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20RoInitialize=E3=80=81RoUni?= =?UTF-8?q?nitialize=E4=BB=A5=E5=8F=8A=E4=B8=80=E4=BA=9BWinRT=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=BF=94=E5=9B=9E=E5=80=BC=E4=BF=AE=E6=AD=A3=EF=BC=88?= =?UTF-8?q?https://github.com/Chuyu-Team/YY-Thunks/issues/28=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ThunksList.md | 3 +++ src/Thunks/api-ms-win-core-winrt-string.hpp | 13 ++++++++++++ src/Thunks/api-ms-win-core-winrt.hpp | 22 ++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/ThunksList.md b/ThunksList.md index 657652d..81318d0 100644 --- a/ThunksList.md +++ b/ThunksList.md @@ -222,3 +222,6 @@ | [FlsFree](https://docs.microsoft.com/windows/win32/api/fibersapi/nf-fibersapi-flsfree) | 不存在时,使用Tls实现。警告,此函数请勿跨模块使用!!! | [FlsGetValue](https://docs.microsoft.com/windows/win32/api/fibersapi/nf-fibersapi-flsgetvalue) | 不存在时,使用Tls实现。警告,此函数请勿跨模块使用!!! | [FlsSetValue](https://docs.microsoft.com/windows/win32/api/fibersapi/nf-fibersapi-flssetvalue) | 不存在时,使用Tls实现。警告,此函数请勿跨模块使用!!! +| [RoInitialize](https://docs.microsoft.com/windows/win32/api/roapi/nf-roapi-roinitialize) | 不存在时,调用 CoInitializeEx。 +| [RoUninitialize](https://docs.microsoft.com/windows/win32/api/roapi/nf-roapi-rouninitialize) | 不存在时,调用 CoUninitialize。 + diff --git a/src/Thunks/api-ms-win-core-winrt-string.hpp b/src/Thunks/api-ms-win-core-winrt-string.hpp index fe35413..4096054 100644 --- a/src/Thunks/api-ms-win-core-winrt-string.hpp +++ b/src/Thunks/api-ms-win-core-winrt-string.hpp @@ -25,6 +25,9 @@ namespace YY return pWindowsCreateString(sourceString, length, string); } + if (string) + *string = nullptr; + return E_NOTIMPL; } #endif @@ -51,6 +54,9 @@ namespace YY return pWindowsCreateStringReference(sourceString, length, hstringHeader, string); } + if (string) + *string = nullptr; + return E_NOTIMPL; } #endif @@ -98,6 +104,10 @@ namespace YY return pWindowsDuplicateString(string, newString); } + + if (newString) + *newString = nullptr; + return E_NOTIMPL; } #endif @@ -145,6 +155,9 @@ namespace YY return pWindowsGetStringRawBuffer(string, length); } + if (length) + *length = 0; + return nullptr; } #endif diff --git a/src/Thunks/api-ms-win-core-winrt.hpp b/src/Thunks/api-ms-win-core-winrt.hpp index f521413..3683f66 100644 --- a/src/Thunks/api-ms-win-core-winrt.hpp +++ b/src/Thunks/api-ms-win-core-winrt.hpp @@ -24,7 +24,12 @@ namespace YY return pRoInitialize(initType); } - return E_NOTIMPL; + if ((unsigned)initType > (unsigned)RO_INIT_MULTITHREADED) + { + return E_INVALIDARG; + } + + return CoInitializeEx(nullptr, initType ? COINIT_MULTITHREADED : COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); } #endif @@ -44,6 +49,8 @@ namespace YY { return pRoUninitialize(); } + + CoUninitialize(); } #endif @@ -66,6 +73,9 @@ namespace YY return pRoActivateInstance(activatableClassId, instance); } + if (instance) + *instance = nullptr; + return E_NOTIMPL; } #endif @@ -91,6 +101,9 @@ namespace YY return pRoRegisterActivationFactories(activatableClassIds, activationFactoryCallbacks, count, cookie); } + if (cookie) + *cookie = nullptr; + return E_NOTIMPL; } #endif @@ -136,6 +149,9 @@ namespace YY return pRoGetActivationFactory(activatableClassId, iid, factory); } + if (factory) + *factory = nullptr; + return E_NOTIMPL; } @@ -162,6 +178,10 @@ namespace YY return pRoRegisterForApartmentShutdown(callbackObject, apartmentIdentifier, regCookie); } + if (regCookie) + *regCookie = nullptr; + + return E_NOTIMPL; }