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.

55 lines
1.5 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. PVOLSNAP_NAME name;
  16. CHAR buffer[100];
  17. if (argc != 3) {
  18. printf("usage: %s drive: <diff area drive>:\n", argv[0]);
  19. return;
  20. }
  21. swprintf(driveName, L"\\\\?\\%c:", toupper(argv[1][0]));
  22. handle = CreateFile(driveName, GENERIC_READ | GENERIC_WRITE,
  23. FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
  24. OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
  25. INVALID_HANDLE_VALUE);
  26. if (handle == INVALID_HANDLE_VALUE) {
  27. printf("Could not open the given volume %d\n", GetLastError());
  28. return;
  29. }
  30. name = (PVOLSNAP_NAME) buffer;
  31. name->NameLength = 12;
  32. name->Name[0] = '\\';
  33. name->Name[1] = '?';
  34. name->Name[2] = '?';
  35. name->Name[3] = '\\';
  36. name->Name[4] = (WCHAR) toupper(argv[2][0]);
  37. name->Name[5] = ':';
  38. name->Name[6] = 0;
  39. b = DeviceIoControl(handle, IOCTL_VOLSNAP_ADD_VOLUME_TO_DIFF_AREA,
  40. name, 100, NULL, 0, &bytes, NULL);
  41. if (!b) {
  42. printf("Add to diff area failed with %d\n", GetLastError());
  43. return;
  44. }
  45. printf("Added %c: to Diff Area for %c:\n", toupper(argv[2][0]),
  46. toupper(argv[1][0]));
  47. }