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.

99 lines
2.7 KiB

  1. #define _NTAPI_ULIB_
  2. #include "ulib.hxx"
  3. extern "C" {
  4. #include "fmifs.h"
  5. };
  6. #include "fmifsmsg.hxx"
  7. #include "ifssys.hxx"
  8. #include "wstring.hxx"
  9. #include "ifsentry.hxx"
  10. #include "system.hxx"
  11. #include "drive.hxx"
  12. VOID
  13. Extend(
  14. IN PWSTR DriveName,
  15. IN BOOLEAN Verify,
  16. IN FMIFS_CALLBACK Callback
  17. )
  18. /*++
  19. Routine Description:
  20. This routine loads and calls the correct DLL to extend the
  21. given volume. Currently only NTFS can do this.
  22. This is is for either GUI or text mode.
  23. Arguments:
  24. DriveName - Supplies the DOS style drive name.
  25. Verify - Whether or not to verify the extended space
  26. Callback - Supplies the necessary call back for
  27. communication with the client
  28. Return Value:
  29. None.
  30. --*/
  31. {
  32. FMIFS_MESSAGE message;
  33. DSTRING extend_string;
  34. DSTRING library_name;
  35. DSTRING file_system_name;
  36. EXTEND_FN extend_function;
  37. HANDLE dll_handle;
  38. DSTRING ntdrivename;
  39. BOOLEAN result;
  40. DSTRING dosdrivename;
  41. FMIFS_FINISHED_INFORMATION finished_info;
  42. DWORD OldErrorMode;
  43. // Initialize the message object with the callback function.
  44. // Load the file system DLL.
  45. // Compute the NT style drive name.
  46. if (!message.Initialize(Callback) ||
  47. !extend_string.Initialize("Extend") ||
  48. !library_name.Initialize("U") ||
  49. !file_system_name.Initialize("NTFS") ||
  50. !library_name.Strcat(&file_system_name) ||
  51. !(extend_function = (EXTEND_FN)
  52. SYSTEM::QueryLibraryEntryPoint(&library_name,
  53. &extend_string,
  54. &dll_handle)) ||
  55. !dosdrivename.Initialize(DriveName) ||
  56. !IFS_SYSTEM::DosDriveNameToNtDriveName(&dosdrivename, &ntdrivename))
  57. {
  58. finished_info.Success = FALSE;
  59. Callback(FmIfsFinished,
  60. sizeof(FMIFS_FINISHED_INFORMATION),
  61. &finished_info);
  62. return;
  63. }
  64. // Disable hard-error popups.
  65. OldErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
  66. // Call chkdsk.
  67. result = extend_function(&ntdrivename,
  68. &message,
  69. Verify
  70. );
  71. // Enable hard-error popups.
  72. SetErrorMode( OldErrorMode );
  73. SYSTEM::FreeLibraryHandle(dll_handle);
  74. finished_info.Success = result;
  75. Callback(FmIfsFinished,
  76. sizeof(FMIFS_FINISHED_INFORMATION),
  77. &finished_info);
  78. }