未验证 提交 9b6baa09 编写于 作者: A Andrii Kurdiumov 提交者: GitHub

Simplify dwrite.dll loading process (#6538)

* Simplify dwrite loading process

All supported OS always has `dwrite.dll`.

* Remove noop
上级 e80b23b7
......@@ -7,37 +7,9 @@
namespace WPFUtils
{
#if defined(__cplusplus_cli)
#endif
HMODULE LoadDWriteLibraryAndGetProcAddress(void **pfncptrDWriteCreateFactory)
{
HMODULE hDWriteLibrary = nullptr;
// KB2533623 introduced the LOAD_LIBRARY_SEARCH_SYSTEM32 flag. It also introduced
// the AddDllDirectory function. We test for presence of AddDllDirectory as an
// indirect evidence for the support of LOAD_LIBRARY_SEARCH_SYSTEM32 flag.
HMODULE hKernel32 = GetModuleHandle(L"kernel32.dll");
if (hKernel32 != nullptr)
{
if (GetProcAddress(hKernel32, "AddDllDirectory") != nullptr)
{
// All supported platforms newer than Vista SP2 shipped with dwrite.dll.
// On Vista SP2, the .NET servicing process will ensure that a MSU containing
// dwrite.dll will be delivered as a prerequisite - effectively guaranteeing that
// this following call to LoadLibraryEx(dwrite.dll) will succeed, and that it will
// not be susceptible to typical DLL planting vulnerability vectors.
hDWriteLibrary = LoadLibraryEx(L"dwrite.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
}
else
{
// LOAD_LIBRARY_SEARCH_SYSTEM32 is not supported on this OS.
// Fall back to using plain ol' LoadLibrary
// There is risk that this call might fail, or that it might be
// susceptible to DLL hijacking.
hDWriteLibrary = LoadLibrary(L"dwrite.dll");
}
}
HMODULE hDWriteLibrary = LoadLibraryEx(L"dwrite.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (hDWriteLibrary)
{
*pfncptrDWriteCreateFactory = GetProcAddress(hDWriteLibrary, "DWriteCreateFactory");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册