2015-07-06 20:09:14 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Aric Stewart
|
|
|
|
*
|
|
|
|
* 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 "ntstatus.h"
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winternl.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "winioctl.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "ddk/wdm.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "hidusage.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "ddk/hidport.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "ddk/hidclass.h"
|
|
|
|
#include "ddk/hidpi.h"
|
2016-04-05 15:45:34 +02:00
|
|
|
#include "cfgmgr32.h"
|
2015-07-06 20:09:14 +02:00
|
|
|
#include "wine/list.h"
|
2015-09-01 22:02:13 +02:00
|
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
#define DEFAULT_POLL_INTERVAL 200
|
|
|
|
#define MAX_POLL_INTERVAL_MSEC 10000
|
|
|
|
|
2015-09-09 17:20:11 +02:00
|
|
|
typedef NTSTATUS (WINAPI *pAddDevice)(DRIVER_OBJECT *DriverObject, DEVICE_OBJECT *PhysicalDeviceObject);
|
|
|
|
|
2015-09-11 17:45:54 +02:00
|
|
|
/* Ring buffer functions */
|
|
|
|
struct ReportRingBuffer;
|
|
|
|
|
2016-04-13 11:28:17 +02:00
|
|
|
typedef struct _BASE_DEVICE_EXTENSION {
|
2015-09-01 22:02:13 +02:00
|
|
|
HID_DEVICE_EXTENSION deviceExtension;
|
|
|
|
|
|
|
|
HID_COLLECTION_INFORMATION information;
|
|
|
|
WINE_HIDP_PREPARSED_DATA *preparseData;
|
|
|
|
|
|
|
|
ULONG poll_interval;
|
|
|
|
WCHAR *device_name;
|
|
|
|
WCHAR *link_name;
|
2016-04-05 15:45:34 +02:00
|
|
|
WCHAR device_id[MAX_DEVICE_ID_LEN];
|
|
|
|
WCHAR instance_id[MAX_DEVICE_ID_LEN];
|
2015-09-11 17:45:54 +02:00
|
|
|
struct ReportRingBuffer *ring_buffer;
|
2015-09-01 22:02:13 +02:00
|
|
|
HANDLE halt_event;
|
|
|
|
HANDLE thread;
|
|
|
|
|
|
|
|
LIST_ENTRY irp_queue;
|
|
|
|
|
|
|
|
/* Minidriver Specific stuff will end up here */
|
|
|
|
} BASE_DEVICE_EXTENSION;
|
2015-07-06 20:09:14 +02:00
|
|
|
|
2015-10-08 21:34:35 +02:00
|
|
|
void RingBuffer_Write(struct ReportRingBuffer *buffer, void *data) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:39 +02:00
|
|
|
UINT RingBuffer_AddPointer(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
|
|
|
void RingBuffer_RemovePointer(struct ReportRingBuffer *ring, UINT index) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:44 +02:00
|
|
|
void RingBuffer_Read(struct ReportRingBuffer *buffer, UINT index, void *output, UINT *size) DECLSPEC_HIDDEN;
|
|
|
|
UINT RingBuffer_GetBufferSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
2015-10-08 21:35:27 +02:00
|
|
|
UINT RingBuffer_GetSize(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
2015-09-11 17:45:54 +02:00
|
|
|
void RingBuffer_Destroy(struct ReportRingBuffer *buffer) DECLSPEC_HIDDEN;
|
|
|
|
struct ReportRingBuffer* RingBuffer_Create(UINT buffer_size) DECLSPEC_HIDDEN;
|
2015-10-08 21:35:27 +02:00
|
|
|
NTSTATUS RingBuffer_SetSize(struct ReportRingBuffer *buffer, UINT size) DECLSPEC_HIDDEN;
|
2015-09-11 17:45:54 +02:00
|
|
|
|
2015-07-06 20:09:14 +02:00
|
|
|
typedef struct _minidriver
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
|
|
|
|
HID_MINIDRIVER_REGISTRATION minidriver;
|
|
|
|
|
|
|
|
PDRIVER_UNLOAD DriverUnload;
|
2015-09-09 17:20:11 +02:00
|
|
|
|
|
|
|
pAddDevice AddDevice;
|
2016-04-05 15:45:34 +02:00
|
|
|
PDRIVER_DISPATCH PNPDispatch;
|
2015-07-06 20:09:14 +02:00
|
|
|
} minidriver;
|
2015-09-01 22:02:13 +02:00
|
|
|
|
2015-09-09 17:20:11 +02:00
|
|
|
NTSTATUS call_minidriver(ULONG code, DEVICE_OBJECT *device, void *in_buff, ULONG in_size, void *out_buff, ULONG out_size) DECLSPEC_HIDDEN;
|
|
|
|
minidriver* find_minidriver(DRIVER_OBJECT* driver) DECLSPEC_HIDDEN;
|
|
|
|
|
2015-09-01 22:02:13 +02:00
|
|
|
/* Internal device functions */
|
|
|
|
NTSTATUS HID_CreateDevice(DEVICE_OBJECT *native_device, HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT **device) DECLSPEC_HIDDEN;
|
2016-04-05 15:45:48 +02:00
|
|
|
NTSTATUS HID_LinkDevice(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
|
2015-09-01 22:02:13 +02:00
|
|
|
void HID_DeleteDevice(HID_MINIDRIVER_REGISTRATION *driver, DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
|
2015-10-08 21:34:35 +02:00
|
|
|
void HID_StartDeviceThread(DEVICE_OBJECT *device) DECLSPEC_HIDDEN;
|
2015-09-09 17:20:11 +02:00
|
|
|
|
2015-09-14 16:58:35 +02:00
|
|
|
NTSTATUS WINAPI HID_Device_ioctl(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:44 +02:00
|
|
|
NTSTATUS WINAPI HID_Device_read(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
2015-10-08 21:34:49 +02:00
|
|
|
NTSTATUS WINAPI HID_Device_write(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:39 +02:00
|
|
|
NTSTATUS WINAPI HID_Device_create(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
|
|
|
NTSTATUS WINAPI HID_Device_close(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
2016-04-05 15:45:34 +02:00
|
|
|
NTSTATUS WINAPI HID_PNP_Dispatch(DEVICE_OBJECT *device, IRP *irp) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:35 +02:00
|
|
|
|
2015-09-09 17:20:11 +02:00
|
|
|
/* Pseudo-Plug and Play support*/
|
|
|
|
NTSTATUS WINAPI PNP_AddDevice(DRIVER_OBJECT *driver, DEVICE_OBJECT* PDO) DECLSPEC_HIDDEN;
|
2015-09-14 16:58:30 +02:00
|
|
|
|
|
|
|
/* Parsing HID Report Descriptors into preparsed data */
|
|
|
|
WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) DECLSPEC_HIDDEN;
|