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.

828 lines
23 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. tfat.c
  5. Abstract:
  6. Test program for the Fat File system
  7. Author:
  8. Gary Kimura [GaryKi] 24-May-1989
  9. Revision History:
  10. --*/
  11. #include <stdio.h>
  12. #include <string.h>
  13. #define toupper(C) ((C) >= 'a' && (C) <= 'z' ? (C) - ('a' - 'A') : (C))
  14. #define isdigit(C) ((C) >= '0' && (C) <= '9')
  15. #include <nt.h>
  16. #include <ntrtl.h>
  17. #include <nturtl.h>
  18. #define simprintf(X,Y) {if (!Silent) {printf(X,Y);} }
  19. BOOLEAN Silent;
  20. //
  21. // The buffer size must be a multiple of 512
  22. //
  23. #define BUFFERSIZE 1024
  24. UCHAR Buffer[BUFFERSIZE];
  25. CHAR Prefix[64];
  26. ULONG WriteThrough = 0;
  27. VOID
  28. WaitForSingleObjectError(
  29. IN NTSTATUS Status
  30. );
  31. VOID
  32. CreateFileError(
  33. IN NTSTATUS Status,
  34. PCHAR File
  35. );
  36. VOID
  37. OpenFileError(
  38. IN NTSTATUS Status,
  39. PCHAR File
  40. );
  41. VOID
  42. ReadFileError(
  43. IN NTSTATUS Status
  44. );
  45. VOID
  46. WriteFileError(
  47. IN NTSTATUS Status
  48. );
  49. VOID
  50. CheckIoStatus(
  51. IN PIO_STATUS_BLOCK IoStatus,
  52. IN ULONG Length,
  53. IN BOOLEAN Read
  54. );
  55. VOID
  56. SetInformationFileError(
  57. IN NTSTATUS Status
  58. );
  59. VOID
  60. QueryInformationFileError(
  61. IN NTSTATUS Status
  62. );
  63. VOID
  64. CloseError(
  65. IN NTSTATUS Status
  66. );
  67. VOID
  68. IoStatusError(
  69. IN NTSTATUS Status
  70. );
  71. VOID
  72. main(
  73. int argc,
  74. char *argv[]
  75. )
  76. {
  77. ULONG i;
  78. ULONG Count;
  79. VOID FatMain();
  80. CHAR Device[8];
  81. STRING NtDevice;
  82. CHAR NtDeviceBuffer[32];
  83. if (argc <= 1) {
  84. printf("usage: %s drive: [iterations [writethrough] ]\n", argv[0]);
  85. return;
  86. }
  87. //
  88. // Decode the device/drive
  89. //
  90. strcpy( Device, argv[1] );
  91. NtDevice.MaximumLength = NtDevice.Length = 32;
  92. NtDevice.Buffer = NtDeviceBuffer;
  93. if (!RtlDosPathNameToNtPathName( Device, &NtDevice, NULL, NULL )) {
  94. printf( "Invalid Dos Device Name\n" );
  95. RtlFreeHeap(RtlProcessHeap(), 0, NtDevice.Buffer);
  96. return;
  97. }
  98. if (NtDevice.Length > 31) {
  99. NtDevice.Length = 31;
  100. }
  101. NtDevice.Buffer[NtDevice.Length] = 0;
  102. //
  103. // Now do the iteration count
  104. //
  105. if (argc >= 3) {
  106. Count = 0;
  107. for (i = 0; isdigit(argv[2][i]); i += 1) {
  108. Count = Count * 10 + argv[2][i] - '0';
  109. }
  110. } else {
  111. Count = 1;
  112. }
  113. //
  114. // Check for write through
  115. //
  116. if (argc >= 4) {
  117. WriteThrough = FILE_WRITE_THROUGH;
  118. }
  119. //
  120. // Check for silent operation
  121. //
  122. if (toupper(Device[0]) != Device[0]) {
  123. Silent = TRUE;
  124. } else {
  125. Silent = FALSE;
  126. }
  127. //
  128. // Do the work
  129. //
  130. FatMain(Count, NtDevice.Buffer);
  131. RtlFreeHeap(RtlProcessHeap(), 0, NtDevice.Buffer);
  132. return;
  133. }
  134. VOID
  135. FatMain(
  136. IN ULONG LoopCount,
  137. IN CHAR Device[]
  138. )
  139. {
  140. VOID Create(),Delete(),Mkdir(),Directory(),Read();
  141. CHAR Str[64];
  142. CHAR LoopStr[64];
  143. ULONG i;
  144. LARGE_INTEGER Time;
  145. printf("FatMain %d\n", LoopCount);
  146. NtQuerySystemTime(&Time);
  147. strcpy( Prefix, Device);
  148. Prefix[48] = 0;
  149. RtlIntegerToChar((ULONG)NtCurrentTeb()->ClientId.UniqueProcess, 16, -8, &Prefix[strlen(Device)]);
  150. Mkdir( Prefix );
  151. Directory( Device );
  152. Directory( Prefix );
  153. for (i = 0; i < LoopCount; i += 1) {
  154. NtQuerySystemTime(&Time);
  155. strcpy(LoopStr, "Start loop xxxxxxxx ");
  156. RtlIntegerToChar(i, 16, -8, &LoopStr[11]);
  157. strcat( LoopStr, Prefix );
  158. printf(LoopStr);
  159. printf("\n");
  160. strcpy( Str, Prefix ); Create( strcat( Str, "\\1.tmp" ), Time.LowPart, 1 );
  161. strcpy( Str, Prefix ); Create( strcat( Str, "\\2.tmp" ), Time.LowPart, 2 );
  162. strcpy( Str, Prefix ); Create( strcat( Str, "\\4.tmp" ), Time.LowPart, 4 );
  163. strcpy( Str, Prefix ); Create( strcat( Str, "\\8.tmp" ), Time.LowPart, 8 );
  164. strcpy( Str, Prefix ); Create( strcat( Str, "\\16.tmp" ), Time.LowPart, 16 );
  165. strcpy( Str, Prefix ); Create( strcat( Str, "\\32.tmp" ), Time.LowPart, 32 );
  166. strcpy( Str, Prefix ); Create( strcat( Str, "\\64.tmp" ), Time.LowPart, 64 );
  167. strcpy( Str, Prefix ); Create( strcat( Str, "\\128.tmp" ), Time.LowPart, 128 );
  168. strcpy( Str, Prefix ); Create( strcat( Str, "\\236.tmp" ), Time.LowPart, 256 );
  169. strcpy( Str, Prefix ); Create( strcat( Str, "\\512.tmp" ), Time.LowPart, 512 );
  170. strcpy( Str, Prefix ); Create( strcat( Str, "\\1024.tmp" ), Time.LowPart, 1024 );
  171. strcpy( Str, Prefix ); Create( strcat( Str, "\\2048.tmp" ), Time.LowPart, 2048 );
  172. strcpy( Str, Prefix ); Create( strcat( Str, "\\4096.tmp" ), Time.LowPart, 4096 );
  173. strcpy( Str, Prefix ); Create( strcat( Str, "\\8192.tmp" ), Time.LowPart, 8192 );
  174. strcpy( Str, Prefix ); Create( strcat( Str, "\\16384.tmp" ), Time.LowPart, 16384 );
  175. strcpy( Str, Prefix ); Create( strcat( Str, "\\32768.tmp" ), Time.LowPart, 32768 );
  176. strcpy( Str, Prefix ); Read( strcat( Str, "\\1.tmp" ), Time.LowPart, 1 );
  177. strcpy( Str, Prefix ); Read( strcat( Str, "\\2.tmp" ), Time.LowPart, 2 );
  178. strcpy( Str, Prefix ); Read( strcat( Str, "\\4.tmp" ), Time.LowPart, 4 );
  179. strcpy( Str, Prefix ); Read( strcat( Str, "\\8.tmp" ), Time.LowPart, 8 );
  180. strcpy( Str, Prefix ); Read( strcat( Str, "\\16.tmp" ), Time.LowPart, 16 );
  181. strcpy( Str, Prefix ); Read( strcat( Str, "\\32.tmp" ), Time.LowPart, 32 );
  182. strcpy( Str, Prefix ); Read( strcat( Str, "\\64.tmp" ), Time.LowPart, 64 );
  183. strcpy( Str, Prefix ); Read( strcat( Str, "\\128.tmp" ), Time.LowPart, 128 );
  184. strcpy( Str, Prefix ); Read( strcat( Str, "\\236.tmp" ), Time.LowPart, 256 );
  185. strcpy( Str, Prefix ); Read( strcat( Str, "\\512.tmp" ), Time.LowPart, 512 );
  186. strcpy( Str, Prefix ); Read( strcat( Str, "\\1024.tmp" ), Time.LowPart, 1024 );
  187. strcpy( Str, Prefix ); Read( strcat( Str, "\\2048.tmp" ), Time.LowPart, 2048 );
  188. strcpy( Str, Prefix ); Read( strcat( Str, "\\4096.tmp" ), Time.LowPart, 4096 );
  189. strcpy( Str, Prefix ); Read( strcat( Str, "\\8192.tmp" ), Time.LowPart, 8192 );
  190. strcpy( Str, Prefix ); Read( strcat( Str, "\\16384.tmp" ), Time.LowPart, 16384 );
  191. strcpy( Str, Prefix ); Read( strcat( Str, "\\32768.tmp" ), Time.LowPart, 32768 );
  192. Directory( Device );
  193. Directory( Prefix );
  194. strcpy( Str, Prefix ); Delete( strcat( Str, "\\1.tmp" ) );
  195. strcpy( Str, Prefix ); Delete( strcat( Str, "\\2.tmp" ) );
  196. strcpy( Str, Prefix ); Delete( strcat( Str, "\\4.tmp" ) );
  197. strcpy( Str, Prefix ); Delete( strcat( Str, "\\8.tmp" ) );
  198. strcpy( Str, Prefix ); Delete( strcat( Str, "\\16.tmp" ) );
  199. strcpy( Str, Prefix ); Delete( strcat( Str, "\\32.tmp" ) );
  200. strcpy( Str, Prefix ); Delete( strcat( Str, "\\64.tmp" ) );
  201. strcpy( Str, Prefix ); Delete( strcat( Str, "\\128.tmp" ) );
  202. strcpy( Str, Prefix ); Delete( strcat( Str, "\\236.tmp" ) );
  203. strcpy( Str, Prefix ); Delete( strcat( Str, "\\512.tmp" ) );
  204. strcpy( Str, Prefix ); Delete( strcat( Str, "\\1024.tmp" ) );
  205. strcpy( Str, Prefix ); Delete( strcat( Str, "\\2048.tmp" ) );
  206. strcpy( Str, Prefix ); Delete( strcat( Str, "\\4096.tmp" ) );
  207. strcpy( Str, Prefix ); Delete( strcat( Str, "\\8192.tmp" ) );
  208. strcpy( Str, Prefix ); Delete( strcat( Str, "\\16384.tmp" ) );
  209. strcpy( Str, Prefix ); Delete( strcat( Str, "\\32768.tmp" ) );
  210. Directory( Device );
  211. Directory( Prefix );
  212. }
  213. printf( "Done\n" );
  214. return;
  215. }
  216. VOID Create(
  217. IN PCHAR FileName,
  218. IN ULONG FileTime,
  219. IN ULONG FileCount
  220. )
  221. {
  222. NTSTATUS Status;
  223. HANDLE FileHandle;
  224. OBJECT_ATTRIBUTES ObjectAttributes;
  225. STRING NameString;
  226. IO_STATUS_BLOCK IoStatus;
  227. LARGE_INTEGER AllocationSize;
  228. LARGE_INTEGER ByteOffset;
  229. ULONG Count;
  230. ULONG Pattern[3];
  231. //
  232. // Get the filename
  233. //
  234. simprintf("Create ", 0); simprintf(FileName, 0); simprintf("\n", 0);
  235. //
  236. // Create the new file
  237. //
  238. AllocationSize = LiFromUlong( FileCount * 4 );
  239. RtlInitString( &NameString, FileName );
  240. InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL );
  241. if (!NT_SUCCESS(Status = NtCreateFile( &FileHandle,
  242. FILE_WRITE_DATA | SYNCHRONIZE,
  243. &ObjectAttributes,
  244. &IoStatus,
  245. &AllocationSize,
  246. FILE_ATTRIBUTE_NORMAL,
  247. 0L,
  248. FILE_SUPERSEDE,
  249. WriteThrough,
  250. (PVOID)NULL,
  251. 0L ))) {
  252. CreateFileError( Status , FileName );
  253. return;
  254. }
  255. //
  256. // The main loop writes out the test pattern our test pattern
  257. // is <FileTime> <FileSize> <Count> where count is the current
  258. // iteration count for the current test pattern output.
  259. //
  260. Pattern[0] = FileTime;
  261. Pattern[1] = FileCount;
  262. for (Count = 0; Count < FileCount; Count += 1) {
  263. Pattern[2] = Count;
  264. ByteOffset = LiFromUlong( Count * 3 * 4 );
  265. if (!NT_SUCCESS(Status = NtWriteFile( FileHandle,
  266. (HANDLE)NULL,
  267. (PIO_APC_ROUTINE)NULL,
  268. (PVOID)NULL,
  269. &IoStatus,
  270. Pattern,
  271. 3 * 4,
  272. &ByteOffset,
  273. (PULONG) NULL ))) {
  274. WriteFileError( Status );
  275. return;
  276. }
  277. if (!NT_SUCCESS(Status = NtWaitForSingleObject(FileHandle, TRUE, NULL))) {
  278. WaitForSingleObjectError( Status );
  279. return;
  280. }
  281. //
  282. // check how the write turned out
  283. //
  284. CheckIoStatus( &IoStatus, 3 * 4, FALSE );
  285. if (!NT_SUCCESS(IoStatus.Status)) {
  286. IoStatusError( IoStatus.Status );
  287. break;
  288. }
  289. }
  290. //
  291. // Now close the file
  292. //
  293. if (!NT_SUCCESS(Status = NtClose( FileHandle ))) {
  294. CloseError( Status );
  295. }
  296. //
  297. // And return to our caller
  298. //
  299. return;
  300. }
  301. VOID Read(
  302. IN PCHAR FileName,
  303. IN ULONG FileTime,
  304. IN ULONG FileCount
  305. )
  306. {
  307. NTSTATUS Status;
  308. HANDLE FileHandle;
  309. OBJECT_ATTRIBUTES ObjectAttributes;
  310. STRING NameString;
  311. IO_STATUS_BLOCK IoStatus;
  312. LARGE_INTEGER AllocationSize;
  313. LARGE_INTEGER ByteOffset;
  314. ULONG Count;
  315. ULONG Pattern[3];
  316. //
  317. // Get the filename
  318. //
  319. simprintf("Read ", 0); simprintf(FileName, 0); simprintf("\n", 0);
  320. //
  321. // Open the existing file
  322. //
  323. AllocationSize = LiFromUlong( FileCount * 4 );
  324. RtlInitString( &NameString, FileName );
  325. InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL );
  326. if (!NT_SUCCESS(Status = NtOpenFile( &FileHandle,
  327. FILE_READ_DATA | FILE_READ_ATTRIBUTES | SYNCHRONIZE,
  328. &ObjectAttributes,
  329. &IoStatus,
  330. 0L,
  331. WriteThrough ))) {
  332. OpenFileError( Status, FileName );
  333. return;
  334. }
  335. //
  336. // The main loop read in the test pattern our test pattern
  337. // is <FileTime> <FileSize> <Count> where count is the current
  338. // iteration count for the current test pattern output.
  339. //
  340. for (Count = 0; Count < FileCount; Count += 1) {
  341. ByteOffset = LiFromUlong( Count * 3 * 4 );
  342. if (!NT_SUCCESS(Status = NtReadFile( FileHandle,
  343. (HANDLE)NULL,
  344. (PIO_APC_ROUTINE)NULL,
  345. (PVOID)NULL,
  346. &IoStatus,
  347. Pattern,
  348. 3 * 4,
  349. &ByteOffset,
  350. (PULONG) NULL ))) {
  351. ReadFileError( Status );
  352. return;
  353. }
  354. if (!NT_SUCCESS(Status = NtWaitForSingleObject(FileHandle, TRUE, NULL))) {
  355. WaitForSingleObjectError( Status );
  356. return;
  357. }
  358. //
  359. // check how the read turned out
  360. //
  361. CheckIoStatus( &IoStatus, 3 * 4, TRUE );
  362. if (!NT_SUCCESS(IoStatus.Status)) {
  363. IoStatusError( IoStatus.Status );
  364. break;
  365. }
  366. //
  367. // Now compare the what we read with what we should have read
  368. //
  369. if ((Pattern[0] != FileTime) ||
  370. (Pattern[1] != FileCount) ||
  371. (Pattern[2] != Count)) {
  372. printf("**** Read Error ****\n");
  373. NtPartyByNumber( 50 );
  374. return;
  375. }
  376. }
  377. //
  378. // Now close the file
  379. //
  380. if (!NT_SUCCESS(Status = NtClose( FileHandle ))) {
  381. CloseError( Status );
  382. }
  383. //
  384. // And return to our caller
  385. //
  386. return;
  387. }
  388. VOID Delete(
  389. IN PCHAR FileName
  390. )
  391. {
  392. NTSTATUS Status;
  393. HANDLE FileHandle;
  394. OBJECT_ATTRIBUTES ObjectAttributes;
  395. STRING NameString;
  396. IO_STATUS_BLOCK IoStatus;
  397. //
  398. // Get the filename
  399. //
  400. simprintf("Delete ", 0); simprintf(FileName, 0); simprintf("\n", 0);
  401. //
  402. // Open the file for delete access
  403. //
  404. RtlInitString( &NameString, FileName );
  405. InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL );
  406. if (!NT_SUCCESS(Status = NtCreateFile( &FileHandle,
  407. DELETE | SYNCHRONIZE,
  408. &ObjectAttributes,
  409. &IoStatus,
  410. (PLARGE_INTEGER)NULL,
  411. 0L,
  412. 0L,
  413. FILE_OPEN,
  414. WriteThrough,
  415. (PVOID)NULL,
  416. 0L ))) {
  417. CreateFileError( Status, FileName );
  418. return;
  419. }
  420. //
  421. // Mark the file for delete
  422. //
  423. ((PFILE_DISPOSITION_INFORMATION)&Buffer[0])->DeleteFile = TRUE;
  424. if (!NT_SUCCESS(Status = NtSetInformationFile( FileHandle,
  425. &IoStatus,
  426. Buffer,
  427. sizeof(FILE_DISPOSITION_INFORMATION),
  428. FileDispositionInformation))) {
  429. SetInformationFileError( Status );
  430. return;
  431. }
  432. //
  433. // Now close the file
  434. //
  435. if (!NT_SUCCESS(Status = NtClose( FileHandle ))) {
  436. CloseError( Status );
  437. }
  438. //
  439. // And return to our caller
  440. //
  441. return;
  442. }
  443. VOID Directory(
  444. IN PCHAR String
  445. )
  446. {
  447. NTSTATUS Status;
  448. HANDLE FileHandle;
  449. OBJECT_ATTRIBUTES ObjectAttributes;
  450. STRING NameString;
  451. IO_STATUS_BLOCK IoStatus;
  452. NTSTATUS NtStatus;
  453. PFILE_ADIRECTORY_INFORMATION FileInfo;
  454. ULONG i;
  455. //
  456. // Get the filename
  457. //
  458. simprintf("Directory ", 0);
  459. simprintf(String, 0);
  460. simprintf("\n", 0);
  461. //
  462. // Open the file for list directory access
  463. //
  464. RtlInitString( &NameString, String );
  465. InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL );
  466. if (!NT_SUCCESS(Status = NtOpenFile( &FileHandle,
  467. FILE_LIST_DIRECTORY | SYNCHRONIZE,
  468. &ObjectAttributes,
  469. &IoStatus,
  470. FILE_SHARE_READ,
  471. WriteThrough | FILE_DIRECTORY_FILE ))) {
  472. OpenFileError( Status , String );
  473. return;
  474. }
  475. //
  476. // zero out the buffer so next time we'll recognize the end of data
  477. //
  478. for (i = 0; i < BUFFERSIZE; i += 1) { Buffer[i] = 0; }
  479. //
  480. // Do the directory loop
  481. //
  482. for (NtStatus = NtQueryDirectoryFile( FileHandle,
  483. (HANDLE)NULL,
  484. (PIO_APC_ROUTINE)NULL,
  485. (PVOID)NULL,
  486. &IoStatus,
  487. Buffer,
  488. BUFFERSIZE,
  489. FileADirectoryInformation,
  490. FALSE,
  491. (PSTRING)NULL,
  492. TRUE);
  493. NT_SUCCESS(NtStatus);
  494. NtStatus = NtQueryDirectoryFile( FileHandle,
  495. (HANDLE)NULL,
  496. (PIO_APC_ROUTINE)NULL,
  497. (PVOID)NULL,
  498. &IoStatus,
  499. Buffer,
  500. BUFFERSIZE,
  501. FileADirectoryInformation,
  502. FALSE,
  503. (PSTRING)NULL,
  504. FALSE) ) {
  505. if (!NT_SUCCESS(Status = NtWaitForSingleObject(FileHandle, TRUE, NULL))) {
  506. // NtPartyByNumber(50);
  507. WaitForSingleObjectError( Status );
  508. return;
  509. }
  510. //
  511. // Check the Irp for success
  512. //
  513. if (!NT_SUCCESS(IoStatus.Status)) {
  514. break;
  515. }
  516. //
  517. // For every record in the buffer type out the directory information
  518. //
  519. //
  520. // Point to the first record in the buffer, we are guaranteed to have
  521. // one otherwise IoStatus would have been No More Files
  522. //
  523. FileInfo = (PFILE_ADIRECTORY_INFORMATION)&Buffer[0];
  524. while (TRUE) {
  525. //
  526. // Print out information about the file
  527. //
  528. simprintf("%8lx ", FileInfo->FileAttributes);
  529. simprintf("%8lx/", FileInfo->EndOfFile.LowPart);
  530. simprintf("%8lx ", FileInfo->AllocationSize.LowPart);
  531. {
  532. CHAR Saved;
  533. Saved = FileInfo->FileName[FileInfo->FileNameLength];
  534. FileInfo->FileName[FileInfo->FileNameLength] = 0;
  535. simprintf(FileInfo->FileName, 0);
  536. FileInfo->FileName[FileInfo->FileNameLength] = Saved;
  537. }
  538. simprintf("\n", 0);
  539. //
  540. // Check if there is another record, if there isn't then we
  541. // simply get out of this loop
  542. //
  543. if (FileInfo->NextEntryOffset == 0) {
  544. break;
  545. }
  546. //
  547. // There is another record so advance FileInfo to the next
  548. // record
  549. //
  550. FileInfo = (PFILE_ADIRECTORY_INFORMATION)(((PUCHAR)FileInfo) + FileInfo->NextEntryOffset);
  551. }
  552. //
  553. // zero out the buffer so next time we'll recognize the end of data
  554. //
  555. for (i = 0; i < BUFFERSIZE; i += 1) { Buffer[i] = 0; }
  556. }
  557. //
  558. // Now close the file
  559. //
  560. if (!NT_SUCCESS(Status = NtClose( FileHandle ))) {
  561. CloseError( Status );
  562. }
  563. //
  564. // And return to our caller
  565. //
  566. return;
  567. }
  568. VOID Mkdir(
  569. IN PCHAR String
  570. )
  571. {
  572. NTSTATUS Status;
  573. HANDLE FileHandle;
  574. OBJECT_ATTRIBUTES ObjectAttributes;
  575. STRING NameString;
  576. IO_STATUS_BLOCK IoStatus;
  577. LARGE_INTEGER AllocationSize;
  578. //
  579. // Get the filename
  580. //
  581. simprintf("Mkdir ", 0);
  582. simprintf(String, 0);
  583. simprintf("\n", 0);
  584. //
  585. // Create the new directory
  586. //
  587. AllocationSize = LiFromLong( 4 );
  588. RtlInitString( &NameString, String );
  589. InitializeObjectAttributes( &ObjectAttributes, &NameString, 0, NULL, NULL );
  590. if (!NT_SUCCESS(Status = NtCreateFile( &FileHandle,
  591. SYNCHRONIZE,
  592. &ObjectAttributes,
  593. &IoStatus,
  594. &AllocationSize,
  595. 0L,
  596. 0L,
  597. FILE_CREATE,
  598. WriteThrough | FILE_DIRECTORY_FILE,
  599. (PVOID)NULL,
  600. 0L ))) {
  601. CreateFileError( Status , String );
  602. return;
  603. }
  604. //
  605. // Now close the directory
  606. //
  607. if (!NT_SUCCESS(Status = NtClose( FileHandle ))) {
  608. CloseError( Status );
  609. }
  610. //
  611. // And return to our caller
  612. //
  613. return;
  614. }
  615. VOID WaitForSingleObjectError(NTSTATUS Status)
  616. { printf("%s WaitForSingleObject Error %X\n", Prefix, Status); }
  617. VOID CreateFileError(NTSTATUS Status, PCHAR File)
  618. { printf("%s CreateFile of %s Error %X\n", Prefix, File, Status); }
  619. VOID OpenFileError(NTSTATUS Status, PCHAR File)
  620. { printf("%s OpenFile of %s Error %X\n", Prefix, File, Status); }
  621. VOID ReadFileError(NTSTATUS Status)
  622. { printf("%s ReadFile Error %X\n", Prefix, Status); }
  623. VOID WriteFileError(NTSTATUS Status)
  624. { printf("%s WriteFile Error %X\n", Prefix, Status); }
  625. VOID SetInformationFileError(NTSTATUS Status)
  626. { printf("%s SetInfoFile Error %X\n", Prefix, Status); }
  627. VOID QueryInformationFileError(NTSTATUS Status)
  628. { printf("%s QueryInfoFile Error %X\n", Prefix, Status); }
  629. VOID CloseError(NTSTATUS Status)
  630. { printf("%s Close Error %X\n", Prefix, Status); }
  631. VOID IoStatusError(NTSTATUS Status)
  632. { printf("%s IoStatus Error %X\n", Prefix, Status); }
  633. VOID CheckIoStatus(PIO_STATUS_BLOCK IoStatus, ULONG Length, BOOLEAN Read)
  634. {
  635. if (!NT_SUCCESS(IoStatus->Status)) {
  636. printf(" IoStatus->Status Error %08lx\n", IoStatus->Status);
  637. }
  638. if ((!Read && (IoStatus->Information != Length))
  639. ||
  640. (Read && (IoStatus->Information > Length))) {
  641. printf(" IoStatus->Information Error %08lx\n", IoStatus->Information);
  642. }
  643. }
  644.