Source code of Windows XP (NT5)
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.

235 lines
7.5 KiB

  1. VERSION 1.0 CLASS
  2. BEGIN
  3. MultiUse = -1 'True
  4. END
  5. Attribute VB_Name = "ClusterRes"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = True
  10. Implements ClusterControl
  11. Implements ClusterResource
  12. Implements ClusterQuorumResource
  13. Const ERROR_MORE_DATA = 234
  14. Const CLUSCTL_RESOURCE_UNKNOWN = 16777216
  15. Const CLUSCTL_RESOURCE_GET_CLASS_INFO = 16777237
  16. Const CLUSCTL_RESOURCE_STORAGE_GET_DISK_INFO = 16777617
  17. Const CLUS_RESCLASS_STORAGE = 1
  18. Const CLUS_RESSUBCLASS_SHARED = -2147483648#
  19. Const CLUSPROP_SYNTAX_DISK_SIGNATURE = 327682
  20. Const CLUSPROP_SYNTAX_PARTITION_INFO = 524289
  21. Const CLUSPROP_SYNTAX_ENDMARK = 0
  22. Const CLUSPROP_PIFLAG_USABLE = 4
  23. Const MAX_PATH = 260
  24. Const byte1 = 255
  25. Const byte2 = 65280
  26. Const byte3 = 16711680
  27. Const byte4 = 4278190080#
  28. Private Function GetByte1(i)
  29. GetByte1 = i And byte1
  30. End Function
  31. Private Function GetByte2(i)
  32. GetByte2 = (i And byte2) * 2 ^ -8
  33. End Function
  34. Private Function GetByte3(i)
  35. GetByte3 = (i And byte3) * 2 ^ -16
  36. End Function
  37. Private Function GetByte4(i)
  38. Dim j As Integer
  39. j = i * 2 ^ -24
  40. If (j < 0) Then
  41. j = j + 256
  42. End If
  43. GetByte4 = j
  44. End Function
  45. Private Function ClusterControl_ResourceControl(ByVal Resource As Long, ByVal ControlCode As Long, InBuffer As Variant, OutBuffer As Variant, BytesReturned As Long) As Long
  46. Select Case ControlCode
  47. Case CLUSCTL_RESOURCE_UNKNOWN:
  48. BytesReturned = 0
  49. ClusterControl_ResourceControl = 0
  50. Case CLUSCTL_RESOURCE_GET_CLASS_INFO:
  51. ' should fill CLUS_RESOURCE_CLASS_INFO
  52. BytesReturned = 8
  53. ' 2 dwords.
  54. OutBuffer(0) = GetByte1(CLUS_RESCLASS_STORAGE)
  55. OutBuffer(1) = GetByte2(CLUS_RESCLASS_STORAGE)
  56. OutBuffer(2) = GetByte3(CLUS_RESCLASS_STORAGE)
  57. OutBuffer(3) = GetByte4(CLUS_RESCLASS_STORAGE)
  58. OutBuffer(4) = GetByte1(CLUS_RESSUBCLASS_SHARED)
  59. OutBuffer(5) = GetByte2(CLUS_RESSUBCLASS_SHARED)
  60. OutBuffer(6) = GetByte3(CLUS_RESSUBCLASS_SHARED)
  61. OutBuffer(7) = GetByte4(CLUS_RESSUBCLASS_SHARED)
  62. ClusterControl_ResourceControl = 0
  63. Case CLUSCTL_RESOURCE_STORAGE_GET_DISK_INFO:
  64. Base = 0
  65. 'PCLUSPROP_DWORD Signature
  66. OutBuffer(Base + 0) = GetByte1(CLUSPROP_SYNTAX_DISK_SIGNATURE)
  67. OutBuffer(Base + 1) = GetByte2(CLUSPROP_SYNTAX_DISK_SIGNATURE)
  68. OutBuffer(Base + 2) = GetByte3(CLUSPROP_SYNTAX_DISK_SIGNATURE)
  69. OutBuffer(Base + 3) = GetByte4(CLUSPROP_SYNTAX_DISK_SIGNATURE)
  70. Base = Base + 4
  71. ' sizeof DWORD
  72. OutBuffer(Base + 0) = GetByte1(4)
  73. OutBuffer(Base + 1) = GetByte2(4)
  74. OutBuffer(Base + 2) = GetByte3(4)
  75. OutBuffer(Base + 3) = GetByte4(4)
  76. Base = Base + 4
  77. ' Value of Signature. Give some junk
  78. OutBuffer(Base + 0) = GetByte1(4)
  79. OutBuffer(Base + 1) = GetByte2(4)
  80. OutBuffer(Base + 2) = GetByte3(4)
  81. OutBuffer(Base + 3) = GetByte4(4)
  82. Base = Base + 4
  83. 'CLUSPROP_SYNTAX_PARTITION_INFO starts
  84. OutBuffer(Base + 0) = GetByte1(CLUSPROP_SYNTAX_PARTITION_INFO)
  85. OutBuffer(Base + 1) = GetByte2(CLUSPROP_SYNTAX_PARTITION_INFO)
  86. OutBuffer(Base + 2) = GetByte3(CLUSPROP_SYNTAX_PARTITION_INFO)
  87. OutBuffer(Base + 3) = GetByte4(CLUSPROP_SYNTAX_PARTITION_INFO)
  88. Base = Base + 4
  89. ' sizeof 1128 - 8
  90. OutBuffer(Base + 0) = GetByte1(1120)
  91. OutBuffer(Base + 1) = GetByte2(1120)
  92. OutBuffer(Base + 2) = GetByte3(1120)
  93. OutBuffer(Base + 3) = GetByte4(1120)
  94. Base = Base + 4
  95. 'DWORD dwFlags;
  96. OutBuffer(Base + 0) = GetByte1(CLUSPROP_PIFLAG_USABLE)
  97. OutBuffer(Base + 1) = GetByte2(CLUSPROP_PIFLAG_USABLE)
  98. OutBuffer(Base + 2) = GetByte3(CLUSPROP_PIFLAG_USABLE)
  99. OutBuffer(Base + 3) = GetByte4(CLUSPROP_PIFLAG_USABLE)
  100. Base = Base + 4
  101. ' szDeviceName[MAX_PATH];
  102. OutBuffer(Base + 0) = Asc("C")
  103. OutBuffer(Base + 1) = 0
  104. OutBuffer(Base + 2) = Asc(":")
  105. OutBuffer(Base + 3) = 0
  106. OutBuffer(Base + 4) = Asc("\")
  107. OutBuffer(Base + 5) = 0
  108. OutBuffer(Base + 6) = 0
  109. OutBuffer(Base + 7) = 0
  110. Base = Base + MAX_PATH * 2
  111. 'szVolumeLabel[MAX_PATH];
  112. OutBuffer(Base + 0) = Asc("S")
  113. OutBuffer(Base + 1) = 0
  114. OutBuffer(Base + 2) = 0
  115. OutBuffer(Base + 3) = 0
  116. Base = Base + MAX_PATH * 2
  117. 'DWORD dwSerialNumber;
  118. OutBuffer(Base + 0) = GetByte1(777)
  119. OutBuffer(Base + 1) = GetByte2(777)
  120. OutBuffer(Base + 2) = GetByte3(777)
  121. OutBuffer(Base + 3) = GetByte4(777)
  122. Base = Base + 4
  123. 'DWORD rgdwMaximumComponentLength;
  124. OutBuffer(Base + 0) = GetByte1(255)
  125. OutBuffer(Base + 1) = GetByte2(255)
  126. OutBuffer(Base + 2) = GetByte3(255)
  127. OutBuffer(Base + 3) = GetByte4(255)
  128. Base = Base + 4
  129. ' DWORD dwFileSystemFlags;
  130. OutBuffer(Base + 0) = 0
  131. OutBuffer(Base + 1) = 0
  132. OutBuffer(Base + 2) = 0
  133. OutBuffer(Base + 3) = 0
  134. Base = Base + 4
  135. ' WCHAR szFileSystem[32];
  136. OutBuffer(Base + 0) = Asc("N")
  137. OutBuffer(Base + 1) = 0
  138. OutBuffer(Base + 2) = Asc("T")
  139. OutBuffer(Base + 3) = 0
  140. OutBuffer(Base + 4) = Asc("F")
  141. OutBuffer(Base + 5) = 0
  142. OutBuffer(Base + 6) = Asc("S")
  143. OutBuffer(Base + 7) = 0
  144. OutBuffer(Base + 8) = 0
  145. OutBuffer(Base + 9) = 0
  146. Base = Base + 64
  147. ' CLUSPROP_SYNTAX
  148. ' DWORD dw (CLUSPROP_SYNTAX_ENDMARK);
  149. OutBuffer(Base + 0) = GetByte1(CLUSPROP_SYNTAX_ENDMARK)
  150. OutBuffer(Base + 1) = GetByte2(CLUSPROP_SYNTAX_ENDMARK)
  151. OutBuffer(Base + 2) = GetByte3(CLUSPROP_SYNTAX_ENDMARK)
  152. OutBuffer(Base + 3) = GetByte4(CLUSPROP_SYNTAX_ENDMARK)
  153. Base = Base + 4
  154. BytesReturned = Base
  155. ClusterControl_ResourceControl = 0
  156. Case Else
  157. BytesReturned = 0
  158. ClusterControl_ResourceControl = 1
  159. End Select
  160. 'sizeof(CLUSPROP_SYNTAX) ; // 4
  161. End Function
  162. Private Function ClusterControl_ResourceTypeControl(ByVal ResourceTypeName As String, ByVal ControlCode As Long, InBuffer As Variant, OutBuffer As Variant, BytesReturned As Long) As Long
  163. OutBuffer(0) = 1
  164. OutBuffer(1) = 2
  165. BytesReturned = 0
  166. ClusterControl_ResourceTypeControl = 1
  167. End Function
  168. Private Function ClusterQuorumResource_QuorumArbitrate(ByVal Resource As Long, LostQuorumResource As Long) As Long
  169. ClusterQuorumResource_QuorumArbitrate = 0
  170. End Function
  171. Private Function ClusterQuorumResource_QuorumRelease(ByVal Resource As Long) As Long
  172. ClusterQuorumResource_QuorumRelease = 0
  173. End Function
  174. Private Sub ClusterResource_Close(ByVal Resource As Long)
  175. End Sub
  176. Private Function ClusterResource_IsAlive(ByVal Resource As Long) As Long
  177. ClusterResource_IsAlive = 1
  178. End Function
  179. Private Function ClusterResource_LooksAlive(ByVal Resource As Long) As Long
  180. ClusterResource_LooksAlive = 1
  181. End Function
  182. Private Function ClusterResource_Offline(ByVal Resource As Long) As Long
  183. ClusterResource_Offline = 0
  184. End Function
  185. Private Function ClusterResource_Online(ByVal Resource As Long, EventHandle As Long) As Long
  186. ClusterResource_Online = 0
  187. End Function
  188. Private Function ClusterResource_Open(ByVal ResourceName As String, ByVal ResourceKey As Long, ByVal ResourceHandle As Long) As Long
  189. ClusterResource_Open = 1
  190. End Function
  191. Private Sub ClusterResource_Terminate(ByVal Resource As Long)
  192. End Sub