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.

123 lines
4.7 KiB

  1. // DeviceControl.h : Declaration of the CDeviceControl
  2. #ifndef __DEVICECONTROL_H_
  3. #define __DEVICECONTROL_H_
  4. #include "resource.h" // main symbols
  5. #include "ioblockdefs.h"
  6. //////////////////////////////////////////
  7. // Taken from NTDDK.H //
  8. //////////////////////////////////////////
  9. #define FILE_ANY_ACCESS 0
  10. #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
  11. #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
  12. #define METHOD_BUFFERED 0
  13. #define METHOD_IN_DIRECT 1
  14. #define METHOD_OUT_DIRECT 2
  15. #define METHOD_NEITHER 3
  16. #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
  17. ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
  18. )
  19. //////////////////////////////////////////
  20. // Taken from USBSCAN.H //
  21. //////////////////////////////////////////
  22. #define FILE_DEVICE_USB_SCAN 0x8000
  23. #define IOCTL_INDEX 0x0800
  24. #define IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX, METHOD_BUFFERED,FILE_ANY_ACCESS)
  25. #define IOCTL_CANCEL_IO CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+1, METHOD_BUFFERED,FILE_ANY_ACCESS)
  26. #define IOCTL_WAIT_ON_DEVICE_EVENT CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+2, METHOD_BUFFERED,FILE_ANY_ACCESS)
  27. #define IOCTL_READ_REGISTERS CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+3, METHOD_BUFFERED,FILE_ANY_ACCESS)
  28. #define IOCTL_WRITE_REGISTERS CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+4, METHOD_BUFFERED,FILE_ANY_ACCESS)
  29. #define IOCTL_GET_CHANNEL_ALIGN_RQST CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+5, METHOD_BUFFERED,FILE_ANY_ACCESS)
  30. #define IOCTL_GET_DEVICE_DESCRIPTOR CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+6, METHOD_BUFFERED,FILE_ANY_ACCESS)
  31. #define IOCTL_RESET_PIPE CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+7, METHOD_BUFFERED,FILE_ANY_ACCESS)
  32. #define IOCTL_GET_USB_DESCRIPTOR CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+8, METHOD_BUFFERED,FILE_ANY_ACCESS)
  33. #define IOCTL_SEND_USB_REQUEST CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+9, METHOD_BUFFERED,FILE_ANY_ACCESS)
  34. #define IOCTL_GET_PIPE_CONFIGURATION CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+10,METHOD_BUFFERED,FILE_ANY_ACCESS)
  35. typedef struct _IO_BLOCK {
  36. IN unsigned uOffset;
  37. IN unsigned uLength;
  38. IN OUT PUCHAR pbyData;
  39. IN unsigned uIndex;
  40. } IO_BLOCK, *PIO_BLOCK;
  41. ///////////////////////////////////////////
  42. #define IOCTL_GET_DEVICE_INFO 0x0
  43. #define IOCTL_GET_DEVICE_STATUS 0x1
  44. #define IOCTL_READ_WRITE_DATA 0x82
  45. #define IOCTL_EPP_ADDR 0x83
  46. #define IOCTL_EPP_READ 0x84
  47. #define IOCTL_EPP_WRITE 0x85
  48. #define IOCTL_SPP_STATUS 0x86
  49. #define IOCTL_SPP_CONTROL 0x87
  50. #define IOCTL_SPP_DATA_BUS 0x88
  51. #define IOCTL_GPIO_OE 0x89
  52. #define IOCTL_GPIO_READ 0x8A
  53. #define IOCTL_GPIO_WRITE 0x8B
  54. ////////////////////////////////////////////////
  55. // Custom BITS structure for bit manipulation //
  56. ////////////////////////////////////////////////
  57. typedef struct _BITS{
  58. BYTE b0 :1;
  59. BYTE b1 :1;
  60. BYTE b2 :1;
  61. BYTE b3 :1;
  62. BYTE b4 :1;
  63. BYTE b5 :1;
  64. BYTE b6 :1;
  65. BYTE b7 :1;
  66. }BITS;
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CDeviceControl
  69. class ATL_NO_VTABLE CDeviceControl :
  70. public CComObjectRootEx<CComSingleThreadModel>,
  71. public CComCoClass<CDeviceControl, &CLSID_DeviceControl>,
  72. public IDispatchImpl<IDeviceControl, &IID_IDeviceControl, &LIBID_WIAFBLib>,
  73. public IObjectSafetyImpl<CDeviceControl, INTERFACESAFE_FOR_UNTRUSTED_CALLER>
  74. {
  75. public:
  76. SCANSETTINGS *m_pScannerSettings;
  77. BYTE *m_pBuffer;
  78. LONG m_lBufferSize;
  79. DWORD m_dwBytesRead;
  80. CDeviceControl()
  81. {
  82. m_pBuffer = NULL;
  83. m_lBufferSize = 0;
  84. m_dwBytesRead = 0;
  85. }
  86. DECLARE_REGISTRY_RESOURCEID(IDR_DEVICECONTROL)
  87. DECLARE_PROTECT_FINAL_CONSTRUCT()
  88. BEGIN_COM_MAP(CDeviceControl)
  89. COM_INTERFACE_ENTRY(IDeviceControl)
  90. COM_INTERFACE_ENTRY(IDispatch)
  91. END_COM_MAP()
  92. // IDeviceControl
  93. public:
  94. STDMETHOD(RawWrite)(LONG lPipeNum,VARIANT *pvbuffer,LONG lbuffersize,LONG lTimeout);
  95. STDMETHOD(RawRead)(LONG lPipeNum,VARIANT *pvbuffer,LONG lbuffersize,LONG *plbytesread,LONG lTimeout);
  96. STDMETHOD(ScanRead)(LONG lPipeNum,LONG lBytesToRead, LONG *plBytesRead, LONG lTimeout);
  97. STDMETHOD(RegisterWrite)(LONG lPipeNum,VARIANT *pvbuffer,LONG lTimeout);
  98. STDMETHOD(RegisterRead)(LONG lPipeNum,LONG lRegNumber, VARIANT *pvbuffer,LONG lTimeout);
  99. STDMETHOD(SetBitsInByte)(BYTE bMask, BYTE bValue, BYTE *pbyte);
  100. };
  101. #endif //__DEVICECONTROL_H_