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.

192 lines
4.1 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: LibSup.c
  6. //
  7. // Contents:
  8. //
  9. // Functions:
  10. //
  11. // History:
  12. //
  13. // Notes:
  14. //
  15. //--------------------------------------------------------------------------
  16. #include "nt.h"
  17. #include "ntrtl.h"
  18. #include "nturtl.h"
  19. #include "libsup.h"
  20. #include "ntddnfs.h"
  21. #include "dfsfsctl.h"
  22. #include "malloc.h"
  23. UNICODE_STRING LocalDfsName = {
  24. sizeof(DFS_SERVER_NAME)-sizeof(UNICODE_NULL),
  25. sizeof(DFS_SERVER_NAME)-sizeof(UNICODE_NULL),
  26. DFS_SERVER_NAME
  27. };
  28. //+-------------------------------------------------------------------------
  29. //
  30. // Function: DfsOpen, public
  31. //
  32. // Synopsis:
  33. //
  34. // Arguments:
  35. //
  36. // Returns:
  37. //
  38. //--------------------------------------------------------------------------
  39. static FILE_FULL_EA_INFORMATION PrincipalEAHeader = {
  40. 0, 0, (sizeof EA_NAME_PRINCIPAL-1), 0,
  41. ""
  42. };
  43. NTSTATUS
  44. DfsOpen(
  45. IN OUT PHANDLE DfsHandle,
  46. IN PUNICODE_STRING DfsName OPTIONAL
  47. )
  48. {
  49. NTSTATUS status;
  50. OBJECT_ATTRIBUTES objectAttributes;
  51. IO_STATUS_BLOCK ioStatus;
  52. PUNICODE_STRING name;
  53. if (ARGUMENT_PRESENT(DfsName)) {
  54. name = DfsName;
  55. } else {
  56. name = &LocalDfsName;
  57. }
  58. InitializeObjectAttributes(
  59. &objectAttributes,
  60. name,
  61. OBJ_CASE_INSENSITIVE,
  62. NULL,
  63. NULL
  64. );
  65. status = NtCreateFile(
  66. DfsHandle,
  67. SYNCHRONIZE | FILE_WRITE_DATA,
  68. &objectAttributes,
  69. &ioStatus,
  70. NULL,
  71. FILE_ATTRIBUTE_NORMAL,
  72. FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  73. FILE_OPEN_IF,
  74. FILE_CREATE_TREE_CONNECTION | FILE_SYNCHRONOUS_IO_NONALERT,
  75. NULL,
  76. 0);
  77. if (NT_SUCCESS(status))
  78. status = ioStatus.Status;
  79. return status;
  80. }
  81. //+-------------------------------------------------------------------------
  82. //
  83. // Function: DfsFsctlEx, local
  84. //
  85. // Synopsis: Issues an NtFsControlFile call to the Dsfs file system
  86. // driver.
  87. //
  88. // Arguments: [DfsFile] -- Target of fsctl
  89. // [FsControlCode] -- The file system control code to be used
  90. // [InputBuffer] -- The fsctl input buffer
  91. // [InputBufferLength]
  92. // [OutputBuffer] -- The fsctl output buffer
  93. // [OutputBufferLength]
  94. // [pInformation] -- Information field of returned IoStatus.
  95. //
  96. // Returns: NTSTATUS - the status of the open or fsctl operation.
  97. //
  98. //--------------------------------------------------------------------------
  99. NTSTATUS
  100. DfsFsctlEx(
  101. IN HANDLE DfsFile,
  102. IN ULONG FsControlCode,
  103. IN PVOID InputBuffer OPTIONAL,
  104. IN ULONG InputBufferLength,
  105. OUT PVOID OutputBuffer OPTIONAL,
  106. IN ULONG OutputBufferLength,
  107. OUT PULONG pInformation
  108. ) {
  109. NTSTATUS Stat;
  110. IO_STATUS_BLOCK IoStatus;
  111. Stat = NtFsControlFile(
  112. DfsFile,
  113. NULL, // Event,
  114. NULL, // ApcRoutine,
  115. NULL, // ApcContext,
  116. &IoStatus,
  117. FsControlCode,
  118. InputBuffer,
  119. InputBufferLength,
  120. OutputBuffer,
  121. OutputBufferLength );
  122. if ( NT_SUCCESS(Stat) ) {
  123. Stat = IoStatus.Status;
  124. *pInformation = (ULONG)IoStatus.Information;
  125. }
  126. return Stat;
  127. }
  128. //+-------------------------------------------------------------------------
  129. //
  130. // Function: DfsFsctl, public
  131. //
  132. // Synopsis:
  133. //
  134. // Arguments:
  135. //
  136. // Returns:
  137. //
  138. //--------------------------------------------------------------------------
  139. NTSTATUS
  140. DfsFsctl(
  141. IN HANDLE DfsHandle,
  142. IN ULONG FsControlCode,
  143. IN PVOID InputBuffer OPTIONAL,
  144. IN ULONG InputBufferLength,
  145. OUT PVOID OutputBuffer OPTIONAL,
  146. IN ULONG OutputBufferLength
  147. )
  148. {
  149. NTSTATUS status;
  150. IO_STATUS_BLOCK ioStatus;
  151. status = NtFsControlFile(
  152. DfsHandle,
  153. NULL, // Event,
  154. NULL, // ApcRoutine,
  155. NULL, // ApcContext,
  156. &ioStatus,
  157. FsControlCode,
  158. InputBuffer,
  159. InputBufferLength,
  160. OutputBuffer,
  161. OutputBufferLength
  162. );
  163. if(NT_SUCCESS(status))
  164. status = ioStatus.Status;
  165. return status;
  166. }