Skip to content

Commit

Permalink
Use ::LoadLibraryEx instead of ::LoadLibraryEx{A,W}.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinj committed Oct 2, 2020
1 parent cbef35a commit dd9902e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions omaha/crashhandler/crash_analyzer_checks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<BYTE*> functions;
functions.push_back(reinterpret_cast<BYTE*>(
::GetProcAddress(kernel32, "HeapCreate")));
Expand Down
4 changes: 2 additions & 2 deletions omaha/crashhandler/crash_analyzer_debugee_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -64,7 +64,7 @@ void TestWildStackPointer() {
void TestPENotInModuleList() {
MEMORY_BASIC_INFORMATION mbi = {0};
BYTE* ntdll = reinterpret_cast<BYTE*>(
::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,
Expand Down
2 changes: 1 addition & 1 deletion omaha/goopdate/cred_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]")));
Expand Down
15 changes: 9 additions & 6 deletions omaha/net/proxy_auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit dd9902e

Please sign in to comment.