diff --git a/strings/base_activation.h b/strings/base_activation.h index 1d3817977..c50effe94 100644 --- a/strings/base_activation.h +++ b/strings/base_activation.h @@ -7,7 +7,7 @@ namespace winrt::impl static void close(type value) noexcept { - WINRT_FreeLibrary(value); + WINRT_IMPL_FreeLibrary(value); } static constexpr type invalid() noexcept @@ -34,7 +34,7 @@ namespace winrt::impl if (hr == impl::error_not_initialized) { - auto usage = static_cast(WINRT_GetProcAddress(WINRT_LoadLibraryW(L"combase.dll"), "CoIncrementMTAUsage")); + auto usage = static_cast(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(L"combase.dll"), "CoIncrementMTAUsage")); if (!usage) { @@ -58,7 +58,7 @@ namespace winrt::impl { path.resize(count); path += L".dll"; - library_handle library(WINRT_LoadLibraryW(path.c_str())); + library_handle library(WINRT_IMPL_LoadLibraryW(path.c_str())); path.resize(path.size() - 4); if (!library) @@ -66,7 +66,7 @@ namespace winrt::impl continue; } - auto library_call = reinterpret_cast(WINRT_GetProcAddress(library.get(), "DllGetActivationFactory")); + auto library_call = reinterpret_cast(WINRT_IMPL_GetProcAddress(library.get(), "DllGetActivationFactory")); if (!library_call) { @@ -292,12 +292,12 @@ namespace winrt::impl void add(factory_cache_entry_base* const entry) noexcept { WINRT_ASSERT(entry); - WINRT_InterlockedPushEntrySList(&m_list, &entry->m_next); + WINRT_IMPL_InterlockedPushEntrySList(&m_list, &entry->m_next); } void clear() noexcept { - slist_entry* entry = static_cast(WINRT_InterlockedFlushSList(&m_list)); + slist_entry* entry = static_cast(WINRT_IMPL_InterlockedFlushSList(&m_list)); while (entry != nullptr) { @@ -437,7 +437,7 @@ WINRT_EXPORT namespace winrt inline void init_apartment(apartment_type const type = apartment_type::multi_threaded) { - hresult const result = WINRT_CoInitializeEx(nullptr, static_cast(type)); + hresult const result = WINRT_IMPL_CoInitializeEx(nullptr, static_cast(type)); if (result < 0) { @@ -447,7 +447,7 @@ WINRT_EXPORT namespace winrt inline void uninit_apartment() noexcept { - WINRT_CoUninitialize(); + WINRT_IMPL_CoUninitialize(); } template @@ -482,7 +482,7 @@ WINRT_EXPORT namespace winrt template auto create_instance(guid const& clsid, uint32_t context = 0x1 /*CLSCTX_INPROC_SERVER*/, void* outer = nullptr) { - return capture(WINRT_CoCreateInstance, clsid, outer, context); + return capture(WINRT_IMPL_CoCreateInstance, clsid, outer, context); } namespace Windows::Foundation diff --git a/strings/base_agile_ref.h b/strings/base_agile_ref.h index b7bc14f92..1f8cd1161 100644 --- a/strings/base_agile_ref.h +++ b/strings/base_agile_ref.h @@ -109,7 +109,7 @@ namespace winrt::impl return; } - result = static_cast(WINRT_GetProcAddress(WINRT_LoadLibraryW(L"combase.dll"), name)); + result = static_cast(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(L"combase.dll"), name)); if (result) { @@ -130,7 +130,7 @@ namespace winrt::impl static constexpr guid git_clsid{ 0x00000323, 0x0000, 0x0000, { 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 } }; com_ptr git; - hresult hr = WINRT_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of(), git.put_void()); + hresult hr = WINRT_IMPL_CoCreateInstance(git_clsid, nullptr, 1 /*CLSCTX_INPROC_SERVER*/, guid_of(), git.put_void()); if (result < 0) { diff --git a/strings/base_array.h b/strings/base_array.h index ff4cfece7..0378e82dc 100644 --- a/strings/base_array.h +++ b/strings/base_array.h @@ -302,7 +302,7 @@ WINRT_EXPORT namespace winrt std::destroy(this->begin(), this->end()); - WINRT_CoTaskMemFree(this->m_data); + WINRT_IMPL_CoTaskMemFree(this->m_data); this->m_data = nullptr; this->m_size = 0; } @@ -321,7 +321,7 @@ WINRT_EXPORT namespace winrt if (0 != size) { - this->m_data = static_cast(WINRT_CoTaskMemAlloc(size * sizeof(value_type))); + this->m_data = static_cast(WINRT_IMPL_CoTaskMemAlloc(size * sizeof(value_type))); if (this->m_data == nullptr) { diff --git a/strings/base_chrono.h b/strings/base_chrono.h index c7b1eb463..1a6236b5b 100644 --- a/strings/base_chrono.h +++ b/strings/base_chrono.h @@ -36,7 +36,7 @@ WINRT_EXPORT namespace winrt static time_point now() noexcept { file_time ft; - WINRT_GetSystemTimePreciseAsFileTime(&ft); + WINRT_IMPL_GetSystemTimePreciseAsFileTime(&ft); return from_file_time(ft); } diff --git a/strings/base_coroutine_foundation.h b/strings/base_coroutine_foundation.h index b2e671d94..66d12efb9 100644 --- a/strings/base_coroutine_foundation.h +++ b/strings/base_coroutine_foundation.h @@ -41,16 +41,16 @@ namespace winrt::impl template void wait_for_completed(Async const& async, uint32_t const timeout) { - void* event = check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr)); + void* event = check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr)); // The delegate is a local to ensure that the event outlives the call to WaitForSingleObject. async_completed_handler_t delegate = [event = handle(event)](auto && ...) { - WINRT_VERIFY(WINRT_SetEvent(event.get())); + WINRT_VERIFY(WINRT_IMPL_SetEvent(event.get())); }; async.Completed(delegate); - WINRT_WaitForSingleObject(event, timeout); + WINRT_IMPL_WaitForSingleObject(event, timeout); } template @@ -664,7 +664,7 @@ WINRT_EXPORT namespace winrt struct shared_type { - handle event{ check_pointer(WINRT_CreateEventW(nullptr, true, false, nullptr)) }; + handle event{ check_pointer(WINRT_IMPL_CreateEventW(nullptr, true, false, nullptr)) }; T result; }; @@ -679,7 +679,7 @@ WINRT_EXPORT namespace winrt if (nullptr == _InterlockedCompareExchangePointer(reinterpret_cast(&shared->result), sender_abi, nullptr)) { sender_abi->AddRef(); - WINRT_VERIFY(WINRT_SetEvent(shared->event.get())); + WINRT_VERIFY(WINRT_IMPL_SetEvent(shared->event.get())); } }); }; diff --git a/strings/base_coroutine_threadpool.h b/strings/base_coroutine_threadpool.h index 8d7957d88..1a6b6170e 100644 --- a/strings/base_coroutine_threadpool.h +++ b/strings/base_coroutine_threadpool.h @@ -8,7 +8,7 @@ namespace winrt::impl inline auto resume_background(std::experimental::coroutine_handle<> handle) { - if (!WINRT_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr)) + if (!WINRT_IMPL_TrySubmitThreadpoolCallback(resume_background_callback, handle.address(), nullptr)) { throw_last_error(); } @@ -18,19 +18,19 @@ namespace winrt::impl { int32_t aptType; int32_t aptTypeQualifier; - return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/)); + return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/)); } inline bool requires_apartment_context() noexcept { int32_t aptType; int32_t aptTypeQualifier; - return (0 == WINRT_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/)); + return (0 == WINRT_IMPL_CoGetApartmentType(&aptType, &aptTypeQualifier)) && ((aptType == 0 /*APTTYPE_STA*/) || (aptType == 2 /*APTTYPE_NA*/) || (aptType == 3 /*APTTYPE_MAINSTA*/)); } inline auto apartment_context() { - return requires_apartment_context() ? capture(WINRT_CoGetObjectContext) : nullptr; + return requires_apartment_context() ? capture(WINRT_IMPL_CoGetObjectContext) : nullptr; } inline int32_t __stdcall resume_apartment_callback(com_callback_args* args) noexcept @@ -256,7 +256,7 @@ WINRT_EXPORT namespace winrt { m_resume = resume; - if (!WINRT_TrySubmitThreadpoolCallback(callback, this, nullptr)) + if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, this, nullptr)) { throw_last_error(); } @@ -313,9 +313,9 @@ WINRT_EXPORT namespace winrt void await_suspend(std::experimental::coroutine_handle<> handle) { - m_timer.attach(check_pointer(WINRT_CreateThreadpoolTimer(callback, handle.address(), nullptr))); + m_timer.attach(check_pointer(WINRT_IMPL_CreateThreadpoolTimer(callback, handle.address(), nullptr))); int64_t relative_count = -m_duration.count(); - WINRT_SetThreadpoolTimer(m_timer.get(), &relative_count, 0, 0); + WINRT_IMPL_SetThreadpoolTimer(m_timer.get(), &relative_count, 0, 0); } void await_resume() const noexcept @@ -335,7 +335,7 @@ WINRT_EXPORT namespace winrt static void close(type value) noexcept { - WINRT_CloseThreadpoolTimer(value); + WINRT_IMPL_CloseThreadpoolTimer(value); } static constexpr type invalid() noexcept @@ -369,16 +369,16 @@ WINRT_EXPORT namespace winrt bool await_ready() const noexcept { - return WINRT_WaitForSingleObject(m_handle, 0) == 0; + return WINRT_IMPL_WaitForSingleObject(m_handle, 0) == 0; } void await_suspend(std::experimental::coroutine_handle<> resume) { m_resume = resume; - m_wait.attach(check_pointer(WINRT_CreateThreadpoolWait(callback, this, nullptr))); + m_wait.attach(check_pointer(WINRT_IMPL_CreateThreadpoolWait(callback, this, nullptr))); int64_t relative_count = -m_timeout.count(); int64_t* file_time = relative_count != 0 ? &relative_count : nullptr; - WINRT_SetThreadpoolWait(m_wait.get(), m_handle, file_time); + WINRT_IMPL_SetThreadpoolWait(m_wait.get(), m_handle, file_time); } bool await_resume() const noexcept @@ -401,7 +401,7 @@ WINRT_EXPORT namespace winrt static void close(type value) noexcept { - WINRT_CloseThreadpoolWait(value); + WINRT_IMPL_CloseThreadpoolWait(value); } static constexpr type invalid() noexcept @@ -423,15 +423,15 @@ WINRT_EXPORT namespace winrt struct thread_pool { thread_pool() : - m_pool(check_pointer(WINRT_CreateThreadpool(nullptr))) + m_pool(check_pointer(WINRT_IMPL_CreateThreadpool(nullptr))) { m_environment.Pool = m_pool.get(); } void thread_limits(uint32_t const high, uint32_t const low) { - WINRT_SetThreadpoolThreadMaximum(m_pool.get(), high); - check_bool(WINRT_SetThreadpoolThreadMinimum(m_pool.get(), low)); + WINRT_IMPL_SetThreadpoolThreadMaximum(m_pool.get(), high); + check_bool(WINRT_IMPL_SetThreadpoolThreadMinimum(m_pool.get(), low)); } bool await_ready() const noexcept @@ -445,7 +445,7 @@ WINRT_EXPORT namespace winrt void await_suspend(std::experimental::coroutine_handle<> handle) { - if (!WINRT_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment)) + if (!WINRT_IMPL_TrySubmitThreadpoolCallback(callback, handle.address(), &m_environment)) { throw_last_error(); } @@ -464,7 +464,7 @@ WINRT_EXPORT namespace winrt static void close(type value) noexcept { - WINRT_CloseThreadpool(value); + WINRT_IMPL_CloseThreadpool(value); } static constexpr type invalid() noexcept diff --git a/strings/base_error.h b/strings/base_error.h index cfecac508..8a3a02762 100644 --- a/strings/base_error.h +++ b/strings/base_error.h @@ -7,7 +7,7 @@ namespace winrt::impl static void close(type value) noexcept { - WINRT_VERIFY(WINRT_HeapFree(WINRT_GetProcessHeap(), 0, value)); + WINRT_VERIFY(WINRT_IMPL_HeapFree(WINRT_IMPL_GetProcessHeap(), 0, value)); } static constexpr type invalid() noexcept @@ -22,7 +22,7 @@ namespace winrt::impl static void close(type value) noexcept { - WINRT_SysFreeString(value); + WINRT_IMPL_SysFreeString(value); } static constexpr type invalid() noexcept @@ -121,7 +121,7 @@ namespace winrt::impl int32_t __stdcall GetDescription(bstr* value) noexcept final { - *value = WINRT_SysAllocString(m_message.c_str()); + *value = WINRT_IMPL_SysAllocString(m_message.c_str()); return *value ? error_ok : error_bad_alloc; } @@ -142,7 +142,7 @@ namespace winrt::impl *fallback = nullptr; *error = m_code; *capability = nullptr; - *message = WINRT_SysAllocString(m_message.c_str()); + *message = WINRT_IMPL_SysAllocString(m_message.c_str()); return *message ? error_ok : error_bad_alloc; } @@ -197,7 +197,7 @@ WINRT_EXPORT namespace winrt hresult_error(hresult const code, take_ownership_from_abi_t) noexcept : m_code(code) { com_ptr info; - WINRT_GetErrorInfo(0, info.put_void()); + WINRT_IMPL_GetErrorInfo(0, info.put_void()); if ((m_info = info.try_as())) { @@ -221,7 +221,7 @@ WINRT_EXPORT namespace winrt if (legacy) { - message = impl::trim_hresult_message(legacy.get(), WINRT_SysStringLen(legacy.get())); + message = impl::trim_hresult_message(legacy.get(), WINRT_IMPL_SysStringLen(legacy.get())); } originate(code, get_abi(message)); @@ -248,11 +248,11 @@ WINRT_EXPORT namespace winrt { if (message) { - return impl::trim_hresult_message(message.get(), WINRT_SysStringLen(message.get())); + return impl::trim_hresult_message(message.get(), WINRT_IMPL_SysStringLen(message.get())); } else { - return impl::trim_hresult_message(fallback.get(), WINRT_SysStringLen(fallback.get())); + return impl::trim_hresult_message(fallback.get(), WINRT_IMPL_SysStringLen(fallback.get())); } } } @@ -260,7 +260,7 @@ WINRT_EXPORT namespace winrt handle_type message; - uint32_t const size = WINRT_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS + uint32_t const size = WINRT_IMPL_FormatMessageW(0x00001300, // FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS nullptr, m_code, 0x00000400, // MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT) @@ -281,7 +281,7 @@ WINRT_EXPORT namespace winrt { if (m_info) { - WINRT_SetErrorInfo(0, m_info.try_as().get()); + WINRT_IMPL_SetErrorInfo(0, m_info.try_as().get()); } return m_code; @@ -297,13 +297,13 @@ WINRT_EXPORT namespace winrt [](int32_t error, void* message, void*) noexcept { com_ptr info(new (std::nothrow) impl::error_info_fallback(error, message), take_ownership_from_abi); - WINRT_VERIFY_(0, WINRT_SetErrorInfo(0, info.get())); + WINRT_VERIFY_(0, WINRT_IMPL_SetErrorInfo(0, info.get())); return 1; }); WINRT_VERIFY(handler(code, message, nullptr)); com_ptr info; - WINRT_VERIFY_(0, WINRT_GetErrorInfo(0, info.put_void())); + WINRT_VERIFY_(0, WINRT_IMPL_GetErrorInfo(0, info.put_void())); WINRT_VERIFY(info.try_as(m_info)); } @@ -511,7 +511,7 @@ WINRT_EXPORT namespace winrt [[noreturn]] inline void throw_last_error() { - throw_hresult(impl::hresult_from_win32(WINRT_GetLastError())); + throw_hresult(impl::hresult_from_win32(WINRT_IMPL_GetLastError())); } inline void check_hresult(hresult const result) diff --git a/strings/base_extern.h b/strings/base_extern.h index f6c0bc24e..fa9906f09 100644 --- a/strings/base_extern.h +++ b/strings/base_extern.h @@ -5,86 +5,86 @@ __declspec(selectany) void(__stdcall* winrt_resume_handler)(void const* token) n extern "C" { - void* __stdcall WINRT_LoadLibraryW(wchar_t const* name) noexcept; - int32_t __stdcall WINRT_FreeLibrary(void* library) noexcept; - void* __stdcall WINRT_GetProcAddress(void* library, char const* name) noexcept; - - int32_t __stdcall WINRT_SetErrorInfo(uint32_t reserved, void* info) noexcept; - int32_t __stdcall WINRT_GetErrorInfo(uint32_t reserved, void** info) noexcept; - int32_t __stdcall WINRT_CoInitializeEx(void*, uint32_t type) noexcept; - void __stdcall WINRT_CoUninitialize() noexcept; - - int32_t __stdcall WINRT_CoCreateFreeThreadedMarshaler(void* outer, void** marshaler) noexcept; - int32_t __stdcall WINRT_CoCreateInstance(winrt::guid const& clsid, void* outer, uint32_t context, winrt::guid const& iid, void** object) noexcept; - int32_t __stdcall WINRT_CoGetCallContext(winrt::guid const& iid, void** object) noexcept; - int32_t __stdcall WINRT_CoGetObjectContext(winrt::guid const& iid, void** object) noexcept; - int32_t __stdcall WINRT_CoGetApartmentType(int32_t* type, int32_t* qualifier) noexcept; - void* __stdcall WINRT_CoTaskMemAlloc(std::size_t size) noexcept; - void __stdcall WINRT_CoTaskMemFree(void* ptr) noexcept; - winrt::impl::bstr __stdcall WINRT_SysAllocString(wchar_t const* value) noexcept; - void __stdcall WINRT_SysFreeString(winrt::impl::bstr string) noexcept; - uint32_t __stdcall WINRT_SysStringLen(winrt::impl::bstr string) noexcept; - int32_t __stdcall WINRT_IIDFromString(wchar_t const* string, winrt::guid* iid) noexcept; - int32_t __stdcall WINRT_MultiByteToWideChar(uint32_t codepage, uint32_t flags, char const* in_string, int32_t in_size, wchar_t* out_string, int32_t out_size) noexcept; - int32_t __stdcall WINRT_WideCharToMultiByte(uint32_t codepage, uint32_t flags, wchar_t const* int_string, int32_t in_size, char* out_string, int32_t out_size, char const* default_char, int32_t* default_used) noexcept; - void* __stdcall WINRT_HeapAlloc(void* heap, uint32_t flags, size_t bytes) noexcept; - int32_t __stdcall WINRT_HeapFree(void* heap, uint32_t flags, void* value) noexcept; - void* __stdcall WINRT_GetProcessHeap() noexcept; - uint32_t __stdcall WINRT_FormatMessageW(uint32_t flags, void const* source, uint32_t code, uint32_t language, wchar_t* buffer, uint32_t size, va_list* arguments) noexcept; - uint32_t __stdcall WINRT_GetLastError() noexcept; - void __stdcall WINRT_GetSystemTimePreciseAsFileTime(void* result) noexcept; - uintptr_t __stdcall WINRT_VirtualQuery(void* address, void* buffer, uintptr_t length) noexcept; - - int32_t __stdcall WINRT_OpenProcessToken(void* process, uint32_t access, void** token) noexcept; - void* __stdcall WINRT_GetCurrentProcess() noexcept; - int32_t __stdcall WINRT_DuplicateToken(void* existing, uint32_t level, void** duplicate) noexcept; - int32_t __stdcall WINRT_OpenThreadToken(void* thread, uint32_t access, int32_t self, void** token) noexcept; - void* __stdcall WINRT_GetCurrentThread() noexcept; - int32_t __stdcall WINRT_SetThreadToken(void** thread, void* token) noexcept; - - void __stdcall WINRT_AcquireSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; - void __stdcall WINRT_AcquireSRWLockShared(winrt::impl::srwlock* lock) noexcept; - uint8_t __stdcall WINRT_TryAcquireSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; - uint8_t __stdcall WINRT_TryAcquireSRWLockShared(winrt::impl::srwlock* lock) noexcept; - void __stdcall WINRT_ReleaseSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; - void __stdcall WINRT_ReleaseSRWLockShared(winrt::impl::srwlock* lock) noexcept; - int32_t __stdcall WINRT_SleepConditionVariableSRW(winrt::impl::condition_variable* cv, winrt::impl::srwlock* lock, uint32_t milliseconds, uint32_t flags) noexcept; - void __stdcall WINRT_WakeConditionVariable(winrt::impl::condition_variable* cv) noexcept; - void __stdcall WINRT_WakeAllConditionVariable(winrt::impl::condition_variable* cv) noexcept; - void* __stdcall WINRT_InterlockedPushEntrySList(void* head, void* entry) noexcept; - void* __stdcall WINRT_InterlockedFlushSList(void* head) noexcept; - - void* __stdcall WINRT_CreateEventW(void*, int32_t, int32_t, void*) noexcept; - int32_t __stdcall WINRT_SetEvent(void*) noexcept; - int32_t __stdcall WINRT_CloseHandle(void* hObject) noexcept; - uint32_t __stdcall WINRT_WaitForSingleObject(void* handle, uint32_t milliseconds) noexcept; - - int32_t __stdcall WINRT_TrySubmitThreadpoolCallback(void(__stdcall *callback)(void*, void* context), void* context, void*) noexcept; - winrt::impl::ptp_timer __stdcall WINRT_CreateThreadpoolTimer(void(__stdcall *callback)(void*, void* context, void*), void* context, void*) noexcept; - void __stdcall WINRT_SetThreadpoolTimer(winrt::impl::ptp_timer timer, void* time, uint32_t period, uint32_t window) noexcept; - void __stdcall WINRT_CloseThreadpoolTimer(winrt::impl::ptp_timer timer) noexcept; - winrt::impl::ptp_wait __stdcall WINRT_CreateThreadpoolWait(void(__stdcall *callback)(void*, void* context, void*, uint32_t result), void* context, void*) noexcept; - void __stdcall WINRT_SetThreadpoolWait(winrt::impl::ptp_wait wait, void* handle, void* timeout) noexcept; - void __stdcall WINRT_CloseThreadpoolWait(winrt::impl::ptp_wait wait) noexcept; - winrt::impl::ptp_io __stdcall WINRT_CreateThreadpoolIo(void* object, void(__stdcall *callback)(void*, void* context, void* overlapped, uint32_t result, std::size_t bytes, void*) noexcept, void* context, void*) noexcept; - void __stdcall WINRT_StartThreadpoolIo(winrt::impl::ptp_io io) noexcept; - void __stdcall WINRT_CancelThreadpoolIo(winrt::impl::ptp_io io) noexcept; - void __stdcall WINRT_CloseThreadpoolIo(winrt::impl::ptp_io io) noexcept; - winrt::impl::ptp_pool __stdcall WINRT_CreateThreadpool(void* reserved) noexcept; - void __stdcall WINRT_SetThreadpoolThreadMaximum(winrt::impl::ptp_pool pool, uint32_t value) noexcept; - int32_t __stdcall WINRT_SetThreadpoolThreadMinimum(winrt::impl::ptp_pool pool, uint32_t value) noexcept; - void __stdcall WINRT_CloseThreadpool(winrt::impl::ptp_pool pool) noexcept; - - int32_t __stdcall WINRT_CanUnloadNow() noexcept; - int32_t __stdcall WINRT_GetActivationFactory(void* classId, void** factory) noexcept; + void* __stdcall WINRT_IMPL_LoadLibraryW(wchar_t const* name) noexcept; + int32_t __stdcall WINRT_IMPL_FreeLibrary(void* library) noexcept; + void* __stdcall WINRT_IMPL_GetProcAddress(void* library, char const* name) noexcept; + + int32_t __stdcall WINRT_IMPL_SetErrorInfo(uint32_t reserved, void* info) noexcept; + int32_t __stdcall WINRT_IMPL_GetErrorInfo(uint32_t reserved, void** info) noexcept; + int32_t __stdcall WINRT_IMPL_CoInitializeEx(void*, uint32_t type) noexcept; + void __stdcall WINRT_IMPL_CoUninitialize() noexcept; + + int32_t __stdcall WINRT_IMPL_CoCreateFreeThreadedMarshaler(void* outer, void** marshaler) noexcept; + int32_t __stdcall WINRT_IMPL_CoCreateInstance(winrt::guid const& clsid, void* outer, uint32_t context, winrt::guid const& iid, void** object) noexcept; + int32_t __stdcall WINRT_IMPL_CoGetCallContext(winrt::guid const& iid, void** object) noexcept; + int32_t __stdcall WINRT_IMPL_CoGetObjectContext(winrt::guid const& iid, void** object) noexcept; + int32_t __stdcall WINRT_IMPL_CoGetApartmentType(int32_t* type, int32_t* qualifier) noexcept; + void* __stdcall WINRT_IMPL_CoTaskMemAlloc(std::size_t size) noexcept; + void __stdcall WINRT_IMPL_CoTaskMemFree(void* ptr) noexcept; + winrt::impl::bstr __stdcall WINRT_IMPL_SysAllocString(wchar_t const* value) noexcept; + void __stdcall WINRT_IMPL_SysFreeString(winrt::impl::bstr string) noexcept; + uint32_t __stdcall WINRT_IMPL_SysStringLen(winrt::impl::bstr string) noexcept; + int32_t __stdcall WINRT_IMPL_IIDFromString(wchar_t const* string, winrt::guid* iid) noexcept; + int32_t __stdcall WINRT_IMPL_MultiByteToWideChar(uint32_t codepage, uint32_t flags, char const* in_string, int32_t in_size, wchar_t* out_string, int32_t out_size) noexcept; + int32_t __stdcall WINRT_IMPL_WideCharToMultiByte(uint32_t codepage, uint32_t flags, wchar_t const* int_string, int32_t in_size, char* out_string, int32_t out_size, char const* default_char, int32_t* default_used) noexcept; + void* __stdcall WINRT_IMPL_HeapAlloc(void* heap, uint32_t flags, size_t bytes) noexcept; + int32_t __stdcall WINRT_IMPL_HeapFree(void* heap, uint32_t flags, void* value) noexcept; + void* __stdcall WINRT_IMPL_GetProcessHeap() noexcept; + uint32_t __stdcall WINRT_IMPL_FormatMessageW(uint32_t flags, void const* source, uint32_t code, uint32_t language, wchar_t* buffer, uint32_t size, va_list* arguments) noexcept; + uint32_t __stdcall WINRT_IMPL_GetLastError() noexcept; + void __stdcall WINRT_IMPL_GetSystemTimePreciseAsFileTime(void* result) noexcept; + uintptr_t __stdcall WINRT_IMPL_VirtualQuery(void* address, void* buffer, uintptr_t length) noexcept; + + int32_t __stdcall WINRT_IMPL_OpenProcessToken(void* process, uint32_t access, void** token) noexcept; + void* __stdcall WINRT_IMPL_GetCurrentProcess() noexcept; + int32_t __stdcall WINRT_IMPL_DuplicateToken(void* existing, uint32_t level, void** duplicate) noexcept; + int32_t __stdcall WINRT_IMPL_OpenThreadToken(void* thread, uint32_t access, int32_t self, void** token) noexcept; + void* __stdcall WINRT_IMPL_GetCurrentThread() noexcept; + int32_t __stdcall WINRT_IMPL_SetThreadToken(void** thread, void* token) noexcept; + + void __stdcall WINRT_IMPL_AcquireSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; + void __stdcall WINRT_IMPL_AcquireSRWLockShared(winrt::impl::srwlock* lock) noexcept; + uint8_t __stdcall WINRT_IMPL_TryAcquireSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; + uint8_t __stdcall WINRT_IMPL_TryAcquireSRWLockShared(winrt::impl::srwlock* lock) noexcept; + void __stdcall WINRT_IMPL_ReleaseSRWLockExclusive(winrt::impl::srwlock* lock) noexcept; + void __stdcall WINRT_IMPL_ReleaseSRWLockShared(winrt::impl::srwlock* lock) noexcept; + int32_t __stdcall WINRT_IMPL_SleepConditionVariableSRW(winrt::impl::condition_variable* cv, winrt::impl::srwlock* lock, uint32_t milliseconds, uint32_t flags) noexcept; + void __stdcall WINRT_IMPL_WakeConditionVariable(winrt::impl::condition_variable* cv) noexcept; + void __stdcall WINRT_IMPL_WakeAllConditionVariable(winrt::impl::condition_variable* cv) noexcept; + void* __stdcall WINRT_IMPL_InterlockedPushEntrySList(void* head, void* entry) noexcept; + void* __stdcall WINRT_IMPL_InterlockedFlushSList(void* head) noexcept; + + void* __stdcall WINRT_IMPL_CreateEventW(void*, int32_t, int32_t, void*) noexcept; + int32_t __stdcall WINRT_IMPL_SetEvent(void*) noexcept; + int32_t __stdcall WINRT_IMPL_CloseHandle(void* hObject) noexcept; + uint32_t __stdcall WINRT_IMPL_WaitForSingleObject(void* handle, uint32_t milliseconds) noexcept; + + int32_t __stdcall WINRT_IMPL_TrySubmitThreadpoolCallback(void(__stdcall *callback)(void*, void* context), void* context, void*) noexcept; + winrt::impl::ptp_timer __stdcall WINRT_IMPL_CreateThreadpoolTimer(void(__stdcall *callback)(void*, void* context, void*), void* context, void*) noexcept; + void __stdcall WINRT_IMPL_SetThreadpoolTimer(winrt::impl::ptp_timer timer, void* time, uint32_t period, uint32_t window) noexcept; + void __stdcall WINRT_IMPL_CloseThreadpoolTimer(winrt::impl::ptp_timer timer) noexcept; + winrt::impl::ptp_wait __stdcall WINRT_IMPL_CreateThreadpoolWait(void(__stdcall *callback)(void*, void* context, void*, uint32_t result), void* context, void*) noexcept; + void __stdcall WINRT_IMPL_SetThreadpoolWait(winrt::impl::ptp_wait wait, void* handle, void* timeout) noexcept; + void __stdcall WINRT_IMPL_CloseThreadpoolWait(winrt::impl::ptp_wait wait) noexcept; + winrt::impl::ptp_io __stdcall WINRT_IMPL_CreateThreadpoolIo(void* object, void(__stdcall *callback)(void*, void* context, void* overlapped, uint32_t result, std::size_t bytes, void*) noexcept, void* context, void*) noexcept; + void __stdcall WINRT_IMPL_StartThreadpoolIo(winrt::impl::ptp_io io) noexcept; + void __stdcall WINRT_IMPL_CancelThreadpoolIo(winrt::impl::ptp_io io) noexcept; + void __stdcall WINRT_IMPL_CloseThreadpoolIo(winrt::impl::ptp_io io) noexcept; + winrt::impl::ptp_pool __stdcall WINRT_IMPL_CreateThreadpool(void* reserved) noexcept; + void __stdcall WINRT_IMPL_SetThreadpoolThreadMaximum(winrt::impl::ptp_pool pool, uint32_t value) noexcept; + int32_t __stdcall WINRT_IMPL_SetThreadpoolThreadMinimum(winrt::impl::ptp_pool pool, uint32_t value) noexcept; + void __stdcall WINRT_IMPL_CloseThreadpool(winrt::impl::ptp_pool pool) noexcept; + + int32_t __stdcall WINRT_IMPL_CanUnloadNow() noexcept; + int32_t __stdcall WINRT_IMPL_GetActivationFactory(void* classId, void** factory) noexcept; } #ifdef _M_HYBRID -#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:#WINRT_" #function "@" #count "=#" #function "@" #count)) +#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:#WINRT_IMPL_" #function "@" #count "=#" #function "@" #count)) #elif _M_IX86 -#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:_WINRT_" #function "@" #count "=_" #function "@" #count)) +#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:_WINRT_IMPL_" #function "@" #count "=_" #function "@" #count)) #else -#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:WINRT_" #function "=" #function)) +#define WINRT_IMPL_LINK(function, count) __pragma(comment(linker, "/alternatename:WINRT_IMPL_" #function "=" #function)) #endif WINRT_IMPL_LINK(LoadLibraryW, 4) diff --git a/strings/base_handle.h b/strings/base_handle.h index b8a076624..60eec8be0 100644 --- a/strings/base_handle.h +++ b/strings/base_handle.h @@ -85,7 +85,7 @@ WINRT_EXPORT namespace winrt static void close(type value) noexcept { - WINRT_VERIFY_(1, WINRT_CloseHandle(value)); + WINRT_VERIFY_(1, WINRT_IMPL_CloseHandle(value)); } static constexpr type invalid() noexcept @@ -102,7 +102,7 @@ WINRT_EXPORT namespace winrt static void close(type value) noexcept { - WINRT_VERIFY_(1, WINRT_CloseHandle(value)); + WINRT_VERIFY_(1, WINRT_IMPL_CloseHandle(value)); } static type invalid() noexcept diff --git a/strings/base_implements.h b/strings/base_implements.h index 2792417b5..78c33fc93 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -946,7 +946,7 @@ namespace winrt::impl { const com_array& inner_iids = get_interfaces(root_implements_type::m_inner); *count = local_count + inner_iids.size(); - *array = static_cast(WINRT_CoTaskMemAlloc(sizeof(guid)*(*count))); + *array = static_cast(WINRT_IMPL_CoTaskMemAlloc(sizeof(guid)*(*count))); if (*array == nullptr) { return error_bad_alloc; @@ -964,7 +964,7 @@ namespace winrt::impl if (local_count > 0) { *count = local_count; - *array = static_cast(WINRT_CoTaskMemAlloc(sizeof(guid)*(*count))); + *array = static_cast(WINRT_IMPL_CoTaskMemAlloc(sizeof(guid)*(*count))); if (*array == nullptr) { return error_bad_alloc; diff --git a/strings/base_lock.h b/strings/base_lock.h index 16f35f9b0..5f92cbd51 100644 --- a/strings/base_lock.h +++ b/strings/base_lock.h @@ -11,32 +11,32 @@ WINRT_EXPORT namespace winrt void lock() noexcept { - WINRT_AcquireSRWLockExclusive(&m_lock); + WINRT_IMPL_AcquireSRWLockExclusive(&m_lock); } void lock_shared() noexcept { - WINRT_AcquireSRWLockShared(&m_lock); + WINRT_IMPL_AcquireSRWLockShared(&m_lock); } bool try_lock() noexcept { - return 0 != WINRT_TryAcquireSRWLockExclusive(&m_lock); + return 0 != WINRT_IMPL_TryAcquireSRWLockExclusive(&m_lock); } bool try_lock_shared() noexcept { - return 0 != WINRT_TryAcquireSRWLockShared(&m_lock); + return 0 != WINRT_IMPL_TryAcquireSRWLockShared(&m_lock); } void unlock() noexcept { - WINRT_ReleaseSRWLockExclusive(&m_lock); + WINRT_IMPL_ReleaseSRWLockExclusive(&m_lock); } void unlock_shared() noexcept { - WINRT_ReleaseSRWLockShared(&m_lock); + WINRT_IMPL_ReleaseSRWLockShared(&m_lock); } private: @@ -78,7 +78,7 @@ WINRT_EXPORT namespace winrt { while (!predicate()) { - WINRT_VERIFY(WINRT_SleepConditionVariableSRW(&m_cv, x.get(), 0xFFFFFFFF /*INFINITE*/, 0)); + WINRT_VERIFY(WINRT_IMPL_SleepConditionVariableSRW(&m_cv, x.get(), 0xFFFFFFFF /*INFINITE*/, 0)); } } @@ -96,7 +96,7 @@ WINRT_EXPORT namespace winrt return false; } - if (!WINRT_SleepConditionVariableSRW(&m_cv, x.get(), static_cast(milliseconds), 0)) + if (!WINRT_IMPL_SleepConditionVariableSRW(&m_cv, x.get(), static_cast(milliseconds), 0)) { return predicate(); } @@ -107,12 +107,12 @@ WINRT_EXPORT namespace winrt void notify_one() noexcept { - WINRT_WakeConditionVariable(&m_cv); + WINRT_IMPL_WakeConditionVariable(&m_cv); } void notify_all() noexcept { - WINRT_WakeAllConditionVariable(&m_cv); + WINRT_IMPL_WakeAllConditionVariable(&m_cv); } private: diff --git a/strings/base_marshaler.h b/strings/base_marshaler.h index 816e58828..359cf3b47 100644 --- a/strings/base_marshaler.h +++ b/strings/base_marshaler.h @@ -105,7 +105,7 @@ namespace winrt::impl static com_ptr get_marshaler() noexcept { com_ptr unknown; - WINRT_VERIFY_(0, WINRT_CoCreateFreeThreadedMarshaler(nullptr, unknown.put_void())); + WINRT_VERIFY_(0, WINRT_IMPL_CoCreateFreeThreadedMarshaler(nullptr, unknown.put_void())); return unknown ? unknown.try_as() : nullptr; } diff --git a/strings/base_natvis.h b/strings/base_natvis.h index 22700929d..065550759 100644 --- a/strings/base_natvis.h +++ b/strings/base_natvis.h @@ -32,7 +32,7 @@ namespace winrt::impl value; value.s = 0; guid iid; - if (WINRT_IIDFromString(iid_str, &iid) == 0) + if (WINRT_IMPL_IIDFromString(iid_str, &iid) == 0) { struct memory_basic_information { @@ -52,7 +52,7 @@ namespace winrt::impl }; memory_basic_information info; // validate object pointer is readable - if ((WINRT_VirtualQuery(object, &info, sizeof(info)) != 0) && ((info.protect & 0xEE) != 0)) + if ((WINRT_IMPL_VirtualQuery(object, &info, sizeof(info)) != 0) && ((info.protect & 0xEE) != 0)) { inspectable_abi* pinsp; if (((unknown_abi*)object)->QueryInterface(iid, reinterpret_cast(&pinsp)) == 0) @@ -60,11 +60,11 @@ namespace winrt::impl static const int IInspectable_vtbl_size = 6; auto vtbl = *(void***)pinsp; // validate vtbl pointer is readable - if ((WINRT_VirtualQuery(vtbl, &info, sizeof(info)) != 0) && ((info.protect & 0xEE) != 0)) + if ((WINRT_IMPL_VirtualQuery(vtbl, &info, sizeof(info)) != 0) && ((info.protect & 0xEE) != 0)) { auto vfunc = vtbl[method + IInspectable_vtbl_size]; // validate method pointer is executable - if ((WINRT_VirtualQuery(vfunc, &info, sizeof(info)) != 0) && ((info.protect & 0xF0) != 0)) + if ((WINRT_IMPL_VirtualQuery(vfunc, &info, sizeof(info)) != 0) && ((info.protect & 0xF0) != 0)) { typedef int32_t(__stdcall inspectable_abi:: * PropertyAccessor)(void*); (pinsp->**(PropertyAccessor*)&vfunc)(&value); diff --git a/strings/base_security.h b/strings/base_security.h index bdfb05af5..8160f11ad 100644 --- a/strings/base_security.h +++ b/strings/base_security.h @@ -6,9 +6,9 @@ WINRT_EXPORT namespace winrt static access_token process() { access_token token; - check_bool(WINRT_OpenProcessToken(WINRT_GetCurrentProcess(), 0x0002 /*TOKEN_DUPLICATE*/, token.put())); + check_bool(WINRT_IMPL_OpenProcessToken(WINRT_IMPL_GetCurrentProcess(), 0x0002 /*TOKEN_DUPLICATE*/, token.put())); access_token duplicate; - check_bool(WINRT_DuplicateToken(token.get(), 2 /*SecurityImpersonation*/, duplicate.put())); + check_bool(WINRT_IMPL_DuplicateToken(token.get(), 2 /*SecurityImpersonation*/, duplicate.put())); return duplicate; } @@ -16,9 +16,9 @@ WINRT_EXPORT namespace winrt { access_token token; - if (!WINRT_OpenThreadToken(WINRT_GetCurrentThread(), 0x0004 /*TOKEN_IMPERSONATE*/, 1, token.put())) + if (!WINRT_IMPL_OpenThreadToken(WINRT_IMPL_GetCurrentThread(), 0x0004 /*TOKEN_IMPERSONATE*/, 1, token.put())) { - uint32_t const error = WINRT_GetLastError(); + uint32_t const error = WINRT_IMPL_GetLastError(); if (error != 1008 /*ERROR_NO_TOKEN*/) { @@ -48,7 +48,7 @@ WINRT_EXPORT namespace winrt com_ptr const& m_server; }; - auto server = capture(WINRT_CoGetCallContext); + auto server = capture(WINRT_IMPL_CoGetCallContext); impersonate_guard impersonate(server); return thread(); } @@ -60,13 +60,13 @@ WINRT_EXPORT namespace winrt access_token impersonate() const { auto previous = thread(); - check_bool(WINRT_SetThreadToken(nullptr, get())); + check_bool(WINRT_IMPL_SetThreadToken(nullptr, get())); return previous; } void revert() const { - check_bool(WINRT_SetThreadToken(nullptr, get())); + check_bool(WINRT_IMPL_SetThreadToken(nullptr, get())); } auto operator()() const diff --git a/strings/base_string.h b/strings/base_string.h index 7fd198693..933f73f25 100644 --- a/strings/base_string.h +++ b/strings/base_string.h @@ -68,7 +68,7 @@ namespace winrt::impl if (0 == --static_cast(handle)->count) { - WINRT_HeapFree(WINRT_GetProcessHeap(), 0, handle); + WINRT_IMPL_HeapFree(WINRT_IMPL_GetProcessHeap(), 0, handle); } } @@ -82,7 +82,7 @@ namespace winrt::impl throw std::invalid_argument("length"); } - auto header = static_cast(WINRT_HeapAlloc(WINRT_GetProcessHeap(), 0, static_cast(bytes_required))); + auto header = static_cast(WINRT_IMPL_HeapAlloc(WINRT_IMPL_GetProcessHeap(), 0, static_cast(bytes_required))); if (!header) { @@ -605,7 +605,7 @@ WINRT_EXPORT namespace winrt hstring to_hstring(T const& value) { std::string_view const view(value); - int const size = WINRT_MultiByteToWideChar(65001 /*CP_UTF8*/, 0, view.data(), static_cast(view.size()), nullptr, 0); + int const size = WINRT_IMPL_MultiByteToWideChar(65001 /*CP_UTF8*/, 0, view.data(), static_cast(view.size()), nullptr, 0); if (size == 0) { @@ -613,13 +613,13 @@ WINRT_EXPORT namespace winrt } impl::hstring_builder result(size); - WINRT_VERIFY_(size, WINRT_MultiByteToWideChar(65001 /*CP_UTF8*/, 0, view.data(), static_cast(view.size()), result.data(), size)); + WINRT_VERIFY_(size, WINRT_IMPL_MultiByteToWideChar(65001 /*CP_UTF8*/, 0, view.data(), static_cast(view.size()), result.data(), size)); return result.to_hstring(); } inline std::string to_string(std::wstring_view value) { - int const size = WINRT_WideCharToMultiByte(65001 /*CP_UTF8*/, 0, value.data(), static_cast(value.size()), nullptr, 0, nullptr, nullptr); + int const size = WINRT_IMPL_WideCharToMultiByte(65001 /*CP_UTF8*/, 0, value.data(), static_cast(value.size()), nullptr, 0, nullptr, nullptr); if (size == 0) { @@ -627,7 +627,7 @@ WINRT_EXPORT namespace winrt } std::string result(size, '?'); - WINRT_VERIFY_(size, WINRT_WideCharToMultiByte(65001 /*CP_UTF8*/, 0, value.data(), static_cast(value.size()), result.data(), size, nullptr, nullptr)); + WINRT_VERIFY_(size, WINRT_IMPL_WideCharToMultiByte(65001 /*CP_UTF8*/, 0, value.data(), static_cast(value.size()), result.data(), size, nullptr, nullptr)); return result; } } diff --git a/test/old_tests/UnitTests/get_activation_factory.cpp b/test/old_tests/UnitTests/get_activation_factory.cpp index 09af3ae98..a3f5a18ba 100644 --- a/test/old_tests/UnitTests/get_activation_factory.cpp +++ b/test/old_tests/UnitTests/get_activation_factory.cpp @@ -39,8 +39,8 @@ TEST_CASE("try_get_activation_factory") // Used to test whether the IRestrictedErrorInfo was left on the thread auto get_error_info = [] { - com_ptr info; - WINRT_GetErrorInfo(0, info.put_void()); + com_ptr info; + GetErrorInfo(0, info.put()); return info.as(); };