From dd9902e81da6d488a1f30f68cd7b2e449eb99679 Mon Sep 17 00:00:00 2001 From: Sorin Jianu Date: Fri, 2 Oct 2020 13:04:33 -0700 Subject: [PATCH] Use ::LoadLibraryEx instead of ::LoadLibraryEx{A,W}. --- omaha/crashhandler/crash_analyzer_checks.cc | 6 +++--- omaha/crashhandler/crash_analyzer_debugee_test.cc | 4 ++-- omaha/goopdate/cred_dialog.cc | 2 +- omaha/net/proxy_auth.cc | 15 +++++++++------ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/omaha/crashhandler/crash_analyzer_checks.cc b/omaha/crashhandler/crash_analyzer_checks.cc index 924f40a35..b73f069b4 100644 --- a/omaha/crashhandler/crash_analyzer_checks.cc +++ b/omaha/crashhandler/crash_analyzer_checks.cc @@ -93,9 +93,9 @@ CrashAnalysisResult NtFunctionsOnStack::Run() { // as the process which crashed we can assume that they are mapped // in the same location in both processes. HMODULE ntdll = - ::LoadLibraryExA("ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); - HMODULE kernel32 = - ::LoadLibraryExA("kernel32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + ::LoadLibraryEx(_T("ntdll.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + HMODULE kernel32 = ::LoadLibraryEx(_T("kernel32.dll"), nullptr, + LOAD_LIBRARY_SEARCH_SYSTEM32); std::vector functions; functions.push_back(reinterpret_cast( ::GetProcAddress(kernel32, "HeapCreate"))); diff --git a/omaha/crashhandler/crash_analyzer_debugee_test.cc b/omaha/crashhandler/crash_analyzer_debugee_test.cc index ed862e86c..db0a77edb 100644 --- a/omaha/crashhandler/crash_analyzer_debugee_test.cc +++ b/omaha/crashhandler/crash_analyzer_debugee_test.cc @@ -44,7 +44,7 @@ void MaxExecMappings() { void NtFunctionsOnStack() { HMODULE ntdll = - ::LoadLibraryExA("ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + ::LoadLibraryEx(_T("ntdll.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); FARPROC ptr = ::GetProcAddress(ntdll, "ZwProtectVirtualMemory"); AwaitTheReaper(); } @@ -64,7 +64,7 @@ void TestWildStackPointer() { void TestPENotInModuleList() { MEMORY_BASIC_INFORMATION mbi = {0}; BYTE* ntdll = reinterpret_cast( - ::LoadLibraryExA("ntdll.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); + ::LoadLibraryEx(_T("ntdll.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); ::VirtualQuery(ntdll, &mbi, sizeof(mbi)); LPVOID buffer = ::VirtualAlloc(NULL, mbi.RegionSize, diff --git a/omaha/goopdate/cred_dialog.cc b/omaha/goopdate/cred_dialog.cc index 02c2a7493..9eab20957 100644 --- a/omaha/goopdate/cred_dialog.cc +++ b/omaha/goopdate/cred_dialog.cc @@ -87,7 +87,7 @@ DWORD CredentialDialogBase::DisplayDialog( CString* username_out, CString* password_out) { scoped_library credui_lib( - ::LoadLibraryExW(L"credui.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); + ::LoadLibraryEx(_T("credui.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); ASSERT1(credui_lib); if (!credui_lib) { CORE_LOG(L3, (_T("[CredUIPromptForCredentialsW not available]"))); diff --git a/omaha/net/proxy_auth.cc b/omaha/net/proxy_auth.cc index 5cb7d7eb5..47459b3d8 100644 --- a/omaha/net/proxy_auth.cc +++ b/omaha/net/proxy_auth.cc @@ -248,8 +248,9 @@ HRESULT ProxyAuth::SetProxyAuthScheme(const CString& proxy_server, // This approach (the key in particular) comes from a securityfocus posting: // http://www.securityfocus.com/archive/1/458115/30/0/threaded bool ProxyAuth::ReadFromIE7(const CString& server) { - scoped_library crypt_lib( - ::LoadLibraryExW(L"crypt32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); + scoped_library crypt_lib(::LoadLibraryEx(_T("crypt32.dll"), + nullptr, + LOAD_LIBRARY_SEARCH_SYSTEM32)); ASSERT1(crypt_lib); if (!crypt_lib) return false; @@ -265,8 +266,9 @@ bool ProxyAuth::ReadFromIE7(const CString& server) { // Load CredEnumerate and CredFree dynamically because they don't exist on // Win2K and so loading the GoogleDesktopCommon.dll otherwise. - scoped_library advapi_lib( - ::LoadLibraryExW(L"advapi32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); + scoped_library advapi_lib(::LoadLibraryEx(_T("advapi32.dll"), + nullptr, + LOAD_LIBRARY_SEARCH_SYSTEM32)); ASSERT1(advapi_lib); if (!advapi_lib) return false; @@ -341,8 +343,9 @@ bool ProxyAuth::ReadFromIE7(const CString& server) { // reading credentials from the IE6 is not supported anymore. bool ProxyAuth::ReadFromPreIE7(const CString& server) { #if (_MSC_VER < 1800) - scoped_library pstore_lib( - ::LoadLibraryExW(L"pstorec.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32)); + scoped_library pstore_lib(::LoadLibraryEx(_T("pstorec.dll"), + nullptr, + LOAD_LIBRARY_SEARCH_SYSTEM32)); ASSERT1(pstore_lib); if (!pstore_lib) return false;