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
c69cc550
Commit
c69cc550
authored
Jun 25, 2013
by
Dmitry Timoshkov
Committed by
Alexandre Julliard
Jun 25, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add more VirtualAlloc and VirtualProtect tests.
parent
a58e9f03
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
4 deletions
+65
-4
virtual.c
dlls/kernel32/tests/virtual.c
+65
-4
No files found.
dlls/kernel32/tests/virtual.c
View file @
c69cc550
...
...
@@ -1581,7 +1581,7 @@ static void test_VirtualProtect(void)
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
,
0
},
/* 0xe0 */
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
|
PAGE_EXECUTE
,
0
}
/* 0xf0 */
};
char
*
base
;
char
*
base
,
*
ptr
;
DWORD
ret
,
old_prot
,
rw_prot
,
exec_prot
,
i
,
j
;
MEMORY_BASIC_INFORMATION
info
;
SYSTEM_INFO
si
;
...
...
@@ -1652,6 +1652,27 @@ static void test_VirtualProtect(void)
DWORD
prot
=
exec_prot
|
rw_prot
;
SetLastError
(
0xdeadbeef
);
ptr
=
VirtualAlloc
(
base
,
si
.
dwPageSize
,
MEM_COMMIT
,
prot
);
if
((
rw_prot
&&
exec_prot
)
||
(
!
rw_prot
&&
!
exec_prot
))
{
ok
(
!
ptr
,
"VirtualAlloc(%02x) should fail
\n
"
,
prot
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
else
{
if
(
prot
&
(
PAGE_WRITECOPY
|
PAGE_EXECUTE_WRITECOPY
))
{
ok
(
!
ptr
,
"VirtualAlloc(%02x) should fail
\n
"
,
prot
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
GetLastError
());
}
else
{
ok
(
ptr
!=
NULL
,
"VirtualAlloc(%02x) error %d
\n
"
,
prot
,
GetLastError
());
ok
(
ptr
==
base
,
"expected %p, got %p
\n
"
,
base
,
ptr
);
}
}
SetLastError
(
0xdeadbeef
);
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
prot
,
&
old_prot
);
if
((
rw_prot
&&
exec_prot
)
||
(
!
rw_prot
&&
!
exec_prot
))
{
...
...
@@ -1734,7 +1755,7 @@ static void test_VirtualAlloc_protection(void)
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
,
FALSE
},
/* 0xe0 */
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
|
PAGE_EXECUTE
,
FALSE
}
/* 0xf0 */
};
char
*
base
;
char
*
base
,
*
ptr
;
DWORD
ret
,
i
;
MEMORY_BASIC_INFORMATION
info
;
SYSTEM_INFO
si
;
...
...
@@ -1772,6 +1793,10 @@ static void test_VirtualAlloc_protection(void)
ok
(
info
.
Protect
==
td
[
i
].
prot
,
"%d: got %#x != expected %#x
\n
"
,
i
,
info
.
Protect
,
td
[
i
].
prot
);
}
SetLastError
(
0xdeadbeef
);
ptr
=
VirtualAlloc
(
base
,
si
.
dwPageSize
,
MEM_COMMIT
,
td
[
i
].
prot
);
ok
(
ptr
==
base
,
"%d: VirtualAlloc failed %d
\n
"
,
i
,
GetLastError
());
VirtualFree
(
base
,
0
,
MEM_FREE
);
}
else
...
...
@@ -1824,7 +1849,7 @@ static void test_CreateFileMapping_protection(void)
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
,
FALSE
,
PAGE_NOACCESS
},
/* 0xe0 */
{
PAGE_EXECUTE_WRITECOPY
|
PAGE_EXECUTE_READWRITE
|
PAGE_EXECUTE_READ
|
PAGE_EXECUTE
,
FALSE
,
PAGE_NOACCESS
}
/* 0xf0 */
};
char
*
base
;
char
*
base
,
*
ptr
;
DWORD
ret
,
i
,
alloc_prot
,
prot
,
old_prot
;
MEMORY_BASIC_INFORMATION
info
;
SYSTEM_INFO
si
;
...
...
@@ -1896,6 +1921,27 @@ static void test_CreateFileMapping_protection(void)
ok
(
info
.
Protect
==
td
[
i
].
prot
,
"%d: got %#x != expected %#x
\n
"
,
i
,
info
.
Protect
,
td
[
i
].
prot
);
}
SetLastError
(
0xdeadbeef
);
ptr
=
VirtualAlloc
(
base
,
si
.
dwPageSize
,
MEM_COMMIT
,
td
[
i
].
prot
);
/* FIXME: remove once Wine is fixed */
if
(
td
[
i
].
prot
==
PAGE_WRITECOPY
||
td
[
i
].
prot
==
PAGE_EXECUTE_WRITECOPY
)
ok
(
!
ptr
,
"%d: VirtualAlloc(%02x) should fail
\n
"
,
i
,
td
[
i
].
prot
);
else
todo_wine
ok
(
!
ptr
,
"%d: VirtualAlloc(%02x) should fail
\n
"
,
i
,
td
[
i
].
prot
);
todo_wine
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"%d: expected ERROR_ACCESS_DENIED, got %d
\n
"
,
i
,
GetLastError
());
SetLastError
(
0xdeadbeef
);
ret
=
VirtualProtect
(
base
,
si
.
dwPageSize
,
td
[
i
].
prot
,
&
old_prot
);
if
(
td
[
i
].
prot
==
PAGE_READONLY
||
td
[
i
].
prot
==
PAGE_WRITECOPY
)
ok
(
ret
,
"%d: VirtualProtect(%02x) error %d
\n
"
,
i
,
td
[
i
].
prot
,
GetLastError
());
else
{
ok
(
!
ret
,
"%d: VirtualProtect(%02x) should fail
\n
"
,
i
,
td
[
i
].
prot
);
ok
(
GetLastError
()
==
ERROR_INVALID_PARAMETER
,
"%d: expected ERROR_INVALID_PARAMETER, got %d
\n
"
,
i
,
GetLastError
());
}
UnmapViewOfFile
(
base
);
CloseHandle
(
hmap
);
}
...
...
@@ -2196,7 +2242,7 @@ static void test_mapping(void)
{
FILE_MAP_EXECUTE
|
SECTION_MAP_EXECUTE
|
FILE_MAP_READ
|
FILE_MAP_WRITE
,
PAGE_EXECUTE_READWRITE
},
/* 0x2e */
{
FILE_MAP_EXECUTE
|
SECTION_MAP_EXECUTE
|
FILE_MAP_READ
|
FILE_MAP_WRITE
|
FILE_MAP_COPY
,
PAGE_EXECUTE_READWRITE
}
/* 0x2f */
};
void
*
base
,
*
nt_base
;
void
*
base
,
*
nt_base
,
*
ptr
;
DWORD
i
,
j
,
k
,
ret
,
old_prot
,
prev_prot
;
SYSTEM_INFO
si
;
char
temp_path
[
MAX_PATH
];
...
...
@@ -2376,6 +2422,21 @@ static void test_mapping(void)
}
}
for
(
k
=
0
;
k
<
sizeof
(
page_prot
)
/
sizeof
(
page_prot
[
0
]);
k
++
)
{
/*trace("map %#x, view %#x, requested prot %#x\n", page_prot[i], view[j].prot, page_prot[k]);*/
SetLastError
(
0xdeadbeef
);
ptr
=
VirtualAlloc
(
base
,
si
.
dwPageSize
,
MEM_COMMIT
,
page_prot
[
k
]);
/* FIXME: remove once Wine is fixed */
if
(
page_prot
[
k
]
==
PAGE_WRITECOPY
||
page_prot
[
k
]
==
PAGE_EXECUTE_WRITECOPY
)
ok
(
!
ptr
,
"VirtualAlloc(%02x) should fail
\n
"
,
page_prot
[
k
]);
else
todo_wine
ok
(
!
ptr
,
"VirtualAlloc(%02x) should fail
\n
"
,
page_prot
[
k
]);
todo_wine
ok
(
GetLastError
()
==
ERROR_ACCESS_DENIED
,
"expected ERROR_ACCESS_DENIED, got %d
\n
"
,
GetLastError
());
}
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