@@ -80,11 +80,9 @@ static std::wstring GetExecutablePath() {
80
80
error_code_large);
81
81
return std::wstring ();
82
82
}
83
- }
84
- else {
83
+ } else {
85
84
// length >= buffer.size() but not ERROR_INSUFFICIENT_BUFFER.
86
- LogError (LOG_TAG " Failed to get executable path. Error: %u" ,
87
- error_code);
85
+ LogError (LOG_TAG " Failed to get executable path. Error: %u" , error_code);
88
86
return std::wstring ();
89
87
}
90
88
}
@@ -194,8 +192,7 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
194
192
}
195
193
if (expected_hash == nullptr || expected_hash_size == 0 ) {
196
194
// Don't check the hash, just load the library.
197
- return LoadLibraryExW (library_filename, NULL ,
198
- LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
195
+ return LoadLibraryW (library_filename);
199
196
}
200
197
201
198
std::wstring executable_path_str = GetExecutablePath ();
@@ -262,14 +259,9 @@ HMODULE VerifyAndLoadAnalyticsLibrary(
262
259
expected_hash_size) != 0 ) {
263
260
LogError (LOG_TAG " Hash mismatch for Analytics DLL." );
264
261
} else {
265
- // Load the library. LOAD_LIBRARY_SEARCH_APPLICATION_DIR is a security
266
- // measure to help ensure that the DLL is loaded from the application's
267
- // installation directory, mitigating risks of DLL preloading attacks
268
- // from other locations. Crucially, LoadLibraryExW with this flag needs
269
- // the DLL *filename only* (library_filename), not the full path we
270
- // constructed for CreateFileW.
271
- hModule = LoadLibraryExW (library_filename, NULL ,
272
- LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
262
+ // Load the library. When loading with a full path string, other
263
+ // directories are not searched.
264
+ hModule = LoadLibraryW (full_dll_path_str);
273
265
if (hModule == NULL ) {
274
266
DWORD dwError = GetLastError ();
275
267
LogError (LOG_TAG " Library load failed for Analytics DLL. Error: %u" ,
0 commit comments