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.

1501 lines
34 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Struct.h
  5. Abstract:
  6. This module defines the data structures that make up the major internal
  7. part of the NetWare file system.
  8. Author:
  9. Colin Watson [ColinW] 18-Dec-1992
  10. Revision History:
  11. --*/
  12. #ifndef _NWSTRUC_
  13. #define _NWSTRUC_
  14. #define byte UCHAR
  15. #define word USHORT
  16. #define dword ULONG
  17. typedef enum _PACKET_TYPE {
  18. SAP_BROADCAST,
  19. NCP_CONNECT,
  20. NCP_FUNCTION,
  21. NCP_SUBFUNCTION,
  22. NCP_DISCONNECT,
  23. NCP_BURST,
  24. NCP_ECHO
  25. } PACKET_TYPE;
  26. typedef struct _NW_TDI_STRUCT {
  27. HANDLE Handle;
  28. PDEVICE_OBJECT pDeviceObject;
  29. PFILE_OBJECT pFileObject;
  30. USHORT Socket;
  31. } NW_TDI_STRUCT, *PNW_TDI_STRUCT;
  32. typedef
  33. NTSTATUS
  34. (*PEX) (
  35. IN struct _IRP_CONTEXT* pIrpC,
  36. IN ULONG BytesAvailable,
  37. IN PUCHAR RspData
  38. );
  39. typedef
  40. VOID
  41. (*PRUN_ROUTINE) (
  42. IN struct _IRP_CONTEXT *IrpContext
  43. );
  44. typedef
  45. NTSTATUS
  46. (*PPOST_PROCESSOR) (
  47. IN struct _IRP_CONTEXT *IrpContext
  48. );
  49. typedef
  50. NTSTATUS
  51. (*PRECEIVE_ROUTINE) (
  52. IN struct _IRP_CONTEXT *IrpContext,
  53. IN ULONG BytesAvailable,
  54. IN PULONG BytesAccepted,
  55. IN PUCHAR Response,
  56. OUT PMDL *pReceiveMdl
  57. );
  58. typedef struct _NW_PID_TABLE_ENTRY {
  59. ULONG_PTR Pid32;
  60. ULONG_PTR ReferenceCount;
  61. ULONG_PTR Flags;
  62. } NW_PID_TABLE_ENTRY, *PNW_PID_TABLE_ENTRY;
  63. typedef struct _NW_PID_TABLE {
  64. //
  65. // Type and size of this record (must be NW_NTC_PID)
  66. //
  67. NODE_TYPE_CODE NodeTypeCode;
  68. NODE_BYTE_SIZE NodeByteSize;
  69. int ValidEntries;
  70. NW_PID_TABLE_ENTRY PidTable[0];
  71. } NW_PID_TABLE, *PNW_PID_TABLE;
  72. //
  73. // The Scb (Server control Block) record corresponds to every server
  74. // connected to by the file system.
  75. // They are ordered in ScbQueue.
  76. // This structure is allocated from paged pool
  77. //
  78. typedef struct _SCB {
  79. //
  80. // The type and size of this record (must be NW_NTC_SCB)
  81. //
  82. NODE_TYPE_CODE NodeTypeCode;
  83. NODE_BYTE_SIZE NodeByteSize;
  84. //
  85. // Pointer to the non-paged part of the SCB.
  86. //
  87. struct _NONPAGED_SCB *pNpScb;
  88. //
  89. // Prefix table entry.
  90. //
  91. UNICODE_PREFIX_TABLE_ENTRY PrefixEntry;
  92. //
  93. // Server version number
  94. //
  95. UCHAR MajorVersion;
  96. UCHAR MinorVersion;
  97. //
  98. // List of VCBs for this server, and a count of the VCB on the list.
  99. // These fields are protected by the RCB resource.
  100. //
  101. LIST_ENTRY ScbSpecificVcbQueue;
  102. ULONG VcbCount;
  103. //
  104. // A list of ICBs for the SCB.
  105. //
  106. LIST_ENTRY IcbList;
  107. ULONG IcbCount;
  108. ULONG OpenNdsStreams;
  109. //
  110. // User credentials that this Scb relates to.
  111. //
  112. LARGE_INTEGER UserUid;
  113. //
  114. // A count of the open files for all the VCBs for this server.
  115. // Plus the number of VCB that are explicitly connected.
  116. //
  117. ULONG OpenFileCount;
  118. //
  119. // The name of the server for this SCB. Note the pNpScb->ServerName and
  120. // UnicodeUid point at subparts of UidServerName->Buffer which must be
  121. // non-paged pool.
  122. //
  123. UNICODE_STRING UidServerName; // L"3e7\mars312
  124. UNICODE_STRING UnicodeUid; // L"3e7"
  125. //
  126. // The name of nds tree that this server belongs to, if any.
  127. //
  128. UNICODE_STRING NdsTreeName; // L"MARS"
  129. //
  130. // The username / password to use for auto-reconnect.
  131. //
  132. UNICODE_STRING UserName;
  133. UNICODE_STRING Password;
  134. //
  135. // Is this the logon (preferred) server?
  136. //
  137. BOOLEAN PreferredServer;
  138. //
  139. // Is this server waiting for us to read a message?
  140. //
  141. BOOLEAN MessageWaiting;
  142. //
  143. // The number of tree connects to the root of the SCB.
  144. //
  145. ULONG AttachCount;
  146. RTL_BITMAP DriveMapHeader;
  147. ULONG DriveMap[ (MAX_DRIVES + 1) / 32 ];
  148. //
  149. // NDS Object Cache.
  150. //
  151. PVOID ObjectCacheBuffer;
  152. LIST_ENTRY ObjectCacheList;
  153. KSEMAPHORE ObjectCacheLock;
  154. } SCB, *PSCB;
  155. //
  156. // Values for pNpScb->State
  157. //
  158. //
  159. // The SCB is on it's way up
  160. //
  161. #define SCB_STATE_ATTACHING (0x0001)
  162. //
  163. // The SCB is connected and logged in.
  164. //
  165. #define SCB_STATE_IN_USE (0x0003)
  166. //
  167. // The SCB is being disconnected or shutdown.
  168. //
  169. #define SCB_STATE_DISCONNECTING (0x0004)
  170. #define SCB_STATE_FLAG_SHUTDOWN (0x0005)
  171. //
  172. // The SCB is waiting to be connected.
  173. //
  174. #define SCB_STATE_RECONNECT_REQUIRED (0x0006)
  175. //
  176. // The SCB is connected but has not been logged into
  177. //
  178. #define SCB_STATE_LOGIN_REQUIRED (0x0007)
  179. //
  180. // The SCB is a fake SCB used to find a dir
  181. // server for a tree.
  182. //
  183. #define SCB_STATE_TREE_SCB (0x0008)
  184. //
  185. // The NONPAGED_SCB (Server control Block) contains all the data required
  186. // when communicating with a server when a spinlock is held or at raised
  187. // IRQL such as when being called at indication time by the transport.
  188. // This structure must be allocated from non-paged pool.
  189. //
  190. typedef struct _NONPAGED_SCB {
  191. //
  192. // The type and size of this record (must be NW_NTC_SCBNP
  193. //
  194. NODE_TYPE_CODE NodeTypeCode;
  195. NODE_BYTE_SIZE NodeByteSize;
  196. //
  197. // Reference count and state information.
  198. //
  199. ULONG Reference;
  200. ULONG State;
  201. //
  202. // The time this SCB was last used.
  203. //
  204. LARGE_INTEGER LastUsedTime;
  205. //
  206. // Sending is true between the IoCallDriver to send the datagram and
  207. // the completion routine for the send.
  208. //
  209. BOOLEAN Sending;
  210. //
  211. // Receiving is true when the transport has indicated to the driver
  212. // that there is data to receive and there is too much data to handle
  213. // at indication time or we have received indicated data before
  214. // the the send IRP completes.
  215. //
  216. BOOLEAN Receiving;
  217. //
  218. // Received is true when the rx data is valid. If a receive Irp is
  219. // put down when Receiving is set to true then Received is set to
  220. // true when the receive Irp completes.
  221. //
  222. BOOLEAN Received;
  223. //
  224. // OkToReceive is true iff pEx should be called
  225. //
  226. BOOLEAN OkToReceive;
  227. //
  228. // Older servers insist that reads and writes do not cross 4k offsets
  229. // in the file.
  230. //
  231. BOOLEAN PageAlign;
  232. //
  233. // The links on the global list of SCBs.
  234. //
  235. LIST_ENTRY ScbLinks;
  236. //
  237. // Pointer to the paged component of the Scb
  238. //
  239. PSCB pScb;
  240. //
  241. // The list of request in progress for this SCB.
  242. //
  243. LIST_ENTRY Requests;
  244. //
  245. // The name of the server for this SCB.
  246. //
  247. UNICODE_STRING ServerName;
  248. //
  249. // Transport related information.
  250. //
  251. TA_IPX_ADDRESS LocalAddress;
  252. TA_IPX_ADDRESS RemoteAddress;
  253. TA_IPX_ADDRESS EchoAddress;
  254. IPXaddress ServerAddress;
  255. ULONG EchoCounter;
  256. //
  257. // Server is an autoassigned a socket in the range 0x4000 to 0x7fff.
  258. // The transport assigns the socket number avoiding in-use sockets.
  259. // Watchdog is socket+1 and Send is socket+2.
  260. //
  261. NW_TDI_STRUCT Server; // Used by us to contact server
  262. NW_TDI_STRUCT WatchDog; // Used by the server to check on us
  263. NW_TDI_STRUCT Send; // Used for send messages
  264. NW_TDI_STRUCT Echo; // Used to determine max packet size
  265. NW_TDI_STRUCT Burst; // Used for burst mode read and write
  266. USHORT TickCount;
  267. USHORT LipTickAdjustment;
  268. SHORT RetryCount; // Counts down to zero for current request
  269. SHORT TimeOut; // ticks to retransmission of current request
  270. UCHAR SequenceNo;
  271. UCHAR ConnectionNo;
  272. UCHAR ConnectionNoHigh;
  273. UCHAR ConnectionStatus;
  274. USHORT MaxTimeOut;
  275. USHORT BufferSize;
  276. UCHAR TaskNo;
  277. //
  278. // Burst mode parameters
  279. //
  280. ULONG LipSequenceNumber;
  281. ULONG SourceConnectionId; // High-low order
  282. ULONG DestinationConnectionId; // High-low order
  283. ULONG MaxPacketSize;
  284. ULONG MaxSendSize;
  285. ULONG MaxReceiveSize;
  286. BOOLEAN SendBurstModeEnabled;
  287. BOOLEAN ReceiveBurstModeEnabled;
  288. BOOLEAN BurstRenegotiateReqd;
  289. ULONG BurstSequenceNo; // Counts # of burst packets sent
  290. USHORT BurstRequestNo; // Counts # of burst requests sent
  291. LONG SendBurstSuccessCount; // The number of consecutive successful bursts
  292. LONG ReceiveBurstSuccessCount; // The number of consecutive successful bursts
  293. //
  294. // Send delays and timeouts
  295. //
  296. SHORT SendTimeout; // Exchange timeout in ticks (1/18th sec)
  297. ULONG TotalWaitTime; // Total time, in ticks, waiting for current response
  298. LONG NwLoopTime; // Time for a small packet to reach the server and return
  299. LONG NwSingleBurstPacketTime; // Time for a burst packet to go to the server
  300. LONG NwMaxSendDelay; // Burst send delay time, in 100us units
  301. LONG NwSendDelay; // Burst send delay time, in 100us units
  302. LONG NwGoodSendDelay; // Burst send delay time, in 100us units
  303. LONG NwBadSendDelay; // Burst send delay time, in 100us units
  304. LONG BurstDataWritten; // Bytes written, used for dummy NCP in write.c
  305. LONG NwMaxReceiveDelay; // Burst delay time, in 100us units
  306. LONG NwReceiveDelay; // Burst delay time, in 100us units
  307. LONG NwGoodReceiveDelay; // Burst delay time, in 100us units
  308. LONG NwBadReceiveDelay; // Burst delay time, in 100us units
  309. LONG CurrentBurstDelay; // All requests in the current burst need the same value
  310. LARGE_INTEGER NtSendDelay; // Burst send delay time, in 100ns units
  311. //
  312. // A spin lock used to protect various fields for this SCB.
  313. // NpScbInterLock is used to protect pNpScb->Reference.
  314. //
  315. KSPIN_LOCK NpScbSpinLock;
  316. KSPIN_LOCK NpScbInterLock;
  317. //
  318. // This field records the last time a time-out event was written to
  319. // the event log for this server.
  320. //
  321. LARGE_INTEGER NwNextEventTime;
  322. //
  323. // LIP estimation of speed in 100bps units.
  324. //
  325. ULONG LipDataSpeed;
  326. // The Pid mapping table - actually the NCP task ID -
  327. // is on a per-SCB basis.
  328. PNW_PID_TABLE PidTable;
  329. ERESOURCE RealPidResource;
  330. //
  331. // Server version number - dup from NpScb because accessed in
  332. // WatchDogDatagramHandler
  333. //
  334. UCHAR MajorVersion;
  335. #ifdef MSWDBG
  336. BOOL RequestQueued;
  337. BOOL RequestDequeued;
  338. ULONG SequenceNumber;
  339. #endif
  340. } NONPAGED_SCB, *PNONPAGED_SCB;
  341. //
  342. // Delete this VCB immediately if the reference count reaches zero.
  343. //
  344. #define VCB_FLAG_DELETE_IMMEDIATELY 0x00000001
  345. #define VCB_FLAG_EXPLICIT_CONNECTION 0x00000002
  346. #define VCB_FLAG_PRINT_QUEUE 0x00000004
  347. #define VCB_FLAG_LONG_NAME 0x00000008
  348. //
  349. // The VCB corresponds to a netware volume.
  350. //
  351. typedef struct _VCB {
  352. //
  353. // Type and size of this record (must be NW_NTC_VCB)
  354. //
  355. NODE_TYPE_CODE NodeTypeCode;
  356. NODE_BYTE_SIZE NodeByteSize;
  357. ULONG Reference;
  358. LARGE_INTEGER LastUsedTime;
  359. //
  360. // Connection the the global VCB list.
  361. //
  362. LIST_ENTRY GlobalVcbListEntry;
  363. ULONG_PTR SequenceNumber;
  364. //
  365. // The requested volume name in the following form:
  366. //
  367. // \{Server | Tree}\{Share | Volume.Object}\Path
  368. //
  369. UNICODE_STRING Name;
  370. //
  371. // If the above name refers to an nds volume, this
  372. // contains the resolved server and share name in
  373. // the following form:
  374. //
  375. // \Server\Share\Path
  376. //
  377. UNICODE_STRING ConnectName;
  378. //
  379. // The share name in Netware compatible form.
  380. //
  381. UNICODE_STRING ShareName;
  382. //
  383. // tommye - MS bug 71690 - store the VCB path
  384. //
  385. UNICODE_STRING Path;
  386. //
  387. // The prefix table entry for this volume.
  388. //
  389. UNICODE_PREFIX_TABLE_ENTRY PrefixEntry; // 7 DWORDs
  390. union {
  391. //
  392. // Disk VCB specific data.
  393. //
  394. struct {
  395. //
  396. // The volume number
  397. //
  398. CHAR VolumeNumber;
  399. //
  400. // The name space number for long name support. -1 if long name
  401. // space is not supported.
  402. //
  403. CHAR LongNameSpace;
  404. //
  405. // The remote handle
  406. //
  407. CHAR Handle;
  408. //
  409. // The Drive Letter we told the server we were mapping. Portable
  410. // NetWare needs this to be different for each permanent handle
  411. // we create.
  412. //
  413. CHAR DriveNumber;
  414. } Disk;
  415. //
  416. // Print VCB specific data.
  417. //
  418. struct {
  419. ULONG QueueId;
  420. } Print;
  421. } Specific;
  422. //
  423. // The drive letter for this VCB. (0 if this is UNC).
  424. //
  425. WCHAR DriveLetter;
  426. //
  427. // The SCB for this volume, and a link to the VCBs for this SCB
  428. //
  429. PSCB Scb;
  430. LIST_ENTRY VcbListEntry;
  431. //
  432. // List of FCBs and DCBs for this server. These fields are protected
  433. // by the RCB resource.
  434. //
  435. LIST_ENTRY FcbList;
  436. //
  437. // The count of open ICBs for this VCB.
  438. //
  439. ULONG OpenFileCount;
  440. //
  441. // VCB flags
  442. //
  443. ULONG Flags;
  444. } VCB, *PVCB;
  445. //
  446. // Use default date / time when netware returns no info, or bogus info.
  447. //
  448. #define DEFAULT_DATE ( 1 + (1 << 5) + (0 << 9) ) /* Jan 1, 1980 */
  449. #define DEFAULT_TIME ( 0 + (0 << 5) + (0 << 11) ) /* 12:00am */
  450. //
  451. // The Fcb/Dcb record corresponds to every open file and directory.
  452. //
  453. // The structure is really divided into two parts. FCB can be allocated
  454. // from paged pool which the NONPAGED_FCB must be allocated from non-paged
  455. // pool.
  456. //
  457. typedef struct _FCB {
  458. //
  459. // Type and size of this record (must be NW_NTC_FCB or NW_NTC_DCB)
  460. //
  461. NODE_TYPE_CODE NodeTypeCode;
  462. NODE_BYTE_SIZE NodeByteSize;
  463. //
  464. // The VCB for this file.
  465. //
  466. PVCB Vcb;
  467. //
  468. // The following field is the fully qualified file name for this FCB/DCB.
  469. // The file name relative to the root of the volume.
  470. //
  471. UNICODE_STRING FullFileName;
  472. UNICODE_STRING RelativeFileName;
  473. //
  474. // Netware file information.
  475. //
  476. USHORT LastModifiedDate;
  477. USHORT LastModifiedTime;
  478. USHORT CreationDate;
  479. USHORT CreationTime;
  480. USHORT LastAccessDate;
  481. //
  482. // The state of the FCB.
  483. //
  484. ULONG State;
  485. ULONG Flags;
  486. //
  487. // A record of accesss currently granted.
  488. //
  489. SHARE_ACCESS ShareAccess;
  490. //
  491. // The prefix table entry for this file.
  492. //
  493. UNICODE_PREFIX_TABLE_ENTRY PrefixEntry;
  494. //
  495. // The SCB for this file, and a link to the FCB for this SCB
  496. //
  497. PSCB Scb;
  498. LIST_ENTRY FcbListEntry;
  499. //
  500. // The list of ICB's for this FCB or DCB.
  501. //
  502. LIST_ENTRY IcbList;
  503. ULONG IcbCount;
  504. //
  505. // A pointer to the specific non-paged data for the Fcb.
  506. //
  507. struct _NONPAGED_FCB *NonPagedFcb;
  508. ULONG LastReadOffset;
  509. ULONG LastReadSize;
  510. } FCB, DCB;
  511. typedef FCB *PFCB;
  512. typedef DCB *PDCB;
  513. typedef enum {
  514. ReadAhead,
  515. WriteBehind
  516. } CACHE_TYPE;
  517. typedef struct _NONPAGED_FCB {
  518. //
  519. // The following field is used for fast I/O
  520. //
  521. // The following comments refer to the use of the AllocationSize field
  522. // of the FsRtl-defined header to the nonpaged Fcb.
  523. //
  524. // For a directory when we create a Dcb we will not immediately
  525. // initialize the cache map, instead we will postpone it until our first
  526. // call to NwReadDirectoryFile or NwPrepareWriteDirectoryFile.
  527. // At that time we will search the Nw to find out the current allocation
  528. // size (by calling NwLookupFileAllocationSize) and then initialize the
  529. // cache map to this allocation size.
  530. //
  531. // For a file when we create an Fcb we will not immediately initialize
  532. // the cache map, instead we will postpone it until we need it and
  533. // then we determine the allocation size from either searching the
  534. // fat to determine the real file allocation, or from the allocation
  535. // that we've just allocated if we're creating a file.
  536. //
  537. // A value of -1 indicates that we do not know what the current allocation
  538. // size really is, and need to examine the fat to find it. A value
  539. // of than -1 is the real file/directory allocation size.
  540. //
  541. // Whenever we need to extend the allocation size we call
  542. // NwAddFileAllocation which (if we're really extending the allocation)
  543. // will modify the Nw, Rcb, and update this field. The caller
  544. // of NwAddFileAllocation is then responsible for altering the Cache
  545. // map size.
  546. //
  547. FSRTL_COMMON_FCB_HEADER Header;
  548. PFCB Fcb;
  549. //
  550. // The following field contains a record of special pointers used by
  551. // MM and Cache to manipluate section objects. Note that the values
  552. // are set outside of the file system. However the file system on an
  553. // open/create will set the file object's SectionObject field to point
  554. // to this field
  555. //
  556. SECTION_OBJECT_POINTERS SegmentObject;
  557. //
  558. // The following field is used to maintain a list of locks owned for
  559. // this file. It points to an ordered list of file locks.
  560. //
  561. LIST_ENTRY FileLockList;
  562. //
  563. // The following field is used to maintain a list of pending locks
  564. // for this file. All locks in this list conflict with existing
  565. // locks on the FileLockList.
  566. //
  567. LIST_ENTRY PendingLockList;
  568. //
  569. // A resource to synchronize access to the FCB and it's ICBs
  570. //
  571. ERESOURCE Resource;
  572. //
  573. // Netware file information.
  574. //
  575. UCHAR Attributes;
  576. //
  577. // File data cache information
  578. //
  579. UCHAR CacheType; // ReadAhead or WriteBehind
  580. PUCHAR CacheBuffer; // The cache buffer
  581. PMDL CacheMdl; // The full MDL for the cache buffer
  582. ULONG CacheSize; // The size of the cache buffer
  583. ULONG CacheFileOffset; // The file offset of this data
  584. ULONG CacheDataSize; // The amount of file data in the cache
  585. } NONPAGED_FCB, NONPAGED_DCB;
  586. typedef NONPAGED_FCB *PNONPAGED_FCB;
  587. typedef NONPAGED_DCB *PNONPAGED_DCB;
  588. #define FCB_STATE_OPEN_PENDING 0x00000001
  589. #define FCB_STATE_OPENED 0x00000002
  590. #define FCB_STATE_CLOSE_PENDING 0x00000003
  591. #define FCB_FLAGS_DELETE_ON_CLOSE 0x00000001
  592. #define FCB_FLAGS_TRUNCATE_ON_CLOSE 0x00000002
  593. #define FCB_FLAGS_PAGING_FILE 0x00000004
  594. #define FCB_FLAGS_PREFIX_INSERTED 0x00000008
  595. #define FCB_FLAGS_FORCE_MISS_IN_PROGRESS 0x00000010
  596. #define FCB_FLAGS_ATTRIBUTES_ARE_VALID 0x00000020
  597. #define FCB_FLAGS_LONG_NAME 0x00000040
  598. #define FCB_FLAGS_LAZY_SET_SHAREABLE 0x00000100
  599. //
  600. // This structure is used for directory searches.
  601. //
  602. typedef struct _NW_DIRECTORY_INFO {
  603. WCHAR FileNameBuffer[NW_MAX_FILENAME_LENGTH];
  604. UNICODE_STRING FileName;
  605. UCHAR Attributes;
  606. USHORT CreationDate;
  607. USHORT CreationTime;
  608. USHORT LastAccessDate;
  609. USHORT LastUpdateDate;
  610. USHORT LastUpdateTime;
  611. ULONG FileSize;
  612. ULONG DosDirectoryEntry;
  613. ULONG FileIndexLow;
  614. ULONG FileIndexHigh;
  615. NTSTATUS Status;
  616. LIST_ENTRY ListEntry;
  617. } NW_DIRECTORY_INFO, *PNW_DIRECTORY_INFO;
  618. //
  619. // The Icb record is allocated for every file object
  620. //
  621. typedef struct _ICB {
  622. //
  623. // Type and size of this record (must be NW_NTC_ICB or NW_NTC_ICB_SCB)
  624. //
  625. NODE_TYPE_CODE NodeTypeCode;
  626. NODE_BYTE_SIZE NodeByteSize;
  627. //
  628. // A link to the list of ICB's for our FCB, and our FCB.
  629. //
  630. LIST_ENTRY ListEntry;
  631. union {
  632. PFCB Fcb;
  633. PSCB Scb;
  634. } SuperType;
  635. PNONPAGED_FCB NpFcb; // Valid only for node type NW_ITC_ICB
  636. //
  637. // The state of this ICB.
  638. //
  639. ULONG State;
  640. //
  641. // The remote handle;
  642. //
  643. UCHAR Handle[6]; // Keep WORD aligned.
  644. BOOLEAN HasRemoteHandle; // TRUE if we have a remote handle for this ICB
  645. //
  646. // The file object for this ICB.
  647. //
  648. PFILE_OBJECT FileObject;
  649. //
  650. // The query template is used to filter directory query requests.
  651. // It originally is set to null and on the first call the NtQueryDirectory
  652. // it is set the the input filename or "*" if the name is supplied.
  653. // All subsquent queries then use this template
  654. //
  655. OEM_STRING NwQueryTemplate;
  656. UNICODE_STRING UQueryTemplate;
  657. ULONG IndexOfLastIcbReturned;
  658. UCHAR Pid;
  659. BOOLEAN DotReturned;
  660. BOOLEAN DotDotReturned;
  661. BOOLEAN ReturnedSomething;
  662. BOOLEAN ShortNameSearch;
  663. //
  664. // More search parameters.
  665. //
  666. USHORT SearchHandle;
  667. UCHAR SearchVolume;
  668. UCHAR SearchAttributes;
  669. //
  670. // Extra search parameters for long name support
  671. //
  672. ULONG SearchIndexLow;
  673. ULONG SearchIndexHigh;
  674. //
  675. // SVR to avoid rescanning from end of dir all
  676. // the way through the directory again.
  677. //
  678. ULONG LastSearchIndexLow;
  679. // SVR end
  680. //
  681. // Print parametres;
  682. //
  683. BOOLEAN IsPrintJob;
  684. USHORT JobId;
  685. BOOLEAN ActuallyPrinted;
  686. //
  687. // This flag prevents cleanup from updating the access time.
  688. //
  689. BOOLEAN UserSetLastAccessTime;
  690. //
  691. // The current file position.
  692. //
  693. ULONG FilePosition;
  694. //
  695. // The size of the file if its ICB_SCB
  696. //
  697. ULONG FileSize;
  698. //
  699. // The Next dirent offset is used by directory enumeration. It is
  700. // the offset (within the directory file) of the next dirent to examine.
  701. //
  702. //VBO OffsetToStartSearchFrom;
  703. //
  704. // If this ICB was created with OPEN_RENAME_TARGET then the following
  705. // parameters are used
  706. //
  707. BOOLEAN IsAFile;
  708. BOOLEAN Exists;
  709. BOOLEAN FailedFindNotify;
  710. //
  711. // Is this a tree handle? We need to know for delete.
  712. //
  713. BOOLEAN IsTreeHandle;
  714. BOOLEAN IsExCredentialHandle;
  715. PVOID pContext;
  716. //
  717. // A linked list of cached directory entries.
  718. //
  719. LIST_ENTRY DirCache;
  720. //
  721. // A hint into the dir cache.
  722. //
  723. PLIST_ENTRY CacheHint;
  724. //
  725. // A pointer to the top of the buffer.
  726. //
  727. PVOID DirCacheBuffer;
  728. } ICB, *PICB;
  729. #define ICB_STATE_OPEN_PENDING 0x00000001
  730. #define ICB_STATE_OPENED 0x00000002
  731. #define ICB_STATE_CLEANED_UP 0x00000003
  732. #define ICB_STATE_CLOSE_PENDING 0x00000004
  733. #define INVALID_PID 0
  734. //
  735. // A structure used to maintain a list of file locks.
  736. //
  737. typedef struct _NW_FILE_LOCK {
  738. //
  739. // Type and size of this record (must be NW_NTC_FILE_LOCK )
  740. //
  741. NODE_TYPE_CODE NodeTypeCode;
  742. NODE_BYTE_SIZE NodeByteSize;
  743. //
  744. // A link to the list of locks for this FCB.
  745. //
  746. LIST_ENTRY ListEntry;
  747. //
  748. // The ICB this lock belongs to.
  749. //
  750. PICB Icb;
  751. //
  752. // The IRP Context for this lock request.
  753. //
  754. struct _IRP_CONTEXT *IrpContext;
  755. //
  756. // The originating process.
  757. //
  758. void *pOwnerProc;
  759. //
  760. // The lock offset, length, and key.
  761. //
  762. LONG StartFileOffset;
  763. ULONG Length;
  764. LONG EndFileOffset;
  765. ULONG Key;
  766. USHORT Flags;
  767. } NW_FILE_LOCK, *PNW_FILE_LOCK;
  768. //
  769. // The Rcb record controls access to the redirector device
  770. //
  771. typedef struct _RCB {
  772. //
  773. // Type and size of this record (must be NW_NTC_RCB)
  774. //
  775. NODE_TYPE_CODE NodeTypeCode;
  776. NODE_BYTE_SIZE NodeByteSize;
  777. //
  778. // The run state of the redirector
  779. //
  780. ULONG State;
  781. //
  782. // The count of open handles to the RCB.
  783. // Access is protected by the RCB Resource.
  784. //
  785. ULONG OpenCount;
  786. //
  787. // A resource to synchronize access to the RCB.
  788. //
  789. ERESOURCE Resource;
  790. //
  791. // A record of accesss currently granted to the RCB.
  792. //
  793. SHARE_ACCESS ShareAccess;
  794. //
  795. // A prefix table of all connected servers.
  796. //
  797. UNICODE_PREFIX_TABLE ServerNameTable;
  798. //
  799. // A prefix table of all open volumes.
  800. //
  801. UNICODE_PREFIX_TABLE VolumeNameTable;
  802. //
  803. // A prefix table of all open files
  804. //
  805. UNICODE_PREFIX_TABLE FileNameTable;
  806. } RCB, *PRCB;
  807. #define RCB_STATE_STOPPED 0x00000001
  808. #define RCB_STATE_STARTING 0x00000002
  809. #define RCB_STATE_NEED_BIND 0x00000003
  810. #define RCB_STATE_RUNNING 0x00000004
  811. #define RCB_STATE_SHUTDOWN 0x00000005
  812. //
  813. // IRP_CONTEXT Flags bits.
  814. //
  815. #define IRP_FLAG_IN_FSD 0x00000001 // This IRP is being process in the FSD
  816. #define IRP_FLAG_ON_SCB_QUEUE 0x00000002 // This IRP is queued to an SCB
  817. #define IRP_FLAG_SEQUENCE_NO_REQUIRED 0x00000004 // This packet requires a sequence #
  818. #define IRP_FLAG_SIGNAL_EVENT 0x00000010
  819. #define IRP_FLAG_RETRY_SEND 0x00000020 // We are resending a timed out request
  820. #define IRP_FLAG_RECONNECTABLE 0x00000040 // We are allowed to try a reconnect if this request fails due to a bad connection
  821. #define IRP_FLAG_RECONNECT_ATTEMPT 0x00000080 // This IRP is being used to attempt a reconnect
  822. #define IRP_FLAG_BURST_REQUEST 0x00000100 // This is a burst request packet
  823. #define IRP_FLAG_BURST_PACKET 0x00000200 // This is any burst packet
  824. #define IRP_FLAG_NOT_OK_TO_RECEIVE 0x00000400 // Don't set ok to receive when sending this packet
  825. #define IRP_FLAG_REROUTE_ATTEMPTED 0x00000800 // A re-route has been attempted for this packet
  826. #define IRP_FLAG_BURST_WRITE 0x00001000 // We are processsing a burst write request
  827. #define IRP_FLAG_SEND_ALWAYS 0x00002000 // Okay to send this packet, even if RCB State is shutdown
  828. #define IRP_FLAG_FREE_RECEIVE_MDL 0x00004000 // Free the receive irp's MDL when the irp completes
  829. #define IRP_FLAG_NOT_SYSTEM_PACKET 0x00008000 // Used in burst writes to alternate system packet and normal
  830. #define IRP_FLAG_NOCONNECT 0x00010000 // Used to inspect server list
  831. #define IRP_FLAG_HAS_CREDENTIAL_LOCK 0X00020000 // Used to prevent deadlocking
  832. #define IRP_FLAG_REROUTE_IN_PROGRESS 0x00040000 // A re-route is currently in progress for this packet.
  833. typedef struct _IRP_CONTEXT {
  834. //
  835. // Type and size of this record (must be NW_NTC_IRP_CONTEXT).
  836. //
  837. NODE_TYPE_CODE NodeTypeCode;
  838. NODE_BYTE_SIZE NodeByteSize;
  839. //
  840. // Information about this IRP
  841. //
  842. ULONG Flags;
  843. //
  844. // This structure is used for posting to the Ex worker threads.
  845. //
  846. WORK_QUEUE_ITEM WorkQueueItem; // 4*sizeof(ULONG)
  847. // Workspace for exchange()
  848. PACKET_TYPE PacketType;
  849. //
  850. // Server Control Block to which this request applies.
  851. //
  852. PNONPAGED_SCB pNpScb;
  853. PSCB pScb;
  854. //
  855. // The socket structure to use for this request. If NULL, use
  856. // pNpScb->Server socket.
  857. //
  858. PNW_TDI_STRUCT pTdiStruct;
  859. //
  860. // List of requests to a particular server. Listed on Scb->Requests.
  861. //
  862. LIST_ENTRY NextRequest;
  863. //
  864. // Used for processing synchronous IRPs.
  865. //
  866. KEVENT Event; // 4 words
  867. //
  868. // A pointer to the originating Irp and its original contents when
  869. // the I/O system submitted it to the rdr.
  870. //
  871. PIRP pOriginalIrp;
  872. PVOID pOriginalSystemBuffer;
  873. PVOID pOriginalUserBuffer;
  874. PMDL pOriginalMdlAddress;
  875. //
  876. // Information used if we need to post an IRP to process the receive
  877. //
  878. PIRP ReceiveIrp;
  879. //
  880. // Pointer to the Mdl used to transmit/receive the Ncp header.
  881. //
  882. PMDL TxMdl;
  883. PMDL RxMdl;
  884. //
  885. // Routine to run when this IRP context reaches the front of the
  886. // SCB queue.
  887. //
  888. PRUN_ROUTINE RunRoutine;
  889. //
  890. // Routine to handle the response Ncp
  891. //
  892. PEX pEx;
  893. //
  894. // Routine to handle packet receipt
  895. //
  896. PRECEIVE_ROUTINE ReceiveDataRoutine;
  897. //
  898. // Routine to handle FSP post processing.
  899. //
  900. PPOST_PROCESSOR PostProcessRoutine;
  901. //
  902. // Routine to run when this IRP context times out while on the SCB
  903. // queue.
  904. //
  905. PRUN_ROUTINE TimeoutRoutine;
  906. //
  907. // Routine to run when this IRP has completed a send.
  908. //
  909. PIO_COMPLETION_ROUTINE CompletionSendRoutine;
  910. //
  911. // Work Item used for scheduling reconnect.
  912. //
  913. PWORK_QUEUE_ITEM pWorkItem;
  914. //
  915. // Buffer used to hold the Ncb to be transmitted/received.
  916. //
  917. ULONG Signature1;
  918. UCHAR req[MAX_SEND_DATA];
  919. ULONG Signature2;
  920. ULONG ResponseLength;
  921. UCHAR rsp[MAX_RECV_DATA];
  922. ULONG Signature3;
  923. //
  924. // Address to be used in the Send Datagram.
  925. //
  926. TA_IPX_ADDRESS Destination;
  927. TDI_CONNECTION_INFORMATION ConnectionInformation; // Remote server
  928. //
  929. // The ICB being processed.
  930. //
  931. PICB Icb;
  932. //
  933. // Per IRP processor information. A handy place to store information
  934. // for the IRP in progress.
  935. //
  936. union {
  937. struct {
  938. UNICODE_STRING FullPathName;
  939. UNICODE_STRING VolumeName;
  940. UNICODE_STRING PathName;
  941. UNICODE_STRING FileName;
  942. BOOLEAN NdsCreate;
  943. BOOLEAN NeedNdsData;
  944. DWORD dwNdsOid;
  945. DWORD dwNdsObjectType;
  946. DWORD dwNdsShareLength;
  947. UNICODE_STRING UidConnectName;
  948. WCHAR DriveLetter;
  949. ULONG ShareType;
  950. BOOLEAN fExCredentialCreate;
  951. PVOID pExCredentials;
  952. PUNICODE_STRING puCredentialName;
  953. PCHAR FindNearestResponse[4];
  954. ULONG FindNearestResponseCount;
  955. LARGE_INTEGER UserUid;
  956. } Create;
  957. struct {
  958. PVOID Buffer;
  959. ULONG Length;
  960. PVCB Vcb;
  961. CHAR VolumeNumber;
  962. } QueryVolumeInformation;
  963. struct {
  964. PVOID Buffer;
  965. ULONG Length;
  966. PMDL InputMdl;
  967. UCHAR Function; // Used for special case post-processing
  968. UCHAR Subfunction; // during UserNcpCallback
  969. } FileSystemControl;
  970. struct {
  971. PVOID Buffer;
  972. ULONG WriteOffset;
  973. ULONG RemainingLength;
  974. PMDL PartialMdl;
  975. PMDL FullMdl;
  976. ULONG FileOffset;
  977. ULONG LastWriteLength;
  978. ULONG BurstOffset;
  979. ULONG BurstLength;
  980. NTSTATUS Status;
  981. ULONG TotalWriteLength;
  982. ULONG TotalWriteOffset;
  983. ULONG PacketCount;
  984. } Write;
  985. struct {
  986. ULONG CacheReadSize; // Amount of data read from the cache
  987. ULONG ReadAheadSize; // Extra data to read
  988. PVOID Buffer; // Buffer for the current read
  989. PMDL FullMdl;
  990. PMDL PartialMdl;
  991. ULONG ReadOffset;
  992. ULONG RemainingLength;
  993. ULONG FileOffset;
  994. ULONG LastReadLength;
  995. LIST_ENTRY PacketList; // List of packets received
  996. ULONG BurstRequestOffset; // Offset in burst buffer for last request
  997. ULONG BurstSize; // Number of bytes in current burst
  998. PVOID BurstBuffer; // Buffer for the current burst
  999. BOOLEAN DataReceived;
  1000. NTSTATUS Status;
  1001. UCHAR Flags;
  1002. ULONG TotalReadLength;
  1003. ULONG TotalReadOffset;
  1004. } Read;
  1005. struct {
  1006. PNW_FILE_LOCK FileLock;
  1007. ULONG Key;
  1008. BOOLEAN Wait;
  1009. BOOLEAN ByKey;
  1010. } Lock;
  1011. } Specific;
  1012. struct {
  1013. UCHAR Error;
  1014. } ResponseParameters;
  1015. #ifdef NWDBG
  1016. ULONG DebugValue;
  1017. ULONG SequenceNumber;
  1018. #endif
  1019. } IRP_CONTEXT, *PIRP_CONTEXT;
  1020. typedef struct _BURST_READ_ENTRY {
  1021. LIST_ENTRY ListEntry;
  1022. ULONG DataOffset;
  1023. USHORT ByteCount;
  1024. } BURST_READ_ENTRY, *PBURST_READ_ENTRY;
  1025. typedef struct _LOGON {
  1026. //
  1027. // The type and size of this record.
  1028. //
  1029. NODE_TYPE_CODE NodeTypeCode;
  1030. NODE_BYTE_SIZE NodeByteSize;
  1031. //
  1032. // List of Login records.
  1033. //
  1034. LIST_ENTRY Next;
  1035. UNICODE_STRING UserName;
  1036. UNICODE_STRING PassWord;
  1037. UNICODE_STRING ServerName;
  1038. LARGE_INTEGER UserUid;
  1039. //
  1040. // The NDS credential list, default tree,
  1041. // and default context for this user.
  1042. //
  1043. ERESOURCE CredentialListResource;
  1044. LIST_ENTRY NdsCredentialList;
  1045. ULONG NwPrintOptions;
  1046. PVCB DriveMapTable[DRIVE_MAP_TABLE_SIZE];
  1047. } LOGON, *PLOGON;
  1048. typedef struct _MINI_IRP_CONTEXT {
  1049. //
  1050. // Header information
  1051. //
  1052. NODE_TYPE_CODE NodeTypeCode;
  1053. NODE_BYTE_SIZE NodeByteSize;
  1054. //
  1055. // A link to queue IRP contexts
  1056. //
  1057. LIST_ENTRY Next;
  1058. PIRP_CONTEXT IrpContext;
  1059. PIRP Irp;
  1060. PVOID Buffer; // The buffer for this request.
  1061. PMDL Mdl1; // The MDL for the buffer
  1062. PMDL Mdl2; // The MDL for the data
  1063. } MINI_IRP_CONTEXT, *PMINI_IRP_CONTEXT;
  1064. //
  1065. // Definitions for unlockable code sections.
  1066. //
  1067. typedef struct _SECTION_DESCRIPTOR {
  1068. PVOID Base;
  1069. PVOID Handle;
  1070. ULONG ReferenceCount;
  1071. } SECTION_DESCRIPTOR, *PSECTION_DESCRIPTOR;
  1072. //
  1073. // The work context is a queueable work item. It is used for specifying
  1074. // the IRP_CONTEXT to our thread which handles reroute attempts.
  1075. //
  1076. typedef struct _WORK_CONTEXT {
  1077. //
  1078. // Type and size of this record (must be NW_NTC_WORK_CONTEXT).
  1079. //
  1080. NODE_TYPE_CODE NodeTypeCode;
  1081. NODE_BYTE_SIZE NodeByteSize;
  1082. //
  1083. // The work to be done
  1084. //
  1085. NODE_WORK_CODE NodeWorkCode;
  1086. PIRP_CONTEXT pIrpC;
  1087. //
  1088. // A link to queue work contexts to the Kernel queue object
  1089. //
  1090. LIST_ENTRY Next;
  1091. } WORK_CONTEXT, *PWORK_CONTEXT;
  1092. //
  1093. // NDS resolved object entry.
  1094. //
  1095. // NOTE: This must be eight byte aligned.
  1096. //
  1097. typedef struct _NDS_OBJECT_CACHE_ENTRY {
  1098. LIST_ENTRY Links;
  1099. LARGE_INTEGER Timeout;
  1100. DWORD DsOid;
  1101. DWORD ObjectType;
  1102. DWORD ResolverFlags;
  1103. BOOLEAN AllowServerJump;
  1104. BOOLEAN Padding[3];
  1105. PSCB Scb;
  1106. ULONG Reserved;
  1107. UNICODE_STRING ObjectName;
  1108. } NDS_OBJECT_CACHE_ENTRY, *PNDS_OBJECT_CACHE_ENTRY;
  1109. #endif // _NWSTRUC_