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.

1365 lines
32 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. RxProcs.h
  5. Abstract:
  6. This module defines all of the globally used procedures in the RDBSS
  7. file system.
  8. Author:
  9. Joe Linn [JoeLinn]
  10. Revision History:
  11. --*/
  12. #ifndef _RDBSSPROCS_
  13. #define _RDBSSPROCS_
  14. #include "rx.h"
  15. #include "backpack.h"
  16. #include "RxTypes.h"
  17. #include "RxAssert.h"
  18. #include "RxLog.h"
  19. #include "RxTrace.h"
  20. #include "RxTimer.h"
  21. #include "RxStruc.h"
  22. extern PVOID RxNull;
  23. //
  24. // The following macro is for all people who compile with the DBG switch
  25. // set, not just rdbss dbg users
  26. //
  27. #if DBG
  28. #define DbgDoit(X) {X;}
  29. #define DebugDoit(X) {X;}
  30. #define DEBUG_ONLY_DECL(X) X
  31. #else
  32. #define DbgDoit(X) {NOTHING;}
  33. #define DebugDoit(X) {NOTHING;}
  34. #define DEBUG_ONLY_DECL(X)
  35. #endif // DBG
  36. //
  37. // utilities
  38. //
  39. // Routines for writing error log entries.
  40. //
  41. /*++
  42. RxLogFailure, RxLogFailureWithBuffer can be used to record an event in
  43. the log. The RxLogFailure, RxLogFailureWithBuffer captures the line
  44. number alongwith the supplied information and writes it to the log. This
  45. is useful in debugging. RxLogFailureDirect, RxLogBufferDirect do not
  46. capture the line number
  47. RxlogEvent is useful for writing events into the log.
  48. --*/
  49. #define RxLogFailure( _DeviceObject, _OriginatorId, _EventId, _Status ) \
  50. RxLogEventDirect( _DeviceObject, _OriginatorId, _EventId, _Status, __LINE__ )
  51. #define RxLogFailureWithBuffer( _DeviceObject, _OriginatorId, _EventId, _Status, _Buffer, _Length ) \
  52. RxLogEventWithBufferDirect( _DeviceObject, _OriginatorId, _EventId, _Status, _Buffer, _Length, __LINE__ )
  53. #define RxLogEvent( _DeviceObject, _OriginatorId, _EventId, _Status) \
  54. RxLogEventDirect(_DeviceObject, _OriginatorId, _EventId, _Status, __LINE__)
  55. VOID
  56. RxLogEventDirect (
  57. IN PRDBSS_DEVICE_OBJECT DeviceObject,
  58. IN PUNICODE_STRING OriginatorId,
  59. IN ULONG EventId,
  60. IN NTSTATUS Status,
  61. IN ULONG Line);
  62. VOID
  63. RxLogEventWithBufferDirect(
  64. IN PVOID DeviceOrDriverObject,
  65. IN PUNICODE_STRING OriginatorId,
  66. IN ULONG EventId,
  67. IN NTSTATUS Status,
  68. IN PVOID DataBuffer,
  69. IN USHORT DataBufferLength,
  70. IN ULONG LineNumber);
  71. VOID
  72. RxLogEventWithAnnotation (
  73. IN PRDBSS_DEVICE_OBJECT DeviceObject,
  74. IN ULONG EventId,
  75. IN NTSTATUS Status,
  76. IN PVOID DataBuffer,
  77. IN USHORT DataBufferLength,
  78. IN PUNICODE_STRING Annotation,
  79. IN ULONG AnnotationCount);
  80. BOOLEAN
  81. RxCcLogError(
  82. IN PDEVICE_OBJECT DeviceObject,
  83. IN PUNICODE_STRING FileName,
  84. IN NTSTATUS Error,
  85. IN NTSTATUS DeviceError,
  86. IN UCHAR IrpMajorCode,
  87. IN PVOID Context
  88. );
  89. //in create.c
  90. NTSTATUS
  91. RxPrefixClaim (
  92. IN PRX_CONTEXT RxContext
  93. );
  94. VOID
  95. RxpPrepareCreateContextForReuse(
  96. PRX_CONTEXT RxContext);
  97. //in devfcb.c
  98. LUID
  99. RxGetUid (
  100. IN PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext
  101. );
  102. ULONG
  103. RxGetSessionId (
  104. IN PIO_STACK_LOCATION IrpSp
  105. );
  106. NTSTATUS
  107. RxFindOrCreateConnections (
  108. IN PRX_CONTEXT RxContext,
  109. IN PUNICODE_STRING CanonicalName,
  110. IN NET_ROOT_TYPE NetRootType,
  111. OUT PUNICODE_STRING LocalNetRootName,
  112. OUT PUNICODE_STRING FilePathName,
  113. IN OUT LOCK_HOLDING_STATE *pLockHoldingState,
  114. IN PRX_CONNECTION_ID RxConnectionId
  115. );
  116. NTSTATUS
  117. RxFindOrCreateVNetRoot(
  118. PRX_CONTEXT RxContext,
  119. PUNICODE_STRING CanonicalName,
  120. NET_ROOT_TYPE NetRootType,
  121. PV_NET_ROOT *pVirtualNetRootPointer,
  122. LOCK_HOLDING_STATE *pLockHoldingState);
  123. //in fileinfo.c
  124. typedef enum _RX_NAME_CONJURING_METHODS {
  125. VNetRoot_As_Prefix,
  126. VNetRoot_As_UNC_Name,
  127. VNetRoot_As_DriveLetter
  128. } RX_NAME_CONJURING_METHODS;
  129. VOID
  130. RxConjureOriginalName (
  131. IN PFCB Fcb,
  132. IN PFOBX Fobx,
  133. OUT PLONG pActualNameLength,
  134. PWCHAR OriginalName,
  135. IN OUT PLONG pLengthRemaining,
  136. IN RX_NAME_CONJURING_METHODS NameConjuringMethod
  137. );
  138. //in cleanup.c
  139. VOID
  140. RxAdjustFileTimesAndSize ( RXCOMMON_SIGNATURE );
  141. //
  142. // A function that returns finished denotes if it was able to complete the
  143. // operation (TRUE) or could not complete the operation (FALSE) because the
  144. // wait value stored in the irp context was false and we would have had
  145. // to block for a resource or I/O
  146. //
  147. typedef BOOLEAN FINISHED;
  148. //
  149. // Buffer control routines for data caching, implemented in CacheSup.c
  150. //
  151. FINISHED
  152. RxZeroData (
  153. IN PRX_CONTEXT RxContext,
  154. IN PVCB Vcb,
  155. IN PFILE_OBJECT FileObject,
  156. IN ULONG StartingZero,
  157. IN ULONG ByteCount
  158. );
  159. NTSTATUS
  160. RxCompleteMdl (
  161. IN PRX_CONTEXT RxContext
  162. );
  163. VOID
  164. RxSyncUninitializeCacheMap (
  165. IN PRX_CONTEXT RxContext,
  166. IN PFILE_OBJECT FileObject
  167. );
  168. VOID
  169. RxLockUserBuffer (
  170. IN PRX_CONTEXT RxContext,
  171. IN LOCK_OPERATION Operation,
  172. IN ULONG BufferLength
  173. );
  174. PVOID
  175. RxMapSystemBuffer (
  176. IN PRX_CONTEXT RxContext
  177. );
  178. PVOID
  179. RxNewMapUserBuffer (
  180. IN PRX_CONTEXT RxContext
  181. );
  182. #define RxUpcaseEaName( RXCONTEXT, NAME, UPCASEDNAME ) \
  183. RtlUpperString( UPCASEDNAME, NAME )
  184. //#define RxDissectName(RXCONTEXT,INPUT_STRING,FIRST_PART,REMAINING_PART) { \
  185. // FsRtlDissectDbcs( (INPUT_STRING), \
  186. // (FIRST_PART), \
  187. // (REMAINING_PART) ); \
  188. //}
  189. //
  190. //
  191. //#define RxDoesNameContainWildCards(RXCONTEXT,NAME) ( \
  192. // FsRtlDoesDbcsContainWildCards( &(NAME) ) \
  193. //)
  194. //
  195. //
  196. //#define RxAreNamesEqual(RXCONTEXT,NAMEA,NAMEB) ( \
  197. // ((ULONG)(NAMEA).Length == (ULONG)(NAMEB).Length) && \
  198. // (RtlCompareMemory( &(NAMEA).Buffer[0], \
  199. // &(NAMEB).Buffer[0], \
  200. // (NAMEA).Length ) == (NAMEA).Length ) \
  201. //)
  202. //
  203. //
  204. //#define RxIsNameValid(RXCONTEXT,NAME,CAN_CONTAIN_WILD_CARDS,PATH_NAME_OK,LEADING_BACKSLAH_OK) ( \
  205. // FsRtlIsFatDbcsLegal((NAME), \
  206. // (CAN_CONTAIN_WILD_CARDS), \
  207. // (PATH_NAME_OK), \
  208. // (LEADING_BACKSLAH_OK)) \
  209. //)
  210. //even though it passes a serial number, this parameter is not used
  211. #ifdef RDBSS_TRACKER
  212. #define RX_FCBTRACKER_PARAMS ,ULONG LineNumber,PSZ FileName,ULONG SerialNumber
  213. #else
  214. #define RX_FCBTRACKER_PARAMS
  215. #endif
  216. #define FCB_MODE_EXCLUSIVE (1)
  217. #define FCB_MODE_SHARED (2)
  218. #define FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE (3)
  219. #define FCB_MODE_SHARED_STARVE_EXCLUSIVE (4)
  220. #define CHANGE_BUFFERING_STATE_CONTEXT ((PRX_CONTEXT)IntToPtr(0xffffffff))
  221. #define CHANGE_BUFFERING_STATE_CONTEXT_WAIT ((PRX_CONTEXT)IntToPtr(0xfffffffe))
  222. NTSTATUS
  223. __RxAcquireFcb(
  224. IN OUT PMRX_FCB pFcb,
  225. IN OUT PRX_CONTEXT pRxContext,
  226. IN ULONG Mode
  227. RX_FCBTRACKER_PARAMS
  228. );
  229. #ifdef RDBSS_TRACKER
  230. #define RxAcquireExclusiveFcb(RXCONTEXT,FCB) \
  231. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_EXCLUSIVE,__LINE__,__FILE__,0)
  232. #else
  233. #define RxAcquireExclusiveFcb(RXCONTEXT,FCB) \
  234. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_EXCLUSIVE)
  235. #endif
  236. #define RX_GET_MRX_FCB(FCB) ((PMRX_FCB)((FCB)))
  237. #ifdef RDBSS_TRACKER
  238. #define RxAcquireSharedFcb(RXCONTEXT,FCB) \
  239. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED,__LINE__,__FILE__,0)
  240. #else
  241. #define RxAcquireSharedFcb(RXCONTEXT,FCB) \
  242. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED)
  243. #endif
  244. #ifdef RDBSS_TRACKER
  245. #define RxAcquireSharedFcbWaitForEx(RXCONTEXT,FCB) \
  246. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE,__LINE__,__FILE__,0)
  247. #else
  248. #define RxAcquireSharedFcbWaitForEx(RXCONTEXT,FCB) \
  249. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED_WAIT_FOR_EXCLUSIVE)
  250. #endif
  251. #ifdef RDBSS_TRACKER
  252. #define RxAcquireSharedFcbStarveEx(RXCONTEXT,FCB) \
  253. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED_STARVE_EXCLUSIVE,__LINE__,__FILE__,0)
  254. #else
  255. #define RxAcquireSharedFcbStarveEx(RXCONTEXT,FCB) \
  256. __RxAcquireFcb(RX_GET_MRX_FCB(FCB),(RXCONTEXT),FCB_MODE_SHARED_STARVE_EXCLUSIVE)
  257. #endif
  258. VOID
  259. __RxReleaseFcb(
  260. IN PRX_CONTEXT pRxContext,
  261. IN PMRX_FCB pFcb
  262. RX_FCBTRACKER_PARAMS
  263. );
  264. #ifdef RDBSS_TRACKER
  265. #define RxReleaseFcb(RXCONTEXT,FCB) \
  266. __RxReleaseFcb((RXCONTEXT),RX_GET_MRX_FCB(FCB),__LINE__,__FILE__,0)
  267. #else
  268. #define RxReleaseFcb(RXCONTEXT,FCB) \
  269. __RxReleaseFcb((RXCONTEXT),RX_GET_MRX_FCB(FCB))
  270. #endif
  271. VOID
  272. __RxReleaseFcbForThread(
  273. IN PRX_CONTEXT pRxContext,
  274. IN PMRX_FCB pFcb,
  275. IN ERESOURCE_THREAD ResourceThreadId
  276. RX_FCBTRACKER_PARAMS
  277. );
  278. #ifdef RDBSS_TRACKER
  279. #define RxReleaseFcbForThread(RXCONTEXT,FCB,THREAD) \
  280. __RxReleaseFcbForThread((RXCONTEXT),RX_GET_MRX_FCB(FCB),(THREAD),__LINE__,__FILE__,0)
  281. #else
  282. #define RxReleaseFcbForThread(RXCONTEXT,FCB,THREAD) \
  283. __RxReleaseFcbForThread((RXCONTEXT),RX_GET_MRX_FCB(FCB),(THREAD))
  284. #endif
  285. #ifdef RDBSS_TRACKER
  286. VOID RxTrackerUpdateHistory(
  287. PRX_CONTEXT pRxContext,
  288. PMRX_FCB pFcb,
  289. ULONG Operation
  290. RX_FCBTRACKER_PARAMS
  291. );
  292. #else
  293. #define RxTrackerUpdateHistory(xRXCONTEXT,xFCB,xOPERATION,xLINENUM,xFILENAME,xSERIALNUMBER) {NOTHING;}
  294. #endif
  295. VOID RxTrackPagingIoResource(
  296. PVOID pInstance,
  297. ULONG Type,
  298. ULONG Line,
  299. PCHAR File);
  300. //this definition is old......i don't like the format
  301. #define RxFcbAcquiredShared(RXCONTEXT,FCB) ( \
  302. ExIsResourceAcquiredSharedLite(RX_GET_MRX_FCB(FCB)->Header.Resource) \
  303. )
  304. #define RxIsFcbAcquiredShared(FCB) ( \
  305. ExIsResourceAcquiredSharedLite(RX_GET_MRX_FCB(FCB)->Header.Resource) \
  306. )
  307. #define RxIsFcbAcquiredExclusive(FCB) ( \
  308. ExIsResourceAcquiredExclusiveLite(RX_GET_MRX_FCB(FCB)->Header.Resource) \
  309. )
  310. #define RxIsFcbAcquired(FCB) ( \
  311. ExIsResourceAcquiredSharedLite(RX_GET_MRX_FCB(FCB)->Header.Resource) | \
  312. ExIsResourceAcquiredExclusiveLite(RX_GET_MRX_FCB(FCB)->Header.Resource) \
  313. )
  314. #define RxAcquirePagingIoResource(FCB,RxContext) \
  315. ExAcquireResourceExclusiveLite(RX_GET_MRX_FCB(FCB)->Header.PagingIoResource,TRUE); \
  316. if (RxContext) { \
  317. ((PRX_CONTEXT)RxContext)->FcbPagingIoResourceAcquired = TRUE; \
  318. } \
  319. RxTrackPagingIoResource(FCB,1,__LINE__,__FILE__) \
  320. #define RxAcquirePagingIoResourceShared(FCB,FLAG,RxContext) \
  321. ExAcquireResourceSharedLite(RX_GET_MRX_FCB(FCB)->Header.PagingIoResource,FLAG); \
  322. if (AcquiredFile) { \
  323. if (RxContext) { \
  324. ((PRX_CONTEXT)RxContext)->FcbPagingIoResourceAcquired = TRUE; \
  325. } \
  326. RxTrackPagingIoResource(FCB,2,__LINE__,__FILE__); \
  327. }
  328. #define RxReleasePagingIoResource(FCB,RxContext) \
  329. RxTrackPagingIoResource(FCB,3,__LINE__,__FILE__); \
  330. if (RxContext) { \
  331. ((PRX_CONTEXT)RxContext)->FcbPagingIoResourceAcquired = FALSE; \
  332. } \
  333. ExReleaseResourceLite(RX_GET_MRX_FCB(FCB)->Header.PagingIoResource)
  334. #define RxReleasePagingIoResourceForThread(FCB,THREAD,RxContext) \
  335. RxTrackPagingIoResource(FCB,3,__LINE__,__FILE__); \
  336. if (RxContext) { \
  337. ((PRX_CONTEXT)RxContext)->FcbPagingIoResourceAcquired = FALSE; \
  338. } \
  339. ExReleaseResourceForThreadLite(RX_GET_MRX_FCB(FCB)->Header.PagingIoResource,(THREAD))
  340. // The following are cache manager call backs
  341. BOOLEAN
  342. RxAcquireFcbForLazyWrite (
  343. IN PVOID Null,
  344. IN BOOLEAN Wait
  345. );
  346. VOID
  347. RxReleaseFcbFromLazyWrite (
  348. IN PVOID Null
  349. );
  350. BOOLEAN
  351. RxAcquireFcbForReadAhead (
  352. IN PVOID Null,
  353. IN BOOLEAN Wait
  354. );
  355. VOID
  356. RxReleaseFcbFromReadAhead (
  357. IN PVOID Null
  358. );
  359. BOOLEAN
  360. RxNoOpAcquire (
  361. IN PVOID Fcb,
  362. IN BOOLEAN Wait
  363. );
  364. VOID
  365. RxNoOpRelease (
  366. IN PVOID Fcb
  367. );
  368. NTSTATUS
  369. RxAcquireForCcFlush (
  370. IN PFILE_OBJECT FileObject,
  371. IN PDEVICE_OBJECT DeviceObject
  372. );
  373. NTSTATUS
  374. RxReleaseForCcFlush (
  375. IN PFILE_OBJECT FileObject,
  376. IN PDEVICE_OBJECT DeviceObject
  377. );
  378. //
  379. // VOID
  380. // RxConvertToSharedFcb (
  381. // IN PRX_CONTEXT RxContext,
  382. // IN PFCB Fcb
  383. // );
  384. //
  385. #define RxConvertToSharedFcb(RXCONTEXT,FCB) { \
  386. ExConvertExclusiveToSharedLite( RX_GET_MRX_FCB(FCB)->Header.Resource ); \
  387. }
  388. VOID
  389. RxVerifyOperationIsLegal (
  390. IN PRX_CONTEXT RxContext
  391. );
  392. //
  393. // Work queue routines for posting and retrieving an Irp, implemented in
  394. // workque.c
  395. //
  396. VOID
  397. RxOplockComplete (
  398. IN PVOID Context,
  399. IN PIRP Irp
  400. );
  401. VOID
  402. RxPrePostIrp (
  403. IN PVOID Context,
  404. IN PIRP Irp
  405. );
  406. VOID
  407. RxAddToWorkque (
  408. IN PRX_CONTEXT RxContext,
  409. IN PIRP Irp
  410. );
  411. NTSTATUS
  412. RxFsdPostRequest (
  413. IN PRX_CONTEXT RxContext
  414. );
  415. #define RxFsdPostRequestWithResume(RXCONTEXT,RESUMEROUTINE) \
  416. (((RXCONTEXT)->ResumeRoutine=(RESUMEROUTINE)), \
  417. RxFsdPostRequest((RXCONTEXT)) \
  418. )
  419. VOID
  420. RxInitializeMRxCalldownContext(
  421. PMRX_CALLDOWN_CONTEXT pContext,
  422. PRDBSS_DEVICE_OBJECT pMRxDeviceObject,
  423. PMRX_CALLDOWN_ROUTINE pRoutine,
  424. PVOID pParameter);
  425. NTSTATUS
  426. RxCalldownMiniRedirectors(
  427. LONG NumberOfMiniRdrs,
  428. PMRX_CALLDOWN_CONTEXT pCalldownContext,
  429. BOOLEAN PostCalldowns);
  430. //
  431. // This macro takes a ulong and returns its rounded up word value
  432. //
  433. #define WordAlign(Val) ( \
  434. ALIGN_UP( Val, WORD ) \
  435. )
  436. //
  437. // This macro takes a pointer and returns a ULONG_PTR representation of
  438. // its rounded up word value
  439. //
  440. #define WordAlignPtr(Ptr) ( \
  441. ALIGN_UP_POINTER( Ptr, WORD ) \
  442. )
  443. //
  444. // This macro takes a ulong and returns its rounded up longword value
  445. //
  446. #define LongAlign(Val) ( \
  447. ALIGN_UP( Val, LONG ) \
  448. )
  449. //
  450. // This macro takes a pointer and returns a ULONG_PTR representation of
  451. // its rounded up word value
  452. //
  453. #define LongAlignPtr(Ptr) ( \
  454. ALIGN_UP_POINTER( Ptr, LONG ) \
  455. )
  456. //
  457. // This macro takes a ulong and returns its rounded up quadword
  458. // value
  459. //
  460. #define QuadAlign(Val) ( \
  461. ALIGN_UP( Val, ULONGLONG ) \
  462. )
  463. //
  464. // This macro takes a pointer and returns a ULONG_PTR representation of
  465. // its rounded up quadword value
  466. //
  467. #define QuadAlignPtr(Ptr) ( \
  468. ALIGN_UP_POINTER( Ptr, ULONGLONG ) \
  469. )
  470. //
  471. // This macro takes a pointer and returns whether it's quadword-aligned
  472. //
  473. #define IsPtrQuadAligned(Ptr) ( \
  474. QuadAlignPtr(Ptr) == (PVOID)(Ptr) \
  475. )
  476. //
  477. // The following types and macros are used to help unpack the packed and
  478. // misaligned fields found in the Bios parameter block
  479. //
  480. typedef union _UCHAR1 {
  481. UCHAR Uchar[1];
  482. UCHAR ForceAlignment;
  483. } UCHAR1, *PUCHAR1;
  484. typedef union _UCHAR2 {
  485. UCHAR Uchar[2];
  486. USHORT ForceAlignment;
  487. } UCHAR2, *PUCHAR2;
  488. typedef union _UCHAR4 {
  489. UCHAR Uchar[4];
  490. ULONG ForceAlignment;
  491. } UCHAR4, *PUCHAR4;
  492. //
  493. // This macro copies an unaligned src byte to an aligned dst byte
  494. //
  495. #define CopyUchar1(Dst,Src) { \
  496. *((UCHAR1 *)(Dst)) = *((UNALIGNED UCHAR1 *)(Src)); \
  497. }
  498. //
  499. // This macro copies an unaligned src word to an aligned dst word
  500. //
  501. #define CopyUchar2(Dst,Src) { \
  502. *((UCHAR2 *)(Dst)) = *((UNALIGNED UCHAR2 *)(Src)); \
  503. }
  504. //
  505. // This macro copies an unaligned src longword to an aligned dsr longword
  506. //
  507. #define CopyUchar4(Dst,Src) { \
  508. *((UCHAR4 *)(Dst)) = *((UNALIGNED UCHAR4 *)(Src)); \
  509. }
  510. #define CopyU4char(Dst,Src) { \
  511. *((UNALIGNED UCHAR4 *)(Dst)) = *((UCHAR4 *)(Src)); \
  512. }
  513. //
  514. //
  515. // the wrapper doesn't yet implement notify and oplock. rather than remove the code
  516. // we define the calls in such a way as to Noop the effects so that we'll have a head
  517. // start on putting it back later...
  518. /* this is a macro definition we'll reenable when we implement oplocks and notifies
  519. //
  520. // VOID
  521. // RxNotifyReportChange (
  522. // IN PRX_CONTEXT RxContext,
  523. // IN PVCB Vcb,
  524. // IN PFCB Fcb,
  525. // IN ULONG Filter,
  526. // IN ULONG Action
  527. // );
  528. //
  529. #define RxNotifyReportChange(I,V,F,FL,A) { \
  530. if ((F)->FullFileName.Buffer == NULL) { \
  531. RxSetFullFileNameInFcb((I),(F)); \
  532. } \
  533. FsRtlNotifyFullReportChange( (V)->NotifySync, \
  534. &(V)->DirNotifyList, \
  535. (PSTRING)&(F)->FullFileName, \
  536. (USHORT) ((F)->FullFileName.Length - \
  537. (F)->FinalNameLength), \
  538. (PSTRING)NULL, \
  539. (PSTRING)NULL, \
  540. (ULONG)FL, \
  541. (ULONG)A, \
  542. (PVOID)NULL ); \
  543. }
  544. */
  545. #define RxNotifyReportChange(I,V,F,FL,A) \
  546. RxDbgTrace(0, Dbg, ("RxNotifyReportChange PRETENDING Fcb %08lx %wZ Filter/Action = %08lx/%08lx\n", \
  547. (F),&((F)->FcbTableEntry.Path),(FL),(A)))
  548. #if 0
  549. #define FsRtlNotifyFullChangeDirectory(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) \
  550. RxDbgTrace(0, Dbg, ("FsRtlNotifyFullReportChange PRETENDING ............\n",0))
  551. #endif
  552. #define FsRtlCheckOplock(A1,A2,A3,A4,A5) \
  553. (STATUS_SUCCESS)
  554. #define FsRtlOplockIsFastIoPossible(__a) (TRUE)
  555. //
  556. // The following procedure is used by the FSP and FSD routines to complete
  557. // an IRP.
  558. //
  559. // Note that this macro allows either the Irp or the RxContext to be
  560. // null, however the only legal order to do this in is:
  561. //
  562. // RxCompleteRequest_OLD( NULL, Irp, Status ); // completes Irp & preserves context
  563. // ...
  564. // RxCompleteRequest_OLD( RxContext, NULL, DontCare ); // deallocates context
  565. //
  566. // This would typically be done in order to pass a "naked" RxContext off to
  567. // the Fsp for post processing, such as read ahead.
  568. //
  569. // The new way is to pass just the RxContext..........
  570. VOID
  571. RxCompleteRequest_Real (
  572. IN PRX_CONTEXT RxContext,
  573. IN PIRP Irp,
  574. IN NTSTATUS Status
  575. );
  576. #if DBG
  577. #define RxCompleteRequest_OLD(RXCONTEXT,IRP,STATUS) { \
  578. RxCompleteRequest_Real(RXCONTEXT,IRP,STATUS); \
  579. (IRP) = NULL; \
  580. (RXCONTEXT) = NULL; \
  581. }
  582. #else
  583. #define RxCompleteRequest_OLD(RXCONTEXT,IRP,STATUS) { \
  584. RxCompleteRequest_Real(RXCONTEXT,IRP,STATUS); \
  585. }
  586. #endif
  587. NTSTATUS
  588. RxCompleteRequest(
  589. PRX_CONTEXT pContext,
  590. NTSTATUS Status);
  591. #define RxCompleteAsynchronousRequest(RXCONTEXT,STATUS) \
  592. RxCompleteRequest(RXCONTEXT,STATUS)
  593. #define RxCompleteContextAndReturn(STATUS) { \
  594. NTSTATUS __sss = (STATUS); \
  595. RxCompleteRequest(RxContext,__sss); \
  596. return(__sss);}
  597. #define RxCompleteContext(STATUS) { \
  598. NTSTATUS __sss = (STATUS); \
  599. RxCompleteRequest(RxContext,__sss);} \
  600. //
  601. // The Following routine makes a popup
  602. //
  603. VOID
  604. RxPopUpFileCorrupt (
  605. IN PRX_CONTEXT RxContext,
  606. IN PFCB Fcb
  607. );
  608. NTSTATUS
  609. RxConstructSrvCall(
  610. PRX_CONTEXT pRxContext,
  611. PSRV_CALL pSrvCall,
  612. LOCK_HOLDING_STATE *pLockHoldingState);
  613. NTSTATUS
  614. RxSetSrvCallDomainName(
  615. PMRX_SRV_CALL pSrvCall,
  616. PUNICODE_STRING pDomainName);
  617. NTSTATUS
  618. RxConstructNetRoot(
  619. PRX_CONTEXT pRxContext,
  620. PSRV_CALL pSrvCall,
  621. PNET_ROOT pNetRoot,
  622. PV_NET_ROOT pVirtualNetRoot,
  623. LOCK_HOLDING_STATE *pLockHoldingState);
  624. NTSTATUS
  625. RxConstructVirtualNetRoot(
  626. PRX_CONTEXT RxContext,
  627. PUNICODE_STRING CanonicalName,
  628. NET_ROOT_TYPE NetRootType,
  629. PV_NET_ROOT *pVirtualNetRootPointer,
  630. LOCK_HOLDING_STATE *pLockHoldingState,
  631. PRX_CONNECTION_ID RxConnectionId);
  632. NTSTATUS
  633. RxFindOrConstructVirtualNetRoot(
  634. PRX_CONTEXT RxContext,
  635. PUNICODE_STRING CanonicalName,
  636. NET_ROOT_TYPE NetRootType,
  637. PUNICODE_STRING RemainingName);
  638. NTSTATUS
  639. RxLowIoFsCtlShell (
  640. IN PRX_CONTEXT RxContext
  641. );
  642. NTSTATUS
  643. RxLowIoFsCtlShellCompletion (
  644. IN PRX_CONTEXT RxContext
  645. );
  646. NTSTATUS
  647. RxLowIoLockControlShell (
  648. IN PRX_CONTEXT RxContext
  649. );
  650. NTSTATUS
  651. RxChangeBufferingState(
  652. PSRV_OPEN SrvOpen,
  653. PVOID Context,
  654. BOOLEAN ComputeNewState
  655. );
  656. VOID
  657. RxAssociateSrvOpenKey(
  658. PMRX_SRV_OPEN pMRxSrvOpen,
  659. PVOID SrvOpenKey);
  660. VOID
  661. RxIndicateChangeOfBufferingState(
  662. PMRX_SRV_CALL pSrvCall,
  663. PVOID SrvOpenKey,
  664. PVOID pContext);
  665. VOID
  666. RxIndicateChangeOfBufferingStateForSrvOpen(
  667. PMRX_SRV_CALL pSrvCall,
  668. PMRX_SRV_OPEN pSrvOpen,
  669. PVOID SrvOpenKey,
  670. PVOID pContext);
  671. NTSTATUS
  672. RxPrepareToReparseSymbolicLink(
  673. PRX_CONTEXT RxContext,
  674. BOOLEAN SymbolicLinkEmbeddedInOldPath,
  675. PUNICODE_STRING pNewPath,
  676. BOOLEAN NewPathIsAbsolute,
  677. BOOLEAN *pReparseRequired);
  678. BOOLEAN
  679. RxLockEnumerator (
  680. IN OUT struct _MRX_SRV_OPEN_ * SrvOpen,
  681. IN OUT PVOID *ContinuationHandle,
  682. OUT PLARGE_INTEGER FileOffset,
  683. OUT PLARGE_INTEGER LockRange,
  684. OUT PBOOLEAN IsLockExclusive
  685. );
  686. //
  687. // Routines for transitioning data structures to stable states.
  688. //
  689. VOID
  690. RxReference(
  691. IN OUT PVOID pInstance);
  692. VOID
  693. RxDereference(
  694. IN OUT PVOID pInstance,
  695. IN LOCK_HOLDING_STATE LockHoldingState);
  696. VOID
  697. RxWaitForStableCondition(
  698. IN PRX_BLOCK_CONDITION pCondition,
  699. IN OUT PLIST_ENTRY pTransitionWaitList,
  700. IN OUT PRX_CONTEXT RxContext,
  701. OUT NTSTATUS *AsyncStatus OPTIONAL);
  702. VOID
  703. RxUpdateCondition(
  704. IN RX_BLOCK_CONDITION NewConditionValue,
  705. OUT RX_BLOCK_CONDITION *pCondition,
  706. IN OUT PLIST_ENTRY pTransitionWaitList);
  707. VOID
  708. RxFinalizeNetTable(
  709. PRDBSS_DEVICE_OBJECT RxDeviceObject,
  710. BOOLEAN fForceFinalization);
  711. #define RxForceNetTableFinalization(RxDeviceObject) \
  712. RxFinalizeNetTable(RxDeviceObject,TRUE)
  713. NTSTATUS
  714. RxCloseAssociatedSrvOpen(
  715. PFOBX pFobx,
  716. PRX_CONTEXT RxContext);
  717. NTSTATUS
  718. RxFinalizeConnection(
  719. IN OUT PNET_ROOT NetRoot,
  720. IN OUT PV_NET_ROOT VNetRoot OPTIONAL,
  721. IN BOOLEAN ForceFilesClosed
  722. );
  723. // routines for manipulating the user's view and the server's view of SHARE_ACCESS.
  724. // the user's view is supported by routines exported by Io...the wrappers just allow
  725. // us to get a msg. the server's view is supported by routines that are essential just
  726. // copies of the Io routines EXCEPT that the Io routines work directly on fileobjects and
  727. // as such cannot be used directly. the routines mentioned are implemented in create.c
  728. #if DBG
  729. VOID
  730. RxDumpWantedAccess(
  731. PSZ where1,
  732. PSZ where2,
  733. PSZ wherelogtag,
  734. IN ACCESS_MASK DesiredAccess,
  735. IN ULONG DesiredShareAccess
  736. );
  737. VOID
  738. RxDumpCurrentAccess(
  739. PSZ where1,
  740. PSZ where2,
  741. PSZ wherelogtag,
  742. PSHARE_ACCESS ShareAccess
  743. );
  744. #else
  745. #define RxDumpWantedAccess(w1,w2,wlt,DA,DSA) {NOTHING;}
  746. #define RxDumpCurrentAccess(w1,w2,wlt,SA) {NOTHING;}
  747. #endif
  748. NTSTATUS
  749. RxCheckShareAccessPerSrvOpens(
  750. IN PFCB Fcb,
  751. IN ACCESS_MASK DesiredAccess,
  752. IN ULONG DesiredShareAccess
  753. );
  754. VOID
  755. RxUpdateShareAccessPerSrvOpens(
  756. IN PSRV_OPEN SrvOpen
  757. );
  758. VOID
  759. RxRemoveShareAccessPerSrvOpens(
  760. IN OUT PSRV_OPEN SrvOpen
  761. );
  762. VOID
  763. RxRemoveShareAccessPerSrvOpens(
  764. IN OUT PSRV_OPEN SrvOpen
  765. );
  766. #if DBG
  767. NTSTATUS
  768. RxCheckShareAccess(
  769. IN ACCESS_MASK DesiredAccess,
  770. IN ULONG DesiredShareAccess,
  771. IN OUT PFILE_OBJECT FileObject,
  772. IN OUT PSHARE_ACCESS ShareAccess,
  773. IN BOOLEAN Update,
  774. IN PSZ where,
  775. IN PSZ wherelogtag
  776. );
  777. VOID
  778. RxRemoveShareAccess(
  779. IN PFILE_OBJECT FileObject,
  780. IN OUT PSHARE_ACCESS ShareAccess,
  781. IN PSZ where,
  782. IN PSZ wherelogtag
  783. );
  784. VOID
  785. RxSetShareAccess(
  786. IN ACCESS_MASK DesiredAccess,
  787. IN ULONG DesiredShareAccess,
  788. IN OUT PFILE_OBJECT FileObject,
  789. OUT PSHARE_ACCESS ShareAccess,
  790. IN PSZ where,
  791. IN PSZ wherelogtag
  792. );
  793. VOID
  794. RxUpdateShareAccess(
  795. IN PFILE_OBJECT FileObject,
  796. IN OUT PSHARE_ACCESS ShareAccess,
  797. IN PSZ where,
  798. IN PSZ wherelogtag
  799. );
  800. #else
  801. #define RxCheckShareAccess(a1,a2,a3,a4,a5,a6,a7) \
  802. IoCheckShareAccess(a1,a2,a3,a4,a5)
  803. #define RxRemoveShareAccess(a1,a2,a3,a4) \
  804. IoRemoveShareAccess(a1,a2)
  805. #define RxSetShareAccess(a1,a2,a3,a4,a5,a6) \
  806. IoSetShareAccess(a1,a2,a3,a4)
  807. #define RxUpdateShareAccess(a1,a2,a3,a4) \
  808. IoUpdateShareAccess(a1,a2)
  809. #endif
  810. //LoadUnload
  811. NTSTATUS
  812. RxDriverEntry(
  813. IN PDRIVER_OBJECT DriverObject,
  814. IN PUNICODE_STRING RegistryPath
  815. );
  816. VOID
  817. RxUnload(
  818. IN PDRIVER_OBJECT DriverObject
  819. );
  820. //minirdr support
  821. VOID
  822. RxInitializeMinirdrDispatchTable(
  823. IN PDRIVER_OBJECT DriverObject
  824. );
  825. ULONG
  826. RxGetNetworkProviderPriority(
  827. PUNICODE_STRING DeviceName
  828. );
  829. VOID
  830. RxExtractServerName(
  831. IN PUNICODE_STRING FilePathName,
  832. OUT PUNICODE_STRING SrvCallName,
  833. OUT PUNICODE_STRING RestOfName
  834. );
  835. VOID
  836. RxCreateNetRootCallBack (
  837. IN PMRX_CREATENETROOT_CONTEXT pCreateNetRootContext
  838. );
  839. NTSTATUS
  840. DuplicateTransportAddress(
  841. PTRANSPORT_ADDRESS *pCopy,
  842. PTRANSPORT_ADDRESS pOriginal,
  843. POOL_TYPE PoolType);
  844. NTSTATUS
  845. RxCepInitializeVC(
  846. PRXCE_VC pVc,
  847. PRXCE_CONNECTION pConnection);
  848. NTSTATUS
  849. DuplicateConnectionInformation(
  850. PRXCE_CONNECTION_INFORMATION *pCopy,
  851. PRXCE_CONNECTION_INFORMATION pOriginal,
  852. POOL_TYPE PoolType);
  853. NTSTATUS
  854. RxCepInitializeConnection(
  855. IN OUT PRXCE_CONNECTION pConnection,
  856. IN PRXCE_ADDRESS pAddress,
  857. IN PRXCE_CONNECTION_INFORMATION pConnectionInformation,
  858. IN PRXCE_CONNECTION_EVENT_HANDLER pHandler,
  859. IN PVOID pEventContext);
  860. NTSTATUS
  861. RxCeInitiateConnectRequest(
  862. struct _RX_CALLOUT_PARAMETERS_BLOCK_ *pParameterBlock);
  863. VOID
  864. RxCeCleanupConnectCallOutContext(
  865. struct _RX_CREATE_CONNECTION_CALLOUT_CONTEXT_ *pCreateConnectionContext);
  866. PVOID
  867. RxAllocateObject(
  868. NODE_TYPE_CODE NodeType,
  869. PMINIRDR_DISPATCH pMRxDispatch,
  870. ULONG NameLength);
  871. VOID
  872. RxFreeObject(PVOID pObject);
  873. NTSTATUS
  874. RxInitializeSrvCallParameters(
  875. PRX_CONTEXT RxContext,
  876. PSRV_CALL SrvCall);
  877. VOID
  878. RxAddVirtualNetRootToNetRoot(
  879. PNET_ROOT pNetRoot,
  880. PV_NET_ROOT pVNetRoot);
  881. VOID
  882. RxRemoveVirtualNetRootFromNetRoot(
  883. PNET_ROOT pNetRoot,
  884. PV_NET_ROOT pVNetRoot);
  885. VOID
  886. RxOrphanFcbsFromThisVNetRoot (
  887. IN PV_NET_ROOT ThisVNetRoot
  888. );
  889. PVOID
  890. RxAllocateFcbObject(
  891. PRDBSS_DEVICE_OBJECT RxDeviceObject,
  892. NODE_TYPE_CODE NodeType,
  893. POOL_TYPE PoolType,
  894. ULONG NameSize,
  895. PVOID pAlreadyAllocatedObject);
  896. VOID
  897. RxFreeFcbObject(PVOID pObject);
  898. VOID
  899. RxPurgeFcb(
  900. IN PFCB pFcb);
  901. BOOLEAN
  902. RxFinalizeNetFcb (
  903. OUT PFCB ThisFcb,
  904. IN BOOLEAN RecursiveFinalize,
  905. IN BOOLEAN ForceFinalize,
  906. IN LONG ReferenceCount
  907. );
  908. VOID
  909. RxCheckFcbStructuresForAlignment(void);
  910. VOID
  911. RxpPrepareCreateContextForReuse(
  912. PRX_CONTEXT RxContext);
  913. NTSTATUS
  914. RxLowIoSubmitRETRY (
  915. IN PRX_CONTEXT RxContext
  916. );
  917. NTSTATUS
  918. RxLowIoCompletionTail (
  919. IN PRX_CONTEXT RxContext
  920. );
  921. VOID
  922. RxRecurrentTimerWorkItemDispatcher (
  923. IN PVOID Context
  924. );
  925. NTSTATUS
  926. RxInitializeWorkQueueDispatcher(
  927. PRX_WORK_QUEUE_DISPATCHER pDispatcher);
  928. VOID
  929. RxInitializeWorkQueue(
  930. PRX_WORK_QUEUE pWorkQueue,
  931. WORK_QUEUE_TYPE WorkQueueType,
  932. ULONG MaximumNumberOfWorkerThreads,
  933. ULONG MinimumNumberOfWorkerThreads);
  934. VOID
  935. RxTearDownWorkQueueDispatcher(
  936. PRX_WORK_QUEUE_DISPATCHER pDispatcher);
  937. VOID
  938. RxTearDownWorkQueue(
  939. PRX_WORK_QUEUE pWorkQueue);
  940. NTSTATUS
  941. RxSpinUpWorkerThread(
  942. PRX_WORK_QUEUE pWorkQueue,
  943. PRX_WORKERTHREAD_ROUTINE Routine,
  944. PVOID Parameter);
  945. VOID
  946. RxSpinUpWorkerThreads(
  947. PRX_WORK_QUEUE pWorkQueue);
  948. VOID
  949. RxSpinUpRequestsDispatcher(
  950. PRX_DISPATCHER pDispatcher);
  951. VOID
  952. RxpSpinUpWorkerThreads(
  953. PRX_WORK_QUEUE pWorkQueue);
  954. VOID
  955. RxpWorkerThreadDispatcher(
  956. IN PRX_WORK_QUEUE pWorkQueue,
  957. IN PLARGE_INTEGER pWaitInterval);
  958. VOID
  959. RxBootstrapWorkerThreadDispatcher(
  960. IN PRX_WORK_QUEUE pWorkQueue);
  961. VOID
  962. RxWorkerThreadDispatcher(
  963. IN PRX_WORK_QUEUE pWorkQueue);
  964. VOID
  965. RxWorkItemDispatcher(
  966. PVOID pContext);
  967. BOOLEAN
  968. RxIsPrefixTableEmpty(
  969. IN PRX_PREFIX_TABLE ThisTable);
  970. PRX_PREFIX_ENTRY
  971. RxTableLookupName_ExactLengthMatch (
  972. IN PRX_PREFIX_TABLE ThisTable,
  973. IN PUNICODE_STRING Name,
  974. IN ULONG HashValue,
  975. IN PRX_CONNECTION_ID OPTIONAL RxConnectionId
  976. );
  977. PVOID
  978. RxTableLookupName (
  979. IN PRX_PREFIX_TABLE ThisTable,
  980. IN PUNICODE_STRING Name,
  981. OUT PUNICODE_STRING RemainingName,
  982. IN PRX_CONNECTION_ID OPTIONAL RxConnectionId
  983. );
  984. VOID
  985. RxAcquireFileForNtCreateSection (
  986. IN PFILE_OBJECT FileObject
  987. );
  988. VOID
  989. RxReleaseFileForNtCreateSection (
  990. IN PFILE_OBJECT FileObject
  991. );
  992. NTSTATUS
  993. RxPrepareRequestForHandling(
  994. PCHANGE_BUFFERING_STATE_REQUEST pRequest);
  995. VOID
  996. RxPrepareRequestForReuse(
  997. PCHANGE_BUFFERING_STATE_REQUEST pRequest);
  998. VOID
  999. RxpDiscardChangeBufferingStateRequests(
  1000. IN OUT PLIST_ENTRY pDiscardedRequests);
  1001. VOID
  1002. RxGatherRequestsForSrvOpen(
  1003. IN OUT PSRV_CALL pSrvCall,
  1004. IN PSRV_OPEN pSrvOpen,
  1005. IN OUT PLIST_ENTRY pRequestsListHead);
  1006. NTSTATUS
  1007. RxpLookupSrvOpenForRequestLite(
  1008. IN PSRV_CALL pSrvCall,
  1009. IN OUT PCHANGE_BUFFERING_STATE_REQUEST pRequest);
  1010. BOOLEAN
  1011. RxContextCheckToFailThisAttempt(
  1012. IN PIRP Irp,
  1013. IN OUT ULONG* InitialContextFlags
  1014. );
  1015. ULONG
  1016. RxAssignMustSucceedContext(
  1017. IN PIRP Irp,
  1018. IN ULONG InitialContextFlags
  1019. );
  1020. PRX_CONTEXT
  1021. RxAllocateMustSucceedContext(
  1022. PIRP Irp,
  1023. IN PRDBSS_DEVICE_OBJECT RxDeviceObject,
  1024. IN ULONG InitialContextFlags,
  1025. OUT PUCHAR MustSucceedDescriptorNumber
  1026. );
  1027. VOID
  1028. RxFreeMustSucceedContext(
  1029. PRX_CONTEXT RxContext
  1030. );
  1031. PRX_LOG_ENTRY_HEADER
  1032. RxGetNextLogEntry(void);
  1033. VOID
  1034. RxPrintLog (
  1035. IN ULONG EntriesToPrint OPTIONAL
  1036. );
  1037. VOID
  1038. RxProcessChangeBufferingStateRequestsForSrvOpen(
  1039. PSRV_OPEN pSrvOpen);
  1040. NTSTATUS
  1041. RxPurgeFobxFromCache(
  1042. PFOBX pFobxToBePurged);
  1043. BOOLEAN
  1044. RxPurgeFobx(
  1045. PFOBX pFobx);
  1046. VOID
  1047. RxPurgeAllFobxs(
  1048. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  1049. VOID
  1050. RxUndoScavengerFinalizationMarking(
  1051. PVOID pInstance);
  1052. VOID
  1053. RxScavengeAllFobxs(
  1054. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  1055. ULONG
  1056. RxTableComputePathHashValue (
  1057. IN PUNICODE_STRING Name
  1058. );
  1059. VOID
  1060. RxExtractServerName(
  1061. IN PUNICODE_STRING FilePathName,
  1062. OUT PUNICODE_STRING SrvCallName,
  1063. OUT PUNICODE_STRING RestOfName
  1064. );
  1065. VOID
  1066. RxCreateNetRootCallBack (
  1067. IN PMRX_CREATENETROOT_CONTEXT pCreateNetRootContext
  1068. );
  1069. VOID
  1070. RxSpinDownOutstandingAsynchronousRequests(
  1071. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  1072. NTSTATUS
  1073. RxRegisterAsynchronousRequest(
  1074. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  1075. VOID
  1076. RxDeregisterAsynchronousRequest(
  1077. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  1078. BOOLEAN
  1079. RxCancelOperationInOverflowQueue(
  1080. PRX_CONTEXT RxContext);
  1081. VOID
  1082. RxOrphanSrvOpens(
  1083. IN PV_NET_ROOT ThisVNetRoot
  1084. );
  1085. VOID
  1086. RxOrphanThisFcb(
  1087. PFCB pFcb
  1088. );
  1089. VOID
  1090. RxOrphanSrvOpensForThisFcb(
  1091. PFCB pFcb,
  1092. IN PV_NET_ROOT ThisVNetRoot,
  1093. BOOLEAN fOrphanAll
  1094. );
  1095. VOID
  1096. RxForceFinalizeAllVNetRoots(
  1097. PNET_ROOT pNetRoot
  1098. );
  1099. #define RxEqualConnectionId( P1, P2 ) RtlEqualMemory( P1, P2, sizeof(RX_CONNECTION_ID) )
  1100. #endif // _RDBSSPROCS_