Skip to content

Commit b05a983

Browse files
committed
[DISKPART] The active and inactive commands do not work on GPT disks
1 parent dd74eaf commit b05a983

File tree

14 files changed

+64
-27
lines changed

14 files changed

+64
-27
lines changed

base/system/diskpart/active.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,30 @@ active_main(
3333
return TRUE;
3434
}
3535

36-
if (CurrentPartition->BootIndicator)
36+
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
3737
{
38-
ConResPuts(StdOut, IDS_ACTIVE_ALREADY);
39-
return TRUE;
40-
}
41-
42-
CurrentPartition->BootIndicator = TRUE;
43-
CurrentDisk->Dirty = TRUE;
44-
UpdateDiskLayout(CurrentDisk);
45-
Status = WritePartitions(CurrentDisk);
46-
if (NT_SUCCESS(Status))
47-
{
48-
ConResPuts(StdOut, IDS_ACTIVE_SUCCESS);
38+
if (CurrentPartition->BootIndicator)
39+
{
40+
ConResPuts(StdOut, IDS_ACTIVE_ALREADY);
41+
return TRUE;
42+
}
43+
44+
CurrentPartition->BootIndicator = TRUE;
45+
CurrentDisk->Dirty = TRUE;
46+
UpdateDiskLayout(CurrentDisk);
47+
Status = WritePartitions(CurrentDisk);
48+
if (NT_SUCCESS(Status))
49+
{
50+
ConResPuts(StdOut, IDS_ACTIVE_SUCCESS);
51+
}
52+
else
53+
{
54+
ConResPuts(StdOut, IDS_ACTIVE_FAIL);
55+
}
4956
}
5057
else
5158
{
52-
ConResPuts(StdOut, IDS_ACTIVE_FAIL);
59+
ConResPuts(StdOut, IDS_ACTIVE_NO_MBR);
5360
}
5461

5562
return TRUE;

base/system/diskpart/inactive.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,30 @@ inactive_main(
3333
return TRUE;
3434
}
3535

36-
if (!CurrentPartition->BootIndicator)
36+
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
3737
{
38-
ConResPuts(StdOut, IDS_INACTIVE_ALREADY);
39-
return TRUE;
40-
}
41-
42-
CurrentPartition->BootIndicator = FALSE;
43-
CurrentDisk->Dirty = TRUE;
44-
UpdateDiskLayout(CurrentDisk);
45-
Status = WritePartitions(CurrentDisk);
46-
if (NT_SUCCESS(Status))
47-
{
48-
ConResPuts(StdOut, IDS_INACTIVE_SUCCESS);
38+
if (!CurrentPartition->BootIndicator)
39+
{
40+
ConResPuts(StdOut, IDS_INACTIVE_ALREADY);
41+
return TRUE;
42+
}
43+
44+
CurrentPartition->BootIndicator = FALSE;
45+
CurrentDisk->Dirty = TRUE;
46+
UpdateDiskLayout(CurrentDisk);
47+
Status = WritePartitions(CurrentDisk);
48+
if (NT_SUCCESS(Status))
49+
{
50+
ConResPuts(StdOut, IDS_INACTIVE_SUCCESS);
51+
}
52+
else
53+
{
54+
ConResPuts(StdOut, IDS_INACTIVE_FAIL);
55+
}
4956
}
5057
else
5158
{
52-
ConResPuts(StdOut, IDS_INACTIVE_FAIL);
59+
ConResPuts(StdOut, IDS_INACTIVE_NO_MBR);
5360
}
5461

5562
return TRUE;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BEGIN
2020
IDS_ACTIVE_FAIL "\nDie Partition konnte nicht als aktiv markiert werden.\nVergewissern Sie sich, dass diese Partition gültig ist.\n"
2121
IDS_ACTIVE_SUCCESS "\nDie aktuelle Partition wurde als aktiv markiert.\n"
2222
IDS_ACTIVE_ALREADY "\nDie aktuelle Partition wurde bereits als aktiv markiert.\n"
23+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2324
END
2425

2526
STRINGTABLE
@@ -96,6 +97,7 @@ BEGIN
9697
IDS_INACTIVE_FAIL "\nDie Partition konnte nicht als inaktiv markiert werden.\nVergewissern Sie sich, dass diese Partition gültig ist.\n"
9798
IDS_INACTIVE_SUCCESS "\nDie aktuelle Partition wurde als inaktiv markiert.\n"
9899
IDS_INACTIVE_ALREADY "\nDie aktuelle Partition wurde bereits als inaktiv markiert.\n"
100+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
99101
END
100102

101103
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BEGIN
2020
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
2121
IDS_ACTIVE_SUCCESS "\nDiskPart marked the current partition as active.\n"
2222
IDS_ACTIVE_ALREADY "\nThe current partition is already marked as active.\n"
23+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2324
END
2425

2526
STRINGTABLE
@@ -96,6 +97,7 @@ BEGIN
9697
IDS_INACTIVE_FAIL "\nDiskPart was unable to mark the partition inactive.\nMake sure the partition is valid.\n"
9798
IDS_INACTIVE_SUCCESS "\nDiskPart marked the current partition as inactive.\n"
9899
IDS_INACTIVE_ALREADY "\nThe current partition is already marked as inactive.\n"
100+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
99101
END
100102

101103
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ BEGIN
2727
IDS_ACTIVE_FAIL "\nDiskPart non ha potuto segnare la partizione come attiva.\nAssicurarsi che la partizione sia valida.\n"
2828
IDS_ACTIVE_SUCCESS "\nDiskPart ha segnato la partizione corrente come attiva.\n"
2929
IDS_ACTIVE_ALREADY "\nLa partizione corrente è già segnata come attiva.\n"
30+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
3031
END
3132

3233
STRINGTABLE
@@ -103,6 +104,7 @@ BEGIN
103104
IDS_INACTIVE_FAIL "\nDiskPart non è stato in grado di segnare la partizione inattiva.\nAssicurarsi che la partizione sia valida.\n"
104105
IDS_INACTIVE_SUCCESS "\nDiskPart ha segnato la partizione corrente come inattiva.\n"
105106
IDS_INACTIVE_ALREADY "\nLa partizione corrente è già segnata come attiva.\n"
107+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
106108
END
107109

108110
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ BEGIN
2020
IDS_ACTIVE_FAIL "\nDiskPart nie mógł oznaczyć partycji jako aktywnej.\nUpewnij się, że partycja jest prawidłowa.\n"
2121
IDS_ACTIVE_SUCCESS "\nDiskPart oznaczył bieżącą partycję jako aktywną.\n"
2222
IDS_ACTIVE_ALREADY "\nBieżąca partycja jest już oznaczona jako aktywna.\n"
23+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2324
END
2425

2526
STRINGTABLE
@@ -96,6 +97,7 @@ BEGIN
9697
IDS_INACTIVE_FAIL "\nDiskPart nie może oznaczyć partycji jako nieaktywnej.\nUpewnij się, że partycja jest prawidłowa.\n"
9798
IDS_INACTIVE_SUCCESS "\nDiskPart oznaczył bieżącą partycję jako nieaktywną.\n"
9899
IDS_INACTIVE_ALREADY "\nBieżąca partycja jest już oznaczona jako nieaktywna.\n"
100+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
99101
END
100102

101103
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ BEGIN
2222
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
2323
IDS_ACTIVE_SUCCESS "\nDiskPart marked the current partition as active.\n"
2424
IDS_ACTIVE_ALREADY "\nThe current partition is already marked as active.\n"
25+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2526
END
2627

2728
STRINGTABLE
@@ -98,6 +99,7 @@ BEGIN
9899
IDS_INACTIVE_FAIL "\nDiskPart was unable to mark the partition inactive.\nMake sure the partition is valid.\n"
99100
IDS_INACTIVE_SUCCESS "\nDiskPart marked the current partition as inactive.\n"
100101
IDS_INACTIVE_ALREADY "\nThe current partition is already marked as inactive.\n"
102+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
101103
END
102104

103105
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ BEGIN
2828
IDS_ACTIVE_FAIL "\nDiskpart nu a reușit să marcheze partiția activă.\nAsigurați-vă că partiția este validă.\n"
2929
IDS_ACTIVE_SUCCESS "\nDiskPart a marcat partiția curentă ca activă.\n"
3030
IDS_ACTIVE_ALREADY "\nPartiția curentă este deja marcată ca activă.\n"
31+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
3132
END
3233

3334
STRINGTABLE
@@ -104,6 +105,7 @@ BEGIN
104105
IDS_INACTIVE_FAIL "\nDiskpart nu a reușit să marcheze partiția inactivă.\nAsigurați-vă că partiția este validă.\n"
105106
IDS_INACTIVE_SUCCESS "\nDiskPart a marcat partiția curentă ca inactivă.\n"
106107
IDS_INACTIVE_ALREADY "\nPartiția curentă este deja marcată ca inactivă.\n"
108+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
107109
END
108110

109111
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ BEGIN
2222
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
2323
IDS_ACTIVE_SUCCESS "\nDiskPart marked the current partition as active.\n"
2424
IDS_ACTIVE_ALREADY "\nThe current partition is already marked as active.\n"
25+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2526
END
2627

2728
STRINGTABLE
@@ -98,6 +99,7 @@ BEGIN
9899
IDS_INACTIVE_FAIL "\nDiskPart was unable to mark the partition inactive.\nMake sure the partition is valid.\n"
99100
IDS_INACTIVE_SUCCESS "\nDiskPart marked the current partition as inactive.\n"
100101
IDS_INACTIVE_ALREADY "\nThe current partition is already marked as inactive.\n"
102+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
101103
END
102104

103105
/* Detail header titles */

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ BEGIN
2424
IDS_ACTIVE_FAIL "\nDiskPart was unable to mark the partition active.\nMake sure the partition is valid.\n"
2525
IDS_ACTIVE_SUCCESS "\nDiskPart marked the current partition as active.\n"
2626
IDS_ACTIVE_ALREADY "\nThe current partition is already marked as active.\n"
27+
IDS_ACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe ACTIVE command can only be used on an MBR disk.\n"
2728
END
2829

2930
STRINGTABLE
@@ -100,6 +101,7 @@ BEGIN
100101
IDS_INACTIVE_FAIL "\nDiskPart was unable to mark the partition inactive.\nMake sure the partition is valid.\n"
101102
IDS_INACTIVE_SUCCESS "\nDiskPart marked the current partition as inactive.\n"
102103
IDS_INACTIVE_ALREADY "\nThe current partition is already marked as inactive.\n"
104+
IDS_INACTIVE_NO_MBR "\nThe selected disk is not an MBR disk.\nThe INACTIVE command can only be used on an MBR disk.\n"
103105
END
104106

105107
/* Detail header titles */

0 commit comments

Comments
 (0)