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
4792cf31
Commit
4792cf31
authored
May 08, 2014
by
Jacek Caban
Committed by
Alexandre Julliard
May 08, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Always use MAP_SHARED in NtMapViewOfSection.
parent
0ec7907c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
virtual.c
dlls/ntdll/virtual.c
+10
-13
No files found.
dlls/ntdll/virtual.c
View file @
4792cf31
...
@@ -854,11 +854,10 @@ done:
...
@@ -854,11 +854,10 @@ done:
* The csVirtual section must be held by caller.
* The csVirtual section must be held by caller.
*/
*/
static
NTSTATUS
map_file_into_view
(
struct
file_view
*
view
,
int
fd
,
size_t
start
,
size_t
size
,
static
NTSTATUS
map_file_into_view
(
struct
file_view
*
view
,
int
fd
,
size_t
start
,
size_t
size
,
off_t
offset
,
unsigned
int
vprot
,
BOOL
removable
)
off_t
offset
,
unsigned
int
vprot
,
int
flags
,
BOOL
removable
)
{
{
void
*
ptr
;
void
*
ptr
;
int
prot
=
VIRTUAL_GetUnixProt
(
vprot
|
VPROT_COMMITTED
/* make sure it is accessible */
);
int
prot
=
VIRTUAL_GetUnixProt
(
vprot
|
VPROT_COMMITTED
/* make sure it is accessible */
);
BOOL
shared_write
=
(
vprot
&
VPROT_WRITE
)
!=
0
;
assert
(
start
<
view
->
size
);
assert
(
start
<
view
->
size
);
assert
(
start
+
size
<=
view
->
size
);
assert
(
start
+
size
<=
view
->
size
);
...
@@ -871,11 +870,9 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
...
@@ -871,11 +870,9 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
}
}
/* only try mmap if media is not removable (or if we require write access) */
/* only try mmap if media is not removable (or if we require write access) */
if
(
!
removable
||
shared_write
)
if
(
!
removable
||
(
flags
&
MAP_SHARED
)
)
{
{
int
flags
=
MAP_FIXED
|
(
shared_write
?
MAP_SHARED
:
MAP_PRIVATE
);
if
(
mmap
(
(
char
*
)
view
->
base
+
start
,
size
,
prot
,
flags
|
MAP_FIXED
,
fd
,
offset
)
!=
(
void
*
)
-
1
)
if
(
mmap
(
(
char
*
)
view
->
base
+
start
,
size
,
prot
,
flags
,
fd
,
offset
)
!=
(
void
*
)
-
1
)
goto
done
;
goto
done
;
if
((
errno
==
EPERM
)
&&
(
prot
&
PROT_EXEC
))
if
((
errno
==
EPERM
)
&&
(
prot
&
PROT_EXEC
))
...
@@ -885,7 +882,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
...
@@ -885,7 +882,7 @@ static NTSTATUS map_file_into_view( struct file_view *view, int fd, size_t start
/* page-aligned (EINVAL), or because the underlying filesystem */
/* page-aligned (EINVAL), or because the underlying filesystem */
/* does not support mmap() (ENOEXEC,ENODEV), we do it by hand. */
/* does not support mmap() (ENOEXEC,ENODEV), we do it by hand. */
if
((
errno
!=
ENOEXEC
)
&&
(
errno
!=
EINVAL
)
&&
(
errno
!=
ENODEV
))
return
FILE_GetNtStatus
();
if
((
errno
!=
ENOEXEC
)
&&
(
errno
!=
EINVAL
)
&&
(
errno
!=
ENODEV
))
return
FILE_GetNtStatus
();
if
(
shared_write
)
/* we cannot fake shared write
mappings */
if
(
flags
&
MAP_SHARED
)
/* we cannot fake shared
mappings */
{
{
if
(
errno
==
EINVAL
)
return
STATUS_INVALID_PARAMETER
;
if
(
errno
==
EINVAL
)
return
STATUS_INVALID_PARAMETER
;
ERR
(
"shared writable mmap not supported, broken filesystem?
\n
"
);
ERR
(
"shared writable mmap not supported, broken filesystem?
\n
"
);
...
@@ -1097,7 +1094,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
...
@@ -1097,7 +1094,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
if
(
!
st
.
st_size
)
goto
error
;
if
(
!
st
.
st_size
)
goto
error
;
header_size
=
min
(
header_size
,
st
.
st_size
);
header_size
=
min
(
header_size
,
st
.
st_size
);
if
(
map_file_into_view
(
view
,
fd
,
0
,
header_size
,
0
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
if
(
map_file_into_view
(
view
,
fd
,
0
,
header_size
,
0
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
goto
error
;
MAP_PRIVATE
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
goto
error
;
dos
=
(
IMAGE_DOS_HEADER
*
)
ptr
;
dos
=
(
IMAGE_DOS_HEADER
*
)
ptr
;
nt
=
(
IMAGE_NT_HEADERS
*
)(
ptr
+
dos
->
e_lfanew
);
nt
=
(
IMAGE_NT_HEADERS
*
)(
ptr
+
dos
->
e_lfanew
);
header_end
=
ptr
+
ROUND_SIZE
(
0
,
header_size
);
header_end
=
ptr
+
ROUND_SIZE
(
0
,
header_size
);
...
@@ -1122,7 +1119,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
...
@@ -1122,7 +1119,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
/* in that case Windows simply maps in the whole file */
/* 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
,
if
(
map_file_into_view
(
view
,
fd
,
0
,
total_size
,
0
,
VPROT_COMMITTED
|
VPROT_READ
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
goto
error
;
MAP_PRIVATE
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
goto
error
;
/* check that all sections are loaded at the right offset */
/* check that all sections are loaded at the right offset */
if
(
nt
->
OptionalHeader
.
FileAlignment
!=
nt
->
OptionalHeader
.
SectionAlignment
)
goto
error
;
if
(
nt
->
OptionalHeader
.
FileAlignment
!=
nt
->
OptionalHeader
.
SectionAlignment
)
goto
error
;
...
@@ -1176,7 +1173,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
...
@@ -1176,7 +1173,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
sec
->
Characteristics
);
sec
->
Characteristics
);
if
(
map_file_into_view
(
view
,
shared_fd
,
sec
->
VirtualAddress
,
map_size
,
pos
,
if
(
map_file_into_view
(
view
,
shared_fd
,
sec
->
VirtualAddress
,
map_size
,
pos
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITE
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITE
,
FALSE
)
!=
STATUS_SUCCESS
)
MAP_SHARED
,
FALSE
)
!=
STATUS_SUCCESS
)
{
{
ERR_
(
module
)(
"Could not map shared section %.8s
\n
"
,
sec
->
Name
);
ERR_
(
module
)(
"Could not map shared section %.8s
\n
"
,
sec
->
Name
);
goto
error
;
goto
error
;
...
@@ -1193,7 +1190,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
...
@@ -1193,7 +1190,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
map_file_into_view
(
view
,
shared_fd
,
base
,
end
-
base
,
map_file_into_view
(
view
,
shared_fd
,
base
,
end
-
base
,
pos
+
(
base
-
sec
->
VirtualAddress
),
pos
+
(
base
-
sec
->
VirtualAddress
),
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
FALSE
);
MAP_PRIVATE
,
FALSE
);
}
}
pos
+=
map_size
;
pos
+=
map_size
;
continue
;
continue
;
...
@@ -1215,7 +1212,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
...
@@ -1215,7 +1212,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
end
<
file_start
||
end
<
file_start
||
map_file_into_view
(
view
,
fd
,
sec
->
VirtualAddress
,
file_size
,
file_start
,
map_file_into_view
(
view
,
fd
,
sec
->
VirtualAddress
,
file_size
,
file_start
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
VPROT_COMMITTED
|
VPROT_READ
|
VPROT_WRITECOPY
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
MAP_PRIVATE
,
!
dup_mapping
)
!=
STATUS_SUCCESS
)
{
{
ERR_
(
module
)(
"Could not map section %.8s, file probably truncated
\n
"
,
sec
->
Name
);
ERR_
(
module
)(
"Could not map section %.8s, file probably truncated
\n
"
,
sec
->
Name
);
goto
error
;
goto
error
;
...
@@ -2630,7 +2627,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
...
@@ -2630,7 +2627,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
TRACE
(
"handle=%p size=%lx offset=%x%08x
\n
"
,
TRACE
(
"handle=%p size=%lx offset=%x%08x
\n
"
,
handle
,
size
,
offset
.
u
.
HighPart
,
offset
.
u
.
LowPart
);
handle
,
size
,
offset
.
u
.
HighPart
,
offset
.
u
.
LowPart
);
res
=
map_file_into_view
(
view
,
unix_handle
,
0
,
size
,
offset
.
QuadPart
,
vprot
,
!
dup_mapping
);
res
=
map_file_into_view
(
view
,
unix_handle
,
0
,
size
,
offset
.
QuadPart
,
vprot
,
MAP_SHARED
,
!
dup_mapping
);
if
(
res
==
STATUS_SUCCESS
)
if
(
res
==
STATUS_SUCCESS
)
{
{
*
addr_ptr
=
view
->
base
;
*
addr_ptr
=
view
->
base
;
...
...
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