Leaked source code of windows server 2003
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.

1508 lines
35 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_ADVANCED_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. //
  586. // This is the mutex that is inserted into the FCB_ADVANCED_HEADER
  587. // FastMutex field
  588. //
  589. FAST_MUTEX AdvancedFcbHeaderMutex;
  590. } NONPAGED_FCB, NONPAGED_DCB;
  591. typedef NONPAGED_FCB *PNONPAGED_FCB;
  592. typedef NONPAGED_DCB *PNONPAGED_DCB;
  593. #define FCB_STATE_OPEN_PENDING 0x00000001
  594. #define FCB_STATE_OPENED 0x00000002
  595. #define FCB_STATE_CLOSE_PENDING 0x00000003
  596. #define FCB_FLAGS_DELETE_ON_CLOSE 0x00000001
  597. #define FCB_FLAGS_TRUNCATE_ON_CLOSE 0x00000002
  598. #define FCB_FLAGS_PAGING_FILE 0x00000004
  599. #define FCB_FLAGS_PREFIX_INSERTED 0x00000008
  600. #define FCB_FLAGS_FORCE_MISS_IN_PROGRESS 0x00000010
  601. #define FCB_FLAGS_ATTRIBUTES_ARE_VALID 0x00000020
  602. #define FCB_FLAGS_LONG_NAME 0x00000040
  603. #define FCB_FLAGS_LAZY_SET_SHAREABLE 0x00000100
  604. //
  605. // This structure is used for directory searches.
  606. //
  607. typedef struct _NW_DIRECTORY_INFO {
  608. WCHAR FileNameBuffer[NW_MAX_FILENAME_LENGTH];
  609. UNICODE_STRING FileName;
  610. UCHAR Attributes;
  611. USHORT CreationDate;
  612. USHORT CreationTime;
  613. USHORT LastAccessDate;
  614. USHORT LastUpdateDate;
  615. USHORT LastUpdateTime;
  616. ULONG FileSize;
  617. ULONG DosDirectoryEntry;
  618. ULONG FileIndexLow;
  619. ULONG FileIndexHigh;
  620. NTSTATUS Status;
  621. LIST_ENTRY ListEntry;
  622. } NW_DIRECTORY_INFO, *PNW_DIRECTORY_INFO;
  623. //
  624. // The Icb record is allocated for every file object
  625. //
  626. typedef struct _ICB {
  627. //
  628. // Type and size of this record (must be NW_NTC_ICB or NW_NTC_ICB_SCB)
  629. //
  630. NODE_TYPE_CODE NodeTypeCode;
  631. NODE_BYTE_SIZE NodeByteSize;
  632. //
  633. // A link to the list of ICB's for our FCB, and our FCB.
  634. //
  635. LIST_ENTRY ListEntry;
  636. union {
  637. PFCB Fcb;
  638. PSCB Scb;
  639. } SuperType;
  640. PNONPAGED_FCB NpFcb; // Valid only for node type NW_ITC_ICB
  641. //
  642. // The state of this ICB.
  643. //
  644. ULONG State;
  645. //
  646. // The remote handle;
  647. //
  648. UCHAR Handle[6]; // Keep WORD aligned.
  649. BOOLEAN HasRemoteHandle; // TRUE if we have a remote handle for this ICB
  650. //
  651. // The file object for this ICB.
  652. //
  653. PFILE_OBJECT FileObject;
  654. //
  655. // The query template is used to filter directory query requests.
  656. // It originally is set to null and on the first call the NtQueryDirectory
  657. // it is set the the input filename or "*" if the name is supplied.
  658. // All subsquent queries then use this template
  659. //
  660. OEM_STRING NwQueryTemplate;
  661. UNICODE_STRING UQueryTemplate;
  662. ULONG IndexOfLastIcbReturned;
  663. UCHAR Pid;
  664. BOOLEAN DotReturned;
  665. BOOLEAN DotDotReturned;
  666. BOOLEAN ReturnedSomething;
  667. BOOLEAN ShortNameSearch;
  668. //
  669. // More search parameters.
  670. //
  671. USHORT SearchHandle;
  672. UCHAR SearchVolume;
  673. UCHAR SearchAttributes;
  674. //
  675. // Extra search parameters for long name support
  676. //
  677. ULONG SearchIndexLow;
  678. ULONG SearchIndexHigh;
  679. //
  680. // SVR to avoid rescanning from end of dir all
  681. // the way through the directory again.
  682. //
  683. ULONG LastSearchIndexLow;
  684. // SVR end
  685. //
  686. // Print parametres;
  687. //
  688. BOOLEAN IsPrintJob;
  689. USHORT JobId;
  690. BOOLEAN ActuallyPrinted;
  691. //
  692. // This flag prevents cleanup from updating the access time.
  693. //
  694. BOOLEAN UserSetLastAccessTime;
  695. //
  696. // The current file position.
  697. //
  698. ULONG FilePosition;
  699. //
  700. // The size of the file if its ICB_SCB
  701. //
  702. ULONG FileSize;
  703. //
  704. // The Next dirent offset is used by directory enumeration. It is
  705. // the offset (within the directory file) of the next dirent to examine.
  706. //
  707. //VBO OffsetToStartSearchFrom;
  708. //
  709. // If this ICB was created with OPEN_RENAME_TARGET then the following
  710. // parameters are used
  711. //
  712. BOOLEAN IsAFile;
  713. BOOLEAN Exists;
  714. BOOLEAN FailedFindNotify;
  715. //
  716. // Is this a tree handle? We need to know for delete.
  717. //
  718. BOOLEAN IsTreeHandle;
  719. BOOLEAN IsExCredentialHandle;
  720. PVOID pContext;
  721. //
  722. // A linked list of cached directory entries.
  723. //
  724. LIST_ENTRY DirCache;
  725. //
  726. // A hint into the dir cache.
  727. //
  728. PLIST_ENTRY CacheHint;
  729. //
  730. // A pointer to the top of the buffer.
  731. //
  732. PVOID DirCacheBuffer;
  733. } ICB, *PICB;
  734. #define ICB_STATE_OPEN_PENDING 0x00000001
  735. #define ICB_STATE_OPENED 0x00000002
  736. #define ICB_STATE_CLEANED_UP 0x00000003
  737. #define ICB_STATE_CLOSE_PENDING 0x00000004
  738. #define INVALID_PID 0
  739. //
  740. // A structure used to maintain a list of file locks.
  741. //
  742. typedef struct _NW_FILE_LOCK {
  743. //
  744. // Type and size of this record (must be NW_NTC_FILE_LOCK )
  745. //
  746. NODE_TYPE_CODE NodeTypeCode;
  747. NODE_BYTE_SIZE NodeByteSize;
  748. //
  749. // A link to the list of locks for this FCB.
  750. //
  751. LIST_ENTRY ListEntry;
  752. //
  753. // The ICB this lock belongs to.
  754. //
  755. PICB Icb;
  756. //
  757. // The IRP Context for this lock request.
  758. //
  759. struct _IRP_CONTEXT *IrpContext;
  760. //
  761. // The originating process.
  762. //
  763. void *pOwnerProc;
  764. //
  765. // The lock offset, length, and key.
  766. //
  767. LONG StartFileOffset;
  768. ULONG Length;
  769. LONG EndFileOffset;
  770. ULONG Key;
  771. USHORT Flags;
  772. } NW_FILE_LOCK, *PNW_FILE_LOCK;
  773. //
  774. // The Rcb record controls access to the redirector device
  775. //
  776. typedef struct _RCB {
  777. //
  778. // Type and size of this record (must be NW_NTC_RCB)
  779. //
  780. NODE_TYPE_CODE NodeTypeCode;
  781. NODE_BYTE_SIZE NodeByteSize;
  782. //
  783. // The run state of the redirector
  784. //
  785. ULONG State;
  786. //
  787. // The count of open handles to the RCB.
  788. // Access is protected by the RCB Resource.
  789. //
  790. ULONG OpenCount;
  791. //
  792. // A resource to synchronize access to the RCB.
  793. //
  794. ERESOURCE Resource;
  795. //
  796. // A record of accesss currently granted to the RCB.
  797. //
  798. SHARE_ACCESS ShareAccess;
  799. //
  800. // A prefix table of all connected servers.
  801. //
  802. UNICODE_PREFIX_TABLE ServerNameTable;
  803. //
  804. // A prefix table of all open volumes.
  805. //
  806. UNICODE_PREFIX_TABLE VolumeNameTable;
  807. //
  808. // A prefix table of all open files
  809. //
  810. UNICODE_PREFIX_TABLE FileNameTable;
  811. } RCB, *PRCB;
  812. #define RCB_STATE_STOPPED 0x00000001
  813. #define RCB_STATE_STARTING 0x00000002
  814. #define RCB_STATE_NEED_BIND 0x00000003
  815. #define RCB_STATE_RUNNING 0x00000004
  816. #define RCB_STATE_SHUTDOWN 0x00000005
  817. //
  818. // IRP_CONTEXT Flags bits.
  819. //
  820. #define IRP_FLAG_IN_FSD 0x00000001 // This IRP is being process in the FSD
  821. #define IRP_FLAG_ON_SCB_QUEUE 0x00000002 // This IRP is queued to an SCB
  822. #define IRP_FLAG_SEQUENCE_NO_REQUIRED 0x00000004 // This packet requires a sequence #
  823. #define IRP_FLAG_SIGNAL_EVENT 0x00000010
  824. #define IRP_FLAG_RETRY_SEND 0x00000020 // We are resending a timed out request
  825. #define IRP_FLAG_RECONNECTABLE 0x00000040 // We are allowed to try a reconnect if this request fails due to a bad connection
  826. #define IRP_FLAG_RECONNECT_ATTEMPT 0x00000080 // This IRP is being used to attempt a reconnect
  827. #define IRP_FLAG_BURST_REQUEST 0x00000100 // This is a burst request packet
  828. #define IRP_FLAG_BURST_PACKET 0x00000200 // This is any burst packet
  829. #define IRP_FLAG_NOT_OK_TO_RECEIVE 0x00000400 // Don't set ok to receive when sending this packet
  830. #define IRP_FLAG_REROUTE_ATTEMPTED 0x00000800 // A re-route has been attempted for this packet
  831. #define IRP_FLAG_BURST_WRITE 0x00001000 // We are processsing a burst write request
  832. #define IRP_FLAG_SEND_ALWAYS 0x00002000 // Okay to send this packet, even if RCB State is shutdown
  833. #define IRP_FLAG_FREE_RECEIVE_MDL 0x00004000 // Free the receive irp's MDL when the irp completes
  834. #define IRP_FLAG_NOT_SYSTEM_PACKET 0x00008000 // Used in burst writes to alternate system packet and normal
  835. #define IRP_FLAG_NOCONNECT 0x00010000 // Used to inspect server list
  836. #define IRP_FLAG_HAS_CREDENTIAL_LOCK 0X00020000 // Used to prevent deadlocking
  837. #define IRP_FLAG_REROUTE_IN_PROGRESS 0x00040000 // A re-route is currently in progress for this packet.
  838. typedef struct _IRP_CONTEXT {
  839. //
  840. // Type and size of this record (must be NW_NTC_IRP_CONTEXT).
  841. //
  842. NODE_TYPE_CODE NodeTypeCode;
  843. NODE_BYTE_SIZE NodeByteSize;
  844. //
  845. // Information about this IRP
  846. //
  847. ULONG Flags;
  848. //
  849. // This structure is used for posting to the Ex worker threads.
  850. //
  851. WORK_QUEUE_ITEM WorkQueueItem; // 4*sizeof(ULONG)
  852. // Workspace for exchange()
  853. PACKET_TYPE PacketType;
  854. //
  855. // Server Control Block to which this request applies.
  856. //
  857. PNONPAGED_SCB pNpScb;
  858. PSCB pScb;
  859. //
  860. // The socket structure to use for this request. If NULL, use
  861. // pNpScb->Server socket.
  862. //
  863. PNW_TDI_STRUCT pTdiStruct;
  864. //
  865. // List of requests to a particular server. Listed on Scb->Requests.
  866. //
  867. LIST_ENTRY NextRequest;
  868. //
  869. // Used for processing synchronous IRPs.
  870. //
  871. KEVENT Event; // 4 words
  872. //
  873. // A pointer to the originating Irp and its original contents when
  874. // the I/O system submitted it to the rdr.
  875. //
  876. PIRP pOriginalIrp;
  877. PVOID pOriginalSystemBuffer;
  878. PVOID pOriginalUserBuffer;
  879. PMDL pOriginalMdlAddress;
  880. //
  881. // Information used if we need to post an IRP to process the receive
  882. //
  883. PIRP ReceiveIrp;
  884. //
  885. // Pointer to the Mdl used to transmit/receive the Ncp header.
  886. //
  887. PMDL TxMdl;
  888. PMDL RxMdl;
  889. //
  890. // Routine to run when this IRP context reaches the front of the
  891. // SCB queue.
  892. //
  893. PRUN_ROUTINE RunRoutine;
  894. //
  895. // Routine to handle the response Ncp
  896. //
  897. PEX pEx;
  898. //
  899. // Routine to handle packet receipt
  900. //
  901. PRECEIVE_ROUTINE ReceiveDataRoutine;
  902. //
  903. // Routine to handle FSP post processing.
  904. //
  905. PPOST_PROCESSOR PostProcessRoutine;
  906. //
  907. // Routine to run when this IRP context times out while on the SCB
  908. // queue.
  909. //
  910. PRUN_ROUTINE TimeoutRoutine;
  911. //
  912. // Routine to run when this IRP has completed a send.
  913. //
  914. PIO_COMPLETION_ROUTINE CompletionSendRoutine;
  915. //
  916. // Work Item used for scheduling reconnect.
  917. //
  918. PWORK_QUEUE_ITEM pWorkItem;
  919. //
  920. // Buffer used to hold the Ncb to be transmitted/received.
  921. //
  922. ULONG Signature1;
  923. UCHAR req[MAX_SEND_DATA];
  924. ULONG Signature2;
  925. ULONG ResponseLength;
  926. UCHAR rsp[MAX_RECV_DATA];
  927. ULONG Signature3;
  928. //
  929. // Address to be used in the Send Datagram.
  930. //
  931. TA_IPX_ADDRESS Destination;
  932. TDI_CONNECTION_INFORMATION ConnectionInformation; // Remote server
  933. //
  934. // The ICB being processed.
  935. //
  936. PICB Icb;
  937. //
  938. // Per IRP processor information. A handy place to store information
  939. // for the IRP in progress.
  940. //
  941. union {
  942. struct {
  943. UNICODE_STRING FullPathName;
  944. UNICODE_STRING VolumeName;
  945. UNICODE_STRING PathName;
  946. UNICODE_STRING FileName;
  947. BOOLEAN NdsCreate;
  948. BOOLEAN NeedNdsData;
  949. DWORD dwNdsOid;
  950. DWORD dwNdsObjectType;
  951. DWORD dwNdsShareLength;
  952. UNICODE_STRING UidConnectName;
  953. WCHAR DriveLetter;
  954. ULONG ShareType;
  955. BOOLEAN fExCredentialCreate;
  956. PVOID pExCredentials;
  957. PUNICODE_STRING puCredentialName;
  958. PCHAR FindNearestResponse[4];
  959. ULONG FindNearestResponseCount;
  960. LARGE_INTEGER UserUid;
  961. } Create;
  962. struct {
  963. PVOID Buffer;
  964. ULONG Length;
  965. PVCB Vcb;
  966. CHAR VolumeNumber;
  967. } QueryVolumeInformation;
  968. struct {
  969. PVOID Buffer;
  970. ULONG Length;
  971. PMDL InputMdl;
  972. UCHAR Function; // Used for special case post-processing
  973. UCHAR Subfunction; // during UserNcpCallback
  974. } FileSystemControl;
  975. struct {
  976. PVOID Buffer;
  977. ULONG WriteOffset;
  978. ULONG RemainingLength;
  979. PMDL PartialMdl;
  980. PMDL FullMdl;
  981. ULONG FileOffset;
  982. ULONG LastWriteLength;
  983. ULONG BurstOffset;
  984. ULONG BurstLength;
  985. NTSTATUS Status;
  986. ULONG TotalWriteLength;
  987. ULONG TotalWriteOffset;
  988. ULONG PacketCount;
  989. } Write;
  990. struct {
  991. ULONG CacheReadSize; // Amount of data read from the cache
  992. ULONG ReadAheadSize; // Extra data to read
  993. PVOID Buffer; // Buffer for the current read
  994. PMDL FullMdl;
  995. PMDL PartialMdl;
  996. ULONG ReadOffset;
  997. ULONG RemainingLength;
  998. ULONG FileOffset;
  999. ULONG LastReadLength;
  1000. LIST_ENTRY PacketList; // List of packets received
  1001. ULONG BurstRequestOffset; // Offset in burst buffer for last request
  1002. ULONG BurstSize; // Number of bytes in current burst
  1003. PVOID BurstBuffer; // Buffer for the current burst
  1004. BOOLEAN DataReceived;
  1005. NTSTATUS Status;
  1006. UCHAR Flags;
  1007. ULONG TotalReadLength;
  1008. ULONG TotalReadOffset;
  1009. } Read;
  1010. struct {
  1011. PNW_FILE_LOCK FileLock;
  1012. ULONG Key;
  1013. BOOLEAN Wait;
  1014. BOOLEAN ByKey;
  1015. } Lock;
  1016. } Specific;
  1017. struct {
  1018. UCHAR Error;
  1019. } ResponseParameters;
  1020. #ifdef NWDBG
  1021. ULONG DebugValue;
  1022. ULONG SequenceNumber;
  1023. #endif
  1024. } IRP_CONTEXT, *PIRP_CONTEXT;
  1025. typedef struct _BURST_READ_ENTRY {
  1026. LIST_ENTRY ListEntry;
  1027. ULONG DataOffset;
  1028. USHORT ByteCount;
  1029. } BURST_READ_ENTRY, *PBURST_READ_ENTRY;
  1030. typedef struct _LOGON {
  1031. //
  1032. // The type and size of this record.
  1033. //
  1034. NODE_TYPE_CODE NodeTypeCode;
  1035. NODE_BYTE_SIZE NodeByteSize;
  1036. //
  1037. // List of Login records.
  1038. //
  1039. LIST_ENTRY Next;
  1040. UNICODE_STRING UserName;
  1041. UNICODE_STRING PassWord;
  1042. UNICODE_STRING ServerName;
  1043. LARGE_INTEGER UserUid;
  1044. //
  1045. // The NDS credential list, default tree,
  1046. // and default context for this user.
  1047. //
  1048. ERESOURCE CredentialListResource;
  1049. LIST_ENTRY NdsCredentialList;
  1050. ULONG NwPrintOptions;
  1051. PVCB DriveMapTable[DRIVE_MAP_TABLE_SIZE];
  1052. } LOGON, *PLOGON;
  1053. typedef struct _MINI_IRP_CONTEXT {
  1054. //
  1055. // Header information
  1056. //
  1057. NODE_TYPE_CODE NodeTypeCode;
  1058. NODE_BYTE_SIZE NodeByteSize;
  1059. //
  1060. // A link to queue IRP contexts
  1061. //
  1062. LIST_ENTRY Next;
  1063. PIRP_CONTEXT IrpContext;
  1064. PIRP Irp;
  1065. PVOID Buffer; // The buffer for this request.
  1066. PMDL Mdl1; // The MDL for the buffer
  1067. PMDL Mdl2; // The MDL for the data
  1068. } MINI_IRP_CONTEXT, *PMINI_IRP_CONTEXT;
  1069. //
  1070. // Definitions for unlockable code sections.
  1071. //
  1072. typedef struct _SECTION_DESCRIPTOR {
  1073. PVOID Base;
  1074. PVOID Handle;
  1075. ULONG ReferenceCount;
  1076. } SECTION_DESCRIPTOR, *PSECTION_DESCRIPTOR;
  1077. //
  1078. // The work context is a queueable work item. It is used for specifying
  1079. // the IRP_CONTEXT to our thread which handles reroute attempts.
  1080. //
  1081. typedef struct _WORK_CONTEXT {
  1082. //
  1083. // Type and size of this record (must be NW_NTC_WORK_CONTEXT).
  1084. //
  1085. NODE_TYPE_CODE NodeTypeCode;
  1086. NODE_BYTE_SIZE NodeByteSize;
  1087. //
  1088. // The work to be done
  1089. //
  1090. NODE_WORK_CODE NodeWorkCode;
  1091. PIRP_CONTEXT pIrpC;
  1092. //
  1093. // A link to queue work contexts to the Kernel queue object
  1094. //
  1095. LIST_ENTRY Next;
  1096. } WORK_CONTEXT, *PWORK_CONTEXT;
  1097. //
  1098. // NDS resolved object entry.
  1099. //
  1100. // NOTE: This must be eight byte aligned.
  1101. //
  1102. typedef struct _NDS_OBJECT_CACHE_ENTRY {
  1103. LIST_ENTRY Links;
  1104. LARGE_INTEGER Timeout;
  1105. DWORD DsOid;
  1106. DWORD ObjectType;
  1107. DWORD ResolverFlags;
  1108. BOOLEAN AllowServerJump;
  1109. BOOLEAN Padding[3];
  1110. PSCB Scb;
  1111. ULONG Reserved;
  1112. UNICODE_STRING ObjectName;
  1113. } NDS_OBJECT_CACHE_ENTRY, *PNDS_OBJECT_CACHE_ENTRY;
  1114. #endif // _NWSTRUC_