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
646ab89f
Commit
646ab89f
authored
Jan 04, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support mapping non page-aligned binaries for SEC_IMAGE mappings.
parent
28356337
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
8 deletions
+48
-8
virtual.c
dlls/ntdll/virtual.c
+42
-5
mapping.c
server/mapping.c
+6
-3
No files found.
dlls/ntdll/virtual.c
View file @
646ab89f
...
...
@@ -882,6 +882,41 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, DWORD total_size
goto
error
;
}
/* check for non page-aligned binary */
if
(
nt
->
OptionalHeader
.
SectionAlignment
<=
page_mask
)
{
/* unaligned sections, this happens for native subsystem binaries */
/* in that case Windows simply maps in the whole file */
if
(
map_file_into_view
(
view
,
fd
,
0
,
total_size
,
0
,
VPROT_COMMITTED
|
VPROT_READ
,
removable
)
!=
STATUS_SUCCESS
)
goto
error
;
/* check that all sections are loaded at the right offset */
for
(
i
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
)
{
if
(
sec
[
i
].
VirtualAddress
!=
sec
[
i
].
PointerToRawData
)
goto
error
;
/* Windows refuses to load in that case too */
}
/* set the image protections */
VIRTUAL_SetProt
(
view
,
ptr
,
total_size
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
|
VPROT_EXEC
);
/* perform relocations if necessary */
/* FIXME: not 100% compatible, Windows doesn't do this for non page-aligned binaries */
if
(
ptr
!=
base
)
{
const
IMAGE_DATA_DIRECTORY
*
relocs
;
relocs
=
&
nt
->
OptionalHeader
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_BASERELOC
];
if
(
relocs
->
VirtualAddress
&&
relocs
->
Size
)
do_relocations
(
ptr
,
relocs
,
ptr
-
base
,
total_size
);
}
goto
done
;
}
/* map all the sections */
for
(
i
=
pos
=
0
;
i
<
nt
->
FileHeader
.
NumberOfSections
;
i
++
,
sec
++
)
...
...
@@ -994,11 +1029,6 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, DWORD total_size
}
}
if
(
!
removable
)
/* don't keep handle open on removable media */
NtDuplicateObject
(
GetCurrentProcess
(),
hmapping
,
GetCurrentProcess
(),
&
view
->
mapping
,
0
,
0
,
DUPLICATE_SAME_ACCESS
);
/* set the image protections */
sec
=
(
IMAGE_SECTION_HEADER
*
)((
char
*
)
&
nt
->
OptionalHeader
+
nt
->
FileHeader
.
SizeOfOptionalHeader
);
...
...
@@ -1011,6 +1041,13 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, DWORD total_size
if
(
sec
->
Characteristics
&
IMAGE_SCN_MEM_EXECUTE
)
vprot
|=
VPROT_EXEC
;
VIRTUAL_SetProt
(
view
,
ptr
+
sec
->
VirtualAddress
,
size
,
vprot
);
}
done:
if
(
!
removable
)
/* don't keep handle open on removable media */
NtDuplicateObject
(
GetCurrentProcess
(),
hmapping
,
GetCurrentProcess
(),
&
view
->
mapping
,
0
,
0
,
DUPLICATE_SAME_ACCESS
);
RtlLeaveCriticalSection
(
&
csVirtual
);
*
addr_ptr
=
ptr
;
...
...
server/mapping.c
View file @
646ab89f
...
...
@@ -103,8 +103,10 @@ static void init_page_size(void)
#define ROUND_ADDR(addr) \
((int)(addr) & ~page_mask)
#define ROUND_SIZE(addr,size) \
(((int)(size) + ((int)(addr) & page_mask) + page_mask) & ~page_mask)
#define ROUND_SIZE_MASK(addr,size,mask) \
(((int)(size) + ((int)(addr) & (mask)) + (mask)) & ~(mask))
#define ROUND_SIZE(addr,size) ROUND_SIZE_MASK( addr, size, page_mask )
/* find the shared PE mapping for a given mapping */
...
...
@@ -236,7 +238,8 @@ static int get_image_params( struct mapping *mapping )
mapping
->
size_low
=
ROUND_SIZE
(
0
,
nt
.
OptionalHeader
.
SizeOfImage
);
mapping
->
size_high
=
0
;
mapping
->
base
=
(
void
*
)
nt
.
OptionalHeader
.
ImageBase
;
mapping
->
header_size
=
ROUND_SIZE
(
mapping
->
base
,
nt
.
OptionalHeader
.
SizeOfHeaders
);
mapping
->
header_size
=
ROUND_SIZE_MASK
(
mapping
->
base
,
nt
.
OptionalHeader
.
SizeOfHeaders
,
nt
.
OptionalHeader
.
SectionAlignment
-
1
);
mapping
->
protect
=
VPROT_IMAGE
;
/* sanity check */
...
...
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