dinput8/tests: Move HID driver tests from ntoskrnl.exe.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
810de9d1a7
commit
6aef301e08
|
@ -1,6 +1,12 @@
|
|||
TESTDLL = dinput8.dll
|
||||
IMPORTS = dinput8 ole32 user32 advapi32
|
||||
IMPORTS = dinput8 ole32 user32 hid advapi32 uuid crypt32 newdev setupapi wintrust
|
||||
|
||||
C_SRCS = \
|
||||
driver_hid_IMPORTS = winecrt0 ntoskrnl hal hidclass
|
||||
driver_hid_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
|
||||
|
||||
SOURCES = \
|
||||
device.c \
|
||||
dinput.c
|
||||
dinput.c \
|
||||
driver_hid.c \
|
||||
driver_hid.spec \
|
||||
hid.c
|
||||
|
|
|
@ -19,8 +19,10 @@
|
|||
#define DIRECTINPUT_VERSION 0x0800
|
||||
|
||||
#define COBJMACROS
|
||||
#include <initguid.h>
|
||||
#include <windows.h>
|
||||
#include <objidl.h>
|
||||
|
||||
#include <initguid.h>
|
||||
#include <dinput.h>
|
||||
#include <dinputd.h>
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@
|
|||
|
||||
#include "wine/list.h"
|
||||
|
||||
#include "driver.h"
|
||||
#include "utils.h"
|
||||
#include "driver_hid.h"
|
||||
|
||||
static UNICODE_STRING control_symlink;
|
||||
|
||||
|
@ -49,43 +48,43 @@ struct irp_queue
|
|||
LIST_ENTRY list;
|
||||
};
|
||||
|
||||
static IRP *irp_queue_pop(struct irp_queue *queue)
|
||||
static IRP *irp_queue_pop( struct irp_queue *queue )
|
||||
{
|
||||
KIRQL irql;
|
||||
IRP *irp;
|
||||
|
||||
KeAcquireSpinLock(&queue->lock, &irql);
|
||||
if (IsListEmpty(&queue->list)) irp = NULL;
|
||||
else irp = CONTAINING_RECORD(RemoveHeadList(&queue->list), IRP, Tail.Overlay.ListEntry);
|
||||
KeReleaseSpinLock(&queue->lock, irql);
|
||||
KeAcquireSpinLock( &queue->lock, &irql );
|
||||
if (IsListEmpty( &queue->list )) irp = NULL;
|
||||
else irp = CONTAINING_RECORD( RemoveHeadList( &queue->list ), IRP, Tail.Overlay.ListEntry );
|
||||
KeReleaseSpinLock( &queue->lock, irql );
|
||||
|
||||
return irp;
|
||||
}
|
||||
|
||||
static void irp_queue_push(struct irp_queue *queue, IRP *irp)
|
||||
static void irp_queue_push( struct irp_queue *queue, IRP *irp )
|
||||
{
|
||||
KIRQL irql;
|
||||
|
||||
KeAcquireSpinLock(&queue->lock, &irql);
|
||||
InsertTailList(&queue->list, &irp->Tail.Overlay.ListEntry);
|
||||
KeReleaseSpinLock(&queue->lock, irql);
|
||||
KeAcquireSpinLock( &queue->lock, &irql );
|
||||
InsertTailList( &queue->list, &irp->Tail.Overlay.ListEntry );
|
||||
KeReleaseSpinLock( &queue->lock, irql );
|
||||
}
|
||||
|
||||
static void irp_queue_clear(struct irp_queue *queue)
|
||||
static void irp_queue_clear( struct irp_queue *queue )
|
||||
{
|
||||
IRP *irp;
|
||||
|
||||
while ((irp = irp_queue_pop(queue)))
|
||||
while ((irp = irp_queue_pop( queue )))
|
||||
{
|
||||
irp->IoStatus.Status = STATUS_DELETE_PENDING;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
||||
}
|
||||
}
|
||||
|
||||
static void irp_queue_init(struct irp_queue *queue)
|
||||
static void irp_queue_init( struct irp_queue *queue )
|
||||
{
|
||||
KeInitializeSpinLock(&queue->lock);
|
||||
InitializeListHead(&queue->list);
|
||||
KeInitializeSpinLock( &queue->lock );
|
||||
InitializeListHead( &queue->list );
|
||||
}
|
||||
|
||||
struct hid_device
|
||||
|
@ -95,71 +94,70 @@ struct hid_device
|
|||
struct irp_queue irp_queue;
|
||||
};
|
||||
|
||||
static NTSTATUS WINAPI driver_pnp(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_pnp( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp);
|
||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
|
||||
HID_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
||||
struct hid_device *impl = ext->MiniDeviceExtension;
|
||||
KIRQL irql;
|
||||
|
||||
if (winetest_debug > 1) trace("pnp %#x\n", stack->MinorFunction);
|
||||
if (winetest_debug > 1) trace( "pnp %#x\n", stack->MinorFunction );
|
||||
|
||||
switch (stack->MinorFunction)
|
||||
{
|
||||
case IRP_MN_START_DEVICE:
|
||||
++got_start_device;
|
||||
impl->removed = FALSE;
|
||||
KeInitializeSpinLock(&impl->lock);
|
||||
irp_queue_init(&impl->irp_queue);
|
||||
IoSetDeviceInterfaceState(&control_symlink, TRUE);
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_START_DEVICE:
|
||||
++got_start_device;
|
||||
impl->removed = FALSE;
|
||||
KeInitializeSpinLock( &impl->lock );
|
||||
irp_queue_init( &impl->irp_queue );
|
||||
IoSetDeviceInterfaceState( &control_symlink, TRUE );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IRP_MN_SURPRISE_REMOVAL:
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||
KeAcquireSpinLock(&impl->lock, &irql);
|
||||
impl->removed = TRUE;
|
||||
KeReleaseSpinLock(&impl->lock, irql);
|
||||
irp_queue_clear(&impl->irp_queue);
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_SURPRISE_REMOVAL:
|
||||
case IRP_MN_QUERY_REMOVE_DEVICE:
|
||||
KeAcquireSpinLock( &impl->lock, &irql );
|
||||
impl->removed = TRUE;
|
||||
KeReleaseSpinLock( &impl->lock, irql );
|
||||
irp_queue_clear( &impl->irp_queue );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||
KeAcquireSpinLock(&impl->lock, &irql);
|
||||
impl->removed = FALSE;
|
||||
KeReleaseSpinLock(&impl->lock, irql);
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_CANCEL_REMOVE_DEVICE:
|
||||
KeAcquireSpinLock( &impl->lock, &irql );
|
||||
impl->removed = FALSE;
|
||||
KeReleaseSpinLock( &impl->lock, irql );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IRP_MN_STOP_DEVICE:
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_STOP_DEVICE:
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
irp_queue_clear(&impl->irp_queue);
|
||||
IoSetDeviceInterfaceState(&control_symlink, FALSE);
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
case IRP_MN_REMOVE_DEVICE:
|
||||
irp_queue_clear( &impl->irp_queue );
|
||||
IoSetDeviceInterfaceState( &control_symlink, FALSE );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
IoSkipCurrentIrpStackLocation(irp);
|
||||
return IoCallDriver(ext->NextDeviceObject, irp);
|
||||
IoSkipCurrentIrpStackLocation( irp );
|
||||
return IoCallDriver( ext->NextDeviceObject, irp );
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS WINAPI driver_power(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_power( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
HID_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
||||
|
||||
/* We do not expect power IRPs as part of normal operation. */
|
||||
ok(0, "unexpected call\n");
|
||||
ok( 0, "unexpected call\n" );
|
||||
|
||||
PoStartNextPowerIrp(irp);
|
||||
IoSkipCurrentIrpStackLocation(irp);
|
||||
return PoCallDriver(ext->NextDeviceObject, irp);
|
||||
PoStartNextPowerIrp( irp );
|
||||
IoSkipCurrentIrpStackLocation( irp );
|
||||
return PoCallDriver( ext->NextDeviceObject, irp );
|
||||
}
|
||||
|
||||
static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
#include "psh_hid_macros.h"
|
||||
/* Replace REPORT_ID with USAGE_PAGE when id is 0 */
|
||||
|
@ -408,7 +406,7 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
|||
#undef REPORT_ID_OR_USAGE_PAGE
|
||||
#include "pop_hid_macros.h"
|
||||
|
||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation(irp);
|
||||
IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
|
||||
HID_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
||||
struct hid_device *impl = ext->MiniDeviceExtension;
|
||||
const ULONG in_size = stack->Parameters.DeviceIoControl.InputBufferLength;
|
||||
|
@ -419,264 +417,264 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
|||
BOOL removed;
|
||||
KIRQL irql;
|
||||
|
||||
if (winetest_debug > 1) trace("ioctl %#x\n", code);
|
||||
if (winetest_debug > 1) trace( "ioctl %#x\n", code );
|
||||
|
||||
ok(got_start_device, "expected IRP_MN_START_DEVICE before any ioctls\n");
|
||||
ok( got_start_device, "expected IRP_MN_START_DEVICE before any ioctls\n" );
|
||||
|
||||
irp->IoStatus.Information = 0;
|
||||
|
||||
KeAcquireSpinLock(&impl->lock, &irql);
|
||||
KeAcquireSpinLock( &impl->lock, &irql );
|
||||
removed = impl->removed;
|
||||
KeReleaseSpinLock(&impl->lock, irql);
|
||||
KeReleaseSpinLock( &impl->lock, irql );
|
||||
|
||||
if (removed)
|
||||
{
|
||||
irp->IoStatus.Status = STATUS_DELETE_PENDING;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
||||
return STATUS_DELETE_PENDING;
|
||||
}
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
|
||||
case IOCTL_HID_GET_DEVICE_DESCRIPTOR:
|
||||
{
|
||||
HID_DESCRIPTOR *desc = irp->UserBuffer;
|
||||
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == sizeof(*desc), "got output size %u\n", out_size );
|
||||
|
||||
if (out_size == sizeof(*desc))
|
||||
{
|
||||
HID_DESCRIPTOR *desc = irp->UserBuffer;
|
||||
ok( !desc->bLength, "got size %u\n", desc->bLength );
|
||||
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(*desc), "got output size %u\n", out_size);
|
||||
|
||||
if (out_size == sizeof(*desc))
|
||||
{
|
||||
ok(!desc->bLength, "got size %u\n", desc->bLength);
|
||||
|
||||
desc->bLength = sizeof(*desc);
|
||||
desc->bDescriptorType = HID_HID_DESCRIPTOR_TYPE;
|
||||
desc->bcdHID = HID_REVISION;
|
||||
desc->bCountry = 0;
|
||||
desc->bNumDescriptors = 1;
|
||||
desc->DescriptorList[0].bReportType = HID_REPORT_DESCRIPTOR_TYPE;
|
||||
desc->DescriptorList[0].wReportLength = sizeof(report_descriptor);
|
||||
irp->IoStatus.Information = sizeof(*desc);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
desc->bLength = sizeof(*desc);
|
||||
desc->bDescriptorType = HID_HID_DESCRIPTOR_TYPE;
|
||||
desc->bcdHID = HID_REVISION;
|
||||
desc->bCountry = 0;
|
||||
desc->bNumDescriptors = 1;
|
||||
desc->DescriptorList[0].bReportType = HID_REPORT_DESCRIPTOR_TYPE;
|
||||
desc->DescriptorList[0].wReportLength = sizeof(report_descriptor);
|
||||
irp->IoStatus.Information = sizeof(*desc);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_GET_REPORT_DESCRIPTOR:
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(report_descriptor), "got output size %u\n", out_size);
|
||||
case IOCTL_HID_GET_REPORT_DESCRIPTOR:
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == sizeof(report_descriptor), "got output size %u\n", out_size );
|
||||
|
||||
if (out_size == sizeof(report_descriptor))
|
||||
{
|
||||
memcpy(irp->UserBuffer, report_descriptor, sizeof(report_descriptor));
|
||||
irp->IoStatus.Information = sizeof(report_descriptor);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
|
||||
if (out_size == sizeof(report_descriptor))
|
||||
{
|
||||
HID_DEVICE_ATTRIBUTES *attr = irp->UserBuffer;
|
||||
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(*attr), "got output size %u\n", out_size);
|
||||
|
||||
if (out_size == sizeof(*attr))
|
||||
{
|
||||
ok(!attr->Size, "got size %u\n", attr->Size);
|
||||
|
||||
attr->Size = sizeof(*attr);
|
||||
attr->VendorID = 0x1209;
|
||||
attr->ProductID = 0x0001;
|
||||
attr->VersionNumber = 0xface;
|
||||
irp->IoStatus.Information = sizeof(*attr);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
memcpy( irp->UserBuffer, report_descriptor, sizeof(report_descriptor) );
|
||||
irp->IoStatus.Information = sizeof(report_descriptor);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
case IOCTL_HID_READ_REPORT:
|
||||
case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
|
||||
{
|
||||
HID_DEVICE_ATTRIBUTES *attr = irp->UserBuffer;
|
||||
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == sizeof(*attr), "got output size %u\n", out_size );
|
||||
|
||||
if (out_size == sizeof(*attr))
|
||||
{
|
||||
ULONG expected_size = 25;
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == expected_size, "got output size %u\n", out_size);
|
||||
ok( !attr->Size, "got size %u\n", attr->Size );
|
||||
|
||||
if (polled)
|
||||
{
|
||||
memset(irp->UserBuffer, 0xa5, expected_size);
|
||||
if (report_id) ((char *)irp->UserBuffer)[0] = report_id;
|
||||
((char *)irp->UserBuffer)[1] = seq++;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoMarkIrpPending(irp);
|
||||
irp_queue_push(&impl->irp_queue, irp);
|
||||
ret = STATUS_PENDING;
|
||||
}
|
||||
break;
|
||||
attr->Size = sizeof(*attr);
|
||||
attr->VendorID = 0x1209;
|
||||
attr->ProductID = 0x0001;
|
||||
attr->VersionNumber = 0xface;
|
||||
irp->IoStatus.Information = sizeof(*attr);
|
||||
}
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_WRITE_REPORT:
|
||||
case IOCTL_HID_READ_REPORT:
|
||||
{
|
||||
ULONG expected_size = 25;
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == expected_size, "got output size %u\n", out_size );
|
||||
|
||||
if (polled)
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 2;
|
||||
|
||||
ok(in_size == sizeof(*packet), "got input size %u\n", in_size);
|
||||
ok(!out_size, "got output size %u\n", out_size);
|
||||
ok(packet->reportBufferLen >= expected_size, "got report size %u\n", packet->reportBufferLen);
|
||||
|
||||
if (report_id)
|
||||
ok(packet->reportBuffer[0] == report_id, "got report id %x\n", packet->reportBuffer[0]);
|
||||
else
|
||||
ok(packet->reportBuffer[0] == 0xcd, "got first byte %x\n", packet->reportBuffer[0]);
|
||||
|
||||
memset( irp->UserBuffer, 0xa5, expected_size );
|
||||
if (report_id) ((char *)irp->UserBuffer)[0] = report_id;
|
||||
((char *)irp->UserBuffer)[1] = seq++;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_GET_INPUT_REPORT:
|
||||
else
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 23;
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(*packet), "got output size %u\n", out_size);
|
||||
|
||||
ok(packet->reportId == report_id, "got id %u\n", packet->reportId);
|
||||
ok(packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen);
|
||||
ok(!!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer);
|
||||
|
||||
memset(packet->reportBuffer, 0xa5, 3);
|
||||
if (report_id) ((char *)packet->reportBuffer)[0] = report_id;
|
||||
((char *)packet->reportBuffer)[1] = seq++;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
IoMarkIrpPending( irp );
|
||||
irp_queue_push( &impl->irp_queue, irp );
|
||||
ret = STATUS_PENDING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_SET_OUTPUT_REPORT:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 2;
|
||||
ok(in_size == sizeof(*packet), "got input size %u\n", in_size);
|
||||
ok(!out_size, "got output size %u\n", out_size);
|
||||
case IOCTL_HID_WRITE_REPORT:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 2;
|
||||
|
||||
ok(packet->reportId == report_id, "got id %u\n", packet->reportId);
|
||||
ok(packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen);
|
||||
ok(!!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer);
|
||||
ok( in_size == sizeof(*packet), "got input size %u\n", in_size );
|
||||
ok( !out_size, "got output size %u\n", out_size );
|
||||
ok( packet->reportBufferLen >= expected_size, "got report size %u\n", packet->reportBufferLen );
|
||||
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
if (report_id)
|
||||
ok( packet->reportBuffer[0] == report_id, "got report id %x\n", packet->reportBuffer[0] );
|
||||
else ok( packet->reportBuffer[0] == 0xcd, "got first byte %x\n", packet->reportBuffer[0] );
|
||||
|
||||
case IOCTL_HID_GET_FEATURE:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 17;
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(*packet), "got output size %u\n", out_size);
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
ok(packet->reportId == report_id, "got id %u\n", packet->reportId);
|
||||
ok(packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen);
|
||||
ok(!!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer);
|
||||
case IOCTL_HID_GET_INPUT_REPORT:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 23;
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == sizeof(*packet), "got output size %u\n", out_size );
|
||||
|
||||
memset(packet->reportBuffer, 0xa5, 3);
|
||||
if (report_id) ((char *)packet->reportBuffer)[0] = report_id;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
ok( packet->reportId == report_id, "got id %u\n", packet->reportId );
|
||||
ok( packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen );
|
||||
ok( !!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer );
|
||||
|
||||
case IOCTL_HID_SET_FEATURE:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 17;
|
||||
ok(in_size == sizeof(*packet), "got input size %u\n", in_size);
|
||||
ok(!out_size, "got output size %u\n", out_size);
|
||||
memset( packet->reportBuffer, 0xa5, 3 );
|
||||
if (report_id) ((char *)packet->reportBuffer)[0] = report_id;
|
||||
((char *)packet->reportBuffer)[1] = seq++;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
ok(packet->reportId == report_id, "got id %u\n", packet->reportId);
|
||||
ok(packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen);
|
||||
ok(!!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer);
|
||||
case IOCTL_HID_SET_OUTPUT_REPORT:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 2;
|
||||
ok( in_size == sizeof(*packet), "got input size %u\n", in_size );
|
||||
ok( !out_size, "got output size %u\n", out_size );
|
||||
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
ok( packet->reportId == report_id, "got id %u\n", packet->reportId );
|
||||
ok( packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen );
|
||||
ok( !!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer );
|
||||
|
||||
case IOCTL_HID_GET_STRING:
|
||||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == 128, "got output size %u\n", out_size);
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test"));
|
||||
irp->IoStatus.Information = sizeof(L"Wine Test");
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
case IOCTL_HID_GET_FEATURE:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 17;
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == sizeof(*packet), "got output size %u\n", out_size );
|
||||
|
||||
default:
|
||||
ok(0, "unexpected ioctl %#x\n", code);
|
||||
ret = STATUS_NOT_IMPLEMENTED;
|
||||
ok( packet->reportId == report_id, "got id %u\n", packet->reportId );
|
||||
ok( packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen );
|
||||
ok( !!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer );
|
||||
|
||||
memset( packet->reportBuffer, 0xa5, 3 );
|
||||
if (report_id) ((char *)packet->reportBuffer)[0] = report_id;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_SET_FEATURE:
|
||||
{
|
||||
HID_XFER_PACKET *packet = irp->UserBuffer;
|
||||
ULONG expected_size = 17;
|
||||
ok( in_size == sizeof(*packet), "got input size %u\n", in_size );
|
||||
ok( !out_size, "got output size %u\n", out_size );
|
||||
|
||||
ok( packet->reportId == report_id, "got id %u\n", packet->reportId );
|
||||
ok( packet->reportBufferLen >= expected_size, "got len %u\n", packet->reportBufferLen );
|
||||
ok( !!packet->reportBuffer, "got buffer %p\n", packet->reportBuffer );
|
||||
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
case IOCTL_HID_GET_STRING:
|
||||
ok( !in_size, "got input size %u\n", in_size );
|
||||
ok( out_size == 128, "got output size %u\n", out_size );
|
||||
|
||||
memcpy( irp->UserBuffer, L"Wine Test", sizeof(L"Wine Test") );
|
||||
irp->IoStatus.Information = sizeof(L"Wine Test");
|
||||
ret = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
default:
|
||||
ok( 0, "unexpected ioctl %#x\n", code );
|
||||
ret = STATUS_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (ret != STATUS_PENDING)
|
||||
{
|
||||
irp->IoStatus.Status = ret;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static NTSTATUS WINAPI driver_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_ioctl( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
HID_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
||||
|
||||
ok(0, "unexpected call\n");
|
||||
IoSkipCurrentIrpStackLocation(irp);
|
||||
return IoCallDriver(ext->NextDeviceObject, irp);
|
||||
ok( 0, "unexpected call\n" );
|
||||
IoSkipCurrentIrpStackLocation( irp );
|
||||
return IoCallDriver( ext->NextDeviceObject, irp );
|
||||
}
|
||||
|
||||
static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *fdo)
|
||||
static NTSTATUS WINAPI driver_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *fdo )
|
||||
{
|
||||
HID_DEVICE_EXTENSION *ext = fdo->DeviceExtension;
|
||||
NTSTATUS ret;
|
||||
|
||||
/* We should be given the FDO, not the PDO. */
|
||||
ok(!!ext->PhysicalDeviceObject, "expected non-NULL pdo\n");
|
||||
ok(ext->NextDeviceObject == ext->PhysicalDeviceObject, "got pdo %p, next %p\n",
|
||||
ext->PhysicalDeviceObject, ext->NextDeviceObject);
|
||||
todo_wine ok(ext->NextDeviceObject->AttachedDevice == fdo, "wrong attached device\n");
|
||||
ok( !!ext->PhysicalDeviceObject, "expected non-NULL pdo\n" );
|
||||
ok( ext->NextDeviceObject == ext->PhysicalDeviceObject, "got pdo %p, next %p\n",
|
||||
ext->PhysicalDeviceObject, ext->NextDeviceObject );
|
||||
todo_wine
|
||||
ok( ext->NextDeviceObject->AttachedDevice == fdo, "wrong attached device\n" );
|
||||
|
||||
ret = IoRegisterDeviceInterface(ext->PhysicalDeviceObject, &control_class, NULL, &control_symlink);
|
||||
ok(!ret, "got %#x\n", ret);
|
||||
ret = IoRegisterDeviceInterface( ext->PhysicalDeviceObject, &control_class, NULL, &control_symlink );
|
||||
ok( !ret, "got %#x\n", ret );
|
||||
|
||||
fdo->Flags &= ~DO_DEVICE_INITIALIZING;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS WINAPI driver_create(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_create( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
ok( 0, "unexpected call\n" );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static NTSTATUS WINAPI driver_close(DEVICE_OBJECT *device, IRP *irp)
|
||||
static NTSTATUS WINAPI driver_close( DEVICE_OBJECT *device, IRP *irp )
|
||||
{
|
||||
ok(0, "unexpected call\n");
|
||||
ok( 0, "unexpected call\n" );
|
||||
irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
IoCompleteRequest(irp, IO_NO_INCREMENT);
|
||||
IoCompleteRequest( irp, IO_NO_INCREMENT );
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void WINAPI driver_unload(DRIVER_OBJECT *driver)
|
||||
static void WINAPI driver_unload( DRIVER_OBJECT *driver )
|
||||
{
|
||||
winetest_cleanup();
|
||||
}
|
||||
|
||||
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *registry)
|
||||
NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry )
|
||||
{
|
||||
static const int info_size = offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data );
|
||||
char buffer[offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ) + sizeof(DWORD)];
|
||||
|
@ -693,24 +691,23 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *registry)
|
|||
HANDLE hkey;
|
||||
DWORD size;
|
||||
|
||||
if ((ret = winetest_init()))
|
||||
return ret;
|
||||
if ((ret = winetest_init())) return ret;
|
||||
|
||||
InitializeObjectAttributes(&attr, registry, 0, NULL, NULL);
|
||||
ret = ZwOpenKey(&hkey, KEY_ALL_ACCESS, &attr);
|
||||
ok(!ret, "ZwOpenKey returned %#x\n", ret);
|
||||
InitializeObjectAttributes( &attr, registry, 0, NULL, NULL );
|
||||
ret = ZwOpenKey( &hkey, KEY_ALL_ACCESS, &attr );
|
||||
ok( !ret, "ZwOpenKey returned %#x\n", ret );
|
||||
|
||||
RtlInitUnicodeString(&name_str, L"ReportID");
|
||||
RtlInitUnicodeString( &name_str, L"ReportID" );
|
||||
size = info_size + sizeof(report_id);
|
||||
ret = ZwQueryValueKey(hkey, &name_str, KeyValuePartialInformation, buffer, size, &size);
|
||||
ok(!ret, "ZwQueryValueKey returned %#x\n", ret);
|
||||
memcpy(&report_id, buffer + info_size, size - info_size);
|
||||
ret = ZwQueryValueKey( hkey, &name_str, KeyValuePartialInformation, buffer, size, &size );
|
||||
ok( !ret, "ZwQueryValueKey returned %#x\n", ret );
|
||||
memcpy( &report_id, buffer + info_size, size - info_size );
|
||||
|
||||
RtlInitUnicodeString(&name_str, L"PolledMode");
|
||||
RtlInitUnicodeString( &name_str, L"PolledMode" );
|
||||
size = info_size + sizeof(polled);
|
||||
ret = ZwQueryValueKey(hkey, &name_str, KeyValuePartialInformation, buffer, size, &size);
|
||||
ok(!ret, "ZwQueryValueKey returned %#x\n", ret);
|
||||
memcpy(&polled, buffer + info_size, size - info_size);
|
||||
ret = ZwQueryValueKey( hkey, &name_str, KeyValuePartialInformation, buffer, size, &size );
|
||||
ok( !ret, "ZwQueryValueKey returned %#x\n", ret );
|
||||
memcpy( &polled, buffer + info_size, size - info_size );
|
||||
params.DevicesArePolled = polled;
|
||||
|
||||
driver->DriverExtension->AddDevice = driver_add_device;
|
||||
|
@ -722,8 +719,8 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *registry)
|
|||
driver->MajorFunction[IRP_MJ_CREATE] = driver_create;
|
||||
driver->MajorFunction[IRP_MJ_CLOSE] = driver_close;
|
||||
|
||||
ret = HidRegisterMinidriver(¶ms);
|
||||
ok(!ret, "got %#x\n", ret);
|
||||
ret = HidRegisterMinidriver( ¶ms );
|
||||
ok( !ret, "got %#x\n", ret );
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,451 @@
|
|||
/*
|
||||
* ntoskrnl.exe testing framework
|
||||
*
|
||||
* Copyright 2015 Sebastian Lackner
|
||||
* Copyright 2015 Michael Müller
|
||||
* Copyright 2015 Christian Costa
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __WINE_DRIVER_HID_H
|
||||
#define __WINE_DRIVER_HID_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winternl.h"
|
||||
|
||||
#include "ddk/wdm.h"
|
||||
|
||||
#include "initguid.h"
|
||||
|
||||
DEFINE_GUID(control_class,0xdeadbeef,0x29ef,0x4538,0xa5,0xfd,0xb6,0x95,0x73,0xa3,0x62,0xc0);
|
||||
|
||||
/* kernel/user shared data */
|
||||
struct winetest_shared_data
|
||||
{
|
||||
int running_under_wine;
|
||||
int winetest_report_success;
|
||||
int winetest_debug;
|
||||
int failures;
|
||||
int todo_failures;
|
||||
};
|
||||
|
||||
#ifndef __WINE_WINE_TEST_H
|
||||
|
||||
#if !defined( __WINE_USE_MSVCRT ) || defined( __MINGW32__ )
|
||||
#define __WINE_PRINTF_ATTR( fmt, args ) __attribute__((format( printf, fmt, args )))
|
||||
#else
|
||||
#define __WINE_PRINTF_ATTR( fmt, args )
|
||||
#endif
|
||||
|
||||
static HANDLE okfile;
|
||||
static LONG successes;
|
||||
static LONG failures;
|
||||
static LONG skipped;
|
||||
static LONG todo_successes;
|
||||
static LONG todo_failures;
|
||||
static LONG muted_traces;
|
||||
static LONG muted_skipped;
|
||||
static LONG muted_todo_successes;
|
||||
|
||||
static int running_under_wine;
|
||||
static int winetest_debug;
|
||||
static int winetest_report_success;
|
||||
|
||||
/* silence todos and skips above this threshold */
|
||||
static int winetest_mute_threshold = 42;
|
||||
|
||||
/* counts how many times a given line printed a message */
|
||||
static LONG line_counters[16384];
|
||||
|
||||
/* The following data must be kept track of on a per-thread basis */
|
||||
struct tls_data
|
||||
{
|
||||
HANDLE thread;
|
||||
const char *current_file; /* file of current check */
|
||||
int current_line; /* line of current check */
|
||||
unsigned int todo_level; /* current todo nesting level */
|
||||
int todo_do_loop;
|
||||
char *str_pos; /* position in debug buffer */
|
||||
char strings[2000]; /* buffer for debug strings */
|
||||
char context[8][128]; /* data to print before messages */
|
||||
unsigned int context_count; /* number of context prefixes */
|
||||
};
|
||||
|
||||
static KSPIN_LOCK tls_data_lock;
|
||||
static struct tls_data tls_data_pool[128];
|
||||
static DWORD tls_data_count;
|
||||
|
||||
static inline struct tls_data *get_tls_data(void)
|
||||
{
|
||||
static struct tls_data tls_overflow;
|
||||
struct tls_data *data;
|
||||
HANDLE thread = PsGetCurrentThreadId();
|
||||
KIRQL irql;
|
||||
|
||||
KeAcquireSpinLock( &tls_data_lock, &irql );
|
||||
for (data = tls_data_pool; data != tls_data_pool + tls_data_count; ++data)
|
||||
if (data->thread == thread) break;
|
||||
if (data == tls_data_pool + ARRAY_SIZE(tls_data_pool)) data = &tls_overflow;
|
||||
else if (data == tls_data_pool + tls_data_count)
|
||||
{
|
||||
data->thread = thread;
|
||||
data->str_pos = data->strings;
|
||||
tls_data_count++;
|
||||
}
|
||||
KeReleaseSpinLock( &tls_data_lock, irql );
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void winetest_set_location( const char *file, int line )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
data->current_file = strrchr( file, '/' );
|
||||
if (data->current_file == NULL) data->current_file = strrchr( file, '\\' );
|
||||
if (data->current_file == NULL) data->current_file = file;
|
||||
else data->current_file++;
|
||||
data->current_line = line;
|
||||
}
|
||||
|
||||
static inline void kvprintf( const char *format, __ms_va_list ap )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
IO_STATUS_BLOCK io;
|
||||
int len = vsnprintf( data->strings, sizeof(data->strings), format, ap );
|
||||
ZwWriteFile( okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL );
|
||||
}
|
||||
|
||||
static inline void WINAPIV kprintf( const char *format, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV kprintf( const char *format, ... )
|
||||
{
|
||||
__ms_va_list valist;
|
||||
|
||||
__ms_va_start( valist, format );
|
||||
kvprintf( format, valist );
|
||||
__ms_va_end( valist );
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV winetest_printf( const char *msg, ... )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
__ms_va_list valist;
|
||||
|
||||
kprintf( "%s:%d: ", data->current_file, data->current_line );
|
||||
__ms_va_start( valist, msg );
|
||||
kvprintf( msg, valist );
|
||||
__ms_va_end( valist );
|
||||
}
|
||||
|
||||
static inline NTSTATUS winetest_init(void)
|
||||
{
|
||||
const struct winetest_shared_data *data;
|
||||
SIZE_T size = sizeof(*data);
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING string;
|
||||
IO_STATUS_BLOCK io;
|
||||
void *addr = NULL;
|
||||
HANDLE section;
|
||||
NTSTATUS ret;
|
||||
|
||||
KeInitializeSpinLock( &tls_data_lock );
|
||||
|
||||
RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest_dinput_section" );
|
||||
/* OBJ_KERNEL_HANDLE is necessary for the file to be accessible from system threads */
|
||||
InitializeObjectAttributes( &attr, &string, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, NULL );
|
||||
if ((ret = ZwOpenSection( §ion, SECTION_MAP_READ, &attr ))) return ret;
|
||||
|
||||
if ((ret = ZwMapViewOfSection( section, NtCurrentProcess(), &addr, 0, 0, NULL, &size, ViewUnmap, 0, PAGE_READONLY )))
|
||||
{
|
||||
ZwClose( section );
|
||||
return ret;
|
||||
}
|
||||
data = addr;
|
||||
running_under_wine = data->running_under_wine;
|
||||
winetest_debug = data->winetest_debug;
|
||||
winetest_report_success = data->winetest_report_success;
|
||||
|
||||
ZwUnmapViewOfSection( NtCurrentProcess(), addr );
|
||||
ZwClose( section );
|
||||
|
||||
RtlInitUnicodeString( &string, L"\\??\\C:\\windows\\winetest_dinput_okfile" );
|
||||
return ZwOpenFile( &okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT );
|
||||
}
|
||||
|
||||
#define winetest_cleanup() winetest_cleanup_( __FILE__ )
|
||||
static inline void winetest_cleanup_( const char *file )
|
||||
{
|
||||
char test_name[MAX_PATH], *tmp;
|
||||
struct winetest_shared_data *data;
|
||||
SIZE_T size = sizeof(*data);
|
||||
const char *source_file;
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
UNICODE_STRING string;
|
||||
void *addr = NULL;
|
||||
HANDLE section;
|
||||
|
||||
source_file = strrchr( file, '/' );
|
||||
if (!source_file) source_file = strrchr( file, '\\' );
|
||||
if (!source_file) source_file = file;
|
||||
else source_file++;
|
||||
|
||||
strcpy( test_name, source_file );
|
||||
if ((tmp = strrchr( test_name, '.' ))) *tmp = 0;
|
||||
|
||||
if (winetest_debug)
|
||||
{
|
||||
kprintf( "%04x:%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
|
||||
(DWORD)(DWORD_PTR)PsGetCurrentProcessId(), test_name,
|
||||
successes + failures + todo_successes + todo_failures, todo_successes, failures + todo_failures,
|
||||
(failures + todo_failures != 1) ? "failures" : "failure", skipped );
|
||||
}
|
||||
|
||||
RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest_dinput_section" );
|
||||
/* OBJ_KERNEL_HANDLE is necessary for the file to be accessible from system threads */
|
||||
InitializeObjectAttributes( &attr, &string, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, NULL );
|
||||
|
||||
if (!ZwOpenSection( §ion, SECTION_MAP_READ | SECTION_MAP_WRITE, &attr ))
|
||||
{
|
||||
if (!ZwMapViewOfSection( section, NtCurrentProcess(), &addr, 0, 0, NULL, &size, ViewUnmap, 0, PAGE_READWRITE ))
|
||||
{
|
||||
data = addr;
|
||||
|
||||
InterlockedExchangeAdd( &data->failures, failures );
|
||||
InterlockedExchangeAdd( &data->todo_failures, todo_failures );
|
||||
|
||||
ZwUnmapViewOfSection( NtCurrentProcess(), addr );
|
||||
}
|
||||
ZwClose( section );
|
||||
}
|
||||
|
||||
ZwClose( okfile );
|
||||
}
|
||||
|
||||
static inline void winetest_print_context( const char *msgtype )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
unsigned int i;
|
||||
|
||||
winetest_printf( "%s", msgtype );
|
||||
for (i = 0; i < data->context_count; ++i) kprintf( "%s: ", data->context[i] );
|
||||
}
|
||||
|
||||
static inline LONG winetest_add_line(void)
|
||||
{
|
||||
struct tls_data *data;
|
||||
int index, count;
|
||||
|
||||
if (winetest_debug > 1) return 0;
|
||||
|
||||
data = get_tls_data();
|
||||
index = data->current_line % ARRAY_SIZE(line_counters);
|
||||
count = InterlockedIncrement( line_counters + index ) - 1;
|
||||
if (count == winetest_mute_threshold)
|
||||
winetest_printf( "Line has been silenced after %d occurrences\n", winetest_mute_threshold );
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static inline int winetest_vok( int condition, const char *msg, __ms_va_list args )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
|
||||
if (data->todo_level)
|
||||
{
|
||||
if (condition)
|
||||
{
|
||||
winetest_print_context( "Test succeeded inside todo block: " );
|
||||
kvprintf( msg, args );
|
||||
InterlockedIncrement( &todo_failures );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!winetest_debug || winetest_add_line() < winetest_mute_threshold)
|
||||
{
|
||||
if (winetest_debug > 0)
|
||||
{
|
||||
winetest_print_context( "Test marked todo: " );
|
||||
kvprintf( msg, args );
|
||||
}
|
||||
InterlockedIncrement( &todo_successes );
|
||||
}
|
||||
else InterlockedIncrement( &muted_todo_successes );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!condition)
|
||||
{
|
||||
winetest_print_context( "Test failed: " );
|
||||
kvprintf( msg, args );
|
||||
InterlockedIncrement( &failures );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (winetest_report_success) winetest_printf( "Test succeeded\n" );
|
||||
InterlockedIncrement( &successes );
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_ok( int condition, const char *msg, ... ) __WINE_PRINTF_ATTR( 2, 3 );
|
||||
static inline void WINAPIV winetest_ok( int condition, const char *msg, ... )
|
||||
{
|
||||
__ms_va_list args;
|
||||
__ms_va_start( args, msg );
|
||||
winetest_vok( condition, msg, args );
|
||||
__ms_va_end( args );
|
||||
}
|
||||
|
||||
static inline void winetest_vskip( const char *msg, __ms_va_list args )
|
||||
{
|
||||
if (winetest_add_line() < winetest_mute_threshold)
|
||||
{
|
||||
winetest_print_context( "Tests skipped: " );
|
||||
kvprintf( msg, args );
|
||||
InterlockedIncrement( &skipped );
|
||||
}
|
||||
else InterlockedIncrement( &muted_skipped );
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_skip( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV winetest_skip( const char *msg, ... )
|
||||
{
|
||||
__ms_va_list args;
|
||||
__ms_va_start( args, msg );
|
||||
winetest_vskip( msg, args );
|
||||
__ms_va_end( args );
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_win_skip( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV winetest_win_skip( const char *msg, ... )
|
||||
{
|
||||
__ms_va_list args;
|
||||
__ms_va_start( args, msg );
|
||||
if (running_under_wine) winetest_vskip( msg, args );
|
||||
else winetest_vok( 0, msg, args );
|
||||
__ms_va_end( args );
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_trace( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV winetest_trace( const char *msg, ... )
|
||||
{
|
||||
__ms_va_list args;
|
||||
|
||||
if (!winetest_debug) return;
|
||||
if (winetest_add_line() < winetest_mute_threshold)
|
||||
{
|
||||
winetest_print_context( "" );
|
||||
__ms_va_start( args, msg );
|
||||
kvprintf( msg, args );
|
||||
__ms_va_end( args );
|
||||
}
|
||||
else InterlockedIncrement( &muted_traces );
|
||||
}
|
||||
|
||||
static inline void winetest_start_todo( int is_todo )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
data->todo_level = (data->todo_level << 1) | (is_todo != 0);
|
||||
data->todo_do_loop = 1;
|
||||
}
|
||||
|
||||
static inline int winetest_loop_todo(void)
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
int do_loop = data->todo_do_loop;
|
||||
data->todo_do_loop = 0;
|
||||
return do_loop;
|
||||
}
|
||||
|
||||
static inline void winetest_end_todo(void)
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
data->todo_level >>= 1;
|
||||
}
|
||||
|
||||
static inline void WINAPIV winetest_push_context( const char *fmt, ... ) __WINE_PRINTF_ATTR( 1, 2 );
|
||||
static inline void WINAPIV winetest_push_context( const char *fmt, ... )
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
__ms_va_list valist;
|
||||
|
||||
if (data->context_count < ARRAY_SIZE(data->context))
|
||||
{
|
||||
__ms_va_start( valist, fmt );
|
||||
vsnprintf( data->context[data->context_count], sizeof(data->context[data->context_count]), fmt, valist );
|
||||
__ms_va_end( valist );
|
||||
data->context[data->context_count][sizeof(data->context[data->context_count]) - 1] = 0;
|
||||
}
|
||||
++data->context_count;
|
||||
}
|
||||
|
||||
static inline void winetest_pop_context(void)
|
||||
{
|
||||
struct tls_data *data = get_tls_data();
|
||||
|
||||
if (data->context_count) --data->context_count;
|
||||
}
|
||||
|
||||
static inline int broken( int condition )
|
||||
{
|
||||
return !running_under_wine && condition;
|
||||
}
|
||||
|
||||
#ifdef WINETEST_NO_LINE_NUMBERS
|
||||
# define subtest_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_subtest
|
||||
# define ignore_exceptions_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ignore_exceptions
|
||||
# define ok_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ok
|
||||
# define skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_skip
|
||||
# define win_skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_win_skip
|
||||
# define trace_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_trace
|
||||
# define wait_child_process_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_wait_child_process
|
||||
#else
|
||||
# define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest
|
||||
# define ignore_exceptions_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ignore_exceptions
|
||||
# define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
|
||||
# define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
|
||||
# define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
|
||||
# define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
|
||||
# define wait_child_process_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_wait_child_process
|
||||
#endif
|
||||
|
||||
#define ok ok_(__FILE__, __LINE__)
|
||||
#define skip skip_(__FILE__, __LINE__)
|
||||
#define trace trace_(__FILE__, __LINE__)
|
||||
#define win_skip win_skip_(__FILE__, __LINE__)
|
||||
|
||||
#define todo_if(is_todo) for (winetest_start_todo(is_todo); \
|
||||
winetest_loop_todo(); \
|
||||
winetest_end_todo())
|
||||
#define todo_wine todo_if(running_under_wine)
|
||||
#define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine)
|
||||
|
||||
#endif /* __WINE_WINE_TEST_H */
|
||||
|
||||
#endif /* __WINE_DRIVER_HID_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* HID report helper macros.
|
||||
*
|
||||
* Copyright 2021 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#undef Data
|
||||
#undef Cnst
|
||||
#undef Array
|
||||
#undef Var
|
||||
#undef Abs
|
||||
#undef Rel
|
||||
#undef NoWrap
|
||||
#undef Wrap
|
||||
#undef NonLin
|
||||
#undef Lin
|
||||
#undef NoPref
|
||||
#undef Pref
|
||||
#undef NoNull
|
||||
#undef Null
|
||||
#undef NonVol
|
||||
#undef Vol
|
||||
#undef Bits
|
||||
#undef Buff
|
||||
|
||||
#undef Physical
|
||||
#undef Application
|
||||
#undef Logical
|
||||
#undef Report
|
||||
#undef NamedArray
|
||||
#undef UsageSwitch
|
||||
#undef UsageModifier
|
||||
|
||||
#undef SHORT_ITEM_0
|
||||
#undef SHORT_ITEM_1
|
||||
#undef SHORT_ITEM_2
|
||||
#undef SHORT_ITEM_4
|
||||
|
||||
#undef LONG_ITEM
|
||||
|
||||
#undef INPUT
|
||||
#undef OUTPUT
|
||||
#undef FEATURE
|
||||
#undef COLLECTION
|
||||
#undef END_COLLECTION
|
||||
|
||||
#undef USAGE_PAGE
|
||||
#undef LOGICAL_MINIMUM
|
||||
#undef LOGICAL_MAXIMUM
|
||||
#undef PHYSICAL_MINIMUM
|
||||
#undef PHYSICAL_MAXIMUM
|
||||
#undef UNIT_EXPONENT
|
||||
#undef UNIT
|
||||
#undef REPORT_SIZE
|
||||
#undef REPORT_ID
|
||||
#undef REPORT_COUNT
|
||||
#undef PUSH
|
||||
#undef POP
|
||||
|
||||
#undef USAGE
|
||||
#undef USAGE_MINIMUM
|
||||
#undef USAGE_MAXIMUM
|
||||
#undef DESIGNATOR_INDEX
|
||||
#undef DESIGNATOR_MINIMUM
|
||||
#undef DESIGNATOR_MAXIMUM
|
||||
#undef STRING_INDEX
|
||||
#undef STRING_MINIMUM
|
||||
#undef STRING_MAXIMUM
|
||||
#undef DELIMITER
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* HID report helper macros.
|
||||
*
|
||||
* Copyright 2021 Rémi Bernon for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <hidusage.h>
|
||||
|
||||
#define Data 0
|
||||
#define Cnst 0x01
|
||||
#define Ary 0
|
||||
#define Var 0x02
|
||||
#define Abs 0
|
||||
#define Rel 0x04
|
||||
#define NoWrap 0
|
||||
#define Wrap 0x08
|
||||
#define NonLin 0
|
||||
#define Lin 0x10
|
||||
#define NoPref 0
|
||||
#define Pref 0x20
|
||||
#define NoNull 0
|
||||
#define Null 0x40
|
||||
#define NonVol 0
|
||||
#define Vol 0x80
|
||||
#define Bits 0
|
||||
#define Buff 0x100
|
||||
|
||||
#define Physical 0x00
|
||||
#define Application 0x01
|
||||
#define Logical 0x02
|
||||
#define Report 0x03
|
||||
#define NamedArray 0x04
|
||||
#define UsageSwitch 0x05
|
||||
#define UsageModifier 0x06
|
||||
|
||||
#define SHORT_ITEM_0(tag,type) (((tag)<<4)|((type)<<2)|0)
|
||||
#define SHORT_ITEM_1(tag,type,data) (((tag)<<4)|((type)<<2)|1),((data)&0xff)
|
||||
#define SHORT_ITEM_2(tag,type,data) (((tag)<<4)|((type)<<2)|2),((data)&0xff),(((data)>>8)&0xff)
|
||||
#define SHORT_ITEM_4(tag,type,data) (((tag)<<4)|((type)<<2)|3),((data)&0xff),(((data)>>8)&0xff),(((data)>>16)&0xff),(((data)>>24)&0xff)
|
||||
|
||||
#define LONG_ITEM(tag,size) SHORT_ITEM_2(0xf,0x3,((tag)<<8)|(size))
|
||||
|
||||
#define INPUT(n,data) SHORT_ITEM_##n(0x8,0,data)
|
||||
#define OUTPUT(n,data) SHORT_ITEM_##n(0x9,0,data)
|
||||
#define FEATURE(n,data) SHORT_ITEM_##n(0xb,0,data)
|
||||
#define COLLECTION(n,data) SHORT_ITEM_##n(0xa,0,data)
|
||||
#define END_COLLECTION SHORT_ITEM_0(0xc,0)
|
||||
|
||||
#define USAGE_PAGE(n,data) SHORT_ITEM_##n(0x0,1,data)
|
||||
#define LOGICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x1,1,data)
|
||||
#define LOGICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,1,data)
|
||||
#define PHYSICAL_MINIMUM(n,data) SHORT_ITEM_##n(0x3,1,data)
|
||||
#define PHYSICAL_MAXIMUM(n,data) SHORT_ITEM_##n(0x4,1,data)
|
||||
#define UNIT_EXPONENT(n,data) SHORT_ITEM_##n(0x5,1,data)
|
||||
#define UNIT(n,data) SHORT_ITEM_##n(0x6,1,data)
|
||||
#define REPORT_SIZE(n,data) SHORT_ITEM_##n(0x7,1,data)
|
||||
#define REPORT_ID(n,data) SHORT_ITEM_##n(0x8,1,data)
|
||||
#define REPORT_COUNT(n,data) SHORT_ITEM_##n(0x9,1,data)
|
||||
#define PUSH(n,data) SHORT_ITEM_##n(0xa,1,data)
|
||||
#define POP(n,data) SHORT_ITEM_##n(0xb,1,data)
|
||||
|
||||
#define USAGE(n,data) SHORT_ITEM_##n(0x0,2,data)
|
||||
#define USAGE_MINIMUM(n,data) SHORT_ITEM_##n(0x1,2,data)
|
||||
#define USAGE_MAXIMUM(n,data) SHORT_ITEM_##n(0x2,2,data)
|
||||
#define DESIGNATOR_INDEX(n,data) SHORT_ITEM_##n(0x3,2,data)
|
||||
#define DESIGNATOR_MINIMUM(n,data) SHORT_ITEM_##n(0x4,2,data)
|
||||
#define DESIGNATOR_MAXIMUM(n,data) SHORT_ITEM_##n(0x5,2,data)
|
||||
#define STRING_INDEX(n,data) SHORT_ITEM_##n(0x6,2,data)
|
||||
#define STRING_MINIMUM(n,data) SHORT_ITEM_##n(0x7,2,data)
|
||||
#define STRING_MAXIMUM(n,data) SHORT_ITEM_##n(0x8,2,data)
|
||||
#define DELIMITER(n,data) SHORT_ITEM_##n(0x9,2,data)
|
|
@ -7,8 +7,6 @@ driver2_IMPORTS = winecrt0 ntoskrnl hal
|
|||
driver2_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
|
||||
driver3_IMPORTS = winecrt0 ntoskrnl hal
|
||||
driver3_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
|
||||
driver_hid_IMPORTS = winecrt0 ntoskrnl hal hidclass
|
||||
driver_hid_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
|
||||
driver_netio_IMPORTS = winecrt0 ntoskrnl hal netio
|
||||
driver_netio_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
|
||||
driver_pnp_IMPORTS = winecrt0 ntoskrnl hal
|
||||
|
@ -21,8 +19,6 @@ SOURCES = \
|
|||
driver2.spec \
|
||||
driver3.c \
|
||||
driver3.spec \
|
||||
driver_hid.c \
|
||||
driver_hid.spec \
|
||||
driver_netio.c \
|
||||
driver_netio.spec \
|
||||
driver_pnp.c \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue