ReactOS  0.4.15-dev-1201-gb2cf5a4
hid.c File Reference
#include "precomp.h"
#include <stdarg.h>
#include <winbase.h>
#include <debug.h>
#include "hidp.h"
Include dependency graph for hid.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

PVOID NTAPI AllocFunction (IN ULONG ItemSize)
 
VOID NTAPI FreeFunction (IN PVOID Item)
 
VOID NTAPI ZeroFunction (IN PVOID Item, IN ULONG ItemSize)
 
VOID NTAPI CopyFunction (IN PVOID Target, IN PVOID Source, IN ULONG Length)
 
VOID __cdecl DebugFunction (IN LPCSTR FormatStr,...)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved)
 
HIDAPI BOOLEAN WINAPI HidD_FlushQueue (IN HANDLE HidDeviceObject)
 
HIDAPI BOOLEAN WINAPI HidD_FreePreparsedData (IN PHIDP_PREPARSED_DATA PreparsedData)
 
HIDAPI BOOLEAN WINAPI HidD_GetAttributes (IN HANDLE HidDeviceObject, OUT PHIDD_ATTRIBUTES Attributes)
 
HIDAPI BOOLEAN WINAPI HidD_GetFeature (IN HANDLE HidDeviceObject, OUT PVOID ReportBuffer, IN ULONG ReportBufferLength)
 
HIDAPI VOID WINAPI HidD_GetHidGuid (OUT LPGUID HidGuid)
 
HIDAPI BOOLEAN WINAPI HidD_GetInputReport (IN HANDLE HidDeviceObject, IN OUT PVOID ReportBuffer, IN ULONG ReportBufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetManufacturerString (IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetNumInputBuffers (IN HANDLE HidDeviceObject, OUT PULONG NumberBuffers)
 
HIDAPI BOOLEAN WINAPI HidD_GetPhysicalDescriptor (IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetPreparsedData (IN HANDLE HidDeviceObject, OUT PHIDP_PREPARSED_DATA *PreparsedData)
 
HIDAPI BOOLEAN WINAPI HidD_GetProductString (IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetSerialNumberString (IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI ULONG WINAPI HidD_Hello (OUT PCHAR Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_SetFeature (IN HANDLE HidDeviceObject, IN PVOID ReportBuffer, IN ULONG ReportBufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_SetNumInputBuffers (IN HANDLE HidDeviceObject, IN ULONG NumberBuffers)
 
HIDAPI BOOLEAN WINAPI HidD_SetOutputReport (IN HANDLE HidDeviceObject, IN PVOID ReportBuffer, IN ULONG ReportBufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetIndexedString (IN HANDLE HidDeviceObject, IN ULONG StringIndex, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetMsGenreDescriptor (IN HANDLE HidDeviceObject, OUT PVOID Buffer, IN ULONG BufferLength)
 
HIDAPI BOOLEAN WINAPI HidD_GetConfiguration (IN HANDLE HidDeviceObject, OUT PHIDD_CONFIGURATION Configuration, IN ULONG ConfigurationLength)
 
HIDAPI BOOLEAN WINAPI HidD_SetConfiguration (IN HANDLE HidDeviceObject, IN PHIDD_CONFIGURATION Configuration, IN ULONG ConfigurationLength)
 

Variables

HINSTANCE hDllInstance
 
const GUID HidClassGuid = {0x4D1E55B2, 0xF16F, 0x11CF, {0x88,0xCB,0x00,0x11,0x11,0x00,0x00,0x30}}
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 34 of file hid.c.

Function Documentation

◆ AllocFunction()

◆ CopyFunction()

VOID NTAPI CopyFunction ( IN PVOID  Target,
IN PVOID  Source,
IN ULONG  Length 
)

Definition at line 70 of file hid.c.

74 {
76 }
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
_Must_inspect_result_ typedef _In_ ULONG _In_ BOOLEAN Target
Definition: iotypes.h:1088
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167

◆ DebugFunction()

VOID __cdecl DebugFunction ( IN LPCSTR  FormatStr,
  ... 
)

Definition at line 80 of file hid.c.

82 {
83 #if 0
84  va_arg list;
85  va_start(list, FormatStr);
86  vDbgPrintEx(FormatStr, list);
87  va_end(list);
88 #endif
89 }
#define va_end(ap)
Definition: acmsvcex.h:90
NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH Format, _In_ va_list ap)
Definition: _list.h:228
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define list
Definition: rosglue.h:35
#define va_start(ap, A)
Definition: acmsvcex.h:91

Referenced by HidParser_AllocateCollection(), HidParser_GetCollection(), HidParser_GetCollectionDescription(), and HidParser_ParseReportDescriptor().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  dwReason,
LPVOID  lpvReserved 
)

Definition at line 92 of file hid.c.

95 {
96  switch(dwReason)
97  {
98  case DLL_PROCESS_ATTACH:
99  hDllInstance = hinstDLL;
100  break;
101 
102  case DLL_THREAD_ATTACH:
103  break;
104 
105  case DLL_THREAD_DETACH:
106  break;
107 
108  case DLL_PROCESS_DETACH:
109  break;
110  }
111  return TRUE;
112 }
#define TRUE
Definition: types.h:120
#define DLL_THREAD_ATTACH
Definition: compat.h:132
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_THREAD_DETACH
Definition: compat.h:133
DWORD dwReason
Definition: misc.cpp:154
#define DLL_PROCESS_DETACH
Definition: compat.h:130
HINSTANCE hDllInstance
Definition: hid.c:38

◆ FreeFunction()

◆ HidD_FlushQueue()

HIDAPI BOOLEAN WINAPI HidD_FlushQueue ( IN HANDLE  HidDeviceObject)

Definition at line 122 of file hid.c.

123 {
124  DWORD RetLen;
125  return DeviceIoControl(HidDeviceObject, IOCTL_HID_FLUSH_QUEUE,
126  NULL, 0,
127  NULL, 0,
128  &RetLen, NULL) != 0;
129 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_HID_FLUSH_QUEUE
Definition: hidclass.h:57

◆ HidD_FreePreparsedData()

HIDAPI BOOLEAN WINAPI HidD_FreePreparsedData ( IN PHIDP_PREPARSED_DATA  PreparsedData)

Definition at line 139 of file hid.c.

140 {
141  return (LocalFree((HLOCAL)PreparsedData) == NULL);
142 }
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA PreparsedData
Definition: hidpi.h:333
smooth NULL
Definition: ftsmooth.c:416
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577

Referenced by get_device(), test_device_info(), test_get_input_report(), and test_read_device().

◆ HidD_GetAttributes()

HIDAPI BOOLEAN WINAPI HidD_GetAttributes ( IN HANDLE  HidDeviceObject,
OUT PHIDD_ATTRIBUTES  Attributes 
)

Definition at line 152 of file hid.c.

154 {
156  DWORD RetLen;
157 
159  NULL, 0,
160  &hci, sizeof(HID_COLLECTION_INFORMATION),
161  &RetLen, NULL))
162  {
163  return FALSE;
164  }
165 
166  /* copy the fields */
167  Attributes->Size = sizeof(HIDD_ATTRIBUTES);
168  Attributes->VendorID = hci.VendorID;
169  Attributes->ProductID = hci.ProductID;
170  Attributes->VersionNumber = hci.VersionNumber;
171 
172  return TRUE;
173 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_HID_GET_COLLECTION_INFORMATION
Definition: hidclass.h:59
struct _HIDD_ATTRIBUTES HIDD_ATTRIBUTES
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

Referenced by test_device_info().

◆ HidD_GetConfiguration()

HIDAPI BOOLEAN WINAPI HidD_GetConfiguration ( IN HANDLE  HidDeviceObject,
OUT PHIDD_CONFIGURATION  Configuration,
IN ULONG  ConfigurationLength 
)

Definition at line 502 of file hid.c.

505 {
506 
507  // magic cookie
509 
510  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_DRIVER_CONFIG,
511  0, 0,
512  &Configuration->size, ConfigurationLength - sizeof(ULONG),
513  (PULONG)&Configuration->cookie, NULL) != 0;
514 }
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
HIDAPI BOOLEAN WINAPI HidD_GetConfiguration(IN HANDLE HidDeviceObject, OUT PHIDD_CONFIGURATION Configuration, IN ULONG ConfigurationLength)
Definition: hid.c:502
CConfiguration Configuration
Definition: main.cpp:11
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_HID_GET_DRIVER_CONFIG
Definition: hidclass.h:74
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

Referenced by HidD_SetConfiguration().

◆ HidD_GetFeature()

HIDAPI BOOLEAN WINAPI HidD_GetFeature ( IN HANDLE  HidDeviceObject,
OUT PVOID  ReportBuffer,
IN ULONG  ReportBufferLength 
)

Definition at line 183 of file hid.c.

186 {
187  DWORD RetLen;
188  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_FEATURE,
189  NULL, 0,
190  ReportBuffer, ReportBufferLength,
191  &RetLen, NULL) != 0;
192 }
smooth NULL
Definition: ftsmooth.c:416
#define IOCTL_HID_GET_FEATURE
Definition: hidclass.h:60
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ HidD_GetHidGuid()

HIDAPI VOID WINAPI HidD_GetHidGuid ( OUT LPGUID  HidGuid)

Definition at line 202 of file hid.c.

203 {
204  *HidGuid = HidClassGuid;
205 }
const GUID HidClassGuid
Definition: hid.c:41

Referenced by get_device(), and run_for_each_device().

◆ HidD_GetIndexedString()

HIDAPI BOOLEAN WINAPI HidD_GetIndexedString ( IN HANDLE  HidDeviceObject,
IN ULONG  StringIndex,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 465 of file hid.c.

469 {
470  DWORD RetLen;
471  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INDEXED_STRING,
472  &StringIndex, sizeof(ULONG),
474  &RetLen, NULL) != 0;
475 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_HID_GET_INDEXED_STRING
Definition: hidclass.h:76
unsigned int ULONG
Definition: retypes.h:1

◆ HidD_GetInputReport()

HIDAPI BOOLEAN WINAPI HidD_GetInputReport ( IN HANDLE  HidDeviceObject,
IN OUT PVOID  ReportBuffer,
IN ULONG  ReportBufferLength 
)

Definition at line 215 of file hid.c.

218 {
219  DWORD RetLen;
220  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_INPUT_REPORT,
221  NULL, 0,
222  ReportBuffer, ReportBufferLength,
223  &RetLen, NULL) != 0;
224 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_HID_GET_INPUT_REPORT
Definition: hidclass.h:63
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

Referenced by test_get_input_report().

◆ HidD_GetManufacturerString()

HIDAPI BOOLEAN WINAPI HidD_GetManufacturerString ( IN HANDLE  HidDeviceObject,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 234 of file hid.c.

237 {
238  DWORD RetLen;
239  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MANUFACTURER_STRING,
240  NULL, 0,
242  &RetLen, NULL) != 0;
243 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define IOCTL_HID_GET_MANUFACTURER_STRING
Definition: hidclass.h:64
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ HidD_GetMsGenreDescriptor()

HIDAPI BOOLEAN WINAPI HidD_GetMsGenreDescriptor ( IN HANDLE  HidDeviceObject,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 484 of file hid.c.

487 {
488  DWORD RetLen;
489  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_MS_GENRE_DESCRIPTOR,
490  0, 0,
492  &RetLen, NULL) != 0;
493 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define IOCTL_HID_GET_MS_GENRE_DESCRIPTOR
Definition: hidclass.h:77
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ HidD_GetNumInputBuffers()

HIDAPI BOOLEAN WINAPI HidD_GetNumInputBuffers ( IN HANDLE  HidDeviceObject,
OUT PULONG  NumberBuffers 
)

Definition at line 253 of file hid.c.

255 {
256  DWORD RetLen;
257  return DeviceIoControl(HidDeviceObject, IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS,
258  NULL, 0,
259  NumberBuffers, sizeof(ULONG),
260  &RetLen, NULL) != 0;
261 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS
Definition: hidclass.h:65
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
unsigned int ULONG
Definition: retypes.h:1

◆ HidD_GetPhysicalDescriptor()

HIDAPI BOOLEAN WINAPI HidD_GetPhysicalDescriptor ( IN HANDLE  HidDeviceObject,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 271 of file hid.c.

274 {
275  DWORD RetLen;
276  return DeviceIoControl(HidDeviceObject, IOCTL_GET_PHYSICAL_DESCRIPTOR,
277  NULL, 0,
279  &RetLen, NULL) != 0;
280 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define IOCTL_GET_PHYSICAL_DESCRIPTOR
Definition: hidclass.h:56
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ HidD_GetPreparsedData()

HIDAPI BOOLEAN WINAPI HidD_GetPreparsedData ( IN HANDLE  HidDeviceObject,
OUT PHIDP_PREPARSED_DATA PreparsedData 
)

Definition at line 290 of file hid.c.

292 {
294  DWORD RetLen;
295  BOOLEAN Ret;
296 
297  if(PreparsedData == NULL)
298  {
299  return FALSE;
300  }
301 
303  NULL, 0,
304  &hci, sizeof(HID_COLLECTION_INFORMATION),
305  &RetLen, NULL))
306  {
307  return FALSE;
308  }
309 
311  if(*PreparsedData == NULL)
312  {
314  return FALSE;
315  }
316 
318  NULL, 0,
320  &RetLen, NULL) != 0;
321 
322  if(!Ret)
323  {
324  /* FIXME - Free the buffer in case we failed to get the descriptor? */
326  }
327 #if 0
328  else
329  {
330  /* should we truncate the memory in case RetLen < hci.DescriptorSize? */
331  }
332 #endif
333 
334  return Ret;
335 }
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG _In_ PHIDP_PREPARSED_DATA PreparsedData
Definition: hidpi.h:333
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define IOCTL_HID_GET_COLLECTION_DESCRIPTOR
Definition: hidclass.h:58
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
#define IOCTL_HID_GET_COLLECTION_INFORMATION
Definition: hidclass.h:59
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define LHND
Definition: winbase.h:363
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373

Referenced by get_device(), test_device_info(), test_get_input_report(), and test_read_device().

◆ HidD_GetProductString()

HIDAPI BOOLEAN WINAPI HidD_GetProductString ( IN HANDLE  HidDeviceObject,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 345 of file hid.c.

348 {
349  DWORD RetLen;
350  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_PRODUCT_STRING,
351  NULL, 0,
353  &RetLen, NULL) != 0;
354 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_HID_GET_PRODUCT_STRING
Definition: hidclass.h:67
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

Referenced by test_device_info(), test_get_input_report(), and test_read_device().

◆ HidD_GetSerialNumberString()

HIDAPI BOOLEAN WINAPI HidD_GetSerialNumberString ( IN HANDLE  HidDeviceObject,
OUT PVOID  Buffer,
IN ULONG  BufferLength 
)

Definition at line 364 of file hid.c.

367 {
368  DWORD RetLen;
369  return DeviceIoControl(HidDeviceObject, IOCTL_HID_GET_SERIALNUMBER_STRING,
370  NULL, 0,
372  &RetLen, NULL) != 0;
373 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
#define IOCTL_HID_GET_SERIALNUMBER_STRING
Definition: hidclass.h:68
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ HidD_Hello()

HIDAPI ULONG WINAPI HidD_Hello ( OUT PCHAR  Buffer,
IN ULONG  BufferLength 
)

Definition at line 389 of file hid.c.

391 {
392  const CHAR HelloString[] = "Hello\n";
393 
394  if(BufferLength > 0)
395  {
396  memcpy(Buffer, HelloString, min(sizeof(HelloString), BufferLength));
397  }
398 
399  return sizeof(HelloString);
400 }
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG BufferLength
Definition: cdrom.h:989
char CHAR
Definition: xmlstorage.h:175
Definition: bufpool.h:45
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55

◆ HidD_SetConfiguration()

HIDAPI BOOLEAN WINAPI HidD_SetConfiguration ( IN HANDLE  HidDeviceObject,
IN PHIDD_CONFIGURATION  Configuration,
IN ULONG  ConfigurationLength 
)

Definition at line 523 of file hid.c.

526 {
527  BOOLEAN Ret = FALSE;
528 
529  if (Configuration->cookie == (PVOID)HidD_GetConfiguration)
530  {
531  Ret = DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_DRIVER_CONFIG,
532  0, 0,
533  (PVOID)&Configuration->size, ConfigurationLength - sizeof(ULONG),
534  (PULONG)&Configuration->cookie, NULL) != 0;
535  }
536  else
537  {
539  }
540 
541  return Ret;
542 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define IOCTL_HID_SET_DRIVER_CONFIG
Definition: hidclass.h:75
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
HIDAPI BOOLEAN WINAPI HidD_GetConfiguration(IN HANDLE HidDeviceObject, OUT PHIDD_CONFIGURATION Configuration, IN ULONG ConfigurationLength)
Definition: hid.c:502
#define SetLastError(x)
Definition: compat.h:611
CConfiguration Configuration
Definition: main.cpp:11
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1

◆ HidD_SetFeature()

HIDAPI BOOLEAN WINAPI HidD_SetFeature ( IN HANDLE  HidDeviceObject,
IN PVOID  ReportBuffer,
IN ULONG  ReportBufferLength 
)

Definition at line 410 of file hid.c.

413 {
414  DWORD RetLen;
415  return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_FEATURE,
416  ReportBuffer, ReportBufferLength,
417  NULL, 0,
418  &RetLen, NULL) != 0;
419 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define IOCTL_HID_SET_FEATURE
Definition: hidclass.h:69

◆ HidD_SetNumInputBuffers()

HIDAPI BOOLEAN WINAPI HidD_SetNumInputBuffers ( IN HANDLE  HidDeviceObject,
IN ULONG  NumberBuffers 
)

Definition at line 429 of file hid.c.

431 {
432  DWORD RetLen;
433  return DeviceIoControl(HidDeviceObject, IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS,
434  &NumberBuffers, sizeof(ULONG),
435  NULL, 0,
436  &RetLen, NULL) != 0;
437 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
unsigned int ULONG
Definition: retypes.h:1
#define IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS
Definition: hidclass.h:70

◆ HidD_SetOutputReport()

HIDAPI BOOLEAN WINAPI HidD_SetOutputReport ( IN HANDLE  HidDeviceObject,
IN PVOID  ReportBuffer,
IN ULONG  ReportBufferLength 
)

Definition at line 447 of file hid.c.

450 {
451  DWORD RetLen;
452  return DeviceIoControl(HidDeviceObject, IOCTL_HID_SET_OUTPUT_REPORT,
453  ReportBuffer, ReportBufferLength,
454  NULL, 0,
455  &RetLen, NULL) != 0;
456 }
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_HID_SET_OUTPUT_REPORT
Definition: hidclass.h:71
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136

◆ ZeroFunction()

VOID NTAPI ZeroFunction ( IN PVOID  Item,
IN ULONG  ItemSize 
)

Definition at line 61 of file hid.c.

64 {
65  memset(Item, 0, ItemSize);
66 }
static UCHAR ItemSize[4]
Definition: parser.c:16
#define memset(x, y, z)
Definition: compat.h:39

Referenced by HidParser_GetCaps(), HidParser_GetCollectionDescription(), HidParser_GetSpecificValueCapsWithReport(), HidParser_GetUsagesWithReport(), and HidParser_ParseReportDescriptor().

Variable Documentation

◆ hDllInstance

HINSTANCE hDllInstance

Definition at line 38 of file hid.c.

Referenced by DllMain().

◆ HidClassGuid

const GUID HidClassGuid = {0x4D1E55B2, 0xF16F, 0x11CF, {0x88,0xCB,0x00,0x11,0x11,0x00,0x00,0x30}}

Definition at line 41 of file hid.c.

Referenced by HidD_GetHidGuid().