Skip to content

Commit a40bd10

Browse files
committed
[DISKPART] Prevent deletion of boot and system partitions
1 parent fad471e commit a40bd10

15 files changed

Lines changed: 99 additions & 4 deletions

File tree

base/system/diskpart/delete.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ DeletePartition(
324324
}
325325
}
326326

327+
if (CurrentPartition->IsBoot || CurrentPartition->IsSystem)
328+
{
329+
ConResPuts(StdOut, IDS_DELETE_PARTITION_SYSTEM);
330+
return EXIT_SUCCESS;
331+
}
332+
327333
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
328334
{
329335
DeleteMbrPartition(bOverride);

base/system/diskpart/diskpart.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ typedef enum _FORMATSTATE
109109
typedef enum _VOLUME_TYPE
110110
{
111111
VOLUME_TYPE_CDROM,
112-
// VOLUME_TYPE_DVD,
113112
VOLUME_TYPE_PARTITION,
114113
VOLUME_TYPE_REMOVABLE,
115114
VOLUME_TYPE_UNKNOWN
@@ -167,6 +166,10 @@ typedef struct _PARTENTRY
167166
BOOLEAN NeedsCheck;
168167

169168
struct _FILE_SYSTEM_ITEM *FileSystem;
169+
170+
BOOL IsSystem;
171+
BOOL IsBoot;
172+
170173
} PARTENTRY, *PPARTENTRY;
171174

172175

base/system/diskpart/lang/de-DE.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ END
6969
STRINGTABLE
7070
BEGIN
7171
IDS_DELETE_PARTITION_FAIL "\nDie gewählte Partition konnte nicht gelöscht werden.\nVergewissern Sie sich, dass die Partition wirklich gelöscht werden kann.\n"
72-
IDS_DELETE_PARTITION_SUCCESS "\nDer gewählte Partition wurde erfolgreich gelöscht.\n"
72+
IDS_DELETE_PARTITION_SUCCESS "\nDie gewählte Partition wurde erfolgreich gelöscht.\n"
73+
IDS_DELETE_PARTITION_SYSTEM "\nDie gewählte Partition ist möglicherweise für den Betrieb des Computers erforderlich und kann nicht gelöscht werden.\n"
7374
END
7475

7576
/* Disk Information Labels */

base/system/diskpart/lang/en-US.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ STRINGTABLE
7070
BEGIN
7171
IDS_DELETE_PARTITION_FAIL "\nDiskPart failed to delete the selected partition.\nPlease make sure the selected partition is valid to delete.\n"
7272
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart successfully deleted the selected partition.\n"
73+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
7374
END
7475

7576
/* Disk Information Labels */

base/system/diskpart/lang/it-IT.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ STRINGTABLE
7777
BEGIN
7878
IDS_DELETE_PARTITION_FAIL "\nDiskPart ha fallito ad eliminare la partizione selezionata.\nAssicurarsi che la partizione selezionata sia valida.\n"
7979
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart ha eliminato con successo la partizione selezionata.\n"
80+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
8081
END
8182

8283
/* Disk Information Labels */

base/system/diskpart/lang/pl-PL.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ STRINGTABLE
7070
BEGIN
7171
IDS_DELETE_PARTITION_FAIL "\nDiskPart nie może usunąć wybranej partycji.\nUpewnij się, że wybrana partycja nadaje się do usunięcia.\n"
7272
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart pomyślnie usunął wybraną partycję.\n"
73+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
7374
END
7475

7576
/* Disk Information Labels */

base/system/diskpart/lang/pt-PT.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ STRINGTABLE
7272
BEGIN
7373
IDS_DELETE_PARTITION_FAIL "\nDiskPart failed to delete the selected partition.\nPlease make sure the selected partition is valid to delete.\n"
7474
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart successfully deleted the selected partition.\n"
75+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
7576
END
7677

7778
/* Disk Information Labels */

base/system/diskpart/lang/ro-RO.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ STRINGTABLE
7878
BEGIN
7979
IDS_DELETE_PARTITION_FAIL "\nDiskPart nu a reușit să șteargă partiția selectată.\nAsigurați-vă că partiția selectată este validă pentru ștergere.\n"
8080
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart a șters cu succes partiția selectată.\n"
81+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
8182
END
8283

8384
/* Disk Information Labels */

base/system/diskpart/lang/ru-RU.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ STRINGTABLE
7272
BEGIN
7373
IDS_DELETE_PARTITION_FAIL "\nDiskPart failed to delete the selected partition.\nPlease make sure the selected partition is valid to delete.\n"
7474
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart successfully deleted the selected partition.\n"
75+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
7576
END
7677

7778
/* Disk Information Labels */

base/system/diskpart/lang/sq-AL.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ STRINGTABLE
7474
BEGIN
7575
IDS_DELETE_PARTITION_FAIL "\nDiskPart failed to delete the selected partition.\nPlease make sure the selected partition is valid to delete.\n"
7676
IDS_DELETE_PARTITION_SUCCESS "\nDiskPart successfully deleted the selected partition.\n"
77+
IDS_DELETE_PARTITION_SYSTEM "\nThe selected partition may be neccessary to the operation of your computer, and may not be deleted.\n"
7778
END
7879

7980
/* Disk Information Labels */

0 commit comments

Comments
 (0)