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.

1775 lines
59 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. srvdata.c
  5. Abstract:
  6. This module defines global data for the LAN Manager server FSP. The
  7. globals defined herein are part of the server driver image, and are
  8. therefore loaded into the system address space and are nonpageable.
  9. Some of the fields point to, or contain pointers to, data that is
  10. also in the system address space and nonpageable. Such data can be
  11. accessed by both the FSP and the FSD. Other fields point to data
  12. that is in the FSP address and may or may not be pageable. Only the
  13. FSP is allowed to address this data. Pageable data can only be
  14. accessed at low IRQL (so that page faults are allowed).
  15. This module also has a routine to initialize those fields defined
  16. here that cannot be statically initialized.
  17. Author:
  18. Chuck Lenzmeier (chuckl) 3-Oct-1989
  19. David Treadwell (davidtr)
  20. Revision History:
  21. --*/
  22. #include "precomp.h"
  23. #include "srvdata.tmh"
  24. #pragma hdrstop
  25. #ifdef ALLOC_PRAGMA
  26. #pragma alloc_text( INIT, SrvInitializeData )
  27. #pragma alloc_text( PAGE, SrvTerminateData )
  28. #endif
  29. #if SRVDBG
  30. ULARGE_INTEGER SrvDebug = {DEBUG_STOP_ON_ERRORS};
  31. ULARGE_INTEGER SmbDebug = {0};
  32. CLONG SrvDumpMaximumRecursion = 0;
  33. #endif // SRVDBG
  34. #ifdef PAGED_DBG
  35. ULONG ThisCodeCantBePaged = 0;
  36. #endif
  37. //
  38. // SrvDeviceObject is a pointer to the server's device object, which
  39. // is created by the server FSD during initialization. This global
  40. // location is accessed primarily by the FSP. The FSD usually knows
  41. // the device object address by other means -- because it was called
  42. // with the address as a parameter, or via a file object, etc. But
  43. // the transport receive event handler in the FSD doesn't have such
  44. // other means, so it needs to access the global storage.
  45. //
  46. // *** The event handler has the address of a server connection block
  47. // (in its ConnectionContext parameter). The device object address
  48. // could be found through the connection block.
  49. //
  50. PDEVICE_OBJECT SrvDeviceObject = NULL;
  51. //
  52. // Fields describing the state of the FSP.
  53. //
  54. BOOLEAN SrvFspActive = FALSE; // Indicates whether the FSP is
  55. // running
  56. BOOLEAN SrvFspTransitioning = FALSE; // Indicates that the server is
  57. // in the process of starting up
  58. // or shutting down
  59. BOOLEAN SrvMultiProcessorDriver = FALSE; // Is this a multiprocessor driver?
  60. BOOLEAN SrvCompletedPNPRegistration = FALSE; // Indicates whether the FSP has completed
  61. // registering for PNP notifications
  62. PEPROCESS SrvServerProcess = NULL; // Pointer to the initial system process
  63. PEPROCESS SrvSvcProcess = NULL; // Pointer to the service controller process
  64. CLONG SrvEndpointCount = 0; // Number of transport endpoints
  65. KEVENT SrvEndpointEvent = {0}; // Signaled when no active endpoints
  66. //
  67. // DMA alignment size
  68. //
  69. ULONG SrvCacheLineSize = 0;
  70. //
  71. // Global spin locks.
  72. //
  73. SRV_GLOBAL_SPIN_LOCKS SrvGlobalSpinLocks = {0};
  74. #if SRVDBG || SRVDBG_HANDLES
  75. //
  76. // Lock used to protect debugging structures.
  77. //
  78. SRV_LOCK SrvDebugLock = {0};
  79. #endif
  80. //
  81. // SrvConfigurationLock is used to synchronize configuration requests.
  82. //
  83. SRV_LOCK SrvConfigurationLock = {0};
  84. //
  85. // SrvStartupShutdownLock is used to synchronize server startup and shutdown
  86. //
  87. SRV_LOCK SrvStartupShutdownLock = {0};
  88. //
  89. // SrvEndpointLock serializes access to the global endpoint list and
  90. // all endpoints. Note that the list of connections in each endpoint
  91. // is also protected by this lock.
  92. //
  93. SRV_LOCK SrvEndpointLock = {0};
  94. //
  95. // SrvShareLock protects all shares.
  96. //
  97. SRV_LOCK SrvShareLock = {0};
  98. //
  99. // The number of processors in the system
  100. //
  101. ULONG SrvNumberOfProcessors = {0};
  102. //
  103. // A vector of nonblocking work queues, one for each processor
  104. //
  105. #if MULTIPROCESSOR
  106. PBYTE SrvWorkQueuesBase = 0; // base of allocated memory for the queues
  107. PWORK_QUEUE SrvWorkQueues = 0; // first queue in the allocated memory
  108. #else
  109. WORK_QUEUE SrvWorkQueues[1];
  110. #endif
  111. PWORK_QUEUE eSrvWorkQueues = 0; // used for terminating 'for' loops
  112. //
  113. // Blocking Work Queue
  114. //
  115. WORK_QUEUE SrvBlockingWorkQueue = {0};
  116. ULONG SrvReBalanced = 0;
  117. ULONG SrvNextBalanceProcessor = 0;
  118. CLONG SrvBlockingOpsInProgress = 0; // Number of blocking ops currently
  119. // being processed
  120. //
  121. // The queue of connections that need an SMB buffer to process a pending
  122. // receive completion.
  123. //
  124. LIST_ENTRY SrvNeedResourceQueue = {0}; // The queue
  125. //
  126. // The queue of connections that are disconnecting and need resource
  127. // thread processing.
  128. //
  129. LIST_ENTRY SrvDisconnectQueue = {0}; // The queue
  130. //
  131. // Queue of connections that needs to be dereferenced.
  132. //
  133. SLIST_HEADER SrvBlockOrphanage = {0}; // The queue
  134. //
  135. // FSP configuration queue. The FSD puts configuration request IRPs
  136. // (from NtDeviceIoControlFile) on this queue, and it is serviced by an
  137. // EX worker thread.
  138. //
  139. LIST_ENTRY SrvConfigurationWorkQueue = {0}; // The queue itself
  140. //
  141. // This is the number of configuration IRPs which have been queued but not
  142. // yet completed.
  143. //
  144. ULONG SrvConfigurationIrpsInProgress = 0;
  145. //
  146. // Base address of the large block allocated to hold initial normal
  147. // work items (see blkwork.c\SrvAllocateInitialWorkItems).
  148. //
  149. PVOID SrvInitialWorkItemBlock = NULL;
  150. //
  151. // Work item used to run the resource thread. Notification event used
  152. // to inform the resource thread to continue running.
  153. //
  154. WORK_QUEUE_ITEM SrvResourceThreadWorkItem = {0};
  155. BOOLEAN SrvResourceThreadRunning = FALSE;
  156. BOOLEAN SrvResourceDisconnectPending = FALSE;
  157. BOOLEAN SrvResourceFreeConnection = FALSE;
  158. LONG SrvResourceOrphanedBlocks = 0;
  159. //
  160. // Denial of Service monitoring variables for the Resource Thread
  161. //
  162. LONG SrvDoSTearDownInProgress = 0;
  163. LONG SrvDoSWorkItemTearDown = 0;
  164. BOOLEAN SrvDoSDetected = FALSE;
  165. BOOLEAN SrvDoSRundownDetector = FALSE;
  166. BOOLEAN SrvDoSRundownIncreased = FALSE;
  167. BOOLEAN SrvDisableDoSChecking = FALSE;
  168. SPECIAL_WORK_ITEM SrvDoSWorkItem;
  169. KSPIN_LOCK SrvDosSpinLock;
  170. LARGE_INTEGER SrvDoSLastRan = {0};
  171. //
  172. // Should we enforce strict name checking?
  173. //
  174. BOOLEAN SrvDisableStrictNameChecking = FALSE;
  175. //
  176. // Generic security mapping for connecting to shares
  177. //
  178. GENERIC_MAPPING SrvShareConnectMapping = GENERIC_SHARE_CONNECT_MAPPING;
  179. //
  180. // What's the minumum # of free work items each processor should have?
  181. //
  182. ULONG SrvMinPerProcessorFreeWorkItems = 0;
  183. //
  184. // The server has callouts to enable a smart card to accelerate its direct
  185. // host IPX performance. This is the vector of entry points.
  186. //
  187. SRV_IPX_SMART_CARD SrvIpxSmartCard = {0};
  188. //
  189. // This is the name of the server computer. Returned in the negprot response
  190. //
  191. UNICODE_STRING SrvComputerName = {0};
  192. //
  193. // The master file table contains one entry for each named file that has
  194. // at least one open instance.
  195. //
  196. MFCBHASH SrvMfcbHashTable[ NMFCB_HASH_TABLE ] = {0};
  197. //
  198. // This is the list of resources which protect the SrvMfcbHashTable buckets
  199. //
  200. SRV_LOCK SrvMfcbHashTableLocks[ NMFCB_HASH_TABLE_LOCKS ];
  201. //
  202. // The share table contains one entry for each share the server is supporting
  203. //
  204. LIST_ENTRY SrvShareHashTable[ NSHARE_HASH_TABLE ] = {0};
  205. //
  206. // Array of the hex digits for use by the dump routines and
  207. // SrvSmbCreateTemporary.
  208. //
  209. CHAR SrvHexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
  210. 'A', 'B', 'C', 'D', 'E', 'F' };
  211. #if SRVCATCH
  212. //
  213. // Are we looking for the special file?
  214. //
  215. UNICODE_STRING SrvCatch;
  216. PWSTR *SrvCatchBuf = NULL;
  217. UNICODE_STRING SrvCatchExt;
  218. PWSTR *SrvCatchExtBuf = NULL;
  219. ULONG SrvCatchShares = 0;
  220. PWSTR *SrvCatchShareNames = NULL;
  221. #endif
  222. //
  223. // SrvSmbIndexTable is the first-layer index table for processing SMBs.
  224. // The contents of this table are used to index into SrvSmbDispatchTable.
  225. //
  226. UCHAR SrvSmbIndexTable[] = {
  227. ISrvSmbCreateDirectory, // SMB_COM_CREATE_DIRECTORY
  228. ISrvSmbDeleteDirectory, // SMB_COM_DELETE_DIRECTORY
  229. ISrvSmbOpen, // SMB_COM_OPEN
  230. ISrvSmbCreate, // SMB_COM_CREATE
  231. ISrvSmbClose, // SMB_COM_CLOSE
  232. ISrvSmbFlush, // SMB_COM_FLUSH
  233. ISrvSmbDelete, // SMB_COM_DELETE
  234. ISrvSmbRename, // SMB_COM_RENAME
  235. ISrvSmbQueryInformation, // SMB_COM_QUERY_INFORMATION
  236. ISrvSmbSetInformation, // SMB_COM_SET_INFORMATION
  237. ISrvSmbRead, // SMB_COM_READ
  238. ISrvSmbWrite, // SMB_COM_WRITE
  239. ISrvSmbLockByteRange, // SMB_COM_LOCK_BYTE_RANGE
  240. ISrvSmbUnlockByteRange, // SMB_COM_UNLOCK_BYTE_RANGE
  241. ISrvSmbCreateTemporary, // SMB_COM_CREATE_TEMPORARY
  242. ISrvSmbCreate, // SMB_COM_CREATE
  243. ISrvSmbCheckDirectory, // SMB_COM_CHECK_DIRECTORY
  244. ISrvSmbProcessExit, // SMB_COM_PROCESS_EXIT
  245. ISrvSmbSeek, // SMB_COM_SEEK
  246. ISrvSmbLockAndRead, // SMB_COM_LOCK_AND_READ
  247. ISrvSmbWrite, // SMB_COM_WRITE_AND_UNLOCK
  248. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  249. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  250. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  251. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  252. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  253. ISrvSmbReadRaw, // SMB_COM_READ_RAW
  254. ISrvSmbReadMpx, // SMB_COM_READ_MPX
  255. ISrvSmbIllegalCommand, // SMB_COM_READ_MPX_SECONDARY (server only)
  256. ISrvSmbWriteRaw, // SMB_COM_WRITE_RAW
  257. ISrvSmbWriteMpx, // SMB_COM_WRITE_MPX
  258. ISrvSmbWriteMpxSecondary, // SMB_COM_WRITE_MPX_SECONDARY
  259. ISrvSmbIllegalCommand, // SMB_COM_WRITE_COMPLETE (server only)
  260. ISrvSmbIllegalCommand, // SMB_COM_QUERY_INFORMATION_SRV
  261. ISrvSmbSetInformation2, // SMB_COM_SET_INFORMATION2
  262. ISrvSmbQueryInformation2, // SMB_COM_QUERY_INFORMATION2
  263. ISrvSmbLockingAndX, // SMB_COM_LOCKING_ANDX
  264. ISrvSmbTransaction, // SMB_COM_TRANSACTION
  265. ISrvSmbTransactionSecondary, // SMB_COM_TRANSACTION_SECONDARY
  266. ISrvSmbIoctl, // SMB_COM_IOCTL
  267. ISrvSmbIoctlSecondary, // SMB_COM_IOCTL_SECONDARY
  268. ISrvSmbMove, // SMB_COM_COPY
  269. ISrvSmbMove, // SMB_COM_MOVE
  270. ISrvSmbEcho, // SMB_COM_ECHO
  271. ISrvSmbWrite, // SMB_COM_WRITE_AND_CLOSE
  272. ISrvSmbOpenAndX, // SMB_COM_OPEN_ANDX
  273. ISrvSmbReadAndX, // SMB_COM_READ_ANDX
  274. ISrvSmbWriteAndX, // SMB_COM_WRITE_ANDX
  275. ISrvSmbIllegalCommand, // SMB_COM_SET_NEW_SIZE
  276. ISrvSmbClose, // SMB_COM_CLOSE_AND_TREE_DISC
  277. ISrvSmbTransaction, // SMB_COM_TRANSACTION2
  278. ISrvSmbTransactionSecondary, // SMB_COM_TRANSACTION2_SECONDARY
  279. ISrvSmbFindClose2, // SMB_COM_FIND_CLOSE2
  280. ISrvSmbFindNotifyClose, // SMB_COM_FIND_NOTIFY_CLOSE
  281. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  282. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  283. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  284. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  285. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  286. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  287. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  288. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  289. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  290. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  291. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  292. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  293. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  294. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  295. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  296. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  297. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  298. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  299. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  300. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  301. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  302. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  303. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  304. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  305. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  306. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  307. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  308. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  309. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  310. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  311. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  312. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  313. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  314. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  315. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  316. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  317. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  318. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  319. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  320. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  321. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  322. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  323. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  324. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  325. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  326. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  327. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  328. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  329. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  330. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  331. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  332. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  333. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  334. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  335. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  336. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  337. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  338. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  339. ISrvSmbTreeConnect, // SMB_COM_TREE_CONNECT
  340. ISrvSmbTreeDisconnect, // SMB_COM_TREE_DISCONNECT
  341. ISrvSmbNegotiate, // SMB_COM_NEGOTIATE
  342. ISrvSmbSessionSetupAndX, // SMB_COM_SESSION_SETUP_ANDX
  343. ISrvSmbLogoffAndX, // SMB_COM_LOGOFF_ANDX
  344. ISrvSmbTreeConnectAndX, // SMB_COM_TREE_CONNECT_ANDX
  345. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  346. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  347. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  348. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  349. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  350. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  351. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  352. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  353. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  354. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  355. ISrvSmbQueryInformationDisk, // SMB_COM_QUERY_INFORMATION_DISK
  356. ISrvSmbSearch, // SMB_COM_SEARCH
  357. ISrvSmbSearch, // SMB_COM_SEARCH
  358. ISrvSmbSearch, // SMB_COM_SEARCH
  359. ISrvSmbSearch, // SMB_COM_SEARCH
  360. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  361. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  362. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  363. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  364. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  365. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  366. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  367. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  368. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  369. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  370. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  371. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  372. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  373. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  374. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  375. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  376. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  377. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  378. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  379. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  380. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  381. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  382. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  383. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  384. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  385. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  386. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  387. ISrvSmbNtTransaction, // SMB_COM_NT_TRANSACT
  388. ISrvSmbNtTransactionSecondary, // SMB_COM_NT_TRANSACT_SECONDARY
  389. ISrvSmbNtCreateAndX, // SMB_COM_NT_CREATE_ANDX
  390. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  391. ISrvSmbNtCancel, // SMB_COM_NT_CANCEL
  392. ISrvSmbRename, // SMB_COM_NT_RENAME
  393. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  394. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  395. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  396. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  397. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  398. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  399. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  400. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  401. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  402. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  403. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  404. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  405. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  406. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  407. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  408. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  409. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  410. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  411. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  412. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  413. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  414. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  415. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  416. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  417. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  418. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  419. ISrvSmbOpenPrintFile, // SMB_COM_OPEN_PRINT_FILE
  420. ISrvSmbWrite, // SMB_COM_WRITE_PRINT_FILE
  421. ISrvSmbClosePrintFile, // SMB_COM_CLOSE_PRINT_FILE
  422. ISrvSmbGetPrintQueue, // SMB_COM_GET_PRINT_QUEUE
  423. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  424. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  425. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  426. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  427. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  428. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  429. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  430. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  431. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  432. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  433. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  434. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  435. ISrvSmbIllegalCommand, // SMB_COM_SEND_MESSAGE
  436. ISrvSmbIllegalCommand, // SMB_COM_SEND_BROADCAST_MESSAGE
  437. ISrvSmbIllegalCommand, // SMB_COM_FORWARD_USER_NAME
  438. ISrvSmbIllegalCommand, // SMB_COM_CANCEL_FORWARD
  439. ISrvSmbIllegalCommand, // SMB_COM_GET_MACHINE_NAME
  440. ISrvSmbIllegalCommand, // SMB_COM_SEND_START_MB_MESSAGE
  441. ISrvSmbIllegalCommand, // SMB_COM_SEND_END_MB_MESSAGE
  442. ISrvSmbIllegalCommand, // SMB_COM_SEND_TEXT_MB_MESSAGE
  443. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  444. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  445. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  446. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  447. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  448. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  449. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  450. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  451. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  452. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  453. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  454. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  455. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  456. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  457. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  458. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  459. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  460. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  461. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  462. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  463. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  464. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  465. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  466. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  467. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  468. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  469. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  470. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  471. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  472. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  473. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  474. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  475. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  476. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  477. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  478. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  479. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  480. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  481. ISrvSmbIllegalCommand, // SMB_COM_ILLEGAL_COMMAND
  482. ISrvSmbIllegalCommand // SMB_COM_ILLEGAL_COMMAND
  483. };
  484. //
  485. // SrvSmbDispatchTable is the jump table for processing SMBs.
  486. //
  487. #if DBG
  488. #define SMB_DISPATCH_ENTRY( x ) { x, #x }
  489. #else
  490. #define SMB_DISPATCH_ENTRY( x ) { x }
  491. #endif
  492. SRV_SMB_DISPATCH_TABLE SrvSmbDispatchTable[] = {
  493. SMB_DISPATCH_ENTRY( SrvSmbIllegalCommand ),
  494. SMB_DISPATCH_ENTRY( SrvSmbCreateDirectory ),
  495. SMB_DISPATCH_ENTRY( SrvSmbDeleteDirectory ),
  496. SMB_DISPATCH_ENTRY( SrvSmbOpen ),
  497. SMB_DISPATCH_ENTRY( SrvSmbCreate ),
  498. SMB_DISPATCH_ENTRY( SrvSmbClose ),
  499. SMB_DISPATCH_ENTRY( SrvSmbFlush ),
  500. SMB_DISPATCH_ENTRY( SrvSmbDelete ),
  501. SMB_DISPATCH_ENTRY( SrvSmbRename ),
  502. SMB_DISPATCH_ENTRY( SrvSmbQueryInformation ),
  503. SMB_DISPATCH_ENTRY( SrvSmbSetInformation ),
  504. SMB_DISPATCH_ENTRY( SrvSmbRead ),
  505. SMB_DISPATCH_ENTRY( SrvSmbWrite ),
  506. SMB_DISPATCH_ENTRY( SrvSmbLockByteRange ),
  507. SMB_DISPATCH_ENTRY( SrvSmbUnlockByteRange ),
  508. SMB_DISPATCH_ENTRY( SrvSmbCreateTemporary ),
  509. SMB_DISPATCH_ENTRY( SrvSmbCheckDirectory ),
  510. SMB_DISPATCH_ENTRY( SrvSmbProcessExit ),
  511. SMB_DISPATCH_ENTRY( SrvSmbSeek ),
  512. SMB_DISPATCH_ENTRY( SrvSmbLockAndRead ),
  513. SMB_DISPATCH_ENTRY( SrvSmbSetInformation2 ),
  514. SMB_DISPATCH_ENTRY( SrvSmbQueryInformation2 ),
  515. SMB_DISPATCH_ENTRY( SrvSmbLockingAndX ),
  516. SMB_DISPATCH_ENTRY( SrvSmbTransaction ),
  517. SMB_DISPATCH_ENTRY( SrvSmbTransactionSecondary ),
  518. SMB_DISPATCH_ENTRY( SrvSmbIoctl ),
  519. SMB_DISPATCH_ENTRY( SrvSmbIoctlSecondary ),
  520. SMB_DISPATCH_ENTRY( SrvSmbMove ),
  521. SMB_DISPATCH_ENTRY( SrvSmbEcho ),
  522. SMB_DISPATCH_ENTRY( SrvSmbOpenAndX ),
  523. SMB_DISPATCH_ENTRY( SrvSmbReadAndX ),
  524. SMB_DISPATCH_ENTRY( SrvSmbWriteAndX ),
  525. SMB_DISPATCH_ENTRY( SrvSmbFindClose2 ),
  526. SMB_DISPATCH_ENTRY( SrvSmbFindNotifyClose ),
  527. SMB_DISPATCH_ENTRY( SrvSmbTreeConnect ),
  528. SMB_DISPATCH_ENTRY( SrvSmbTreeDisconnect ),
  529. SMB_DISPATCH_ENTRY( SrvSmbNegotiate ),
  530. SMB_DISPATCH_ENTRY( SrvSmbSessionSetupAndX ),
  531. SMB_DISPATCH_ENTRY( SrvSmbLogoffAndX ),
  532. SMB_DISPATCH_ENTRY( SrvSmbTreeConnectAndX ),
  533. SMB_DISPATCH_ENTRY( SrvSmbQueryInformationDisk ),
  534. SMB_DISPATCH_ENTRY( SrvSmbSearch ),
  535. SMB_DISPATCH_ENTRY( SrvSmbNtTransaction ),
  536. SMB_DISPATCH_ENTRY( SrvSmbNtTransactionSecondary ),
  537. SMB_DISPATCH_ENTRY( SrvSmbNtCreateAndX ),
  538. SMB_DISPATCH_ENTRY( SrvSmbNtCancel ),
  539. SMB_DISPATCH_ENTRY( SrvSmbOpenPrintFile ),
  540. SMB_DISPATCH_ENTRY( SrvSmbClosePrintFile ),
  541. SMB_DISPATCH_ENTRY( SrvSmbGetPrintQueue ),
  542. SMB_DISPATCH_ENTRY( SrvSmbReadRaw ),
  543. SMB_DISPATCH_ENTRY( SrvSmbWriteRaw ),
  544. SMB_DISPATCH_ENTRY( SrvSmbReadMpx ),
  545. SMB_DISPATCH_ENTRY( SrvSmbWriteMpx ),
  546. SMB_DISPATCH_ENTRY( SrvSmbWriteMpxSecondary )
  547. };
  548. //
  549. // Table of WordCount values for all SMBs.
  550. //
  551. SCHAR SrvSmbWordCount[] = {
  552. 0, // SMB_COM_CREATE_DIRECTORY
  553. 0, // SMB_COM_DELETE_DIRECTORY
  554. 2, // SMB_COM_OPEN
  555. 3, // SMB_COM_CREATE
  556. 3, // SMB_COM_CLOSE
  557. 1, // SMB_COM_FLUSH
  558. 1, // SMB_COM_DELETE
  559. 1, // SMB_COM_RENAME
  560. 0, // SMB_COM_QUERY_INFORMATION
  561. 8, // SMB_COM_SET_INFORMATION
  562. 5, // SMB_COM_READ
  563. 5, // SMB_COM_WRITE
  564. 5, // SMB_COM_LOCK_BYTE_RANGE
  565. 5, // SMB_COM_UNLOCK_BYTE_RANGE
  566. 3, // SMB_COM_CREATE_TEMPORARY
  567. 3, // SMB_COM_CREATE
  568. 0, // SMB_COM_CHECK_DIRECTORY
  569. 0, // SMB_COM_PROCESS_EXIT
  570. 4, // SMB_COM_SEEK
  571. 5, // SMB_COM_LOCK_AND_READ
  572. 5, // SMB_COM_WRITE_AND_UNLOCK
  573. -2, // SMB_COM_ILLEGAL_COMMAND
  574. -2, // SMB_COM_ILLEGAL_COMMAND
  575. -2, // SMB_COM_ILLEGAL_COMMAND
  576. -2, // SMB_COM_ILLEGAL_COMMAND
  577. -2, // SMB_COM_ILLEGAL_COMMAND
  578. -1, // SMB_COM_READ_RAW
  579. 8, // SMB_COM_READ_MPX
  580. 8, // SMB_COM_READ_MPX_SECONDARY
  581. -1, // SMB_COM_WRITE_RAW
  582. 12, // SMB_COM_WRITE_MPX
  583. 12, // SMB_COM_WRITE_MPX_SECONDARY
  584. -2, // SMB_COM_ILLEGAL_COMMAND
  585. 1, // SMB_COM_QUERY_INFORMATION_SRV
  586. 7, // SMB_COM_SET_INFORMATION2
  587. 1, // SMB_COM_QUERY_INFORMATION2
  588. 8, // SMB_COM_LOCKING_ANDX
  589. -1, // SMB_COM_TRANSACTION
  590. 8, // SMB_COM_TRANSACTION_SECONDARY
  591. 14, // SMB_COM_IOCTL
  592. 8, // SMB_COM_IOCTL_SECONDARY
  593. 3, // SMB_COM_COPY
  594. 3, // SMB_COM_MOVE
  595. 1, // SMB_COM_ECHO
  596. -1, // SMB_COM_WRITE_AND_CLOSE
  597. 15, // SMB_COM_OPEN_ANDX
  598. -1, // SMB_COM_READ_ANDX
  599. -1, // SMB_COM_WRITE_ANDX
  600. 3, // SMB_COM_SET_NEW_SIZE
  601. 3, // SMB_COM_CLOSE_AND_TREE_DISC
  602. -1, // SMB_COM_TRANSACTION2
  603. 9, // SMB_COM_TRANSACTION2_SECONDARY
  604. 1, // SMB_COM_FIND_CLOSE2
  605. 1, // SMB_COM_FIND_NOTIFY_CLOSE
  606. -2, // SMB_COM_ILLEGAL_COMMAND
  607. -2, // SMB_COM_ILLEGAL_COMMAND
  608. -2, // SMB_COM_ILLEGAL_COMMAND
  609. -2, // SMB_COM_ILLEGAL_COMMAND
  610. -2, // SMB_COM_ILLEGAL_COMMAND
  611. -2, // SMB_COM_ILLEGAL_COMMAND
  612. -2, // SMB_COM_ILLEGAL_COMMAND
  613. -2, // SMB_COM_ILLEGAL_COMMAND
  614. -2, // SMB_COM_ILLEGAL_COMMAND
  615. -2, // SMB_COM_ILLEGAL_COMMAND
  616. -2, // SMB_COM_ILLEGAL_COMMAND
  617. -2, // SMB_COM_ILLEGAL_COMMAND
  618. -2, // SMB_COM_ILLEGAL_COMMAND
  619. -2, // SMB_COM_ILLEGAL_COMMAND
  620. -2, // SMB_COM_ILLEGAL_COMMAND
  621. -2, // SMB_COM_ILLEGAL_COMMAND
  622. -2, // SMB_COM_ILLEGAL_COMMAND
  623. -2, // SMB_COM_ILLEGAL_COMMAND
  624. -2, // SMB_COM_ILLEGAL_COMMAND
  625. -2, // SMB_COM_ILLEGAL_COMMAND
  626. -2, // SMB_COM_ILLEGAL_COMMAND
  627. -2, // SMB_COM_ILLEGAL_COMMAND
  628. -2, // SMB_COM_ILLEGAL_COMMAND
  629. -2, // SMB_COM_ILLEGAL_COMMAND
  630. -2, // SMB_COM_ILLEGAL_COMMAND
  631. -2, // SMB_COM_ILLEGAL_COMMAND
  632. -2, // SMB_COM_ILLEGAL_COMMAND
  633. -2, // SMB_COM_ILLEGAL_COMMAND
  634. -2, // SMB_COM_ILLEGAL_COMMAND
  635. -2, // SMB_COM_ILLEGAL_COMMAND
  636. -2, // SMB_COM_ILLEGAL_COMMAND
  637. -2, // SMB_COM_ILLEGAL_COMMAND
  638. -2, // SMB_COM_ILLEGAL_COMMAND
  639. -2, // SMB_COM_ILLEGAL_COMMAND
  640. -2, // SMB_COM_ILLEGAL_COMMAND
  641. -2, // SMB_COM_ILLEGAL_COMMAND
  642. -2, // SMB_COM_ILLEGAL_COMMAND
  643. -2, // SMB_COM_ILLEGAL_COMMAND
  644. -2, // SMB_COM_ILLEGAL_COMMAND
  645. -2, // SMB_COM_ILLEGAL_COMMAND
  646. -2, // SMB_COM_ILLEGAL_COMMAND
  647. -2, // SMB_COM_ILLEGAL_COMMAND
  648. -2, // SMB_COM_ILLEGAL_COMMAND
  649. -2, // SMB_COM_ILLEGAL_COMMAND
  650. -2, // SMB_COM_ILLEGAL_COMMAND
  651. -2, // SMB_COM_ILLEGAL_COMMAND
  652. -2, // SMB_COM_ILLEGAL_COMMAND
  653. -2, // SMB_COM_ILLEGAL_COMMAND
  654. -2, // SMB_COM_ILLEGAL_COMMAND
  655. -2, // SMB_COM_ILLEGAL_COMMAND
  656. -2, // SMB_COM_ILLEGAL_COMMAND
  657. -2, // SMB_COM_ILLEGAL_COMMAND
  658. -2, // SMB_COM_ILLEGAL_COMMAND
  659. -2, // SMB_COM_ILLEGAL_COMMAND
  660. -2, // SMB_COM_ILLEGAL_COMMAND
  661. -2, // SMB_COM_ILLEGAL_COMMAND
  662. -2, // SMB_COM_ILLEGAL_COMMAND
  663. -2, // SMB_COM_ILLEGAL_COMMAND
  664. 0, // SMB_COM_TREE_CONNECT
  665. 0, // SMB_COM_TREE_DISCONNECT
  666. 0, // SMB_COM_NEGOTIATE
  667. -1, // SMB_COM_SESSION_SETUP_ANDX
  668. 2, // SMB_COM_LOGOFF_ANDX
  669. 4, // SMB_COM_TREE_CONNECT_ANDX
  670. -2, // SMB_COM_ILLEGAL_COMMAND
  671. -2, // SMB_COM_ILLEGAL_COMMAND
  672. -2, // SMB_COM_ILLEGAL_COMMAND
  673. -2, // SMB_COM_ILLEGAL_COMMAND
  674. -2, // SMB_COM_ILLEGAL_COMMAND
  675. -2, // SMB_COM_ILLEGAL_COMMAND
  676. -2, // SMB_COM_ILLEGAL_COMMAND
  677. -2, // SMB_COM_ILLEGAL_COMMAND
  678. -2, // SMB_COM_ILLEGAL_COMMAND
  679. -2, // SMB_COM_ILLEGAL_COMMAND
  680. 0, // SMB_COM_QUERY_INFORMATION_DISK
  681. 2, // SMB_COM_SEARCH
  682. 2, // SMB_COM_SEARCH
  683. 2, // SMB_COM_SEARCH
  684. 2, // SMB_COM_SEARCH
  685. -2, // SMB_COM_ILLEGAL_COMMAND
  686. -2, // SMB_COM_ILLEGAL_COMMAND
  687. -2, // SMB_COM_ILLEGAL_COMMAND
  688. -2, // SMB_COM_ILLEGAL_COMMAND
  689. -2, // SMB_COM_ILLEGAL_COMMAND
  690. -2, // SMB_COM_ILLEGAL_COMMAND
  691. -2, // SMB_COM_ILLEGAL_COMMAND
  692. -2, // SMB_COM_ILLEGAL_COMMAND
  693. -2, // SMB_COM_ILLEGAL_COMMAND
  694. -2, // SMB_COM_ILLEGAL_COMMAND
  695. -2, // SMB_COM_ILLEGAL_COMMAND
  696. -2, // SMB_COM_ILLEGAL_COMMAND
  697. -2, // SMB_COM_ILLEGAL_COMMAND
  698. -2, // SMB_COM_ILLEGAL_COMMAND
  699. -2, // SMB_COM_ILLEGAL_COMMAND
  700. -2, // SMB_COM_ILLEGAL_COMMAND
  701. -2, // SMB_COM_ILLEGAL_COMMAND
  702. -2, // SMB_COM_ILLEGAL_COMMAND
  703. -2, // SMB_COM_ILLEGAL_COMMAND
  704. -2, // SMB_COM_ILLEGAL_COMMAND
  705. -2, // SMB_COM_ILLEGAL_COMMAND
  706. -2, // SMB_COM_ILLEGAL_COMMAND
  707. -2, // SMB_COM_ILLEGAL_COMMAND
  708. -2, // SMB_COM_ILLEGAL_COMMAND
  709. -2, // SMB_COM_ILLEGAL_COMMAND
  710. -2, // SMB_COM_ILLEGAL_COMMAND
  711. -2, // SMB_COM_ILLEGAL_COMMAND
  712. -1, // SMB_COM_NT_TRANSACT
  713. 18, // SMB_COM_NT_TRANSACT_SECONDARY
  714. 24, // SMB_COM_NT_CREATE_ANDX
  715. -2, // SMB_COM_ILLEGAL_COMMAND
  716. 0, // SMB_COM_NT_CANCEL
  717. 4, // SMB_COM_NT_RENAME
  718. -2, // SMB_COM_ILLEGAL_COMMAND
  719. -2, // SMB_COM_ILLEGAL_COMMAND
  720. -2, // SMB_COM_ILLEGAL_COMMAND
  721. -2, // SMB_COM_ILLEGAL_COMMAND
  722. -2, // SMB_COM_ILLEGAL_COMMAND
  723. -2, // SMB_COM_ILLEGAL_COMMAND
  724. -2, // SMB_COM_ILLEGAL_COMMAND
  725. -2, // SMB_COM_ILLEGAL_COMMAND
  726. -2, // SMB_COM_ILLEGAL_COMMAND
  727. -2, // SMB_COM_ILLEGAL_COMMAND
  728. -2, // SMB_COM_ILLEGAL_COMMAND
  729. -2, // SMB_COM_ILLEGAL_COMMAND
  730. -2, // SMB_COM_ILLEGAL_COMMAND
  731. -2, // SMB_COM_ILLEGAL_COMMAND
  732. -2, // SMB_COM_ILLEGAL_COMMAND
  733. -2, // SMB_COM_ILLEGAL_COMMAND
  734. -2, // SMB_COM_ILLEGAL_COMMAND
  735. -2, // SMB_COM_ILLEGAL_COMMAND
  736. -2, // SMB_COM_ILLEGAL_COMMAND
  737. -2, // SMB_COM_ILLEGAL_COMMAND
  738. -2, // SMB_COM_ILLEGAL_COMMAND
  739. -2, // SMB_COM_ILLEGAL_COMMAND
  740. -2, // SMB_COM_ILLEGAL_COMMAND
  741. -2, // SMB_COM_ILLEGAL_COMMAND
  742. -2, // SMB_COM_ILLEGAL_COMMAND
  743. -2, // SMB_COM_ILLEGAL_COMMAND
  744. 2, // SMB_COM_OPEN_PRINT_FILE
  745. 1, // SMB_COM_WRITE_PRINT_FILE
  746. 1, // SMB_COM_CLOSE_PRINT_FILE
  747. 2, // SMB_COM_GET_PRINT_QUEUE
  748. -2, // SMB_COM_ILLEGAL_COMMAND
  749. -2, // SMB_COM_ILLEGAL_COMMAND
  750. -2, // SMB_COM_ILLEGAL_COMMAND
  751. -2, // SMB_COM_ILLEGAL_COMMAND
  752. -2, // SMB_COM_ILLEGAL_COMMAND
  753. -2, // SMB_COM_ILLEGAL_COMMAND
  754. -2, // SMB_COM_ILLEGAL_COMMAND
  755. -2, // SMB_COM_ILLEGAL_COMMAND
  756. -2, // SMB_COM_ILLEGAL_COMMAND
  757. -2, // SMB_COM_ILLEGAL_COMMAND
  758. -2, // SMB_COM_ILLEGAL_COMMAND
  759. -2, // SMB_COM_ILLEGAL_COMMAND
  760. -2, // SMB_COM_SEND_MESSAGE
  761. -2, // SMB_COM_SEND_BROADCAST_MESSAGE
  762. -2, // SMB_COM_FORWARD_USER_NAME
  763. -2, // SMB_COM_CANCEL_FORWARD
  764. -2, // SMB_COM_GET_MACHINE_NAME
  765. -2, // SMB_COM_SEND_START_MB_MESSAGE
  766. -2, // SMB_COM_SEND_END_MB_MESSAGE
  767. -2, // SMB_COM_SEND_TEXT_MB_MESSAGE
  768. -2, // SMB_COM_ILLEGAL_COMMAND
  769. -2, // SMB_COM_ILLEGAL_COMMAND
  770. -2, // SMB_COM_ILLEGAL_COMMAND
  771. -2, // SMB_COM_ILLEGAL_COMMAND
  772. -2, // SMB_COM_ILLEGAL_COMMAND
  773. -2, // SMB_COM_ILLEGAL_COMMAND
  774. -2, // SMB_COM_ILLEGAL_COMMAND
  775. -2, // SMB_COM_ILLEGAL_COMMAND
  776. -2, // SMB_COM_ILLEGAL_COMMAND
  777. -2, // SMB_COM_ILLEGAL_COMMAND
  778. -2, // SMB_COM_ILLEGAL_COMMAND
  779. -2, // SMB_COM_ILLEGAL_COMMAND
  780. -2, // SMB_COM_ILLEGAL_COMMAND
  781. -2, // SMB_COM_ILLEGAL_COMMAND
  782. -2, // SMB_COM_ILLEGAL_COMMAND
  783. -2, // SMB_COM_ILLEGAL_COMMAND
  784. -2, // SMB_COM_ILLEGAL_COMMAND
  785. -2, // SMB_COM_ILLEGAL_COMMAND
  786. -2, // SMB_COM_ILLEGAL_COMMAND
  787. -2, // SMB_COM_ILLEGAL_COMMAND
  788. -2, // SMB_COM_ILLEGAL_COMMAND
  789. -2, // SMB_COM_ILLEGAL_COMMAND
  790. -2, // SMB_COM_ILLEGAL_COMMAND
  791. -2, // SMB_COM_ILLEGAL_COMMAND
  792. -2, // SMB_COM_ILLEGAL_COMMAND
  793. -2, // SMB_COM_ILLEGAL_COMMAND
  794. -2, // SMB_COM_ILLEGAL_COMMAND
  795. -2, // SMB_COM_ILLEGAL_COMMAND
  796. -2, // SMB_COM_ILLEGAL_COMMAND
  797. -2, // SMB_COM_ILLEGAL_COMMAND
  798. -2, // SMB_COM_ILLEGAL_COMMAND
  799. -2, // SMB_COM_ILLEGAL_COMMAND
  800. -2, // SMB_COM_ILLEGAL_COMMAND
  801. -2, // SMB_COM_ILLEGAL_COMMAND
  802. -2, // SMB_COM_ILLEGAL_COMMAND
  803. -2, // SMB_COM_ILLEGAL_COMMAND
  804. -2, // SMB_COM_ILLEGAL_COMMAND
  805. -2, // SMB_COM_ILLEGAL_COMMAND
  806. -2, // SMB_COM_ILLEGAL_COMMAND
  807. -2, // SMB_COM_ILLEGAL_COMMAND
  808. };
  809. //
  810. // SrvCanonicalNamedPipePrefix is "PIPE\".
  811. //
  812. UNICODE_STRING SrvCanonicalNamedPipePrefix = {0};
  813. //
  814. // The following is used to generate NT style pipe paths.
  815. //
  816. UNICODE_STRING SrvNamedPipeRootDirectory = {0};
  817. //
  818. // The following is used to generate NT style mailslot paths.
  819. //
  820. UNICODE_STRING SrvMailslotRootDirectory = {0};
  821. //
  822. // SrvTransaction2DispatchTable is the jump table for processing
  823. // Transaction2 SMBs.
  824. //
  825. PSMB_TRANSACTION_PROCESSOR SrvTransaction2DispatchTable[] = {
  826. SrvSmbOpen2,
  827. SrvSmbFindFirst2,
  828. SrvSmbFindNext2,
  829. SrvSmbQueryFsInformation,
  830. SrvSmbSetFsInformation,
  831. SrvSmbQueryPathInformation,
  832. SrvSmbSetPathInformation,
  833. SrvSmbQueryFileInformation,
  834. SrvSmbSetFileInformation,
  835. SrvSmbFsctl,
  836. SrvSmbIoctl2,
  837. SrvSmbFindNotify,
  838. SrvSmbFindNotify,
  839. SrvSmbCreateDirectory2,
  840. SrvTransactionNotImplemented, // Can be reused...
  841. SrvTransactionNotImplemented,
  842. SrvSmbGetDfsReferral,
  843. SrvSmbReportDfsInconsistency
  844. };
  845. //
  846. // SrvNtTransactionDispatchTable is the jump table for processing
  847. // NtTransaction SMBs.
  848. //
  849. PSMB_TRANSACTION_PROCESSOR SrvNtTransactionDispatchTable[ NT_TRANSACT_MAX_FUNCTION+1 ] = {
  850. NULL,
  851. SrvSmbCreateWithSdOrEa,
  852. SrvSmbNtIoctl,
  853. SrvSmbSetSecurityDescriptor,
  854. SrvSmbNtNotifyChange,
  855. SrvSmbNtRename,
  856. SrvSmbQuerySecurityDescriptor,
  857. SrvSmbQueryQuota,
  858. SrvSmbSetQuota
  859. };
  860. //
  861. // Global variables for server statistics.
  862. //
  863. SRV_STATISTICS SrvStatistics = {0};
  864. #if SRVDBG_STATS || SRVDBG_STATS2
  865. SRV_STATISTICS_DEBUG SrvDbgStatistics = {0};
  866. #endif
  867. //
  868. // The number of abortive disconnects that the server has gotten
  869. //
  870. ULONG SrvAbortiveDisconnects = 0;
  871. //
  872. // The number of memory retries, and how often they were successful
  873. //
  874. LONG SrvMemoryAllocationRetries = 0;
  875. LONG SrvMemoryAllocationRetriesSuccessful = 0;
  876. //
  877. // Server environment information strings.
  878. //
  879. UNICODE_STRING SrvNativeOS = {0};
  880. OEM_STRING SrvOemNativeOS = {0};
  881. UNICODE_STRING SrvNativeLanMan = {0};
  882. OEM_STRING SrvOemNativeLanMan = {0};
  883. UNICODE_STRING SrvSystemRoot = {0};
  884. //
  885. // The following will be a permanent handle and device object pointer
  886. // to NPFS.
  887. //
  888. HANDLE SrvNamedPipeHandle = NULL;
  889. PDEVICE_OBJECT SrvNamedPipeDeviceObject = NULL;
  890. PFILE_OBJECT SrvNamedPipeFileObject = NULL;
  891. //
  892. // The following are used to converse with the Dfs driver
  893. //
  894. PFAST_IO_DEVICE_CONTROL SrvDfsFastIoDeviceControl = NULL;
  895. PDEVICE_OBJECT SrvDfsDeviceObject = NULL;
  896. PFILE_OBJECT SrvDfsFileObject = NULL;
  897. //
  898. // The following will be a permanent handle and device object pointer
  899. // to MSFS.
  900. //
  901. HANDLE SrvMailslotHandle = NULL;
  902. PDEVICE_OBJECT SrvMailslotDeviceObject = NULL;
  903. PFILE_OBJECT SrvMailslotFileObject = NULL;
  904. //
  905. // Flag indicating XACTSRV whether is active, and resource synchronizing
  906. // access to XACTSRV-related variabled.
  907. //
  908. BOOLEAN SrvXsActive = FALSE;
  909. ERESOURCE SrvXsResource = {0};
  910. //
  911. // Handle to the unnamed shared memory and communication port used for
  912. // communication between the server and XACTSRV.
  913. //
  914. HANDLE SrvXsSectionHandle = NULL;
  915. HANDLE SrvXsPortHandle = NULL;
  916. //
  917. // Pointers to control the unnamed shared memory for the XACTSRV LPC port.
  918. // The port memory heap handle is initialized to NULL to indicate that
  919. // there is no connection with XACTSRV yet.
  920. //
  921. PVOID SrvXsPortMemoryBase = NULL;
  922. ULONG_PTR SrvXsPortMemoryDelta = 0;
  923. PVOID SrvXsPortMemoryHeap = NULL;
  924. //
  925. // Pointer to heap header for the special XACTSRV shared-memory heap.
  926. //
  927. PVOID SrvXsHeap = NULL;
  928. //
  929. // Dispatch table for server APIs. APIs are dispatched based on the
  930. // control code passed to NtFsControlFile.
  931. //
  932. // *** The order here must match the order of API codes defined in
  933. // net\inc\srvfsctl.h!
  934. PAPI_PROCESSOR SrvApiDispatchTable[] = {
  935. SrvNetConnectionEnum,
  936. SrvNetFileClose,
  937. SrvNetFileEnum,
  938. SrvNetServerDiskEnum,
  939. SrvNetServerSetInfo,
  940. SrvNetServerTransportAdd,
  941. SrvNetServerTransportDel,
  942. SrvNetServerTransportEnum,
  943. SrvNetSessionDel,
  944. SrvNetSessionEnum,
  945. SrvNetShareAdd,
  946. SrvNetShareDel,
  947. SrvNetShareEnum,
  948. SrvNetShareSetInfo,
  949. SrvNetStatisticsGet
  950. };
  951. //
  952. // Names for the various types of clients. This array corresponds to
  953. // the SMB_DIALECT enumerated type.
  954. //
  955. UNICODE_STRING SrvClientTypes[LAST_DIALECT] = {0};
  956. //
  957. // All the resumable Enum APIs use ordered lists for context-free
  958. // resume. All data blocks in the server that correspond to return
  959. // information for Enum APIs are maintained in ordered lists.
  960. //
  961. SRV_LOCK SrvOrderedListLock = {0};
  962. ORDERED_LIST_HEAD SrvEndpointList = {0};
  963. ORDERED_LIST_HEAD SrvRfcbList = {0};
  964. ORDERED_LIST_HEAD SrvSessionList = {0};
  965. ORDERED_LIST_HEAD SrvTreeConnectList = {0};
  966. //
  967. // The DNS name for the domain
  968. //
  969. PUNICODE_STRING SrvDnsDomainName = NULL;
  970. //
  971. // To synchronize server shutdown with API requests handled in the
  972. // server FSD, we track the number of outstanding API requests. The
  973. // shutdown code waits until all APIs have been completed to start
  974. // termination.
  975. //
  976. // SrvApiRequestCount tracks the active APIs in the FSD.
  977. // SrvApiCompletionEvent is set by the last API to complete, and the
  978. // shutdown code waits on it if there are outstanding APIs.
  979. //
  980. ULONG SrvApiRequestCount = 0;
  981. KEVENT SrvApiCompletionEvent = {0};
  982. //
  983. // Security data for logging on remote users. SrvLsaHandle is the logon
  984. // process handle that we use in calls to LsaLogonUser.
  985. // SrvSystemSecurityMode contains the secutity mode the system is
  986. // running in. SrvAuthenticationPackage is a token that describes the
  987. // authentication package being used. SrvNullSessionToken is a cached
  988. // token handle representing the null session.
  989. //
  990. CtxtHandle SrvNullSessionToken = {0, 0};
  991. CtxtHandle SrvLmLsaHandle = {0, 0};
  992. CtxtHandle SrvExtensibleSecurityHandle = {0, 0};
  993. //
  994. // Security descriptor granting Administrator READ access.
  995. // Used to see if a client has administrative privileges
  996. //
  997. SECURITY_DESCRIPTOR SrvAdminSecurityDescriptor;
  998. //
  999. // Security descriptor granting Anonymous READ access.
  1000. // Used to see if a client was an anonymous (null session) logon
  1001. //
  1002. SECURITY_DESCRIPTOR SrvNullSessionSecurityDescriptor;
  1003. //
  1004. // A list of SMBs waiting for an oplock break to occur, before they can
  1005. // proceed, and a lock to protect the list.
  1006. //
  1007. LIST_ENTRY SrvWaitForOplockBreakList = {0};
  1008. SRV_LOCK SrvOplockBreakListLock = {0};
  1009. //
  1010. // A list of outstanding oplock break requests. The list is protected by
  1011. // SrvOplockBreakListLock.
  1012. //
  1013. LIST_ENTRY SrvOplockBreaksInProgressList = {0};
  1014. //
  1015. // Global security context. Use static tracking.
  1016. //
  1017. SECURITY_QUALITY_OF_SERVICE SrvSecurityQOS = {0};
  1018. //
  1019. // A BOOLEAN to indicate whether the server is paused. If paused, the
  1020. // server will not accept new tree connections from non-admin users.
  1021. //
  1022. BOOLEAN SrvPaused = FALSE;
  1023. //
  1024. // Alerting information.
  1025. //
  1026. SRV_ERROR_RECORD SrvErrorRecord = {0};
  1027. SRV_ERROR_RECORD SrvNetworkErrorRecord = {0};
  1028. BOOLEAN SrvDiskAlertRaised[26] = {0};
  1029. //
  1030. // Counts of the number of times pool allocations have failed because
  1031. // the server was at its configured pool limit.
  1032. //
  1033. ULONG SrvNonPagedPoolLimitHitCount = 0;
  1034. ULONG SrvPagedPoolLimitHitCount = 0;
  1035. //
  1036. // SrvOpenCount counts the number of active opens of the server device.
  1037. // This is used at server shutdown time to determine whether the server
  1038. // service should unload the driver.
  1039. //
  1040. ULONG SrvOpenCount = 0;
  1041. //
  1042. // Counters for logging resource shortage events during a scavenger pass.
  1043. //
  1044. ULONG SrvOutOfFreeConnectionCount = 0;
  1045. ULONG SrvOutOfRawWorkItemCount = 0;
  1046. ULONG SrvFailedBlockingIoCount = 0;
  1047. //
  1048. // Current core search timeout time in seconds
  1049. //
  1050. ULONG SrvCoreSearchTimeout = 0;
  1051. SRV_LOCK SrvUnlockableCodeLock = {0};
  1052. SECTION_DESCRIPTOR SrvSectionInfo[SRV_CODE_SECTION_MAX] = {
  1053. { SrvSmbRead, NULL, 0 }, // pageable code -- locked
  1054. // only and always on NTAS
  1055. { SrvCheckAndReferenceRfcb, NULL, 0 } // 8FIL section -- locked
  1056. // when files are open
  1057. };
  1058. //
  1059. // SrvTimerList is a pool of timer/DPC structures available for use by
  1060. // code that needs to start a timer.
  1061. //
  1062. SLIST_HEADER SrvTimerList = {0};
  1063. //
  1064. // Name that should be displayed when doing a server alert.
  1065. //
  1066. PWSTR SrvAlertServiceName = NULL;
  1067. //
  1068. // Variable to store the number of tick counts for 5 seconds
  1069. //
  1070. ULONG SrvFiveSecondTickCount = 0;
  1071. //
  1072. // Flag indicating whether or not we need to filter extended characters
  1073. // out of 8.3 names ourselves.
  1074. //
  1075. BOOLEAN SrvFilterExtendedCharsInPath = FALSE;
  1076. //
  1077. // Flag indicating if we enforce all logoff times
  1078. //
  1079. BOOLEAN SrvEnforceLogoffTimes = FALSE;
  1080. //
  1081. // Holds the TDI PNP notification handle
  1082. //
  1083. HANDLE SrvTdiNotificationHandle = 0;
  1084. //
  1085. // Flag indicating whether or not SMB security signatures are enabled.
  1086. //
  1087. BOOLEAN SrvSmbSecuritySignaturesEnabled = FALSE;
  1088. //
  1089. // Flag indicating whether or not SMB security signatures are required. The signature
  1090. // must match between the client and the server for the smb to be accepted.
  1091. //
  1092. BOOLEAN SrvSmbSecuritySignaturesRequired = FALSE;
  1093. //
  1094. // Flag indicating whether or not SMB security signatures should be applied to W9x
  1095. // clients.
  1096. //
  1097. BOOLEAN SrvEnableW9xSecuritySignatures = FALSE;
  1098. //
  1099. // Maximum amount of data that we'll allocate to support a METHOD_NEITHER Fsctl call
  1100. //
  1101. ULONG SrvMaxFsctlBufferSize = 70*1024;
  1102. //
  1103. // Maximum NT transaction size which we'll accept.
  1104. //
  1105. ULONG SrvMaxNtTransactionSize = 70*1024;
  1106. //
  1107. // Maximum size of large Read&X that we'll allow. We need to lock down a cache region
  1108. // to service this request, so we don't want it to get too big
  1109. //
  1110. ULONG SrvMaxReadSize = 64*1024;
  1111. //
  1112. // Maximum size of a compressed write that we'll allow. We need to lock down a cache
  1113. // region to service this request, so we dont' want it to get too big.
  1114. //
  1115. ULONG SrvMaxCompressedDataLength = 64*1024;
  1116. //
  1117. // When we receive an uncompressed large write from a client, we receive it in chunks,
  1118. // locking & unlocking the file cache as we receive the data. SrvMaxWriteChunk is the
  1119. // size of this 'chunk'. There's no magic to this chosen value.
  1120. //
  1121. ULONG SrvMaxWriteChunk = 64 * 1024;
  1122. //
  1123. // Handle used for PoRegisterSystemState calls
  1124. //
  1125. PVOID SrvPoRegistrationState = NULL;
  1126. //
  1127. // Counter used to suppress extraneous PoRegisterSystemStateCalls
  1128. //
  1129. ULONG SrvIdleCount = 0;
  1130. //
  1131. // If a server worker threads remains idle for this many ticks, then it terminate
  1132. //
  1133. LONGLONG SrvIdleThreadTimeOut = 0;
  1134. //
  1135. // Denial-of-Service monitoring and logging controls
  1136. //
  1137. LARGE_INTEGER SrvLastDosAttackTime = {0};
  1138. ULONG SrvDOSAttacks = 0;
  1139. BOOLEAN SrvLogEventOnDOS = TRUE;
  1140. #if SRVNTVERCHK
  1141. //
  1142. // This is the minimum NT5 client build number that we will allow to connect to the server
  1143. //
  1144. ULONG SrvMinNT5Client = 0;
  1145. BOOLEAN SrvMinNT5ClientIPCToo = FALSE;
  1146. //
  1147. // To force upgrades of our internal development community, we can set a
  1148. // value in the registry that governs the minimum NT release that we allow
  1149. // people to run to connect to this server. However, some folks have special
  1150. // needs that preclude a forced upgrade. Presuming they have a static IP address,
  1151. // you can add their address to the registry to exclude them from the build number
  1152. // checking logic
  1153. //
  1154. DWORD SrvAllowIPAddress[25];
  1155. #endif
  1156. //
  1157. // These are used to track persistent connections/handles. The counters are
  1158. // assigned to RFCBs, connections, and sessions.
  1159. //
  1160. #ifdef INCLUDE_SMB_PERSISTENT
  1161. ULONG SrvGlobalPersistentSessionId = 0;
  1162. ULONG SrvGlobalPersistentRfcbId = 0;
  1163. #endif
  1164. VOID
  1165. SrvInitializeData (
  1166. VOID
  1167. )
  1168. /*++
  1169. Routine Description:
  1170. This is the initialization routine for data defined in this module.
  1171. Arguments:
  1172. None.
  1173. Return Value:
  1174. None.
  1175. --*/
  1176. {
  1177. ULONG i,j;
  1178. ANSI_STRING string;
  1179. PAGED_CODE( );
  1180. #if MULTIPROCESSOR
  1181. SrvMultiProcessorDriver = TRUE;
  1182. #endif
  1183. //
  1184. // Initialize the statistics database.
  1185. //
  1186. RtlZeroMemory( &SrvStatistics, sizeof(SrvStatistics) );
  1187. #if SRVDBG_STATS || SRVDBG_STATS2
  1188. RtlZeroMemory( &SrvDbgStatistics, sizeof(SrvDbgStatistics) );
  1189. #endif
  1190. //
  1191. // Store the address of the initial system process for later use.
  1192. //
  1193. SrvServerProcess = IoGetCurrentProcess();
  1194. //
  1195. // Store the number of processors
  1196. //
  1197. SrvNumberOfProcessors = KeNumberProcessors;
  1198. //
  1199. // Initialize the event used to determine when all endpoints have
  1200. // closed.
  1201. //
  1202. KeInitializeEvent( &SrvEndpointEvent, SynchronizationEvent, FALSE );
  1203. //
  1204. // Initialize the event used to deterine when all API requests have
  1205. // completed.
  1206. //
  1207. KeInitializeEvent( &SrvApiCompletionEvent, SynchronizationEvent, FALSE );
  1208. //
  1209. // Allocate the spin lock used to synchronize between the FSD and
  1210. // the FSP.
  1211. //
  1212. INITIALIZE_GLOBAL_SPIN_LOCK( Fsd );
  1213. #if SRVDBG || SRVDBG_HANDLES
  1214. INITIALIZE_GLOBAL_SPIN_LOCK( Debug );
  1215. #endif
  1216. INITIALIZE_GLOBAL_SPIN_LOCK( Statistics );
  1217. //
  1218. // Initialize various (non-spin) locks.
  1219. //
  1220. INITIALIZE_LOCK(
  1221. &SrvConfigurationLock,
  1222. CONFIGURATION_LOCK_LEVEL,
  1223. "SrvConfigurationLock"
  1224. );
  1225. INITIALIZE_LOCK(
  1226. &SrvStartupShutdownLock,
  1227. STARTUPSHUTDOWN_LOCK_LEVEL,
  1228. "SrvStartupShutdownLock"
  1229. );
  1230. INITIALIZE_LOCK(
  1231. &SrvEndpointLock,
  1232. ENDPOINT_LOCK_LEVEL,
  1233. "SrvEndpointLock"
  1234. );
  1235. for( i=0; i < NMFCB_HASH_TABLE_LOCKS; i++ ) {
  1236. INITIALIZE_LOCK(
  1237. &SrvMfcbHashTableLocks[i],
  1238. MFCB_LIST_LOCK_LEVEL,
  1239. "SrvMfcbListLock"
  1240. );
  1241. }
  1242. INITIALIZE_LOCK(
  1243. &SrvShareLock,
  1244. SHARE_LOCK_LEVEL,
  1245. "SrvShareLock"
  1246. );
  1247. INITIALIZE_LOCK(
  1248. &SrvOplockBreakListLock,
  1249. OPLOCK_LIST_LOCK_LEVEL,
  1250. "SrvOplockBreakListLock"
  1251. );
  1252. #if SRVDBG || SRVDBG_HANDLES
  1253. INITIALIZE_LOCK(
  1254. &SrvDebugLock,
  1255. DEBUG_LOCK_LEVEL,
  1256. "SrvDebugLock"
  1257. );
  1258. #endif
  1259. //
  1260. // Create the resource serializing access to the XACTSRV port. This
  1261. // resource protects access to the shared memory reference count and
  1262. // the shared memory heap.
  1263. //
  1264. ExInitializeResourceLite( &SrvXsResource );
  1265. //
  1266. // Initialize the need resource queue
  1267. //
  1268. InitializeListHead( &SrvNeedResourceQueue );
  1269. //
  1270. // Initialize the connection disconnect queue
  1271. //
  1272. InitializeListHead( &SrvDisconnectQueue );
  1273. //
  1274. // Initialize the configuration queue.
  1275. //
  1276. InitializeListHead( &SrvConfigurationWorkQueue );
  1277. //
  1278. // Initialize the orphan queue
  1279. //
  1280. ExInitializeSListHead( &SrvBlockOrphanage );
  1281. //
  1282. // Initialize the Timer List
  1283. //
  1284. ExInitializeSListHead( &SrvTimerList );
  1285. //
  1286. // Initialize the resource thread work item and continuation event.
  1287. // (Note that this is a notification [non-autoclearing] event.)
  1288. //
  1289. ExInitializeWorkItem(
  1290. &SrvResourceThreadWorkItem,
  1291. SrvResourceThread,
  1292. NULL
  1293. );
  1294. //
  1295. // Initialize global lists.
  1296. //
  1297. for( i=j=0; i < NMFCB_HASH_TABLE; i++ ) {
  1298. InitializeListHead( &SrvMfcbHashTable[i].List );
  1299. SrvMfcbHashTable[i].Lock = &SrvMfcbHashTableLocks[ j ];
  1300. if( ++j == NMFCB_HASH_TABLE_LOCKS ) {
  1301. j = 0;
  1302. }
  1303. }
  1304. for( i=0; i < NSHARE_HASH_TABLE; i++ ) {
  1305. InitializeListHead( &SrvShareHashTable[i] );
  1306. }
  1307. //
  1308. // Initialize the ordered list lock. Indicate that the ordered
  1309. // lists have not yet been initialized, so that TerminateServer can
  1310. // determine whether to delete them.
  1311. //
  1312. INITIALIZE_LOCK(
  1313. &SrvOrderedListLock,
  1314. ORDERED_LIST_LOCK_LEVEL,
  1315. "SrvOrderedListLock"
  1316. );
  1317. SrvEndpointList.Initialized = FALSE;
  1318. SrvRfcbList.Initialized = FALSE;
  1319. SrvSessionList.Initialized = FALSE;
  1320. SrvTreeConnectList.Initialized = FALSE;
  1321. //
  1322. // Initialize the unlockable code package lock.
  1323. //
  1324. INITIALIZE_LOCK(
  1325. &SrvUnlockableCodeLock,
  1326. UNLOCKABLE_CODE_LOCK_LEVEL,
  1327. "SrvUnlockableCodeLock"
  1328. );
  1329. //
  1330. // Initialize the waiting for oplock break to occur list, and the
  1331. // oplock breaks in progress list.
  1332. //
  1333. InitializeListHead( &SrvWaitForOplockBreakList );
  1334. InitializeListHead( &SrvOplockBreaksInProgressList );
  1335. //
  1336. // The default security quality of service for non NT clients.
  1337. //
  1338. SrvSecurityQOS.ImpersonationLevel = SecurityImpersonation;
  1339. SrvSecurityQOS.ContextTrackingMode = SECURITY_STATIC_TRACKING;
  1340. SrvSecurityQOS.EffectiveOnly = FALSE;
  1341. //
  1342. // Initialize Unicode strings.
  1343. //
  1344. RtlInitString( &string, StrPipeSlash );
  1345. RtlAnsiStringToUnicodeString(
  1346. &SrvCanonicalNamedPipePrefix,
  1347. &string,
  1348. TRUE
  1349. );
  1350. RtlInitUnicodeString( &SrvNamedPipeRootDirectory, StrNamedPipeDevice );
  1351. RtlInitUnicodeString( &SrvMailslotRootDirectory, StrMailslotDevice );
  1352. //
  1353. // The server's name
  1354. //
  1355. RtlInitUnicodeString( &SrvNativeLanMan, StrNativeLanman );
  1356. RtlInitAnsiString( (PANSI_STRING)&SrvOemNativeLanMan, StrNativeLanmanOem );
  1357. //
  1358. // The system root
  1359. //
  1360. #if defined(i386)
  1361. RtlInitUnicodeString( &SrvSystemRoot, SharedUserData->NtSystemRoot );
  1362. #endif
  1363. //
  1364. // Debug logic to verify the contents of SrvApiDispatchTable (see
  1365. // inititialization earlier in this module).
  1366. //
  1367. ASSERT( SRV_API_INDEX(FSCTL_SRV_MAX_API_CODE) + 1 ==
  1368. sizeof(SrvApiDispatchTable) / sizeof(PAPI_PROCESSOR) );
  1369. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1370. FSCTL_SRV_NET_CONNECTION_ENUM)] == SrvNetConnectionEnum );
  1371. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1372. FSCTL_SRV_NET_FILE_CLOSE)] == SrvNetFileClose );
  1373. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1374. FSCTL_SRV_NET_FILE_ENUM)] == SrvNetFileEnum );
  1375. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1376. FSCTL_SRV_NET_SERVER_DISK_ENUM)] == SrvNetServerDiskEnum );
  1377. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1378. FSCTL_SRV_NET_SERVER_SET_INFO)] == SrvNetServerSetInfo );
  1379. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1380. FSCTL_SRV_NET_SERVER_XPORT_ADD)] == SrvNetServerTransportAdd );
  1381. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1382. FSCTL_SRV_NET_SERVER_XPORT_DEL)] == SrvNetServerTransportDel );
  1383. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1384. FSCTL_SRV_NET_SERVER_XPORT_ENUM)] == SrvNetServerTransportEnum );
  1385. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1386. FSCTL_SRV_NET_SESSION_DEL)] == SrvNetSessionDel );
  1387. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1388. FSCTL_SRV_NET_SESSION_ENUM)] == SrvNetSessionEnum );
  1389. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1390. FSCTL_SRV_NET_SHARE_ADD)] == SrvNetShareAdd );
  1391. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1392. FSCTL_SRV_NET_SHARE_DEL)] == SrvNetShareDel );
  1393. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1394. FSCTL_SRV_NET_SHARE_ENUM)] == SrvNetShareEnum );
  1395. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1396. FSCTL_SRV_NET_SHARE_SET_INFO)] == SrvNetShareSetInfo );
  1397. ASSERT( SrvApiDispatchTable[SRV_API_INDEX(
  1398. FSCTL_SRV_NET_STATISTICS_GET)] == SrvNetStatisticsGet );
  1399. //
  1400. // Setup error log records
  1401. //
  1402. SrvErrorRecord.AlertNumber = ALERT_ErrorLog;
  1403. SrvNetworkErrorRecord.AlertNumber = ALERT_NetIO;
  1404. //
  1405. // Names for the various types of clients. This array corresponds
  1406. // to the SMB_DIALECT enumerated type.
  1407. //
  1408. for ( i = 0; i <= SmbDialectMsNet30; i++ ) {
  1409. RtlInitUnicodeString( &SrvClientTypes[i], StrClientTypes[i] );
  1410. }
  1411. for ( ; i < LAST_DIALECT; i++ ) {
  1412. SrvClientTypes[i] = SrvClientTypes[i-1]; // "DOWN LEVEL"
  1413. }
  1414. //
  1415. // Initialize the timer pool.
  1416. //
  1417. INITIALIZE_GLOBAL_SPIN_LOCK( Timer );
  1418. //
  1419. // Initialize the 4 endpoint spinlocks
  1420. //
  1421. for ( i = 0 ; i < ENDPOINT_LOCK_COUNT ; i++ ) {
  1422. INITIALIZE_SPIN_LOCK( &ENDPOINT_SPIN_LOCK(i) );
  1423. }
  1424. //KeSetSpecialSpinLock( &ENDPOINT_SPIN_LOCK(0), "endpoint 0 " );
  1425. //KeSetSpecialSpinLock( &ENDPOINT_SPIN_LOCK(1), "endpoint 1 " );
  1426. //KeSetSpecialSpinLock( &ENDPOINT_SPIN_LOCK(2), "endpoint 2 " );
  1427. //KeSetSpecialSpinLock( &ENDPOINT_SPIN_LOCK(3), "endpoint 3 " );
  1428. //
  1429. // Initialize the DMA alignment size
  1430. //
  1431. SrvCacheLineSize = KeGetRecommendedSharedDataAlignment(); // For PERF improvement, get the recommended cacheline
  1432. // alignment, instead of the HAL default
  1433. #if SRVDBG
  1434. {
  1435. ULONG cls = SrvCacheLineSize;
  1436. while ( cls > 2 ) {
  1437. ASSERTMSG(
  1438. "SRV: cache line size not a power of two",
  1439. (cls & 1) == 0 );
  1440. cls = cls >> 1;
  1441. }
  1442. }
  1443. #endif
  1444. if ( SrvCacheLineSize < 8 ) SrvCacheLineSize = 8;
  1445. SrvCacheLineSize--;
  1446. //
  1447. // Compute the number of tick counts for 5 seconds
  1448. //
  1449. SrvFiveSecondTickCount = 5*10*1000*1000 / KeQueryTimeIncrement();
  1450. return;
  1451. } // SrvInitializeData
  1452. VOID
  1453. SrvTerminateData (
  1454. VOID
  1455. )
  1456. /*++
  1457. Routine Description:
  1458. This is the rundown routine for data defined in this module. It is
  1459. called when the server driver is unloaded.
  1460. Arguments:
  1461. None.
  1462. Return Value:
  1463. None.
  1464. --*/
  1465. {
  1466. ULONG i;
  1467. PAGED_CODE( );
  1468. //
  1469. // Clean up SmbTrace.
  1470. //
  1471. SmbTraceTerminate( SMBTRACE_SERVER );
  1472. //
  1473. // Terminate various (non-spin) locks.
  1474. //
  1475. DELETE_LOCK( &SrvConfigurationLock );
  1476. DELETE_LOCK( &SrvStartupShutdownLock );
  1477. DELETE_LOCK( &SrvEndpointLock );
  1478. for( i=0; i < NMFCB_HASH_TABLE_LOCKS; i++ ) {
  1479. DELETE_LOCK( &SrvMfcbHashTableLocks[i] );
  1480. }
  1481. DELETE_LOCK( &SrvShareLock );
  1482. DELETE_LOCK( &SrvOplockBreakListLock );
  1483. #if SRVDBG || SRVDBG_HANDLES
  1484. DELETE_LOCK( &SrvDebugLock );
  1485. #endif
  1486. DELETE_LOCK( &SrvOrderedListLock );
  1487. DELETE_LOCK( &SrvUnlockableCodeLock );
  1488. ExDeleteResourceLite( &SrvXsResource );
  1489. RtlFreeUnicodeString( &SrvCanonicalNamedPipePrefix );
  1490. RtlFreeUnicodeString( &SrvComputerName );
  1491. } // SrvTerminateData