Skip to content

Commit

Permalink
Fea #94, Fix some Windows Runtime API fallback behavior to follow the…
Browse files Browse the repository at this point in the history
… previous C++/WinRT fallback implementations.
  • Loading branch information
MouriNaruto authored and mingkuang-Chuyu committed May 30, 2024
1 parent 9098fee commit 6cc251b
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 224 deletions.
20 changes: 10 additions & 10 deletions ThunksList.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@
| RoActivateInstance | 不存在时,返回 E_NOTIMPL。
| RoRegisterActivationFactories | 不存在时,返回 E_NOTIMPL。
| RoRevokeActivationFactories | 不存在时,什么也不做。
| RoGetActivationFactory | 不存在时,返回 E_NOTIMPL。
| RoGetActivationFactory | 不存在时,返回 CLASS_E_CLASSNOTAVAILABLE
| RoRegisterForApartmentShutdown | 不存在时,返回 E_NOTIMPL。
| RoUnregisterForApartmentShutdown | 不存在时,返回 E_NOTIMPL。
| RoGetApartmentIdentifier | 不存在时,返回 E_NOTIMPL。

## api-ms-win-core-winrt-error-l1-1-0.dll
| 函数 | Fallback
| ---- | -----------
| RoOriginateError | 不存在时,返回 FALSE.
| RoOriginateErrorW | 不存在时,返回 FALSE.
| RoOriginateError | 不存在时,返回 TRUE.
| RoOriginateErrorW | 不存在时,返回 TRUE.

## api-ms-win-core-winrt-string-l1-1-0.dll
| 函数 | Fallback
Expand Down Expand Up @@ -612,13 +612,13 @@
| 函数 | Fallback
| ---- | -----------
| UiaClientsAreListening | 不存在时,假装没有人在监听。
| UiaHostProviderFromHwnd | 存在时,报告错误 E_NOTIMPL。
| UiaRaiseAutomationEvent | 存在时,报告错误 E_NOTIMPL。
| UiaRaiseAutomationPropertyChangedEvent | 存在时,报告错误 E_NOTIMPL。
| UiaReturnRawElementProvider | 存在时,报告错误 E_NOTIMPL。
| UiaGetReservedMixedAttributeValue | 存在时,报告错误 E_NOTIMPL。
| UiaGetReservedNotSupportedValue | 存在时,报告错误 E_NOTIMPL。
| UiaRaiseStructureChangedEvent | 存在时,报告错误 E_NOTIMPL。
| UiaHostProviderFromHwnd | 不存在时,报告错误 E_NOTIMPL。
| UiaRaiseAutomationEvent | 不存在时,报告错误 E_NOTIMPL。
| UiaRaiseAutomationPropertyChangedEvent | 不存在时,报告错误 E_NOTIMPL。
| UiaReturnRawElementProvider | 不存在时,报告错误 E_NOTIMPL。
| UiaGetReservedMixedAttributeValue | 不存在时,报告错误 E_NOTIMPL。
| UiaGetReservedNotSupportedValue | 不存在时,报告错误 E_NOTIMPL。
| UiaRaiseStructureChangedEvent | 不存在时,报告错误 E_NOTIMPL。

## user32.dll
| 函数 | Fallback
Expand Down
90 changes: 46 additions & 44 deletions src/Thunks/api-ms-win-core-winrt-error.hpp
Original file line number Diff line number Diff line change
@@ -1,57 +1,59 @@

#include <roerrorapi.h>
#include <roerrorapi.h>

namespace YY
namespace YY::Thunks
{
namespace Thunks
{
#if (YY_Thunks_Support_Version < NTDDI_WIN8)

//Windows 8 [desktop apps | UWP apps]
//Windows Server 2012 [desktop apps | UWP apps]
__DEFINE_THUNK(
api_ms_win_core_winrt_error_l1_1_0,
8,
BOOL,
WINAPI,
RoOriginateError,
_In_ HRESULT error,
_In_opt_ HSTRING message
)
//Windows 8 [desktop apps | UWP apps]
//Windows Server 2012 [desktop apps | UWP apps]
__DEFINE_THUNK(
api_ms_win_core_winrt_error_l1_1_0,
8,
BOOL,
WINAPI,
RoOriginateError,
_In_ HRESULT error,
_In_opt_ HSTRING message
)
{
if (auto pRoOriginateError = try_get_RoOriginateError())
{
if (auto pRoOriginateError = try_get_RoOriginateError())
{
return pRoOriginateError(error, message);
}

return FALSE;
return pRoOriginateError(error, message);
}

// According to the C++/WinRT fallback implementation, we should
// return TRUE to tell the caller that the error message was
// reported successfully.
return TRUE;
}
#endif

#if (YY_Thunks_Support_Version < NTDDI_WIN8)

//Windows 8 [desktop apps | UWP apps]
//Windows Server 2012 [desktop apps | UWP apps]
__DEFINE_THUNK(
api_ms_win_core_winrt_error_l1_1_0,
12,
BOOL,
WINAPI,
RoOriginateErrorW,
_In_ HRESULT error,
_In_ UINT cchMax,
_When_(cchMax == 0, _In_reads_or_z_opt_(MAX_ERROR_MESSAGE_CHARS) )
_When_(cchMax > 0 && cchMax < MAX_ERROR_MESSAGE_CHARS, _In_reads_or_z_(cchMax) )
_When_(cchMax >= MAX_ERROR_MESSAGE_CHARS, _In_reads_or_z_(MAX_ERROR_MESSAGE_CHARS) ) PCWSTR message
)
//Windows 8 [desktop apps | UWP apps]
//Windows Server 2012 [desktop apps | UWP apps]
__DEFINE_THUNK(
api_ms_win_core_winrt_error_l1_1_0,
12,
BOOL,
WINAPI,
RoOriginateErrorW,
_In_ HRESULT error,
_In_ UINT cchMax,
_When_(cchMax == 0, _In_reads_or_z_opt_(MAX_ERROR_MESSAGE_CHARS) )
_When_(cchMax > 0 && cchMax < MAX_ERROR_MESSAGE_CHARS, _In_reads_or_z_(cchMax) )
_When_(cchMax >= MAX_ERROR_MESSAGE_CHARS, _In_reads_or_z_(MAX_ERROR_MESSAGE_CHARS) ) PCWSTR message
)
{
if (auto pRoOriginateErrorW = try_get_RoOriginateErrorW())
{
if (auto pRoOriginateErrorW = try_get_RoOriginateErrorW())
{
return pRoOriginateErrorW(error, cchMax, message);
}

return FALSE;
return pRoOriginateErrorW(error, cchMax, message);
}
#endif

// According to the C++/WinRT fallback implementation, we should
// return TRUE to tell the caller that the error message was
// reported successfully.
return TRUE;
}
}
#endif
}
Loading

0 comments on commit 6cc251b

Please sign in to comment.