Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions strings/base_activation.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace winrt::impl

if (hr == impl::error_not_initialized)
{
auto usage = reinterpret_cast<int32_t(__stdcall*)(void** cookie) noexcept>(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(L"combase.dll"), "CoIncrementMTAUsage"));
auto usage = reinterpret_cast<int32_t(__stdcall*)(void** cookie) noexcept>(WINRT_IMPL_GetProcAddress(load_library(L"combase.dll"), "CoIncrementMTAUsage"));

if (!usage)
{
Expand All @@ -66,7 +66,7 @@ namespace winrt::impl
{
path.resize(count);
path += L".dll";
library_handle library(WINRT_IMPL_LoadLibraryW(path.c_str()));
library_handle library(load_library(path.c_str()));
path.resize(path.size() - 4);

if (!library)
Expand Down
7 changes: 6 additions & 1 deletion strings/base_agile_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ namespace winrt::impl
atomic_ref_count m_references{ 1 };
};

inline void* load_library(wchar_t const* library) noexcept
{
return WINRT_IMPL_LoadLibraryExW(library, nullptr, 0x00001000 /* LOAD_LIBRARY_SEARCH_DEFAULT_DIRS */);
}

template <typename F, typename L>
void load_runtime_function(wchar_t const* library, char const* name, F& result, L fallback) noexcept
{
Expand All @@ -134,7 +139,7 @@ namespace winrt::impl
return;
}

result = reinterpret_cast<F>(WINRT_IMPL_GetProcAddress(WINRT_IMPL_LoadLibraryW(library), name));
result = reinterpret_cast<F>(WINRT_IMPL_GetProcAddress(load_library(library), name));

if (result)
{
Expand Down
2 changes: 1 addition & 1 deletion strings/base_extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ __declspec(selectany) int32_t(__stdcall* winrt_activation_handler)(void* classId

extern "C"
{
void* __stdcall WINRT_IMPL_LoadLibraryW(wchar_t const* name) noexcept WINRT_IMPL_LINK(LoadLibraryW, 4);
void* __stdcall WINRT_IMPL_LoadLibraryExW(wchar_t const* name, void* unused, uint32_t flags) noexcept WINRT_IMPL_LINK(LoadLibraryExW, 12);
int32_t __stdcall WINRT_IMPL_FreeLibrary(void* library) noexcept WINRT_IMPL_LINK(FreeLibrary, 4);
void* __stdcall WINRT_IMPL_GetProcAddress(void* library, char const* name) noexcept WINRT_IMPL_LINK(GetProcAddress, 8);

Expand Down