mirror of https://github.com/PCSX2/pcsx2.git
3rdparty: Update WIL to v1.0.240803.1
This commit is contained in:
parent
caaa3519ad
commit
3f1df0ea92
File diff suppressed because it is too large
Load Diff
|
@ -2398,7 +2398,7 @@ RETURN_IF_FAILED(wil::stream_seek_nothrow(source, LLONG_MAX, STREAM_SEEK_CUR));
|
|||
@param stream The stream to seek
|
||||
@param offset The position, in bytes from the current position, to seek
|
||||
@param from The starting point from which to seek, from the STREAM_SEEK_* set of values
|
||||
@param value Optionally recieves the new absolute position from the stream
|
||||
@param value Optionally receives the new absolute position from the stream
|
||||
*/
|
||||
inline HRESULT stream_seek_nothrow(_In_ IStream* stream, long long offset, unsigned long from, _Out_opt_ unsigned long long* value = nullptr)
|
||||
{
|
||||
|
@ -2418,7 +2418,7 @@ RETURN_HR(wil::stream_set_position_nothrow(source, 16));
|
|||
~~~~
|
||||
@param stream The stream whose size is to be returned in `value`
|
||||
@param offset The position, in bytes from the start of the stream, to seek to
|
||||
@param value Optionally recieves the new absolute position from the stream
|
||||
@param value Optionally receives the new absolute position from the stream
|
||||
*/
|
||||
inline HRESULT stream_set_position_nothrow(_In_ IStream* stream, unsigned long long offset, _Out_opt_ unsigned long long* value = nullptr)
|
||||
{
|
||||
|
@ -2888,7 +2888,7 @@ if (wcscmp(content.get(), L"waffles") == 0)
|
|||
@endcode
|
||||
@param source The stream from which to read a string
|
||||
@param options Controls the behavior when reading a zero-length string
|
||||
@return An non-null string (but possibly zero lengh) string read from `source`
|
||||
@return An non-null string (but possibly zero length) string read from `source`
|
||||
*/
|
||||
inline wil::unique_cotaskmem_string stream_read_string(_In_ ISequentialStream* source, empty_string_options options = empty_string_options::returns_empty)
|
||||
{
|
||||
|
|
|
@ -526,7 +526,7 @@ to be able to layer additional functionality into other libraries by their mere
|
|||
of initialization should be used whenever they are available.
|
||||
~~~~
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
||||
{
|
||||
g_pfnGetModuleName = GetCurrentModuleName;
|
||||
g_pfnFailFastInLoaderCallout = FailFastInLoaderCallout;
|
||||
|
@ -537,16 +537,16 @@ WI_HEADER_INITITALIZATION_FUNCTION(InitializeDesktopFamilyApis, []
|
|||
The above example is used within WIL to decide whether or not the library containing WIL is allowed to use
|
||||
desktop APIs. Building this functionality as `#IFDEF`s within functions would create ODR violations, whereas
|
||||
doing it with global function pointers and header initialization allows a runtime determination. */
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn)
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn)
|
||||
#elif defined(_M_IX86)
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
|
||||
extern "C" \
|
||||
{ \
|
||||
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
|
||||
} \
|
||||
__pragma(comment(linker, "/INCLUDE:_g_header_init_" #name))
|
||||
#elif defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_ARM64)
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) \
|
||||
#define WI_HEADER_INITIALIZATION_FUNCTION(name, fn) \
|
||||
extern "C" \
|
||||
{ \
|
||||
__declspec(selectany) unsigned char g_header_init_##name = static_cast<unsigned char>(fn()); \
|
||||
|
@ -556,6 +556,9 @@ doing it with global function pointers and header initialization allows a runtim
|
|||
#error linker pragma must include g_header_init variation
|
||||
#endif
|
||||
|
||||
// Keep the misspelled name for backward compatibility.
|
||||
#define WI_HEADER_INITITALIZATION_FUNCTION(name, fn) WI_HEADER_INITIALIZATION_FUNCTION(name, fn)
|
||||
|
||||
/** All Windows Implementation Library classes and functions are located within the "wil" namespace.
|
||||
The 'wil' namespace is an intentionally short name as the intent is for code to be able to reference
|
||||
the namespace directly (example: `wil::srwlock lock;`) without a using statement. Resist adding a using
|
||||
|
@ -687,32 +690,32 @@ boolean, BOOLEAN, and classes with an explicit bool cast.
|
|||
@param val The logical bool expression
|
||||
@return A C++ bool representing the evaluation of `val`. */
|
||||
template <typename T, __R_ENABLE_IF_IS_CLASS(T)>
|
||||
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val)
|
||||
_Post_satisfies_(return == static_cast<bool>(val)) __forceinline constexpr bool verify_bool(const T& val) WI_NOEXCEPT
|
||||
{
|
||||
return static_cast<bool>(val);
|
||||
}
|
||||
|
||||
template <typename T, __R_ENABLE_IF_IS_NOT_CLASS(T)>
|
||||
__forceinline constexpr bool verify_bool(T /*val*/)
|
||||
__forceinline constexpr bool verify_bool(T /*val*/) WI_NOEXCEPT
|
||||
{
|
||||
static_assert(!wistd::is_same<T, T>::value, "Wrong Type: bool/BOOL/BOOLEAN/boolean expected");
|
||||
return false;
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val)
|
||||
_Post_satisfies_(return == val) __forceinline constexpr bool verify_bool<bool>(bool val) WI_NOEXCEPT
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val)
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<int>(int val) WI_NOEXCEPT
|
||||
{
|
||||
return (val != 0);
|
||||
}
|
||||
|
||||
template <>
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val)
|
||||
_Post_satisfies_(return == (val != 0)) __forceinline constexpr bool verify_bool<unsigned char>(unsigned char val) WI_NOEXCEPT
|
||||
{
|
||||
return (val != 0);
|
||||
}
|
||||
|
@ -723,7 +726,7 @@ accept any `int` value as long as that is the underlying typedef behind `BOOL`.
|
|||
@param val The Win32 BOOL returning expression
|
||||
@return A Win32 BOOL representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val)
|
||||
_Post_satisfies_(return == val) __forceinline constexpr int verify_BOOL(T val) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'int' as BOOL is actually: typedef int BOOL;
|
||||
static_assert((wistd::is_same<T, int>::value), "Wrong Type: BOOL expected");
|
||||
|
@ -752,7 +755,7 @@ RETURN_HR_IF(static_cast<HRESULT>(UIA_E_NOTSUPPORTED), (patternId != UIA_DragPat
|
|||
@param hr The HRESULT returning expression
|
||||
@return An HRESULT representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr)
|
||||
_Post_satisfies_(return == hr) inline constexpr long verify_hresult(T hr) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'long' as HRESULT is actually: typedef _Return_type_success_(return >= 0) long HRESULT
|
||||
static_assert(wistd::is_same<T, long>::value, "Wrong Type: HRESULT expected");
|
||||
|
@ -781,7 +784,7 @@ NT_RETURN_IF_FALSE(static_cast<NTSTATUS>(STATUS_NOT_SUPPORTED), (dispatch->Versi
|
|||
@param status The NTSTATUS returning expression
|
||||
@return An NTSTATUS representing the evaluation of `val`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == status) inline long verify_ntstatus(T status)
|
||||
_Post_satisfies_(return == status) inline long verify_ntstatus(T status) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Written in terms of 'long' as NTSTATUS is actually: typedef _Return_type_success_(return >= 0) long NTSTATUS
|
||||
static_assert(wistd::is_same<T, long>::value, "Wrong Type: NTSTATUS expected");
|
||||
|
@ -795,7 +798,7 @@ commonly used when manipulating Win32 error codes.
|
|||
@param error The Win32 error code returning expression
|
||||
@return An Win32 error code representing the evaluation of `error`. */
|
||||
template <typename T>
|
||||
_Post_satisfies_(return == error) inline T verify_win32(T error)
|
||||
_Post_satisfies_(return == error) inline T verify_win32(T error) WI_NOEXCEPT
|
||||
{
|
||||
// Note: Win32 error code are defined as 'long' (#define ERROR_SUCCESS 0L), but are more frequently used as DWORD (unsigned
|
||||
// long). This accept both types.
|
||||
|
@ -810,7 +813,7 @@ _Post_satisfies_(return == error) inline T verify_win32(T error)
|
|||
// Implementation details for macros and helper functions... do not use directly.
|
||||
namespace details
|
||||
{
|
||||
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
|
||||
// Use size-specific casts to avoid sign extending numbers -- avoid warning C4310: cast truncates constant value
|
||||
#define __WI_MAKE_UNSIGNED(val) \
|
||||
(__pragma(warning(push)) __pragma(warning(disable : 4310 4309))( \
|
||||
sizeof(val) == 1 ? static_cast<unsigned char>(val) \
|
||||
|
|
|
@ -191,7 +191,7 @@ struct com_task;
|
|||
/// @cond
|
||||
namespace wil::details::coro
|
||||
{
|
||||
// task and com_task are convertable to each other. However, not
|
||||
// task and com_task are convertible to each other. However, not
|
||||
// all consumers of this header have COM enabled. Support for saving
|
||||
// COM thread-local error information and restoring it on the resuming
|
||||
// thread is enabled using these function pointers. If COM is not
|
||||
|
@ -764,8 +764,8 @@ inline void __stdcall DestroyRestrictedErrorInformation(_In_ void* restricted_er
|
|||
|
||||
struct apartment_info
|
||||
{
|
||||
APTTYPE aptType;
|
||||
APTTYPEQUALIFIER aptTypeQualifier;
|
||||
APTTYPE aptType{};
|
||||
APTTYPEQUALIFIER aptTypeQualifier{};
|
||||
|
||||
void load()
|
||||
{
|
||||
|
@ -814,7 +814,7 @@ struct apartment_resumer
|
|||
|
||||
__WI_COROUTINE_NAMESPACE::coroutine_handle<> waiter;
|
||||
wil::com_ptr<IContextCallback> context{nullptr};
|
||||
apartment_info info;
|
||||
apartment_info info{};
|
||||
HRESULT resume_result = S_OK;
|
||||
|
||||
void capture_context(__WI_COROUTINE_NAMESPACE::coroutine_handle<> handle)
|
||||
|
@ -925,7 +925,7 @@ auto task_base<T>::resume_same_apartment() && noexcept
|
|||
|
||||
// This section is lit up when COM headers are available. Initialize the global function
|
||||
// pointers such that error information can be saved and restored across thread boundaries.
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(CoroutineRestrictedErrorInitialize, [] {
|
||||
::wil::details::coro::g_pfnCaptureRestrictedErrorInformation = ::wil::details::coro::CaptureRestrictedErrorInformation;
|
||||
::wil::details::coro::g_pfnRestoreRestrictedErrorInformation = ::wil::details::coro::RestoreRestrictedErrorInformation;
|
||||
::wil::details::coro::g_pfnDestroyRestrictedErrorInformation = ::wil::details::coro::DestroyRestrictedErrorInformation;
|
||||
|
|
|
@ -255,7 +255,7 @@ namespace details
|
|||
{
|
||||
#ifndef CPPWINRT_SUPPRESS_STATIC_INITIALIZERS
|
||||
WI_ODR_PRAGMA("CPPWINRT_SUPPRESS_STATIC_INITIALIZERS", "0")
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_CppWinRT, [] {
|
||||
::wil::WilInitialize_CppWinRT();
|
||||
return 1;
|
||||
});
|
||||
|
|
|
@ -476,7 +476,7 @@ next_entry_offset_iterator<T> create_next_entry_offset_iterator(T* p)
|
|||
|
||||
enum class FolderChangeEvent : DWORD
|
||||
{
|
||||
ChangesLost = 0, // requies special handling, reset state as events were lost
|
||||
ChangesLost = 0, // requires special handling, reset state as events were lost
|
||||
Added = FILE_ACTION_ADDED,
|
||||
Removed = FILE_ACTION_REMOVED,
|
||||
Modified = FILE_ACTION_MODIFIED,
|
||||
|
@ -1122,9 +1122,9 @@ struct file_and_error_result
|
|||
DWORD last_error{};
|
||||
};
|
||||
|
||||
/** Non-throwing open existing using OPEN_EXISTING.
|
||||
/** Non-throwing open existing using OPEN_EXISTING, returns handle and error code.
|
||||
~~~
|
||||
auto handle = wil::try_open_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_file(
|
||||
|
@ -1150,7 +1150,7 @@ inline wil::unique_hfile open_file(
|
|||
DWORD dwDesiredAccess = GENERIC_READ,
|
||||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
bool inheritHandle = false) noexcept
|
||||
bool inheritHandle = false)
|
||||
{
|
||||
auto result = try_open_file(path, dwDesiredAccess, dwShareMode, dwFlagsAndAttributes, inheritHandle);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
|
@ -1173,7 +1173,7 @@ namespace details
|
|||
|
||||
/** create using CREATE_NEW, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_create_new_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_create_new_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_create_new_file(
|
||||
|
@ -1189,7 +1189,7 @@ inline file_and_error_result try_create_new_file(
|
|||
|
||||
/** create using OPEN_ALWAYS, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_open_or_create_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_or_create_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_or_create_file(
|
||||
|
@ -1205,7 +1205,7 @@ inline file_and_error_result try_open_or_create_file(
|
|||
|
||||
/** create using CREATE_ALWAYS, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_open_or_truncate_existing_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_open_or_truncate_existing_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_open_or_truncate_existing_file(
|
||||
|
@ -1221,7 +1221,7 @@ inline file_and_error_result try_open_or_truncate_existing_file(
|
|||
|
||||
/** create using TRUNCATE_EXISTING, returns handle and error code.
|
||||
~~~
|
||||
auto [handle, error = wil::try_truncate_existing_file(filePath.c_str());
|
||||
auto [handle, error] = wil::try_truncate_existing_file(filePath.c_str());
|
||||
~~~
|
||||
*/
|
||||
inline file_and_error_result try_truncate_existing_file(
|
||||
|
@ -1247,7 +1247,7 @@ inline wil::unique_hfile create_new_file(
|
|||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_create_new_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
|
@ -1265,7 +1265,7 @@ inline wil::unique_hfile open_or_create_file(
|
|||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_open_or_create_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
THROW_WIN32_IF(result.last_error, !result.file.is_valid());
|
||||
|
@ -1283,7 +1283,7 @@ inline wil::unique_hfile open_or_truncate_existing_file(
|
|||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result = try_open_or_truncate_existing_file(
|
||||
path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
|
@ -1302,7 +1302,7 @@ inline wil::unique_hfile truncate_existing_file(
|
|||
DWORD dwShareMode = FILE_SHARE_READ,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes = nullptr,
|
||||
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL,
|
||||
HANDLE hTemplateFile = nullptr) noexcept
|
||||
HANDLE hTemplateFile = nullptr)
|
||||
{
|
||||
auto result =
|
||||
try_truncate_existing_file(path, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwFlagsAndAttributes, hTemplateFile);
|
||||
|
|
|
@ -27,9 +27,9 @@
|
|||
// stdint.h and intsafe.h have conflicting definitions, so it's not safe to include either to pick up our dependencies,
|
||||
// so the definitions we need are copied below
|
||||
#ifdef _WIN64
|
||||
#define __WI_SIZE_MAX 0xffffffffffffffffui64 // UINT64_MAX
|
||||
#define __WI_SIZE_MAX 0xffffffffffffffffULL // UINT64_MAX
|
||||
#else /* _WIN64 */
|
||||
#define __WI_SIZE_MAX 0xffffffffui32 // UINT32_MAX
|
||||
#define __WI_SIZE_MAX 0xffffffffUL // UINT32_MAX
|
||||
#endif /* _WIN64 */
|
||||
/// @endcond
|
||||
|
||||
|
@ -721,7 +721,7 @@ class com_ptr_t; // forward
|
|||
namespace details
|
||||
{
|
||||
// The first two attach_to_smart_pointer() overloads are ambiguous when passed a com_ptr_t.
|
||||
// To solve that use this functions return type to elminate the reset form for com_ptr_t.
|
||||
// To solve that use this functions return type to eliminate the reset form for com_ptr_t.
|
||||
template <typename T, typename err>
|
||||
wistd::false_type use_reset(wil::com_ptr_t<T, err>*)
|
||||
{
|
||||
|
@ -1025,7 +1025,7 @@ struct empty_deleter
|
|||
};
|
||||
|
||||
/** unique_any_array_ptr is a RAII type for managing conformant arrays that need to be freed and have elements that may need to be
|
||||
freed. The intented use for this RAII type would be to capture out params from API like IPropertyValue::GetStringArray. This class
|
||||
freed. The intended use for this RAII type would be to capture out params from API like IPropertyValue::GetStringArray. This class
|
||||
also maintains the size of the array, so it can iterate over the members and deallocate them before it deallocates the base array
|
||||
pointer.
|
||||
|
||||
|
@ -2892,6 +2892,7 @@ typedef unique_any_t<event_t<details::unique_storage<details::handle_resource_po
|
|||
typedef unique_any_t<event_t<details::unique_storage<details::handle_resource_policy>, err_exception_policy>> unique_event;
|
||||
#endif
|
||||
|
||||
#ifndef WIL_NO_SLIM_EVENT
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \
|
||||
((_WIN32_WINNT >= _WIN32_WINNT_WIN8) || (__WIL_RESOURCE_ENABLE_QUIRKS && (_WIN32_WINNT >= _WIN32_WINNT_WIN7)))
|
||||
enum class SlimEventType
|
||||
|
@ -2973,13 +2974,13 @@ public:
|
|||
return !!ReadAcquire(&m_isSignaled);
|
||||
}
|
||||
|
||||
bool wait(DWORD timeoutMiliseconds) WI_NOEXCEPT
|
||||
bool wait(DWORD timeoutMilliseconds) WI_NOEXCEPT
|
||||
{
|
||||
if (timeoutMiliseconds == 0)
|
||||
if (timeoutMilliseconds == 0)
|
||||
{
|
||||
return TryAcquireEvent();
|
||||
}
|
||||
else if (timeoutMiliseconds == INFINITE)
|
||||
else if (timeoutMilliseconds == INFINITE)
|
||||
{
|
||||
return wait();
|
||||
}
|
||||
|
@ -2991,12 +2992,12 @@ public:
|
|||
|
||||
while (!TryAcquireEvent())
|
||||
{
|
||||
if (elapsedTimeMilliseconds >= timeoutMiliseconds)
|
||||
if (elapsedTimeMilliseconds >= timeoutMilliseconds)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD newTimeout = static_cast<DWORD>(timeoutMiliseconds - elapsedTimeMilliseconds);
|
||||
DWORD newTimeout = static_cast<DWORD>(timeoutMilliseconds - elapsedTimeMilliseconds);
|
||||
|
||||
if (!WaitForSignal(newTimeout))
|
||||
{
|
||||
|
@ -3039,10 +3040,10 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
bool WaitForSignal(DWORD timeoutMiliseconds) WI_NOEXCEPT
|
||||
bool WaitForSignal(DWORD timeoutMilliseconds) WI_NOEXCEPT
|
||||
{
|
||||
LONG falseValue = FALSE;
|
||||
BOOL waitResult = WaitOnAddress(&m_isSignaled, &falseValue, sizeof(m_isSignaled), timeoutMiliseconds);
|
||||
BOOL waitResult = WaitOnAddress(&m_isSignaled, &falseValue, sizeof(m_isSignaled), timeoutMilliseconds);
|
||||
__FAIL_FAST_ASSERT__(waitResult || ::GetLastError() == ERROR_TIMEOUT);
|
||||
return !!waitResult;
|
||||
}
|
||||
|
@ -3060,6 +3061,7 @@ using slim_event_manual_reset = slim_event_t<SlimEventType::ManualReset>;
|
|||
using slim_event = slim_event_auto_reset;
|
||||
|
||||
#endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
|
||||
#endif // WIL_NO_SLIM_EVENT
|
||||
|
||||
typedef unique_any<HANDLE, decltype(&details::ReleaseMutex), details::ReleaseMutex, details::pointer_access_none> mutex_release_scope_exit;
|
||||
|
||||
|
@ -4731,7 +4733,7 @@ inline unique_hstring make_unique_string_nothrow<unique_hstring>(
|
|||
_When_((source != nullptr) && length == static_cast<size_t>(-1), _In_z_) PCWSTR source,
|
||||
size_t length) WI_NOEXCEPT
|
||||
{
|
||||
WI_ASSERT(source != nullptr); // the HSTRING version of this function does not suport this case
|
||||
WI_ASSERT(source != nullptr); // the HSTRING version of this function does not support this case
|
||||
if (length == static_cast<size_t>(-1))
|
||||
{
|
||||
length = wcslen(source);
|
||||
|
@ -5218,7 +5220,7 @@ struct cert_context_t
|
|||
}
|
||||
|
||||
/** A wrapper around CertEnumCertificatesInStore.
|
||||
CertEnumCertificatesInStore takes ownership of its second paramter in an unclear fashion,
|
||||
CertEnumCertificatesInStore takes ownership of its second parameter in an unclear fashion,
|
||||
making it error-prone to use in combination with unique_cert_context. This wrapper helps
|
||||
manage the resource correctly while ensuring the GetLastError state set by CertEnumCertificatesInStore.
|
||||
is not lost. See MSDN for more information on `CertEnumCertificatesInStore`.
|
||||
|
@ -6264,7 +6266,7 @@ using wdf_wait_lock_release_scope_exit =
|
|||
using unique_wdf_device_init = unique_any<WDFDEVICE_INIT*, decltype(&::WdfDeviceInitFree), ::WdfDeviceInitFree>;
|
||||
#endif
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(PASSIVE_LEVEL)
|
||||
_Acquires_lock_(lock)
|
||||
wdf_wait_lock_release_scope_exit acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEXCEPT
|
||||
{
|
||||
|
@ -6272,7 +6274,7 @@ wdf_wait_lock_release_scope_exit acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEX
|
|||
return wdf_wait_lock_release_scope_exit(lock);
|
||||
}
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(APC_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(APC_LEVEL)
|
||||
_When_(return, _Acquires_lock_(lock))
|
||||
wdf_wait_lock_release_scope_exit try_acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_NOEXCEPT
|
||||
{
|
||||
|
@ -6291,7 +6293,7 @@ wdf_wait_lock_release_scope_exit try_acquire_wdf_wait_lock(WDFWAITLOCK lock) WI_
|
|||
using wdf_spin_lock_release_scope_exit =
|
||||
unique_any<WDFSPINLOCK, decltype(&::WdfSpinLockRelease), ::WdfSpinLockRelease, details::pointer_access_none>;
|
||||
|
||||
inline WI_NODISCARD _IRQL_requires_max_(DISPATCH_LEVEL)
|
||||
WI_NODISCARD inline _IRQL_requires_max_(DISPATCH_LEVEL)
|
||||
_IRQL_raises_(DISPATCH_LEVEL)
|
||||
_Acquires_lock_(lock)
|
||||
wdf_spin_lock_release_scope_exit acquire_wdf_spin_lock(WDFSPINLOCK lock) WI_NOEXCEPT
|
||||
|
@ -6507,7 +6509,7 @@ private:
|
|||
// function only if the call-site source location is obtained from elsewhere (i.e., plumbed
|
||||
// through other abstractions).
|
||||
template <typename wdf_object_t>
|
||||
inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
WI_NODISCARD inline unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
wdf_object_t wdfObject, PVOID tag, LONG lineNumber, PCSTR fileName) WI_NOEXCEPT
|
||||
{
|
||||
// Parameter is incorrectly marked as non-const, so the const-cast is required.
|
||||
|
@ -6516,7 +6518,7 @@ inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_referen
|
|||
}
|
||||
|
||||
template <typename wdf_object_t>
|
||||
inline WI_NODISCARD unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
WI_NODISCARD inline unique_wdf_object_reference<wdf_object_t> wdf_object_reference_increment(
|
||||
const wil::unique_wdf_any<wdf_object_t>& wdfObject, PVOID tag, LONG lineNumber, PCSTR fileName) WI_NOEXCEPT
|
||||
{
|
||||
return wdf_object_reference_increment(wdfObject.get(), tag, lineNumber, fileName);
|
||||
|
@ -7451,7 +7453,7 @@ namespace details
|
|||
{
|
||||
// Only those lock types specialized by lock_proof_traits will allow either a write_lock_required or
|
||||
// read_lock_required to be constructed. The allows_exclusive value indicates if the type represents an exclusive,
|
||||
// write-safe lock aquisition, or a shared, read-only lock acquisition.
|
||||
// write-safe lock acquisition, or a shared, read-only lock acquisition.
|
||||
template <typename T>
|
||||
struct lock_proof_traits
|
||||
{
|
||||
|
@ -7480,7 +7482,7 @@ another function that requires them.
|
|||
These types are implicitly convertible from various lock holding types, enabling callers to provide them as
|
||||
proof of the lock that they hold.
|
||||
|
||||
The following example is intentially contrived to demonstrate multiple use cases:
|
||||
The following example is intentionally contrived to demonstrate multiple use cases:
|
||||
- Methods that require only shared/read access
|
||||
- Methods that require only exclusive write access
|
||||
- Methods that pass their proof-of-lock to a helper
|
||||
|
|
|
@ -435,7 +435,7 @@ namespace details_abi
|
|||
private:
|
||||
struct Node
|
||||
{
|
||||
DWORD threadId = ULONG_MAX;
|
||||
DWORD threadId = 0xffffffff; // MAXDWORD
|
||||
Node* pNext = nullptr;
|
||||
T value{};
|
||||
};
|
||||
|
@ -1169,7 +1169,7 @@ namespace details
|
|||
__declspec(selectany)::wil::details_abi::ProcessLocalStorage<::wil::details_abi::ProcessLocalData> g_processLocalData("WilError_03");
|
||||
__declspec(selectany)::wil::details_abi::ThreadLocalStorage<ThreadFailureCallbackHolder*> g_threadFailureCallbacks;
|
||||
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeResultHeader, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeResultHeader, [] {
|
||||
g_pfnGetContextAndNotifyFailure = GetContextAndNotifyFailure;
|
||||
::wil::details_abi::g_pProcessLocalData = &g_processLocalData;
|
||||
g_pThreadFailureCallbacks = &g_threadFailureCallbacks;
|
||||
|
|
|
@ -93,7 +93,7 @@ typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
|
|||
#endif
|
||||
#ifndef __NTSTATUS_FROM_WIN32
|
||||
#define __NTSTATUS_FROM_WIN32(x) \
|
||||
((NTSTATUS)(x) <= 0 ? ((NTSTATUS)(x)) : ((NTSTATUS)(((x)&0x0000FFFF) | (FACILITY_WIN32 << 16) | ERROR_SEVERITY_ERROR)))
|
||||
((NTSTATUS)(x) <= 0 ? ((NTSTATUS)(x)) : ((NTSTATUS)(((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | ERROR_SEVERITY_ERROR)))
|
||||
#endif
|
||||
|
||||
#ifndef WIL_AllocateMemory
|
||||
|
@ -757,6 +757,14 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
|||
return __hr; \
|
||||
} \
|
||||
__WI_SUPPRESS_4127_E while ((void)0, 0)
|
||||
#define __RETURN_HR_FAIL_SUPPRESS_TELEMETRY(hr, str) \
|
||||
__WI_SUPPRESS_4127_S do \
|
||||
{ \
|
||||
const HRESULT __hr = (hr); \
|
||||
__R_FN(Return_HrSuppressTelemetry)(__R_INFO(str) __hr); \
|
||||
return __hr; \
|
||||
} \
|
||||
__WI_SUPPRESS_4127_E while ((void)0, 0)
|
||||
#define __RETURN_HR_FAIL_NOFILE(hr, str) \
|
||||
__WI_SUPPRESS_4127_S do \
|
||||
{ \
|
||||
|
@ -1097,6 +1105,21 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
|||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
// Always logs failed HR, if expected, telemetry will be called with 'alreadyReported'
|
||||
#define RETURN_IF_FAILED_SUPPRESS_TELEMETRY_IF_EXPECTED(hr, hrExpected, ...) \
|
||||
do \
|
||||
{ \
|
||||
const auto __hrRet = wil::verify_hresult(hr); \
|
||||
if (FAILED(__hrRet)) \
|
||||
{ \
|
||||
if ((__hrRet == wil::verify_hresult(hrExpected)) WI_FOREACH(__WI_OR_IS_EXPECTED_HRESULT, ##__VA_ARGS__)) \
|
||||
{ \
|
||||
__RETURN_HR_FAIL_SUPPRESS_TELEMETRY(__hrRet, #hr); \
|
||||
} \
|
||||
__RETURN_HR_FAIL(__hrRet, #hr); \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
//*****************************************************************************
|
||||
// Macros for logging failures (ignore or pass-through)
|
||||
//*****************************************************************************
|
||||
|
@ -1267,7 +1290,7 @@ WI_ODR_PRAGMA("WIL_FreeMemory", "0")
|
|||
if (!wil::verify_bool(condition)) \
|
||||
{ \
|
||||
WI_ASSERT_FAIL(#condition); \
|
||||
__RFF_FN(FailFast_Unexpected)(__RFF_INFO_ONLY(#condition)) \
|
||||
__RFF_FN(FailFast_Unexpected)(__RFF_INFO_ONLY(#condition)); \
|
||||
} \
|
||||
} while (0, 0)
|
||||
#define WI_FAIL_FAST_ASSERT_MSG(condition, msg) \
|
||||
|
@ -1738,7 +1761,7 @@ inline HRESULT GetFailureLogString(
|
|||
_Pre_satisfies_(cchDest > 0) _In_ size_t cchDest,
|
||||
_In_ FailureInfo const& failure) WI_NOEXCEPT
|
||||
{
|
||||
// This function was lenient to empty strings at one point and some callers became dependent on this beahvior
|
||||
// This function was lenient to empty strings at one point and some callers became dependent on this behavior
|
||||
if ((cchDest == 0) || (pszDest == nullptr))
|
||||
{
|
||||
return S_OK;
|
||||
|
@ -2155,6 +2178,7 @@ namespace details
|
|||
_Pre_satisfies_(debugStringSizeChars > 0) size_t debugStringSizeChars,
|
||||
_Out_writes_(callContextStringSizeChars) _Post_z_ PSTR callContextString,
|
||||
_Pre_satisfies_(callContextStringSizeChars > 0) size_t callContextStringSizeChars,
|
||||
FailureFlags flags,
|
||||
_Out_ FailureInfo* failure) WI_NOEXCEPT;
|
||||
|
||||
__declspec(noinline) inline void ReportFailure(
|
||||
|
@ -2168,12 +2192,13 @@ namespace details
|
|||
__R_FN_PARAMS_FULL,
|
||||
const ResultStatus& resultPair,
|
||||
_In_opt_ PCWSTR message = nullptr,
|
||||
ReportFailureOptions options = ReportFailureOptions::None);
|
||||
ReportFailureOptions options = ReportFailureOptions::None,
|
||||
FailureFlags flags = FailureFlags::None);
|
||||
template <FailureType>
|
||||
inline void ReportFailure_ReplaceMsg(__R_FN_PARAMS_FULL, HRESULT hr, _Printf_format_string_ PCSTR formatString, ...);
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, FailureType type, HRESULT hr);
|
||||
template <FailureType>
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr);
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags flags = FailureFlags::None);
|
||||
template <FailureType>
|
||||
__declspec(noinline) inline HRESULT
|
||||
ReportFailure_CaughtException(__R_FN_PARAMS_FULL, SupportedExceptions supported = SupportedExceptions::Default);
|
||||
|
@ -2745,7 +2770,7 @@ namespace details
|
|||
{
|
||||
status =
|
||||
((NTSTATUS)(hr) <= 0 ? ((NTSTATUS)(hr))
|
||||
: ((NTSTATUS)(((hr)&0x0000FFFF) | (FACILITY_SSPI << 16) | ERROR_SEVERITY_ERROR)));
|
||||
: ((NTSTATUS)(((hr) & 0x0000FFFF) | (FACILITY_SSPI << 16) | ERROR_SEVERITY_ERROR)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2826,8 +2851,8 @@ namespace details
|
|||
// NOTE: The following two functions are unfortunate copies of strsafe.h functions that have been copied to reduce the friction associated with using
|
||||
// Result.h and ResultException.h in a build that does not have WINAPI_PARTITION_DESKTOP defined (where these are conditionally enabled).
|
||||
|
||||
static STRSAFEAPI WilStringLengthWorkerA(
|
||||
_In_reads_or_z_(cchMax) STRSAFE_PCNZCH psz,
|
||||
inline HRESULT WilStringLengthWorkerA(
|
||||
_In_reads_or_z_(cchMax) PCNZCH psz,
|
||||
_In_ _In_range_(<=, STRSAFE_MAX_CCH) size_t cchMax,
|
||||
_Out_opt_ _Deref_out_range_(<, cchMax) _Deref_out_range_(<=, _String_length_(psz)) size_t* pcchLength)
|
||||
{
|
||||
|
@ -2858,8 +2883,8 @@ namespace details
|
|||
}
|
||||
|
||||
_Must_inspect_result_
|
||||
STRSAFEAPI StringCchLengthA(
|
||||
_In_reads_or_z_(cchMax) STRSAFE_PCNZCH psz,
|
||||
inline HRESULT StringCchLengthA(
|
||||
_In_reads_or_z_(cchMax) PCNZCH psz,
|
||||
_In_ _In_range_(1, STRSAFE_MAX_CCH) size_t cchMax,
|
||||
_Out_opt_ _Deref_out_range_(<, cchMax) _Deref_out_range_(<=, _String_length_(psz)) size_t* pcchLength)
|
||||
{
|
||||
|
@ -2880,8 +2905,8 @@ namespace details
|
|||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
_Post_satisfies_(cchDest > 0 && cchDest <= cchMax) static STRSAFEAPI
|
||||
WilStringValidateDestA(_In_reads_opt_(cchDest) STRSAFE_PCNZCH /*pszDest*/, _In_ size_t cchDest, _In_ const size_t cchMax)
|
||||
_Post_satisfies_(cchDest > 0 && cchDest <= cchMax) inline HRESULT
|
||||
WilStringValidateDestA(_In_reads_opt_(cchDest) PCNZCH /*pszDest*/, _In_ size_t cchDest, _In_ const size_t cchMax)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
if ((cchDest == 0) || (cchDest > cchMax))
|
||||
|
@ -2891,7 +2916,7 @@ namespace details
|
|||
return hr;
|
||||
}
|
||||
|
||||
static STRSAFEAPI WilStringVPrintfWorkerA(
|
||||
inline HRESULT WilStringVPrintfWorkerA(
|
||||
_Out_writes_(cchDest) _Always_(_Post_z_) STRSAFE_LPSTR pszDest,
|
||||
_In_ _In_range_(1, STRSAFE_MAX_CCH) size_t cchDest,
|
||||
_Always_(_Out_opt_ _Deref_out_range_(<=, cchDest - 1)) size_t* pcchNewDestLength,
|
||||
|
@ -2948,7 +2973,7 @@ namespace details
|
|||
return hr;
|
||||
}
|
||||
|
||||
__inline HRESULT StringCchPrintfA(
|
||||
inline HRESULT StringCchPrintfA(
|
||||
_Out_writes_(cchDest) _Always_(_Post_z_) STRSAFE_LPSTR pszDest,
|
||||
_In_ size_t cchDest,
|
||||
_In_ _Printf_format_string_ STRSAFE_LPCSTR pszFormat,
|
||||
|
@ -3080,7 +3105,7 @@ namespace details
|
|||
{
|
||||
#ifndef RESULT_SUPPRESS_STATIC_INITIALIZERS
|
||||
#if !defined(BUILD_WINDOWS) || defined(WIL_SUPPRESS_PRIVATE_API_USE)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse, [] {
|
||||
::wil::WilInitialize_ResultMacros_DesktopOrSystem_SuppressPrivateApiUse();
|
||||
return 1;
|
||||
});
|
||||
|
@ -3091,7 +3116,7 @@ namespace details
|
|||
#else // !WINAPI_PARTITION_DESKTOP, !WINAPI_PARTITION_SYSTEM, explicitly assume these modules can direct link
|
||||
namespace details
|
||||
{
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(WilInitialize_ResultMacros_AppOnly, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(WilInitialize_ResultMacros_AppOnly, [] {
|
||||
g_pfnRaiseFailFastException = ::RaiseFailFastException;
|
||||
return 1;
|
||||
});
|
||||
|
@ -3869,7 +3894,7 @@ namespace details
|
|||
}
|
||||
|
||||
#if !defined(RESULT_SUPPRESS_STATIC_INITIALIZERS)
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeWinRt, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeWinRt, [] {
|
||||
g_pfnResultFromCaughtException_WinRt = ResultFromCaughtException_WinRt;
|
||||
g_pfnResultFromKnownExceptions_WinRt = ResultFromKnownExceptions_WinRt;
|
||||
g_pfnThrowPlatformException = ThrowPlatformException;
|
||||
|
@ -4124,7 +4149,7 @@ namespace details
|
|||
}
|
||||
}
|
||||
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(InitializeResultExceptions, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(InitializeResultExceptions, [] {
|
||||
g_pfnRunFunctorWithExceptionFilter = RunFunctorWithExceptionFilter;
|
||||
g_pfnRethrow = Rethrow;
|
||||
g_pfnThrowResultException = ThrowResultExceptionInternal;
|
||||
|
@ -4320,6 +4345,7 @@ namespace details
|
|||
_Pre_satisfies_(debugStringSizeChars > 0) size_t debugStringSizeChars,
|
||||
_Out_writes_(callContextStringSizeChars) _Post_z_ PSTR callContextString,
|
||||
_Pre_satisfies_(callContextStringSizeChars > 0) size_t callContextStringSizeChars,
|
||||
FailureFlags flags,
|
||||
_Out_ FailureInfo* failure) WI_NOEXCEPT
|
||||
{
|
||||
debugString[0] = L'\0';
|
||||
|
@ -4360,7 +4386,7 @@ namespace details
|
|||
};
|
||||
|
||||
failure->type = type;
|
||||
failure->flags = FailureFlags::None;
|
||||
failure->flags = flags;
|
||||
WI_SetFlagIf(failure->flags, FailureFlags::NtStatus, resultPair.kind == ResultStatus::Kind::NtStatus);
|
||||
failure->failureId = ::InterlockedIncrementNoFence(&s_failureId);
|
||||
failure->pszMessage = ((message != nullptr) && (message[0] != L'\0')) ? message : nullptr;
|
||||
|
@ -4501,7 +4527,8 @@ namespace details
|
|||
}
|
||||
|
||||
template <FailureType T>
|
||||
inline __declspec(noinline) void ReportFailure_Return(__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
inline __declspec(noinline) void ReportFailure_Return(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags flags)
|
||||
{
|
||||
bool needPlatformException =
|
||||
((T == FailureType::Exception) && WI_IsFlagClear(options, ReportFailureOptions::MayRethrow) &&
|
||||
|
@ -4522,6 +4549,7 @@ namespace details
|
|||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
flags,
|
||||
&failure);
|
||||
|
||||
if (WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
|
@ -4531,9 +4559,10 @@ namespace details
|
|||
}
|
||||
|
||||
template <FailureType T, bool SuppressAction>
|
||||
inline __declspec(noinline) void ReportFailure_Base(__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
inline __declspec(noinline) void ReportFailure_Base(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags flags)
|
||||
{
|
||||
ReportFailure_Return<T>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
ReportFailure_Return<T>(__R_FN_CALL_FULL, resultPair, message, options, flags);
|
||||
}
|
||||
|
||||
template <FailureType T>
|
||||
|
@ -4559,6 +4588,7 @@ namespace details
|
|||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
FailureFlags::None,
|
||||
&failure);
|
||||
__WI_SUPPRESS_4127_S
|
||||
if ((T == FailureType::FailFast) || WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
|
@ -4587,14 +4617,14 @@ namespace details
|
|||
|
||||
template <>
|
||||
inline __declspec(noinline) RESULT_NORETURN void ReportFailure_Base<FailureType::FailFast, false>(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags)
|
||||
{
|
||||
ReportFailure_NoReturn<FailureType::FailFast>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline __declspec(noinline) RESULT_NORETURN void ReportFailure_Base<FailureType::Exception, false>(
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options)
|
||||
__R_FN_PARAMS_FULL, const ResultStatus& resultPair, PCWSTR message, ReportFailureOptions options, FailureFlags)
|
||||
{
|
||||
ReportFailure_NoReturn<FailureType::Exception>(__R_FN_CALL_FULL, resultPair, message, options);
|
||||
}
|
||||
|
@ -4764,19 +4794,22 @@ namespace details
|
|||
}
|
||||
|
||||
template <FailureType T>
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline void ReportFailure_Hr(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags flags)
|
||||
{
|
||||
ReportFailure_Base<T>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
ReportFailure_Base<T>(
|
||||
__R_FN_CALL_FULL, ResultStatus::FromResult(hr), nullptr /*message*/, ReportFailureOptions::None /*options*/, flags);
|
||||
}
|
||||
|
||||
template <>
|
||||
__declspec(noinline) inline RESULT_NORETURN void ReportFailure_Hr<FailureType::FailFast>(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline RESULT_NORETURN
|
||||
void ReportFailure_Hr<FailureType::FailFast>(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags)
|
||||
{
|
||||
ReportFailure_Base<FailureType::FailFast>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
}
|
||||
|
||||
template <>
|
||||
__declspec(noinline) inline RESULT_NORETURN void ReportFailure_Hr<FailureType::Exception>(__R_FN_PARAMS_FULL, HRESULT hr)
|
||||
__declspec(noinline) inline RESULT_NORETURN
|
||||
void ReportFailure_Hr<FailureType::Exception>(__R_FN_PARAMS_FULL, HRESULT hr, FailureFlags)
|
||||
{
|
||||
ReportFailure_Base<FailureType::Exception>(__R_FN_CALL_FULL, ResultStatus::FromResult(hr));
|
||||
}
|
||||
|
@ -5182,6 +5215,7 @@ namespace details
|
|||
ARRAYSIZE(debugString),
|
||||
callContextString,
|
||||
ARRAYSIZE(callContextString),
|
||||
FailureFlags::None,
|
||||
&failure);
|
||||
|
||||
if (WI_IsFlagSet(failure.flags, FailureFlags::RequestFailFast))
|
||||
|
@ -5228,6 +5262,13 @@ namespace details
|
|||
wil::details::ReportFailure_Hr<FailureType::Return>(__R_DIRECT_FN_CALL hr);
|
||||
}
|
||||
|
||||
__R_DIRECT_METHOD(void, Return_HrSuppressTelemetry)(__R_DIRECT_FN_PARAMS HRESULT hr) WI_NOEXCEPT
|
||||
{
|
||||
__R_FN_LOCALS;
|
||||
const FailureFlags flags = FailureFlags::RequestSuppressTelemetry;
|
||||
wil::details::ReportFailure_Hr<FailureType::Return>(__R_DIRECT_FN_CALL hr, flags);
|
||||
}
|
||||
|
||||
_Success_(true)
|
||||
_Translates_Win32_to_HRESULT_(err)
|
||||
__R_DIRECT_METHOD(HRESULT, Return_Win32)(__R_DIRECT_FN_PARAMS DWORD err) WI_NOEXCEPT
|
||||
|
|
|
@ -122,7 +122,7 @@ namespace details
|
|||
} // namespace wil
|
||||
|
||||
// Automatically call RoOriginateError upon error origination by including this file
|
||||
WI_HEADER_INITITALIZATION_FUNCTION(ResultStowedExceptionInitialize, [] {
|
||||
WI_HEADER_INITIALIZATION_FUNCTION(ResultStowedExceptionInitialize, [] {
|
||||
::wil::SetOriginateErrorCallback(::wil::details::RaiseRoOriginateOnWilExceptions);
|
||||
::wil::SetFailfastWithContextCallback(::wil::details::FailfastWithContextCallback);
|
||||
return 1;
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace details
|
|||
wistd::is_same<T, int>::value || wistd::is_same<T, unsigned int>::value || wistd::is_same<T, long>::value ||
|
||||
wistd::is_same<T, unsigned long>::value || wistd::is_same<T, __int64>::value || wistd::is_same<T, unsigned __int64>::value;
|
||||
|
||||
// True when either type is potentialy variably sized (e.g. size_t, ptrdiff_t)
|
||||
// True when either type is potentially variably sized (e.g. size_t, ptrdiff_t)
|
||||
template <typename OldT, typename NewT>
|
||||
constexpr bool is_potentially_variably_sized_cast_v =
|
||||
is_potentially_variably_sized_type_v<OldT> || is_potentially_variably_sized_type_v<NewT>;
|
||||
|
|
|
@ -24,10 +24,9 @@ namespace details
|
|||
{
|
||||
};
|
||||
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindowsNoThrow(TEnumApi&& enumApi, TCallback&& callback) noexcept
|
||||
template <typename TCallback>
|
||||
BOOL __stdcall EnumWindowsCallbackNoThrow(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
auto enumproc = [](HWND hwnd, LPARAM lParam) -> BOOL {
|
||||
auto pCallback = reinterpret_cast<TCallback*>(lParam);
|
||||
#ifdef __cpp_if_constexpr
|
||||
using result_t = decltype((*pCallback)(hwnd));
|
||||
|
@ -52,21 +51,26 @@ namespace details
|
|||
#else
|
||||
return (*pCallback)(hwnd);
|
||||
#endif
|
||||
};
|
||||
enumApi(enumproc, reinterpret_cast<LPARAM>(&callback));
|
||||
}
|
||||
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindowsNoThrow(TEnumApi&& enumApi, TCallback&& callback) noexcept
|
||||
{
|
||||
enumApi(EnumWindowsCallbackNoThrow<TCallback>, reinterpret_cast<LPARAM>(&callback));
|
||||
}
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindows(TEnumApi&& enumApi, TCallback&& callback)
|
||||
{
|
||||
struct
|
||||
template <typename TCallback>
|
||||
struct EnumWindowsCallbackData
|
||||
{
|
||||
std::exception_ptr exception;
|
||||
TCallback* pCallback;
|
||||
} callbackData = {nullptr, &callback};
|
||||
auto enumproc = [](HWND hwnd, LPARAM lParam) -> BOOL {
|
||||
auto pCallbackData = reinterpret_cast<decltype(&callbackData)>(lParam);
|
||||
};
|
||||
|
||||
template <typename TCallback>
|
||||
BOOL __stdcall EnumWindowsCallback(HWND hwnd, LPARAM lParam)
|
||||
{
|
||||
auto pCallbackData = reinterpret_cast<EnumWindowsCallbackData<TCallback>*>(lParam);
|
||||
try
|
||||
{
|
||||
auto pCallback = pCallbackData->pCallback;
|
||||
|
@ -100,7 +104,12 @@ namespace details
|
|||
return FALSE;
|
||||
}
|
||||
};
|
||||
enumApi(enumproc, reinterpret_cast<LPARAM>(&callbackData));
|
||||
|
||||
template <typename TEnumApi, typename TCallback>
|
||||
void DoEnumWindows(TEnumApi&& enumApi, TCallback&& callback)
|
||||
{
|
||||
EnumWindowsCallbackData<TCallback> callbackData = {nullptr, &callback};
|
||||
enumApi(EnumWindowsCallback<TCallback>, reinterpret_cast<LPARAM>(&callbackData));
|
||||
if (callbackData.exception)
|
||||
{
|
||||
std::rethrow_exception(callbackData.exception);
|
||||
|
|
|
@ -271,7 +271,7 @@ struct TwoPhaseHStringConstructor
|
|||
return TwoPhaseHStringConstructor{characterLength};
|
||||
}
|
||||
|
||||
//! Returns the HSTRING after it has been populated like Detatch() or release(); be sure to put this in a RAII type to manage
|
||||
//! Returns the HSTRING after it has been populated like Detach() or release(); be sure to put this in a RAII type to manage
|
||||
//! its lifetime.
|
||||
HSTRING Promote()
|
||||
{
|
||||
|
@ -1700,8 +1700,8 @@ hr = run_when_complete_nothrow<StorageFile*>(getFileOp.Get(), [](HRESULT hr, ISt
|
|||
~~~
|
||||
*/
|
||||
|
||||
//! Run a fuction when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler agile
|
||||
//! and run on the async thread.
|
||||
//! Run a function when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler
|
||||
//! agile and run on the async thread.
|
||||
template <typename TAgility = IUnknown, typename TFunc>
|
||||
HRESULT run_when_complete_nothrow(_In_ ABI::Windows::Foundation::IAsyncAction* operation, TFunc&& func) WI_NOEXCEPT
|
||||
{
|
||||
|
@ -1727,8 +1727,8 @@ HRESULT run_when_complete_nothrow(_In_ ABI::Windows::Foundation::IAsyncActionWit
|
|||
}
|
||||
|
||||
#ifdef WIL_ENABLE_EXCEPTIONS
|
||||
//! Run a fuction when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler agile
|
||||
//! and run on the async thread.
|
||||
//! Run a function when an async operation completes. Use Microsoft::WRL::FtmBase for TAgility to make the completion handler
|
||||
//! agile and run on the async thread.
|
||||
template <typename TAgility = IUnknown, typename TFunc>
|
||||
void run_when_complete(_In_ ABI::Windows::Foundation::IAsyncAction* operation, TFunc&& func)
|
||||
{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// and non-exception based code should utilize this functionality.
|
||||
|
||||
// This header mimics libc++'s '__config' header to the extent necessary to get the wistd::* definitions compiling. Note
|
||||
// that this has a few key differences since libc++'s MSVC compatability is currently not functional and a bit behind
|
||||
// that this has a few key differences since libc++'s MSVC compatibility is currently not functional and a bit behind
|
||||
|
||||
#ifndef _WISTD_CONFIG_H_
|
||||
#define _WISTD_CONFIG_H_
|
||||
|
@ -130,7 +130,7 @@
|
|||
#define __WI_CLANG_DISABLE_WARNING(warning)
|
||||
#endif
|
||||
|
||||
// NOTE: MSVC, which is what we primarily target, is severly underrepresented in libc++ and checks such as
|
||||
// NOTE: MSVC, which is what we primarily target, is severely underrepresented in libc++ and checks such as
|
||||
// __has_feature(...) are always false for MSVC, even when the feature being tested _is_ present in MSVC. Therefore, we
|
||||
// instead modify all checks to be __WI_HAS_FEATURE_IS_UNION, etc., which provides the correct value for MSVC and falls
|
||||
// back to the __has_feature(...), etc. value otherwise. We intentionally leave '__has_feature', etc. undefined for MSVC
|
||||
|
|
|
@ -1946,7 +1946,7 @@ struct __numeric_type<void>
|
|||
|
||||
// __promote
|
||||
|
||||
template <class _A1, class _A2 = void, class _A3 = void, bool = __numeric_type<_A1>::value&& __numeric_type<_A2>::value&& __numeric_type<_A3>::value>
|
||||
template <class _A1, class _A2 = void, class _A3 = void, bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value>
|
||||
class __promote_imp
|
||||
{
|
||||
public:
|
||||
|
@ -4775,7 +4775,7 @@ struct underlying_type
|
|||
{
|
||||
static_assert(
|
||||
_Support,
|
||||
"The underyling_type trait requires compiler "
|
||||
"The underlying_type trait requires compiler "
|
||||
"support. Either no such support exists or "
|
||||
"libc++ does not know how to use it.");
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue