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.

92 lines
2.5 KiB

  1. #include <nt.h>
  2. #include <ntddft.h>
  3. #include <ntdddisk.h>
  4. #include <ntrtl.h>
  5. #include <nturtl.h>
  6. #include <windows.h>
  7. #include <stdio.h>
  8. #include <process.h>
  9. #include <memory.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. int __cdecl
  14. main( int argc, char **argv )
  15. {
  16. PARTITION_INFORMATION PartitionInfo;
  17. FT_SYNC_INFORMATION SyncInfo;
  18. BYTE DriveNameBuffer[32];
  19. HANDLE VolumeHandle;
  20. ULONG BytesTransferred;
  21. if( argc < 2 ) {
  22. printf( "usage: %s DosDriveName: [-b:StartingSector] [-e:EndingSector]\n", argv[0] );
  23. exit(4);
  24. }
  25. memset( DriveNameBuffer, 0, sizeof( DriveNameBuffer ) );
  26. strcat( DriveNameBuffer, "\\\\.\\" );
  27. strcat( DriveNameBuffer, argv[1] );
  28. // Open the volume with the DOS name.
  29. //
  30. VolumeHandle = CreateFile( DriveNameBuffer,
  31. GENERIC_READ,
  32. FILE_SHARE_READ | FILE_SHARE_WRITE,
  33. NULL,
  34. OPEN_EXISTING,
  35. 0,
  36. 0 );
  37. if( VolumeHandle == INVALID_HANDLE_VALUE ) {
  38. printf( "Unable to open %s [Error %d]\n", argv[1], GetLastError() );
  39. exit(4);
  40. }
  41. // GetFile information.
  42. //
  43. if( !DeviceIoControl( VolumeHandle,
  44. IOCTL_DISK_GET_PARTITION_INFO,
  45. NULL,
  46. 0,
  47. &PartitionInfo,
  48. sizeof( PartitionInfo ),
  49. &BytesTransferred,
  50. NULL ) ) {
  51. printf( "Unable to get volume size [Error %d].\n", GetLastError() );
  52. CloseHandle( VolumeHandle );
  53. exit(4);
  54. }
  55. // Synchronize the parity information for the entire volume:
  56. //
  57. SyncInfo.ByteOffset.QuadPart = 0;
  58. SyncInfo.ByteCount = PartitionInfo.PartitionLength;
  59. // Issue the IOCTL
  60. //
  61. if( !DeviceIoControl( VolumeHandle,
  62. FT_SYNC_REDUNDANT_COPY,
  63. &SyncInfo,
  64. sizeof( SyncInfo ),
  65. NULL,
  66. 0,
  67. &BytesTransferred,
  68. NULL ) ) {
  69. printf( "Synchronization failed (Error %d).\n", GetLastError() );
  70. } else {
  71. printf( "Synchronization complete.\n" );
  72. }
  73. CloseHandle( VolumeHandle );
  74. return( 0 );
  75. }