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.

645 lines
24 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. RxInit.c
  5. Abstract:
  6. This module implements the FSD-level dispatch routine for the RDBSS.
  7. Author:
  8. Joe Linn [JoeLinn] 2-dec-1994
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. #include <ntddnfs.h>
  14. #include "NtDspVec.h"
  15. //
  16. // The debug trace level
  17. //
  18. #define Dbg (DEBUG_TRACE_DISPATCH)
  19. // the difference between dispatch problem and unimplemented is my judgement as to whether
  20. // this represents a likely application error or not. in a free build, there's no difference.
  21. NTSTATUS
  22. RxCommonDispatchProblem ( RXCOMMON_SIGNATURE );
  23. NTSTATUS
  24. RxCommonUnimplemented ( RXCOMMON_SIGNATURE );
  25. RX_FSD_DISPATCH_VECTOR RxFsdDispatchVector[IRP_MJ_MAXIMUM_FUNCTION + 1] = {
  26. DISPVECENTRY_NEW(CREATE, TRUE, Create, 0x10), // 0x00
  27. DISPVECENTRY_NEW(CREATE_NAMED_PIPE, TRUE, Unimplemented, 0x10), // 0x01
  28. DISPVECENTRY_NEW(CLOSE, TRUE, Close, 0x10), // 0x02
  29. DISPVECENTRY_NEW(READ, TRUE, Read, 0x10), // 0x03
  30. DISPVECENTRY_NEW(WRITE, TRUE, Write, 0x10), // 0x04
  31. DISPVECENTRY_NEW(QUERY_INFORMATION, TRUE, QueryInformation, 0x10), // 0x05
  32. DISPVECENTRY_NEW(SET_INFORMATION, TRUE, SetInformation, 0x10), // 0x06
  33. DISPVECENTRY_NEW(QUERY_EA, TRUE, QueryEa, 0x10), // 0x07
  34. DISPVECENTRY_NEW(SET_EA, TRUE, SetEa, 0x10), // 0x08
  35. DISPVECENTRY_NEW(FLUSH_BUFFERS, TRUE, FlushBuffers, 0x10), // 0x09
  36. DISPVECENTRY_NEW(QUERY_VOLUME_INFORMATION, TRUE, QueryVolumeInformation, 0x10), // 0x0a
  37. DISPVECENTRY_NEW(SET_VOLUME_INFORMATION, FALSE, SetVolumeInformation, 0x10), // 0x0b //BUGBUG
  38. DISPVECENTRY_NEW(DIRECTORY_CONTROL, TRUE, DirectoryControl, 0x10), // 0x0c
  39. DISPVECENTRY_NEW(FILE_SYSTEM_CONTROL, TRUE, FileSystemControl, 0x10), // 0x0d
  40. DISPVECENTRY_NEW(DEVICE_CONTROL, TRUE, DeviceControl, 0x10), // 0x0e
  41. DISPVECENTRY_NEW(INTERNAL_DEVICE_CONTROL, TRUE, DeviceControl, 0x10), // 0x0f
  42. DISPVECENTRY_NEW(SHUTDOWN, FALSE, Shutdown, 0x10), // 0x10 //BUGBUG
  43. DISPVECENTRY_NEW(LOCK_CONTROL, TRUE, LockControl, 0x10), // 0x11
  44. DISPVECENTRY_NEW(CLEANUP, TRUE, Cleanup, 0x10), // 0x12
  45. DISPVECENTRY_NEW(CREATE_MAILSLOT, TRUE, Unimplemented, 0x10), // 0x13
  46. DISPVECENTRY_NEW(QUERY_SECURITY, TRUE, QuerySecurity, 0x10), // 0x14
  47. DISPVECENTRY_NEW(SET_SECURITY, TRUE, SetSecurity, 0x10), // 0x15
  48. DISPVECENTRY_NEW(QUERY_POWER, TRUE, Unimplemented, 0x10), // 0x16
  49. DISPVECENTRY_NEW(NOT_DEFINED, TRUE, Unimplemented, 0x10), // 0x17
  50. DISPVECENTRY_NEW(DEVICE_CHANGE, TRUE, Unimplemented, 0x10), // 0x18
  51. DISPVECENTRY_NEW(QUERY_QUOTA, TRUE, Unimplemented, 0x10), // 0x19
  52. DISPVECENTRY_NEW(SET_QUOTA, TRUE, Unimplemented, 0x10), // 0x1a
  53. DISPVECENTRY_NEW(PNP_POWER, TRUE, Unimplemented, 0x10) // 0x1b
  54. };
  55. RX_FSD_DISPATCH_VECTOR RxDeviceFCBVector[IRP_MJ_MAXIMUM_FUNCTION + 1] = {
  56. DISPVECENTRY_NEW(CREATE, TRUE, DispatchProblem, 0x10),
  57. DISPVECENTRY_NEW(CREATE_NAMED_PIPE, TRUE, DispatchProblem, 0x10),
  58. DISPVECENTRY_NEW(CLOSE, TRUE, DevFCBClose, 0x10),
  59. DISPVECENTRY_NEW(READ, TRUE, DispatchProblem, 0x10),
  60. DISPVECENTRY_NEW(WRITE, TRUE, DispatchProblem, 0x10),
  61. DISPVECENTRY_NEW(QUERY_INFORMATION, TRUE, DispatchProblem, 0x10),
  62. DISPVECENTRY_NEW(SET_INFORMATION, TRUE, DispatchProblem, 0x10),
  63. DISPVECENTRY_NEW(QUERY_EA, TRUE, DispatchProblem, 0x10),
  64. DISPVECENTRY_NEW(SET_EA, TRUE, DispatchProblem, 0x10),
  65. DISPVECENTRY_NEW(FLUSH_BUFFERS, TRUE, DispatchProblem, 0x10),
  66. DISPVECENTRY_NEW(QUERY_VOLUME_INFORMATION, TRUE, DevFCBQueryVolInfo, 0x10),
  67. DISPVECENTRY_NEW(SET_VOLUME_INFORMATION, TRUE, DispatchProblem, 0x10),
  68. DISPVECENTRY_NEW(DIRECTORY_CONTROL, TRUE, DispatchProblem, 0x10),
  69. DISPVECENTRY_NEW(FILE_SYSTEM_CONTROL, TRUE, DevFCBFsCtl, 0x10),
  70. DISPVECENTRY_NEW(DEVICE_CONTROL, TRUE, DevFCBIoCtl, 0x10),
  71. DISPVECENTRY_NEW(INTERNAL_DEVICE_CONTROL, TRUE, DevFCBIoCtl, 0x10),
  72. DISPVECENTRY_NEW(SHUTDOWN, TRUE, DispatchProblem, 0x10),
  73. DISPVECENTRY_NEW(LOCK_CONTROL, TRUE, DispatchProblem, 0x10),
  74. DISPVECENTRY_NEW(CLEANUP, TRUE, DevFCBCleanup, 0x10),
  75. DISPVECENTRY_NEW(CREATE_MAILSLOT, TRUE, DispatchProblem, 0x10),
  76. DISPVECENTRY_NEW(QUERY_SECURITY, TRUE, DispatchProblem, 0x10),
  77. DISPVECENTRY_NEW(SET_SECURITY, TRUE, DispatchProblem, 0x10),
  78. DISPVECENTRY_NEW(QUERY_POWER, TRUE, Unimplemented, 0x10), // 0x16
  79. DISPVECENTRY_NEW(NOT_DEFINED, TRUE, Unimplemented, 0x10), // 0x17
  80. DISPVECENTRY_NEW(DEVICE_CHANGE, TRUE, Unimplemented, 0x10), // 0x18
  81. DISPVECENTRY_NEW(QUERY_QUOTA, TRUE, Unimplemented, 0x10), // 0x19
  82. DISPVECENTRY_NEW(SET_QUOTA, TRUE, Unimplemented, 0x10), // 0x1a
  83. DISPVECENTRY_NEW(PNP_POWER, TRUE, Unimplemented, 0x10) // 0x1b
  84. };
  85. FAST_IO_DISPATCH RxFastIoDispatch;
  86. NTSTATUS
  87. RxFsdCommonDispatch (
  88. PRX_FSD_DISPATCH_VECTOR DispatchVector,
  89. IN UCHAR MajorFunctionCode,
  90. IN PIO_STACK_LOCATION IrpSp,
  91. IN PFILE_OBJECT FileObject,
  92. IN PIRP Irp,
  93. IN PRDBSS_DEVICE_OBJECT RxObject
  94. );
  95. VOID
  96. RxInitializeDispatchVectors(
  97. OUT PDRIVER_OBJECT DriverObject
  98. );
  99. #ifdef ALLOC_PRAGMA
  100. #pragma alloc_text(INIT, RxInitializeDispatchVectors)
  101. //not pageable SPINLOCK #pragma alloc_text(PAGE, RxFsdCommonDispatch)
  102. #pragma alloc_text(PAGE, RxCommonDispatchProblem)
  103. #pragma alloc_text(PAGE, RxCommonUnimplemented)
  104. #pragma alloc_text(PAGE, RxFsdDispatch)
  105. #endif
  106. VOID
  107. RxInitializeDispatchVectors(
  108. OUT PDRIVER_OBJECT DriverObject
  109. )
  110. /*++
  111. Routine Description:
  112. This routine initializes the dispatch table for the driver object
  113. Arguments:
  114. DriverObject - Supplies the driver object
  115. --*/
  116. {
  117. ULONG i;
  118. PAGED_CODE();
  119. for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) {
  120. DriverObject->MajorFunction[i] = (PDRIVER_DISPATCH)RxFsdDispatch;
  121. }
  122. // Set Dispatch Vector for the DevFCB
  123. RxDeviceFCB.PrivateDispatchVector = &RxDeviceFCBVector[0];
  124. ASSERT (RxFsdDispatchVector[IRP_MJ_MAXIMUM_FUNCTION].CommonRoutine != NULL);
  125. ASSERT (RxDeviceFCBVector[IRP_MJ_MAXIMUM_FUNCTION].CommonRoutine != NULL);
  126. DriverObject->FastIoDispatch = &RxFastIoDispatch; //this is dangerous!!!
  127. RxFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
  128. RxFastIoDispatch.FastIoCheckIfPossible = RxFastIoCheckIfPossible; // CheckForFastIo
  129. RxFastIoDispatch.FastIoRead = RxFastIoRead; // Read
  130. RxFastIoDispatch.FastIoWrite = RxFastIoWrite; // Write
  131. RxFastIoDispatch.FastIoQueryBasicInfo = NULL; //RxFastQueryBasicInfo; // QueryBasicInfo
  132. RxFastIoDispatch.FastIoQueryStandardInfo = NULL; //RxFastQueryStdInfo; // QueryStandardInfo
  133. RxFastIoDispatch.FastIoLock = NULL; //RxFastLock; // Lock
  134. RxFastIoDispatch.FastIoUnlockSingle = NULL; //RxFastUnlockSingle; // UnlockSingle
  135. RxFastIoDispatch.FastIoUnlockAll = NULL; //RxFastUnlockAll; // UnlockAll
  136. RxFastIoDispatch.FastIoUnlockAllByKey = NULL; //RxFastUnlockAllByKey; // UnlockAllByKey
  137. RxFastIoDispatch.FastIoDeviceControl = NULL; // IoDeviceControl
  138. RxFastIoDispatch.AcquireFileForNtCreateSection = RxAcquireFileForNtCreateSection;
  139. RxFastIoDispatch.ReleaseFileForNtCreateSection = RxReleaseFileForNtCreateSection;
  140. // Initialize the global netname table and export
  141. RxInitializePrefixTable( &RxNetNameTable, 0, FALSE);
  142. RxExports.pRxNetNameTable = &RxNetNameTable;
  143. RxNetNameTable.IsNetNameTable = TRUE;
  144. // Initialize the cache manager callback routines
  145. RxData.CacheManagerCallbacks.AcquireForLazyWrite = &RxAcquireFcbForLazyWrite;
  146. RxData.CacheManagerCallbacks.ReleaseFromLazyWrite = &RxReleaseFcbFromLazyWrite;
  147. RxData.CacheManagerCallbacks.AcquireForReadAhead = &RxAcquireFcbForReadAhead;
  148. RxData.CacheManagerCallbacks.ReleaseFromReadAhead = &RxReleaseFcbFromReadAhead;
  149. RxData.CacheManagerNoOpCallbacks.AcquireForLazyWrite = &RxNoOpAcquire;
  150. RxData.CacheManagerNoOpCallbacks.ReleaseFromLazyWrite = &RxNoOpRelease;
  151. RxData.CacheManagerNoOpCallbacks.AcquireForReadAhead = &RxNoOpAcquire;
  152. RxData.CacheManagerNoOpCallbacks.ReleaseFromReadAhead = &RxNoOpRelease;
  153. }
  154. NTSTATUS
  155. RxCommonDispatchProblem ( RXCOMMON_SIGNATURE )
  156. {
  157. // if we get here then something is awry. this is used to initialize fields that SHOULD
  158. // not be accessed....like the create field in any vector but the highest level
  159. PAGED_CODE();
  160. RxDbgTrace( 0, (DEBUG_TRACE_ALWAYS), ("RxFsdDispatchPROBLEM: IrpC =%08lx,Code=", RxContext, RxContext->MajorFunction ));
  161. RxDbgTrace( 0, (DEBUG_TRACE_ALWAYS), ("---------------------PROBLEM-----%s\n", "" ));
  162. RxLog(("%s %lx %ld\n","pDX", RxContext, RxContext->MajorFunction));
  163. // RxCompleteContextAndReturn( RxStatus(NOT_IMPLEMENTED) );
  164. return STATUS_NOT_IMPLEMENTED;
  165. }
  166. NTSTATUS
  167. RxCommonUnimplemented ( RXCOMMON_SIGNATURE )
  168. {
  169. PAGED_CODE();
  170. RxDbgTrace( 0, (DEBUG_TRACE_ALWAYS), ("RxFsdDispatRxFsdUnImplementedchPROBLEM: IrpC =%08lx,Code=",
  171. RxContext, RxContext->MajorFunction ));
  172. RxDbgTrace( 0, (DEBUG_TRACE_ALWAYS), ("---------------------UNIMLEMENTED-----%s\n", "" ));
  173. // RxCompleteContextAndReturn( RxStatus(NOT_IMPLEMENTED) );
  174. return STATUS_NOT_IMPLEMENTED;
  175. }
  176. RxDbgTraceDoit(ULONG RxDbgTraceEnableCommand = 0xffff;)
  177. NTSTATUS
  178. RxFsdDispatch (
  179. IN PRDBSS_DEVICE_OBJECT RxDeviceObject,
  180. IN PIRP Irp
  181. )
  182. /*++
  183. Routine Description:
  184. This routine implements the FSD dispatch for the RDBSS.
  185. Arguments:
  186. RxDeviceObject - Supplies the device object for the packet being processed.
  187. Irp - Supplies the Irp being processed
  188. Return Value:
  189. RXSTATUS - The Fsd status for the Irp
  190. --*/
  191. {
  192. NTSTATUS status;
  193. PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation( Irp ); //ok4ioget
  194. UCHAR MajorFunctionCode = IrpSp->MajorFunction;
  195. PFILE_OBJECT FileObject = IrpSp->FileObject; //ok4->fileobj
  196. PRX_FSD_DISPATCH_VECTOR DispatchVector;
  197. PAGED_CODE();
  198. RxDbgTraceDoit(
  199. if (MajorFunctionCode == RxDbgTraceEnableCommand) {
  200. RxNextGlobalTraceSuppress = RxGlobalTraceSuppress = FALSE;
  201. }
  202. if (0) {
  203. RxNextGlobalTraceSuppress = RxGlobalTraceSuppress = FALSE;
  204. }
  205. );
  206. RxDbgTrace( 0, Dbg, ("RxFsdDispatch: Code =%02lx (%lu) ----------%s-----------\n",
  207. MajorFunctionCode,
  208. ++RxIrpCodeCount[IrpSp->MajorFunction],
  209. RxIrpCodeToName[MajorFunctionCode] ));
  210. // get a private dispatch table if there is one
  211. if (FileObject->FsContext != NULL) {
  212. if (((PFCB)(FileObject->FsContext))->PrivateDispatchVector != NULL) { //ok4fscontext
  213. RxDbgTraceLV( 0, Dbg, 2500, ("Using Private Dispatch Vector\n"));
  214. DispatchVector = ((PFCB)(FileObject->FsContext))->PrivateDispatchVector;
  215. } else {
  216. DispatchVector = RxFsdDispatchVector;
  217. }
  218. } else if (MajorFunctionCode == IRP_MJ_CREATE) {
  219. DispatchVector = RxFsdDispatchVector;
  220. } else {
  221. DispatchVector = NULL;
  222. RxDbgTrace(
  223. 0,
  224. Dbg,
  225. ("RxFsdDispatch: Code =%02lx (%lu) ----------%s-----------\n",
  226. MajorFunctionCode,
  227. ++RxIrpCodeCount[IrpSp->MajorFunction],
  228. RxIrpCodeToName[MajorFunctionCode]));
  229. }
  230. if (DispatchVector != NULL) {
  231. status = RxFsdCommonDispatch( DispatchVector,
  232. MajorFunctionCode,
  233. IrpSp,
  234. FileObject,
  235. Irp,
  236. RxDeviceObject );
  237. RxDbgTrace( 0, Dbg, ("RxFsdDispatch: Status =%02lx %s....\n",
  238. status,
  239. RxIrpCodeToName[MajorFunctionCode] ));
  240. RxDbgTraceDoit(
  241. if (RxGlobalTraceIrpCount > 0) {
  242. RxGlobalTraceIrpCount -= 1;
  243. RxGlobalTraceSuppress = FALSE;
  244. } else {
  245. RxGlobalTraceSuppress = RxNextGlobalTraceSuppress;
  246. }
  247. );
  248. } else {
  249. status = STATUS_INVALID_HANDLE;
  250. }
  251. return status;
  252. }
  253. NTSTATUS
  254. RxFsdCommonDispatch (
  255. PRX_FSD_DISPATCH_VECTOR DispatchVector,
  256. IN UCHAR MajorFunctionCode,
  257. IN PIO_STACK_LOCATION IrpSp,
  258. IN PFILE_OBJECT FileObject,
  259. IN PIRP Irp,
  260. IN PRDBSS_DEVICE_OBJECT RxDeviceObject
  261. )
  262. /*++
  263. Routine Description:
  264. This routine implements the FSD part of dispatch for IRP's
  265. Arguments:
  266. DispatchVector - the dispatch vector
  267. MajorFunctionCode - the IRP major function
  268. IrpSp - the IRP stack
  269. FileObject - the file object
  270. Irp - the IRP
  271. Return Value:
  272. RXSTATUS - The FSD status for the IRP
  273. Notes:
  274. --*/
  275. { //not currently pageable.......
  276. NTSTATUS Status = STATUS_SUCCESS;
  277. PRX_CONTEXT RxContext = NULL;
  278. UCHAR MinorFunctionCode = IrpSp->MinorFunction;
  279. BOOLEAN TopLevel;
  280. ULONG ContextFlags = 0;
  281. BOOLEAN Wait;
  282. BOOLEAN Cancellable;
  283. BOOLEAN ModWriter = FALSE;
  284. BOOLEAN fCleanupOrClose = FALSE;
  285. BOOLEAN fContinueOperation = TRUE;
  286. KIRQL SavedIrql;
  287. BOOLEAN PostRequest = FALSE;
  288. PRX_DISPATCH DispatchRoutine = NULL;
  289. PDRIVER_CANCEL CancelRoutine = NULL;
  290. //RxDbgTraceLV(+1, Dbg, 1500, ("RxFsd[%s]\n", RxIrpCodeToName[MajorFunctionCode]));
  291. //TimerStart(Dbg);
  292. FsRtlEnterFileSystem();
  293. TopLevel = RxTryToBecomeTheTopLevelIrp( Irp );
  294. try {
  295. // Treat all operations as being cancellable and waitable.
  296. Wait = RX_CONTEXT_FLAG_WAIT;
  297. Cancellable = TRUE;
  298. CancelRoutine = RxCancelRoutine;
  299. // Retract the capability based upon the operation
  300. switch (MajorFunctionCode) {
  301. case IRP_MJ_FILE_SYSTEM_CONTROL:
  302. // Call the common FileSystem Control routine, with blocking allowed if
  303. // synchronous. This opeation needs to special case the mount
  304. // and verify suboperations because we know they are allowed to block.
  305. // We identify these suboperations by looking at the file object field
  306. // and seeing if its null.
  307. Wait = (FileObject == NULL) ? TRUE : CanFsdWait( Irp );
  308. break;
  309. case IRP_MJ_READ:
  310. case IRP_MJ_LOCK_CONTROL:
  311. case IRP_MJ_DIRECTORY_CONTROL:
  312. case IRP_MJ_QUERY_VOLUME_INFORMATION:
  313. case IRP_MJ_WRITE:
  314. case IRP_MJ_QUERY_INFORMATION:
  315. case IRP_MJ_SET_INFORMATION:
  316. case IRP_MJ_QUERY_EA:
  317. case IRP_MJ_SET_EA:
  318. case IRP_MJ_QUERY_SECURITY:
  319. case IRP_MJ_SET_SECURITY:
  320. case IRP_MJ_FLUSH_BUFFERS:
  321. case IRP_MJ_DEVICE_CONTROL:
  322. case IRP_MJ_SET_VOLUME_INFORMATION:
  323. Wait = CanFsdWait( Irp );
  324. break;
  325. case IRP_MJ_CLEANUP:
  326. case IRP_MJ_CLOSE:
  327. Cancellable = FALSE;
  328. fCleanupOrClose = TRUE;
  329. break;
  330. default:
  331. break;
  332. }
  333. KeAcquireSpinLock(&RxStrucSupSpinLock,&SavedIrql);
  334. fContinueOperation = TRUE;
  335. switch (RxDeviceObject->StartStopContext.State) {
  336. case RDBSS_STARTABLE: //here only device creates and device operations can go thru
  337. {
  338. if (((FileObject->FileName.Length == 0) &&
  339. (FileObject->RelatedFileObject == NULL))
  340. || (DispatchVector == RxDeviceFCBVector)){
  341. NOTHING;
  342. } else {
  343. fContinueOperation = FALSE;
  344. Status = STATUS_REDIRECTOR_NOT_STARTED;
  345. }
  346. }
  347. break;
  348. case RDBSS_STOP_IN_PROGRESS:
  349. if (!fCleanupOrClose) {
  350. fContinueOperation = FALSE;
  351. Status = STATUS_REDIRECTOR_NOT_STARTED;
  352. }
  353. break;
  354. //case RDBSS_STOPPED:
  355. // {
  356. // if ((MajorFunctionCode == IRP_MJ_FILE_SYSTEM_CONTROL) &&
  357. // (MinorFunctionCode == IRP_MN_USER_FS_REQUEST) &&
  358. // (IrpSp->Parameters.FileSystemControl.FsControlCode == FSCTL_LMR_START)) {
  359. // RxDeviceObject->StartStopContext.State = RDBSS_START_IN_PROGRESS;
  360. // RxDeviceObject->StartStopContext.Version++;
  361. // fContinueOperation = TRUE;
  362. // } else {
  363. // fContinueOperation = FALSE;
  364. // Status = STATUS_REDIRECTOR_NOT_STARTED);
  365. // }
  366. // }
  367. case RDBSS_STARTED:
  368. // intentional break;
  369. default:
  370. break;
  371. }
  372. KeReleaseSpinLock(&RxStrucSupSpinLock,SavedIrql);
  373. if ((IrpSp->FileObject != NULL) &&
  374. (IrpSp->FileObject->FsContext != NULL)) {
  375. PFCB pFcb = (PFCB)IrpSp->FileObject->FsContext;
  376. if (FlagOn(pFcb->FcbState,FCB_STATE_ORPHANED)) {
  377. if (!fCleanupOrClose) {
  378. DbgPrint("Ignoring operation on ORPHANED FCB %lx %lx %lx\n",pFcb,MajorFunctionCode,MinorFunctionCode);
  379. fContinueOperation = FALSE;
  380. Status = STATUS_UNEXPECTED_NETWORK_ERROR;
  381. } else {
  382. DbgPrint("Delayed Close/Cleanup on ORPHANED FCB %lx\n",pFcb);
  383. fContinueOperation = TRUE;
  384. }
  385. }
  386. }
  387. if (RxDeviceObject->StartStopContext.State == RDBSS_STOP_IN_PROGRESS) {
  388. if (fCleanupOrClose) {
  389. PFILE_OBJECT pFileObject = IrpSp->FileObject;
  390. PFCB pFcb = (PFCB)pFileObject->FsContext;
  391. DbgPrint("RDBSS -- Close after Stop");
  392. DbgPrint("RDBSS: Irp(%lx) MJ %ld MN %ld FileObject(%lx) FCB(%lx) \n",
  393. Irp,IrpSp->MajorFunction,IrpSp->MinorFunction,pFileObject,pFcb);
  394. if ((pFileObject != NULL)
  395. && (pFcb != NULL)
  396. && (pFcb != &RxDeviceFCB)
  397. && NodeTypeIsFcb(pFcb)) {
  398. DbgPrint(
  399. "RDBSS: OpenCount(%ld) UncleanCount(%ld) Name(%wZ)\n",
  400. pFcb->OpenCount,
  401. pFcb->UncleanCount,
  402. &pFcb->FcbTableEntry.Path);
  403. }
  404. }
  405. }
  406. if (!fContinueOperation) {
  407. try_return(Status);
  408. }
  409. if (Wait) {
  410. SetFlag(ContextFlags,RX_CONTEXT_FLAG_WAIT);
  411. }
  412. RxContext = RxCreateRxContext( Irp, RxDeviceObject, ContextFlags );
  413. if (RxContext == NULL) {
  414. Status = STATUS_INSUFFICIENT_RESOURCES;
  415. RxCompleteRequest_OLD( RxNull, Irp, Status );
  416. try_return( Status );
  417. }
  418. // Assume ownership of the Irp by setting the cancelling routine.
  419. if (Cancellable) {
  420. RxSetCancelRoutine(Irp,CancelRoutine);
  421. } else {
  422. // Ensure that those operations regarded as non cancellable will
  423. // not be cancelled.
  424. RxSetCancelRoutine(Irp,NULL);
  425. }
  426. ASSERT(MajorFunctionCode <= IRP_MJ_MAXIMUM_FUNCTION);
  427. Irp->IoStatus.Information = 0;
  428. Irp->IoStatus.Status = STATUS_SUCCESS;
  429. DispatchRoutine = DispatchVector[MajorFunctionCode].CommonRoutine;
  430. switch (MajorFunctionCode) {
  431. case IRP_MJ_READ:
  432. case IRP_MJ_WRITE:
  433. // If this is an Mdl complete request, don't go through
  434. // common read.
  435. if ( FlagOn(MinorFunctionCode, IRP_MN_COMPLETE) ) {
  436. DispatchRoutine = RxCompleteMdl;
  437. } else if ( FlagOn(MinorFunctionCode, IRP_MN_DPC) ) {
  438. // Post all DPC calls.
  439. RxDbgTrace(0, Dbg, ("Passing DPC call to Fsp\n", 0 ));
  440. PostRequest = TRUE;
  441. } else if ((MajorFunctionCode == IRP_MJ_READ) &&
  442. (IoGetRemainingStackSize() < 0xe00)) {
  443. //
  444. // Check if we have enough stack space to process this request. If there
  445. // isn't enough then we will pass the request off to the stack overflow thread.
  446. //
  447. // joejoe where did the number come from......
  448. // this number should come from the minirdr....only he knows how much he needs
  449. // and in my configuration it should definitely be bigger than for FAT!
  450. // plus......i can't go to the net on the hypercrtical thread!!! this will have to be
  451. // reworked! maybe we should have our own hypercritical thread............
  452. RxDbgTrace(0, Dbg, ("Passing StackOverflowRead off\n", 0 ));
  453. try_return( Status = RxPostStackOverflowRead( RxContext) );
  454. }
  455. break;
  456. default:
  457. NOTHING;
  458. }
  459. //
  460. // set the resume routine for the fsp to be the dispatch routine and then either post immediately
  461. // or calldow to the common dispatch as appropriate
  462. RxContext->ResumeRoutine = DispatchRoutine;
  463. if( DispatchRoutine != NULL ) {
  464. if (PostRequest) {
  465. Status = RxFsdPostRequest(RxContext);
  466. } else {
  467. do {
  468. Status = DispatchRoutine( RXCOMMON_ARGUMENTS );
  469. } while (Status == STATUS_RETRY);
  470. if (Status != STATUS_PENDING) {
  471. if (! ((RxContext->CurrentIrp == Irp) &&
  472. (RxContext->CurrentIrpSp == IrpSp) &&
  473. (RxContext->MajorFunction == MajorFunctionCode) &&
  474. (RxContext->MinorFunction == MinorFunctionCode) )
  475. ) {
  476. DbgPrint("RXCONTEXT CONTAMINATED!!!! rxc=%08lx\n", RxContext);
  477. DbgPrint("-irp> %08lx %08lx\n",RxContext->CurrentIrp,Irp);
  478. DbgPrint("--sp> %08lx %08lx\n",RxContext->CurrentIrpSp,IrpSp);
  479. DbgPrint("--mj> %08lx %08lx\n",RxContext->MajorFunction,MajorFunctionCode);
  480. DbgPrint("--mn> %08lx %08lx\n",RxContext->MinorFunction,MinorFunctionCode);
  481. DbgBreakPoint();
  482. }
  483. Status = RxCompleteRequest( RxContext, Status );
  484. }
  485. }
  486. } else {
  487. Status = STATUS_NOT_IMPLEMENTED;
  488. }
  489. try_exit: NOTHING;
  490. } except(RxExceptionFilter( RxContext, GetExceptionInformation() )) {
  491. // The I/O request was not handled successfully, abort the I/O request with
  492. // the error status that we get back from the execption code
  493. Status = RxProcessException( RxContext, GetExceptionCode() );
  494. }
  495. if (TopLevel) {
  496. IoSetTopLevelIrp( NULL );
  497. }
  498. FsRtlExitFileSystem();
  499. //RxDbgTraceLV(-1, Dbg, 1500, ("RxFsd[%s] Status-> %08lx\n", RxIrpCodeToName[MajorFunctionCode],Status));
  500. //TimerStop(Dbg,"RxFsdCreate");
  501. return Status;
  502. #if DBG
  503. NOTHING;
  504. #else
  505. UNREFERENCED_PARAMETER( IrpSp );
  506. #endif
  507. }
  508.