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.

177 lines
6.0 KiB

4 years ago
  1. //+-------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1992, Microsoft Corporation.
  4. //
  5. // File: dnr.h
  6. //
  7. // Contents: Definitions for distributed name resolution context
  8. //
  9. // History: 26 May 1992 Alanw Created
  10. // 04 Sep 1992 Milans Added support for replica selection
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "rpselect.h"
  14. //
  15. // Maximum number of times we'll go around the main loop in DnrResolveName.
  16. //
  17. #define MAX_DNR_ATTEMPTS 5
  18. // The following define a Name resolution context which describes the
  19. // state of an ongoing name resolution. A pointer to this context is
  20. // used as the argument to a DPC which will initiate the next step of
  21. // name resolution.
  22. typedef enum {
  23. DnrStateEnter = 0,
  24. DnrStateStart, // Start or restart nameres process
  25. DnrStateGetFirstDC, // contact a dc, so that we can...
  26. DnrStateGetReferrals, // ask knowledge server for referral
  27. DnrStateGetNextDC,
  28. DnrStateCompleteReferral, // waiting for I/O completion of referral req.
  29. DnrStateSendRequest, // requesting Open, ResolveName, etc.
  30. DnrStatePostProcessOpen, // resume Dnr after call to provider
  31. DnrStateGetFirstReplica, // select the first server.
  32. DnrStateGetNextReplica, // a server failed, select another
  33. DnrStateSvcListCheck, // exhausted svc list, see if svc list changed
  34. DnrStateDone, // done, complete the IRP
  35. DnrStateLocalCompletion = 101 // like done, small optimization
  36. } DNR_STATE;
  37. typedef struct _DNR_CONTEXT {
  38. //
  39. // The type and size of this record (must be DSFS_NTC_DNR_CONTEXT)
  40. //
  41. NODE_TYPE_CODE NodeTypeCode;
  42. NODE_BYTE_SIZE NodeByteSize;
  43. DNR_STATE State; // State of name resolution
  44. SECURITY_CLIENT_CONTEXT SecurityContext; // Security context of caller.
  45. PDFS_PKT_ENTRY pPktEntry; // pointer to locked PKT entry
  46. ULONG USN; // USN of pPktEntry when we cached it
  47. PDFS_SERVICE pService; // pointer to file service being used
  48. PPROVIDER_DEF pProvider; // Same as pService->pProvider
  49. //
  50. // The Provider Defs are protected by DfsData.Resource. We don't want
  51. // to hold this (or any other) resource when going over the net. So, we
  52. // cache that part of the provider def that we need to use upon returning
  53. // from the network call.
  54. //
  55. USHORT ProviderId;
  56. PDEVICE_OBJECT TargetDevice;
  57. //
  58. // Since we don't want to hold any locks while going over the net,
  59. // we need to reference the authenticated tree connection to the server
  60. // we will send the open request to.
  61. //
  62. PFILE_OBJECT AuthConn;
  63. // The pService field is protected by Pkt.Resource. Again, we don't want
  64. // to hold this resource when going over the net. However, we need to
  65. // use pService->ConnFile to send a referral request. So, we reference
  66. // and cache the pService->ConnFile in the DnrContext, release the Pkt,
  67. // then send the referral request over the cached DCConnFile.
  68. //
  69. PFILE_OBJECT DCConnFile;
  70. PDFS_CREDENTIALS Credentials; // Credentials to use during Dnr
  71. PIRP_CONTEXT pIrpContext; // associated IRP context
  72. PIRP OriginalIrp; // original IRP we started with
  73. NTSTATUS FinalStatus; // status to complete IRP with
  74. PDFS_FCB FcbToUse; // If DNR succeeds, FCB to use.
  75. PDFS_VCB Vcb; // associated DFS_VCB
  76. UNICODE_STRING FileName; // file name being processed
  77. UNICODE_STRING RemainingPart; // remaining part of file name
  78. UNICODE_STRING SavedFileName; // The one that came with the file
  79. PFILE_OBJECT SavedRelatedFileObject; // object.
  80. USHORT NewNameLen; // Length of translated name.
  81. REPL_SELECT_CONTEXT RSelectContext; // Context for replica selection
  82. REPL_SELECT_CONTEXT RDCSelectContext; // Context for DC replica selection
  83. ULONG ReferralSize; // size of buffer needed for referral
  84. unsigned int Attempts; // number of name resolution attempts
  85. BOOLEAN ReleasePkt; // if TRUE, Pkt resource must be freed
  86. BOOLEAN DnrActive; // if TRUE, DnrNameResolve active on this context
  87. BOOLEAN GotReferral; // if TRUE, last action was a referral
  88. BOOLEAN FoundInconsistency; // if TRUE, last referral involved
  89. // inconsistencies in it.
  90. BOOLEAN CalledDCLocator;// if TRUE, we have already called locator
  91. BOOLEAN Impersonate; // if TRUE, we need to impersonate using SecurityToken
  92. BOOLEAN NameAllocated; // if TRUE, FileName.Buffer was allocated separately
  93. PDEVICE_OBJECT DeviceObject;
  94. } DNR_CONTEXT, *PDNR_CONTEXT;
  95. //
  96. // The initial length of a referral requested over the network.
  97. //
  98. #define MAX_REFERRAL_LENGTH 2048
  99. //
  100. // Prototypes for functions in dnr.c
  101. //
  102. NTSTATUS
  103. DnrStartNameResolution(
  104. IN PIRP_CONTEXT IrpContext,
  105. IN PIRP Irp,
  106. IN PDFS_VCB Vcb
  107. );
  108. NTSTATUS
  109. DnrNameResolve(
  110. IN PDNR_CONTEXT DnrContext
  111. );
  112. VOID
  113. DnrComposeFileName(
  114. OUT PUNICODE_STRING FullName,
  115. IN PDFS_VCB Vcb,
  116. IN PFILE_OBJECT RelatedFile,
  117. IN PUNICODE_STRING FileName
  118. );
  119. NTSTATUS
  120. DfsCreateConnection(
  121. IN PDFS_SERVICE pService,
  122. IN PPROVIDER_DEF pProvider,
  123. OUT PHANDLE handle
  124. );
  125. NTSTATUS
  126. DfsCloseConnection(
  127. IN PDFS_SERVICE pService
  128. );
  129. BOOLEAN
  130. DnrConcatenateFilePath (
  131. IN PUNICODE_STRING Dest,
  132. IN PWSTR RemainingPath,
  133. IN USHORT Length
  134. );
  135. PIRP
  136. DnrBuildFsControlRequest (
  137. IN PFILE_OBJECT FileObject OPTIONAL,
  138. IN PVOID Context,
  139. IN ULONG IoControlCode,
  140. IN PVOID MainBuffer,
  141. IN ULONG InputBufferLength,
  142. IN PVOID AuxiliaryBuffer OPTIONAL,
  143. IN ULONG OutputBufferLength,
  144. IN PIO_COMPLETION_ROUTINE CompletionRoutine
  145. );