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
31fd0663
Commit
31fd0663
authored
Jan 14, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/tests: Add test cases for reading/writing process memory from an invalid buffer address.
parent
858a7efd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
4 deletions
+33
-4
virtual.c
dlls/kernel32/tests/virtual.c
+33
-4
No files found.
dlls/kernel32/tests/virtual.c
View file @
31fd0663
...
...
@@ -84,8 +84,8 @@ static void test_VirtualAllocEx(void)
return
;
}
src
=
HeapAlloc
(
GetProcessHeap
(),
0
,
alloc_size
);
dst
=
HeapAlloc
(
GetProcessHeap
(),
0
,
alloc_size
);
src
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
dst
=
VirtualAlloc
(
NULL
,
alloc_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
for
(
i
=
0
;
i
<
alloc_size
;
i
++
)
src
[
i
]
=
i
&
0xff
;
...
...
@@ -96,11 +96,40 @@ static void test_VirtualAllocEx(void)
b
=
ReadProcessMemory
(
hProcess
,
addr1
,
dst
,
alloc_size
,
&
bytes_read
);
ok
(
b
&&
(
bytes_read
==
alloc_size
),
"%lu bytes read
\n
"
,
bytes_read
);
ok
(
!
memcmp
(
src
,
dst
,
alloc_size
),
"Data from remote process differs
\n
"
);
/* test invalid source buffers */
b
=
VirtualProtect
(
src
+
0x2000
,
0x2000
,
PAGE_NOACCESS
,
&
old_prot
);
ok
(
b
,
"VirtualProtect failed error %u
\n
"
,
GetLastError
()
);
b
=
WriteProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_written
);
ok
(
!
b
,
"WriteProcessMemory succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
||
GetLastError
()
==
ERROR_PARTIAL_COPY
,
/* vista */
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
bytes_written
==
0
,
"%lu bytes written
\n
"
,
bytes_written
);
b
=
ReadProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_read
);
ok
(
!
b
,
"ReadProcessMemory succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
bytes_read
==
0
,
"%lu bytes written
\n
"
,
bytes_read
);
b
=
VirtualProtect
(
src
,
0x2000
,
PAGE_NOACCESS
,
&
old_prot
);
ok
(
b
,
"VirtualProtect failed error %u
\n
"
,
GetLastError
()
);
b
=
WriteProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_written
);
ok
(
!
b
,
"WriteProcessMemory succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
||
GetLastError
()
==
ERROR_PARTIAL_COPY
,
/* vista */
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
bytes_written
==
0
,
"%lu bytes written
\n
"
,
bytes_written
);
b
=
ReadProcessMemory
(
hProcess
,
addr1
,
src
,
alloc_size
,
&
bytes_read
);
ok
(
!
b
,
"ReadProcessMemory succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_NOACCESS
,
"wrong error %u
\n
"
,
GetLastError
()
);
ok
(
bytes_read
==
0
,
"%lu bytes written
\n
"
,
bytes_read
);
b
=
pVirtualFreeEx
(
hProcess
,
addr1
,
0
,
MEM_RELEASE
);
ok
(
b
!=
0
,
"VirtualFreeEx, error %u
\n
"
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
src
);
HeapFree
(
GetProcessHeap
(),
0
,
dst
);
VirtualFree
(
src
,
0
,
MEM_FREE
);
VirtualFree
(
dst
,
0
,
MEM_FREE
);
/*
* The following tests parallel those in test_VirtualAlloc()
...
...
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