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.

1675 lines
40 KiB

  1. #include "brian.h"
  2. typedef struct _ASYNC_QFILE {
  3. USHORT FileIndex;
  4. PUSHORT BufferIndexPtr;
  5. USHORT BufferIndex;
  6. ULONG Length;
  7. FILE_INFORMATION_CLASS FileInfoClass;
  8. BOOLEAN DisplayParms;
  9. BOOLEAN VerboseResults;
  10. USHORT AsyncIndex;
  11. } ASYNC_QFILE, *PASYNC_QFILE;
  12. #define QFILE_LENGTH_DEFAULT 100
  13. #define FILE_INFO_CLASS_DEFAULT FileAllInformation
  14. #define DISPLAY_PARMS_DEFAULT FALSE
  15. #define VERBOSE_DEFAULT FALSE
  16. #define DISPLAY_INDEX_DEFAULT 0
  17. VOID
  18. FullQFile(
  19. IN OUT PASYNC_QFILE AsyncQFile
  20. );
  21. VOID
  22. DisplayQFileBasicInformation (
  23. IN USHORT BufferIndex
  24. );
  25. VOID
  26. DisplayQFileStandardInformation (
  27. IN USHORT BufferIndex
  28. );
  29. VOID
  30. DisplayQFileInternalInformation (
  31. IN USHORT BufferIndex
  32. );
  33. VOID
  34. DisplayQFileEaInformation (
  35. IN USHORT BufferIndex
  36. );
  37. VOID
  38. DisplayQFileAccessInformation (
  39. IN USHORT BufferIndex
  40. );
  41. VOID
  42. DisplayQFileNameInformation (
  43. IN USHORT BufferIndex
  44. );
  45. VOID
  46. DisplayQFilePositionInformation (
  47. IN USHORT BufferIndex
  48. );
  49. VOID
  50. DisplayQFileModeInformation (
  51. IN USHORT BufferIndex
  52. );
  53. VOID
  54. DisplayQFileAlignmentInformation (
  55. IN USHORT BufferIndex
  56. );
  57. VOID
  58. DisplayQFileAllInformation (
  59. IN USHORT BufferIndex
  60. );
  61. VOID
  62. DisplayQFileStreamInformation (
  63. IN USHORT BufferIndex
  64. );
  65. VOID
  66. DisplayQFileAlternateNameInformation (
  67. IN USHORT BufferIndex
  68. );
  69. VOID
  70. DisplayQFileNetworkQueryInformation (
  71. IN USHORT BufferIndex
  72. );
  73. VOID
  74. DisplayBasicInformation (
  75. IN PFILE_BASIC_INFORMATION FileInfo
  76. );
  77. VOID
  78. DisplayStandardInformation (
  79. IN PFILE_STANDARD_INFORMATION FileInfo
  80. );
  81. VOID
  82. DisplayInternalInformation (
  83. IN PFILE_INTERNAL_INFORMATION FileInfo
  84. );
  85. VOID
  86. DisplayEaInformation (
  87. IN PFILE_EA_INFORMATION FileInfo
  88. );
  89. VOID
  90. DisplayAccessInformation (
  91. IN PFILE_ACCESS_INFORMATION FileInfo
  92. );
  93. VOID
  94. DisplayNameInformation (
  95. IN PFILE_NAME_INFORMATION FileInfo
  96. );
  97. VOID
  98. DisplayPositionInformation (
  99. IN PFILE_POSITION_INFORMATION FileInfo
  100. );
  101. VOID
  102. DisplayModeInformation (
  103. IN PFILE_MODE_INFORMATION FileInfo
  104. );
  105. VOID
  106. DisplayAlignmentInformation (
  107. IN PFILE_ALIGNMENT_INFORMATION FileInfo
  108. );
  109. VOID
  110. DisplayStreamInformation (
  111. IN PFILE_STREAM_INFORMATION FileInfo
  112. );
  113. VOID
  114. DisplayNetworkOpenInformation (
  115. IN PFILE_NETWORK_OPEN_INFORMATION FileInfo
  116. );
  117. VOID
  118. InputQFile (
  119. IN PCHAR ParamBuffer
  120. )
  121. {
  122. ULONG FileIndex;
  123. PUSHORT BufferIndexPtr;
  124. USHORT BufferIndex;
  125. ULONG Length;
  126. FILE_INFORMATION_CLASS FileInfoClass;
  127. BOOLEAN DisplayParms;
  128. BOOLEAN VerboseResults;
  129. USHORT AsyncIndex;
  130. BOOLEAN ParamReceived;
  131. BOOLEAN LastInput;
  132. //
  133. // Set the defaults.
  134. //
  135. BufferIndexPtr = NULL;
  136. BufferIndex = 0;
  137. Length = QFILE_LENGTH_DEFAULT;
  138. FileInfoClass = FILE_INFO_CLASS_DEFAULT;
  139. DisplayParms = DISPLAY_PARMS_DEFAULT;
  140. VerboseResults = VERBOSE_DEFAULT;
  141. AsyncIndex = 0;
  142. ParamReceived = FALSE;
  143. LastInput = TRUE;
  144. //
  145. // While there is more input, analyze the parameter and update the
  146. // query flags.
  147. //
  148. while (TRUE) {
  149. ULONG DummyCount;
  150. ULONG TempIndex;
  151. //
  152. // Swallow leading white spaces.
  153. //
  154. ParamBuffer = SwallowWhite( ParamBuffer, &DummyCount );
  155. if (*ParamBuffer) {
  156. //
  157. // If the next parameter is legal then check the paramter value.
  158. // Update the parameter value.
  159. //
  160. if ((*ParamBuffer == '-'
  161. || *ParamBuffer == '/')
  162. && (ParamBuffer++, *ParamBuffer != '\0')) {
  163. BOOLEAN SwitchBool;
  164. //
  165. // Switch on the next character.
  166. //
  167. switch (*ParamBuffer) {
  168. //
  169. // Update the buffer index.
  170. //
  171. case 'b' :
  172. case 'B' :
  173. //
  174. // Move to the next character, as long as there
  175. // are no white spaces continue analyzing letters.
  176. // On the first bad letter, skip to the next
  177. // parameter.
  178. //
  179. ParamBuffer++;
  180. TempIndex = AsciiToInteger( ParamBuffer );
  181. BufferIndex = (USHORT) TempIndex;
  182. BufferIndexPtr = &BufferIndex;
  183. Length = Buffers[BufferIndex].Length;
  184. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  185. break;
  186. //
  187. // Update the byte count.
  188. //
  189. case 'l' :
  190. case 'L' :
  191. //
  192. // Move to the next character, as long as there
  193. // are no white spaces continue analyzing letters.
  194. // On the first bad letter, skip to the next
  195. // parameter.
  196. //
  197. ParamBuffer++;
  198. Length = AsciiToInteger( ParamBuffer );
  199. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  200. break;
  201. //
  202. // Update the file handle index.
  203. //
  204. case 'i' :
  205. case 'I' :
  206. //
  207. // Move to the next character, as long as there
  208. // are no white spaces continue analyzing letters.
  209. // On the first bad letter, skip to the next
  210. // parameter.
  211. //
  212. ParamBuffer++;
  213. FileIndex = AsciiToInteger( ParamBuffer );
  214. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  215. ParamReceived = TRUE;
  216. break;
  217. //
  218. // Update the information class.
  219. //
  220. case 'c' :
  221. case 'C' :
  222. //
  223. // Move to the next character, as long as there
  224. // are no white spaces continue analyzing letters.
  225. // On the first bad letter, skip to the next
  226. // parameter.
  227. //
  228. ParamBuffer++;
  229. SwitchBool = TRUE;
  230. while (*ParamBuffer
  231. && *ParamBuffer != ' '
  232. && *ParamBuffer != '\t') {
  233. //
  234. // Perform switch on character.
  235. //
  236. switch (*ParamBuffer) {
  237. case 'a' :
  238. case 'A' :
  239. FileInfoClass = FileBasicInformation;
  240. break;
  241. case 'b' :
  242. case 'B' :
  243. FileInfoClass = FileStandardInformation;
  244. break;
  245. case 'c' :
  246. case 'C' :
  247. FileInfoClass = FileInternalInformation;
  248. break;
  249. case 'd' :
  250. case 'D' :
  251. FileInfoClass = FileEaInformation;
  252. break;
  253. case 'e' :
  254. case 'E' :
  255. FileInfoClass = FileAccessInformation;
  256. break;
  257. case 'f' :
  258. case 'F' :
  259. FileInfoClass = FileNameInformation;
  260. break;
  261. case 'g' :
  262. case 'G' :
  263. FileInfoClass = FilePositionInformation;
  264. break;
  265. case 'h' :
  266. case 'H' :
  267. FileInfoClass = FileModeInformation;
  268. break;
  269. case 'i' :
  270. case 'I' :
  271. FileInfoClass = FileAlignmentInformation;
  272. break;
  273. case 'j' :
  274. case 'J' :
  275. FileInfoClass = FileAllInformation;
  276. break;
  277. case 'k' :
  278. case 'K' :
  279. FileInfoClass = FileStreamInformation;
  280. break;
  281. case 'l' :
  282. case 'L' :
  283. FileInfoClass = FileAlternateNameInformation;
  284. break;
  285. case 'm' :
  286. case 'M' :
  287. FileInfoClass = FileNetworkOpenInformation;
  288. break;
  289. default :
  290. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  291. SwitchBool = FALSE;
  292. }
  293. if (!SwitchBool) {
  294. break;
  295. }
  296. ParamBuffer++;
  297. }
  298. break;
  299. case 'v' :
  300. case 'V' :
  301. //
  302. // Legal values for params are T/t or F/f.
  303. //
  304. ParamBuffer++;
  305. if( *ParamBuffer == 'T'
  306. || *ParamBuffer == 't' ) {
  307. VerboseResults = TRUE;
  308. ParamBuffer++;
  309. } else if( *ParamBuffer == 'F'
  310. || *ParamBuffer == 'f' ) {
  311. VerboseResults = FALSE;
  312. ParamBuffer++;
  313. }
  314. break;
  315. case 'y' :
  316. case 'Y' :
  317. //
  318. // Set the display parms flag and jump over this
  319. // character.
  320. //
  321. DisplayParms = TRUE;
  322. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  323. break;
  324. case 'z' :
  325. case 'Z' :
  326. //
  327. // Set flag for more input and jump over this char.
  328. //
  329. LastInput = FALSE;
  330. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  331. break;
  332. default :
  333. //
  334. // Swallow to the next white space and continue the
  335. // loop.
  336. //
  337. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  338. }
  339. }
  340. //
  341. // Else the text is invalid, skip the entire block.
  342. //
  343. //
  344. //
  345. // Else if there is no input then exit.
  346. //
  347. } else if( LastInput ) {
  348. break;
  349. //
  350. // Else try to read another line for open parameters.
  351. //
  352. } else {
  353. }
  354. }
  355. //
  356. // If no parameters were received then display the syntax message.
  357. //
  358. if (!ParamReceived) {
  359. printf( "\n Usage: qf [options]* -i<index> [options]*\n" );
  360. printf( "\n Options:" );
  361. printf( "\n -i<digits> File index" );
  362. printf( "\n -l<digits> Buffer length" );
  363. printf( "\n -b<digits> Buffer index" );
  364. printf( "\n -c<char> File information class" );
  365. printf( "\n -v[t|f] Verbose results" );
  366. printf( "\n -y Display parameters to query" );
  367. printf( "\n -z Additional input line" );
  368. printf( "\n\n" );
  369. //
  370. // Else call our read routine.
  371. //
  372. } else {
  373. NTSTATUS Status;
  374. SIZE_T RegionSize;
  375. ULONG TempIndex;
  376. PASYNC_QFILE AsyncQFile;
  377. HANDLE ThreadHandle;
  378. ULONG ThreadId;
  379. RegionSize = sizeof( ASYNC_QFILE );
  380. Status = AllocateBuffer( 0, &RegionSize, &TempIndex );
  381. AsyncIndex = (USHORT) TempIndex;
  382. if (!NT_SUCCESS( Status )) {
  383. printf("\n\tInputQFile: Unable to allocate async structure" );
  384. } else {
  385. AsyncQFile = (PASYNC_QFILE) Buffers[AsyncIndex].Buffer;
  386. AsyncQFile->FileIndex = (USHORT) FileIndex;
  387. AsyncQFile->BufferIndex = BufferIndex;
  388. AsyncQFile->BufferIndexPtr = BufferIndexPtr
  389. ? &AsyncQFile->BufferIndex
  390. : BufferIndexPtr;
  391. AsyncQFile->Length = Length;
  392. AsyncQFile->FileInfoClass = FileInfoClass;
  393. AsyncQFile->DisplayParms = DisplayParms;
  394. AsyncQFile->VerboseResults = VerboseResults;
  395. AsyncQFile->AsyncIndex = AsyncIndex;
  396. if (!SynchronousCmds) {
  397. ThreadHandle = CreateThread( NULL,
  398. 0,
  399. FullQFile,
  400. AsyncQFile,
  401. 0,
  402. &ThreadId );
  403. if (ThreadHandle == 0) {
  404. printf( "\nInputQFile: Spawning thread fails -> %d\n", GetLastError() );
  405. DeallocateBuffer( AsyncIndex );
  406. return;
  407. }
  408. } else {
  409. FullQFile( AsyncQFile );
  410. }
  411. }
  412. }
  413. return;
  414. }
  415. VOID
  416. FullQFile(
  417. IN OUT PASYNC_QFILE AsyncQFile
  418. )
  419. {
  420. NTSTATUS Status;
  421. IO_STATUS_BLOCK Iosb;
  422. USHORT ThisBufferIndex;
  423. BOOLEAN UnwindQFileBuffer = FALSE;
  424. Status = STATUS_SUCCESS;
  425. if (AsyncQFile->DisplayParms) {
  426. bprint "\nQFile Parameters" );
  427. bprint "\n File Handle Index -> %d", AsyncQFile->FileIndex );
  428. bprint "\n Buffer Index Ptr -> %08lx", AsyncQFile->BufferIndexPtr );
  429. if (AsyncQFile->BufferIndexPtr) {
  430. bprint "\n BufferIndex value -> %04x", AsyncQFile->BufferIndex );
  431. }
  432. bprint "\n Length -> %08lx", AsyncQFile->Length );
  433. bprint "\n FileInfoClass -> %08lx", AsyncQFile->FileInfoClass );
  434. bprint "\n\n" );
  435. }
  436. try {
  437. SIZE_T ThisLength;
  438. //
  439. // If we need a buffer, allocate it now.
  440. //
  441. if (AsyncQFile->BufferIndexPtr == NULL) {
  442. ULONG TempIndex;
  443. ThisLength = 4096;
  444. Status = AllocateBuffer( 0L, &ThisLength, &TempIndex );
  445. ThisBufferIndex = (USHORT) TempIndex;
  446. if (!NT_SUCCESS( Status )) {
  447. bprint "\n\tFullQFile: Unable to allocate a query buffer" );
  448. try_return( Status );
  449. }
  450. bprint "\n\tFullQFile: Reading into buffer -> %04x\n", ThisBufferIndex );
  451. bprint "\n" );
  452. UnwindQFileBuffer = TRUE;
  453. AsyncQFile->Length = (ULONG) ThisLength;
  454. } else {
  455. ThisBufferIndex = AsyncQFile->BufferIndex;
  456. }
  457. //
  458. // Check that the buffer index is valid.
  459. //
  460. if (ThisBufferIndex >= MAX_BUFFERS) {
  461. bprint "\n\tFullQFile: The read buffer index is invalid" );
  462. try_return( Status = STATUS_INVALID_HANDLE );
  463. }
  464. //
  465. // Check that the file index is valid.
  466. //
  467. if (AsyncQFile->FileIndex >= MAX_HANDLES) {
  468. bprint "\n\tFullQFile: The file index is invalid" );
  469. try_return( Status = STATUS_INVALID_HANDLE );
  470. }
  471. //
  472. // Call the query file routine.
  473. //
  474. Status = NtQueryInformationFile( Handles[AsyncQFile->FileIndex].Handle,
  475. &Iosb,
  476. Buffers[ThisBufferIndex].Buffer,
  477. AsyncQFile->Length,
  478. AsyncQFile->FileInfoClass );
  479. UnwindQFileBuffer = FALSE;
  480. if (AsyncQFile->VerboseResults) {
  481. bprint "\nQuery File: Status -> %08lx", Status );
  482. if (NT_SUCCESS( Status )) {
  483. bprint "\n Iosb.Information -> %08lx", Iosb.Information );
  484. bprint "\n Iosb.Status -> %08lx", Iosb.Status );
  485. }
  486. bprint "\n" );
  487. }
  488. try_return( Status );
  489. try_exit: NOTHING;
  490. } finally {
  491. if (UnwindQFileBuffer) {
  492. DeallocateBuffer( ThisBufferIndex );
  493. }
  494. DeallocateBuffer( AsyncQFile->AsyncIndex );
  495. }
  496. if (!SynchronousCmds) {
  497. NtTerminateThread( 0, STATUS_SUCCESS );
  498. }
  499. }
  500. VOID
  501. InputDisplayQFile (
  502. IN PCHAR ParamBuffer
  503. )
  504. {
  505. FILE_INFORMATION_CLASS FileInfoClass;
  506. ULONG BufferIndex;
  507. BOOLEAN ParamReceived;
  508. BOOLEAN LastInput;
  509. //
  510. // Set the defaults.
  511. //
  512. BufferIndex = DISPLAY_INDEX_DEFAULT;
  513. FileInfoClass = FILE_INFO_CLASS_DEFAULT;
  514. ParamReceived = FALSE;
  515. LastInput = TRUE;
  516. //
  517. // While there is more input, analyze the parameter and update the
  518. // query flags.
  519. //
  520. while (TRUE) {
  521. ULONG DummyCount;
  522. //
  523. // Swallow leading white spaces.
  524. //
  525. ParamBuffer = SwallowWhite( ParamBuffer, &DummyCount );
  526. if (*ParamBuffer) {
  527. //
  528. // If the next parameter is legal then check the paramter value.
  529. // Update the parameter value.
  530. //
  531. if ((*ParamBuffer == '-'
  532. || *ParamBuffer == '/')
  533. && (ParamBuffer++, *ParamBuffer != '\0')) {
  534. BOOLEAN SwitchBool;
  535. //
  536. // Switch on the next character.
  537. //
  538. switch( *ParamBuffer ) {
  539. //
  540. // Check the buffer index.
  541. //
  542. case 'b' :
  543. case 'B' :
  544. //
  545. // Move to the next character, as long as there
  546. // are no white spaces continue analyzing letters.
  547. // On the first bad letter, skip to the next
  548. // parameter.
  549. //
  550. ParamBuffer++;
  551. BufferIndex = AsciiToInteger( ParamBuffer );
  552. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  553. ParamReceived = TRUE;
  554. break;
  555. //
  556. // Update the desired access.
  557. //
  558. case 'c' :
  559. case 'C' :
  560. //
  561. // Move to the next character, as long as there
  562. // are no white spaces continue analyzing letters.
  563. // On the first bad letter, skip to the next
  564. // parameter.
  565. //
  566. ParamBuffer++;
  567. SwitchBool = TRUE;
  568. while (*ParamBuffer
  569. && *ParamBuffer != ' '
  570. && *ParamBuffer != '\t') {
  571. //
  572. // Perform switch on character.
  573. //
  574. switch (*ParamBuffer) {
  575. case 'a' :
  576. case 'A' :
  577. FileInfoClass = FileBasicInformation;
  578. break;
  579. case 'b' :
  580. case 'B' :
  581. FileInfoClass = FileStandardInformation;
  582. break;
  583. case 'c' :
  584. case 'C' :
  585. FileInfoClass = FileInternalInformation;
  586. break;
  587. case 'd' :
  588. case 'D' :
  589. FileInfoClass = FileEaInformation;
  590. break;
  591. case 'e' :
  592. case 'E' :
  593. FileInfoClass = FileAccessInformation;
  594. break;
  595. case 'f' :
  596. case 'F' :
  597. FileInfoClass = FileNameInformation;
  598. break;
  599. case 'g' :
  600. case 'G' :
  601. FileInfoClass = FilePositionInformation;
  602. break;
  603. case 'h' :
  604. case 'H' :
  605. FileInfoClass = FileModeInformation;
  606. break;
  607. case 'i' :
  608. case 'I' :
  609. FileInfoClass = FileAlignmentInformation;
  610. break;
  611. case 'j' :
  612. case 'J' :
  613. FileInfoClass = FileAllInformation;
  614. break;
  615. case 'k' :
  616. case 'K' :
  617. FileInfoClass = FileStreamInformation;
  618. break;
  619. case 'l' :
  620. case 'L' :
  621. FileInfoClass = FileAlternateNameInformation;
  622. break;
  623. case 'm' :
  624. case 'M' :
  625. FileInfoClass = FileNetworkOpenInformation;
  626. break;
  627. default :
  628. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  629. SwitchBool = FALSE;
  630. }
  631. if (!SwitchBool) {
  632. break;
  633. }
  634. ParamBuffer++;
  635. }
  636. break;
  637. default :
  638. //
  639. // Swallow to the next white space and continue the
  640. // loop.
  641. //
  642. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  643. }
  644. }
  645. //
  646. // Else the text is invalid, skip the entire block.
  647. //
  648. //
  649. //
  650. // Else if there is no input then exit.
  651. //
  652. } else if ( LastInput ) {
  653. break;
  654. //
  655. // Else try to read another line for open parameters.
  656. //
  657. } else {
  658. }
  659. }
  660. //
  661. // If no parameters were received then display the syntax message.
  662. //
  663. if (!ParamReceived) {
  664. printf( "\n Usage: dqf [options]* -b<digits> [options]*\n" );
  665. printf( "\n Options:" );
  666. printf( "\n -b<digits> Buffer index" );
  667. printf( "\n -c<char> Key to buffer format" );
  668. printf( "\n\n" );
  669. //
  670. // Else call our display buffer routine.
  671. //
  672. } else {
  673. switch (FileInfoClass) {
  674. case FileBasicInformation:
  675. DisplayQFileBasicInformation( (USHORT) BufferIndex );
  676. break;
  677. case FileStandardInformation:
  678. DisplayQFileStandardInformation( (USHORT) BufferIndex );
  679. break;
  680. case FileInternalInformation:
  681. DisplayQFileInternalInformation( (USHORT) BufferIndex );
  682. break;
  683. case FileEaInformation:
  684. DisplayQFileEaInformation( (USHORT) BufferIndex );
  685. break;
  686. case FileAccessInformation:
  687. DisplayQFileAccessInformation( (USHORT) BufferIndex );
  688. break;
  689. case FileNameInformation:
  690. DisplayQFileNameInformation( (USHORT) BufferIndex );
  691. break;
  692. case FilePositionInformation:
  693. DisplayQFilePositionInformation( (USHORT) BufferIndex );
  694. break;
  695. case FileModeInformation:
  696. DisplayQFileModeInformation( (USHORT) BufferIndex );
  697. break;
  698. case FileAlignmentInformation:
  699. DisplayQFileAlignmentInformation( (USHORT) BufferIndex );
  700. break;
  701. case FileAllInformation:
  702. DisplayQFileAllInformation( (USHORT) BufferIndex );
  703. break;
  704. case FileStreamInformation:
  705. DisplayQFileStreamInformation( (USHORT) BufferIndex );
  706. break;
  707. case FileAlternateNameInformation:
  708. DisplayQFileAlternateNameInformation( (USHORT) BufferIndex );
  709. break;
  710. case FileNetworkOpenInformation:
  711. DisplayQFileNetworkQueryInformation( (USHORT) BufferIndex );
  712. break;
  713. }
  714. }
  715. }
  716. VOID
  717. DisplayQFileBasicInformation (
  718. IN USHORT BufferIndex
  719. )
  720. {
  721. PFILE_BASIC_INFORMATION FileInfo;
  722. if (!Buffers[BufferIndex].Used) {
  723. printf( "\nDisplayQFileBasicInformation: Invalid buffer\n" );
  724. return;
  725. }
  726. try {
  727. FileInfo = (PFILE_BASIC_INFORMATION) Buffers[BufferIndex].Buffer;
  728. printf( "\n\nBasic File Information\n" );
  729. DisplayBasicInformation( FileInfo );
  730. printf( "\n" );
  731. try_return( NOTHING );
  732. try_exit: NOTHING;
  733. } finally {
  734. if (AbnormalTermination()) {
  735. printf( "\nDisplayQFileBasicInformation: AbnormalTermination\n" );
  736. }
  737. }
  738. return;
  739. }
  740. VOID
  741. DisplayQFileStandardInformation (
  742. IN USHORT BufferIndex
  743. )
  744. {
  745. PFILE_STANDARD_INFORMATION FileInfo;
  746. if (!Buffers[BufferIndex].Used) {
  747. printf( "\nDisplayQFileStandardInformation: Invalid buffer\n" );
  748. return;
  749. }
  750. try {
  751. FileInfo = (PFILE_STANDARD_INFORMATION) Buffers[BufferIndex].Buffer;
  752. printf( "\n\nStandard File Information\n" );
  753. DisplayStandardInformation( FileInfo );
  754. printf( "\n" );
  755. try_return( NOTHING );
  756. try_exit: NOTHING;
  757. } finally {
  758. if (AbnormalTermination()) {
  759. printf( "\nDisplayQFileStandardInformation: AbnormalTermination\n" );
  760. }
  761. }
  762. return;
  763. }
  764. VOID
  765. DisplayQFileInternalInformation (
  766. IN USHORT BufferIndex
  767. )
  768. {
  769. PFILE_INTERNAL_INFORMATION FileInfo;
  770. if (!Buffers[BufferIndex].Used) {
  771. printf( "\nDisplayQFileInternalInformation: Invalid buffer\n" );
  772. return;
  773. }
  774. try {
  775. FileInfo = (PFILE_INTERNAL_INFORMATION) Buffers[BufferIndex].Buffer;
  776. printf( "\n\nInternal File Information\n" );
  777. DisplayInternalInformation( FileInfo );
  778. printf( "\n" );
  779. try_return( NOTHING );
  780. try_exit: NOTHING;
  781. } finally {
  782. if (AbnormalTermination()) {
  783. printf( "\nDisplayQFileInternalInformation: AbnormalTermination\n" );
  784. }
  785. }
  786. return;
  787. }
  788. VOID
  789. DisplayQFileEaInformation (
  790. IN USHORT BufferIndex
  791. )
  792. {
  793. PFILE_EA_INFORMATION FileInfo;
  794. if (!Buffers[BufferIndex].Used) {
  795. printf( "\nDisplayQFileEaInformation: Invalid buffer\n" );
  796. return;
  797. }
  798. try {
  799. FileInfo = (PFILE_EA_INFORMATION) Buffers[BufferIndex].Buffer;
  800. printf( "\n\nEa File Information\n" );
  801. DisplayEaInformation( FileInfo );
  802. printf( "\n" );
  803. try_return( NOTHING );
  804. try_exit: NOTHING;
  805. } finally {
  806. if (AbnormalTermination()) {
  807. printf( "\nDisplayQFileEaInformation: AbnormalTermination\n" );
  808. }
  809. }
  810. return;
  811. }
  812. VOID
  813. DisplayQFileAccessInformation (
  814. IN USHORT BufferIndex
  815. )
  816. {
  817. PFILE_ACCESS_INFORMATION FileInfo;
  818. if (!Buffers[BufferIndex].Used) {
  819. printf( "\nDisplayQFileAccessInformation: Invalid buffer\n" );
  820. return;
  821. }
  822. try {
  823. FileInfo = (PFILE_ACCESS_INFORMATION) Buffers[BufferIndex].Buffer;
  824. printf( "\n\nAccess File Information\n" );
  825. DisplayAccessInformation( FileInfo );
  826. printf( "\n" );
  827. try_return( NOTHING );
  828. try_exit: NOTHING;
  829. } finally {
  830. if (AbnormalTermination()) {
  831. printf( "\nDisplayQFileAccessInformation: AbnormalTermination\n" );
  832. }
  833. }
  834. return;
  835. }
  836. VOID
  837. DisplayQFileNameInformation (
  838. IN USHORT BufferIndex
  839. )
  840. {
  841. PFILE_NAME_INFORMATION FileInfo;
  842. if (!Buffers[BufferIndex].Used) {
  843. printf( "\nDisplayQFileNameInformation: Invalid buffer\n" );
  844. return;
  845. }
  846. try {
  847. FileInfo = (PFILE_NAME_INFORMATION) Buffers[BufferIndex].Buffer;
  848. printf( "\n\nName File Information\n" );
  849. DisplayNameInformation( FileInfo );
  850. printf( "\n" );
  851. try_return( NOTHING );
  852. try_exit: NOTHING;
  853. } finally {
  854. if (AbnormalTermination()) {
  855. printf( "\nDisplayQFileNameInformation: AbnormalTermination\n" );
  856. }
  857. }
  858. return;
  859. }
  860. VOID
  861. DisplayQFilePositionInformation (
  862. IN USHORT BufferIndex
  863. )
  864. {
  865. PFILE_POSITION_INFORMATION FileInfo;
  866. if (!Buffers[BufferIndex].Used) {
  867. printf( "\nDisplayQFilePositionInformation: Invalid buffer\n" );
  868. return;
  869. }
  870. try {
  871. FileInfo = (PFILE_POSITION_INFORMATION) Buffers[BufferIndex].Buffer;
  872. printf( "\n\nPosition File Information\n" );
  873. DisplayPositionInformation( FileInfo );
  874. printf( "\n" );
  875. try_return( NOTHING );
  876. try_exit: NOTHING;
  877. } finally {
  878. if (AbnormalTermination()) {
  879. printf( "\nDisplayQFilePositionInformation: AbnormalTermination\n" );
  880. }
  881. }
  882. return;
  883. }
  884. VOID
  885. DisplayQFileModeInformation (
  886. IN USHORT BufferIndex
  887. )
  888. {
  889. PFILE_MODE_INFORMATION FileInfo;
  890. if (!Buffers[BufferIndex].Used) {
  891. printf( "\nDisplayQFileModeInformation: Invalid buffer\n" );
  892. return;
  893. }
  894. try {
  895. FileInfo = (PFILE_MODE_INFORMATION) Buffers[BufferIndex].Buffer;
  896. printf( "\n\nMode File Information\n" );
  897. DisplayModeInformation( FileInfo );
  898. printf( "\n" );
  899. try_return( NOTHING );
  900. try_exit: NOTHING;
  901. } finally {
  902. if (AbnormalTermination()) {
  903. printf( "\nDisplayQFileModeInformation: AbnormalTermination\n" );
  904. }
  905. }
  906. return;
  907. }
  908. VOID
  909. DisplayQFileAlignmentInformation (
  910. IN USHORT BufferIndex
  911. )
  912. {
  913. PFILE_ALIGNMENT_INFORMATION FileInfo;
  914. if (!Buffers[BufferIndex].Used) {
  915. printf( "\nDisplayQFileAlignmentInformation: Invalid buffer\n" );
  916. return;
  917. }
  918. try {
  919. FileInfo = (PFILE_ALIGNMENT_INFORMATION) Buffers[BufferIndex].Buffer;
  920. printf( "\n\nAlignment File Information\n" );
  921. DisplayAlignmentInformation( FileInfo );
  922. printf( "\n" );
  923. try_return( NOTHING );
  924. try_exit: NOTHING;
  925. } finally {
  926. if (AbnormalTermination()) {
  927. printf( "\nDisplayQFileAlignmentInformation: AbnormalTermination\n" );
  928. }
  929. }
  930. return;
  931. }
  932. VOID
  933. DisplayQFileAllInformation (
  934. IN USHORT BufferIndex
  935. )
  936. {
  937. PFILE_ALL_INFORMATION FileInfo;
  938. if (!Buffers[BufferIndex].Used) {
  939. printf( "\nDisplayQFileAllInformation: Invalid buffer\n" );
  940. return;
  941. }
  942. try {
  943. FileInfo = (PFILE_ALL_INFORMATION) Buffers[BufferIndex].Buffer;
  944. printf( "\n\nAll File Information\n" );
  945. DisplayNameInformation( &FileInfo->NameInformation );
  946. DisplayBasicInformation( &FileInfo->BasicInformation );
  947. DisplayStandardInformation( &FileInfo->StandardInformation );
  948. DisplayInternalInformation( &FileInfo->InternalInformation );
  949. DisplayEaInformation( &FileInfo->EaInformation );
  950. DisplayAccessInformation( &FileInfo->AccessInformation );
  951. DisplayPositionInformation( &FileInfo->PositionInformation );
  952. DisplayModeInformation( &FileInfo->ModeInformation );
  953. DisplayAlignmentInformation( &FileInfo->AlignmentInformation );
  954. printf( "\n" );
  955. try_return( NOTHING );
  956. try_exit: NOTHING;
  957. } finally {
  958. if (AbnormalTermination()) {
  959. printf( "\nDisplayQFileBasicInformation: AbnormalTermination\n" );
  960. }
  961. }
  962. return;
  963. }
  964. VOID
  965. DisplayQFileStreamInformation (
  966. IN USHORT BufferIndex
  967. )
  968. {
  969. PFILE_STREAM_INFORMATION FileInfo;
  970. ULONG NextOffset;
  971. if (!Buffers[BufferIndex].Used) {
  972. printf( "\nDisplayQFileStreamInformation: Invalid buffer\n" );
  973. return;
  974. }
  975. try {
  976. NextOffset = 0;
  977. FileInfo = (PFILE_STREAM_INFORMATION) Buffers[BufferIndex].Buffer;
  978. printf( "\n\nStream File Information\n" );
  979. do {
  980. FileInfo = (PFILE_STREAM_INFORMATION) ((PUCHAR) FileInfo + NextOffset);
  981. DisplayStreamInformation( FileInfo );
  982. NextOffset = FileInfo->NextEntryOffset;
  983. } while ( NextOffset );
  984. printf( "\n" );
  985. try_return( NOTHING );
  986. try_exit: NOTHING;
  987. } finally {
  988. if (AbnormalTermination()) {
  989. printf( "\nDisplayQFileStreamInformation: AbnormalTermination\n" );
  990. }
  991. }
  992. return;
  993. }
  994. VOID
  995. DisplayQFileAlternateNameInformation (
  996. IN USHORT BufferIndex
  997. )
  998. {
  999. PFILE_NAME_INFORMATION FileInfo;
  1000. if (!Buffers[BufferIndex].Used) {
  1001. printf( "\nDisplayQFileAlternateNameInformation: Invalid buffer\n" );
  1002. return;
  1003. }
  1004. try {
  1005. FileInfo = (PFILE_NAME_INFORMATION) Buffers[BufferIndex].Buffer;
  1006. printf( "\n\nAlternate Name File Information\n" );
  1007. DisplayNameInformation( FileInfo );
  1008. printf( "\n" );
  1009. try_return( NOTHING );
  1010. try_exit: NOTHING;
  1011. } finally {
  1012. if (AbnormalTermination()) {
  1013. printf( "\nDisplayQFileAlternateNameInformation: AbnormalTermination\n" );
  1014. }
  1015. }
  1016. return;
  1017. }
  1018. VOID
  1019. DisplayQFileNetworkQueryInformation (
  1020. IN USHORT BufferIndex
  1021. )
  1022. {
  1023. PFILE_NETWORK_OPEN_INFORMATION FileInfo;
  1024. if (!Buffers[BufferIndex].Used) {
  1025. printf( "\nDisplayQFileNetworkQueryInformation: Invalid buffer\n" );
  1026. return;
  1027. }
  1028. try {
  1029. FileInfo = (PFILE_NETWORK_OPEN_INFORMATION) Buffers[BufferIndex].Buffer;
  1030. printf( "\n\nNetwork Open File Information\n" );
  1031. DisplayNetworkOpenInformation( FileInfo );
  1032. printf( "\n" );
  1033. try_return( NOTHING );
  1034. try_exit: NOTHING;
  1035. } finally {
  1036. if (AbnormalTermination()) {
  1037. printf( "\nDisplayQFileNetworkOpenInformation: AbnormalTermination\n" );
  1038. }
  1039. }
  1040. return;
  1041. }
  1042. VOID
  1043. DisplayBasicInformation (
  1044. IN PFILE_BASIC_INFORMATION FileInfo
  1045. )
  1046. {
  1047. printf( "\n\tCreation Time -> " );
  1048. PrintTime( &FileInfo->CreationTime );
  1049. printf( "\n\tLast Access Time -> " );
  1050. PrintTime( &FileInfo->LastAccessTime );
  1051. printf( "\n\tLast Write Time -> " );
  1052. PrintTime( &FileInfo->LastWriteTime );
  1053. printf( "\n\tChange Time -> " );
  1054. PrintTime( &FileInfo->ChangeTime );
  1055. printf( "\n\tFile Attributes -> %08lx", FileInfo->FileAttributes );
  1056. return;
  1057. }
  1058. VOID
  1059. DisplayStandardInformation (
  1060. IN PFILE_STANDARD_INFORMATION FileInfo
  1061. )
  1062. {
  1063. printf( "\n\tAllocation Size -> " );
  1064. PrintLargeInteger( &FileInfo->AllocationSize );
  1065. printf( "\n\tEnd Of File -> " );
  1066. PrintLargeInteger( &FileInfo->EndOfFile );
  1067. printf( "\n\tNumber of Links -> %08lx", FileInfo->NumberOfLinks );
  1068. printf( "\n\tDelete Pending -> %04x", FileInfo->DeletePending );
  1069. printf( "\n\tDirectory -> %d", FileInfo->Directory );
  1070. return;
  1071. }
  1072. VOID
  1073. DisplayInternalInformation (
  1074. IN PFILE_INTERNAL_INFORMATION FileInfo
  1075. )
  1076. {
  1077. printf( "\n\tFile Index.LowPart -> %08lx", FileInfo->IndexNumber.LowPart );
  1078. printf( "\n\tFile Index.HighPart -> %08lx", FileInfo->IndexNumber.HighPart );
  1079. printf( "\n\n\tFile Index.LowPart -> %ld", FileInfo->IndexNumber.LowPart );
  1080. printf( "\n\tFile Index.HighPart -> %ld", FileInfo->IndexNumber.HighPart );
  1081. return;
  1082. }
  1083. VOID
  1084. DisplayEaInformation (
  1085. IN PFILE_EA_INFORMATION FileInfo
  1086. )
  1087. {
  1088. printf( "\n\tEa Size -> %08lx", FileInfo->EaSize );
  1089. return;
  1090. }
  1091. VOID
  1092. DisplayAccessInformation (
  1093. IN PFILE_ACCESS_INFORMATION FileInfo
  1094. )
  1095. {
  1096. printf( "\n\tAccess Flags -> %08lx", FileInfo->AccessFlags );
  1097. return;
  1098. }
  1099. VOID
  1100. DisplayNameInformation (
  1101. IN PFILE_NAME_INFORMATION FileInfo
  1102. )
  1103. {
  1104. ANSI_STRING AnsiString;
  1105. UNICODE_STRING UnicodeString;
  1106. UnicodeString.MaximumLength =
  1107. UnicodeString.Length = (USHORT) FileInfo->FileNameLength;
  1108. UnicodeString.Buffer = (PWSTR) &FileInfo->FileName;
  1109. UnicodeString.MaximumLength += 2;
  1110. RtlUnicodeStringToAnsiString( &AnsiString,
  1111. &UnicodeString,
  1112. TRUE );
  1113. printf( "\n\tFile Name -> %s", AnsiString.Buffer );
  1114. RtlFreeAnsiString( &AnsiString );
  1115. return;
  1116. }
  1117. VOID
  1118. DisplayPositionInformation (
  1119. IN PFILE_POSITION_INFORMATION FileInfo
  1120. )
  1121. {
  1122. printf( "\n\tFile Position -> " );
  1123. PrintLargeInteger( &FileInfo->CurrentByteOffset );
  1124. return;
  1125. }
  1126. VOID
  1127. DisplayModeInformation (
  1128. IN PFILE_MODE_INFORMATION FileInfo
  1129. )
  1130. {
  1131. printf( "\n\tFile Mode -> %08lx", FileInfo->Mode );
  1132. return;
  1133. }
  1134. VOID
  1135. DisplayAlignmentInformation (
  1136. IN PFILE_ALIGNMENT_INFORMATION FileInfo
  1137. )
  1138. {
  1139. printf( "\n\tAlignment -> %08lx", FileInfo->AlignmentRequirement );
  1140. return;
  1141. }
  1142. VOID
  1143. DisplayStreamInformation (
  1144. IN PFILE_STREAM_INFORMATION FileInfo
  1145. )
  1146. {
  1147. UNICODE_STRING UnicodeString;
  1148. ANSI_STRING AnsiString;
  1149. printf( "\n\tStreamSize -> " );
  1150. PrintLargeInteger( &FileInfo->StreamSize );
  1151. printf( "\n\tStreamAllocationSize -> " );
  1152. PrintLargeInteger( &FileInfo->StreamAllocationSize );
  1153. printf( "\n\tStreamNameLength -> %08lx", FileInfo->StreamNameLength );
  1154. UnicodeString.MaximumLength = (USHORT) FileInfo->StreamNameLength + 2;
  1155. UnicodeString.Length = (USHORT) FileInfo->StreamNameLength;
  1156. UnicodeString.Buffer = (PWSTR) &FileInfo->StreamName;
  1157. RtlUnicodeStringToAnsiString( &AnsiString,
  1158. &UnicodeString,
  1159. TRUE );
  1160. printf( "\n\tStream Name -> %s", AnsiString.Buffer );
  1161. RtlFreeAnsiString( &AnsiString );
  1162. }
  1163. VOID
  1164. DisplayNetworkOpenInformation (
  1165. IN PFILE_NETWORK_OPEN_INFORMATION FileInfo
  1166. )
  1167. {
  1168. printf( "\n\tCreation Time -> " );
  1169. PrintTime( &FileInfo->CreationTime );
  1170. printf( "\n\tLast Access Time -> " );
  1171. PrintTime( &FileInfo->LastAccessTime );
  1172. printf( "\n\tLast Write Time -> " );
  1173. PrintTime( &FileInfo->LastWriteTime );
  1174. printf( "\n\tChange Time -> " );
  1175. PrintTime( &FileInfo->ChangeTime );
  1176. printf( "\n\tAllocation Size -> " );
  1177. PrintLargeInteger( &FileInfo->AllocationSize );
  1178. printf( "\n\tEnd Of File -> " );
  1179. PrintLargeInteger( &FileInfo->EndOfFile );
  1180. printf( "\n\tFile Attributes -> %08lx", FileInfo->FileAttributes );
  1181. }