Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1672 lines
38 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. NtTerminateThread( 0, STATUS_SUCCESS );
  497. }
  498. VOID
  499. InputDisplayQFile (
  500. IN PCHAR ParamBuffer
  501. )
  502. {
  503. FILE_INFORMATION_CLASS FileInfoClass;
  504. ULONG BufferIndex;
  505. BOOLEAN ParamReceived;
  506. BOOLEAN LastInput;
  507. //
  508. // Set the defaults.
  509. //
  510. BufferIndex = DISPLAY_INDEX_DEFAULT;
  511. FileInfoClass = FILE_INFO_CLASS_DEFAULT;
  512. ParamReceived = FALSE;
  513. LastInput = TRUE;
  514. //
  515. // While there is more input, analyze the parameter and update the
  516. // query flags.
  517. //
  518. while (TRUE) {
  519. ULONG DummyCount;
  520. //
  521. // Swallow leading white spaces.
  522. //
  523. ParamBuffer = SwallowWhite( ParamBuffer, &DummyCount );
  524. if (*ParamBuffer) {
  525. //
  526. // If the next parameter is legal then check the paramter value.
  527. // Update the parameter value.
  528. //
  529. if ((*ParamBuffer == '-'
  530. || *ParamBuffer == '/')
  531. && (ParamBuffer++, *ParamBuffer != '\0')) {
  532. BOOLEAN SwitchBool;
  533. //
  534. // Switch on the next character.
  535. //
  536. switch( *ParamBuffer ) {
  537. //
  538. // Check the buffer index.
  539. //
  540. case 'b' :
  541. case 'B' :
  542. //
  543. // Move to the next character, as long as there
  544. // are no white spaces continue analyzing letters.
  545. // On the first bad letter, skip to the next
  546. // parameter.
  547. //
  548. ParamBuffer++;
  549. BufferIndex = AsciiToInteger( ParamBuffer );
  550. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  551. ParamReceived = TRUE;
  552. break;
  553. //
  554. // Update the desired access.
  555. //
  556. case 'c' :
  557. case 'C' :
  558. //
  559. // Move to the next character, as long as there
  560. // are no white spaces continue analyzing letters.
  561. // On the first bad letter, skip to the next
  562. // parameter.
  563. //
  564. ParamBuffer++;
  565. SwitchBool = TRUE;
  566. while (*ParamBuffer
  567. && *ParamBuffer != ' '
  568. && *ParamBuffer != '\t') {
  569. //
  570. // Perform switch on character.
  571. //
  572. switch (*ParamBuffer) {
  573. case 'a' :
  574. case 'A' :
  575. FileInfoClass = FileBasicInformation;
  576. break;
  577. case 'b' :
  578. case 'B' :
  579. FileInfoClass = FileStandardInformation;
  580. break;
  581. case 'c' :
  582. case 'C' :
  583. FileInfoClass = FileInternalInformation;
  584. break;
  585. case 'd' :
  586. case 'D' :
  587. FileInfoClass = FileEaInformation;
  588. break;
  589. case 'e' :
  590. case 'E' :
  591. FileInfoClass = FileAccessInformation;
  592. break;
  593. case 'f' :
  594. case 'F' :
  595. FileInfoClass = FileNameInformation;
  596. break;
  597. case 'g' :
  598. case 'G' :
  599. FileInfoClass = FilePositionInformation;
  600. break;
  601. case 'h' :
  602. case 'H' :
  603. FileInfoClass = FileModeInformation;
  604. break;
  605. case 'i' :
  606. case 'I' :
  607. FileInfoClass = FileAlignmentInformation;
  608. break;
  609. case 'j' :
  610. case 'J' :
  611. FileInfoClass = FileAllInformation;
  612. break;
  613. case 'k' :
  614. case 'K' :
  615. FileInfoClass = FileStreamInformation;
  616. break;
  617. case 'l' :
  618. case 'L' :
  619. FileInfoClass = FileAlternateNameInformation;
  620. break;
  621. case 'm' :
  622. case 'M' :
  623. FileInfoClass = FileNetworkOpenInformation;
  624. break;
  625. default :
  626. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  627. SwitchBool = FALSE;
  628. }
  629. if (!SwitchBool) {
  630. break;
  631. }
  632. ParamBuffer++;
  633. }
  634. break;
  635. default :
  636. //
  637. // Swallow to the next white space and continue the
  638. // loop.
  639. //
  640. ParamBuffer = SwallowNonWhite( ParamBuffer, &DummyCount );
  641. }
  642. }
  643. //
  644. // Else the text is invalid, skip the entire block.
  645. //
  646. //
  647. //
  648. // Else if there is no input then exit.
  649. //
  650. } else if ( LastInput ) {
  651. break;
  652. //
  653. // Else try to read another line for open parameters.
  654. //
  655. } else {
  656. }
  657. }
  658. //
  659. // If no parameters were received then display the syntax message.
  660. //
  661. if (!ParamReceived) {
  662. printf( "\n Usage: dqf [options]* -b<digits> [options]*\n" );
  663. printf( "\n Options:" );
  664. printf( "\n -b<digits> Buffer index" );
  665. printf( "\n -c<char> Key to buffer format" );
  666. printf( "\n\n" );
  667. //
  668. // Else call our display buffer routine.
  669. //
  670. } else {
  671. switch (FileInfoClass) {
  672. case FileBasicInformation:
  673. DisplayQFileBasicInformation( (USHORT) BufferIndex );
  674. break;
  675. case FileStandardInformation:
  676. DisplayQFileStandardInformation( (USHORT) BufferIndex );
  677. break;
  678. case FileInternalInformation:
  679. DisplayQFileInternalInformation( (USHORT) BufferIndex );
  680. break;
  681. case FileEaInformation:
  682. DisplayQFileEaInformation( (USHORT) BufferIndex );
  683. break;
  684. case FileAccessInformation:
  685. DisplayQFileAccessInformation( (USHORT) BufferIndex );
  686. break;
  687. case FileNameInformation:
  688. DisplayQFileNameInformation( (USHORT) BufferIndex );
  689. break;
  690. case FilePositionInformation:
  691. DisplayQFilePositionInformation( (USHORT) BufferIndex );
  692. break;
  693. case FileModeInformation:
  694. DisplayQFileModeInformation( (USHORT) BufferIndex );
  695. break;
  696. case FileAlignmentInformation:
  697. DisplayQFileAlignmentInformation( (USHORT) BufferIndex );
  698. break;
  699. case FileAllInformation:
  700. DisplayQFileAllInformation( (USHORT) BufferIndex );
  701. break;
  702. case FileStreamInformation:
  703. DisplayQFileStreamInformation( (USHORT) BufferIndex );
  704. break;
  705. case FileAlternateNameInformation:
  706. DisplayQFileAlternateNameInformation( (USHORT) BufferIndex );
  707. break;
  708. case FileNetworkOpenInformation:
  709. DisplayQFileNetworkQueryInformation( (USHORT) BufferIndex );
  710. break;
  711. }
  712. }
  713. }
  714. VOID
  715. DisplayQFileBasicInformation (
  716. IN USHORT BufferIndex
  717. )
  718. {
  719. PFILE_BASIC_INFORMATION FileInfo;
  720. if (!Buffers[BufferIndex].Used) {
  721. printf( "\nDisplayQFileBasicInformation: Invalid buffer\n" );
  722. return;
  723. }
  724. try {
  725. FileInfo = (PFILE_BASIC_INFORMATION) Buffers[BufferIndex].Buffer;
  726. printf( "\n\nBasic File Information\n" );
  727. DisplayBasicInformation( FileInfo );
  728. printf( "\n" );
  729. try_return( NOTHING );
  730. try_exit: NOTHING;
  731. } finally {
  732. if (AbnormalTermination()) {
  733. printf( "\nDisplayQFileBasicInformation: AbnormalTermination\n" );
  734. }
  735. }
  736. return;
  737. }
  738. VOID
  739. DisplayQFileStandardInformation (
  740. IN USHORT BufferIndex
  741. )
  742. {
  743. PFILE_STANDARD_INFORMATION FileInfo;
  744. if (!Buffers[BufferIndex].Used) {
  745. printf( "\nDisplayQFileStandardInformation: Invalid buffer\n" );
  746. return;
  747. }
  748. try {
  749. FileInfo = (PFILE_STANDARD_INFORMATION) Buffers[BufferIndex].Buffer;
  750. printf( "\n\nStandard File Information\n" );
  751. DisplayStandardInformation( FileInfo );
  752. printf( "\n" );
  753. try_return( NOTHING );
  754. try_exit: NOTHING;
  755. } finally {
  756. if (AbnormalTermination()) {
  757. printf( "\nDisplayQFileStandardInformation: AbnormalTermination\n" );
  758. }
  759. }
  760. return;
  761. }
  762. VOID
  763. DisplayQFileInternalInformation (
  764. IN USHORT BufferIndex
  765. )
  766. {
  767. PFILE_INTERNAL_INFORMATION FileInfo;
  768. if (!Buffers[BufferIndex].Used) {
  769. printf( "\nDisplayQFileInternalInformation: Invalid buffer\n" );
  770. return;
  771. }
  772. try {
  773. FileInfo = (PFILE_INTERNAL_INFORMATION) Buffers[BufferIndex].Buffer;
  774. printf( "\n\nInternal File Information\n" );
  775. DisplayInternalInformation( FileInfo );
  776. printf( "\n" );
  777. try_return( NOTHING );
  778. try_exit: NOTHING;
  779. } finally {
  780. if (AbnormalTermination()) {
  781. printf( "\nDisplayQFileInternalInformation: AbnormalTermination\n" );
  782. }
  783. }
  784. return;
  785. }
  786. VOID
  787. DisplayQFileEaInformation (
  788. IN USHORT BufferIndex
  789. )
  790. {
  791. PFILE_EA_INFORMATION FileInfo;
  792. if (!Buffers[BufferIndex].Used) {
  793. printf( "\nDisplayQFileEaInformation: Invalid buffer\n" );
  794. return;
  795. }
  796. try {
  797. FileInfo = (PFILE_EA_INFORMATION) Buffers[BufferIndex].Buffer;
  798. printf( "\n\nEa File Information\n" );
  799. DisplayEaInformation( FileInfo );
  800. printf( "\n" );
  801. try_return( NOTHING );
  802. try_exit: NOTHING;
  803. } finally {
  804. if (AbnormalTermination()) {
  805. printf( "\nDisplayQFileEaInformation: AbnormalTermination\n" );
  806. }
  807. }
  808. return;
  809. }
  810. VOID
  811. DisplayQFileAccessInformation (
  812. IN USHORT BufferIndex
  813. )
  814. {
  815. PFILE_ACCESS_INFORMATION FileInfo;
  816. if (!Buffers[BufferIndex].Used) {
  817. printf( "\nDisplayQFileAccessInformation: Invalid buffer\n" );
  818. return;
  819. }
  820. try {
  821. FileInfo = (PFILE_ACCESS_INFORMATION) Buffers[BufferIndex].Buffer;
  822. printf( "\n\nAccess File Information\n" );
  823. DisplayAccessInformation( FileInfo );
  824. printf( "\n" );
  825. try_return( NOTHING );
  826. try_exit: NOTHING;
  827. } finally {
  828. if (AbnormalTermination()) {
  829. printf( "\nDisplayQFileAccessInformation: AbnormalTermination\n" );
  830. }
  831. }
  832. return;
  833. }
  834. VOID
  835. DisplayQFileNameInformation (
  836. IN USHORT BufferIndex
  837. )
  838. {
  839. PFILE_NAME_INFORMATION FileInfo;
  840. if (!Buffers[BufferIndex].Used) {
  841. printf( "\nDisplayQFileNameInformation: Invalid buffer\n" );
  842. return;
  843. }
  844. try {
  845. FileInfo = (PFILE_NAME_INFORMATION) Buffers[BufferIndex].Buffer;
  846. printf( "\n\nName File Information\n" );
  847. DisplayNameInformation( FileInfo );
  848. printf( "\n" );
  849. try_return( NOTHING );
  850. try_exit: NOTHING;
  851. } finally {
  852. if (AbnormalTermination()) {
  853. printf( "\nDisplayQFileNameInformation: AbnormalTermination\n" );
  854. }
  855. }
  856. return;
  857. }
  858. VOID
  859. DisplayQFilePositionInformation (
  860. IN USHORT BufferIndex
  861. )
  862. {
  863. PFILE_POSITION_INFORMATION FileInfo;
  864. if (!Buffers[BufferIndex].Used) {
  865. printf( "\nDisplayQFilePositionInformation: Invalid buffer\n" );
  866. return;
  867. }
  868. try {
  869. FileInfo = (PFILE_POSITION_INFORMATION) Buffers[BufferIndex].Buffer;
  870. printf( "\n\nPosition File Information\n" );
  871. DisplayPositionInformation( FileInfo );
  872. printf( "\n" );
  873. try_return( NOTHING );
  874. try_exit: NOTHING;
  875. } finally {
  876. if (AbnormalTermination()) {
  877. printf( "\nDisplayQFilePositionInformation: AbnormalTermination\n" );
  878. }
  879. }
  880. return;
  881. }
  882. VOID
  883. DisplayQFileModeInformation (
  884. IN USHORT BufferIndex
  885. )
  886. {
  887. PFILE_MODE_INFORMATION FileInfo;
  888. if (!Buffers[BufferIndex].Used) {
  889. printf( "\nDisplayQFileModeInformation: Invalid buffer\n" );
  890. return;
  891. }
  892. try {
  893. FileInfo = (PFILE_MODE_INFORMATION) Buffers[BufferIndex].Buffer;
  894. printf( "\n\nMode File Information\n" );
  895. DisplayModeInformation( FileInfo );
  896. printf( "\n" );
  897. try_return( NOTHING );
  898. try_exit: NOTHING;
  899. } finally {
  900. if (AbnormalTermination()) {
  901. printf( "\nDisplayQFileModeInformation: AbnormalTermination\n" );
  902. }
  903. }
  904. return;
  905. }
  906. VOID
  907. DisplayQFileAlignmentInformation (
  908. IN USHORT BufferIndex
  909. )
  910. {
  911. PFILE_ALIGNMENT_INFORMATION FileInfo;
  912. if (!Buffers[BufferIndex].Used) {
  913. printf( "\nDisplayQFileAlignmentInformation: Invalid buffer\n" );
  914. return;
  915. }
  916. try {
  917. FileInfo = (PFILE_ALIGNMENT_INFORMATION) Buffers[BufferIndex].Buffer;
  918. printf( "\n\nAlignment File Information\n" );
  919. DisplayAlignmentInformation( FileInfo );
  920. printf( "\n" );
  921. try_return( NOTHING );
  922. try_exit: NOTHING;
  923. } finally {
  924. if (AbnormalTermination()) {
  925. printf( "\nDisplayQFileAlignmentInformation: AbnormalTermination\n" );
  926. }
  927. }
  928. return;
  929. }
  930. VOID
  931. DisplayQFileAllInformation (
  932. IN USHORT BufferIndex
  933. )
  934. {
  935. PFILE_ALL_INFORMATION FileInfo;
  936. if (!Buffers[BufferIndex].Used) {
  937. printf( "\nDisplayQFileAllInformation: Invalid buffer\n" );
  938. return;
  939. }
  940. try {
  941. FileInfo = (PFILE_ALL_INFORMATION) Buffers[BufferIndex].Buffer;
  942. printf( "\n\nAll File Information\n" );
  943. DisplayNameInformation( &FileInfo->NameInformation );
  944. DisplayBasicInformation( &FileInfo->BasicInformation );
  945. DisplayStandardInformation( &FileInfo->StandardInformation );
  946. DisplayInternalInformation( &FileInfo->InternalInformation );
  947. DisplayEaInformation( &FileInfo->EaInformation );
  948. DisplayAccessInformation( &FileInfo->AccessInformation );
  949. DisplayPositionInformation( &FileInfo->PositionInformation );
  950. DisplayModeInformation( &FileInfo->ModeInformation );
  951. DisplayAlignmentInformation( &FileInfo->AlignmentInformation );
  952. printf( "\n" );
  953. try_return( NOTHING );
  954. try_exit: NOTHING;
  955. } finally {
  956. if (AbnormalTermination()) {
  957. printf( "\nDisplayQFileBasicInformation: AbnormalTermination\n" );
  958. }
  959. }
  960. return;
  961. }
  962. VOID
  963. DisplayQFileStreamInformation (
  964. IN USHORT BufferIndex
  965. )
  966. {
  967. PFILE_STREAM_INFORMATION FileInfo;
  968. ULONG NextOffset;
  969. if (!Buffers[BufferIndex].Used) {
  970. printf( "\nDisplayQFileStreamInformation: Invalid buffer\n" );
  971. return;
  972. }
  973. try {
  974. NextOffset = 0;
  975. FileInfo = (PFILE_STREAM_INFORMATION) Buffers[BufferIndex].Buffer;
  976. printf( "\n\nStream File Information\n" );
  977. do {
  978. FileInfo = (PFILE_STREAM_INFORMATION) ((PUCHAR) FileInfo + NextOffset);
  979. DisplayStreamInformation( FileInfo );
  980. NextOffset = FileInfo->NextEntryOffset;
  981. } while ( NextOffset );
  982. printf( "\n" );
  983. try_return( NOTHING );
  984. try_exit: NOTHING;
  985. } finally {
  986. if (AbnormalTermination()) {
  987. printf( "\nDisplayQFileStreamInformation: AbnormalTermination\n" );
  988. }
  989. }
  990. return;
  991. }
  992. VOID
  993. DisplayQFileAlternateNameInformation (
  994. IN USHORT BufferIndex
  995. )
  996. {
  997. PFILE_NAME_INFORMATION FileInfo;
  998. if (!Buffers[BufferIndex].Used) {
  999. printf( "\nDisplayQFileAlternateNameInformation: Invalid buffer\n" );
  1000. return;
  1001. }
  1002. try {
  1003. FileInfo = (PFILE_NAME_INFORMATION) Buffers[BufferIndex].Buffer;
  1004. printf( "\n\nAlternate Name File Information\n" );
  1005. DisplayNameInformation( FileInfo );
  1006. printf( "\n" );
  1007. try_return( NOTHING );
  1008. try_exit: NOTHING;
  1009. } finally {
  1010. if (AbnormalTermination()) {
  1011. printf( "\nDisplayQFileAlternateNameInformation: AbnormalTermination\n" );
  1012. }
  1013. }
  1014. return;
  1015. }
  1016. VOID
  1017. DisplayQFileNetworkQueryInformation (
  1018. IN USHORT BufferIndex
  1019. )
  1020. {
  1021. PFILE_NETWORK_OPEN_INFORMATION FileInfo;
  1022. if (!Buffers[BufferIndex].Used) {
  1023. printf( "\nDisplayQFileNetworkQueryInformation: Invalid buffer\n" );
  1024. return;
  1025. }
  1026. try {
  1027. FileInfo = (PFILE_NETWORK_OPEN_INFORMATION) Buffers[BufferIndex].Buffer;
  1028. printf( "\n\nNetwork Open File Information\n" );
  1029. DisplayNetworkOpenInformation( FileInfo );
  1030. printf( "\n" );
  1031. try_return( NOTHING );
  1032. try_exit: NOTHING;
  1033. } finally {
  1034. if (AbnormalTermination()) {
  1035. printf( "\nDisplayQFileNetworkOpenInformation: AbnormalTermination\n" );
  1036. }
  1037. }
  1038. return;
  1039. }
  1040. VOID
  1041. DisplayBasicInformation (
  1042. IN PFILE_BASIC_INFORMATION FileInfo
  1043. )
  1044. {
  1045. printf( "\n\tCreation Time -> " );
  1046. PrintTime( &FileInfo->CreationTime );
  1047. printf( "\n\tLast Access Time -> " );
  1048. PrintTime( &FileInfo->LastAccessTime );
  1049. printf( "\n\tLast Write Time -> " );
  1050. PrintTime( &FileInfo->LastWriteTime );
  1051. printf( "\n\tChange Time -> " );
  1052. PrintTime( &FileInfo->ChangeTime );
  1053. printf( "\n\tFile Attributes -> %08lx", FileInfo->FileAttributes );
  1054. return;
  1055. }
  1056. VOID
  1057. DisplayStandardInformation (
  1058. IN PFILE_STANDARD_INFORMATION FileInfo
  1059. )
  1060. {
  1061. printf( "\n\tAllocation Size -> " );
  1062. PrintLargeInteger( &FileInfo->AllocationSize );
  1063. printf( "\n\tEnd Of File -> " );
  1064. PrintLargeInteger( &FileInfo->EndOfFile );
  1065. printf( "\n\tNumber of Links -> %08lx", FileInfo->NumberOfLinks );
  1066. printf( "\n\tDelete Pending -> %04x", FileInfo->DeletePending );
  1067. printf( "\n\tDirectory -> %d", FileInfo->Directory );
  1068. return;
  1069. }
  1070. VOID
  1071. DisplayInternalInformation (
  1072. IN PFILE_INTERNAL_INFORMATION FileInfo
  1073. )
  1074. {
  1075. printf( "\n\tFile Index.LowPart -> %08lx", FileInfo->IndexNumber.LowPart );
  1076. printf( "\n\tFile Index.HighPart -> %08lx", FileInfo->IndexNumber.HighPart );
  1077. printf( "\n\n\tFile Index.LowPart -> %ld", FileInfo->IndexNumber.LowPart );
  1078. printf( "\n\tFile Index.HighPart -> %ld", FileInfo->IndexNumber.HighPart );
  1079. return;
  1080. }
  1081. VOID
  1082. DisplayEaInformation (
  1083. IN PFILE_EA_INFORMATION FileInfo
  1084. )
  1085. {
  1086. printf( "\n\tEa Size -> %08lx", FileInfo->EaSize );
  1087. return;
  1088. }
  1089. VOID
  1090. DisplayAccessInformation (
  1091. IN PFILE_ACCESS_INFORMATION FileInfo
  1092. )
  1093. {
  1094. printf( "\n\tAccess Flags -> %08lx", FileInfo->AccessFlags );
  1095. return;
  1096. }
  1097. VOID
  1098. DisplayNameInformation (
  1099. IN PFILE_NAME_INFORMATION FileInfo
  1100. )
  1101. {
  1102. ANSI_STRING AnsiString;
  1103. UNICODE_STRING UnicodeString;
  1104. UnicodeString.MaximumLength =
  1105. UnicodeString.Length = (USHORT) FileInfo->FileNameLength;
  1106. UnicodeString.Buffer = (PWSTR) &FileInfo->FileName;
  1107. UnicodeString.MaximumLength += 2;
  1108. RtlUnicodeStringToAnsiString( &AnsiString,
  1109. &UnicodeString,
  1110. TRUE );
  1111. printf( "\n\tFile Name -> %s", AnsiString.Buffer );
  1112. RtlFreeAnsiString( &AnsiString );
  1113. return;
  1114. }
  1115. VOID
  1116. DisplayPositionInformation (
  1117. IN PFILE_POSITION_INFORMATION FileInfo
  1118. )
  1119. {
  1120. printf( "\n\tFile Position -> " );
  1121. PrintLargeInteger( &FileInfo->CurrentByteOffset );
  1122. return;
  1123. }
  1124. VOID
  1125. DisplayModeInformation (
  1126. IN PFILE_MODE_INFORMATION FileInfo
  1127. )
  1128. {
  1129. printf( "\n\tFile Mode -> %08lx", FileInfo->Mode );
  1130. return;
  1131. }
  1132. VOID
  1133. DisplayAlignmentInformation (
  1134. IN PFILE_ALIGNMENT_INFORMATION FileInfo
  1135. )
  1136. {
  1137. printf( "\n\tAlignment -> %08lx", FileInfo->AlignmentRequirement );
  1138. return;
  1139. }
  1140. VOID
  1141. DisplayStreamInformation (
  1142. IN PFILE_STREAM_INFORMATION FileInfo
  1143. )
  1144. {
  1145. UNICODE_STRING UnicodeString;
  1146. ANSI_STRING AnsiString;
  1147. printf( "\n\tStreamSize -> " );
  1148. PrintLargeInteger( &FileInfo->StreamSize );
  1149. printf( "\n\tStreamAllocationSize -> " );
  1150. PrintLargeInteger( &FileInfo->StreamAllocationSize );
  1151. printf( "\n\tStreamNameLength -> %08lx", FileInfo->StreamNameLength );
  1152. UnicodeString.MaximumLength = (USHORT) FileInfo->StreamNameLength + 2;
  1153. UnicodeString.Length = (USHORT) FileInfo->StreamNameLength;
  1154. UnicodeString.Buffer = (PWSTR) &FileInfo->StreamName;
  1155. RtlUnicodeStringToAnsiString( &AnsiString,
  1156. &UnicodeString,
  1157. TRUE );
  1158. printf( "\n\tStream Name -> %s", AnsiString.Buffer );
  1159. RtlFreeAnsiString( &AnsiString );
  1160. }
  1161. VOID
  1162. DisplayNetworkOpenInformation (
  1163. IN PFILE_NETWORK_OPEN_INFORMATION FileInfo
  1164. )
  1165. {
  1166. printf( "\n\tCreation Time -> " );
  1167. PrintTime( &FileInfo->CreationTime );
  1168. printf( "\n\tLast Access Time -> " );
  1169. PrintTime( &FileInfo->LastAccessTime );
  1170. printf( "\n\tLast Write Time -> " );
  1171. PrintTime( &FileInfo->LastWriteTime );
  1172. printf( "\n\tChange Time -> " );
  1173. PrintTime( &FileInfo->ChangeTime );
  1174. printf( "\n\tAllocation Size -> " );
  1175. PrintLargeInteger( &FileInfo->AllocationSize );
  1176. printf( "\n\tEnd Of File -> " );
  1177. PrintLargeInteger( &FileInfo->EndOfFile );
  1178. printf( "\n\tFile Attributes -> %08lx", FileInfo->FileAttributes );
  1179. }