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) ...@@ -377,11 +377,7 @@ static void testLoadLibraryEx(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmodule = LoadLibraryExA("testfile.dll", NULL, LOAD_LIBRARY_AS_DATAFILE); hmodule = LoadLibraryExA("testfile.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
ok(hmodule == 0, "Expected 0, got %p\n", hmodule); 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"); DeleteFileA("testfile.dll");
...@@ -423,7 +419,6 @@ static void testLoadLibraryEx(void) ...@@ -423,7 +419,6 @@ static void testLoadLibraryEx(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
hmodule = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE); hmodule = LoadLibraryExA(path, NULL, LOAD_LIBRARY_AS_DATAFILE);
ok(hmodule == 0, "Expected 0, got %p\n", hmodule); ok(hmodule == 0, "Expected 0, got %p\n", hmodule);
todo_wine
ok(GetLastError() == ERROR_FILE_NOT_FOUND, ok(GetLastError() == ERROR_FILE_NOT_FOUND,
"Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); "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 ...@@ -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, file = CreateFileW( filenameW, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, 0, 0 ); 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; if (file == INVALID_HANDLE_VALUE) return FALSE;
mapping = CreateFileMappingW( file, NULL, protect, 0, 0, NULL ); mapping = CreateFileMappingW( file, NULL, protect, 0, 0, NULL );
...@@ -154,31 +155,22 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags ) ...@@ -154,31 +155,22 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
LdrLockLoaderLock( 0, NULL, &magic ); LdrLockLoaderLock( 0, NULL, &magic );
if (!LdrGetDllHandle( load_path, flags, libname, &module )) if (!LdrGetDllHandle( load_path, flags, libname, &module ))
{
LdrAddRefDll( 0, module ); LdrAddRefDll( 0, module );
LdrUnlockLoaderLock( 0, magic ); else
goto done; load_library_as_datafile( load_path, flags, libname->Buffer, &module );
}
if (load_library_as_datafile( load_path, flags, libname->Buffer, &module ))
{
LdrUnlockLoaderLock( 0, magic );
goto done;
}
LdrUnlockLoaderLock( 0, magic ); LdrUnlockLoaderLock( 0, magic );
flags |= DONT_RESOLVE_DLL_REFERENCES; /* Just in case */
/* Fallback to normal behaviour */
} }
else
status = LdrLoadDll( load_path, flags, libname, &module );
if (status != STATUS_SUCCESS)
{ {
module = 0; status = LdrLoadDll( load_path, flags, libname, &module );
if (status == STATUS_DLL_NOT_FOUND && (GetVersion() & 0x80000000)) if (!set_ntstatus( status ))
SetLastError( ERROR_DLL_NOT_FOUND ); {
else module = 0;
SetLastError( RtlNtStatusToDosError( status ) ); if (status == STATUS_DLL_NOT_FOUND && (GetVersion() & 0x80000000))
SetLastError( ERROR_DLL_NOT_FOUND );
}
} }
done:
RtlReleasePath( load_path ); RtlReleasePath( load_path );
return module; 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