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
65c37cee
Commit
65c37cee
authored
Aug 26, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use exported APIs instead of virtual_map_section() to load PE modules.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1581fb61
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
57 deletions
+73
-57
loader.c
dlls/ntdll/loader.c
+39
-36
loader.c
dlls/ntdll/unix/loader.c
+28
-9
unix_private.h
dlls/ntdll/unix/unix_private.h
+0
-3
virtual.c
dlls/ntdll/unix/virtual.c
+4
-4
unixlib.h
dlls/ntdll/unixlib.h
+2
-5
No files found.
dlls/ntdll/loader.c
View file @
65c37cee
This diff is collapsed.
Click to expand it.
dlls/ntdll/unix/loader.c
View file @
65c37cee
...
...
@@ -896,6 +896,23 @@ static NTSTATUS CDECL load_so_dll( UNICODE_STRING *nt_name, void **module )
}
/* check a PE library architecture */
static
BOOL
is_valid_binary
(
HMODULE
module
,
const
SECTION_IMAGE_INFORMATION
*
info
)
{
#ifdef __i386__
return
info
->
Machine
==
IMAGE_FILE_MACHINE_I386
;
#elif defined(__arm__)
return
info
->
Machine
==
IMAGE_FILE_MACHINE_ARM
||
info
->
Machine
==
IMAGE_FILE_MACHINE_THUMB
||
info
->
Machine
==
IMAGE_FILE_MACHINE_ARMNT
;
#elif defined(__x86_64__)
/* we don't support 32-bit IL-only builtins yet */
return
info
->
Machine
==
IMAGE_FILE_MACHINE_AMD64
;
#elif defined(__aarch64__)
return
info
->
Machine
==
IMAGE_FILE_MACHINE_ARM64
;
#endif
}
/* check if the library is the correct architecture */
/* only returns false for a valid library of the wrong arch */
static
int
check_library_arch
(
int
fd
)
...
...
@@ -943,7 +960,7 @@ static inline char *prepend( char *buffer, const char *str, size_t len )
*
* Open a file for a new dll. Helper for find_dll_file.
*/
static
NTSTATUS
open_dll_file
(
const
char
*
name
,
void
**
module
,
pe_image_info_t
*
image_info
)
static
NTSTATUS
open_dll_file
(
const
char
*
name
,
void
**
module
,
SECTION_IMAGE_INFORMATION
*
image_info
)
{
struct
builtin_module
*
builtin
;
OBJECT_ATTRIBUTES
attr
=
{
sizeof
(
attr
)
};
...
...
@@ -995,20 +1012,22 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
}
status
=
virtual_map_section
(
mapping
,
module
,
0
,
0
,
NULL
,
&
len
,
0
,
PAGE_EXECUTE_READ
,
image_info
);
NtQuerySection
(
mapping
,
SectionImageInformation
,
image_info
,
sizeof
(
*
image_info
),
NULL
);
status
=
NtMapViewOfSection
(
mapping
,
NtCurrentProcess
(),
module
,
0
,
0
,
NULL
,
&
len
,
ViewShare
,
0
,
PAGE_EXECUTE_READ
);
if
(
status
==
STATUS_IMAGE_NOT_AT_BASE
)
status
=
STATUS_SUCCESS
;
NtClose
(
mapping
);
if
(
status
)
return
status
;
/* ignore non-builtins */
if
(
!
(
image_info
->
image_f
lags
&
IMAGE_FLAGS_WineBuiltin
))
if
(
!
(
image_info
->
u
.
ImageF
lags
&
IMAGE_FLAGS_WineBuiltin
))
{
WARN
(
"%s found in WINEDLLPATH but not a builtin, ignoring
\n
"
,
debugstr_a
(
name
)
);
status
=
STATUS_DLL_NOT_FOUND
;
}
else
if
(
image_info
->
cpu
!=
client_cpu
)
else
if
(
!
is_valid_binary
(
*
module
,
image_info
)
)
{
TRACE
(
"%s is for
CPU %u, continuing search
\n
"
,
debugstr_a
(
name
),
image_info
->
cpu
);
TRACE
(
"%s is for
arch %x, continuing search
\n
"
,
debugstr_a
(
name
),
image_info
->
Machine
);
status
=
STATUS_IMAGE_MACHINE_TYPE_MISMATCH
;
}
...
...
@@ -1026,7 +1045,7 @@ static NTSTATUS open_dll_file( const char *name, void **module, pe_image_info_t
/***********************************************************************
* open_builtin_file
*/
static
NTSTATUS
open_builtin_file
(
char
*
name
,
void
**
module
,
pe_image_info_t
*
image_info
)
static
NTSTATUS
open_builtin_file
(
char
*
name
,
void
**
module
,
SECTION_IMAGE_INFORMATION
*
image_info
)
{
NTSTATUS
status
;
int
fd
;
...
...
@@ -1046,7 +1065,7 @@ static NTSTATUS open_builtin_file( char *name, void **module, pe_image_info_t *i
if
(
!
dlopen_dll
(
name
,
module
))
{
memset
(
image_info
,
0
,
sizeof
(
*
image_info
)
);
image_info
->
image_f
lags
=
IMAGE_FLAGS_WineBuiltin
;
image_info
->
u
.
ImageF
lags
=
IMAGE_FLAGS_WineBuiltin
;
status
=
STATUS_SUCCESS
;
}
else
...
...
@@ -1065,7 +1084,8 @@ static NTSTATUS open_builtin_file( char *name, void **module, pe_image_info_t *i
/***********************************************************************
* load_builtin_dll
*/
static
NTSTATUS
CDECL
load_builtin_dll
(
const
WCHAR
*
name
,
void
**
module
,
pe_image_info_t
*
image_info
)
static
NTSTATUS
CDECL
load_builtin_dll
(
const
WCHAR
*
name
,
void
**
module
,
SECTION_IMAGE_INFORMATION
*
image_info
)
{
unsigned
int
i
,
pos
,
len
,
namelen
,
maxlen
=
0
;
char
*
ptr
,
*
file
;
...
...
@@ -1346,7 +1366,6 @@ static struct unix_funcs unix_funcs =
get_initial_directory
,
get_unix_codepage_data
,
get_locales
,
virtual_map_section
,
virtual_release_address_space
,
exec_process
,
set_show_dot_files
,
...
...
dlls/ntdll/unix/unix_private.h
View file @
65c37cee
...
...
@@ -115,9 +115,6 @@ extern void CDECL get_initial_directory( UNICODE_STRING *dir ) DECLSPEC_HIDDEN;
extern
void
CDECL
get_initial_console
(
HANDLE
*
handle
,
HANDLE
*
std_in
,
HANDLE
*
std_out
,
HANDLE
*
std_err
)
DECLSPEC_HIDDEN
;
extern
USHORT
*
CDECL
get_unix_codepage_data
(
void
)
DECLSPEC_HIDDEN
;
extern
void
CDECL
get_locales
(
WCHAR
*
sys
,
WCHAR
*
user
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
CDECL
virtual_map_section
(
HANDLE
handle
,
PVOID
*
addr_ptr
,
unsigned
short
zero_bits_64
,
SIZE_T
commit_size
,
const
LARGE_INTEGER
*
offset_ptr
,
SIZE_T
*
size_ptr
,
ULONG
alloc_type
,
ULONG
protect
,
pe_image_info_t
*
image_info
)
DECLSPEC_HIDDEN
;
extern
void
CDECL
virtual_release_address_space
(
void
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
CDECL
exec_process
(
UNICODE_STRING
*
path
,
UNICODE_STRING
*
cmdline
,
NTSTATUS
status
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/unix/virtual.c
View file @
65c37cee
...
...
@@ -2181,9 +2181,9 @@ static NTSTATUS map_image_into_view( struct file_view *view, int fd, void *orig_
*
* Map a file section into memory.
*/
NTSTATUS
CDECL
virtual_map_section
(
HANDLE
handle
,
PVOID
*
addr_ptr
,
unsigned
short
zero_bits_64
,
SIZE_T
commit_size
,
const
LARGE_INTEGER
*
offset_ptr
,
SIZE_T
*
size_ptr
,
ULONG
alloc_type
,
ULONG
protect
,
pe_image_info_t
*
image_info
)
static
NTSTATUS
virtual_map_section
(
HANDLE
handle
,
PVOID
*
addr_ptr
,
unsigned
short
zero_bits_64
,
SIZE_T
commit_size
,
const
LARGE_INTEGER
*
offset_ptr
,
SIZE_T
*
size_ptr
,
ULONG
alloc_type
,
ULONG
protect
,
pe_image_info_t
*
image_info
)
{
NTSTATUS
res
;
mem_size_t
full_size
;
...
...
@@ -4163,7 +4163,7 @@ void virtual_fill_image_information( const pe_image_info_t *pe_info, SECTION_IMA
info
->
DllCharacteristics
=
pe_info
->
dll_charact
;
info
->
Machine
=
pe_info
->
machine
;
info
->
ImageContainsCode
=
pe_info
->
contains_code
;
info
->
ImageFlags
=
pe_info
->
image_flags
&
~
(
IMAGE_FLAGS_WineBuiltin
|
IMAGE_FLAGS_WineFakeDll
)
;
info
->
ImageFlags
=
pe_info
->
image_flags
;
info
->
LoaderFlags
=
pe_info
->
loader_flags
;
info
->
ImageFileSize
=
pe_info
->
file_size
;
info
->
CheckSum
=
pe_info
->
checksum
;
...
...
dlls/ntdll/unixlib.h
View file @
65c37cee
...
...
@@ -27,7 +27,7 @@
struct
_DISPATCHER_CONTEXT
;
/* increment this when you change the function table */
#define NTDLL_UNIXLIB_VERSION
99
#define NTDLL_UNIXLIB_VERSION
100
struct
unix_funcs
{
...
...
@@ -79,9 +79,6 @@ struct unix_funcs
void
(
CDECL
*
get_locales
)(
WCHAR
*
sys
,
WCHAR
*
user
);
/* virtual memory functions */
NTSTATUS
(
CDECL
*
virtual_map_section
)(
HANDLE
handle
,
PVOID
*
addr_ptr
,
unsigned
short
zero_bits_64
,
SIZE_T
commit_size
,
const
LARGE_INTEGER
*
offset_ptr
,
SIZE_T
*
size_ptr
,
ULONG
alloc_type
,
ULONG
protect
,
pe_image_info_t
*
image_info
);
void
(
CDECL
*
virtual_release_address_space
)(
void
);
/* thread/process functions */
...
...
@@ -93,7 +90,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
,
pe_image_info_t
*
image_info
);
SECTION_IMAGE_INFORMATION
*
image_info
);
NTSTATUS
(
CDECL
*
unload_builtin_dll
)(
void
*
module
);
void
(
CDECL
*
init_builtin_dll
)(
void
*
module
);
NTSTATUS
(
CDECL
*
unwind_builtin_dll
)(
ULONG
type
,
struct
_DISPATCHER_CONTEXT
*
dispatch
,
...
...
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