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
5ed5cf0e
Commit
5ed5cf0e
authored
Apr 07, 2021
by
Zebediah Figura
Committed by
Alexandre Julliard
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntoskrnl/tests: Test querying device IDs from the root-enumerated PDO.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bc69e804
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
0 deletions
+91
-0
driver.h
dlls/ntoskrnl.exe/tests/driver.h
+2
-0
driver_pnp.c
dlls/ntoskrnl.exe/tests/driver_pnp.c
+82
-0
ntoskrnl.c
dlls/ntoskrnl.exe/tests/ntoskrnl.c
+7
-0
No files found.
dlls/ntoskrnl.exe/tests/driver.h
View file @
5ed5cf0e
...
...
@@ -36,6 +36,8 @@
#define IOCTL_WINETEST_MISMATCHED_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80b, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_COMPLETION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x80c, METHOD_NEITHER, FILE_ANY_ACCESS)
#define IOCTL_WINETEST_BUS_MAIN CTL_CODE(FILE_DEVICE_BUS_EXTENDER, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
static
const
char
teststr
[]
=
"Wine is not an emulator"
;
struct
test_data
...
...
dlls/ntoskrnl.exe/tests/driver_pnp.c
View file @
5ed5cf0e
...
...
@@ -19,6 +19,7 @@
*/
#include <stdarg.h>
#include <stdio.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
...
...
@@ -29,6 +30,7 @@
#include "ddk/wdm.h"
#include "driver.h"
#include "utils.h"
static
const
GUID
control_class
=
{
0xdeadbeef
,
0x29ef
,
0x4538
,
{
0xa5
,
0xfd
,
0xb6
,
0x95
,
0x73
,
0xa3
,
0x62
,
0xc0
}};
static
UNICODE_STRING
control_symlink
;
...
...
@@ -94,6 +96,79 @@ static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp)
return
pdo_pnp
(
device
,
irp
);
}
static
void
test_bus_query_id
(
DEVICE_OBJECT
*
top_device
)
{
IO_STACK_LOCATION
*
stack
;
IO_STATUS_BLOCK
io
;
NTSTATUS
ret
;
KEVENT
event
;
IRP
*
irp
;
KeInitializeEvent
(
&
event
,
NotificationEvent
,
FALSE
);
irp
=
IoBuildSynchronousFsdRequest
(
IRP_MJ_PNP
,
top_device
,
NULL
,
0
,
NULL
,
&
event
,
&
io
);
irp
->
IoStatus
.
Status
=
STATUS_NOT_SUPPORTED
;
stack
=
IoGetNextIrpStackLocation
(
irp
);
stack
->
MinorFunction
=
IRP_MN_QUERY_ID
;
stack
->
Parameters
.
QueryId
.
IdType
=
BusQueryDeviceID
;
ret
=
IoCallDriver
(
top_device
,
irp
);
ok
(
ret
==
STATUS_SUCCESS
,
"got %#x
\n
"
,
ret
);
ok
(
io
.
Status
==
STATUS_SUCCESS
,
"got %#x
\n
"
,
ret
);
ok
(
!
wcscmp
((
WCHAR
*
)
io
.
Information
,
L"ROOT
\\
WINETEST"
),
"got id '%ls'
\n
"
,
(
WCHAR
*
)
io
.
Information
);
ExFreePool
((
WCHAR
*
)
io
.
Information
);
irp
=
IoBuildSynchronousFsdRequest
(
IRP_MJ_PNP
,
top_device
,
NULL
,
0
,
NULL
,
&
event
,
&
io
);
irp
->
IoStatus
.
Status
=
STATUS_NOT_SUPPORTED
;
stack
=
IoGetNextIrpStackLocation
(
irp
);
stack
->
MinorFunction
=
IRP_MN_QUERY_ID
;
stack
->
Parameters
.
QueryId
.
IdType
=
BusQueryInstanceID
;
ret
=
IoCallDriver
(
top_device
,
irp
);
ok
(
ret
==
STATUS_SUCCESS
,
"got %#x
\n
"
,
ret
);
ok
(
io
.
Status
==
STATUS_SUCCESS
,
"got %#x
\n
"
,
ret
);
ok
(
!
wcscmp
((
WCHAR
*
)
io
.
Information
,
L"0"
),
"got id '%ls'
\n
"
,
(
WCHAR
*
)
io
.
Information
);
ExFreePool
((
WCHAR
*
)
io
.
Information
);
}
static
void
test_bus_query
(
void
)
{
DEVICE_OBJECT
*
top_device
;
top_device
=
IoGetAttachedDeviceReference
(
bus_pdo
);
ok
(
top_device
==
bus_fdo
,
"wrong top device
\n
"
);
test_bus_query_id
(
top_device
);
ObDereferenceObject
(
top_device
);
}
static
NTSTATUS
fdo_ioctl
(
IRP
*
irp
,
IO_STACK_LOCATION
*
stack
,
ULONG
code
)
{
switch
(
code
)
{
case
IOCTL_WINETEST_BUS_MAIN
:
test_bus_query
();
return
STATUS_SUCCESS
;
default:
ok
(
0
,
"Unexpected ioctl %#x.
\n
"
,
code
);
return
STATUS_NOT_IMPLEMENTED
;
}
}
static
NTSTATUS
WINAPI
driver_ioctl
(
DEVICE_OBJECT
*
device
,
IRP
*
irp
)
{
IO_STACK_LOCATION
*
stack
=
IoGetCurrentIrpStackLocation
(
irp
);
ULONG
code
=
stack
->
Parameters
.
DeviceIoControl
.
IoControlCode
;
NTSTATUS
status
=
STATUS_NOT_IMPLEMENTED
;
if
(
device
==
bus_fdo
)
status
=
fdo_ioctl
(
irp
,
stack
,
code
);
irp
->
IoStatus
.
Status
=
status
;
IoCompleteRequest
(
irp
,
IO_NO_INCREMENT
);
return
status
;
}
static
NTSTATUS
WINAPI
driver_add_device
(
DRIVER_OBJECT
*
driver
,
DEVICE_OBJECT
*
pdo
)
{
NTSTATUS
ret
;
...
...
@@ -129,13 +204,20 @@ static NTSTATUS WINAPI driver_close(DEVICE_OBJECT *device, IRP *irp)
static
void
WINAPI
driver_unload
(
DRIVER_OBJECT
*
driver
)
{
winetest_cleanup
();
}
NTSTATUS
WINAPI
DriverEntry
(
DRIVER_OBJECT
*
driver
,
UNICODE_STRING
*
registry
)
{
NTSTATUS
ret
;
if
((
ret
=
winetest_init
()))
return
ret
;
driver
->
DriverExtension
->
AddDevice
=
driver_add_device
;
driver
->
DriverUnload
=
driver_unload
;
driver
->
MajorFunction
[
IRP_MJ_PNP
]
=
driver_pnp
;
driver
->
MajorFunction
[
IRP_MJ_DEVICE_CONTROL
]
=
driver_ioctl
;
driver
->
MajorFunction
[
IRP_MJ_CREATE
]
=
driver_create
;
driver
->
MajorFunction
[
IRP_MJ_CLOSE
]
=
driver_close
;
...
...
dlls/ntoskrnl.exe/tests/ntoskrnl.c
View file @
5ed5cf0e
...
...
@@ -994,6 +994,7 @@ static void test_pnp_devices(void)
SP_DEVINFO_DATA
device
=
{
sizeof
(
device
)};
HDEVINFO
set
;
HANDLE
bus
;
DWORD
size
;
BOOL
ret
;
set
=
SetupDiGetClassDevsA
(
&
control_class
,
NULL
,
NULL
,
DIGCF_PRESENT
|
DIGCF_DEVICEINTERFACE
);
...
...
@@ -1024,6 +1025,9 @@ static void test_pnp_devices(void)
bus
=
CreateFileA
(
iface_detail
->
DevicePath
,
0
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
ok
(
bus
!=
INVALID_HANDLE_VALUE
,
"got error %u
\n
"
,
GetLastError
());
ret
=
DeviceIoControl
(
bus
,
IOCTL_WINETEST_BUS_MAIN
,
NULL
,
0
,
NULL
,
0
,
&
size
,
NULL
);
ok
(
ret
,
"got error %u
\n
"
,
GetLastError
());
CloseHandle
(
bus
);
}
...
...
@@ -1175,6 +1179,8 @@ static void test_pnp_driver(struct testsign_context *ctx)
unload_driver
(
service
);
CloseServiceHandle
(
manager
);
cat_okfile
();
GetFullPathNameA
(
"winetest.inf"
,
sizeof
(
path
),
path
,
NULL
);
ret
=
SetupCopyOEMInfA
(
path
,
NULL
,
0
,
0
,
dest
,
sizeof
(
dest
),
NULL
,
&
filepart
);
ok
(
ret
,
"Failed to copy INF, error %#x
\n
"
,
GetLastError
());
...
...
@@ -1278,6 +1284,7 @@ START_TEST(ntoskrnl)
subtest
(
"driver_netio"
);
test_driver_netio
(
&
ctx
);
subtest
(
"driver_pnp"
);
test_pnp_driver
(
&
ctx
);
out
:
...
...
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