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
6eec34a9
Commit
6eec34a9
authored
Sep 25, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add more WRITECOPY tests.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0494f036
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
19 deletions
+58
-19
virtual.c
dlls/kernel32/tests/virtual.c
+58
-19
No files found.
dlls/kernel32/tests/virtual.c
View file @
6eec34a9
...
@@ -3836,6 +3836,16 @@ static DWORD map_prot_no_write(DWORD prot)
...
@@ -3836,6 +3836,16 @@ static DWORD map_prot_no_write(DWORD prot)
}
}
}
}
static
DWORD
map_prot_written
(
DWORD
prot
)
{
switch
(
prot
)
{
case
PAGE_WRITECOPY
:
return
PAGE_READWRITE
;
case
PAGE_EXECUTE_WRITECOPY
:
return
PAGE_EXECUTE_READWRITE
;
default:
return
prot
;
}
}
static
DWORD
file_access_to_prot
(
DWORD
access
)
static
DWORD
file_access_to_prot
(
DWORD
access
)
{
{
BOOL
exec
=
access
&
FILE_MAP_EXECUTE
;
BOOL
exec
=
access
&
FILE_MAP_EXECUTE
;
...
@@ -4083,29 +4093,11 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -4083,29 +4093,11 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
if
(
is_compatible_protection
(
alloc_prot
,
actual_prot
))
if
(
is_compatible_protection
(
alloc_prot
,
actual_prot
))
{
{
/* win2k and XP don't support EXEC on file mappings */
/* win2k and XP don't support EXEC on file mappings */
if
(
!
ret
&&
page_prot
[
k
]
==
PAGE_EXECUTE
)
if
(
!
ret
&&
(
page_prot
[
k
]
==
PAGE_EXECUTE
||
page_prot
[
k
]
==
PAGE_EXECUTE_WRITECOPY
||
view
[
j
].
prot
==
PAGE_EXECUTE_WRITECOPY
)
)
{
{
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE
\n
"
);
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE
\n
"
);
continue
;
continue
;
}
}
/* NT4 and win2k don't support EXEC on file mappings */
if
(
!
ret
&&
(
page_prot
[
k
]
==
PAGE_EXECUTE_READ
||
page_prot
[
k
]
==
PAGE_EXECUTE_READWRITE
))
{
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE
\n
"
);
continue
;
}
/* Vista+ supports PAGE_EXECUTE_WRITECOPY, earlier versions don't */
if
(
!
ret
&&
page_prot
[
k
]
==
PAGE_EXECUTE_WRITECOPY
)
{
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE_WRITECOPY
\n
"
);
continue
;
}
/* win2k and XP don't support PAGE_EXECUTE_WRITECOPY views properly */
if
(
!
ret
&&
view
[
j
].
prot
==
PAGE_EXECUTE_WRITECOPY
)
{
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE_WRITECOPY view properly
\n
"
);
continue
;
}
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
]);
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
);
...
@@ -4164,6 +4156,53 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
...
@@ -4164,6 +4156,53 @@ static void test_mapping( HANDLE hfile, DWORD sec_flags )
}
}
}
}
if
(
!
anon_mapping
&&
is_compatible_protection
(
alloc_prot
,
PAGE_WRITECOPY
))
{
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
PAGE_WRITECOPY
,
&
old_prot
);
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
);
if
(
ret
)
*
(
DWORD
*
)
base
=
0xdeadbeef
;
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"%d: VirtualQuery failed %d
\n
"
,
j
,
GetLastError
());
todo_wine
ok
(
info
.
Protect
==
PAGE_READWRITE
,
"VirtualProtect wrong prot, map %#x, view %#x got %#x
\n
"
,
page_prot
[
i
],
view
[
j
].
prot
,
info
.
Protect
);
prev_prot
=
info
.
Protect
;
alloc_prot
=
info
.
AllocationProtect
;
for
(
k
=
0
;
k
<
sizeof
(
page_prot
)
/
sizeof
(
page_prot
[
0
]);
k
++
)
{
DWORD
actual_prot
=
(
sec_flags
&
SEC_IMAGE
)
?
map_prot_no_write
(
page_prot
[
k
])
:
page_prot
[
k
];
SetLastError
(
0xdeadbeef
);
old_prot
=
0xdeadbeef
;
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
page_prot
[
k
],
&
old_prot
);
if
(
is_compatible_protection
(
alloc_prot
,
actual_prot
))
{
/* win2k and XP don't support EXEC on file mappings */
if
(
!
ret
&&
(
page_prot
[
k
]
==
PAGE_EXECUTE
||
page_prot
[
k
]
==
PAGE_EXECUTE_WRITECOPY
||
view
[
j
].
prot
==
PAGE_EXECUTE_WRITECOPY
))
{
ok
(
broken
(
!
ret
),
"VirtualProtect doesn't support PAGE_EXECUTE
\n
"
);
continue
;
}
ok
(
ret
,
"VirtualProtect error %d, map %#x, view %#x, requested prot %#x
\n
"
,
GetLastError
(),
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
ok
(
old_prot
==
prev_prot
,
"got %#x, expected %#x
\n
"
,
old_prot
,
prev_prot
);
ret
=
VirtualQuery
(
base
,
&
info
,
sizeof
(
info
));
ok
(
ret
,
"%d: VirtualQuery failed %d
\n
"
,
j
,
GetLastError
());
todo_wine_if
(
map_prot_written
(
page_prot
[
k
]
)
!=
actual_prot
)
ok
(
info
.
Protect
==
map_prot_written
(
page_prot
[
k
]
),
"VirtualProtect wrong prot, map %#x, view %#x, requested prot %#x got %#x
\n
"
,
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
],
info
.
Protect
);
prev_prot
=
info
.
Protect
;
}
else
{
ok
(
!
ret
,
"VirtualProtect should fail, map %#x, view %#x, requested prot %#x
\n
"
,
page_prot
[
i
],
view
[
j
].
prot
,
page_prot
[
k
]);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
}
}
UnmapViewOfFile
(
base
);
UnmapViewOfFile
(
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