Писать полный 18-секторный MBR GRUB4DOS с MBR-helper

This commit is contained in:
Paravis committed 2026-11-14 19:40:20 +03:00
1 parent 1945686542
commit 8725f867ca
3 files changed
+28 -12

No files matched your search

Binary file not shown.
@@ -1130,14 +1130,9 @@ public class MainActivity extends Activity {
okMbr = sameSector(image, read10(connection, in, out, 0, 1));
break;
}
case MGR:
case G4D: {
String mbrAsset = type == LegacyType.MGR
? "legacy/nt60-mbr.bin" : "legacy/g4d-mbr.bin";
String pbrAsset = type == LegacyType.MGR
? "legacy/bootmgr-pbr.bin" : "legacy/g4d-pbr.bin";
byte[] code = readAsset(mbrAsset);
byte[] pbrCode = readAsset(pbrAsset);
case MGR: {
byte[] code = readAsset("legacy/nt60-mbr.bin");
byte[] pbrCode = readAsset("legacy/bootmgr-pbr.bin");
if (code == null || code.length < 440 || pbrCode == null) {
return "Не найдены встроенные MBR/PBR";
}
@@ -1149,6 +1144,24 @@ public class MainActivity extends Activity {
okMbr = sameSector(image, read10(connection, in, out, 0, 1));
break;
}
case G4D: {
byte[] code = readAsset("legacy/g4d-mbr.bin");
byte[] pbrCode = readAsset("legacy/g4d-pbr.bin");
if (code == null || code.length < 18 * 512 || pbrCode == null) {
return "Не найдены встроенные MBR/PBR GRUB4DOS";
}
byte[] image = java.util.Arrays.copyOf(code, 18 * 512);
System.arraycopy(code, 0, image, 0, 440);
System.arraycopy(mbr, 440, image, 440, 72);
System.arraycopy(mbr, 0, image, 512, 512);
if (!write10(connection, in, out, 0, image)) {
return "Ошибка записи MBR GRUB4DOS\nБэкап: " + backupPath;
}
okPbr = writePbr(connection, in, out, partStart, pbrCode);
byte[] check = read10(connection, in, out, 0, 18);
okMbr = check != null && regionEquals(image, check, image.length);
break;
}
default:
return "Неизвестный загрузчик";
}