Windows NT 4.0 source code leak
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.

225 lines
9.0 KiB

4 years ago
  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: dsfsctl.h
  6. //
  7. // Contents: This module contains the definitions of internally used file
  8. // system controls for the Dfs file system. It also contains
  9. // definitions of macros used in the implementation of Fsctrls.
  10. //
  11. // Public control code and structure declarations are in the
  12. // private header file dfsfsctl.h.
  13. //
  14. // Classes: -none-
  15. //
  16. // Functions: -none-
  17. //
  18. // History: 02 Jan 1992 Alan Whitney (alanw) Created
  19. //
  20. //--------------------------------------------------------------------------
  21. #ifndef _DSFSCTL_
  22. #define _DSFSCTL_
  23. #ifndef IOCTL_DFS_BASE
  24. # include <dfsfsctl.h>
  25. #endif //IOCTL_DFS_BASE
  26. //+----------------------------------------------------------------------------
  27. //
  28. // Macro: IS_DFS_CTL_CODE
  29. //
  30. // Synopsis: Determines whether a fsctrl code is a Dfs fsctrl code.
  31. //
  32. // Arguments: [c] -- The control code to test
  33. //
  34. // Returns: TRUE if c is a Dfs fsctrl code, FALSE if its not.
  35. //
  36. //-----------------------------------------------------------------------------
  37. #define IS_DFS_CTL_CODE(c) \
  38. (((c) & CTL_CODE(0xFF, 0,0,0)) == CTL_CODE(FSCTL_DFS_BASE, 0,0,0))
  39. //+----------------------------------------------------------------------------
  40. //
  41. // Macro: OFFSET_TO_POINTER
  42. //
  43. // Synopsis: Certain fsctls (mainly those issued by the srvsvc) communicate
  44. // via buffers that contain "pointers" which are really offsets
  45. // from the beginning of the buffer. This macro fixes up the
  46. // offsets to real pointers
  47. //
  48. // Arguments: [field] -- The field to fix up.
  49. // [buffer] -- The beginning of the buffer.
  50. //
  51. // Returns: Nothing
  52. //
  53. //-----------------------------------------------------------------------------
  54. #define OFFSET_TO_POINTER(field, buffer) \
  55. ( ((PCHAR)field) += ((ULONG)buffer) )
  56. //+----------------------------------------------------------------------------
  57. //
  58. // Function: DFS_DUPLICATE_STRING
  59. //
  60. // Synopsis: Macro to create a UNICODE_STRING from an LPWSTR. The buffer
  61. // for the UNICODE_STRING is allocated using ExAllocatePool.
  62. //
  63. // Useful for duplicating strings received in fsctls from the
  64. // server.
  65. //
  66. // Arguments: [ustr] -- Destination UNICODE_STRING
  67. // [pwsz] -- Source LPWSTR
  68. // [status] -- If pool allocation fails, this will be set to
  69. // STATUS_INSUFFICIENT_RESOURCES
  70. //
  71. // Returns: Nothing. Check the status parameter to see if the operation
  72. // succeeded.
  73. //
  74. //-----------------------------------------------------------------------------
  75. #define DFS_DUPLICATE_STRING(ustr,pwsz,status) \
  76. ustr.Length = wcslen(pwsz) * sizeof(WCHAR); \
  77. ustr.MaximumLength = ustr.Length + sizeof(WCHAR); \
  78. ustr.Buffer = ExAllocatePool(PagedPool, ustr.MaximumLength ); \
  79. if (ustr.Buffer != NULL) { \
  80. RtlCopyMemory( ustr.Buffer, pwsz, ustr.MaximumLength ); \
  81. status = STATUS_SUCCESS; \
  82. } else { \
  83. status = STATUS_INSUFFICIENT_RESOURCES; \
  84. }
  85. //+---------------------------------------------------------------------------
  86. //
  87. // Macro: STD_FSCTRL_PROLOGUE, public
  88. //
  89. // Synopsis: Do the standard stuff associated with any fsctrl implementation
  90. // which needs to run in the FSP. This assumes a standard set
  91. // of parameters for the calling function, as below:
  92. //
  93. // DfsMyownFsctrl(
  94. // IN PIRP_CONTEXT IrpContext,
  95. // IN PIRP Irp,
  96. // [maybe] IN PVOID InputBuffer,
  97. // IN ULONG InputBufferLength,
  98. // [maybe] IN PVOID OutputBuffer,
  99. // IN ULONG OutputBufferLength
  100. // );
  101. //
  102. // Arguments: [szName] -- Name of the function for debug trace messages
  103. // [fExpInp] -- TRUE if it takes an input buffer
  104. // [fExpOutp] -- TRUE if it takes an output buffer
  105. // [fInFsp] -- TRUE if the request must be processed from the
  106. // FSP.
  107. //
  108. // Returns: None
  109. //
  110. // Notes: The macros CHECK_BUFFER_TRUE and CHECK_BUFFER_FALSE are
  111. // necessary for the generation of STD_FSCTRL_PROLOGUE and
  112. // are not intended to be used directly.
  113. //
  114. //
  115. //----------------------------------------------------------------------------
  116. #define CHK_BUFFER_FALSE(szName, inout) ;
  117. #define CHK_BUFFER_TRUE(szName, inout) \
  118. if (!ARGUMENT_PRESENT(inout##Buffer) || (inout##BufferLength == 0)) {\
  119. DfsDbgTrace(0, Dbg, #szName ": Bad buffer\n", 0); \
  120. DfsCompleteRequest( IrpContext, Irp, STATUS_INVALID_PARAMETER );\
  121. return STATUS_INVALID_PARAMETER; \
  122. }
  123. #define CHK_INFSP_FALSE(szName)
  124. #define CHK_INFSP_TRUE(szName) \
  125. if ((IrpContext->Flags & IRP_CONTEXT_FLAG_IN_FSD) != 0) { \
  126. DfsDbgTrace(0, Dbg, #szName ": Posting to FSP\n",0); \
  127. status = DfsFsdPostRequest( IrpContext, Irp ); \
  128. return status; \
  129. }
  130. #define STD_FSCTRL_PROLOGUE(szName, fExpInp, fExpOutp, fInFsp) { \
  131. ASSERT(ARGUMENT_PRESENT(IrpContext) && (ARGUMENT_PRESENT(Irp))); \
  132. CHK_BUFFER_##fExpInp(szName, Input) \
  133. CHK_BUFFER_##fExpOutp(szName, Output) \
  134. CHK_INFSP_##fInFsp(szName) \
  135. DfsDbgTrace(+1, Dbg, #szName ": Entered\n", 0); \
  136. }
  137. //+---------------------------------------------------------------------------
  138. //
  139. // Macro: RETURN_BUFFER_SIZE, public
  140. //
  141. // Synopsis: Return conventional errors when the output of an fsctrl
  142. // function is larger than the user buffer. This assumes a
  143. // standard set of parameters for the calling function, as
  144. // below:
  145. //
  146. // DfsMyownFsctrl(
  147. // IN PIRP_CONTEXT IrpContext,
  148. // IN PIRP Irp,
  149. // [maybe] IN PVOID InputBuffer,
  150. // [maybe] IN ULONG InputBufferLength,
  151. // IN PVOID OutputBuffer,
  152. // IN ULONG OutputBufferLength
  153. // );
  154. //
  155. // Arguments: [x] -- The required size of the output buffer
  156. // [Status] -- The status to be returned from the fsctrl.
  157. //
  158. // Returns: Sets Status to STATUS_BUFFER_TOO_SMALL or
  159. // STATUS_BUFFER_OVERFLOW. The convention we use is that if
  160. // the OutputBuffer is at least sizeof(ULONG) big, then we stuff
  161. // the needed size in OutputBuffer and return
  162. // STATUS_BUFFER_OVERFLOW, which is a warning code. If the
  163. // OutputBuffer isn't big enough for that, we return
  164. // STATUS_BUFFER_TOO_SMALL.
  165. //
  166. // Notes: Requires that the function declare "OutputBufferLength",
  167. // "OutputBuffer", and "Irp". Irp->IoStatus.Information will
  168. // be set to the return size.
  169. //
  170. //----------------------------------------------------------------------------
  171. #define RETURN_BUFFER_SIZE(x, Status) \
  172. if ((OutputBufferLength) < sizeof(ULONG)) { \
  173. Status = STATUS_BUFFER_TOO_SMALL; \
  174. } else { \
  175. Status = STATUS_BUFFER_OVERFLOW; \
  176. *((PULONG) OutputBuffer) = x; \
  177. Irp->IoStatus.Information = sizeof(ULONG); \
  178. }
  179. //
  180. // Internal Distributed file system control operations.
  181. //
  182. #define FSCTL_DFS_PKT_FLUSH_CACHE CTL_CODE(FSCTL_DFS_BASE, 2044, METHOD_BUFFERED, FILE_ANY_ACCESS)
  183. #define FSCTL_DFS_DBG_BREAK CTL_CODE(FSCTL_DFS_BASE, 2045, METHOD_BUFFERED, FILE_ANY_ACCESS)
  184. #define FSCTL_DFS_DBG_FLAGS CTL_CODE(FSCTL_DFS_BASE, 2046, METHOD_BUFFERED, FILE_ANY_ACCESS)
  185. #define FSCTL_DFS_INTERNAL_READ_MEM CTL_CODE(FSCTL_DFS_BASE, 2047, METHOD_BUFFERED, FILE_READ_DATA)
  186. #define FSCTL_DFS_SET_PKT_ENTRY_TIMEOUT CTL_CODE(FSCTL_DFS_BASE, 2048, METHOD_BUFFERED, FILE_ANY_ACCESS)
  187. //
  188. // Control structure for FSCTL_DFS_INTERNAL_READ_MEM (input)
  189. //
  190. typedef struct _FILE_DFS_READ_MEM {
  191. DWORD Address;
  192. ULONG Length;
  193. } FILE_DFS_READ_MEM, *PFILE_DFS_READ_MEM;
  194. #endif // _DSFSCTL_