Commit f404e309 authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Don't fall back to dll loading for LOAD_LIBRARY_AS_DATAFILE.

parent c5b0dd5f
......@@ -377,11 +377,7 @@ static void testLoadLibraryEx(void)
SetLastError(0xdeadbeef);
hmodule = LoadLibraryExA("testfile.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
todo_wine
{
ok(GetLastError() == ERROR_FILE_INVALID,
"Expected ERROR_FILE_INVALID, got %d\n", GetLastError());
}
ok(GetLastError() == ERROR_FILE_INVALID, "Expected ERROR_FILE_INVALID, got %d\n", GetLastError());
DeleteFileA("testfile.dll");
......@@ -423,7 +419,6 @@ static void testLoadLibraryEx(void)
SetLastError(0xdeadbeef);
hmodule = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE);
ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
todo_wine
ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
......
......@@ -95,6 +95,7 @@ static BOOL load_library_as_datafile( LPCWSTR load_path, DWORD flags, LPCWSTR na
file = CreateFileW( filenameW, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, 0 );
}
if (file == INVALID_HANDLE_VALUE) ERR("can't load %s\n", debugstr_w(name));
if (file == INVALID_HANDLE_VALUE) return FALSE;
mapping = CreateFileMappingW( file, NULL, protect, 0, 0, NULL );
......@@ -154,31 +155,22 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
LdrLockLoaderLock( 0, NULL, &magic );
if (!LdrGetDllHandle( load_path, flags, libname, &module ))
{
LdrAddRefDll( 0, module );
LdrUnlockLoaderLock( 0, magic );
goto done;
}
if (load_library_as_datafile( load_path, flags, libname->Buffer, &module ))
{
LdrUnlockLoaderLock( 0, magic );
goto done;
}
else
load_library_as_datafile( load_path, flags, libname->Buffer, &module );
LdrUnlockLoaderLock( 0, magic );
flags |= DONT_RESOLVE_DLL_REFERENCES; /* Just in case */
/* Fallback to normal behaviour */
}
status = LdrLoadDll( load_path, flags, libname, &module );
if (status != STATUS_SUCCESS)
else
{
module = 0;
if (status == STATUS_DLL_NOT_FOUND && (GetVersion() & 0x80000000))
SetLastError( ERROR_DLL_NOT_FOUND );
else
SetLastError( RtlNtStatusToDosError( status ) );
status = LdrLoadDll( load_path, flags, libname, &module );
if (!set_ntstatus( status ))
{
module = 0;
if (status == STATUS_DLL_NOT_FOUND && (GetVersion() & 0x80000000))
SetLastError( ERROR_DLL_NOT_FOUND );
}
}
done:
RtlReleasePath( load_path );
return module;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment