10 Commits
17 changed files with 849 additions and 1628 deletions

No files matched your search

-33
View File
@@ -1,33 +0,0 @@
# Build output
build/
build_x64/
build_x86/
out/
bin/
obj/
*.exe
*.dll
*.lib
*.exp
*.obj
*.pdb
*.ilk
*.res
*.tlog
*.idb
# CMake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
# Visual Studio
.vs/
*.vcxproj*
*.sln
*.user
*.suo
# Logs, temporary and debug files
*.log
*.tmp
-44
View File
@@ -1,44 +0,0 @@
cmake_minimum_required(VERSION 3.20)
project(ChangeBootloaderCpp LANGUAGES CXX)
enable_language(RC)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_executable(ChangeBootLoader WIN32
src/main.cpp
src/boot.cpp
src/util.cpp
src/app.rc
)
set_property(TARGET ChangeBootLoader PROPERTY MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(ChangeBootLoader PRIVATE
UNICODE
_UNICODE
WIN32_LEAN_AND_MEAN
NOMINMAX
)
target_compile_options(ChangeBootLoader PRIVATE
/utf-8
/W4
/permissive-
)
target_link_libraries(ChangeBootLoader PRIVATE
user32
gdi32
)
# The manifest is embedded through app.rc; do not let the linker add a second one.
target_link_options(ChangeBootLoader PRIVATE /MANIFEST:NO)
set_target_properties(ChangeBootLoader PROPERTIES
OUTPUT_NAME "Change_BootLoader"
)
+308
View File
@@ -0,0 +1,308 @@
#include <GUIConstantsEx.au3>
#include <GuiConstants.au3>
#include <file.au3>
#include ".\Include\GUICtrlOnHover.au3"
#NoTrayIcon
#RequireAdmin
#pragma compile(Stripper, True)
#pragma compile(ProductVersion, 2.0.0)
#pragma compile(ProductName, "Change bootLoader")
#pragma compile(FileDescription, CBL)
#pragma compile(LegalCopyright, paravis.ru@2022)
#pragma compile(CompanyName, paravis.ru@2022)
Opt("TrayIconHide", 1)
Opt("ExpandEnvStrings", 1)
Global $szdrive, $szdir, $szfname, $szext, $img
$testpath = _pathsplit(@ScriptFullPath, $szdrive, $szdir, $szfname, $szext)
$namedisk = ($testpath[1] & "\")
$kitchen = ($namedisk & "efi\Paravis\Boot\kitchen")
$bootice = ($namedisk & "efi\Paravis\Boot\kitchen\bootice.exe")
$main = GUICreate("Change BootLoader", 390, 184, 318, 213)
GUICtrlCreateGroup("Legacy BIOS", 3, 3, 384, 61)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$xor = GUICtrlCreateButton("Install XorBoot", 8, 20, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$bmgr = GUICtrlCreateButton("Install Bootmgr", 134, 20, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$g4d = GUICtrlCreateButton("Install Grub4Dos", 261, 20, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("UEFI", 3, 62, 384, 61)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$bmgru = GUICtrlCreateButton("Install Bootmgr (SecureBoot ON)", 8, 80, 180, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$xoru = GUICtrlCreateButton("Install Xorboot (SecureBoot OFF)", 200, 80, 180, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
GUICtrlCreateGroup("Xorboot / Grub4dos Theme", 3, 121, 384, 61)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$theme1 = GUICtrlCreateButton("Light Blue Theme", 8, 137, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$theme2 = GUICtrlCreateButton("Dark Violet Theme", 134, 137, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$theme3 = GUICtrlCreateButton("Colorful Theme", 261, 137, 121, 33)
GUICtrlSetFont(-1, 8, 800, 0, "Tahoma")
$img1 = GUICreate("", 400, 300, -1, -1, $ws_popup, $ws_ex_composited, $main)
$pic1 = GUICtrlCreatePic($kitchen & "\Legacy\L", 0, 0, 400, 300)
$img2 = GUICreate("", 400, 300, -1, -1, $ws_popup, $ws_ex_composited, $main)
$pic2 = GUICtrlCreatePic($kitchen & "\Legacy\V", 0, 0, 400, 300)
$img3 = GUICreate("", 400, 300, -1, -1, $ws_popup, $ws_ex_composited, $main)
$pic3 = GUICtrlCreatePic($kitchen & "\Legacy\C", 0, 0, 400, 300)
GUISetState(@SW_HIDE, $img1)
GUISetState(@SW_HIDE, $img2)
GUISetState(@SW_HIDE, $img3)
GUISetState(@SW_SHOW, $main)
Func _hide()
GUICtrlSetState($xor, $gui_disable)
GUICtrlSetState($bmgr, $gui_disable)
GUICtrlSetState($g4d, $gui_disable)
GUICtrlSetState($bmgru, $gui_disable)
GUICtrlSetState($xoru, $gui_disable)
GUICtrlSetState($theme1, $gui_disable)
GUICtrlSetState($theme2, $gui_disable)
GUICtrlSetState($theme3, $gui_disable)
EndFunc
Func _show()
GUICtrlSetState($xor, $gui_enable)
GUICtrlSetState($bmgr, $gui_enable)
GUICtrlSetState($g4d, $gui_enable)
GUICtrlSetState($bmgru, $gui_enable)
GUICtrlSetState($xoru, $gui_enable)
GUICtrlSetState($theme1, $gui_enable)
GUICtrlSetState($theme2, $gui_enable)
GUICtrlSetState($theme3, $gui_enable)
EndFunc
Func _onhover1()
GUISetState(@SW_SHOWNOACTIVATE, $img1)
EndFunc
Func _onleave1()
GUISetState(@SW_HIDE, $img1)
EndFunc
Func _onhover2()
GUISetState(@SW_SHOWNOACTIVATE, $img2)
EndFunc
Func _onleave2()
GUISetState(@SW_HIDE, $img2)
EndFunc
Func _onhover3()
GUISetState(@SW_SHOWNOACTIVATE, $img3)
EndFunc
Func _onleave3()
GUISetState(@SW_HIDE, $img3)
EndFunc
While 1
$mp = MouseGetPos()
WinMove($img1, "", $mp[0] + 30, $mp[1] + 30)
$mp = MouseGetPos()
WinMove($img2, "", $mp[0] + 30, $mp[1] + 30)
$mp = MouseGetPos()
WinMove($img3, "", $mp[0] + 30, $mp[1] + 30)
Switch GUIGetMsg()
Case $gui_event_close
ExitLoop
Case $xor
_hide()
FileDelete($namedisk & "\bootmgr")
FileDelete($namedisk & "\grldr")
FileCopy($kitchen & "\13", $namedisk & "efi\Paravis\boot\13", 1)
FileCopy($kitchen & "\1313", $namedisk & "efi\Paravis\boot\1313", 1)
FileCopy($kitchen & "\xbt.bin", $namedisk & "efi\Paravis\boot\Paravis", 1)
RunWait($bootice & " /DEVICE=" & $namedisk & " /mbr /restore /file=xbt.bin /keep_dpt /quiet")
RunWait($bootice & " /DEVICE=" & $namedisk & " /pbr /restore /file=xbt_p.bin /keep_bpb /quiet")
MsgBox(0 + 64 + 262144, "Xorboot", "bootloader successfully changed!")
_show()
Case $bmgr
_hide()
FileDelete(@ScriptDir & "Paravis")
FileDelete($namedisk & "bootmgr")
FileDelete($namedisk & "grldr")
FileCopy($kitchen & "\bootmgr", $namedisk & "bootmgr")
FileCopy($kitchen & "\bootmgr", $namedisk & "efi\Paravis\boot\Paravis", 1)
RunWait($bootice & " /DEVICE=" & $namedisk & " /mbr /install /type=nt60 /quiet")
RunWait($bootice & " /DEVICE=" & $namedisk & " /pbr /install /type=bootmgr /quiet")
MsgBox(0 + 64 + 262144, "Bootmgr", "bootloader successfully changed!")
_show()
Case $g4d
_hide()
FileDelete($namedisk & "bootmgr")
FileDelete($namedisk & "grldr")
FileCopy($kitchen & "\grldr", $namedisk & "grldr")
FileCopy($kitchen & "\grldr", $namedisk & "efi\Paravis\boot\Paravis", 1)
RunWait($bootice & " /DEVICE=" & $namedisk & " /mbr /install /type=GRUB4DOS /quiet")
RunWait($bootice & " /DEVICE=" & $namedisk & " /pbr /install /type=GRUB4DOS /quiet")
MsgBox(0 + 64 + 262144, "Grub4Dos", "Bootloader successfully changed!")
_show()
Case $bmgru
_hide()
FileDelete($namedisk & "efi\boot\bootx64.efi")
FileDelete($namedisk & "efi\boot\bootia32.efi")
FileDelete($namedisk & "efi\boot\bx86.pf")
FileDelete($namedisk & "efi\boot\hx86.pf")
FileDelete($namedisk & "efi\boot\x86.pf")
FileDelete($namedisk & "efi\boot\bx64.pf")
FileDelete($namedisk & "efi\boot\hx64.pf")
FileDelete($namedisk & "efi\boot\x64.pf")
FileCopy($kitchen & "\UEFIx64\mgrx64.efi", $namedisk & "efi\boot\bootx64.efi")
FileCopy($kitchen & "\UEFIx86\mgrx86.efi", $namedisk & "efi\boot\bootia32.efi")
MsgBox(0 + 64 + 262144, "UEFI Bootmgr", "Bootloader successfully changed!")
_show()
Case $xoru
_hide()
FileDelete($namedisk & "efi\boot\bootx64.efi")
FileDelete($namedisk & "efi\boot\bootia32.efi")
FileDelete($namedisk & "efi\boot\bx86.pf")
FileDelete($namedisk & "efi\boot\hx86.pf")
FileDelete($namedisk & "efi\boot\x86.pf")
FileDelete($namedisk & "efi\boot\bx64.pf")
FileDelete($namedisk & "efi\boot\hx64.pf")
FileDelete($namedisk & "efi\boot\x64.pf")
FileCopy($kitchen & "\UEFIx64\bootx64.efi", $namedisk & "efi\boot\bootx64.efi")
FileCopy($kitchen & "\UEFIx86\bootia32.efi", $namedisk & "efi\boot\bootia32.efi")
FileCopy($kitchen & "\UEFIx86\bx86.pf", $namedisk & "efi\boot\bx86.pf")
FileCopy($kitchen & "\UEFIx86\hx86.pf", $namedisk & "efi\boot\hx86.pf")
FileCopy($kitchen & "\UEFIx86\x86.pf", $namedisk & "efi\boot\x86.pf")
FileCopy($kitchen & "\UEFIx64\bx64.pf", $namedisk & "efi\boot\bx64.pf")
FileCopy($kitchen & "\UEFIx64\hx64.pf", $namedisk & "efi\boot\hx64.pf")
FileCopy($kitchen & "\UEFIx64\x64.pf", $namedisk & "efi\boot\x64.pf")
MsgBox(0 + 64 + 262144, "UEFI Xorboot", "Bootloader successfully changed!")
_show()
Case $theme1
_hide()
If NOT FileExists($namedisk & "bootmgr") Then
FileCopy($kitchen & "\UEFIx64\Legacy_L\bx64.pf", $namedisk & "efi\boot\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\hx64.pf", $namedisk & "efi\boot\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\bx64.pf", $kitchen & "\UEFIx64\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\hx64.pf", $kitchen & "\UEFIx64\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\Linux\bx64.pf", $kitchen & "\UEFIx64\Linux\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\Linux\hx64.pf", $kitchen & "\UEFIx64\Linux\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\MSDaRT\bx64.pf", $kitchen & "\UEFIx64\MSDaRT\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\MSDaRT\hx64.pf", $kitchen & "\UEFIx64\MSDaRT\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\Utilits\bx64.pf", $kitchen & "\UEFIx64\Utilits\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_L\Utilits\hx64.pf", $kitchen & "\UEFIx64\Utilits\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\bx86.pf", $namedisk & "efi\boot\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\hx86.pf", $namedisk & "efi\boot\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\bx86.pf", $kitchen & "\UEFIx86\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\hx86.pf", $kitchen & "\UEFIx86\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\Linux\bx86.pf", $kitchen & "\UEFIx86\Linux\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\Linux\hx86.pf", $kitchen & "\UEFIx86\Linux\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\Utilits\bx86.pf", $kitchen & "\UEFIx86\Utilits\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_L\Utilits\hx86.pf", $kitchen & "\UEFIx86\Utilits\hx86.pf", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\UBCD", $namedisk & "efi\Paravis\UBCD\menus\UBCD", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\dartt", $kitchen & "\dartt", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\main", $kitchen & "\main", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\mintT", $kitchen & "\mintT", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\strT", $kitchen & "\strT", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\G4D\utilT", $kitchen & "\utilT", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\13", $namedisk & "efi\Paravis\Boot\13", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\1313", $namedisk & "efi\Paravis\Boot\1313", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\14", $namedisk & "efi\Paravis\Boot\14", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\1414", $namedisk & "efi\Paravis\Boot\1414", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\15", $namedisk & "efi\Paravis\Boot\15", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\1515", $namedisk & "efi\Paravis\Boot\1515", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\16", $namedisk & "efi\Paravis\Boot\16", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\1616", $namedisk & "efi\Paravis\Boot\1616", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\17", $namedisk & "efi\Paravis\Boot\17", 1)
FileCopy($kitchen & "\Legacy\Legacy_L\Xorboot\1717", $namedisk & "efi\Paravis\Boot\1717", 1)
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "Theme successfully changed!")
Else
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "First install the Xorboot or Grub4dos!")
EndIf
_show()
Case $theme2
_hide()
If NOT FileExists($namedisk & "bootmgr") Then
FileCopy($kitchen & "\UEFIx64\Legacy_V\bx64.pf", $namedisk & "efi\boot\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\hx64.pf", $namedisk & "efi\boot\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\bx64.pf", $kitchen & "\UEFIx64\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\hx64.pf", $kitchen & "\UEFIx64\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\Linux\bx64.pf", $kitchen & "\UEFIx64\Linux\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\Linux\hx64.pf", $kitchen & "\UEFIx64\Linux\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\MSDaRT\bx64.pf", $kitchen & "\UEFIx64\MSDaRT\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\MSDaRT\hx64.pf", $kitchen & "\UEFIx64\MSDaRT\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\Utilits\bx64.pf", $kitchen & "\UEFIx64\Utilits\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_V\Utilits\hx64.pf", $kitchen & "\UEFIx64\Utilits\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\bx86.pf", $namedisk & "efi\boot\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\hx86.pf", $namedisk & "efi\boot\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\bx86.pf", $kitchen & "\UEFIx86\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\hx86.pf", $kitchen & "\UEFIx86\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\Linux\bx86.pf", $kitchen & "\UEFIx86\Linux\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\Linux\hx86.pf", $kitchen & "\UEFIx86\Linux\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\Utilits\bx86.pf", $kitchen & "\UEFIx86\Utilits\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_V\Utilits\hx86.pf", $kitchen & "\UEFIx86\Utilits\hx86.pf", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\UBCD", $namedisk & "efi\Paravis\UBCD\menus\UBCD", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\dartt", $kitchen & "\dartt", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\main", $kitchen & "\main", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\mintT", $kitchen & "\mintT", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\strT", $kitchen & "\strT", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\G4D\utilT", $kitchen & "\utilT", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\13", $namedisk & "efi\Paravis\Boot\13", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\1313", $namedisk & "efi\Paravis\Boot\1313", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\14", $namedisk & "efi\Paravis\Boot\14", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\1414", $namedisk & "efi\Paravis\Boot\1414", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\15", $namedisk & "efi\Paravis\Boot\15", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\1515", $namedisk & "efi\Paravis\Boot\1515", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\16", $namedisk & "efi\Paravis\Boot\16", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\1616", $namedisk & "efi\Paravis\Boot\1616", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\17", $namedisk & "efi\Paravis\Boot\17", 1)
FileCopy($kitchen & "\Legacy\Legacy_V\Xorboot\1717", $namedisk & "efi\Paravis\Boot\1717", 1)
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "Theme successfully changed!")
Else
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "First install the Xorboot or Grub4dos!")
EndIf
_show()
Case $theme3
_hide()
If NOT FileExists($namedisk & "bootmgr") Then
FileCopy($kitchen & "\UEFIx64\Legacy_C\bx64.pf", $namedisk & "efi\boot\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\hx64.pf", $namedisk & "efi\boot\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\bx64.pf", $kitchen & "\UEFIx64\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\hx64.pf", $kitchen & "\UEFIx64\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\Linux\bx64.pf", $kitchen & "\UEFIx64\Linux\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\Linux\hx64.pf", $kitchen & "\UEFIx64\Linux\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\MSDaRT\bx64.pf", $kitchen & "\UEFIx64\MSDaRT\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\MSDaRT\hx64.pf", $kitchen & "\UEFIx64\MSDaRT\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\Utilits\bx64.pf", $kitchen & "\UEFIx64\Utilits\bx64.pf", 1)
FileCopy($kitchen & "\UEFIx64\Legacy_C\Utilits\hx64.pf", $kitchen & "\UEFIx64\Utilits\hx64.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\bx86.pf", $namedisk & "efi\boot\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\hx86.pf", $namedisk & "efi\boot\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\bx86.pf", $kitchen & "\UEFIx86\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\hx86.pf", $kitchen & "\UEFIx86\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\Linux\bx86.pf", $kitchen & "\UEFIx86\Linux\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\Linux\hx86.pf", $kitchen & "\UEFIx86\Linux\hx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\Utilits\bx86.pf", $kitchen & "\UEFIx86\Utilits\bx86.pf", 1)
FileCopy($kitchen & "\UEFIx86\Legacy_C\Utilits\hx86.pf", $kitchen & "\UEFIx86\Utilits\hx86.pf", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\UBCD", $namedisk & "efi\Paravis\UBCD\menus\UBCD", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\dartt", $kitchen & "\dartt", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\main", $kitchen & "\main", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\mintT", $kitchen & "\mintT", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\strT", $kitchen & "\strT", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\G4D\utilT", $kitchen & "\utilT", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\13", $namedisk & "efi\Paravis\Boot\13", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\1313", $namedisk & "efi\Paravis\Boot\1313", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\14", $namedisk & "efi\Paravis\Boot\14", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\1414", $namedisk & "efi\Paravis\Boot\1414", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\15", $namedisk & "efi\Paravis\Boot\15", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\1515", $namedisk & "efi\Paravis\Boot\1515", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\16", $namedisk & "efi\Paravis\Boot\16", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\1616", $namedisk & "efi\Paravis\Boot\1616", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\17", $namedisk & "efi\Paravis\Boot\17", 1)
FileCopy($kitchen & "\Legacy\Legacy_C\Xorboot\1717", $namedisk & "efi\Paravis\Boot\1717", 1)
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "Theme successfully changed!")
Else
MsgBox(0 + 64 + 262144, "Xorboot / Grub4dos Theme", "First install the Xorboot or Grub4dos!")
EndIf
_show()
EndSwitch
WEnd
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2026 Paravis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+4 -61
View File
@@ -1,64 +1,7 @@
# Установщик загрузчика PARAVIS # Change_bootloader
Нативная Win32-версия `Change_bootloader.au3` на C++. Окно, кнопки, действия и Исходник Change bootloader'а (программа установки сборки на флешку).
сообщения те же, что в AutoIt-версии.
## Сборка Все необходимые файлы для смены загрузчика, а так же превью тем, находятся уже на установленной флешке. Сама программа может лежать в любой папке на диске с установленной сборкой.
Требования: Visual Studio 2022 (Desktop C++) и CMake 3.20+. НЕ ЗАПУСКАЙТЕ ИСХОДНИК И СКОМПИЛИРОВАННЫЙ EXE НА ДИСКАХ ГДЕ НЕТ СБОРКИ. В лучшем случае получите кучу ошибок и не рабочие превью тем. В худшем, угробите загрузочную запись диска.
```bat
build.cmd
```
Результат:
```
build\Release\Change_BootLoader.exe
```
Программа 32-битная, использует статическую CRT (VC++ Redistributable не
нужен) и запрашивает права администратора через встроенный манифест.
## Как работает
- Запускать с корня флешки PARAVIS, например `F:\Change_BootLoader.exe`.
- Диск определяется по пути к самой программе; проверяются
`\efi\Paravis\Boot\bootice.exe` и `\efi\Paravis\Boot\NOT.DEL`.
- Если этих файлов нет, показывается исходное сообщение об ошибке и выход.
- Семь кнопок выполняют те же операции, что и AutoIt-версия:
- Legacy BIOS: XorBoot, Bootmgr, Grub4Dos, Grub2
- UEFI: Bootmgr, Grub2, Xorboot
- Bootice, xcopy и скрипт создания MBR для GRUB2 вызываются так же, как в
AutoIt-версии. Скрипт:
`\efi\Paravis\Boot\grub2\bios\make-paravis-mbr.ps1`.
## Примечания
- Интерфейс совпадает с AutoIt-версией (376×208, те же шрифты, позиции,
цвета наведения и нажатия).
- Диалоги — нативный `MessageBoxW` с теми же заголовками и текстами.
- Пока идёт установка загрузчика, все кнопки затенены; кнопка
устанавливаемого загрузчика остаётся чуть ярче.
- Повторный запуск запрещён: второй экземпляр активирует уже открытое окно
и сразу завершается.
- Все предупреждения — модальные: блокируют главное окно и показываются
поверх него.
- Отладочный лог по умолчанию выключен. `PARAVIS_DEBUG_LOG=1` включает
запись в `%TEMP%\cbl_cpp_debug.log`.
- Действие «GRUB2 Legacy» использует те же команды bootice `/sectors`, что и
AutoIt-версия. На виртуальных дисках bootice может показывать свои
диалоги подтверждения; на реальной флешке PARAVIS поведение совпадает с
оригиналом.
## Структура репозитория
```
src/ исходники и ресурсы C++
legacy-au3/ исходная версия на AutoIt
build.cmd сборка релиза
```
## Лицензия
MIT, см. [`LICENSE`](LICENSE).
-9
View File
@@ -1,9 +0,0 @@
@echo off
setlocal
cd /d "%~dp0"
cmake -S . -B build -G "Visual Studio 17 2022" -A Win32
if errorlevel 1 exit /b 1
cmake --build build --config Release
if errorlevel 1 exit /b 1
echo.
echo Built: %~dp0build\Release\Change_BootLoader.exe
+537
View File
@@ -0,0 +1,537 @@
#Region Header
#include-once
#CS UDF Info
Name.........: GUICtrlOnHover.au3
Forum link...: http://www.autoitscript.com/forum/index.php?s=&showtopic=55120
Author.......: G.Sandler a.k.a MrCreatoR (CreatoR's Lab, www.creator-lab.ucoz.ru, www.autoit-script.ru)
Remarks......:
1) TreeView/ListView Items can not be set :(.
2) When the window is not active, the hover/leave hover functions will still called, but not when the window is disabled.
3) The hover/leave hover functions will be called even if the script is paused by such functions as MsgBox().
4) The $sHover_Func/$sLeaveHover_Func functions should not introduce significant delays in the main script,
for example by calling functions like Sleep() or MsgBox().
5) IMPORTANT!
A) Do not call _GUICtrl_OnHoverRegister inside $sHover_Func/$sLeaveHover_Func functions, it's not a good idea.
B) This UDF registering WM_COMMAND and WM_LBUTTONDOWN window messages.
Please ensure that those messages are not used after including this library,
if they do, you will have to call __GUICtrl_SOH_WM_COMMAND and __GUICtrl_SOH_WM_LBUTTONDOWN inside those functions. Example:
Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
__GUICtrl_SOH_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
...
EndFunc
*** Version History ***
[v2.0] - [09.06.2010]
* Fixed potential issue with calling $sPrimaryDownFunc function (first call was performed only after recieving WM_COMMAND message, wich is the control event).
* Fixed an issue with blocking the OnHover function - the OnLeaveHover function was not called untill the OnHover function was blocked.
* Fixed(?) (again) issue when the UDF is not working under 64-bit OS.
* Optimized internal "__GUICtrl_SOH_Call" function to work faster when calling parameters functions.
[v1.9] - [21.05.2010]
* UDF library now compatible with AutoIt 3.3.6.1.
* UDF library renamed to GUICtrlOnHover.au3.
* Changed the main function name to _GUICtrl_OnHoverRegister, For backwards compatibility reasons, other (old) function names are still supported:
_GUICtrl_SetOnHover, GUICtrl_SetOnHover, GUICtrlSetOnHover, _GUICtrlSetOnHover
* Fixed(?) issue when the UDF is not working under 64-bit OS.
* Global variables and internal functions renaming (for "cosmetic" reasons only).
* UDF's code is more readable now.
[v1.8] - [28.09.2009]
* Few Global variables now have more unique name.
* Fixed an issue with false calling of function on PrimaryDown event.
I.e when the user clicks on other place (not on the hovered control) and drag the cursor to the control, the PrimaryDown function was called.
* Due to (and as a result of) previous issue, the UDF now registering WM_COMMAND and WM_LBUTTONDOWN messages at first UDF call.
[v1.7] - [07.07.2009]
+ Added _GUICtrl_SetHoverOnBackWindow...
Allows to set the hovering mode:
$iSetBackWin = 1 (default) hovering process will proceed even when GUI is not active (in background).
$iSetBackWin <> 1 hovering process will NOT proceed when GUI is not active.
[v1.6] - [12.06.2009]
* Now the UDF compatible with scripts (or other udfs) that uses OnAutoItExit function.
i.e: "OnAutoItExit" function that was *previously* set by user will be called as well.
+ Added new parameter $iKeepCall_Hover_Func. If this parameter = 1,
then the $sHover_Func function *Will* be called constantly untill the control is no longer been hovered
(default is 0, do not call the function constantly).
+ Added new arguments to calling function...
The OnPrimaryDown/Up function now can recieve one more argument:
$iClickMode - Defines the Click mode (1 - Pressed, 2 - Released)
* Changed return value - function will return 2 when $iCtrlID is redefined (ReSet, already exists in the controls list).
* Fixed incorrect documentation parts.
* Fixed "OnClick" handeling. When using multiple GUIs, the active gui was not recognized properly.
* Fixed(?) bug with "dimension range exceeded" when trying to UnSet a Control.
[v1.5]
+ Added AutoIt 3.2.10.0+ support, but 3.2.8.1 or less is dropped :( (due to lack of native CallBack functions).
+ Added Primary Down and Primary Up support. Helping to handle with the buttons pressing.
+ Added new arguments to calling function...
The OnHover function now can recieve two more arguments:
$iHoverMode - Defines the hover mode (1 - Hover, 2 - Leaves Hovering)
$hWnd_Hovered - Control Handle where the mouse is moved to (after hovering).
* Almost all code of this UDF was rewritted.
* Now the main function name is _GUICtrl_SetOnHover(),
but for backwards compatibility reasons, other (old) function names are still supported.
* Fixed bug with hovering controls in other apps.
* Improvements in generaly, the UDF working more stable now.
[v1.?]
* Beta changes, see "Forum link" for more details.
[v1.0]
* First release.
#CE
#EndRegion Header
#Region Internal Global Variables
Global $a__GUICtrl_SOH_Ctrls[1][1]
Global $a__GUICtrl_SOH_LastHoveredElements[2] = [-1, -1]
Global $a__GUICtrl_SOH_LastHoveredElementsMark = -1
Global $h__GUICtrl_SOH_LastClickedElementMark = -1
Global $i__GUICtrl_SOH_CtrlsModified = 0
Global $i__GUICtrl_SOH_HoverOnBackWin = 1
Global $i__GUICtrl_SOH_LastPrimaryDownCtrlID = 0
Global $p__GUICtrl_SOH_TimerProc = 0
Global $i__GUICtrl_SOH_TimerID = 0
Global $s__GUICtrl_SOH_User32_Dll = @SystemDir & "\User32.dll"
Global $s__GUICtrl_SOH_OnExitFunc = ""
If @AutoItVersion < "3.3.2.0" Then
$s__GUICtrl_SOH_OnExitFunc = Execute('Opt("OnExitFunc", "__GUICtrl_SOH_Exit")')
Else
Execute('OnAutoItExitRegister("__GUICtrl_SOH_Exit")')
EndIf
Global Const $n__GUICtrl_SOH_WM_COMMAND = 0x0111
Global Const $n__GUICtrl_SOH_WM_LBUTTONDOWN = 0x0201
#EndRegion Internal Global Variables
#Region Public Functions
; #FUNCTION# ====================================================================================================
; Name...........: _GUICtrl_OnHoverRegister
; Description....: Registers a function to be called when GUI elements been hovered.
; Syntax.........: _GUICtrl_OnHoverRegister($iCtrlID [, $sHover_Func="" [, $sLeaveHover_Func=-1 [, $sPrimaryDownFunc=-1 [, $sPrimaryUpFunc=-1 [, $iKeepCall_PrDn_Func=1 [, $iKeepCall_Hover_Func=0 ]]]]]])
;
; Parameters.....: $iCtrlID - The Ctrl ID to set hovering for (can be a -1 as indication to the last item created).
;
; $sHover_Func - [Optional] Function to call when the mouse is hovering the control.
; If this parameter passed as empty string (""),
; then the specified CtrlID is UnSet from Hovering Handler list.
;
; $sLeaveHover_Func - [Optional] Function to call when the mouse is leaving hovering the control
; (-1 no function used).
; * For both parameters, $sHover_FuncName and $sLeaveHover_FuncName,
; the specified function called with maximum 3 parameters:
; $iCtrlID - CtrlID of hovered control.
; $iHoverMode - Defines the hover mode (1 - Hover, 2 - Leaves Hovering).
; $hWnd_Hovered - Control Handle where the mouse is moved to (after hovering).
;
; $sPrimaryDownFunc - [Optional] Function to call when Primary mouse button is *clicked* on the control.
; (-1 -> function is not called).
;
; $sPrimaryUpFunc - [Optional] Function to call when Primary mouse button is *released* the control.
; (-1 -> function is not called).
;
; * For both parameters, $sPrimaryDownFunc and $sPrimaryUpFunc,
; the specified function called with maximum 2 parameters:
; $iCtrlID - CtrlID of clicked control.
; $iClickMode - Defines the click mode (1 - Pressed, 2 - Released).
;
; $iKeepCall_PrDn_Func - [Optional] If this parameter < 1,
; then the $sPrimaryDownFunc function will *Not* be called constantly untill
; the primary mouse button is released (default behaviour - $iKeepCall_PrDn_Func = 1).
;
; $iKeepCall_Hover_Func - [Optional] If this parameter = 1,
; then the $sHover_Func function *Will* be called constantly untill
; the control is no longer been hovered (default behaviour - $iKeepCall_Hover_Func = 0).
;
; Return values..: Success - Returns 1 if the function registered succesefully.
; When $iCtrlID is redefined (ReSet, already exists in the controls list), the return value is 2.
; Failure - Set @error to 1 and return 0 if $iCtrlID is not a GUI Control Identifier.
;
; Author.........: G.Sandler (a.k.a CreatoR), www.creator-lab.ucoz.ru, www.autoit-script.ru.
; Modified.......:
; Remarks........: 1) TreeView/ListView Items can not be set :(.
; 2) When the window is not active, the hover/leave hover functions will still called, but not when the window is disabled.
; 3) The hover/leave hover functions will be called even if the script is paused by such functions as MsgBox().
; 4) The $sHover_Func/$sLeaveHover_Func functions should not introduce significant delays in the main script,
; for example by calling functions like Sleep() or MsgBox().
; 5) IMPORTANT!
; A) Do not call _GUICtrl_OnHoverRegister inside $sHover_Func/$sLeaveHover_Func functions, it's not a good idea.
;
; B) This UDF registering WM_COMMAND and WM_LBUTTONDOWN window messages.
; Please ensure that those messages are not used after including this library,
; if they do, you will have to call __GUICtrl_SOH_WM_COMMAND and __GUICtrl_SOH_WM_LBUTTONDOWN inside those functions. Example:
;
; Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
; __GUICtrl_SOH_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
; ...
; EndFunc
;
; Related........:
; Link...........: http://www.autoitscript.com/forum/index.php?s=&showtopic=55120
; Example........: Yes.
; ===============================================================================================================
Func _GUICtrl_OnHoverRegister($iCtrlID, $sHover_Func="", $sLeaveHover_Func=-1, $sPrimaryDownFunc=-1, $sPrimaryUpFunc=-1, $iKeepCall_PrDn_Func=1, $iKeepCall_Hover_Func=0)
Local $hCtrlID = GUICtrlGetHandle($iCtrlID)
If Not $hCtrlID Then
Return SetError(1, 0, 0)
EndIf
If $p__GUICtrl_SOH_TimerProc = 0 Then
$p__GUICtrl_SOH_TimerProc = DllCallbackRegister("__GUICtrl_SOH_CALLBACK", "none", "hwnd;int;uint_ptr;dword")
$i__GUICtrl_SOH_TimerID = DllCall($s__GUICtrl_SOH_User32_Dll, "int", "SetTimer", _
"hwnd", 0, "uint_ptr", Round(TimerInit()), "uint", 30, "ptr", DllCallbackGetPtr($p__GUICtrl_SOH_TimerProc))
GUIRegisterMsg($n__GUICtrl_SOH_WM_COMMAND, "__GUICtrl_SOH_WM_COMMAND")
GUIRegisterMsg($n__GUICtrl_SOH_WM_LBUTTONDOWN, "__GUICtrl_SOH_WM_LBUTTONDOWN")
If IsArray($i__GUICtrl_SOH_TimerID) Then
$i__GUICtrl_SOH_TimerID = $i__GUICtrl_SOH_TimerID[0]
EndIf
EndIf
;UnSet Hovering for specified control (remove control id from hovering checking process)
If $sHover_Func = "" And @NumParams <= 2 Then
Local $a__GUICtrl_SOH_Ctrls_Tmp[1][1]
Local $a__GUICtrl_SOH_Ctrls_Swap = $a__GUICtrl_SOH_Ctrls ;This one prevents a bug with "dimension range exceeded"
For $i = 1 To $a__GUICtrl_SOH_Ctrls_Swap[0][0]
If $hCtrlID <> $a__GUICtrl_SOH_Ctrls_Swap[$i][0] Then
$a__GUICtrl_SOH_Ctrls_Tmp[0][0] += 1
ReDim $a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]+1][7]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][0] = $a__GUICtrl_SOH_Ctrls_Swap[$i][0]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][1] = $a__GUICtrl_SOH_Ctrls_Swap[$i][1]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][2] = $a__GUICtrl_SOH_Ctrls_Swap[$i][2]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][3] = $a__GUICtrl_SOH_Ctrls_Swap[$i][3]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][4] = $a__GUICtrl_SOH_Ctrls_Swap[$i][4]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][5] = $a__GUICtrl_SOH_Ctrls_Swap[$i][5]
$a__GUICtrl_SOH_Ctrls_Tmp[$a__GUICtrl_SOH_Ctrls_Tmp[0][0]][6] = $a__GUICtrl_SOH_Ctrls_Swap[$i][6]
EndIf
Next
If $a__GUICtrl_SOH_Ctrls_Tmp[0][0] < 1 Then
__GUICtrl_SOH_ReleaseResources() ;Release the callbacks
Else
$i__GUICtrl_SOH_CtrlsModified = 1
$a__GUICtrl_SOH_Ctrls = $a__GUICtrl_SOH_Ctrls_Tmp
EndIf
Return 1
EndIf
;Check if the hovering process already handle the passed CtrlID, if so, just assign new values (functions)
For $i = 1 To $a__GUICtrl_SOH_Ctrls[0][0]
If $hCtrlID = $a__GUICtrl_SOH_Ctrls[$i][0] Then
$a__GUICtrl_SOH_Ctrls[$i][0] = $hCtrlID
$a__GUICtrl_SOH_Ctrls[$i][1] = $sHover_Func
$a__GUICtrl_SOH_Ctrls[$i][2] = $sLeaveHover_Func
$a__GUICtrl_SOH_Ctrls[$i][3] = $sPrimaryDownFunc
$a__GUICtrl_SOH_Ctrls[$i][4] = $sPrimaryUpFunc
$a__GUICtrl_SOH_Ctrls[$i][5] = $iKeepCall_PrDn_Func
$a__GUICtrl_SOH_Ctrls[$i][6] = $iKeepCall_Hover_Func
Return 2
EndIf
Next
$a__GUICtrl_SOH_Ctrls[0][0] += 1
ReDim $a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]+1][7]
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][0] = $hCtrlID
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][1] = $sHover_Func
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][2] = $sLeaveHover_Func
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][3] = $sPrimaryDownFunc
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][4] = $sPrimaryUpFunc
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][5] = $iKeepCall_PrDn_Func
$a__GUICtrl_SOH_Ctrls[$a__GUICtrl_SOH_Ctrls[0][0]][6] = $iKeepCall_Hover_Func
Return 1
EndFunc
;Set the hovering mode:
; $iSetBackWin = 1 (default) hovering process will proceed even when GUI is not active (in background).
; $iSetBackWin <> 1 hovering process will NOT proceed when GUI is not active.
Func _GUICtrl_SetHoverOnBackWindow($iSetBackWin)
$i__GUICtrl_SOH_HoverOnBackWin = Number($iSetBackWin = 1)
EndFunc
#EndRegion Public Functions
#Region Backwards Compatibility Functions
;Backwards compatibility function #1
Func _GUICtrl_SetOnHover($iCtrlID, $sHover_Func="", $sLeaveHover_Func=-1, $sPrimaryDownFunc=-1, $sPrimaryUpFunc=-1, $iKeepCall_PrDn_Func=1, $iKeepCall_Hover_Func=0)
_GUICtrl_OnHoverRegister($iCtrlID, $sHover_Func, $sLeaveHover_Func, $sPrimaryDownFunc, $sPrimaryUpFunc, $iKeepCall_PrDn_Func, $iKeepCall_Hover_Func)
EndFunc
;Backwards compatibility function #2
Func GUICtrl_SetOnHover($iCtrlID, $sHover_Func="", $sLeaveHover_Func=-1, $sPrimaryDownFunc=-1, $sPrimaryUpFunc=-1, $iKeepCall_PrDn_Func=1, $iKeepCall_Hover_Func=0)
_GUICtrl_OnHoverRegister($iCtrlID, $sHover_Func, $sLeaveHover_Func, $sPrimaryDownFunc, $sPrimaryUpFunc, $iKeepCall_PrDn_Func, $iKeepCall_Hover_Func)
EndFunc
;Backwards compatibility function #3
Func GUICtrlSetOnHover($iCtrlID, $sHover_Func="", $sLeaveHover_Func=-1, $sPrimaryDownFunc=-1, $sPrimaryUpFunc=-1, $iKeepCall_PrDn_Func=1, $iKeepCall_Hover_Func=0)
_GUICtrl_OnHoverRegister($iCtrlID, $sHover_Func, $sLeaveHover_Func, $sPrimaryDownFunc, $sPrimaryUpFunc, $iKeepCall_PrDn_Func, $iKeepCall_Hover_Func)
EndFunc
;Backwards compatibility function #4
Func _GUICtrlSetOnHover($iCtrlID, $sHover_Func="", $sLeaveHover_Func=-1, $sPrimaryDownFunc=-1, $sPrimaryUpFunc=-1, $iKeepCall_PrDn_Func=1, $iKeepCall_Hover_Func=0)
_GUICtrl_OnHoverRegister($iCtrlID, $sHover_Func, $sLeaveHover_Func, $sPrimaryDownFunc, $sPrimaryUpFunc, $iKeepCall_PrDn_Func, $iKeepCall_Hover_Func)
EndFunc
#EndRegion Backwards Compatibility Functions
#Region Internal Functions
;CallBack function to handle the hovering process
Func __GUICtrl_SOH_CALLBACK($hWnd, $uiMsg, $idEvent, $dwTime)
$i__GUICtrl_SOH_CtrlsModified = 0
If $a__GUICtrl_SOH_Ctrls[0][0] < 1 Then
Return
EndIf
If $i__GUICtrl_SOH_HoverOnBackWin Then
Local $iControl_Hovered = __GUICtrl_SOH_ControlGetHovered()
Else
Local $iControl_Hovered = GUIGetCursorInfo()
If Not IsArray($iControl_Hovered) Then
Return
EndIf
$iControl_Hovered = GUICtrlGetHandle($iControl_Hovered[4])
EndIf
Local $sCheck_LHE = $a__GUICtrl_SOH_LastHoveredElements[1]
Local $iCheck_LCEM = $h__GUICtrl_SOH_LastClickedElementMark
Local $iCtrlID
;Leave Hovering Process and reset variables
If Not $iControl_Hovered Or ($sCheck_LHE <> -1 And $iControl_Hovered <> $sCheck_LHE) Then
If $a__GUICtrl_SOH_LastHoveredElementsMark = -1 Then
Return
EndIf
Local $a__Tmp_GUICtrl_SOH_LastHoveredElements[2] = [$a__GUICtrl_SOH_LastHoveredElements[0], $a__GUICtrl_SOH_LastHoveredElements[1]]
$a__GUICtrl_SOH_LastHoveredElements[0] = -1
$a__GUICtrl_SOH_LastHoveredElements[1] = -1
$a__GUICtrl_SOH_LastHoveredElementsMark = -1
$h__GUICtrl_SOH_LastClickedElementMark = -1
If $a__Tmp_GUICtrl_SOH_LastHoveredElements[0] <> -1 Then
$iCtrlID = DllCall($s__GUICtrl_SOH_User32_Dll, "int", "GetDlgCtrlID", "hwnd", $a__Tmp_GUICtrl_SOH_LastHoveredElements[1])
If IsArray($iCtrlID) Then
$iCtrlID = $iCtrlID[0]
EndIf
;2 is the indicator of OnLeavHover process
__GUICtrl_SOH_Call($a__Tmp_GUICtrl_SOH_LastHoveredElements[0], $iCtrlID, 2, $iControl_Hovered)
EndIf
Else ;Hovering Process, Primary Down/Up handler, and set $a__GUICtrl_SOH_LastHoveredElements
If $i__GUICtrl_SOH_CtrlsModified = 1 Then
$i__GUICtrl_SOH_CtrlsModified = 0
Return
EndIf
Local $iUbound = UBound($a__GUICtrl_SOH_Ctrls)-1
For $i = 1 To $a__GUICtrl_SOH_Ctrls[0][0]
If $i > $iUbound Then
ExitLoop
EndIf
If $a__GUICtrl_SOH_Ctrls[$i][0] = $iControl_Hovered Then
$iCtrlID = DllCall($s__GUICtrl_SOH_User32_Dll, "int", "GetDlgCtrlID", "hwnd", $iControl_Hovered)
If IsArray($iCtrlID) Then
$iCtrlID = $iCtrlID[0]
EndIf
;Primary Down/Up handler
If ($a__GUICtrl_SOH_Ctrls[$i][3] <> "" Or $a__GUICtrl_SOH_Ctrls[$i][4] <> "") And ($iCheck_LCEM = -1 Or $iCheck_LCEM = $iControl_Hovered) Then
Local $aCursorInfo = 0
Local $hParent_Wnd = DllCall($s__GUICtrl_SOH_User32_Dll, "hwnd", "GetParent", "hwnd", $iControl_Hovered)
If Not @error And IsArray($hParent_Wnd) Then
$hParent_Wnd = $hParent_Wnd[0]
$aCursorInfo = GUIGetCursorInfo($hParent_Wnd)
Else
$aCursorInfo = GUIGetCursorInfo()
EndIf
If IsArray($aCursorInfo) Then
;Primary Down...
;* First condition is to prevent function call when holding down m.button from other control
;* Last condition is to Prevent/Allow multiple function call
;(depending on $iKeepCall_PrDn_Func param).
If ($i__GUICtrl_SOH_LastPrimaryDownCtrlID = $iControl_Hovered Or $i__GUICtrl_SOH_LastPrimaryDownCtrlID = 0) And WinActive($hParent_Wnd) And _
$aCursorInfo[2] = 1 And $a__GUICtrl_SOH_Ctrls[$i][3] <> -1 And _
(($a__GUICtrl_SOH_Ctrls[$i][5] < 1 And $iCheck_LCEM <> $iControl_Hovered) Or $a__GUICtrl_SOH_Ctrls[$i][5] > 0) Then
;1 is the indicator of Primary*Down* event
__GUICtrl_SOH_Call($a__GUICtrl_SOH_Ctrls[$i][3], $iCtrlID, 1)
$h__GUICtrl_SOH_LastClickedElementMark = $iControl_Hovered
;Primary Up
ElseIf $aCursorInfo[2] = 0 And $a__GUICtrl_SOH_Ctrls[$i][4] <> -1 And $iCheck_LCEM = $iControl_Hovered Then
;2 is the indicator of Primary*Up* event
__GUICtrl_SOH_Call($a__GUICtrl_SOH_Ctrls[$i][4], $iCtrlID, 2)
$h__GUICtrl_SOH_LastClickedElementMark = -1
EndIf
EndIf
EndIf
If $i__GUICtrl_SOH_CtrlsModified = 1 Then
ExitLoop
EndIf
If $a__GUICtrl_SOH_Ctrls[$i][6] < 1 And $a__GUICtrl_SOH_LastHoveredElementsMark = $a__GUICtrl_SOH_Ctrls[$i][0] Then
ExitLoop
Else
$a__GUICtrl_SOH_LastHoveredElementsMark = $a__GUICtrl_SOH_Ctrls[$i][0]
EndIf
If $a__GUICtrl_SOH_Ctrls[$i][2] <> -1 Then
$a__GUICtrl_SOH_LastHoveredElements[0] = $a__GUICtrl_SOH_Ctrls[$i][2]
$a__GUICtrl_SOH_LastHoveredElements[1] = $iControl_Hovered
EndIf
__GUICtrl_SOH_Call($a__GUICtrl_SOH_Ctrls[$i][1], $iCtrlID, 1, 0) ;1 is the indicator of OnHover process
If $i__GUICtrl_SOH_CtrlsModified = 1 Then
ExitLoop
EndIf
ExitLoop
EndIf
Next
EndIf
$i__GUICtrl_SOH_CtrlsModified = 0
EndFunc
Func __GUICtrl_SOH_WM_COMMAND($hWndGUI, $MsgID, $WParam, $LParam)
$i__GUICtrl_SOH_LastPrimaryDownCtrlID = $LParam
EndFunc
Func __GUICtrl_SOH_WM_LBUTTONDOWN($hWndGUI, $MsgID, $WParam, $LParam)
$i__GUICtrl_SOH_LastPrimaryDownCtrlID = 0
EndFunc
;Thanks to amel27 for that one!!!
Func __GUICtrl_SOH_ControlGetHovered()
Local $iOld_Opt_MCM = Opt("MouseCoordMode", 1)
Local $tPoint = DllStructCreate("int X;int Y")
Local $aMPos = MouseGetPos()
DllStructSetData($tPoint, "x", $aMPos[0])
DllStructSetData($tPoint, "y", $aMPos[1])
Local $tPointCast = DllStructCreate("int64", DllStructGetPtr($tPoint))
Local $aRet = DllCall($s__GUICtrl_SOH_User32_Dll, "hwnd", "WindowFromPoint", "int64", DllStructGetData($tPointCast, 1))
Opt("MouseCoordMode", $iOld_Opt_MCM)
If @error Then
Return SetError(@error, @extended, 0)
EndIf
Return $aRet[0]
EndFunc
;Call() function wrapper
Func __GUICtrl_SOH_Call($sFunction, $sParam1="", $sParam2="", $sParam3="", $sParam4="", $sParam5="")
Local $iRet = Call($sFunction)
If @error <> 0xDEAD Then
Return $iRet
EndIf
$iRet = Call($sFunction, $sParam1)
If @error <> 0xDEAD Then
Return $iRet
EndIf
$iRet = Call($sFunction, $sParam1, $sParam2)
If @error <> 0xDEAD Then
Return $iRet
EndIf
$iRet = Call($sFunction, $sParam1, $sParam2, $sParam3)
If @error <> 0xDEAD Then
Return $iRet
EndIf
$iRet = Call($sFunction, $sParam1, $sParam2, $sParam3, $sParam4)
If @error <> 0xDEAD Then
Return $iRet
EndIf
$iRet = Call($sFunction, $sParam1, $sParam2, $sParam3, $sParam4, $sParam5)
If @error <> 0xDEAD Then
Return $iRet
EndIf
Return SetError(1, 0, 0)
EndFunc
;Release resources function
Func __GUICtrl_SOH_ReleaseResources()
If $p__GUICtrl_SOH_TimerProc > 0 Then
DllCallbackFree($p__GUICtrl_SOH_TimerProc)
EndIf
If $i__GUICtrl_SOH_TimerID > 0 Then
DllCall($s__GUICtrl_SOH_User32_Dll, "int", "KillTimer", "hwnd", 0, "uint_ptr", $i__GUICtrl_SOH_TimerID)
EndIf
GUIRegisterMsg($n__GUICtrl_SOH_WM_COMMAND, "")
GUIRegisterMsg($n__GUICtrl_SOH_WM_LBUTTONDOWN, "")
$p__GUICtrl_SOH_TimerProc = 0
$i__GUICtrl_SOH_TimerID = 0
EndFunc
;Release the CallBack resources when exit
Func __GUICtrl_SOH_Exit()
If $s__GUICtrl_SOH_OnExitFunc <> "" Then
Call($s__GUICtrl_SOH_OnExitFunc)
EndIf
__GUICtrl_SOH_ReleaseResources()
EndFunc
#EndRegion Internal Functions
-393
View File
@@ -1,393 +0,0 @@
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <FileConstants.au3>
#NoTrayIcon
#RequireAdmin
#pragma compile(Stripper, True)
#pragma compile(ProductVersion, 3.2.0)
#pragma compile(ProductName, "Change bootLoader")
#pragma compile(FileDescription, CBL)
#pragma compile(LegalCopyright, paravis.ru@2024)
#pragma compile(CompanyName, paravis.ru@2024)
Opt("ExpandEnvStrings", 1)
Opt("GUIOnEventMode", 0)
Opt("MustDeclareVars", 1)
; --- оформление (как у установщика)
Global Const $CLR_BG = 0xF1F4F9
Global Const $CLR_HEAD = 0x1E2A44
Global Const $CLR_DIM = 0x6B7280
Global Const $CLR_BORDER = 0xBFC9D6
Global Const $CLR_BTN = 0xFFFFFF
Global Const $CLR_HOVER = 0xE4EEFF
Global Const $CLR_PRESS = 0xCFE0FF
Global Const $CLR_TEXT = 0x14202E
Global $sDisk = StringLeft(@ScriptDir, 2)
Global $boot = ($sDisk & "\efi\Paravis\Boot")
Global $bootice = ($boot & "\bootice.exe")
; защита: не даём случайно записать MBR в диск, где нет сборки Paravis
If Not FileExists($bootice) Or Not FileExists($boot & "\NOT.DEL") Then
MsgBox(BitOR($MB_ICONERROR, $MB_OK), "Change BootLoader", "Этот диск не является сборкой Paravis (нет bootice.exe или NOT.DEL):" & @CRLF & $sDisk)
Exit
EndIf
Global $hMain, $hMin, $hClose, $hTitle, $hSub
Global $aFrame[7], $aBtn[7], $aBg[7], $aName[7]
Global $gDown = -1, $gBusy = False, $gDrag = False, $gDragX = 0, $gDragY = 0
Global $gMinBg = -1, $gCloseBg = -1
; --- окно
$hMain = GUICreate("Change BootLoader", 376, 208, -1, -1, $WS_POPUP, $WS_EX_APPWINDOW)
GUISetBkColor($CLR_BG, $hMain)
GUISetFont(9, 400, 0, "Tahoma", $hMain)
; шапка
Global $hHead = GUICtrlCreateLabel("", 0, 0, 376, 48)
GUICtrlSetBkColor($hHead, $CLR_HEAD)
$hTitle = GUICtrlCreateLabel("Paravis Flash", 16, 2, 300, 24)
GUICtrlSetFont($hTitle, 15, 700, 0, "Tahoma")
GUICtrlSetColor($hTitle, 0xFFFFFF)
GUICtrlSetBkColor($hTitle, $CLR_HEAD)
$hSub = GUICtrlCreateLabel("Смена загрузчика", 18, 27, 300, 14)
GUICtrlSetColor($hSub, 0xC7D0E0)
GUICtrlSetBkColor($hSub, $CLR_HEAD)
$hMin = GUICtrlCreateLabel("—", 306, 2, 30, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_NOTIFY))
GUICtrlSetFont($hMin, 10, 400, 0, "Tahoma")
GUICtrlSetColor($hMin, 0xC7D0E0)
GUICtrlSetBkColor($hMin, $CLR_HEAD)
$hClose = GUICtrlCreateLabel("✕", 338, 2, 30, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_NOTIFY))
GUICtrlSetFont($hClose, 9, 400, 0, "Tahoma")
GUICtrlSetColor($hClose, 0xC7D0E0)
GUICtrlSetBkColor($hClose, $CLR_HEAD)
; --- подписи секций
Local $hSecL = GUICtrlCreateLabel("LEGACY BIOS", 15, 56, 200, 14)
GUICtrlSetFont($hSecL, 8, 700, 0, "Tahoma")
GUICtrlSetColor($hSecL, $CLR_DIM)
GUICtrlSetBkColor($hSecL, $CLR_BG)
Local $hSecU = GUICtrlCreateLabel("UEFI", 15, 152, 200, 14)
GUICtrlSetFont($hSecU, 8, 700, 0, "Tahoma")
GUICtrlSetColor($hSecU, $CLR_DIM)
GUICtrlSetBkColor($hSecU, $CLR_BG)
; --- кнопки: рамка 1 px + надпись
$aName[0] = "XorBoot"
$aName[1] = "Bootmgr"
$aName[2] = "Grub4Dos"
$aName[3] = "Grub2"
$aName[4] = "Bootmgr"
$aName[5] = "Grub2"
$aName[6] = "Xorboot"
Local $aPos[7][4] = [ _
[14, 72, 170, 32], _
[192, 72, 170, 32], _
[14, 110, 170, 32], _
[192, 110, 170, 32], _
[14, 168, 110, 32], _
[132, 168, 110, 32], _
[250, 168, 110, 32] ]
Local $i
For $i = 0 To 6
$aFrame[$i] = GUICtrlCreateLabel("", $aPos[$i][0] - 1, $aPos[$i][1] - 1, $aPos[$i][2] + 2, $aPos[$i][3] + 2)
GUICtrlSetBkColor($aFrame[$i], $CLR_BORDER)
$aBtn[$i] = GUICtrlCreateLabel($aName[$i], $aPos[$i][0], $aPos[$i][1], $aPos[$i][2], $aPos[$i][3], BitOR($SS_CENTER, $SS_CENTERIMAGE, $SS_NOTIFY))
GUICtrlSetFont($aBtn[$i], 10, 400, 0, "Segoe UI Semibold")
GUICtrlSetColor($aBtn[$i], $CLR_TEXT)
GUICtrlSetBkColor($aBtn[$i], $CLR_BTN)
$aBg[$i] = $CLR_BTN
Next
GUISetState(@SW_SHOW, $hMain)
AdlibRegister("_Poll", 40)
While 1
If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
Sleep(30)
WEnd
; ================= действия =================
Func _Run($idx)
If $gBusy Then Return
; перед любым действием подтверждаем целевой диск
If Not FileExists($boot & "\NOT.DEL") Or _DiskNumber($sDisk) < 0 Then
_Msg("Целевой диск не подтверждён:" & @CRLF & $sDisk & @CRLF & _
"нет \efi\Paravis\Boot\NOT.DEL или не найден PhysicalDrive.")
Return
EndIf
$gBusy = True
Switch $idx
Case 0
_LegacyXor()
Case 1
_LegacyMgr()
Case 2
_LegacyG4d()
Case 3
_LegacyGrub2()
Case 4
_UefiMgr()
Case 5
_UefiGrub2()
Case 6
_UefiXor()
EndSwitch
$gBusy = False
EndFunc
Func _LegacyXor()
FileDelete($sDisk & "\bootmgr")
FileDelete($sDisk & "\grldr")
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /restore /file=" & $boot & "\xor\xmbr.bin /keep_dpt /quiet")
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /restore /file=" & $boot & "\xor\xpbr.bin /keep_bpb /quiet")
_Done("XorBoot")
EndFunc
Func _LegacyMgr()
FileDelete($sDisk & "\bootmgr")
FileDelete($sDisk & "\grldr")
FileCopy($boot & "\mgr\bootmgr", $sDisk & "\bootmgr")
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=nt60 /quiet")
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=bootmgr /quiet")
_Done("Bootmgr")
EndFunc
Func _LegacyG4d()
FileDelete($sDisk & "\bootmgr")
FileDelete($sDisk & "\grldr")
FileCopy($boot & "\g4d\grldr", $sDisk & "\grldr")
RunWait($bootice & " /DEVICE=" & $sDisk & " /mbr /install /type=GRUB4DOS /quiet")
RunWait($bootice & " /DEVICE=" & $sDisk & " /pbr /install /type=GRUB4DOS /quiet")
_Done("Grub4Dos")
EndFunc
Func _LegacyGrub2()
Local $src = $boot & "\loaders\grub2-bios"
Local $dst = $boot & "\grub2\bios"
If Not FileExists($src & "\boot.img") Or Not FileExists($src & "\core.img") Then
_Msg("Файлы GRUB2 для Legacy BIOS не найдены:" & @CRLF & $src)
Return
EndIf
If Not FileExists($dst & "\grub.cfg") Then
_Msg("Не найден основной grub.cfg:" & @CRLF & $dst & "\grub.cfg")
Return
EndIf
Local $disk = _DiskNumber($sDisk)
If $disk < 0 Then
_Msg("Не удалось определить номер физического диска для " & $sDisk)
Return
EndIf
; убрать файлы других Legacy-загрузчиков из корня
FileDelete($sDisk & "\bootmgr")
FileDelete($sDisk & "\grldr")
; дерево для core.img: модули и меню должны лежать по префиксу /efi/Paravis/Boot/grub2/bios
DirCreate($dst)
DirCreate($dst & "\i386-pc")
FileCopy($src & "\boot.img", $dst & "\boot.img", 9)
FileCopy($src & "\core.img", $dst & "\core.img", 9)
FileCopy($src & "\make-paravis-mbr.ps1", $dst & "\make-paravis-mbr.ps1", 9)
; grub.cfg НЕ копируем: в loaders лежит тестовое меню, рабочее уже в $dst
RunWait(@ComSpec & ' /c xcopy /E /I /Y /Q "' & $src & '\i386-pc" "' & $dst & '\i386-pc" > nul 2>&1', "", @SW_HIDE)
; MBR-образ: наш boot.img (0..439) + текущая таблица разделов (440..511)
Local $rc1 = RunWait('powershell.exe -NoProfile -ExecutionPolicy Bypass -File "' & $dst & '\make-paravis-mbr.ps1" -Disk ' & $disk & ' -Boot "' & $dst & '\boot.img" -Out "' & $dst & '\paravis-mbr-table.img"', "", @SW_HIDE)
If $rc1 <> 0 Then
_Msg("Не удалось сформировать MBR-образ (код " & $rc1 & ").")
Return
EndIf
; Bootice /sectors: MBR (сектор 0) и core.img (с сектора 1); таблица разделов сохраняется
Local $rc2 = RunWait('"' & $bootice & '" /DEVICE=' & $sDisk & ' /sectors /restore /file="' & $dst & '\paravis-mbr-table.img" /lba=0 /sectors=1 /quiet', "", @SW_HIDE)
If $rc2 <> 0 Then
_Msg("Ошибка записи MBR (код " & $rc2 & ").")
Return
EndIf
Local $rc3 = RunWait('"' & $bootice & '" /DEVICE=' & $sDisk & ' /sectors /restore /file="' & $dst & '\core.img" /lba=1 /sectors=591 /quiet', "", @SW_HIDE)
If $rc3 <> 0 Then
_Msg("Ошибка записи core.img (код " & $rc3 & ").")
Return
EndIf
_Done("Grub2 (Legacy)")
EndFunc
Func _UefiMgr()
_UefiClean()
FileCopy($boot & "\mgr\UEFI\bootx64.efi", $sDisk & "\efi\boot\bootx64.efi")
FileCopy($boot & "\mgr\UEFI\bootia32.efi", $sDisk & "\efi\boot\bootia32.efi")
_Done("UEFI Bootmgr")
EndFunc
Func _UefiGrub2()
; bootia32 не трогаем: на ia32 остаётся XorBoot
FileDelete($sDisk & "\efi\boot\bootx64.efi")
FileDelete($sDisk & "\efi\boot\fbx64.efi")
FileDelete($sDisk & "\efi\boot\mmx64.efi")
FileCopy($boot & "\loaders\grub2\bootx64.efi", $sDisk & "\efi\boot\bootx64.efi")
FileCopy($boot & "\loaders\grub2\fbx64.efi", $sDisk & "\efi\boot\fbx64.efi")
FileCopy($boot & "\loaders\grub2\mmx64.efi", $sDisk & "\efi\boot\mmx64.efi")
_Done("UEFI GRUB2")
EndFunc
Func _UefiXor()
_UefiClean()
FileCopy($boot & "\xor\UEFI\bootx64.efi", $sDisk & "\efi\boot\bootx64.efi")
FileCopy($boot & "\xor\UEFI\bootia32.efi", $sDisk & "\efi\boot\bootia32.efi")
_Done("UEFI Xorboot")
EndFunc
Func _UefiClean()
FileDelete($sDisk & "\efi\boot\bootx64.efi")
FileDelete($sDisk & "\efi\boot\bootia32.efi")
FileDelete($sDisk & "\efi\boot\fbx64.efi")
FileDelete($sDisk & "\efi\boot\mmx64.efi")
EndFunc
; ================= служба =================
Func _Done($name)
_Msg("Загрузчик изменён: " & $name)
EndFunc
Func _Msg($text)
Local $prev = $gBusy
$gBusy = True
MsgBox(BitOR($MB_ICONINFORMATION, $MB_OK), "Change BootLoader", $text)
$gBusy = $prev
EndFunc
Func _DiskNumber($letter)
Local $oWMI = ObjGet("winmgmts:\\.\root\cimv2")
If Not IsObj($oWMI) Then Return -1
Local $col = $oWMI.ExecQuery("SELECT * FROM Win32_DiskDrive")
If Not IsObj($col) Then Return -1
For $d In $col
Local $parts = $oWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $d.DeviceID & "'} WHERE AssocClass=Win32_DiskDriveToDiskPartition")
If IsObj($parts) Then
For $p In $parts
Local $lds = $oWMI.ExecQuery("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $p.DeviceID & "'} WHERE AssocClass=Win32_LogicalDiskToPartition")
If IsObj($lds) Then
For $l In $lds
If StringUpper(String($l.DeviceID)) = StringUpper($letter) Then
Return Number(StringRegExpReplace($d.DeviceID, ".*PHYSICALDRIVE(\d+).*", "$1"))
EndIf
Next
EndIf
Next
EndIf
Next
Return -1
EndFunc
Func _Poll()
Local $ci = GUIGetCursorInfo($hMain)
If Not IsArray($ci) Then Return
; кнопки шапки
Local $minBg = $CLR_HEAD, $closeBg = $CLR_HEAD
If $ci[4] = $hMin Then
If $ci[2] = 1 Then
$minBg = 0x3A4A6B
Else
$minBg = 0x2C3A57
EndIf
EndIf
If $ci[4] = $hClose Then
If $ci[2] = 1 Then
$closeBg = 0xC0392B
Else
$closeBg = 0xE04B3F
EndIf
EndIf
If $minBg <> $gMinBg Then
GUICtrlSetBkColor($hMin, $minBg)
$gMinBg = $minBg
EndIf
If $closeBg <> $gCloseBg Then
GUICtrlSetBkColor($hClose, $closeBg)
$gCloseBg = $closeBg
EndIf
; нажатия в шапке
Static $minDown = False, $closeDown = False
If $ci[4] = $hMin And $ci[2] = 1 Then
$minDown = True
ElseIf $minDown Then
$minDown = False
If $ci[4] = $hMin And $ci[2] = 0 Then GUISetState(@SW_MINIMIZE, $hMain)
EndIf
If $ci[4] = $hClose And $ci[2] = 1 Then
$closeDown = True
ElseIf $closeDown Then
$closeDown = False
If $ci[4] = $hClose And $ci[2] = 0 Then Exit
EndIf
; перетаскивание за шапку
If ($ci[4] = $hHead Or $ci[4] = $hTitle Or $ci[4] = $hSub) And $ci[2] = 1 And Not $gDrag Then
Local $m = MouseGetPos()
Local $w = WinGetPos($hMain)
If IsArray($m) And IsArray($w) Then
$gDrag = True
$gDragX = $m[0] - $w[0]
$gDragY = $m[1] - $w[1]
EndIf
EndIf
If $gDrag Then
If $ci[2] = 0 Then
$gDrag = False
Else
Local $m2 = MouseGetPos()
If IsArray($m2) Then WinMove($hMain, "", $m2[0] - $gDragX, $m2[1] - $gDragY)
EndIf
EndIf
; подсветка кнопок
Local $i
For $i = 0 To 6
Local $bg = $CLR_BTN
If $ci[4] = $aBtn[$i] Or $ci[4] = $aFrame[$i] Then
If $ci[2] = 1 Then
$bg = $CLR_PRESS
Else
$bg = $CLR_HOVER
EndIf
EndIf
If $aBg[$i] <> $bg Then
GUICtrlSetBkColor($aBtn[$i], $bg)
$aBg[$i] = $bg
EndIf
Next
; клик по кнопке
If $gBusy Then Return
If $ci[2] = 1 Then
For $i = 0 To 6
If $ci[4] = $aBtn[$i] Or $ci[4] = $aFrame[$i] Then
$gDown = $i
Return
EndIf
Next
$gDown = -1
ElseIf $gDown >= 0 Then
Local $idx = $gDown
$gDown = -1
If $ci[4] = $aBtn[$idx] Or $ci[4] = $aFrame[$idx] Then _Run($idx)
EndIf
EndFunc
-7
View File
@@ -1,7 +0,0 @@
# Change_bootloader
Исходник Change bootloader'а (программа установки сборки на флешку).
Все необходимые файлы для смены загрузчика, находятся уже на установленной флешке. Сама программа может лежать в любой папке на диске с установленной сборкой.
НЕ ЗАПУСКАЙТЕ ИСХОДНИК И СКОМПИЛИРОВАННЫЙ EXE НА ДИСКАХ ГДЕ НЕТ СБОРКИ. В лучшем случае получите кучу ошибок. В худшем, угробите загрузочную запись диска.
-64
View File
@@ -1,64 +0,0 @@
#pragma once
#include "util.h"
#include <windows.h>
#include <string>
class App {
public:
HINSTANCE hInst = nullptr;
HWND hwnd = nullptr;
HFONT fontTitle = nullptr;
HFONT fontSub = nullptr;
HFONT fontMin = nullptr;
HFONT fontClose = nullptr;
HFONT fontSection = nullptr;
HFONT fontButton = nullptr;
int width = 376;
int height = 208;
std::wstring disk;
std::wstring boot;
std::wstring bootice;
bool busy = false;
bool modal = false;
int activeButton = -1;
bool minDown = false;
bool closeDown = false;
bool dragging = false;
int dragX = 0;
int dragY = 0;
int downButton = -1;
COLORREF minBg = ColorFromHex(0x1E2A44);
COLORREF closeBg = ColorFromHex(0x1E2A44);
COLORREF buttonBg[7] = {
RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255),
RGB(255, 255, 255), RGB(255, 255, 255), RGB(255, 255, 255),
RGB(255, 255, 255)
};
bool Init(HWND window);
void CreateFonts();
void DestroyFonts();
void Paint(HDC dc);
void OnPoll();
void RunAction(int index);
void ShowMessage(const std::wstring& text,
UINT flags = MB_ICONINFORMATION | MB_OK);
void LegacyXor();
void LegacyMgr();
void LegacyG4d();
void LegacyGrub2();
void UefiMgr();
void UefiGrub2();
void UefiXor();
void UefiClean();
void Done(const std::wstring& name);
};
-22
View File
@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="3.2.0.0" processorArchitecture="*" name="PARAVIS.CHANGEBOOTLOADER" type="win32"/>
<description>Change bootLoader</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
</assembly>
-33
View File
@@ -1,33 +0,0 @@
#include <windows.h>
1 ICON "sec.ico"
1 24 "app.manifest"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,2,0,0
PRODUCTVERSION 3,2,0,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "paravis.ru@2024"
VALUE "FileDescription", "CBL"
VALUE "FileVersion", "3.2.0.0"
VALUE "InternalName", "ChangeBootLoader"
VALUE "OriginalFilename", "Change_BootLoader.exe"
VALUE "ProductName", "Change bootLoader"
VALUE "ProductVersion", "3.2.0.0"
VALUE "LegalCopyright", "paravis.ru@2024"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
-214
View File
@@ -1,214 +0,0 @@
#include "app.h"
#include "util.h"
#include <string>
void App::ShowMessage(const std::wstring& text, UINT flags)
{
bool previous = modal;
modal = true;
EnableWindow(hwnd, FALSE);
InvalidateRect(hwnd, nullptr, FALSE);
UpdateWindow(hwnd);
SetForegroundWindow(hwnd);
MessageBoxW(hwnd, text.c_str(), L"Change BootLoader",
flags | MB_SETFOREGROUND | MB_TOPMOST);
EnableWindow(hwnd, TRUE);
SetForegroundWindow(hwnd);
modal = previous;
InvalidateRect(hwnd, nullptr, FALSE);
}
void App::RunAction(int index)
{
if (busy) {
return;
}
int diskNumber = GetDiskNumberForDrive(disk[0]);
DebugLog(L"RunAction index=%d disk=%s physical=%d", index, disk.c_str(), diskNumber);
if (!FileExists(boot + L"\\NOT.DEL") || diskNumber < 0) {
ShowMessage(L"Целевой диск не подтверждён:\r\n" + disk +
L"\r\nнет \\efi\\Paravis\\Boot\\NOT.DEL или не найден PhysicalDrive.");
return;
}
busy = true;
activeButton = index;
InvalidateRect(hwnd, nullptr, FALSE);
UpdateWindow(hwnd);
switch (index) {
case 0:
LegacyXor();
break;
case 1:
LegacyMgr();
break;
case 2:
LegacyG4d();
break;
case 3:
LegacyGrub2();
break;
case 4:
UefiMgr();
break;
case 5:
UefiGrub2();
break;
case 6:
UefiXor();
break;
default:
break;
}
busy = false;
activeButton = -1;
InvalidateRect(hwnd, nullptr, FALSE);
}
void App::Done(const std::wstring& name)
{
ShowMessage(L"Загрузчик изменён: " + name);
}
void App::LegacyXor()
{
DeleteFileIfExists(disk + L"\\bootmgr");
DeleteFileIfExists(disk + L"\\grldr");
RunWait(bootice + L" /DEVICE=" + disk +
L" /mbr /restore /file=" + boot + L"\\xor\\xmbr.bin /keep_dpt /quiet");
RunWait(bootice + L" /DEVICE=" + disk +
L" /pbr /restore /file=" + boot + L"\\xor\\xpbr.bin /keep_bpb /quiet");
Done(L"XorBoot");
}
void App::LegacyMgr()
{
DeleteFileIfExists(disk + L"\\bootmgr");
DeleteFileIfExists(disk + L"\\grldr");
CopyFileOverwrite(boot + L"\\mgr\\bootmgr", disk + L"\\bootmgr");
RunWait(bootice + L" /DEVICE=" + disk + L" /mbr /install /type=nt60 /quiet");
RunWait(bootice + L" /DEVICE=" + disk + L" /pbr /install /type=bootmgr /quiet");
Done(L"Bootmgr");
}
void App::LegacyG4d()
{
DeleteFileIfExists(disk + L"\\bootmgr");
DeleteFileIfExists(disk + L"\\grldr");
CopyFileOverwrite(boot + L"\\g4d\\grldr", disk + L"\\grldr");
RunWait(bootice + L" /DEVICE=" + disk + L" /mbr /install /type=GRUB4DOS /quiet");
RunWait(bootice + L" /DEVICE=" + disk + L" /pbr /install /type=GRUB4DOS /quiet");
Done(L"Grub4Dos");
}
void App::LegacyGrub2()
{
std::wstring source = boot + L"\\loaders\\grub2-bios";
std::wstring destination = boot + L"\\grub2\\bios";
if (!FileExists(source + L"\\boot.img") || !FileExists(source + L"\\core.img")) {
ShowMessage(L"Файлы GRUB2 для Legacy BIOS не найдены:\r\n" + source);
return;
}
if (!FileExists(destination + L"\\grub.cfg")) {
ShowMessage(L"Не найден основной grub.cfg:\r\n" + destination + L"\\grub.cfg");
return;
}
int diskNumber = GetDiskNumberForDrive(disk[0]);
if (diskNumber < 0) {
ShowMessage(L"Не удалось определить номер физического диска для " + disk);
return;
}
DeleteFileIfExists(disk + L"\\bootmgr");
DeleteFileIfExists(disk + L"\\grldr");
EnsureDirectory(destination);
EnsureDirectory(destination + L"\\i386-pc");
CopyFileOverwrite(source + L"\\boot.img", destination + L"\\boot.img");
CopyFileOverwrite(source + L"\\core.img", destination + L"\\core.img");
CopyFileOverwrite(source + L"\\make-paravis-mbr.ps1",
destination + L"\\make-paravis-mbr.ps1");
std::wstring xcopy = L"\"" + GetComSpec() +
L"\" /c xcopy /E /I /Y /Q \"" + source + L"\\i386-pc\" \"" +
destination + L"\\i386-pc\" > nul 2>&1";
RunWait(xcopy);
std::wstring powershell = L"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"" +
destination + L"\\make-paravis-mbr.ps1\" -Disk " +
std::to_wstring(diskNumber) + L" -Boot \"" + destination +
L"\\boot.img\" -Out \"" + destination + L"\\paravis-mbr-table.img\"";
int rc1 = RunWait(powershell);
if (rc1 != 0) {
ShowMessage(L"Не удалось сформировать MBR-образ (код " +
std::to_wstring(rc1) + L").");
return;
}
std::wstring mbr = L"\"" + bootice + L"\" /DEVICE=" + disk +
L" /sectors /restore /file=\"" + destination +
L"\\paravis-mbr-table.img\" /lba=0 /sectors=1 /quiet";
int rc2 = RunWait(mbr);
if (rc2 != 0) {
ShowMessage(L"Ошибка записи MBR (код " + std::to_wstring(rc2) + L").");
return;
}
std::wstring core = L"\"" + bootice + L"\" /DEVICE=" + disk +
L" /sectors /restore /file=\"" + destination +
L"\\core.img\" /lba=1 /sectors=591 /quiet";
int rc3 = RunWait(core);
if (rc3 != 0) {
ShowMessage(L"Ошибка записи core.img (код " + std::to_wstring(rc3) + L").");
return;
}
Done(L"Grub2 (Legacy)");
}
void App::UefiMgr()
{
UefiClean();
CopyFileOverwrite(boot + L"\\mgr\\UEFI\\bootx64.efi",
disk + L"\\efi\\boot\\bootx64.efi");
CopyFileOverwrite(boot + L"\\mgr\\UEFI\\bootia32.efi",
disk + L"\\efi\\boot\\bootia32.efi");
Done(L"UEFI Bootmgr");
}
void App::UefiGrub2()
{
DeleteFileIfExists(disk + L"\\efi\\boot\\bootx64.efi");
DeleteFileIfExists(disk + L"\\efi\\boot\\fbx64.efi");
DeleteFileIfExists(disk + L"\\efi\\boot\\mmx64.efi");
CopyFileOverwrite(boot + L"\\loaders\\grub2\\bootx64.efi",
disk + L"\\efi\\boot\\bootx64.efi");
CopyFileOverwrite(boot + L"\\loaders\\grub2\\fbx64.efi",
disk + L"\\efi\\boot\\fbx64.efi");
CopyFileOverwrite(boot + L"\\loaders\\grub2\\mmx64.efi",
disk + L"\\efi\\boot\\mmx64.efi");
Done(L"UEFI GRUB2");
}
void App::UefiXor()
{
UefiClean();
CopyFileOverwrite(boot + L"\\xor\\UEFI\\bootx64.efi",
disk + L"\\efi\\boot\\bootx64.efi");
CopyFileOverwrite(boot + L"\\xor\\UEFI\\bootia32.efi",
disk + L"\\efi\\boot\\bootia32.efi");
Done(L"UEFI Xorboot");
}
void App::UefiClean()
{
DeleteFileIfExists(disk + L"\\efi\\boot\\bootx64.efi");
DeleteFileIfExists(disk + L"\\efi\\boot\\bootia32.efi");
DeleteFileIfExists(disk + L"\\efi\\boot\\fbx64.efi");
DeleteFileIfExists(disk + L"\\efi\\boot\\mmx64.efi");
}
-465
View File
@@ -1,465 +0,0 @@
#include "app.h"
#include "util.h"
#include <windowsx.h>
#include <algorithm>
#include <string>
namespace {
const wchar_t* kMainClass = L"ChangeBootLoaderCpp";
const wchar_t* kWindowTitle = L"Change BootLoader";
const DWORD CLR_BG = 0xF1F4F9;
const DWORD CLR_HEAD = 0x1E2A44;
const DWORD CLR_DIM = 0x6B7280;
const DWORD CLR_BORDER = 0xBFC9D6;
const DWORD CLR_HOVER = 0xE4EEFF;
const DWORD CLR_PRESS = 0xCFE0FF;
const DWORD CLR_TEXT = 0x14202E;
const DWORD CLR_BUSY_BG = 0xE9ECF1;
const DWORD CLR_BUSY_BORDER = 0xD5DAE2;
const DWORD CLR_BUSY_TEXT = 0xA7AEBA;
const DWORD CLR_ACTIVE_BG = 0xD8E4F8;
const DWORD CLR_ACTIVE_BORDER = 0x9BB8E8;
const DWORD CLR_ACTIVE_TEXT = 0x2E4A78;
const wchar_t* kButtonNames[7] = {
L"XorBoot", L"Bootmgr", L"Grub4Dos", L"Grub2",
L"Bootmgr", L"Grub2", L"Xorboot"
};
const int kButtonPos[7][4] = {
{ 14, 72, 170, 32 },
{ 192, 72, 170, 32 },
{ 14, 110, 170, 32 },
{ 192, 110, 170, 32 },
{ 14, 168, 110, 32 },
{ 132, 168, 110, 32 },
{ 250, 168, 110, 32 }
};
enum class HitKind {
None,
Header,
Title,
Sub,
Min,
Close,
Button
};
struct HitResult {
HitKind kind = HitKind::None;
int index = -1;
};
void FillRectColor(HDC dc, int x, int y, int w, int h, COLORREF color)
{
RECT rect{ x, y, x + w, y + h };
HBRUSH brush = CreateSolidBrush(color);
FillRect(dc, &rect, brush);
DeleteObject(brush);
}
void DrawTextRect(HDC dc, const std::wstring& text, HFONT font,
int x, int y, int w, int h, COLORREF color, UINT flags)
{
HGDIOBJ oldFont = SelectObject(dc, font);
int oldMode = SetBkMode(dc, TRANSPARENT);
COLORREF oldColor = SetTextColor(dc, color);
RECT rect{ x, y, x + w, y + h };
DrawTextW(dc, text.c_str(), -1, &rect, flags | DT_NOPREFIX | DT_SINGLELINE);
SetTextColor(dc, oldColor);
SetBkMode(dc, oldMode);
SelectObject(dc, oldFont);
}
HitResult HitTest(POINT point)
{
auto inside = [&point](int x, int y, int w, int h) {
return point.x >= x && point.y >= y &&
point.x < x + w && point.y < y + h;
};
if (inside(306, 2, 30, 18)) {
return { HitKind::Min, -1 };
}
if (inside(338, 2, 30, 18)) {
return { HitKind::Close, -1 };
}
if (inside(16, 2, 300, 24)) {
return { HitKind::Title, -1 };
}
if (inside(18, 27, 300, 14)) {
return { HitKind::Sub, -1 };
}
if (inside(0, 0, 376, 48)) {
return { HitKind::Header, -1 };
}
for (int i = 0; i < 7; ++i) {
int x = kButtonPos[i][0] - 1;
int y = kButtonPos[i][1] - 1;
int w = kButtonPos[i][2] + 2;
int h = kButtonPos[i][3] + 2;
if (inside(x, y, w, h)) {
return { HitKind::Button, i };
}
}
return {};
}
LRESULT CALLBACK MainProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
App* app = reinterpret_cast<App*>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
switch (message) {
case WM_CREATE: {
auto* create = reinterpret_cast<CREATESTRUCTW*>(lParam);
app = reinterpret_cast<App*>(create->lpCreateParams);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(app));
if (app) {
app->Init(hwnd);
}
return 0;
}
case WM_ERASEBKGND:
return 1;
case WM_PAINT: {
PAINTSTRUCT paint{};
HDC dc = BeginPaint(hwnd, &paint);
if (app) {
app->Paint(dc);
}
EndPaint(hwnd, &paint);
return 0;
}
case WM_TIMER:
if (app && wParam == 1) {
app->OnPoll();
}
return 0;
case WM_CLOSE:
DebugLog(L"WM_CLOSE busy=%d", (app && app->busy) ? 1 : 0);
if (app && app->busy) {
return 0;
}
DestroyWindow(hwnd);
return 0;
case WM_DESTROY:
if (app) {
app->DestroyFonts();
}
PostQuitMessage(0);
return 0;
}
return DefWindowProcW(hwnd, message, wParam, lParam);
}
} // namespace
bool App::Init(HWND window)
{
hwnd = window;
HDC dc = GetDC(hwnd);
int dpi = GetDeviceCaps(dc, LOGPIXELSY);
ReleaseDC(hwnd, dc);
if (dpi <= 0) {
dpi = 96;
}
auto create = [dpi](int points, int weight, const wchar_t* face) -> HFONT {
// AutoIt/Windows GUI font sizing truncates fractional pixel heights;
// this matters for 8 pt fonts (10 px, not 11 px).
int height = -(points * dpi / 72);
return CreateFontW(height, 0, 0, 0, weight,
FALSE, FALSE, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, face);
};
fontTitle = create(15, FW_BOLD, L"Tahoma");
fontSub = create(9, FW_NORMAL, L"Tahoma");
fontMin = create(10, FW_NORMAL, L"Tahoma");
fontClose = create(9, FW_NORMAL, L"Tahoma");
fontSection = create(8, FW_BOLD, L"Tahoma");
fontButton = create(10, FW_NORMAL, L"Segoe UI Semibold");
HICON icon = LoadIconW(hInst, MAKEINTRESOURCEW(1));
if (icon) {
SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(icon));
SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(icon));
}
return true;
}
void App::DestroyFonts()
{
for (HFONT* font : { &fontTitle, &fontSub, &fontMin, &fontClose,
&fontSection, &fontButton }) {
if (*font) {
DeleteObject(*font);
*font = nullptr;
}
}
}
void App::Paint(HDC dc)
{
RECT client{};
GetClientRect(hwnd, &client);
int w = client.right;
int h = client.bottom;
if (w <= 0 || h <= 0) {
return;
}
HDC memory = CreateCompatibleDC(dc);
HBITMAP bitmap = CreateCompatibleBitmap(dc, w, h);
HGDIOBJ oldBitmap = SelectObject(memory, bitmap);
FillRectColor(memory, 0, 0, 376, 208, ColorFromHex(CLR_BG));
FillRectColor(memory, 0, 0, 376, 48, ColorFromHex(CLR_HEAD));
DrawTextRect(memory, L"Paravis Flash", fontTitle, 16, 2, 300, 24,
RGB(255, 255, 255), DT_LEFT | DT_TOP);
DrawTextRect(memory, L"Смена загрузчика", fontSub, 18, 27, 300, 14,
ColorFromHex(0xC7D0E0), DT_LEFT | DT_TOP);
FillRectColor(memory, 306, 2, 30, 18, minBg);
DrawTextRect(memory, L"—", fontMin, 306, 2, 30, 18,
ColorFromHex(0xC7D0E0), DT_CENTER | DT_VCENTER);
FillRectColor(memory, 338, 2, 30, 18, closeBg);
DrawTextRect(memory, L"✕", fontClose, 338, 2, 30, 18,
ColorFromHex(0xC7D0E0), DT_CENTER | DT_VCENTER);
DrawTextRect(memory, L"LEGACY BIOS", fontSection, 15, 56, 200, 14,
ColorFromHex(CLR_DIM), DT_LEFT | DT_TOP);
DrawTextRect(memory, L"UEFI", fontSection, 15, 152, 200, 14,
ColorFromHex(CLR_DIM), DT_LEFT | DT_TOP);
for (int i = 0; i < 7; ++i) {
int x = kButtonPos[i][0];
int y = kButtonPos[i][1];
int bw = kButtonPos[i][2];
int bh = kButtonPos[i][3];
COLORREF background = buttonBg[i];
COLORREF border = ColorFromHex(CLR_BORDER);
COLORREF text = ColorFromHex(CLR_TEXT);
if (busy) {
if (i == activeButton) {
background = ColorFromHex(CLR_ACTIVE_BG);
border = ColorFromHex(CLR_ACTIVE_BORDER);
text = ColorFromHex(CLR_ACTIVE_TEXT);
} else {
background = ColorFromHex(CLR_BUSY_BG);
border = ColorFromHex(CLR_BUSY_BORDER);
text = ColorFromHex(CLR_BUSY_TEXT);
}
} else if (modal) {
background = ColorFromHex(CLR_BUSY_BG);
border = ColorFromHex(CLR_BUSY_BORDER);
text = ColorFromHex(CLR_BUSY_TEXT);
}
FillRectColor(memory, x - 1, y - 1, bw + 2, bh + 2, border);
FillRectColor(memory, x, y, bw, bh, background);
DrawTextRect(memory, kButtonNames[i], fontButton, x, y, bw, bh,
text, DT_CENTER | DT_VCENTER);
}
BitBlt(dc, 0, 0, w, h, memory, 0, 0, SRCCOPY);
SelectObject(memory, oldBitmap);
DeleteObject(bitmap);
DeleteDC(memory);
}
void App::OnPoll()
{
if (modal) {
return;
}
POINT screen{};
GetCursorPos(&screen);
bool leftDown = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0;
POINT client = screen;
ScreenToClient(hwnd, &client);
HitResult hit = HitTest(client);
if (busy) {
downButton = -1;
for (int i = 0; i < 7; ++i) {
buttonBg[i] = (i == activeButton) ? ColorFromHex(CLR_ACTIVE_BG)
: ColorFromHex(CLR_BUSY_BG);
}
minBg = ColorFromHex(CLR_HEAD);
closeBg = ColorFromHex(CLR_HEAD);
InvalidateRect(hwnd, nullptr, FALSE);
return;
}
COLORREF minColor = ColorFromHex(CLR_HEAD);
COLORREF closeColor = ColorFromHex(CLR_HEAD);
if (hit.kind == HitKind::Min) {
minColor = leftDown ? ColorFromHex(0x3A4A6B) : ColorFromHex(0x2C3A57);
}
if (hit.kind == HitKind::Close) {
closeColor = leftDown ? ColorFromHex(0xC0392B) : ColorFromHex(0xE04B3F);
}
minBg = minColor;
closeBg = closeColor;
if (hit.kind == HitKind::Min && leftDown) {
minDown = true;
} else if (minDown) {
minDown = false;
if (hit.kind == HitKind::Min && !leftDown) {
ShowWindow(hwnd, SW_MINIMIZE);
}
}
if (hit.kind == HitKind::Close && leftDown) {
closeDown = true;
} else if (closeDown) {
closeDown = false;
if (hit.kind == HitKind::Close && !leftDown && !busy) {
DestroyWindow(hwnd);
return;
}
}
if ((hit.kind == HitKind::Header || hit.kind == HitKind::Title ||
hit.kind == HitKind::Sub) && leftDown && !dragging) {
POINT mouse{};
RECT windowRect{};
GetCursorPos(&mouse);
GetWindowRect(hwnd, &windowRect);
dragging = true;
dragX = mouse.x - windowRect.left;
dragY = mouse.y - windowRect.top;
}
if (dragging) {
if (!leftDown) {
dragging = false;
} else {
POINT mouse{};
GetCursorPos(&mouse);
SetWindowPos(hwnd, nullptr, mouse.x - dragX, mouse.y - dragY,
0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
}
}
for (int i = 0; i < 7; ++i) {
COLORREF background = RGB(255, 255, 255);
if (hit.kind == HitKind::Button && hit.index == i) {
background = leftDown ? ColorFromHex(CLR_PRESS)
: ColorFromHex(CLR_HOVER);
}
buttonBg[i] = background;
}
if (leftDown) {
if (hit.kind == HitKind::Button) {
downButton = hit.index;
} else {
downButton = -1;
}
} else if (downButton >= 0) {
int index = downButton;
downButton = -1;
if (hit.kind == HitKind::Button && hit.index == index) {
RunAction(index);
}
}
InvalidateRect(hwnd, nullptr, FALSE);
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR, int)
{
HANDLE instanceMutex = CreateMutexW(nullptr, FALSE,
L"Local\\ChangeBootLoader_SingleInstance");
if (instanceMutex && GetLastError() == ERROR_ALREADY_EXISTS) {
HWND existing = FindWindowW(kMainClass, nullptr);
if (existing) {
if (IsIconic(existing)) {
ShowWindow(existing, SW_RESTORE);
}
SetForegroundWindow(existing);
} else {
MessageBoxW(nullptr, L"Change BootLoader уже запущен.",
kWindowTitle,
MB_ICONINFORMATION | MB_OK | MB_SETFOREGROUND | MB_TOPMOST);
}
CloseHandle(instanceMutex);
return 0;
}
App app;
app.hInst = hInstance;
std::wstring exeDir = GetExeDir();
if (exeDir.size() < 2 || exeDir[1] != L':') {
MessageBoxW(nullptr, L"Не удалось определить диск установщика.",
kWindowTitle,
MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST);
return 1;
}
wchar_t letter = exeDir[0];
if (letter >= L'a' && letter <= L'z') {
letter = static_cast<wchar_t>(letter - L'a' + L'A');
}
app.disk = std::wstring(1, letter) + L":";
app.boot = app.disk + L"\\efi\\Paravis\\Boot";
app.bootice = app.boot + L"\\bootice.exe";
if (!FileExists(app.bootice) || !FileExists(app.boot + L"\\NOT.DEL")) {
std::wstring text = L"Этот диск не является сборкой Paravis "
L"(нет bootice.exe или NOT.DEL):\r\n" + app.disk;
MessageBoxW(nullptr, text.c_str(), kWindowTitle,
MB_ICONERROR | MB_OK | MB_SETFOREGROUND | MB_TOPMOST);
return 0;
}
WNDCLASSEXW windowClass{};
windowClass.cbSize = sizeof(windowClass);
windowClass.lpfnWndProc = MainProc;
windowClass.hInstance = hInstance;
windowClass.hCursor = LoadCursorW(nullptr, IDC_ARROW);
windowClass.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(1));
windowClass.hIconSm = LoadIconW(hInstance, MAKEINTRESOURCEW(1));
windowClass.lpszClassName = kMainClass;
if (!RegisterClassExW(&windowClass)) {
return 1;
}
RECT workArea{};
SystemParametersInfoW(SPI_GETWORKAREA, 0, &workArea, 0);
int workWidth = workArea.right - workArea.left;
int workHeight = workArea.bottom - workArea.top;
int x = workArea.left + (workWidth - app.width) / 2;
int y = workArea.top + (workHeight - app.height) / 2;
app.hwnd = CreateWindowExW(WS_EX_APPWINDOW, kMainClass, kWindowTitle,
WS_POPUP | WS_CLIPCHILDREN,
x, y, app.width, app.height,
nullptr, nullptr, hInstance, &app);
if (!app.hwnd) {
return 1;
}
ShowWindow(app.hwnd, SW_SHOW);
UpdateWindow(app.hwnd);
SetForegroundWindow(app.hwnd);
SetTimer(app.hwnd, 1, 40, nullptr);
MSG message{};
while (GetMessageW(&message, nullptr, 0, 0) > 0) {
TranslateMessage(&message);
DispatchMessageW(&message);
}
return static_cast<int>(message.wParam);
}
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

-245
View File
@@ -1,245 +0,0 @@
#include "util.h"
#include <winioctl.h>
#include <cstdarg>
#include <cstdio>
#include <iterator>
#include <vector>
std::wstring Format(const wchar_t* fmt, ...)
{
va_list args;
va_start(args, fmt);
va_list copy;
va_copy(copy, args);
int needed = _vscwprintf(fmt, copy);
va_end(copy);
if (needed < 0) {
va_end(args);
return std::wstring();
}
std::wstring result(static_cast<size_t>(needed), L'\0');
if (needed > 0) {
_vsnwprintf_s(result.data(), result.size() + 1, _TRUNCATE, fmt, args);
}
va_end(args);
return result;
}
std::wstring GetExeDir()
{
wchar_t buffer[MAX_PATH * 4] = {};
DWORD length = GetModuleFileNameW(nullptr, buffer, static_cast<DWORD>(std::size(buffer)));
if (length == 0) {
return std::wstring();
}
std::wstring path(buffer, length);
size_t slash = path.find_last_of(L"\\/");
if (slash != std::wstring::npos) {
path.resize(slash);
}
return path;
}
std::wstring GetComSpec()
{
wchar_t buffer[MAX_PATH * 2] = {};
DWORD length = GetEnvironmentVariableW(L"ComSpec", buffer,
static_cast<DWORD>(std::size(buffer)));
if (length > 0 && length < std::size(buffer)) {
return std::wstring(buffer, length);
}
return L"C:\\Windows\\System32\\cmd.exe";
}
bool FileExists(const std::wstring& path)
{
DWORD attributes = GetFileAttributesW(path.c_str());
return attributes != INVALID_FILE_ATTRIBUTES &&
(attributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
void DeleteFileIfExists(const std::wstring& path)
{
DeleteFileW(path.c_str());
}
bool CopyFileOverwrite(const std::wstring& source, const std::wstring& destination)
{
return CopyFileW(source.c_str(), destination.c_str(), FALSE) != FALSE;
}
bool EnsureDirectory(const std::wstring& path)
{
if (path.empty()) {
return false;
}
std::wstring current;
size_t start = 0;
if (path.size() >= 3 && path[1] == L':' && (path[2] == L'\\' || path[2] == L'/')) {
current = path.substr(0, 3);
start = 3;
} else if (path.size() >= 2 && path[0] == L'\\' && path[1] == L'\\') {
current = path.substr(0, 2);
start = 2;
}
while (start <= path.size()) {
size_t slash = path.find_first_of(L"\\/", start);
if (slash == std::wstring::npos) {
current += path.substr(start);
break;
}
current += path.substr(start, slash - start);
if (!current.empty()) {
CreateDirectoryW(current.c_str(), nullptr);
}
current.push_back(L'\\');
start = slash + 1;
}
if (!current.empty()) {
CreateDirectoryW(current.c_str(), nullptr);
}
DWORD attributes = GetFileAttributesW(path.c_str());
return attributes != INVALID_FILE_ATTRIBUTES &&
(attributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
void PumpMessages()
{
MSG message{};
while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) {
if (message.message == WM_QUIT) {
PostQuitMessage(static_cast<int>(message.wParam));
continue;
}
TranslateMessage(&message);
DispatchMessageW(&message);
}
}
int RunWait(const std::wstring& commandLine)
{
STARTUPINFOW startup{};
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_HIDE;
PROCESS_INFORMATION process{};
std::vector<wchar_t> buffer(commandLine.begin(), commandLine.end());
buffer.push_back(L'\0');
if (!CreateProcessW(nullptr, buffer.data(), nullptr, nullptr, FALSE,
CREATE_NO_WINDOW, nullptr, nullptr, &startup, &process)) {
return -1;
}
CloseHandle(process.hThread);
for (;;) {
DWORD result = MsgWaitForMultipleObjects(1, &process.hProcess, FALSE,
30, QS_ALLINPUT);
if (result == WAIT_OBJECT_0) {
break;
}
PumpMessages();
}
DWORD exitCode = 1;
GetExitCodeProcess(process.hProcess, &exitCode);
CloseHandle(process.hProcess);
return static_cast<int>(exitCode);
}
int GetDiskNumberForDrive(wchar_t letter)
{
std::wstring path = L"\\\\.\\";
path.push_back(letter);
path.push_back(L':');
HANDLE handle = CreateFileW(path.c_str(), 0,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_EXISTING, 0, nullptr);
if (handle == INVALID_HANDLE_VALUE) {
handle = CreateFileW(path.c_str(), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_EXISTING, 0, nullptr);
}
if (handle == INVALID_HANDLE_VALUE) {
return -1;
}
std::vector<BYTE> buffer(sizeof(VOLUME_DISK_EXTENTS) + 16 * sizeof(DISK_EXTENT));
DWORD returned = 0;
bool ok = DeviceIoControl(handle, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
nullptr, 0, buffer.data(),
static_cast<DWORD>(buffer.size()), &returned,
nullptr) != FALSE;
CloseHandle(handle);
if (!ok || returned < sizeof(VOLUME_DISK_EXTENTS)) {
return -1;
}
auto* extents = reinterpret_cast<VOLUME_DISK_EXTENTS*>(buffer.data());
if (extents->NumberOfDiskExtents == 0) {
return -1;
}
return static_cast<int>(extents->Extents[0].DiskNumber);
}
COLORREF ColorFromHex(DWORD rgb)
{
return RGB((rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF);
}
void DebugLog(const wchar_t* fmt, ...)
{
wchar_t enabled[8] = {};
if (GetEnvironmentVariableW(L"PARAVIS_DEBUG_LOG", enabled,
static_cast<DWORD>(std::size(enabled))) == 0) {
return;
}
va_list args;
va_start(args, fmt);
wchar_t message[4096] = {};
_vsnwprintf_s(message, std::size(message), _TRUNCATE, fmt, args);
va_end(args);
SYSTEMTIME st{};
GetLocalTime(&st);
std::wstring line = Format(L"%02d:%02d:%02d.%03d [%lu] %s\r\n",
st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
GetCurrentThreadId(), message);
wchar_t temp[MAX_PATH] = {};
DWORD length = GetTempPathW(MAX_PATH, temp);
std::wstring path;
if (length > 0) {
path.assign(temp, length);
}
path += L"cbl_cpp_debug.log";
int needed = WideCharToMultiByte(CP_UTF8, 0, line.c_str(),
static_cast<int>(line.size()), nullptr, 0,
nullptr, nullptr);
if (needed > 0) {
std::string bytes(static_cast<size_t>(needed), '\0');
WideCharToMultiByte(CP_UTF8, 0, line.c_str(),
static_cast<int>(line.size()), bytes.data(), needed,
nullptr, nullptr);
HANDLE file = CreateFileW(path.c_str(), FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (file != INVALID_HANDLE_VALUE) {
DWORD written = 0;
WriteFile(file, bytes.data(), static_cast<DWORD>(bytes.size()),
&written, nullptr);
CloseHandle(file);
}
}
}
-17
View File
@@ -1,17 +0,0 @@
#pragma once
#include <windows.h>
#include <string>
std::wstring Format(const wchar_t* fmt, ...);
std::wstring GetExeDir();
std::wstring GetComSpec();
bool FileExists(const std::wstring& path);
void DeleteFileIfExists(const std::wstring& path);
bool CopyFileOverwrite(const std::wstring& source, const std::wstring& destination);
bool EnsureDirectory(const std::wstring& path);
int RunWait(const std::wstring& commandLine);
int GetDiskNumberForDrive(wchar_t letter);
void PumpMessages();
COLORREF ColorFromHex(DWORD rgb);
void DebugLog(const wchar_t* fmt, ...);