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.

598 lines
14 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. proxymrx.h
  5. Abstract:
  6. The global include file for PROXY mini redirector
  7. Author:
  8. Balan Sethu Raman (SethuR) - Created 2-March-95
  9. Revision History:
  10. --*/
  11. #ifndef _PROXYMRX_H_
  12. #define _PROXYMRX_H_
  13. #include "align.h"
  14. #include "status.h"
  15. #include "mrxglbl.h" // global data declarations/defines etc.
  16. #include "pxypoolt.h" // Pool tag definitions
  17. #include "asynceng.h"
  18. #pragma warning(error:4101) // Unreferenced local variable
  19. //mini's does use these
  20. #undef RxCaptureRequestPacket
  21. #undef RxCaptureParamBlock
  22. #ifdef RX_PRIVATE_BUILD
  23. #if 1
  24. #ifdef RDBSSTRACE
  25. extern ULONG MRxProxyDbgPrintF;
  26. #undef RxDbgTrace
  27. #define RxDbgTrace(a,b,__d__) { if(MRxProxyDbgPrintF){DbgPrint __d__;}}
  28. #undef RxDbgTraceLV
  29. #define RxDbgTraceLV(a,b,c,__d__) { if(MRxProxyDbgPrintF){DbgPrint __d__;}}
  30. #undef RxDbgTraceUnIndent
  31. #define RxDbgTraceUnIndent(a,b) {NOTHING;}
  32. #endif //#ifdef RDBSSTRACE
  33. #endif //if 1
  34. #endif //ifdef RX_PRIVATE_BUILD
  35. extern ULONG MRxProxyLoudStringTableSize;
  36. extern UNICODE_STRING MRxProxyLoudStrings[50];
  37. VOID
  38. MRxProxySetLoud(
  39. IN PBYTE Msg,
  40. IN PRX_CONTEXT RxContext,
  41. IN PUNICODE_STRING s
  42. );
  43. VOID
  44. MRxProxyInitializeLoudStrings(
  45. void
  46. );
  47. //
  48. typedef struct _MRXPROXY_DEVICE_OBJECT {
  49. union {
  50. RDBSS_DEVICE_OBJECT;
  51. RDBSS_DEVICE_OBJECT RxDeviceObject;
  52. };
  53. UNICODE_STRING InnerPrefixForOpens;
  54. UNICODE_STRING PrefixForRename;
  55. } MRXPROXY_DEVICE_OBJECT, *PMRXPROXY_DEVICE_OBJECT;
  56. //TEMPORARY
  57. #define MRXPROXY_PREFIX_FOR_RENAME L"\\CC$$WRAP"
  58. #define MRXPROXY_INNERPREFIX_FOR_OPENS L"\\??\\C:\\CC$$WRAP"
  59. extern PMRXPROXY_DEVICE_OBJECT MRxProxyDeviceObject;
  60. //
  61. // a pointer to the process that the rdbss posts to.....this is a nondisappearing process!
  62. extern PEPROCESS MRxProxySystemProcess;
  63. //
  64. // a serialization mutex used for various things........
  65. extern FAST_MUTEX MRxProxySerializationMutex;
  66. //
  67. // A pointer to an instance of MRX_PROXY_FCB is stored in the context field of
  68. // MRX_FCBs handled by the PROXY mini rdr.
  69. typedef struct _MRX_PROXY_FCB_ {
  70. //M for Minirdr CODE.IMPROVEMENT should this be moved into the FCB itself?
  71. ULONG MFlags;
  72. ULONG WriteOnlySrvOpenCount;
  73. } MRX_PROXY_FCB, *PMRX_PROXY_FCB;
  74. #define MRxProxyGetFcbExtension(pFcb) \
  75. (((pFcb) == NULL) ? NULL : (PMRX_PROXY_FCB)((pFcb)->Context))
  76. #define PROXY_FCB_FLAG_SENT_DISPOSITION_INFO 0x00000001
  77. typedef struct _PROXYPSE_FILEINFO_BUNDLE {
  78. FILE_BASIC_INFORMATION Basic;
  79. FILE_STANDARD_INFORMATION Standard;
  80. } PROXYPSE_FILEINFO_BUNDLE, *PPROXYPSE_FILEINFO_BUNDLE;
  81. typedef struct _MRXPROXY_CREATE_PARAMETERS {
  82. //this is done this way for when this expands...as it's likely too
  83. //CODE.IMPROVEMENT for example, we should put the mapped stuff in here
  84. ULONG Pid;
  85. UCHAR SecurityFlags;
  86. } MRXPROXY_CREATE_PARAMETERS, *PMRXPROXY_CREATE_PARAMETERS;
  87. typedef struct _MRX_PROXY_DEFERRED_OPEN_CONTEXT {
  88. NT_CREATE_PARAMETERS NtCreateParameters; // a copy of the createparameters
  89. ULONG RxContextFlags;
  90. MRXPROXY_CREATE_PARAMETERS ProxyCp;
  91. USHORT RxContextCreateFlags;
  92. } MRX_PROXY_DEFERRED_OPEN_CONTEXT, *PMRX_PROXY_DEFERRED_OPEN_CONTEXT;
  93. //
  94. // A pointer to an instance of MRX_PROXY_SRV_OPEN is stored in the context fields
  95. // of MRX_SRV_OPEN handled by the PROXY mini rdr. This encapsulates the FID used
  96. // to identify open files/directories in the PROXY protocol.
  97. typedef struct _MRX_PROXY_SRV_OPEN {
  98. ULONG Flags;
  99. HANDLE UnderlyingHandle;
  100. PFILE_OBJECT UnderlyingFileObject;
  101. PDEVICE_OBJECT UnderlyingDeviceObject;
  102. ULONG NumberOfQueryDirectories;
  103. #if 0
  104. SMBMINI stuff
  105. ULONG Version;
  106. PMRX_PROXY_DEFERRED_OPEN_CONTEXT DeferredOpenContext;
  107. // the following fields are used for to save the results of a GetFileAttributes
  108. // and to validate whether the fields should be reused or not
  109. ULONG RxContextSerialNumber;
  110. LARGE_INTEGER TimeStampInTicks;
  111. PROXYPSE_FILEINFO_BUNDLE FileInfo;
  112. #endif //0
  113. //PETHREAD OriginalThread; //this is used to assert filelocks on oplockbreak
  114. //PEPROCESS OriginalProcess; //this is just used in asserts...joejoe should be DBG
  115. //localmini MINIRDR_OPLOCK_STATE OplockState;
  116. //localmini PMINIRDR_OPLOCK_COMPLETION_CONTEXT Mocc;
  117. } MRX_PROXY_SRV_OPEN, *PMRX_PROXY_SRV_OPEN;
  118. #define MRxProxyGetSrvOpenExtension(pSrvOpen) \
  119. (((pSrvOpen) == NULL) ? NULL : (PMRX_PROXY_SRV_OPEN)((pSrvOpen)->Context))
  120. #define PROXY_SRVOPEN_FLAG_NOT_REALLY_OPEN 0x00000001
  121. #define PROXY_SRVOPEN_FLAG_CANT_GETATTRIBS 0x00000004
  122. #define PROXY_SRVOPEN_FLAG_DEFERRED_OPEN 0x00000008
  123. #define PROXY_SRVOPEN_FLAG_WRITE_ONLY_HANDLE 0x00000008
  124. typedef USHORT PROXY_SEARCH_HANDLE;
  125. typedef struct _MRX_PROXY_DIRECTORY_RESUME_INFO {
  126. //REQ_FIND_NEXT2 FindNext2_Request;
  127. //now we have to include space for a resume name........
  128. WCHAR NameSpace[MAXIMUM_FILENAME_LENGTH+1]; //trailing null
  129. USHORT ParametersLength;
  130. } MRX_PROXY_DIRECTORY_RESUME_INFO, *PMRX_PROXY_DIRECTORY_RESUME_INFO;
  131. // A pointer to an instance of MRX_PROXY_FOBX is stored in the context field
  132. // of MRX_FOBXs handled by the PROXY mini rdr. Depending upon the file type
  133. // i.e., file or directory the appropriate context information is stored.
  134. typedef struct _MRX_PROXY_FOBX_ {
  135. union {
  136. struct {
  137. struct {
  138. PROXY_SEARCH_HANDLE SearchHandle;
  139. ULONG Version;
  140. union {
  141. //the close code will try to free this!
  142. //PMRX_PROXY_DIRECTORY_RESUME_INFO ResumeInfo;
  143. //PPROXY_RESUME_KEY CoreResumeKey;
  144. ULONG Dummy;
  145. };
  146. struct {
  147. //unaligned direntry sidebuffering params
  148. PBYTE UnalignedDirEntrySideBuffer; //close will try to free this too
  149. ULONG SerialNumber;
  150. BOOLEAN EndOfSearchReached;
  151. BOOLEAN IsUnicode;
  152. BOOLEAN IsNonNtT2Find;
  153. ULONG FilesReturned;
  154. ULONG EntryOffset;
  155. ULONG TotalDataBytesReturned;
  156. //ULONG ReturnedEntryOffset;
  157. };
  158. };
  159. NTSTATUS ErrorStatus;
  160. USHORT Flags;
  161. USHORT FileNameOffset;
  162. USHORT FileNameLengthOffset;
  163. BOOLEAN WildCardsFound;
  164. } Enumeration;
  165. };
  166. union {
  167. struct {
  168. //dont do this yet
  169. //ULONG MaximumReadBufferLength;
  170. //ULONG MaximumWriteBufferLength;
  171. USHORT Flags;
  172. } File;
  173. };
  174. } MRX_PROXY_FOBX, *PMRX_PROXY_FOBX;
  175. #define MRxProxyGetFileObjectExtension(pFobx) \
  176. (((pFobx) == NULL) ? NULL : (PMRX_PROXY_FOBX)((pFobx)->Context))
  177. #define PROXYFOBX_ENUMFLAG_SEARCH_NOT_THE_FIRST 0x0001
  178. #define PROXYFOBX_ENUMFLAG_SEARCH_HANDLE_OPEN 0x0002
  179. #define PROXYFOBX_ENUMFLAG_FAST_RESUME 0x0004
  180. #define PROXYFOBX_ENUMFLAG_CORE_SEARCH_IN_PROGRESS 0x0008
  181. #define PROXYFOBX_ENUMFLAG_LOUD_FINALIZE 0x0010
  182. typedef
  183. NTSTATUS
  184. (NTAPI *PMRXPROXY_CANCEL_ROUTINE) (
  185. PRX_CONTEXT pRxContext);
  186. // The RX_CONTEXT instance has four fields ( ULONG's ) provided by the wrapper
  187. // which can be used by the mini rdr to store its context. This is used by
  188. // the PROXY mini rdr to identify the parameters for request cancellation
  189. typedef struct _MRXPROXY_RX_CONTEXT {
  190. PMRXPROXY_CANCEL_ROUTINE pCancelRoutine;
  191. PVOID pCancelContext;
  192. union {
  193. struct {
  194. PMRXPROXY_ASYNCENGINE_CONTEXT AsyncEngineContext;
  195. PVOID SPARE;
  196. };
  197. struct {
  198. PVOID PostedOpContext;
  199. NTSTATUS PostedOpStatus;
  200. };
  201. IO_STATUS_BLOCK SyncCallDownIoStatus;
  202. };
  203. } MRXPROXY_RX_CONTEXT, *PMRXPROXY_RX_CONTEXT;
  204. #define MRxProxyGetMinirdrContext(pRxContext) \
  205. ((PMRXPROXY_RX_CONTEXT)(&(pRxContext)->MRxContext[0]))
  206. #define MRxProxyMakeSrvOpenKey(Tid,Fid) \
  207. (PVOID)(((ULONG)(Tid) << 16) | (ULONG)(Fid))
  208. //
  209. // forward declarations for all dispatch vector methods.
  210. //
  211. NTSTATUS
  212. MRxProxyStart (
  213. IN OUT struct _RX_CONTEXT * RxContext,
  214. IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject
  215. );
  216. NTSTATUS
  217. MRxProxyStop (
  218. IN OUT struct _RX_CONTEXT * RxContext,
  219. IN OUT PRDBSS_DEVICE_OBJECT RxDeviceObject
  220. );
  221. NTSTATUS
  222. MRxProxyMinirdrControl (
  223. IN OUT PRX_CONTEXT RxContext,
  224. IN OUT PVOID pContext,
  225. IN OUT PUCHAR SharedBuffer,
  226. IN ULONG InputBufferLength,
  227. IN ULONG OutputBufferLength,
  228. OUT PULONG CopyBackLength
  229. );
  230. NTSTATUS
  231. MRxProxyDevFcb (
  232. IN OUT PRX_CONTEXT RxContext
  233. );
  234. NTSTATUS
  235. MRxProxyDevFcbXXXControlFile (
  236. IN OUT PRX_CONTEXT RxContext
  237. );
  238. NTSTATUS
  239. MRxProxyCreate (
  240. IN OUT PRX_CONTEXT RxContext
  241. );
  242. NTSTATUS
  243. MRxProxyCollapseOpen (
  244. IN OUT PRX_CONTEXT RxContext
  245. );
  246. NTSTATUS
  247. MRxProxyShouldTryToCollapseThisOpen (
  248. IN PRX_CONTEXT RxContext
  249. );
  250. NTSTATUS
  251. MRxProxyRead (
  252. IN OUT PRX_CONTEXT RxContext
  253. );
  254. NTSTATUS
  255. MRxProxyWrite (
  256. IN OUT PRX_CONTEXT RxContext
  257. );
  258. NTSTATUS
  259. MRxProxyLocks(
  260. IN OUT PRX_CONTEXT RxContext
  261. );
  262. NTSTATUS
  263. MRxProxyFlush(
  264. IN OUT PRX_CONTEXT RxContext
  265. );
  266. NTSTATUS
  267. MRxProxyFsCtl(
  268. IN OUT PRX_CONTEXT RxContext
  269. );
  270. NTSTATUS
  271. MRxProxyIoCtl(
  272. IN OUT PRX_CONTEXT RxContext
  273. );
  274. NTSTATUS
  275. MRxProxyNotifyChangeDirectory(
  276. IN OUT PRX_CONTEXT RxContext
  277. );
  278. #if 0
  279. NTSTATUS
  280. MRxProxyUnlockRoutine (
  281. IN OUT PRX_CONTEXT RxContext,
  282. IN PFILE_LOCK_INFO LockInfo
  283. );
  284. #endif
  285. NTSTATUS
  286. MRxProxyComputeNewBufferingState(
  287. IN OUT PMRX_SRV_OPEN pSrvOpen,
  288. IN PVOID pMRxContext,
  289. OUT ULONG *pNewBufferingState);
  290. NTSTATUS
  291. MRxProxyFlush (
  292. IN OUT PRX_CONTEXT RxContext
  293. );
  294. NTSTATUS
  295. MRxProxyCloseWithDelete (
  296. IN OUT PRX_CONTEXT RxContext
  297. );
  298. NTSTATUS
  299. MRxProxyZeroExtend (
  300. IN OUT PRX_CONTEXT RxContext
  301. );
  302. NTSTATUS
  303. MRxProxyTruncate (
  304. IN OUT PRX_CONTEXT RxContext
  305. );
  306. NTSTATUS
  307. MRxProxyCleanupFobx (
  308. IN OUT PRX_CONTEXT RxContext
  309. );
  310. NTSTATUS
  311. MRxProxyCloseSrvOpen (
  312. IN OUT PRX_CONTEXT RxContext
  313. );
  314. NTSTATUS
  315. MRxProxyClosedSrvOpenTimeOut (
  316. IN OUT PRX_CONTEXT RxContext
  317. );
  318. NTSTATUS
  319. MRxProxyQueryDirectory (
  320. IN OUT PRX_CONTEXT RxContext
  321. );
  322. NTSTATUS
  323. MRxProxyQueryEaInformation (
  324. IN OUT PRX_CONTEXT RxContext
  325. );
  326. NTSTATUS
  327. MRxProxySetEaInformation (
  328. IN OUT struct _RX_CONTEXT * RxContext
  329. );
  330. NTSTATUS
  331. MRxProxyQuerySecurityInformation (
  332. IN OUT PRX_CONTEXT RxContext
  333. );
  334. NTSTATUS
  335. MRxProxySetSecurityInformation (
  336. IN OUT struct _RX_CONTEXT * RxContext
  337. );
  338. NTSTATUS
  339. MRxProxyQueryVolumeInformation (
  340. IN OUT PRX_CONTEXT RxContext
  341. );
  342. NTSTATUS
  343. MRxProxySetVolumeInformation (
  344. IN OUT PRX_CONTEXT RxContext
  345. );
  346. NTSTATUS
  347. MRxProxyLowIOSubmit (
  348. IN OUT PRX_CONTEXT RxContext
  349. );
  350. NTSTATUS
  351. MRxProxyCreateVNetRoot(
  352. IN OUT PMRX_V_NET_ROOT pVirtualNetRoot,
  353. IN OUT PMRX_CREATENETROOT_CONTEXT pContext
  354. );
  355. NTSTATUS
  356. MRxProxyFinalizeVNetRoot(
  357. IN OUT PMRX_V_NET_ROOT pVirtualNetRoot,
  358. IN PBOOLEAN ForceDisconnect);
  359. NTSTATUS
  360. MRxProxyFinalizeNetRoot(
  361. IN OUT PMRX_NET_ROOT pNetRoot,
  362. IN PBOOLEAN ForceDisconnect);
  363. NTSTATUS
  364. MRxProxyUpdateNetRootState(
  365. IN PMRX_NET_ROOT pNetRoot);
  366. VOID
  367. MRxProxyExtractNetRootName(
  368. IN PUNICODE_STRING FilePathName,
  369. IN PMRX_SRV_CALL SrvCall,
  370. OUT PUNICODE_STRING NetRootName,
  371. OUT PUNICODE_STRING RestOfName OPTIONAL
  372. );
  373. NTSTATUS
  374. MRxProxyCreateSrvCall(
  375. PMRX_SRV_CALL pSrvCall,
  376. PMRX_SRVCALL_CALLBACK_CONTEXT pCallbackContext);
  377. NTSTATUS
  378. MRxProxyFinalizeSrvCall(
  379. PMRX_SRV_CALL pSrvCall,
  380. BOOLEAN Force);
  381. NTSTATUS
  382. MRxProxySrvCallWinnerNotify(
  383. IN OUT PMRX_SRV_CALL pSrvCall,
  384. IN BOOLEAN ThisMinirdrIsTheWinner,
  385. IN OUT PVOID pSrvCallContext);
  386. NTSTATUS
  387. MRxProxyQueryFileInformation (
  388. IN OUT PRX_CONTEXT RxContext
  389. );
  390. NTSTATUS
  391. MRxProxyQueryNamedPipeInformation (
  392. IN OUT PRX_CONTEXT RxContext,
  393. IN FILE_INFORMATION_CLASS FileInformationClass,
  394. IN OUT PVOID Buffer,
  395. IN OUT PULONG pLengthRemaining
  396. );
  397. NTSTATUS
  398. MRxProxySetFileInformation (
  399. IN OUT PRX_CONTEXT RxContext
  400. );
  401. NTSTATUS
  402. MRxProxySetNamedPipeInformation (
  403. IN OUT PRX_CONTEXT RxContext,
  404. IN FILE_INFORMATION_CLASS FileInformationClass,
  405. IN PVOID pBuffer,
  406. IN ULONG BufferLength
  407. );
  408. NTSTATUS
  409. MRxProxySetFileInformationAtCleanup(
  410. IN OUT PRX_CONTEXT RxContext
  411. );
  412. NTSTATUS
  413. MRxProxyDeallocateForFcb (
  414. IN OUT PMRX_FCB pFcb
  415. );
  416. NTSTATUS
  417. MRxProxyDeallocateForFobx (
  418. IN OUT PMRX_FOBX pFobx
  419. );
  420. NTSTATUS
  421. MRxProxyIsLockRealizable (
  422. IN OUT PMRX_FCB pFcb,
  423. IN PLARGE_INTEGER ByteOffset,
  424. IN PLARGE_INTEGER Length,
  425. IN ULONG LowIoLockFlags
  426. );
  427. NTSTATUS
  428. MRxProxyForcedClose (
  429. IN OUT PMRX_SRV_OPEN SrvOpen
  430. );
  431. NTSTATUS
  432. MRxProxyExtendForCache (
  433. IN OUT struct _RX_CONTEXT * RxContext,
  434. IN OUT PLARGE_INTEGER pNewFileSize,
  435. OUT PLARGE_INTEGER pNewAllocationSize
  436. );
  437. NTSTATUS
  438. MRxProxyExtendForNonCache (
  439. IN OUT struct _RX_CONTEXT * RxContext,
  440. IN OUT PLARGE_INTEGER pNewFileSize,
  441. OUT PLARGE_INTEGER pNewAllocationSize
  442. );
  443. NTSTATUS
  444. MRxProxyCompleteBufferingStateChangeRequest (
  445. IN OUT PRX_CONTEXT RxContext,
  446. IN OUT PMRX_SRV_OPEN SrvOpen,
  447. IN PVOID pContext
  448. );
  449. #if 0
  450. NTSTATUS
  451. MRxProxyTransportUpdateHandler(
  452. PRXCE_TRANSPORT_NOTIFICATION pTransportNotification
  453. );
  454. #endif
  455. //other misc prototypes
  456. //CODE.IMPROVEMENT.NTIFS this should be in ntifs.h
  457. NTSYSAPI
  458. NTSTATUS
  459. NTAPI
  460. ZwFsControlFile(
  461. IN HANDLE FileHandle,
  462. IN HANDLE Event OPTIONAL,
  463. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  464. IN PVOID ApcContext OPTIONAL,
  465. OUT PIO_STATUS_BLOCK IoStatusBlock,
  466. IN ULONG FsControlCode,
  467. IN PVOID InputBuffer OPTIONAL,
  468. IN ULONG InputBufferLength,
  469. OUT PVOID OutputBuffer OPTIONAL,
  470. IN ULONG OutputBufferLength
  471. );
  472. NTSTATUS
  473. MRxProxySyncXxxInformation(
  474. IN OUT PRX_CONTEXT RxContext,
  475. IN UCHAR MajorFunction,
  476. IN PFILE_OBJECT FileObject,
  477. IN ULONG InformationClass,
  478. IN ULONG Length,
  479. OUT PVOID Information,
  480. OUT PULONG ReturnedLength OPTIONAL
  481. );
  482. #endif // _PROXYMRX_H_
  483.