[DISKPART] Prevent drive letter changes on boot or system volumes

This commit is contained in:
Eric Kohl
2026-01-12 19:35:38 +01:00
parent a40bd103fc
commit 702f9c6f77
14 changed files with 24 additions and 0 deletions
+6
View File
@@ -74,6 +74,12 @@ assign_main(
}
}
if (CurrentVolume->IsBoot || CurrentVolume->IsSystem)
{
ConResPuts(StdOut, IDS_ASSIGN_SYSTEM_VOLUME);
return EXIT_SUCCESS;
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
+1
View File
@@ -32,6 +32,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nDer angegebene Buchstabe wurde diesem Laufwerk bereits zugewiesen.\n"
IDS_ASSIGN_INVALID_LETTER "\nDer angegebene Laufwerksbuchstabe ist kein gültiger Volumebuchstabe.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nEs ist kein freier Laufwerksbuchstabe vorhanden, der diesem Volume zugewiesen werden kann.\nGeben Sie einen Laufwerksbuchstaben frei, und wiederholen Sie den Vorgang.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDer Laufwerkbuchstabe einens System-, Start- oder Auslagerungsvolumes kann nicht neu zugeordnet werden.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -32,6 +32,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -39,6 +39,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -32,6 +32,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -34,6 +34,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -40,6 +40,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -34,6 +34,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -36,6 +36,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -42,6 +42,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -41,6 +41,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+1
View File
@@ -41,6 +41,7 @@ BEGIN
IDS_ASSIGN_ALREADY_ASSIGNED "\nThe specified letter has already been assigned to this drive.\n"
IDS_ASSIGN_INVALID_LETTER "\nThe letter you specified is not a valid volume letter.\n"
IDS_ASSIGN_NO_MORE_LETTER "\nThere are no free drive letters to assign to this volume.\nPlease free up a drive letter and try again.\n"
IDS_ASSIGN_SYSTEM_VOLUME "\nDiskPart cannot reassign the drive letter on a system, boot or pagefile volume.\n"
END
/* AUTOMOUNT command strings */
+6
View File
@@ -88,6 +88,12 @@ remove_main(
}
}
if (CurrentVolume->IsBoot || CurrentVolume->IsSystem)
{
ConResPuts(StdOut, IDS_ASSIGN_SYSTEM_VOLUME);
return EXIT_SUCCESS;
}
if (nExclusive > 1)
{
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
+1
View File
@@ -32,6 +32,7 @@
#define IDS_ASSIGN_ALREADY_ASSIGNED 1022
#define IDS_ASSIGN_INVALID_LETTER 1023
#define IDS_ASSIGN_NO_MORE_LETTER 1024
#define IDS_ASSIGN_SYSTEM_VOLUME 1025
#define IDS_CLEAN_FAIL 1030
#define IDS_CLEAN_SUCCESS 1031