From: Vibhav Pant vibhavp@gmail.com
--- dlls/ntoskrnl.exe/tests/driver.h | 19 +++++++ dlls/ntoskrnl.exe/tests/driver_pnp.c | 77 ++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+)
diff --git a/dlls/ntoskrnl.exe/tests/driver.h b/dlls/ntoskrnl.exe/tests/driver.h index fd91211e6d0..9c51af0a4c6 100644 --- a/dlls/ntoskrnl.exe/tests/driver.h +++ b/dlls/ntoskrnl.exe/tests/driver.h @@ -80,3 +80,22 @@ static const GUID control_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6
#define SERVER_LISTEN_PORT 9374 #define CLIENT_LISTEN_PORT 9375 + +#define WINETEST_DEFINE_DEVPROPS \ + WINETEST_DRIVER_DEVPROP( 1, DEVPROP_TYPE_BYTE, {.byte = 0xde}, sizeof( BYTE ) ) \ + WINETEST_DRIVER_DEVPROP( 2, DEVPROP_TYPE_INT16, {.int16 = 0xbeef}, sizeof( INT16 ) ) \ + WINETEST_DRIVER_DEVPROP( 3, DEVPROP_TYPE_UINT16, {.uint16 = 0xbeef}, sizeof( UINT16 ) ) \ + WINETEST_DRIVER_DEVPROP( 4, DEVPROP_TYPE_INT32, {.int32 = 0xdeadbeef}, sizeof( INT32 ) ) \ + WINETEST_DRIVER_DEVPROP( 5, DEVPROP_TYPE_UINT32, {.uint32 = 0xdeadbeef}, sizeof( UINT32 ) ) \ + WINETEST_DRIVER_DEVPROP( 6, DEVPROP_TYPE_INT64, {.int64 = 0xdeadbeefdeadbeef}, sizeof( INT64 ) ) \ + WINETEST_DRIVER_DEVPROP( 7, DEVPROP_TYPE_UINT64, {.uint64 = 0xdeadbeefdeadbeef}, sizeof( UINT64 ) ) + +#define WINETEST_DRIVER_DEVPROP( i, typ, val, size ) \ + DEFINE_DEVPROPKEY( DEVPKEY_Winetest_##i, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, \ + 0xde, 0xad, 0xbe, 0xef, ( i ) ); + +WINETEST_DEFINE_DEVPROPS; +DEFINE_DEVPROPKEY( DEVPKEY_Winetest_8, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xde, + 0xad, 0xbe, 0xef, 8 ); /* DEVPROP_TYPE_GUID */ + +#undef WINETEST_DRIVER_DEVPROP diff --git a/dlls/ntoskrnl.exe/tests/driver_pnp.c b/dlls/ntoskrnl.exe/tests/driver_pnp.c index f66d56de8c7..70678b1a45c 100644 --- a/dlls/ntoskrnl.exe/tests/driver_pnp.c +++ b/dlls/ntoskrnl.exe/tests/driver_pnp.c @@ -35,6 +35,8 @@
#include "wine/list.h"
+#include "initguid.h" +#include "devpkey.h" #include "driver.h" #include "utils.h"
@@ -610,12 +612,87 @@ static void test_bus_query(void) ObDereferenceObject(top_device); }
+struct winetest_deviceprop +{ + const DEVPROPKEY *key; + DEVPROPTYPE type; + union { + BYTE byte; + INT16 int16; + UINT16 uint16; + INT32 int32; + UINT32 uint32; + INT64 int64; + UINT64 uint64; + GUID guid; + } value; + SIZE_T size; +}; + +#define WINETEST_DRIVER_DEVPROP(i, typ, val, size) {&DEVPKEY_Winetest_##i, (typ), val, (size)}, +static struct winetest_deviceprop deviceprops[] = { + WINETEST_DEFINE_DEVPROPS + {&DEVPKEY_Winetest_8, DEVPROP_TYPE_GUID, + {.guid = {0xdeadbeef, 0xdead, 0xbeef, {0xde, 0xad, 0xbe, 0xef, 0xde, 0xad, 0xbe, 0xef}}}, sizeof(GUID)} +}; +#undef WINETEST_DRIVER_DEVPROP + +static void test_device_properties( DEVICE_OBJECT *device ) +{ + SIZE_T i; + + for (i = 0; i < ARRAY_SIZE( deviceprops ); i++) + { + NTSTATUS status; + ULONG size = deviceprops[i].size; + DEVPROPTYPE type = deviceprops[i].type; + const DEVPROPKEY *key = deviceprops[i].key; + void *value = &deviceprops[i].value; + + status = IoSetDevicePropertyData( device, key, LOCALE_NEUTRAL, 0, type, size, value ); + ok( status == STATUS_SUCCESS, "Failed to set device property, status %#lx.\n", status ); + if (status == STATUS_SUCCESS) + { + void *buf; + ULONG req_size; + DEVPROPTYPE stored_type; + + status = IoGetDevicePropertyData( device, key, LOCALE_NEUTRAL, 0, 0, NULL, &req_size, + &stored_type ); + ok( status == STATUS_BUFFER_TOO_SMALL, "Expected status %#lx, got %#lx.\n", + STATUS_BUFFER_TOO_SMALL, status ); + ok( req_size == size, "Expected required size %lu, got %lu.\n", req_size, size ); + ok( stored_type == type, "Expected DEVPROPTYPE value %#lx, got %#lx.\n", type, + stored_type ); + + buf = ExAllocatePool( PagedPool, size ); + ok( buf != NULL, "Failed to allocate buffer.\n" ); + if (buf != NULL) + { + memset( buf, 0, size ); + status = IoGetDevicePropertyData( device, key, LOCALE_NEUTRAL, 0, size, buf, NULL, + &stored_type ); + ok( status == STATUS_SUCCESS, "Failed to get device property, status %#lx.\n", + status ); + if (status == STATUS_SUCCESS) + ok( memcmp( buf, value, size ) == 0, + "Got unexpected device property value.\n" ); + ExFreePool( buf ); + } + } + status = IoSetDevicePropertyData( device, key, LOCALE_NEUTRAL, 0, type, 0, NULL ); + ok( status == STATUS_SUCCESS, "Failed to delete device property, status %#lx.\n", status ); + } + return; +} + static NTSTATUS fdo_ioctl(IRP *irp, IO_STACK_LOCATION *stack, ULONG code) { switch (code) { case IOCTL_WINETEST_BUS_MAIN: test_bus_query(); + test_device_properties( bus_pdo ); return STATUS_SUCCESS;
case IOCTL_WINETEST_BUS_REGISTER_IFACE: