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
5d088206
Commit
5d088206
authored
Feb 15, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Use the image information data when mapping an image file.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
4a2ad423
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
19 deletions
+16
-19
virtual.c
dlls/ntdll/virtual.c
+16
-19
No files found.
dlls/ntdll/virtual.c
View file @
5d088206
...
@@ -1357,8 +1357,8 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable )
...
@@ -1357,8 +1357,8 @@ static NTSTATUS map_pe_header( void *ptr, size_t size, int fd, BOOL *removable )
*
*
* Map an executable (PE format) image into memory.
* Map an executable (PE format) image into memory.
*/
*/
static
NTSTATUS
map_image
(
HANDLE
hmapping
,
ACCESS_MASK
access
,
int
fd
,
char
*
base
,
SIZE_T
total_size
,
static
NTSTATUS
map_image
(
HANDLE
hmapping
,
ACCESS_MASK
access
,
int
fd
,
SIZE_T
mask
,
SIZE_T
mask
,
SIZE_T
header_size
,
int
shared_fd
,
BOOL
removable
,
PVOID
*
addr_ptr
)
pe_image_info_t
*
image_info
,
int
shared_fd
,
BOOL
removable
,
PVOID
*
addr_ptr
)
{
{
IMAGE_DOS_HEADER
*
dos
;
IMAGE_DOS_HEADER
*
dos
;
IMAGE_NT_HEADERS
*
nt
;
IMAGE_NT_HEADERS
*
nt
;
...
@@ -1366,12 +1366,21 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
...
@@ -1366,12 +1366,21 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
IMAGE_SECTION_HEADER
*
sec
;
IMAGE_SECTION_HEADER
*
sec
;
IMAGE_DATA_DIRECTORY
*
imports
;
IMAGE_DATA_DIRECTORY
*
imports
;
NTSTATUS
status
=
STATUS_CONFLICTING_ADDRESSES
;
NTSTATUS
status
=
STATUS_CONFLICTING_ADDRESSES
;
SIZE_T
header_size
,
total_size
=
image_info
->
map_size
;
int
i
;
int
i
;
off_t
pos
;
off_t
pos
;
sigset_t
sigset
;
sigset_t
sigset
;
struct
stat
st
;
struct
stat
st
;
struct
file_view
*
view
=
NULL
;
struct
file_view
*
view
=
NULL
;
char
*
ptr
,
*
header_end
,
*
header_start
;
char
*
ptr
,
*
header_end
,
*
header_start
;
char
*
base
=
wine_server_get_ptr
(
image_info
->
base
);
if
(
total_size
!=
image_info
->
map_size
)
/* truncated */
{
WARN
(
"Modules larger than 4Gb (%s) not supported
\n
"
,
wine_dbgstr_longlong
(
image_info
->
map_size
)
);
return
STATUS_INVALID_PARAMETER
;
}
if
((
ULONG_PTR
)
base
!=
image_info
->
base
)
base
=
NULL
;
/* zero-map the whole range */
/* zero-map the whole range */
...
@@ -1397,7 +1406,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
...
@@ -1397,7 +1406,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
status
=
FILE_GetNtStatus
();
status
=
FILE_GetNtStatus
();
goto
error
;
goto
error
;
}
}
header_size
=
min
(
header_size
,
st
.
st_size
);
header_size
=
min
(
image_info
->
header_size
,
st
.
st_size
);
if
((
status
=
map_pe_header
(
view
->
base
,
header_size
,
fd
,
&
removable
))
!=
STATUS_SUCCESS
)
goto
error
;
if
((
status
=
map_pe_header
(
view
->
base
,
header_size
,
fd
,
&
removable
))
!=
STATUS_SUCCESS
)
goto
error
;
status
=
STATUS_INVALID_IMAGE_FORMAT
;
/* generic error */
status
=
STATUS_INVALID_IMAGE_FORMAT
;
/* generic error */
...
@@ -1419,7 +1428,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
...
@@ -1419,7 +1428,7 @@ static NTSTATUS map_image( HANDLE hmapping, ACCESS_MASK access, int fd, char *ba
/* check for non page-aligned binary */
/* check for non page-aligned binary */
if
(
nt
->
OptionalHeader
.
SectionAlignment
<=
page_mask
)
if
(
image_info
->
image_flags
&
IMAGE_FLAGS_ImageMappedFlat
)
{
{
/* unaligned sections, this happens for native subsystem binaries */
/* unaligned sections, this happens for native subsystem binaries */
/* in that case Windows simply maps in the whole file */
/* in that case Windows simply maps in the whole file */
...
@@ -1654,35 +1663,23 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S
...
@@ -1654,35 +1663,23 @@ NTSTATUS virtual_map_section( HANDLE handle, PVOID *addr_ptr, ULONG zero_bits, S
if
(
sec_flags
&
SEC_IMAGE
)
if
(
sec_flags
&
SEC_IMAGE
)
{
{
void
*
base
=
wine_server_get_ptr
(
image_info
->
base
);
if
((
ULONG_PTR
)
base
!=
image_info
->
base
)
base
=
NULL
;
size
=
image_info
->
map_size
;
if
(
size
!=
image_info
->
map_size
)
/* truncated */
{
WARN
(
"Modules larger than 4Gb (%s) not supported
\n
"
,
wine_dbgstr_longlong
(
image_info
->
map_size
)
);
res
=
STATUS_INVALID_PARAMETER
;
goto
done
;
}
if
(
shared_file
)
if
(
shared_file
)
{
{
int
shared_fd
,
shared_needs_close
;
int
shared_fd
,
shared_needs_close
;
if
((
res
=
server_get_unix_fd
(
shared_file
,
FILE_READ_DATA
|
FILE_WRITE_DATA
,
if
((
res
=
server_get_unix_fd
(
shared_file
,
FILE_READ_DATA
|
FILE_WRITE_DATA
,
&
shared_fd
,
&
shared_needs_close
,
NULL
,
NULL
)))
goto
done
;
&
shared_fd
,
&
shared_needs_close
,
NULL
,
NULL
)))
goto
done
;
res
=
map_image
(
handle
,
access
,
unix_handle
,
base
,
size
,
mask
,
image_info
->
header_size
,
res
=
map_image
(
handle
,
access
,
unix_handle
,
mask
,
image_info
,
shared_fd
,
needs_close
,
addr_ptr
);
shared_fd
,
needs_close
,
addr_ptr
);
if
(
shared_needs_close
)
close
(
shared_fd
);
if
(
shared_needs_close
)
close
(
shared_fd
);
close_handle
(
shared_file
);
close_handle
(
shared_file
);
}
}
else
else
{
{
res
=
map_image
(
handle
,
access
,
unix_handle
,
base
,
size
,
mask
,
image_info
->
header_size
,
res
=
map_image
(
handle
,
access
,
unix_handle
,
mask
,
image_info
,
-
1
,
needs_close
,
addr_ptr
);
-
1
,
needs_close
,
addr_ptr
);
}
}
if
(
needs_close
)
close
(
unix_handle
);
if
(
needs_close
)
close
(
unix_handle
);
if
(
res
>=
0
)
*
size_ptr
=
size
;
if
(
res
>=
0
)
*
size_ptr
=
image_info
->
map_
size
;
return
res
;
return
res
;
}
}
...
...
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