1 #ifndef _FBT_HW_H_ 2 #define _FBT_HW_H_ 3 4 #include <winioctl.h> 5 6 // HW Driver Abstraction layer 7 class CBTHW 8 { 9 public: 10 // The driver is opened for OVERLAPPED I/O 11 CBTHW(); 12 virtual ~CBTHW(); 13 14 // Set the driver instances symbolic name 15 void SetDeviceName(LPCTSTR szDeviceName); 16 DWORD GetDeviceName(LPTSTR szBuffer, DWORD dwBufferSize); 17 18 // Open a handle to the driver instance 19 virtual DWORD Attach(LPCSTR szDeviceName); 20 virtual DWORD Detach(); 21 HANDLE GetDriverHandle(); IsAttached()22 BOOL IsAttached() {return GetDriverHandle()!=INVALID_HANDLE_VALUE;} 23 24 // Send a command to the driver 25 DWORD SendCommand(DWORD dwCommand, LPVOID lpInBuffer=NULL, DWORD dwInBufferSize=0, LPVOID lpOutBuffer=NULL, DWORD dwOutBufferSize=0, OVERLAPPED *pOverlapped=NULL); 26 DWORD SendData(LPVOID lpBuffer, DWORD dwBufferSize, DWORD *dwBytesSent, OVERLAPPED *pOverlapped); 27 DWORD GetData(LPVOID lpBuffer, DWORD dwBufferSize, DWORD *dwBytesRead, OVERLAPPED *pOverlapped); 28 29 protected: 30 HANDLE m_hDriver; 31 TCHAR m_szDeviceName[1024]; 32 33 }; 34 35 36 #endif // _FBT_HW_H_ 37