-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
roapi一些错误处理函数 #142
roapi一些错误处理函数 #142
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
#if (YY_Thunks_Target < __WindowsNT6_2) | ||
#if (YY_Thunks_Target < __WindowsNT6_3) | ||
#include <roerrorapi.h> | ||
#include <winstring.h> | ||
#endif | ||
|
||
namespace YY::Thunks | ||
{ | ||
|
||
#if (YY_Thunks_Target < __WindowsNT6_2) | ||
//Windows 8 [desktop apps | UWP apps] | ||
//Windows Server 2012 [desktop apps | UWP apps] | ||
__DEFINE_THUNK( | ||
api_ms_win_core_winrt_error_l1_1_0, | ||
4, | ||
void, | ||
WINAPI, | ||
RoFailFastWithErrorContext, | ||
HRESULT hrError | ||
) | ||
{ | ||
if (auto pRoFailFastWithErrorContext = try_get_RoFailFastWithErrorContext()) | ||
{ | ||
pRoFailFastWithErrorContext(hrError); | ||
} | ||
} | ||
#endif | ||
|
||
|
||
#if (YY_Thunks_Target < __WindowsNT6_2) | ||
|
||
//Windows 8 [desktop apps | UWP apps] | ||
|
@@ -58,4 +80,80 @@ namespace YY::Thunks | |
return TRUE; | ||
} | ||
#endif | ||
|
||
#if (YY_Thunks_Target < __WindowsNT6_3) | ||
//Windows 8.1 [desktop apps | UWP apps] | ||
//Windows Server 2012 [desktop apps | UWP apps] | ||
__DEFINE_THUNK( | ||
api_ms_win_core_winrt_error_l1_1_1, | ||
12, | ||
BOOL, | ||
WINAPI, | ||
RoOriginateLanguageException, | ||
_In_ HRESULT error, | ||
_In_opt_ HSTRING message, | ||
_In_opt_ IUnknown* languageException | ||
) | ||
{ | ||
if (auto pRoOriginateLanguageException = try_get_RoOriginateLanguageException()) | ||
{ | ||
return pRoOriginateLanguageException(error, message, languageException); | ||
} | ||
if ((error == S_OK) || (!languageException) || WindowsIsStringEmpty(message)) | ||
return FALSE; | ||
// The RoOriginateLanguageException function behaves like RoOriginateError but takes another parameter that stores extra information about the error. | ||
return TRUE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fallback逻辑为什么不调用RoOriginateError? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 他们都是win8的api,fallback也没用吧... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
你的注释写着 RoOriginateLanguageException 8.1引入 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 确实 |
||
} | ||
#endif | ||
|
||
#if (YY_Thunks_Target < __WindowsNT6_2) | ||
//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, | ||
RoTransformError, | ||
_In_ HRESULT oldError, | ||
_In_ HRESULT newError, | ||
_In_opt_ HSTRING message | ||
) | ||
{ | ||
if (auto pRoTransformError = try_get_RoTransformError()) | ||
{ | ||
return pRoTransformError(oldError, newError, message); | ||
} | ||
if ((oldError == S_OK && newError == S_OK) || WindowsIsStringEmpty(message)) | ||
return FALSE; | ||
return TRUE; | ||
} | ||
#endif | ||
|
||
#if (YY_Thunks_Target < __WindowsNT6_2) | ||
//Windows 8 [desktop apps | UWP apps] | ||
//Windows Server 2012 [desktop apps | UWP apps] | ||
__DEFINE_THUNK( | ||
api_ms_win_core_winrt_error_l1_1_0, | ||
16, | ||
BOOL, | ||
WINAPI, | ||
RoTransformErrorW, | ||
_In_ HRESULT oldError, | ||
_In_ HRESULT newError, | ||
_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 pRoTransformErrorW = try_get_RoTransformErrorW()) | ||
{ | ||
return pRoTransformErrorW(oldError, newError, cchMax, message); | ||
} | ||
if ((oldError == S_OK && newError == S_OK) || ((!cchMax) || !(message))) | ||
return FALSE; | ||
return TRUE; | ||
} | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果从API语义上,RoFailFastWithErrorContext调用后不应该继续执行……
能解释一下原因吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没太懂,RoFailFastWithErrorContext不是这次你新增的吗?还是说抓个函数你有其他的参考来源?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不好意思,眼花了。我记得好像参考了哪个来着,奇怪