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
d5d0738f
Commit
d5d0738f
authored
May 19, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Tweak the file mapping permission checks some more, with tests.
parent
d4e1d887
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
7 deletions
+39
-7
virtual.c
dlls/kernel32/tests/virtual.c
+34
-1
virtual.c
dlls/kernel32/virtual.c
+1
-2
virtual.c
dlls/ntdll/virtual.c
+3
-3
mapping.c
server/mapping.c
+1
-1
No files found.
dlls/kernel32/tests/virtual.c
View file @
d5d0738f
...
...
@@ -328,7 +328,7 @@ static void test_MapViewOfFile(void)
{
static
const
char
testfile
[]
=
"testfile.xxx"
;
const
char
*
name
;
HANDLE
file
,
mapping
;
HANDLE
file
,
mapping
,
map2
;
void
*
ptr
,
*
ptr2
;
MEMORY_BASIC_INFORMATION
info
;
BOOL
ret
;
...
...
@@ -365,6 +365,39 @@ static void test_MapViewOfFile(void)
ptr
=
MapViewOfFile
(
mapping
,
FILE_MAP_WRITE
,
0
,
0
,
4096
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
FILE_MAP_READ
|
FILE_MAP_WRITE
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ptr
=
MapViewOfFile
(
map2
,
FILE_MAP_WRITE
,
0
,
0
,
4096
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile FILE_MAP_WRITE error %u
\n
"
,
GetLastError
()
);
UnmapViewOfFile
(
ptr
);
CloseHandle
(
map2
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
FILE_MAP_READ
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ptr
=
MapViewOfFile
(
map2
,
FILE_MAP_WRITE
,
0
,
0
,
4096
);
if
(
!
ptr
)
{
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
0
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ok
(
!
ptr
,
"MapViewOfFile succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"Wrong error %d
\n
"
,
GetLastError
()
);
CloseHandle
(
map2
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
mapping
,
GetCurrentProcess
(),
&
map2
,
FILE_MAP_READ
,
FALSE
,
0
);
ok
(
ret
,
"DuplicateHandle failed error %u
\n
"
,
GetLastError
());
ptr
=
MapViewOfFile
(
map2
,
0
,
0
,
0
,
4096
);
ok
(
ptr
!=
NULL
,
"MapViewOfFile NO_ACCESS error %u
\n
"
,
GetLastError
()
);
}
else
win_skip
(
"no access checks on win9x
\n
"
);
UnmapViewOfFile
(
ptr
);
CloseHandle
(
map2
);
CloseHandle
(
mapping
);
/* read-only mapping */
...
...
dlls/kernel32/virtual.c
View file @
d5d0738f
...
...
@@ -539,9 +539,8 @@ LPVOID WINAPI MapViewOfFileEx( HANDLE handle, DWORD access,
offset
.
u
.
HighPart
=
offset_high
;
if
(
access
&
FILE_MAP_WRITE
)
protect
=
PAGE_READWRITE
;
else
if
(
access
&
FILE_MAP_READ
)
protect
=
PAGE_READONLY
;
else
if
(
access
&
FILE_MAP_COPY
)
protect
=
PAGE_WRITECOPY
;
else
protect
=
PAGE_
NOACCESS
;
else
protect
=
PAGE_
READONLY
;
if
(
access
&
FILE_MAP_EXECUTE
)
protect
<<=
4
;
...
...
dlls/ntdll/virtual.c
View file @
d5d0738f
...
...
@@ -2288,18 +2288,18 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
switch
(
protect
)
{
case
PAGE_NOACCESS
:
access
=
SECTION_QUERY
;
access
=
0
;
break
;
case
PAGE_READWRITE
:
case
PAGE_EXECUTE_READWRITE
:
access
=
SECTION_
QUERY
|
SECTION_
MAP_WRITE
;
access
=
SECTION_MAP_WRITE
;
break
;
case
PAGE_READONLY
:
case
PAGE_WRITECOPY
:
case
PAGE_EXECUTE
:
case
PAGE_EXECUTE_READ
:
case
PAGE_EXECUTE_WRITECOPY
:
access
=
SECTION_
QUERY
|
SECTION_
MAP_READ
;
access
=
SECTION_MAP_READ
;
break
;
default:
return
STATUS_INVALID_PARAMETER
;
...
...
server/mapping.c
View file @
d5d0738f
...
...
@@ -562,7 +562,7 @@ DECL_HANDLER(get_mapping_info)
struct
fd
*
fd
;
if
((
mapping
=
(
struct
mapping
*
)
get_handle_obj
(
current
->
process
,
req
->
handle
,
req
->
access
|
SECTION_QUERY
,
&
mapping_ops
)))
req
->
access
,
&
mapping_ops
)))
{
reply
->
size
=
mapping
->
size
;
reply
->
protect
=
mapping
->
protect
;
...
...
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