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.

139 lines
3.6 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation
  4. //
  5. // File: dfsext.cxx
  6. //
  7. // Contents: Code to see if a path refers to a Dfs path.
  8. //
  9. // Classes: None
  10. //
  11. // Functions: TranslateDfsPath
  12. //
  13. // History: June 17, 1996 Milans Created
  14. //
  15. //-----------------------------------------------------------------------------
  16. #include "act.hxx"
  17. #ifdef DFSACTIVATION
  18. NTSTATUS
  19. DfsFsctl(
  20. IN HANDLE DfsHandle,
  21. IN ULONG FsControlCode,
  22. IN PVOID InputBuffer OPTIONAL,
  23. IN ULONG InputBufferLength,
  24. OUT PVOID OutputBuffer OPTIONAL,
  25. IN OUT PULONG OutputBufferLength);
  26. NTSTATUS
  27. DfsOpen(
  28. IN OUT PHANDLE DfsHandle);
  29. //+-------------------------------------------------------------------------
  30. //
  31. // Function: DfsOpen, private
  32. //
  33. // Synopsis: Opens a handle to the Dfs driver for fsctl purposes.
  34. //
  35. // Arguments: [DfsHandle] -- On successful return, contains handle to the
  36. // driver.
  37. //
  38. // Returns: NTSTATUS of attempt to open the Dfs driver.
  39. //
  40. //--------------------------------------------------------------------------
  41. NTSTATUS
  42. DfsOpen(
  43. IN OUT PHANDLE DfsHandle)
  44. {
  45. NTSTATUS status;
  46. OBJECT_ATTRIBUTES objectAttributes;
  47. IO_STATUS_BLOCK ioStatus;
  48. UNICODE_STRING name = {
  49. sizeof(DFS_DRIVER_NAME)-sizeof(UNICODE_NULL),
  50. sizeof(DFS_DRIVER_NAME)-sizeof(UNICODE_NULL),
  51. DFS_DRIVER_NAME};
  52. InitializeObjectAttributes(
  53. &objectAttributes,
  54. &name,
  55. OBJ_CASE_INSENSITIVE,
  56. NULL,
  57. NULL
  58. );
  59. status = NtCreateFile(
  60. DfsHandle,
  61. SYNCHRONIZE,
  62. &objectAttributes,
  63. &ioStatus,
  64. NULL,
  65. FILE_ATTRIBUTE_NORMAL,
  66. FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
  67. FILE_OPEN_IF,
  68. FILE_CREATE_TREE_CONNECTION | FILE_SYNCHRONOUS_IO_NONALERT,
  69. NULL,
  70. 0);
  71. if (NT_SUCCESS(status))
  72. status = ioStatus.Status;
  73. return status;
  74. }
  75. //+-------------------------------------------------------------------------
  76. //
  77. // Function: DfsFsctl, public
  78. //
  79. // Synopsis: Fsctl's to the Dfs driver.
  80. //
  81. // Arguments: [DfsHandle] -- Handle to the Dfs driver, usually obtained by
  82. // calling DfsOpen.
  83. // [FsControlCode] -- The FSCTL code (see private\inc\dfsfsctl.h)
  84. // [InputBuffer] -- InputBuffer to the fsctl.
  85. // [InputBufferLength] -- Length, in BYTES, of InputBuffer
  86. // [OutputBuffer] -- OutputBuffer to the fsctl.
  87. // [OutputBufferLength] -- Length, in BYTES, of OutputBuffer
  88. //
  89. // Returns: NTSTATUS of Fsctl attempt.
  90. //
  91. //--------------------------------------------------------------------------
  92. NTSTATUS
  93. DfsFsctl(
  94. IN HANDLE DfsHandle,
  95. IN ULONG FsControlCode,
  96. IN PVOID InputBuffer OPTIONAL,
  97. IN ULONG InputBufferLength,
  98. OUT PVOID OutputBuffer OPTIONAL,
  99. IN OUT PULONG OutputBufferLength
  100. )
  101. {
  102. NTSTATUS status;
  103. IO_STATUS_BLOCK ioStatus;
  104. status = NtFsControlFile(
  105. DfsHandle,
  106. NULL, // Event,
  107. NULL, // ApcRoutine,
  108. NULL, // ApcContext,
  109. &ioStatus,
  110. FsControlCode,
  111. InputBuffer,
  112. InputBufferLength,
  113. OutputBuffer,
  114. *OutputBufferLength
  115. );
  116. if(NT_SUCCESS(status))
  117. status = ioStatus.Status;
  118. if (status == STATUS_BUFFER_OVERFLOW)
  119. *OutputBufferLength = *((PULONG) OutputBuffer);
  120. return status;
  121. }
  122. #endif // DFSACTIVATION