Commit d7bdd5a5 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Pass the full NT path name to load_builtin_dll().

parent 9419eadd
......@@ -2369,34 +2369,28 @@ static NTSTATUS load_so_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name,
/***********************************************************************
* load_builtin_dll
*/
static NTSTATUS load_builtin_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name,
static NTSTATUS load_builtin_dll( LPCWSTR load_path, UNICODE_STRING *nt_name,
DWORD flags, WINE_MODREF** pwm )
{
const WCHAR *name, *p;
NTSTATUS status;
void *module, *unix_entry = NULL;
SECTION_IMAGE_INFORMATION image_info;
/* Fix the name in case we have a full path and extension */
name = nt_name->Buffer;
if ((p = wcsrchr( name, '\\' ))) name = p + 1;
if ((p = wcsrchr( name, '/' ))) name = p + 1;
TRACE("Trying built-in %s\n", debugstr_us(nt_name));
TRACE("Trying built-in %s\n", debugstr_w(name));
status = unix_funcs->load_builtin_dll( name, &module, &unix_entry, &image_info );
status = unix_funcs->load_builtin_dll( nt_name, &module, &unix_entry, &image_info );
if (status) return status;
if ((*pwm = get_modref( module ))) /* already loaded */
{
if ((*pwm)->ldr.LoadCount != -1) (*pwm)->ldr.LoadCount++;
TRACE( "Found %s for %s at %p, count=%d\n",
debugstr_w((*pwm)->ldr.FullDllName.Buffer), debugstr_w(name),
debugstr_us(&(*pwm)->ldr.FullDllName), debugstr_us(nt_name),
(*pwm)->ldr.DllBase, (*pwm)->ldr.LoadCount);
return STATUS_SUCCESS;
}
TRACE( "loading %s from %s\n", debugstr_w(name), debugstr_us(nt_name) );
TRACE( "loading %s\n", debugstr_us(nt_name) );
status = build_module( load_path, nt_name, &module, &image_info, NULL, flags, pwm );
if (!status) (*pwm)->unix_entry = unix_entry;
else if (module) unix_funcs->unload_builtin_dll( module );
......
......@@ -1177,16 +1177,15 @@ static inline char *prepend( char *buffer, const char *str, size_t len )
*
* Open a file for a new dll. Helper for open_builtin_file.
*/
static NTSTATUS open_dll_file( const char *name, HANDLE *mapping, void **module,
static NTSTATUS open_dll_file( const char *name, OBJECT_ATTRIBUTES *attr, HANDLE *mapping, void **module,
SECTION_IMAGE_INFORMATION *image_info, struct stat *st )
{
struct builtin_module *builtin;
OBJECT_ATTRIBUTES attr = { sizeof(attr) };
LARGE_INTEGER size;
NTSTATUS status;
HANDLE handle;
if ((status = open_unix_file( &handle, name, GENERIC_READ | SYNCHRONIZE, &attr, 0,
if ((status = open_unix_file( &handle, name, GENERIC_READ | SYNCHRONIZE, attr, 0,
FILE_SHARE_READ | FILE_SHARE_DELETE, FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE, NULL, 0 )))
{
......@@ -1244,13 +1243,13 @@ static NTSTATUS open_dll_file( const char *name, HANDLE *mapping, void **module,
/***********************************************************************
* open_builtin_file
*/
static NTSTATUS open_builtin_file( char *name, HANDLE *mapping, void **module,
static NTSTATUS open_builtin_file( char *name, OBJECT_ATTRIBUTES *attr, HANDLE *mapping, void **module,
SECTION_IMAGE_INFORMATION *image_info, struct stat *st )
{
NTSTATUS status;
int fd;
status = open_dll_file( name, mapping, module, image_info, st );
status = open_dll_file( name, attr, mapping, module, image_info, st );
if (status != STATUS_DLL_NOT_FOUND) return status;
/* try .so file */
......@@ -1305,17 +1304,24 @@ static NTSTATUS map_builtin_module( HANDLE mapping, void **module, struct stat *
/***********************************************************************
* load_builtin_dll
*/
static NTSTATUS CDECL load_builtin_dll( const WCHAR *name, void **module, void **unix_entry,
static NTSTATUS CDECL load_builtin_dll( UNICODE_STRING *nt_name, void **module, void **unix_entry,
SECTION_IMAGE_INFORMATION *image_info )
{
unsigned int i, pos, len, namelen, maxlen = 0;
unsigned int i, pos, namepos, namelen, maxlen = 0;
unsigned int len = nt_name->Length / sizeof(WCHAR);
char *ptr = NULL, *file, *ext = NULL;
OBJECT_ATTRIBUTES attr;
NTSTATUS status = STATUS_DLL_NOT_FOUND;
BOOL found_image = FALSE;
HANDLE mapping;
struct stat st;
len = wcslen( name );
for (i = namepos = 0; i < len; i++)
if (nt_name->Buffer[i] == '/' || nt_name->Buffer[i] == '\\') namepos = i + 1;
len -= namepos;
if (!len) return STATUS_DLL_NOT_FOUND;
InitializeObjectAttributes( &attr, nt_name, 0, 0, NULL );
if (build_dir) maxlen = strlen(build_dir) + sizeof("/programs/") + len;
maxlen = max( maxlen, dll_path_maxlen + 1 ) + len + sizeof(".so");
......@@ -1325,8 +1331,8 @@ static NTSTATUS CDECL load_builtin_dll( const WCHAR *name, void **module, void *
/* we don't want to depend on the current codepage here */
for (i = 0; i < len; i++)
{
if (name[i] > 127) goto done;
file[pos + i] = (char)name[i];
if (nt_name->Buffer[namepos + i] > 127) goto done;
file[pos + i] = (char)nt_name->Buffer[namepos + i];
if (file[pos + i] >= 'A' && file[pos + i] <= 'Z') file[pos + i] += 'a' - 'A';
else if (file[pos + i] == '.') ext = file + pos + i;
}
......@@ -1342,7 +1348,7 @@ static NTSTATUS CDECL load_builtin_dll( const WCHAR *name, void **module, void *
ptr = prepend( ptr, ptr, namelen );
ptr = prepend( ptr, "/dlls", sizeof("/dlls") - 1 );
ptr = prepend( ptr, build_dir, strlen(build_dir) );
status = open_builtin_file( ptr, &mapping, module, image_info, &st );
status = open_builtin_file( ptr, &attr, &mapping, module, image_info, &st );
if (status != STATUS_DLL_NOT_FOUND) goto done;
/* now as a program */
......@@ -1353,7 +1359,7 @@ static NTSTATUS CDECL load_builtin_dll( const WCHAR *name, void **module, void *
ptr = prepend( ptr, ptr, namelen );
ptr = prepend( ptr, "/programs", sizeof("/programs") - 1 );
ptr = prepend( ptr, build_dir, strlen(build_dir) );
status = open_builtin_file( ptr, &mapping, module, image_info, &st );
status = open_builtin_file( ptr, &attr, &mapping, module, image_info, &st );
if (status != STATUS_DLL_NOT_FOUND) goto done;
}
......@@ -1361,13 +1367,13 @@ static NTSTATUS CDECL load_builtin_dll( const WCHAR *name, void **module, void *
{
file[pos + len + 1] = 0;
ptr = prepend( file + pos, dll_paths[i], strlen(dll_paths[i]) );
status = open_builtin_file( ptr, &mapping, module, image_info, &st );
status = open_builtin_file( ptr, &attr, &mapping, module, image_info, &st );
if (status == STATUS_IMAGE_MACHINE_TYPE_MISMATCH) found_image = TRUE;
else if (status != STATUS_DLL_NOT_FOUND) goto done;
}
if (found_image) status = STATUS_IMAGE_MACHINE_TYPE_MISMATCH;
WARN( "cannot find builtin library for %s\n", debugstr_w(name) );
WARN( "cannot find builtin library for %s\n", debugstr_us(nt_name) );
done:
if (!status && !*module)
......@@ -1495,15 +1501,23 @@ found:
*/
static void load_ntdll(void)
{
static WCHAR path[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\','n','t','d','l','l','.','d','l','l',0};
NTSTATUS status;
SECTION_IMAGE_INFORMATION info;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING str;
HANDLE mapping;
struct stat st;
void *module;
char *name = build_path( dll_dir, "ntdll.dll.so" );
str.Buffer = path;
str.Length = sizeof(path) - sizeof(WCHAR);
str.MaximumLength = sizeof(path);
InitializeObjectAttributes( &attr, &str, 0, 0, NULL );
name[strlen(name) - 3] = 0; /* remove .so */
status = open_builtin_file( name, &mapping, &module, &info, &st );
status = open_builtin_file( name, &attr, &mapping, &module, &info, &st );
if (!status && !module)
{
status = map_builtin_module( mapping, &module, &st );
......
......@@ -27,7 +27,7 @@
struct _DISPATCHER_CONTEXT;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 107
#define NTDLL_UNIXLIB_VERSION 108
struct unix_funcs
{
......@@ -87,7 +87,7 @@ struct unix_funcs
/* loader functions */
NTSTATUS (CDECL *load_so_dll)( UNICODE_STRING *nt_name, void **module );
NTSTATUS (CDECL *load_builtin_dll)( const WCHAR *name, void **module, void **unix_entry,
NTSTATUS (CDECL *load_builtin_dll)( UNICODE_STRING *name, void **module, void **unix_entry,
SECTION_IMAGE_INFORMATION *image_info );
NTSTATUS (CDECL *unload_builtin_dll)( void *module );
void (CDECL *init_builtin_dll)( void *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