Проверять маркеры NOT.DEL и подсвечивать текущий загрузчик

This commit is contained in:
Paravis committed 2026-11-14 18:22:07 +03:00
1 parent f8081df0a1
commit a6690504eb
4 files changed
+38 -2

No files matched your search

+5 -2
View File
@@ -24,14 +24,17 @@ build\Release\Change_BootLoader.exe
- Запускать с корня флешки Paravis, например `F:\Change_BootLoader.exe`.
- Диск определяется по пути к самой программе; проверяются
`\efi\Paravis\Boot\bootice.exe` и `\efi\Paravis\Boot\NOT.DEL`.
- Если этих файлов нет, показывается исходное сообщение об ошибке и выход.
`\efi\Paravis\Boot\bootice.exe`, `\efi\Paravis\Boot\NOT.DEL` и маркер
данных `ISO\Ventoy\NOT.DEL` на одном из разделов.
- Если маркеров нет, показывается сообщение об ошибке и выход.
- Семь кнопок выполняют те же операции, что и AutoIt-версия:
- Legacy BIOS: XorBoot, Bootmgr, Grub4Dos, Grub2
- UEFI: Bootmgr, Grub2, Xorboot
- После успешной смены записывает `\efi\Paravis\Boot\bootstate.txt`
(`legacy=`, `uefi=`). Этот же файл читает Android-приложение, чтобы
подсветить установленный загрузчик.
- При запуске читает `bootstate.txt` и подсвечивает текущий Legacy- и
UEFI-загрузчик тем же стилем, что и Android-приложение.
- Bootice, xcopy и скрипт создания MBR для GRUB2 вызываются так же, как в
AutoIt-версии. Скрипт:
`\efi\Paravis\Boot\grub2\bios\make-paravis-mbr.ps1`.
+3
View File
@@ -30,6 +30,8 @@ public:
bool busy = false;
bool modal = false;
int activeButton = -1;
int currentLegacy = -1;
int currentUefi = -1;
bool minDown = false;
bool closeDown = false;
@@ -47,6 +49,7 @@ public:
};
bool Init(HWND window);
void LoadBootState();
void CreateFonts();
void DestroyFonts();
void Paint(HDC dc);
+14
View File
@@ -62,6 +62,13 @@ static void WriteBootState(const std::wstring& bootDir, int legacy, int uefi)
}
void App::LoadBootState()
{
std::wstring path = boot + L"\\bootstate.txt";
currentLegacy = ReadStateValue(path, "legacy");
currentUefi = ReadStateValue(path, "uefi");
DebugLog(L"bootstate loaded: legacy=%d uefi=%d", currentLegacy, currentUefi);
}
void App::ShowMessage(const std::wstring& text, UINT flags)
{
bool previous = modal;
@@ -141,6 +148,7 @@ void App::LegacyXor()
RunWait(bootice + L" /DEVICE=" + disk +
L" /pbr /restore /file=" + boot + L"\\xor\\xpbr.bin /keep_bpb /quiet");
WriteBootState(boot, 0, -1);
currentLegacy = 0;
Done(L"XorBoot");
}
@@ -152,6 +160,7 @@ void App::LegacyMgr()
RunWait(bootice + L" /DEVICE=" + disk + L" /mbr /install /type=nt60 /quiet");
RunWait(bootice + L" /DEVICE=" + disk + L" /pbr /install /type=bootmgr /quiet");
WriteBootState(boot, 1, -1);
currentLegacy = 1;
Done(L"Bootmgr");
}
@@ -163,6 +172,7 @@ void App::LegacyG4d()
RunWait(bootice + L" /DEVICE=" + disk + L" /mbr /install /type=GRUB4DOS /quiet");
RunWait(bootice + L" /DEVICE=" + disk + L" /pbr /install /type=GRUB4DOS /quiet");
WriteBootState(boot, 2, -1);
currentLegacy = 2;
Done(L"Grub4Dos");
}
@@ -231,6 +241,7 @@ void App::LegacyGrub2()
}
WriteBootState(boot, 3, -1);
currentLegacy = 3;
Done(L"Grub2 (Legacy)");
}
@@ -242,6 +253,7 @@ void App::UefiMgr()
CopyFileOverwrite(boot + L"\\mgr\\UEFI\\bootia32.efi",
disk + L"\\efi\\boot\\bootia32.efi");
WriteBootState(boot, -1, 0);
currentUefi = 0;
Done(L"UEFI Bootmgr");
}
@@ -257,6 +269,7 @@ void App::UefiGrub2()
CopyFileOverwrite(boot + L"\\loaders\\grub2\\mmx64.efi",
disk + L"\\efi\\boot\\mmx64.efi");
WriteBootState(boot, -1, 1);
currentUefi = 1;
Done(L"UEFI GRUB2");
}
@@ -268,6 +281,7 @@ void App::UefiXor()
CopyFileOverwrite(boot + L"\\xor\\UEFI\\bootia32.efi",
disk + L"\\efi\\boot\\bootia32.efi");
WriteBootState(boot, -1, 2);
currentUefi = 2;
Done(L"UEFI Xorboot");
}
+16
View File
@@ -79,6 +79,16 @@ void DrawTextRect(HDC dc, const std::wstring& text, HFONT font,
SelectObject(dc, oldFont);
}
std::wstring FindDataMarker()
{
for (wchar_t letter = L'C'; letter <= L'Z'; ++letter) {
std::wstring path = std::wstring(1, letter) + L":\\ISO\\Ventoy\\NOT.DEL";
if (FileExists(path)) {
return path;
}
}
return L"";
}
HitResult HitTest(POINT point)
{
auto inside = [&point](int x, int y, int w, int h) {
@@ -194,6 +204,7 @@ bool App::Init(HWND window)
SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icon));
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));
}
LoadBootState();
return true;
}
@@ -265,6 +276,11 @@ void App::Paint(HDC dc)
background = ColorFromHex(CLR_BUSY_BG);
border = ColorFromHex(CLR_BUSY_BORDER);
text = ColorFromHex(CLR_BUSY_TEXT);
} else if ((i < 4 && i == currentLegacy) ||
(i >= 4 && i - 4 == currentUefi)) {
background = ColorFromHex(CLR_ACTIVE_BG);
border = ColorFromHex(CLR_ACTIVE_BORDER);
text = ColorFromHex(CLR_ACTIVE_TEXT);
}
FillRectColor(memory, x - 1, y - 1, bw + 2, bh + 2, border);