Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
5.6 KiB

  1. /*
  2. ********************************************************************************
  3. *
  4. * VXDCLNT.H
  5. *
  6. *
  7. * VXDCLNT - Sample Ring-0 HID device mapper for Memphis
  8. *
  9. * Copyright 1997 Microsoft Corp.
  10. *
  11. * (ep)
  12. *
  13. ********************************************************************************
  14. */
  15. #define WANTVXDWRAPS
  16. #include <basetyps.h>
  17. #include <wdm.h>
  18. #include <BASEDEF.H>
  19. #include <vmm.h>
  20. #include <vxdldr.h>
  21. #include <ntkern.h>
  22. #include <vxdwraps.h>
  23. #include <hidusage.h>
  24. #include <hidpi.h>
  25. #include <hidclass.h>
  26. /*
  27. * Type definitions for imported functions.
  28. */
  29. typedef NTSTATUS (*t_pIoGetDeviceClassAssociations) (
  30. IN LPGUID ClassGuid,
  31. IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL,
  32. IN ULONG Flags,
  33. OUT PWSTR *SymbolicLinkList
  34. );
  35. typedef NTSTATUS (__stdcall *t_pHidP_GetCaps) (
  36. IN PHIDP_PREPARSED_DATA PreparsedData,
  37. OUT PHIDP_CAPS Capabilities
  38. );
  39. typedef NTSTATUS (__stdcall *t_pHidP_GetUsages) (
  40. IN HIDP_REPORT_TYPE ReportType,
  41. IN USAGE UsagePage,
  42. IN USHORT LinkCollection, // Optional
  43. OUT USAGE * UsageList,
  44. IN OUT ULONG * UsageLength,
  45. IN PHIDP_PREPARSED_DATA PreparsedData,
  46. IN PCHAR Report,
  47. IN ULONG ReportLength
  48. );
  49. typedef NTSTATUS (__stdcall *t_pHidP_GetUsageValue) (
  50. IN HIDP_REPORT_TYPE ReportType,
  51. IN USAGE UsagePage,
  52. IN USHORT LinkCollection, // Optional
  53. IN USAGE Usage,
  54. OUT PULONG UsageValue,
  55. IN PHIDP_PREPARSED_DATA PreparsedData,
  56. IN PCHAR Report,
  57. IN ULONG ReportLength
  58. );
  59. typedef NTSTATUS (*t_pHidP_SetUsages) (
  60. IN HIDP_REPORT_TYPE ReportType,
  61. IN USAGE UsagePage,
  62. IN USHORT LinkCollection, // Optional
  63. IN PUSAGE UsageList,
  64. IN OUT PULONG UsageLength,
  65. IN PHIDP_PREPARSED_DATA PreparsedData,
  66. IN OUT PCHAR Report,
  67. IN ULONG ReportLength
  68. );
  69. typedef NTSTATUS (__stdcall *t_pHidP_GetScaledUsageValue) (
  70. IN HIDP_REPORT_TYPE ReportType,
  71. IN USAGE UsagePage,
  72. IN USHORT LinkCollection, // Optional
  73. IN USAGE Usage,
  74. OUT PLONG UsageValue,
  75. IN PHIDP_PREPARSED_DATA PreparsedData,
  76. IN PCHAR Report,
  77. IN ULONG ReportLength
  78. );
  79. typedef ULONG (__stdcall *t_pHidP_MaxUsageListLength) (
  80. IN HIDP_REPORT_TYPE ReportType,
  81. IN USAGE UsagePage,
  82. IN PHIDP_PREPARSED_DATA PreparsedData
  83. );
  84. typedef NTSTATUS (__stdcall * t_pHidP_GetValueCaps) (
  85. IN HIDP_REPORT_TYPE ReportType,
  86. OUT PHIDP_VALUE_CAPS ValueCaps,
  87. IN OUT PULONG ValueCapsLength,
  88. IN PHIDP_PREPARSED_DATA PreparsedData
  89. );
  90. typedef struct tag_writeReport {
  91. PUCHAR report;
  92. ULONG reportLen;
  93. struct tag_writeReport *next;
  94. } writeReport;
  95. typedef struct tag_deviceContext {
  96. HANDLE devHandle;
  97. BOOL readPending;
  98. PUCHAR report;
  99. LARGE_INTEGER dataLength;
  100. HIDP_CAPS hidCapabilities;
  101. PHIDP_VALUE_CAPS valueCaps;
  102. PHIDP_PREPARSED_DATA hidDescriptor;
  103. IO_STATUS_BLOCK ioStatusBlock;
  104. WORK_QUEUE_ITEM workItemRead;
  105. WORK_QUEUE_ITEM workItemWrite;
  106. WORK_QUEUE_ITEM workItemClose;
  107. UINT buttonListLength;
  108. PUSAGE buttonValues;
  109. WCHAR deviceFileName[(MAXIMUM_FILENAME_LENGTH*sizeof(WCHAR))+sizeof(UNICODE_NULL)];
  110. writeReport *writeReportQueue;
  111. VMM_SEMAPHORE writeReportQueueSemaphore;
  112. struct tag_deviceContext *next;
  113. } deviceContext;
  114. #ifdef DEBUG
  115. extern UINT dbgOpt;
  116. #define DBGOUT(msg_in_parens) if (dbgOpt) { _Debug_Printf_Service("\r\nVXDCLNT> "); _Debug_Printf_Service msg_in_parens; _Debug_Printf_Service("\r\n"); }
  117. #define DBGERR(msg_in_parens) { _Debug_Printf_Service("\r\n *** VXDCLNT ERROR *** \r\nVXDCLNT> "); _Debug_Printf_Service msg_in_parens; _Debug_Printf_Service("\r\n"); }
  118. #define DBGBREAK() { _asm { int 3 } }
  119. #else
  120. #define DBGOUT(msg_in_parens)
  121. #define DBGERR(msg_in_parens)
  122. #define DBGBREAK()
  123. #endif
  124. _inline VOID Signal_Semaphore_No_Switch(VMM_SEMAPHORE sem)
  125. {
  126. _asm mov eax, [sem]
  127. VMMCall(Signal_Semaphore_No_Switch)
  128. }
  129. VOID ReadCompletion(IN PVOID Context, IN PIO_STATUS_BLOCK IoStatusBlock, IN ULONG Reserved);
  130. VOID VMDPostPointerMessage(LONG deltaX, LONG deltaY, ULONG Buttons, ULONG Wheel);
  131. VOID VMDPostAbsolutePointerMessage(LONG deltaX, LONG deltaY, ULONG Buttons);
  132. VOID WorkItemCallback_Read(PVOID context);
  133. VOID WorkItemCallback_Write(PVOID context);
  134. VOID WorkItemCallback_Open(PVOID context);
  135. VOID WorkItemCallback_Close(PVOID context);
  136. VOID ConnectNTDeviceDrivers();
  137. VOID _cdecl DispatchNtReadFile(deviceContext *device);
  138. extern BOOL ShutDown;
  139. extern t_pHidP_GetUsageValue pHidP_GetUsageValue;
  140. extern t_pHidP_GetScaledUsageValue pHidP_GetScaledUsageValue;
  141. extern t_pHidP_SetUsages pHidP_SetUsages;
  142. extern t_pHidP_GetUsages pHidP_GetUsages;
  143. extern t_pHidP_MaxUsageListLength pHidP_MaxUsageListLength;
  144. extern t_pIoGetDeviceClassAssociations pIoGetDeviceClassAssociations;
  145. extern t_pHidP_GetCaps pHidP_GetCaps;
  146. extern t_pHidP_GetValueCaps pHidP_GetValueCaps;