Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
63b62953
Commit
63b62953
authored
Jan 21, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Check for valid architecture before mapping the module.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
7203ad0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
37 deletions
+39
-37
loader.c
dlls/ntdll/loader.c
+16
-17
loader.c
dlls/ntdll/unix/loader.c
+23
-20
No files found.
dlls/ntdll/loader.c
View file @
63b62953
...
...
@@ -1985,6 +1985,8 @@ static BOOL convert_to_pe64( HMODULE module, const SECTION_IMAGE_INFORMATION *in
void
*
addr
=
module
;
ULONG
i
,
old_prot
;
if
(
nt
->
OptionalHeader
.
Magic
!=
IMAGE_NT_OPTIONAL_HDR32_MAGIC
)
return
TRUE
;
/* already 64-bit */
TRACE
(
"%p
\n
"
,
module
);
if
(
NtProtectVirtualMemory
(
NtCurrentProcess
(),
&
addr
,
&
size
,
PAGE_READWRITE
,
&
old_prot
))
...
...
@@ -2305,33 +2307,30 @@ static NTSTATUS open_dll_file( UNICODE_STRING *nt_name, WINE_MODREF **pwm, void
NULL
,
&
size
,
PAGE_EXECUTE_READ
,
SEC_IMAGE
,
handle
);
if
(
!
status
)
{
NtQuerySection
(
mapping
,
SectionImageInformation
,
image_info
,
sizeof
(
*
image_info
),
NULL
);
if
(
!
is_valid_binary
(
handle
,
image_info
))
{
TRACE
(
"%s is for arch %x, continuing search
\n
"
,
debugstr_us
(
nt_name
),
image_info
->
Machine
);
status
=
STATUS_IMAGE_MACHINE_TYPE_MISMATCH
;
NtClose
(
mapping
);
}
}
NtClose
(
handle
);
if
(
!
status
)
{
if
(
*
module
)
{
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
}
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
&&
!
is_valid_binary
(
handle
,
image_info
))
{
TRACE
(
"%s is for arch %x, continuing search
\n
"
,
debugstr_us
(
nt_name
),
image_info
->
Machine
);
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
status
=
STATUS_IMAGE_MACHINE_TYPE_MISMATCH
;
}
#ifdef _WIN64
if
(
!
status
&&
image_info
->
Machine
!=
IMAGE_FILE_MACHINE_AMD64
&&
image_info
->
Machine
!=
IMAGE_FILE_MACHINE_ARM64
)
{
if
(
!
convert_to_pe64
(
*
module
,
image_info
))
status
=
STATUS_INVALID_IMAGE_FORMAT
;
}
if
(
!
status
&&
!
convert_to_pe64
(
*
module
,
image_info
))
status
=
STATUS_INVALID_IMAGE_FORMAT
;
#endif
NtClose
(
handle
);
NtClose
(
mapping
);
}
return
status
;
}
...
...
dlls/ntdll/unix/loader.c
View file @
63b62953
...
...
@@ -1077,7 +1077,7 @@ 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
)
static
BOOL
is_valid_binary
(
const
SECTION_IMAGE_INFORMATION
*
info
)
{
#ifdef __i386__
return
info
->
Machine
==
IMAGE_FILE_MACHINE_I386
;
...
...
@@ -1138,7 +1138,7 @@ static inline char *prepend( char *buffer, const char *str, size_t len )
/***********************************************************************
* open_dll_file
*
* Open a file for a new dll. Helper for
find_dll
_file.
* Open a file for a new dll. Helper for
open_builtin
_file.
*/
static
NTSTATUS
open_dll_file
(
const
char
*
name
,
void
**
module
,
SECTION_IMAGE_INFORMATION
*
image_info
)
{
...
...
@@ -1187,37 +1187,40 @@ static NTSTATUS open_dll_file( const char *name, void **module, SECTION_IMAGE_IN
NtClose
(
handle
);
if
(
status
)
return
status
;
if
(
*
module
)
{
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
}
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
->
u
.
ImageFlags
&
IMAGE_FLAGS_WineBuiltin
))
{
WARN
(
"%s found in WINEDLLPATH but not a builtin, ignoring
\n
"
,
debugstr_a
(
name
)
);
status
=
STATUS_DLL_NOT_FOUND
;
}
else
if
(
!
is_valid_binary
(
*
module
,
image_info
))
else
if
(
!
is_valid_binary
(
image_info
))
{
TRACE
(
"%s is for arch %x, continuing search
\n
"
,
debugstr_a
(
name
),
image_info
->
Machine
);
status
=
STATUS_IMAGE_MACHINE_TYPE_MISMATCH
;
}
if
(
!
status
)
status
=
add_builtin_module
(
*
module
,
NULL
,
&
st
);
if
(
status
)
else
{
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
if
(
*
module
)
{
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
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
;
if
(
!
status
)
{
status
=
add_builtin_module
(
*
module
,
NULL
,
&
st
);
if
(
status
)
{
NtUnmapViewOfSection
(
NtCurrentProcess
(),
*
module
);
*
module
=
NULL
;
}
}
}
NtClose
(
mapping
);
return
status
;
}
...
...
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