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.

554 lines
8.2 KiB

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <nt.h>
  5. #include <ntrtl.h>
  6. #include <ntddcdrm.h>
  7. #include <ntdddisk.h>
  8. extern BOOLEAN SynchronousCmds;
  9. extern ULONG (*DbgPrintLocation)(PCH Format,...);
  10. ULONG
  11. GetLastError(
  12. VOID
  13. );
  14. HANDLE
  15. CreateThread(
  16. IN PVOID lpThreadAttributes,
  17. IN ULONG dwStackSize,
  18. IN PVOID lpStartAddress,
  19. IN PVOID lpParameter,
  20. IN ULONG dwCreationFlags,
  21. OUT PVOID lpThreadId
  22. );
  23. #define FlagOn( Flags,SingleFlag ) ( \
  24. (BOOLEAN)(((Flags) & (SingleFlag)) != 0 ? TRUE : FALSE) \
  25. )
  26. //
  27. // Shell constants
  28. //
  29. #define SHELL_UNKNOWN 0
  30. #define SHELL_EXIT 1
  31. #define SHELL_OPEN 2
  32. #define SHELL_CLEAR_BUFFER 3
  33. #define SHELL_DISPLAY_BYTES 4
  34. #define SHELL_COPY_BUFFER 5
  35. #define SHELL_ALLOC_MEM 6
  36. #define SHELL_DEALLOC_MEM 7
  37. #define SHELL_PUT_EA 8
  38. #define SHELL_FILL_EA 9
  39. #define SHELL_DISPLAY_HANDLE 10
  40. #define SHELL_CLOSE_HANDLE 11
  41. #define SHELL_READ_FILE 12
  42. #define SHELL_PAUSE 13
  43. #define SHELL_QUERY_EAS 14
  44. #define SHELL_SET_EAS 15
  45. #define SHELL_BREAK 16
  46. #define SHELL_OPLOCK 17
  47. #define SHELL_WRITE 18
  48. #define SHELL_QDIR 19
  49. #define SHELL_DISPLAY_QDIR 20
  50. #define SHELL_QFILE 21
  51. #define SHELL_DISPLAY_QFILE 22
  52. #define SHELL_NOTIFY_CHANGE 23
  53. #define SHELL_ENTER_TIME 24
  54. #define SHELL_DISPLAY_TIME 25
  55. #define SHELL_SETFILE 26
  56. #define SHELL_QUERY_VOLUME 27
  57. #define SHELL_DISPLAY_QVOL 28
  58. #define SHELL_SET_VOLUME 29
  59. #define SHELL_FSCTRL 30
  60. #define SHELL_IOCTL 31
  61. #define SHELL_CANCEL_IO 32
  62. #define SHELL_SPARSE 33
  63. #define SHELL_USN 34
  64. #define SHELL_FILL_BUFFER 35
  65. #define SHELL_FILL_BUFFER_USN 36
  66. #define SHELL_DISPLAY_WORDS 37
  67. #define SHELL_DISPLAY_DWORDS 38
  68. #define SHELL_REPARSE 39
  69. #define try_return(S) { S; goto try_exit; }
  70. #define bprint (*DbgPrintLocation)(
  71. //
  72. // Support routines contained in prmptsup.c
  73. //
  74. PCHAR
  75. SwallowNonWhite (
  76. IN PCHAR Ptr,
  77. OUT PULONG Count
  78. );
  79. PCHAR
  80. SwallowWhite (
  81. IN PCHAR Ptr,
  82. OUT PULONG Count
  83. );
  84. ULONG
  85. AnalyzeBuffer (
  86. PCHAR *BuffPtr,
  87. PULONG ParamStringLen
  88. );
  89. BOOLEAN
  90. ExtractCmd (
  91. PCHAR *BufferPtr,
  92. PULONG BufferLen
  93. );
  94. VOID
  95. CommandSummary ();
  96. //
  97. // Routines contained in topen.c
  98. //
  99. VOID
  100. InputOpenFile(
  101. IN PCHAR ParamBuffer
  102. );
  103. #define ROUND_UP( x, y ) ((ULONG)(x) + ((y)-1) & ~((y)-1))
  104. //
  105. // Routines contained in tbuffer.c
  106. //
  107. #define MAX_BUFFERS 200
  108. typedef struct _BUFFER_ELEMENT {
  109. PCHAR Buffer;
  110. ULONG Length;
  111. BOOLEAN Used;
  112. } BUFFER_ELEMENT, *PBUFFER_ELEMENT;
  113. extern BUFFER_ELEMENT Buffers[MAX_BUFFERS];
  114. extern HANDLE BufferEvent;
  115. VOID
  116. InitBuffers (
  117. );
  118. VOID
  119. UninitBuffers (
  120. );
  121. NTSTATUS
  122. AllocateBuffer (
  123. IN ULONG ZeroBits,
  124. IN OUT PSIZE_T RegionSize,
  125. OUT PULONG BufferIndex
  126. );
  127. NTSTATUS
  128. DeallocateBuffer (
  129. IN ULONG Index
  130. );
  131. BOOLEAN
  132. BufferInfo (
  133. IN ULONG Index,
  134. OUT PVOID *BufferAddress,
  135. OUT PULONG RegionSize
  136. );
  137. VOID
  138. InputClearBuffer(
  139. IN PCHAR ParamBuffer
  140. );
  141. VOID
  142. InputDisplayBuffer(
  143. IN PCHAR ParamBuffer,
  144. IN ULONG DisplaySize
  145. );
  146. VOID
  147. InputCopyBuffer(
  148. IN PCHAR ParamBuffer
  149. );
  150. VOID
  151. InputAllocMem(
  152. IN PCHAR ParamBuffer
  153. );
  154. VOID
  155. InputDeallocMem(
  156. IN PCHAR ParamBuffer
  157. );
  158. VOID
  159. InputFillBuffer(
  160. IN PCHAR ParamBuffer
  161. );
  162. VOID
  163. InputFillBufferUsn(
  164. IN PCHAR ParamBuffer
  165. );
  166. //
  167. // Ea routines contained in tea.c
  168. //
  169. VOID
  170. InputPutEaName(
  171. IN PCHAR ParamBuffer
  172. );
  173. VOID
  174. InputFillEaBuffer(
  175. IN PCHAR ParamBuffer
  176. );
  177. VOID
  178. InputQueryEa(
  179. IN PCHAR ParamBuffer
  180. );
  181. VOID
  182. InputSetEa(
  183. IN PCHAR ParamBuffer
  184. );
  185. //
  186. // Routines contained in thandle.c
  187. //
  188. #define MAX_HANDLES 200
  189. typedef struct _HANDLE_ELEMENT {
  190. HANDLE Handle;
  191. BOOLEAN Used;
  192. } HANDLE_ELEMENT, *PHANDLE_ELEMENT;
  193. HANDLE_ELEMENT Handles[MAX_HANDLES];
  194. HANDLE HandleEvent;
  195. VOID
  196. InitHandles (
  197. );
  198. VOID
  199. UninitHandles (
  200. );
  201. NTSTATUS
  202. ObtainIndex (
  203. OUT PUSHORT NewIndex
  204. );
  205. NTSTATUS
  206. FreeIndex (
  207. IN USHORT Index
  208. );
  209. VOID
  210. InputDisplayHandle (
  211. IN PCHAR ParamBuffer
  212. );
  213. //
  214. // Routines defined in tclose.c
  215. //
  216. VOID
  217. InputCloseIndex (
  218. IN PCHAR ParamBuffer
  219. );
  220. //
  221. // Routines contained in tevent.c
  222. //
  223. #define MAX_EVENTS 200
  224. typedef struct _EVENT_ELEMENT {
  225. HANDLE Handle;
  226. BOOLEAN Used;
  227. } EVENT_ELEMENT, *PEVENT_ELEMENT;
  228. EVENT_ELEMENT Events[MAX_EVENTS];
  229. HANDLE EventEvent;
  230. VOID
  231. InitEvents (
  232. );
  233. VOID
  234. UninitEvents (
  235. );
  236. NTSTATUS
  237. ObtainEvent (
  238. OUT PUSHORT NewIndex
  239. );
  240. VOID
  241. FreeEvent (
  242. IN USHORT Index
  243. );
  244. //
  245. // Routines contained in tread.c
  246. //
  247. VOID
  248. InputRead(
  249. IN PCHAR ParamBuffer
  250. );
  251. //
  252. // Routines defined in tpause.c
  253. //
  254. VOID
  255. InputPause (
  256. IN PCHAR ParamBuffer
  257. );
  258. //
  259. // Routines defined in tbreak.c
  260. //
  261. VOID
  262. InputBreak (
  263. IN PCHAR ParamBuffer
  264. );
  265. //
  266. // Routines defined in toplock.c
  267. //
  268. VOID
  269. InputOplock (
  270. IN PCHAR ParamBuffer
  271. );
  272. //
  273. // Routines defined in tdevctl.c
  274. //
  275. VOID
  276. InputDevctrl (
  277. IN PCHAR ParamBuffer
  278. );
  279. //
  280. // Routines defined in tfsctrl.c
  281. //
  282. VOID
  283. InputFsctrl (
  284. IN PCHAR ParamBuffer
  285. );
  286. //
  287. // Routines defined in tsparse.c
  288. //
  289. VOID
  290. InputSparse (
  291. IN PCHAR ParamBuffer
  292. );
  293. //
  294. // Routines defined in tusn.c
  295. //
  296. VOID
  297. InputUsn (
  298. IN PCHAR ParamBuffer
  299. );
  300. //
  301. // Routines defined in treparse.c
  302. //
  303. VOID
  304. InputReparse (
  305. IN PCHAR ParamBuffer
  306. );
  307. //
  308. // Routines contained in twrite.c
  309. //
  310. VOID
  311. InputWrite (
  312. IN PCHAR ParamBuffer
  313. );
  314. //
  315. // Routines contained in tqdir.c
  316. //
  317. VOID
  318. InputQDir (
  319. IN PCHAR ParamBuffer
  320. );
  321. VOID
  322. InputDisplayQDir (
  323. IN PCHAR ParamBuffer
  324. );
  325. VOID
  326. DisplayQDirNames (
  327. IN USHORT BufferIndex
  328. );
  329. VOID
  330. DisplayQDirDirs (
  331. IN USHORT BufferIndex
  332. );
  333. VOID
  334. DisplayQDirFullDirs (
  335. IN USHORT BufferIndex
  336. );
  337. VOID
  338. DisplayQDirIdFullDirs (
  339. IN USHORT BufferIndex
  340. );
  341. VOID
  342. DisplayQBothDirs (
  343. IN USHORT BufferIndex
  344. );
  345. VOID
  346. DisplayQIdBothDirs (
  347. IN USHORT BufferIndex
  348. );
  349. VOID
  350. DisplayQOleDirs (
  351. IN USHORT BufferIndex
  352. );
  353. //
  354. // Routines contained in ttime.c
  355. //
  356. VOID
  357. InputEnterTime (
  358. IN PCHAR ParamBuffer
  359. );
  360. VOID
  361. InputDisplayTime (
  362. IN PCHAR ParamBuffer
  363. );
  364. VOID
  365. PrintTime (
  366. IN PTIME Time
  367. );
  368. VOID
  369. BPrintTime (
  370. IN PTIME Time
  371. );
  372. //
  373. // Routines contained in tmisc.c
  374. //
  375. VOID
  376. PrintLargeInteger (
  377. IN PLARGE_INTEGER LargeInt
  378. );
  379. ULONG
  380. AsciiToInteger (
  381. IN PCHAR Ascii
  382. );
  383. ULONGLONG
  384. AsciiToLargeInteger (
  385. IN PCHAR Ascii
  386. );
  387. //
  388. // Routines contained in tqfile.c
  389. //
  390. VOID
  391. InputQFile (
  392. IN PCHAR ParamBuffer
  393. );
  394. VOID
  395. InputDisplayQFile (
  396. IN PCHAR ParamBuffer
  397. );
  398. //
  399. // Routines contained in tnotify.c
  400. //
  401. VOID
  402. InputNotifyChange (
  403. IN PCHAR ParamBuffer
  404. );
  405. //
  406. // Routines contained in tsetfile.c
  407. //
  408. VOID
  409. InputSetFile (
  410. IN PCHAR ParamBuffer
  411. );
  412. //
  413. // Routines contained in tqvolume.c
  414. //
  415. VOID
  416. InputQVolume (
  417. IN PCHAR ParamBuffer
  418. );
  419. VOID
  420. InputDisplayQVolume (
  421. IN PCHAR ParamBuffer
  422. );
  423. //
  424. // Routines contained in tsetvol.c
  425. //
  426. VOID
  427. InputSetVolume (
  428. IN PCHAR ParamBuffer
  429. );
  430. //
  431. // Routines defined in tcancel.c
  432. //
  433. VOID
  434. InputCancelIndex (
  435. IN PCHAR ParamBuffer
  436. );