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.

42 lines
1.1 KiB

  1. #include <windows.h>
  2. #include <winioctl.h>
  3. #include <ntddsnap.h>
  4. #include <stdio.h>
  5. void __cdecl
  6. main(
  7. int argc,
  8. char** argv
  9. )
  10. {
  11. WCHAR driveName[10];
  12. HANDLE handle;
  13. BOOL b;
  14. DWORD bytes;
  15. if (argc != 2) {
  16. printf("usage: %s drive:\n", argv[0]);
  17. return;
  18. }
  19. swprintf(driveName, L"\\\\?\\%c:", toupper(argv[1][0]));
  20. handle = CreateFile(driveName, GENERIC_READ | GENERIC_WRITE,
  21. FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
  22. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
  23. INVALID_HANDLE_VALUE);
  24. if (handle == INVALID_HANDLE_VALUE) {
  25. printf("Could not open the given volume %d\n", GetLastError());
  26. return;
  27. }
  28. b = DeviceIoControl(handle, IOCTL_VOLSNAP_CLEAR_DIFF_AREA,
  29. NULL, 0, NULL, 0, &bytes, NULL);
  30. if (!b) {
  31. printf("Clear diff area failed with %d\n", GetLastError());
  32. return;
  33. }
  34. printf("Diff Area Cleared.\n");
  35. }