Leaked source code of windows server 2003
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.

183 lines
6.5 KiB

  1. // @doc
  2. /**********************************************************************
  3. *
  4. * @module SWVBENUM.h |
  5. *
  6. * Header file for SideWinde Virtual Bus Enumerator
  7. *
  8. * History
  9. * ----------------------------------------------------------
  10. * Mitchell S. Dernis Original
  11. *
  12. * (c) 1986-1998 Microsoft Corporation. All right reserved.
  13. *
  14. * @xref SWBENUM.C
  15. *
  16. **********************************************************************/
  17. //---------------------------------------------------------------------
  18. // Structures required for Virtual Bus
  19. //---------------------------------------------------------------------
  20. //
  21. // @struct SWVB_GLOBALS |
  22. // Global variables belonging to the Virtual Bus
  23. // Basic info, such as the PDO and FDO of the bus itself,
  24. // which is really a HID PDO, and a filter (not function) Device
  25. // Object which is letting us use it also as a Bus FDO.
  26. //
  27. typedef struct tagSWVB_GLOBALS
  28. {
  29. PDEVICE_OBJECT pBusFdo; //@field Pointer to Fdo to use as BUS
  30. PDEVICE_OBJECT pBusPdo; //@field Pointer to Pdo to use as BUS
  31. ULONG ulDeviceRelationsAllocCount; //@field Allocated count for device relations
  32. PDEVICE_RELATIONS pDeviceRelations; //@field Device Relations holds PDOs on bus
  33. ULONG ulDeviceNumber; //@field Used to name devices
  34. } SWVB_GLOBALS, *PSWVB_GLOBALS;
  35. //
  36. // @struct SWVB_DEVICE_SERVICE_TABLE |
  37. // Service table that Virtual Device Module
  38. // gives to Virtual Bus on the <f SWVB_Expose>
  39. // call. The PnP entries are only if the Virtual
  40. // Device needs additional processing for these. Particularly,
  41. // remove if anything in the Virtual Device part of the extension
  42. // is dynamically allocated. The usual malarkey is handled by the
  43. // SWVBENUM code.
  44. //
  45. typedef struct tagSWVB_DEVICE_SERVICE_TABLE
  46. {
  47. PDRIVER_DISPATCH pfnCreate; //@field Entry point IRP_MJ_CREATE
  48. PDRIVER_DISPATCH pfnClose; //@field Entry point IRP_MJ_CLOSE
  49. PDRIVER_DISPATCH pfnRead; //@field Entry point IRP_MJ_READ
  50. PDRIVER_DISPATCH pfnWrite; //@field Entry point IRP_MJ_WRITE
  51. PDRIVER_DISPATCH pfnIoctl; //@field Entry point IRP_MJ_IOCTL
  52. PDRIVER_DISPATCH pfnStart; //@field Entry point IRP_MJ_PNP\IRP_MN_START
  53. PDRIVER_DISPATCH pfnStop; //@field Entry point IRP_MJ_PNP\IRP_MN_STOP
  54. PDRIVER_DISPATCH pfnRemove; //@field Entry point IRP_MJ_PNP\IRP_MN_REMOVE
  55. } SWVB_DEVICE_SERVICE_TABLE, *PSWVB_DEVICE_SERVICE_TABLE;
  56. typedef NTSTATUS (*PFN_GCK_INIT_DEVICE)(PDEVICE_OBJECT pDeviceObject, ULONG ulInitContext);
  57. //
  58. // @struct SWVB_EXPOSE_DATA |
  59. // Data that must be passed on calls to <f GCK_SWVB_Expose>
  60. //
  61. typedef struct tagSWVB_EXPOSE_DATA
  62. {
  63. ULONG ulDeviceExtensionSize; // @field [in] Size of extension needed by virtual device
  64. PSWVB_DEVICE_SERVICE_TABLE pServiceTable; // @field [in] Pointer to service table of virtual device
  65. PWCHAR pmwszDeviceId; // @field [in] HardwareID for new device, without enumerator name
  66. PFN_GCK_INIT_DEVICE pfnInitDevice; // @field [in] Callback to initialize new Device Object
  67. ULONG ulInitContext; // @field [in] COntext for pfnInitDevice
  68. ULONG ulInstanceNumber; // @field [in] Instance Number of new device
  69. } SWVB_EXPOSE_DATA, *PSWVB_EXPOSE_DATA;
  70. //
  71. // @struct SWVB_PDO_EXT |
  72. // Device Extensions for PDOs created by the SWVB
  73. // Appended to this extension is the device extension
  74. // size requested by the virtual device module
  75. // in the <f SWVB_Expose> call.
  76. typedef struct tagSWVB_PDO_EXT
  77. {
  78. ULONG ulGckDevObjType; // @field Type of GcKernel device object.
  79. BOOLEAN fStarted; // @field Marks that Virtual Device is started
  80. BOOLEAN fRemoved; // @field Marks that Virtual Device is removed
  81. BOOLEAN fAttached; // @field The device is attached as long as we say it is.
  82. PSWVB_DEVICE_SERVICE_TABLE pServiceTable; // @field Service Table for virtual device
  83. GCK_REMOVE_LOCK RemoveLock; // @field Custom Remove Lock
  84. PWCHAR pmwszHardwareID; // @field HardwareID of device
  85. ULONG ulInstanceNumber; // @field Instance number
  86. ULONG ulOpenCount; // @field Count of open handles
  87. }SWVB_PDO_EXT, *PSWVB_PDO_EXT;
  88. //
  89. // Accessor for instance number of PSWVB_PDO_EXT
  90. //
  91. inline ULONG GCK_SWVB_GetInstanceNumber(PDEVICE_OBJECT pDeviceObject)
  92. {
  93. PSWVB_PDO_EXT pPdoExt = (PSWVB_PDO_EXT)pDeviceObject->DeviceExtension;
  94. ASSERT(GCK_DO_TYPE_SWVB == pPdoExt->ulGckDevObjType);
  95. return pPdoExt->ulInstanceNumber;
  96. }
  97. //---------------------------------------------------------------------------
  98. // Error Codes specific to SWVB
  99. //---------------------------------------------------------------------------
  100. //---------------------------------------------------------------------------
  101. // Macros
  102. //---------------------------------------------------------------------------
  103. //
  104. // @func PVOID | SWVB_GetVirtualDeviceExtension |
  105. // Accesses Device Extension of PDO exposed on the SWVB.
  106. // @rdesc Returns pointer to Virtual Device Part of DeviceExtension
  107. // @parm PDEVICE_OBJECT | [in] pDeviceObject |
  108. // Pointer to DeviceObject to get extension from.
  109. // @comm Implemented as MACRO.
  110. //
  111. #define GCK_SWVB_GetVirtualDeviceExtension(__pDeviceObject__) \
  112. (\
  113. (PVOID)\
  114. (\
  115. (PCHAR)\
  116. ( (__pDeviceObject__)->DeviceExtension )\
  117. + sizeof(SWVB_PDO_EXT)\
  118. )\
  119. )
  120. //---------------------------------------------------------------------------
  121. // #define strings
  122. //---------------------------------------------------------------------------
  123. #define SWVB_DEVICE_NAME_BASE L"\\Device\\SideWinderVirtualDevicePdo_000"
  124. #define SWVB_DEVICE_NAME_TMPLT L"\\Device\\SideWinderVirtualDevicePdo_%0.3x"
  125. #define SWVB_BUS_ID L"SWVBENUM\\"
  126. #define SWVB_HARDWARE_ID_TMPLT L"SWVBENUM\\%s"
  127. #define SWVB_INSTANCE_EXT L"_000"
  128. #define SWVB_INSTANCE_ID_TMPLT L"%s_%0.3d"
  129. //---------------------------------------------------------------------------
  130. // General entry points defined in GckShell.h
  131. //---------------------------------------------------------------------------
  132. #ifndef __gckshell_h__
  133. #include "gckshell.h"
  134. #endif
  135. //---------------------------------------------------------------------------
  136. // Function declarations - autodoc comments in .c file
  137. //---------------------------------------------------------------------------
  138. extern "C"
  139. {
  140. NTSTATUS
  141. GCK_SWVB_SetBusDOs
  142. (
  143. IN PDEVICE_OBJECT pBusFdo,
  144. IN PDEVICE_OBJECT pBusPdo
  145. );
  146. NTSTATUS
  147. GCK_SWVB_HandleBusRelations
  148. (
  149. IN OUT PIO_STATUS_BLOCK pIoStatus
  150. );
  151. NTSTATUS
  152. GCK_SWVB_Expose
  153. (
  154. IN PSWVB_EXPOSE_DATA pSwvbExposeData
  155. );
  156. NTSTATUS
  157. GCK_SWVB_Remove
  158. (
  159. IN PDEVICE_OBJECT pPdo
  160. );
  161. ULONG
  162. MultiSzWByteLength
  163. (
  164. PWCHAR pmwszBuffer
  165. );
  166. }