forked from Chuyu-Team/VC-LTL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions_downlevel.cpp
More file actions
45 lines (37 loc) · 1.07 KB
/
Copy pathexceptions_downlevel.cpp
File metadata and controls
45 lines (37 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "pch.h"
#include <roerrorapi.h>
extern "C" void *__GetPlatformExceptionInfo(int *);
namespace Platform
{
typedef struct _WinRTExceptionInfo
{
BSTR description;
BSTR restrictedErrorString;
BSTR restrictedErrorReference;
BSTR capabilitySid;
HRESULT hr;
::Microsoft::WRL::ComPtr<IRestrictedErrorInfo> restrictedInfo;
void* throwInfo; // Do not need to free - this points to a static part of our binary.
unsigned int size;
typedef void* (__stdcall *PFNPREPARE_FOR_THROW)(void* pException);
} WinRTExceptionInfo;
}
VCCORLIB_API long __stdcall __abi_translateCurrentException(bool translateBadAlloc)
{
int isBadAlloc = 0;
auto exinfo = reinterpret_cast< ::Platform::WinRTExceptionInfo*>(__GetPlatformExceptionInfo(&isBadAlloc));
if (isBadAlloc && translateBadAlloc)
{
::Windows::Foundation::Diagnostics::OriginateError(E_OUTOFMEMORY, nullptr);
return E_OUTOFMEMORY;
}
else if (exinfo != nullptr)
{
if (exinfo->restrictedInfo != nullptr)
{
::SetRestrictedErrorInfo(exinfo->restrictedInfo.Get());
}
return exinfo->hr;
}
__abi_FailFast();
}