Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
d7bdd5a5
Commit
d7bdd5a5
authored
Feb 09, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Pass the full NT path name to load_builtin_dll().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
9419eadd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
28 deletions
+36
-28
loader.c
dlls/ntdll/loader.c
+5
-11
loader.c
dlls/ntdll/unix/loader.c
+29
-15
unixlib.h
dlls/ntdll/unixlib.h
+2
-2
No files found.
dlls/ntdll/loader.c
View file @
d7bdd5a5
...
...
@@ -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
);
...
...
dlls/ntdll/unix/loader.c
View file @
d7bdd5a5
...
...
@@ -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
(
n
ame
[
i
]
>
127
)
goto
done
;
file
[
pos
+
i
]
=
(
char
)
n
ame
[
i
];
if
(
n
t_name
->
Buffer
[
namepos
+
i
]
>
127
)
goto
done
;
file
[
pos
+
i
]
=
(
char
)
n
t_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
);
...
...
dlls/ntdll/unixlib.h
View file @
d7bdd5a5
...
...
@@ -27,7 +27,7 @@
struct
_DISPATCHER_CONTEXT
;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION 10
7
#define NTDLL_UNIXLIB_VERSION 10
8
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment