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.

190 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. drdevol
  5. Abstract:
  6. This module contains a subclass of W32DrDev that uses overlapped IO
  7. implementations of read, write, and IOCTL handlers.
  8. Author:
  9. Tad Brockway 3/23/99
  10. Revision History:
  11. --*/
  12. #ifndef __DRDEVOL_H__
  13. #define __DRDEVOL_H__
  14. #include "w32drdev.h"
  15. ///////////////////////////////////////////////////////////////
  16. //
  17. // _W32DRDEV_OVERLAPPEDIO_PARAMS
  18. //
  19. // Async IO Parameters
  20. //
  21. class W32DrDeviceOverlapped;
  22. class W32DRDEV_OVERLAPPEDIO_PARAMS : public DrObject
  23. {
  24. public:
  25. #if DBG
  26. ULONG magicNo;
  27. #endif
  28. W32DrDeviceOverlapped *pObject;
  29. PRDPDR_IOREQUEST_PACKET pIoRequestPacket;
  30. PRDPDR_IOCOMPLETION_PACKET pIoReplyPacket;
  31. ULONG IoReplyPacketSize;
  32. OVERLAPPED overlapped;
  33. //
  34. // Constructor/Destructor
  35. //
  36. W32DRDEV_OVERLAPPEDIO_PARAMS(W32DrDeviceOverlapped *pObj,
  37. PRDPDR_IOREQUEST_PACKET pIOP) {
  38. pIoRequestPacket = pIOP;
  39. pObject = pObj;
  40. pIoReplyPacket = NULL;
  41. IoReplyPacketSize = 0;
  42. #if DBG
  43. magicNo = GOODMEMMAGICNUMBER;
  44. #endif
  45. memset(&overlapped, 0, sizeof(overlapped));
  46. }
  47. ~W32DRDEV_OVERLAPPEDIO_PARAMS() {
  48. DC_BEGIN_FN("~W32DRDEV_OVERLAPPEDIO_PARAMS");
  49. #if DBG
  50. ASSERT(magicNo == GOODMEMMAGICNUMBER);
  51. #endif
  52. ASSERT(overlapped.hEvent == NULL);
  53. ASSERT(pIoRequestPacket == NULL);
  54. ASSERT(pIoReplyPacket == NULL);
  55. #if DBG
  56. memset(&magicNo, DRBADMEM, sizeof(magicNo));
  57. #endif
  58. DC_END_FN();
  59. }
  60. //
  61. // Return the class name.
  62. //
  63. virtual DRSTRING ClassName() { return TEXT("W32DRDEV_OVERLAPPEDIO_PARAMS"); };
  64. };
  65. ///////////////////////////////////////////////////////////////
  66. //
  67. // W32DrDeviceOverlapped
  68. //
  69. class W32DrDeviceOverlapped : public W32DrDevice
  70. {
  71. protected:
  72. //
  73. // IO Processing Functions
  74. //
  75. // This subclass of DrDevice handles the following IO requests. These
  76. // functions may be overridden in a subclass.
  77. //
  78. // pIoRequestPacket - Request packet received from server.
  79. // packetLen - Length of the packet
  80. //
  81. //
  82. virtual VOID MsgIrpCreate(
  83. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  84. IN UINT32 packetLen
  85. );
  86. //
  87. // Simultaneously Handles Read and Write IO requests.
  88. //
  89. VOID MsgIrpReadWrite(PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  90. IN UINT32 packetLen);
  91. //
  92. // Read and Writes are handled uniformly.
  93. //
  94. virtual VOID MsgIrpRead(
  95. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  96. IN UINT32 packetLen
  97. ) {
  98. DC_BEGIN_FN("W32DrDevice::MsgIrpRead");
  99. MsgIrpReadWrite(pIoRequestPacket, packetLen);
  100. DC_END_FN();
  101. }
  102. virtual VOID MsgIrpWrite(
  103. IN PRDPDR_IOREQUEST_PACKET pIoRequestPacket,
  104. IN UINT32 packetLen
  105. ) {
  106. DC_BEGIN_FN("W32DrDevice::MsgIrpWrite");
  107. MsgIrpReadWrite(pIoRequestPacket, packetLen);
  108. DC_END_FN();
  109. }
  110. //
  111. // Dispatch an IOCTL directly to the device driver. This will
  112. // likely not work for platforms that don't match the server
  113. // platform.
  114. //
  115. VOID DispatchIOCTLDirectlyToDriver(
  116. PRDPDR_IOREQUEST_PACKET pIoRequestPacket
  117. );
  118. //
  119. // Async IO Management Functions
  120. //
  121. virtual HANDLE StartReadIO(W32DRDEV_OVERLAPPEDIO_PARAMS *params,
  122. DWORD *status);
  123. virtual HANDLE StartWriteIO(W32DRDEV_OVERLAPPEDIO_PARAMS *params,
  124. DWORD *status);
  125. virtual HANDLE StartIOCTL(W32DRDEV_OVERLAPPEDIO_PARAMS *params,
  126. OUT DWORD *status);
  127. static HANDLE _StartIOFunc(PVOID params, DWORD *status);
  128. VOID CompleteIOFunc(W32DRDEV_OVERLAPPEDIO_PARAMS *params,
  129. DWORD status);
  130. static VOID _CompleteIOFunc(PVOID params, DWORD status);
  131. virtual VOID CancelIOFunc(W32DRDEV_OVERLAPPEDIO_PARAMS *params);
  132. static VOID _CancelIOFunc(W32DRDEV_OVERLAPPEDIO_PARAMS *params);
  133. public:
  134. //
  135. // Public Methods
  136. //
  137. // Constructor/Destructor
  138. W32DrDeviceOverlapped(
  139. ProcObj *processObject, ULONG deviceID,
  140. const TCHAR *devicePath) :
  141. W32DrDevice(processObject, deviceID, devicePath) {}
  142. // Return the class name.
  143. virtual DRSTRING ClassName() { return TEXT("W32DrDeviceOverlapped"); }
  144. };
  145. #endif