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.

131 lines
4.4 KiB

  1. // Gemplus (C) 1999
  2. //
  3. // Version 1.0
  4. // Author: Sergey Ivanov
  5. // Date of creation - 11.01.1999
  6. // Change log:
  7. //
  8. #ifndef USB_READER
  9. #define USB_READER
  10. #include "debug.h"
  11. #include "thread.h"
  12. #include "usbdev.h"
  13. #include "reader.h"
  14. class CUSBDevice;
  15. class CReader;
  16. class CSmartCard;
  17. //class CGemCore;//TOBE REMOVED
  18. #pragma PAGEDCODE
  19. class CUSBReader : public CUSBDevice, public CReader
  20. {
  21. public:
  22. NTSTATUS m_Status;
  23. SAFE_DESTRUCTORS();
  24. virtual VOID dispose(){self_delete();};
  25. protected:
  26. virtual ~CUSBReader();
  27. public:
  28. CUSBReader();
  29. virtual PDEVICE_OBJECT getSystemDeviceObject()
  30. {
  31. PDEVICE_OBJECT pFdo = getSystemObject();
  32. TRACE("Reader reports device object 0x%x\n",pFdo);
  33. return pFdo;
  34. };
  35. virtual VOID reader_set_busy();
  36. virtual VOID reader_set_Idle();
  37. virtual NTSTATUS reader_WaitForIdle();
  38. virtual NTSTATUS reader_WaitForIdleAndBlock();
  39. // We support asynchronous communications only for Open and DeviceIOControl functions...
  40. virtual NTSTATUS open(PIRP Irp);
  41. virtual NTSTATUS thread_open(IN PIRP Irp);
  42. virtual NTSTATUS close(PIRP Irp);
  43. virtual NTSTATUS deviceControl(IN PIRP Irp);
  44. virtual NTSTATUS thread_deviceControl(IN PIRP Irp);
  45. virtual NTSTATUS cleanup(PIRP irp);
  46. //Overwrite some generic USB device handlers
  47. virtual NTSTATUS PnP_HandleSurprizeRemoval(IN PIRP Irp);
  48. virtual VOID setNotificationState(ULONG state){StateToNotify = state;};
  49. virtual ULONG getNotificationState(){ return StateToNotify;};
  50. virtual BOOL isSmartCardInitialized(){return scard_Initialized;};
  51. virtual VOID setSmartCardInitialized(BOOL state) {scard_Initialized = state;};
  52. virtual PSMARTCARD_EXTENSION getCardExtention()
  53. {
  54. return &smartCardExtention;
  55. };
  56. virtual CSmartCard* getSmartCard()
  57. {
  58. return smartCard;
  59. };
  60. //virtual BOOL createInterface(LONG interfaceType, LONG protocolType,CDevice* device);//TOBE CHANGED
  61. virtual BOOL createInterface(LONG interfaceType, LONG protocolType,CUSBReader* device);
  62. virtual VOID initializeSmartCardSystem();
  63. virtual ULONG reader_UpdateCardState();
  64. virtual VOID completeCardTracking();
  65. virtual BOOLEAN setDevicePowerState(IN DEVICE_POWER_STATE DeviceState);
  66. // Do specific step on the way system goes down
  67. virtual VOID onSystemPowerDown();
  68. virtual VOID onSystemPowerUp();
  69. virtual NTSTATUS reader_getVersion(PUCHAR pVersion, PULONG pLength);
  70. virtual NTSTATUS reader_setMode(ULONG mode);
  71. #ifdef DEBUG
  72. virtual NTSTATUS reader_Read(IN PIRP Irp);
  73. virtual NTSTATUS reader_Write(IN PIRP Irp);
  74. #endif
  75. virtual NTSTATUS reader_Read(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  76. virtual NTSTATUS reader_Write(BYTE* pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  77. virtual NTSTATUS reader_Ioctl(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  78. virtual NTSTATUS reader_SwitchSpeed(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  79. virtual NTSTATUS reader_VendorAttribute(ULONG ControlCode,BYTE* pRequest,ULONG RequestLength,BYTE* pReply,ULONG* pReplyLength);
  80. virtual NTSTATUS reader_Power(ULONG ControlCode,BYTE* pReply,ULONG* pReplyLength, BOOLEAN Specific);
  81. virtual NTSTATUS reader_SetProtocol(ULONG ProtocolRequested, UCHAR ProtocolNegociation);
  82. virtual NTSTATUS setTransparentConfig(PSCARD_CARD_CAPABILITIES cardCapabilities, BYTE NewWtx);
  83. virtual NTSTATUS reader_translate_request(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength, PSCARD_CARD_CAPABILITIES cardCapabilities, BYTE NewWtx);
  84. virtual NTSTATUS reader_translate_response(BYTE * pRequest,ULONG RequestLength,BYTE * pReply,ULONG* pReplyLength);
  85. #ifdef DEBUG
  86. // virtual NTSTATUS read(IN PIRP Irp);
  87. // virtual NTSTATUS write(IN PIRP Irp);
  88. #endif
  89. static VOID PoolingThreadFunction(CUSBReader* device);
  90. virtual NTSTATUS PoolingThreadRoutine();
  91. virtual NTSTATUS startIoRequest(CPendingIRP* IrpReq);
  92. virtual NTSTATUS ThreadRoutine();//Overwrite standard function...
  93. virtual VOID onDeviceStart();
  94. virtual VOID onDeviceStop();
  95. private:
  96. BOOL scard_Initialized;
  97. // Interface to communicate with reader from smartCard system...
  98. CReaderInterface* interface;
  99. //CGemCore* interface;//TOBE CHANGED
  100. //ULONG CardState;
  101. ULONG StateToNotify;
  102. CSmartCard* smartCard;
  103. SMARTCARD_EXTENSION smartCardExtention;
  104. CThread* PoolingThread;
  105. };
  106. #endif // If defined