Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
64946e55
Commit
64946e55
authored
May 31, 2020
by
Paul Gofman
Committed by
Alexandre Julliard
Jun 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntoskrnl.exe/tests: Add a test for accessing process memory.
Signed-off-by:
Paul Gofman
<
pgofman@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ee7a5b28
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
1 deletion
+78
-1
driver.c
dlls/ntoskrnl.exe/tests/driver.c
+66
-0
driver.h
dlls/ntoskrnl.exe/tests/driver.h
+3
-0
ntoskrnl.c
dlls/ntoskrnl.exe/tests/ntoskrnl.c
+9
-1
No files found.
dlls/ntoskrnl.exe/tests/driver.c
View file @
64946e55
...
...
@@ -2067,6 +2067,71 @@ static void test_dpc(void)
KeRevertToUserAffinityThread
();
}
static
void
test_process_memory
(
const
struct
test_input
*
test_input
)
{
NTSTATUS
(
WINAPI
*
pMmCopyVirtualMemory
)(
PEPROCESS
fromprocess
,
void
*
fromaddress
,
PEPROCESS
toprocess
,
void
*
toaddress
,
SIZE_T
bufsize
,
KPROCESSOR_MODE
mode
,
SIZE_T
*
copied
);
char
buffer
[
sizeof
(
teststr
)];
ULONG64
modified_value
;
PEPROCESS
process
;
KAPC_STATE
state
;
NTSTATUS
status
;
SIZE_T
size
;
BYTE
*
base
;
pMmCopyVirtualMemory
=
get_proc_address
(
"MmCopyVirtualMemory"
);
status
=
PsLookupProcessByProcessId
((
HANDLE
)(
ULONG_PTR
)
test_input
->
process_id
,
&
process
);
ok
(
status
==
STATUS_SUCCESS
,
"Got unexpected status %#x.
\n
"
,
status
);
if
(
status
)
return
;
if
(
0
)
/* Crashes on Windows. */
PsGetProcessSectionBaseAddress
(
NULL
);
base
=
PsGetProcessSectionBaseAddress
(
process
);
ok
(
!!
base
,
"Got NULL base address.
\n
"
);
ok
(
process
==
PsGetCurrentProcess
(),
"Got unexpected process %p, PsGetCurrentProcess() %p.
\n
"
,
process
,
PsGetCurrentProcess
());
modified_value
=
0xdeadbeeffeedcafe
;
if
(
pMmCopyVirtualMemory
)
{
size
=
0xdeadbeef
;
status
=
pMmCopyVirtualMemory
(
process
,
base
+
test_input
->
teststr_offset
,
PsGetCurrentProcess
(),
buffer
,
sizeof
(
buffer
),
UserMode
,
&
size
);
todo_wine
ok
(
status
==
STATUS_ACCESS_VIOLATION
,
"Got unexpected status %#x.
\n
"
,
status
);
ok
(
!
size
,
"Got unexpected size %#lx.
\n
"
,
size
);
memset
(
buffer
,
0
,
sizeof
(
buffer
));
size
=
0xdeadbeef
;
if
(
0
)
/* Passing NULL for the copied size address hangs Windows. */
pMmCopyVirtualMemory
(
process
,
base
+
test_input
->
teststr_offset
,
PsGetCurrentProcess
(),
buffer
,
sizeof
(
buffer
),
KernelMode
,
NULL
);
status
=
pMmCopyVirtualMemory
(
process
,
base
+
test_input
->
teststr_offset
,
PsGetCurrentProcess
(),
buffer
,
sizeof
(
buffer
),
KernelMode
,
&
size
);
todo_wine
ok
(
status
==
STATUS_SUCCESS
,
"Got unexpected status %#x.
\n
"
,
status
);
todo_wine
ok
(
size
==
sizeof
(
buffer
),
"Got unexpected size %lu.
\n
"
,
size
);
todo_wine
ok
(
!
strcmp
(
buffer
,
teststr
),
"Got unexpected test string.
\n
"
);
}
else
{
win_skip
(
"MmCopyVirtualMemory is not available.
\n
"
);
}
if
(
!
test_input
->
running_under_wine
)
{
KeStackAttachProcess
((
PKPROCESS
)
process
,
&
state
);
todo_wine
ok
(
!
strcmp
(
teststr
,
(
char
*
)(
base
+
test_input
->
teststr_offset
)),
"Strings do not match.
\n
"
);
*
test_input
->
modified_value
=
modified_value
;
KeUnstackDetachProcess
(
&
state
);
}
ObDereferenceObject
(
process
);
}
static
NTSTATUS
main_test
(
DEVICE_OBJECT
*
device
,
IRP
*
irp
,
IO_STACK_LOCATION
*
stack
)
{
ULONG
length
=
stack
->
Parameters
.
DeviceIoControl
.
OutputBufferLength
;
...
...
@@ -2122,6 +2187,7 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st
#endif
test_affinity
();
test_dpc
();
test_process_memory
(
test_input
);
if
(
main_test_work_item
)
return
STATUS_UNEXPECTED_IO_ERROR
;
...
...
dlls/ntoskrnl.exe/tests/driver.h
View file @
64946e55
...
...
@@ -42,6 +42,9 @@ struct test_input
int
running_under_wine
;
int
winetest_report_success
;
int
winetest_debug
;
DWORD
process_id
;
SIZE_T
teststr_offset
;
ULONG64
*
modified_value
;
WCHAR
path
[
1
];
};
...
...
dlls/ntoskrnl.exe/tests/ntoskrnl.c
View file @
64946e55
...
...
@@ -148,8 +148,9 @@ static void main_test(void)
static
const
WCHAR
dokW
[]
=
{
'd'
,
'o'
,
'k'
,
0
};
WCHAR
temppathW
[
MAX_PATH
],
pathW
[
MAX_PATH
];
struct
test_input
*
test_input
;
UNICODE_STRING
pathU
;
DWORD
len
,
written
,
read
;
ULONG64
modified_value
;
UNICODE_STRING
pathU
;
LONG
new_failures
;
char
buffer
[
512
];
HANDLE
okfile
;
...
...
@@ -165,6 +166,11 @@ static void main_test(void)
test_input
->
running_under_wine
=
!
strcmp
(
winetest_platform
,
"wine"
);
test_input
->
winetest_report_success
=
winetest_report_success
;
test_input
->
winetest_debug
=
winetest_debug
;
test_input
->
process_id
=
GetCurrentProcessId
();
test_input
->
teststr_offset
=
(
SIZE_T
)((
BYTE
*
)
&
teststr
-
(
BYTE
*
)
NtCurrentTeb
()
->
Peb
->
ImageBaseAddress
);
test_input
->
modified_value
=
&
modified_value
;
modified_value
=
0
;
memcpy
(
test_input
->
path
,
pathU
.
Buffer
,
len
);
res
=
DeviceIoControl
(
device
,
IOCTL_WINETEST_MAIN_TEST
,
test_input
,
offsetof
(
struct
test_input
,
path
[
len
/
sizeof
(
WCHAR
)]),
...
...
@@ -172,6 +178,8 @@ static void main_test(void)
ok
(
res
,
"DeviceIoControl failed: %u
\n
"
,
GetLastError
());
ok
(
written
==
sizeof
(
new_failures
),
"got size %x
\n
"
,
written
);
todo_wine
ok
(
modified_value
==
0xdeadbeeffeedcafe
,
"Got unexpected value %#I64x.
\n
"
,
modified_value
);
okfile
=
CreateFileW
(
pathW
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
okfile
!=
INVALID_HANDLE_VALUE
,
"failed to create %s: %u
\n
"
,
wine_dbgstr_w
(
pathW
),
GetLastError
());
...
...
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