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.

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