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
43a4401e
Commit
43a4401e
authored
Feb 13, 2019
by
Piotr Caban
Committed by
Alexandre Julliard
Feb 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add file mapping tests on readonly file.
Signed-off-by:
Piotr Caban
<
piotr@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
01b8a795
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
7 deletions
+34
-7
virtual.c
dlls/kernel32/tests/virtual.c
+34
-7
No files found.
dlls/kernel32/tests/virtual.c
View file @
43a4401e
...
@@ -3889,7 +3889,7 @@ static void *map_view_of_file(HANDLE handle, DWORD access)
...
@@ -3889,7 +3889,7 @@ static void *map_view_of_file(HANDLE handle, DWORD access)
return
addr
;
return
addr
;
}
}
static
void
test_mapping
(
HANDLE
hfile
,
DWORD
sec_flags
)
static
void
test_mapping
(
HANDLE
hfile
,
DWORD
sec_flags
,
BOOL
readonly
)
{
{
static
const
DWORD
page_prot
[]
=
static
const
DWORD
page_prot
[]
=
{
{
...
@@ -3940,12 +3940,26 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -3940,12 +3940,26 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
MEMORY_BASIC_INFORMATION
info
,
nt_info
;
MEMORY_BASIC_INFORMATION
info
,
nt_info
;
BOOL
anon_mapping
=
(
hfile
==
INVALID_HANDLE_VALUE
);
BOOL
anon_mapping
=
(
hfile
==
INVALID_HANDLE_VALUE
);
trace
(
"testing %s mapping flags %08x
\n
"
,
anon_mapping
?
"anonymous"
:
"file"
,
sec_flags
);
trace
(
"testing %s mapping flags %08x %s
\n
"
,
anon_mapping
?
"anonymous"
:
"file"
,
sec_flags
,
readonly
?
"readonly file"
:
""
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
page_prot
);
i
++
)
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
page_prot
);
i
++
)
{
{
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
page_prot
[
i
]
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
page_prot
[
i
]
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
if
(
readonly
&&
(
page_prot
[
i
]
==
PAGE_READWRITE
||
page_prot
[
i
]
==
PAGE_EXECUTE_READ
||
page_prot
[
i
]
==
PAGE_EXECUTE_READWRITE
||
page_prot
[
i
]
==
PAGE_EXECUTE_WRITECOPY
))
{
todo_wine_if
(
page_prot
[
i
]
==
PAGE_EXECUTE_READ
||
page_prot
[
i
]
==
PAGE_EXECUTE_WRITECOPY
)
{
ok
(
!
hmap
,
"%d: CreateFileMapping(%04x) should fail
\n
"
,
i
,
page_prot
[
i
]);
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
||
broken
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
),
"expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
}
if
(
hmap
)
CloseHandle
(
hmap
);
continue
;
}
if
(
page_prot
[
i
]
==
PAGE_NOACCESS
)
if
(
page_prot
[
i
]
==
PAGE_NOACCESS
)
{
{
HANDLE
hmap2
;
HANDLE
hmap2
;
...
@@ -3958,7 +3972,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -3958,7 +3972,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
if
(
sec_flags
&
SEC_IMAGE
)
if
(
sec_flags
&
SEC_IMAGE
)
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
PAGE_WRITECOPY
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
PAGE_WRITECOPY
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
else
else
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
PAGE_READ
WRITE
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
hmap
=
CreateFileMappingW
(
hfile
,
NULL
,
PAGE_READ
ONLY
|
sec_flags
,
0
,
si
.
dwPageSize
,
NULL
);
ok
(
hmap
!=
0
,
"CreateFileMapping(PAGE_READWRITE) error %d
\n
"
,
GetLastError
());
ok
(
hmap
!=
0
,
"CreateFileMapping(PAGE_READWRITE) error %d
\n
"
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
SetLastError
(
0xdeadbeef
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
hmap
,
GetCurrentProcess
(),
&
hmap2
,
0
,
FALSE
,
0
);
ret
=
DuplicateHandle
(
GetCurrentProcess
(),
hmap
,
GetCurrentProcess
(),
&
hmap2
,
0
,
FALSE
,
0
);
...
@@ -3968,7 +3982,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -3968,7 +3982,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
}
}
if
(
page_prot
[
i
]
==
PAGE_EXECUTE
)
if
(
page_prot
[
i
]
==
PAGE_EXECUTE
)
{
{
ok
(
!
hmap
,
"CreateFileMapping(PAGE_
NOACCESS
) should fail
\n
"
);
ok
(
!
hmap
,
"CreateFileMapping(PAGE_
EXECUTE
) should fail
\n
"
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
continue
;
continue
;
...
@@ -4101,12 +4115,15 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -4101,12 +4115,15 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
continue
;
continue
;
}
}
todo_wine_if
(
readonly
&&
page_prot
[
k
]
==
PAGE_WRITECOPY
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x, requested prot %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x, requested prot %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
todo_wine_if
(
readonly
&&
page_prot
[
k
]
==
PAGE_WRITECOPY
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
old_prot
==
prev_prot
,
"got %#x, expected %#x
\n
"
,
old_prot
,
prev_prot
);
ok
(
old_prot
==
prev_prot
,
"got %#x, expected %#x
\n
"
,
old_prot
,
prev_prot
);
prev_prot
=
actual_prot
;
prev_prot
=
actual_prot
;
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"%d: VirtualQuery failed %d
\n
"
,
j
,
GetLastError
());
ok
(
ret
,
"%d: VirtualQuery failed %d
\n
"
,
j
,
GetLastError
());
todo_wine_if
(
readonly
&&
page_prot
[
k
]
==
PAGE_WRITECOPY
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
info
.
Protect
==
actual_prot
,
ok
(
info
.
Protect
==
actual_prot
,
"VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x
\n
"
,
"VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x
\n
"
,
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
],
info
.
Protect
);
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
],
info
.
Protect
);
...
@@ -4161,6 +4178,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -4161,6 +4178,7 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
if
(
!
anon_mapping
&&
is_compatible_protection
(
alloc_prot
,
PAGE_WRITECOPY
))
if
(
!
anon_mapping
&&
is_compatible_protection
(
alloc_prot
,
PAGE_WRITECOPY
))
{
{
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
PAGE_WRITECOPY
,
&
old_prot
);
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
PAGE_WRITECOPY
,
&
old_prot
);
todo_wine_if
(
readonly
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
);
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
);
if
(
ret
)
*
(
DWORD
*
)
base
=
0xdeadbeef
;
if
(
ret
)
*
(
DWORD
*
)
base
=
0xdeadbeef
;
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
...
@@ -4187,7 +4205,9 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -4187,7 +4205,9 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
continue
;
continue
;
}
}
todo_wine_if
(
readonly
&&
page_prot
[
k
]
==
PAGE_WRITECOPY
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x, requested prot %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x, requested prot %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
todo_wine_if
(
readonly
&&
page_prot
[
k
]
==
PAGE_WRITECOPY
&&
view
[
j
].
prot
!=
PAGE_WRITECOPY
)
ok
(
old_prot
==
prev_prot
,
"got %#x, expected %#x
\n
"
,
old_prot
,
prev_prot
);
ok
(
old_prot
==
prev_prot
,
"got %#x, expected %#x
\n
"
,
old_prot
,
prev_prot
);
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
...
@@ -4226,7 +4246,14 @@ static void test_mappings(void)
...
@@ -4226,7 +4246,14 @@ static void test_mappings(void)
SetFilePointer
(
hfile
,
si
.
dwPageSize
,
NULL
,
FILE_BEGIN
);
SetFilePointer
(
hfile
,
si
.
dwPageSize
,
NULL
,
FILE_BEGIN
);
SetEndOfFile
(
hfile
);
SetEndOfFile
(
hfile
);
test_mapping
(
hfile
,
SEC_COMMIT
);
test_mapping
(
hfile
,
SEC_COMMIT
,
FALSE
);
CloseHandle
(
hfile
);
hfile
=
CreateFileA
(
file_name
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"CreateFile(%s) error %d
\n
"
,
file_name
,
GetLastError
());
test_mapping
(
hfile
,
SEC_COMMIT
,
TRUE
);
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
DeleteFileA
(
file_name
);
DeleteFileA
(
file_name
);
...
@@ -4238,12 +4265,12 @@ static void test_mappings(void)
...
@@ -4238,12 +4265,12 @@ static void test_mappings(void)
hfile
=
CreateFileA
(
file_name
,
GENERIC_READ
|
GENERIC_EXECUTE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
hfile
=
CreateFileA
(
file_name
,
GENERIC_READ
|
GENERIC_EXECUTE
,
FILE_SHARE_READ
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"CreateFile(%s) error %d
\n
"
,
file_name
,
GetLastError
());
ok
(
hfile
!=
INVALID_HANDLE_VALUE
,
"CreateFile(%s) error %d
\n
"
,
file_name
,
GetLastError
());
test_mapping
(
hfile
,
SEC_IMAGE
);
test_mapping
(
hfile
,
SEC_IMAGE
,
FALSE
);
CloseHandle
(
hfile
);
CloseHandle
(
hfile
);
/* now anonymous mappings */
/* now anonymous mappings */
test_mapping
(
INVALID_HANDLE_VALUE
,
SEC_COMMIT
);
test_mapping
(
INVALID_HANDLE_VALUE
,
SEC_COMMIT
,
FALSE
);
}
}
static
void
test_shared_memory
(
BOOL
is_child
)
static
void
test_shared_memory
(
BOOL
is_child
)
...
...
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