mirror of https://github.com/ventoy/Ventoy.git
1.0.09 beta1 release
This commit is contained in:
parent
d42bc35915
commit
3ca624f3ee
Binary file not shown.
|
@ -26,20 +26,29 @@ echo ''
|
|||
|
||||
vtdebug "############# Ventoy2Disk $0 ################"
|
||||
|
||||
if [ "$1" = "-i" ]; then
|
||||
MODE="install"
|
||||
elif [ "$1" = "-I" ]; then
|
||||
MODE="install"
|
||||
FORCE="Y"
|
||||
elif [ "$1" = "-u" ]; then
|
||||
MODE="update"
|
||||
else
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
while [ -n "$1" ]; do
|
||||
if [ "$1" = "-i" ]; then
|
||||
MODE="install"
|
||||
elif [ "$1" = "-I" ]; then
|
||||
MODE="install"
|
||||
FORCE="Y"
|
||||
elif [ "$1" = "-u" ]; then
|
||||
MODE="update"
|
||||
elif [ "$1" = "-s" ]; then
|
||||
SECUREBOOT="YES"
|
||||
else
|
||||
if ! [ -b "$1" ]; then
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
fi
|
||||
DISK=$1
|
||||
fi
|
||||
|
||||
if ! [ -b "$2" ]; then
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$MODE" ]; then
|
||||
print_usage
|
||||
cd $OLDDIR
|
||||
exit 1
|
||||
|
@ -85,8 +94,6 @@ if ! check_tool_work_ok; then
|
|||
fi
|
||||
|
||||
|
||||
DISK=$2
|
||||
|
||||
if ! [ -b "$DISK" ]; then
|
||||
vterr "Disk $DISK does not exist"
|
||||
cd $OLDDIR
|
||||
|
@ -101,7 +108,7 @@ if [ -e /sys/class/block/${DISK#/dev/}/start ]; then
|
|||
fi
|
||||
|
||||
grep "^$DISK" /proc/mounts | while read mtline; do
|
||||
mtpnt=$(echo $mtline | awk '{print $2}')
|
||||
mtpnt=$(echo $mtline | awk '{print $DISK}')
|
||||
vtdebug "Trying to umount $mtpnt ..."
|
||||
umount $mtpnt >/dev/null 2>&1
|
||||
done
|
||||
|
@ -204,6 +211,7 @@ if [ "$MODE" = "install" ]; then
|
|||
|
||||
chmod +x ./tool/vtoy_gen_uuid
|
||||
|
||||
vtinfo "writing data to disk ..."
|
||||
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=446
|
||||
./tool/xzcat ./boot/core.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=2047 seek=1
|
||||
./tool/xzcat ./ventoy/ventoy.disk.img.xz | dd status=none conv=fsync of=$DISK bs=512 count=$VENTOY_SECTOR_NUM seek=$part2_start_sector
|
||||
|
@ -214,8 +222,32 @@ if [ "$MODE" = "install" ]; then
|
|||
#disk signature
|
||||
./tool/vtoy_gen_uuid | dd status=none conv=fsync of=${DISK} skip=12 seek=440 bs=1 count=4
|
||||
|
||||
vtinfo "sync data ..."
|
||||
sync
|
||||
|
||||
vtinfo "esp partition processing ..."
|
||||
|
||||
if [ "$SECUREBOOT" != "YES" ]; then
|
||||
mkdir ./tmp_mnt
|
||||
|
||||
vtdebug "mounting part2 ...."
|
||||
for tt in 1 2 3; do
|
||||
if mount ${DISK}2 ./tmp_mnt; then
|
||||
vtdebug "mounting part2 success"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
umount ./tmp_mnt
|
||||
rm -rf ./tmp_mnt
|
||||
fi
|
||||
|
||||
echo ""
|
||||
vtinfo "Install Ventoy to $DISK successfully finished."
|
||||
echo ""
|
||||
|
@ -258,6 +290,27 @@ else
|
|||
|
||||
sync
|
||||
|
||||
if [ "$SECUREBOOT" != "YES" ]; then
|
||||
mkdir ./tmp_mnt
|
||||
|
||||
vtdebug "mounting part2 ...."
|
||||
for tt in 1 2 3; do
|
||||
if mount ${DISK}2 ./tmp_mnt; then
|
||||
vtdebug "mounting part2 success"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
rm -f ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
rm -f ./tmp_mnt/EFI/BOOT/grubx64.efi
|
||||
rm -f ./tmp_mnt/EFI/BOOT/MokManager.efi
|
||||
mv ./tmp_mnt/EFI/BOOT/grubx64_real.efi ./tmp_mnt/EFI/BOOT/BOOTX64.EFI
|
||||
|
||||
umount ./tmp_mnt
|
||||
rm -rf ./tmp_mnt
|
||||
fi
|
||||
|
||||
echo ""
|
||||
vtinfo "Update Ventoy to $DISK successfully finished."
|
||||
echo ""
|
||||
|
|
|
@ -52,8 +52,8 @@ const TCHAR * g_Str_ChineseSimple[STR_ID_MAX] =
|
|||
TEXT("提醒"),
|
||||
TEXT("请在正确的目录下运行!"),
|
||||
TEXT("设备"),
|
||||
TEXT("本地 Ventoy"),
|
||||
TEXT("设备上 Ventoy"),
|
||||
TEXT("安装包内 Ventoy 版本"),
|
||||
TEXT("设备内部 Ventoy 版本"),
|
||||
TEXT("状态 - 准备就绪"),
|
||||
TEXT("安装"),
|
||||
TEXT("升级"),
|
||||
|
@ -70,5 +70,5 @@ const TCHAR * g_Str_ChineseSimple[STR_ID_MAX] =
|
|||
|
||||
const TCHAR * GetString(enum STR_ID ID)
|
||||
{
|
||||
return g_Str_English[ID];
|
||||
return g_cur_lang_data->MsgString[ID];
|
||||
};
|
||||
|
|
|
@ -21,35 +21,64 @@
|
|||
#ifndef __LANGUAGE_H__
|
||||
#define __LANGUAGE_H__
|
||||
|
||||
|
||||
typedef enum STR_ID
|
||||
{
|
||||
STR_ERROR = 0,
|
||||
STR_WARNING,
|
||||
STR_INFO,
|
||||
STR_INCORRECT_DIR,
|
||||
STR_ERROR = 0,
|
||||
STR_WARNING, // 1
|
||||
STR_INFO, // 2
|
||||
STR_INCORRECT_DIR, //3
|
||||
STR_INCORRECT_TREE_DIR, //4
|
||||
|
||||
STR_DEVICE,
|
||||
STR_LOCAL_VER,
|
||||
STR_DISK_VER,
|
||||
STR_STATUS,
|
||||
STR_INSTALL,
|
||||
STR_UPDATE,
|
||||
STR_DEVICE, //5
|
||||
STR_LOCAL_VER, //6
|
||||
STR_DISK_VER, //7
|
||||
STR_STATUS, //8
|
||||
STR_INSTALL, //9
|
||||
STR_UPDATE, //10
|
||||
|
||||
STR_UPDATE_TIP,
|
||||
STR_INSTALL_TIP,
|
||||
STR_INSTALL_TIP2,
|
||||
STR_UPDATE_TIP, //11
|
||||
STR_INSTALL_TIP, //12
|
||||
STR_INSTALL_TIP2,//13
|
||||
|
||||
STR_INSTALL_SUCCESS,
|
||||
STR_INSTALL_FAILED,
|
||||
STR_UPDATE_SUCCESS,
|
||||
STR_UPDATE_FAILED,
|
||||
STR_INSTALL_SUCCESS,//14
|
||||
STR_INSTALL_FAILED,//15
|
||||
STR_UPDATE_SUCCESS,//16
|
||||
STR_UPDATE_FAILED,//17
|
||||
|
||||
STR_WAIT_PROCESS,
|
||||
STR_WAIT_PROCESS,//18
|
||||
|
||||
STR_MENU_OPTION,//19
|
||||
STR_MENU_SECURE_BOOT,//20
|
||||
|
||||
STR_ID_MAX
|
||||
STR_ID_MAX
|
||||
}STR_ID;
|
||||
|
||||
extern BOOL g_SecureBoot;
|
||||
|
||||
#define VTOY_MENU_SECURE_BOOT 0xA000
|
||||
#define VTOY_MENU_LANGUAGE_BEGIN 0xB000
|
||||
|
||||
|
||||
#define VENTOY_LANGUAGE_INI TEXT(".\\ventoy\\languages.ini")
|
||||
#define VENTOY_CFG_INI TEXT(".\\Ventoy2Disk.ini")
|
||||
#define VENTOY_MAX_LANGUAGE 200
|
||||
|
||||
#define GET_INI_STRING(Key, Buf) GetPrivateProfileString(Language, Key, TEXT("#"), Buf, sizeof(Buf), VENTOY_LANGUAGE_INI)
|
||||
|
||||
typedef struct VENTOY_LANGUAGE
|
||||
{
|
||||
WCHAR Name[64];
|
||||
WCHAR FontFamily[64];
|
||||
int FontSize;
|
||||
|
||||
WCHAR StrId[STR_ID_MAX][64];
|
||||
WCHAR MsgString[STR_ID_MAX][1024];
|
||||
|
||||
}VENTOY_LANGUAGE;
|
||||
|
||||
extern VENTOY_LANGUAGE *g_cur_lang_data;
|
||||
|
||||
const TCHAR * GetString(enum STR_ID ID);
|
||||
|
||||
#define _G(a) GetString(a)
|
||||
|
|
|
@ -824,10 +824,128 @@ int GetVentoyVerInPhyDrive(const PHY_DRIVE_INFO *pDriveInfo, CHAR *VerBuf, size_
|
|||
|
||||
|
||||
|
||||
|
||||
static unsigned int g_disk_unxz_len = 0;
|
||||
static BYTE *g_part_img_pos = NULL;
|
||||
static BYTE *g_part_img_buf[VENTOY_EFI_PART_SIZE / SIZE_1MB];
|
||||
|
||||
|
||||
static int VentoyFatMemRead(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 offset;
|
||||
BYTE *MbBuf = NULL;
|
||||
|
||||
for (i = 0; i < SectorCount; i++)
|
||||
{
|
||||
offset = (Sector + i) * 512;
|
||||
|
||||
if (g_part_img_buf[1] == NULL)
|
||||
{
|
||||
MbBuf = g_part_img_buf[0] + offset;
|
||||
memcpy(Buffer + i * 512, MbBuf, 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||
memcpy(Buffer + i * 512, MbBuf + (offset % SIZE_1MB), 512);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int VentoyFatMemWrite(uint32 Sector, uint8 *Buffer, uint32 SectorCount)
|
||||
{
|
||||
uint32 i;
|
||||
uint32 offset;
|
||||
BYTE *MbBuf = NULL;
|
||||
|
||||
for (i = 0; i < SectorCount; i++)
|
||||
{
|
||||
offset = (Sector + i) * 512;
|
||||
|
||||
if (g_part_img_buf[1] == NULL)
|
||||
{
|
||||
MbBuf = g_part_img_buf[0] + offset;
|
||||
memcpy(MbBuf, Buffer + i * 512, 512);
|
||||
}
|
||||
else
|
||||
{
|
||||
MbBuf = g_part_img_buf[offset / SIZE_1MB];
|
||||
memcpy(MbBuf + (offset % SIZE_1MB), Buffer + i * 512, 512);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int VentoyProcSecureBoot(BOOL SecureBoot)
|
||||
{
|
||||
int rc = 0;
|
||||
int size;
|
||||
char *filebuf = NULL;
|
||||
void *file = NULL;
|
||||
|
||||
Log("VentoyProcSecureBoot %d ...", SecureBoot);
|
||||
|
||||
if (SecureBoot)
|
||||
{
|
||||
Log("Secure boot is enabled ...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
fl_init();
|
||||
|
||||
if (0 == fl_attach_media(VentoyFatMemRead, VentoyFatMemWrite))
|
||||
{
|
||||
file = fl_fopen("/EFI/BOOT/grubx64_real.efi", "rb");
|
||||
Log("Open ventoy efi file %p ", file);
|
||||
if (file)
|
||||
{
|
||||
fl_fseek(file, 0, SEEK_END);
|
||||
size = (int)fl_ftell(file);
|
||||
fl_fseek(file, 0, SEEK_SET);
|
||||
|
||||
Log("ventoy efi file size %d ...", size);
|
||||
|
||||
filebuf = (char *)malloc(size);
|
||||
if (filebuf)
|
||||
{
|
||||
fl_fread(filebuf, 1, size, file);
|
||||
}
|
||||
|
||||
fl_fclose(file);
|
||||
|
||||
Log("Now delete all efi files ...");
|
||||
fl_remove("/EFI/BOOT/BOOTX64.EFI");
|
||||
fl_remove("/EFI/BOOT/grubx64.efi");
|
||||
fl_remove("/EFI/BOOT/grubx64_real.efi");
|
||||
fl_remove("/EFI/BOOT/MokManager.efi");
|
||||
|
||||
file = fl_fopen("/EFI/BOOT/BOOTX64.EFI", "wb");
|
||||
Log("Open bootx64 efi file %p ", file);
|
||||
if (file)
|
||||
{
|
||||
fl_fwrite(filebuf, 1, size, file);
|
||||
fl_fflush(file);
|
||||
fl_fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
fl_shutdown();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int disk_xz_flush(void *src, unsigned int size)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -919,6 +1037,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
|||
if (len == writelen)
|
||||
{
|
||||
Log("decompress finished success");
|
||||
|
||||
VentoyProcSecureBoot(g_SecureBoot);
|
||||
|
||||
for (i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||
{
|
||||
dwSize = 0;
|
||||
|
@ -965,6 +1086,9 @@ static int FormatPart2Fat(HANDLE hDrive, UINT64 StartSectorId)
|
|||
if (g_disk_unxz_len == VENTOY_EFI_PART_SIZE)
|
||||
{
|
||||
Log("decompress finished success");
|
||||
|
||||
VentoyProcSecureBoot(g_SecureBoot);
|
||||
|
||||
for (int i = 0; i < VENTOY_EFI_PART_SIZE / SIZE_1MB; i++)
|
||||
{
|
||||
dwSize = 0;
|
||||
|
|
Binary file not shown.
|
@ -26,17 +26,55 @@
|
|||
|
||||
HINSTANCE g_hInst;
|
||||
|
||||
|
||||
BOOL g_SecureBoot = FALSE;
|
||||
HWND g_DialogHwnd;
|
||||
HWND g_ComboxHwnd;
|
||||
HWND g_StaticLocalVerHwnd;
|
||||
HWND g_StaticDiskVerHwnd;
|
||||
HWND g_BtnInstallHwnd;
|
||||
HWND g_StaticDevHwnd;
|
||||
HWND g_StaticLocalHwnd;
|
||||
HWND g_StaticDiskHwnd;
|
||||
HWND g_BtnUpdateHwnd;
|
||||
HWND g_ProgressBarHwnd;
|
||||
HWND g_StaticStatusHwnd;
|
||||
CHAR g_CurVersion[64];
|
||||
HANDLE g_ThreadHandle = NULL;
|
||||
|
||||
int g_language_count = 0;
|
||||
int g_cur_lang_id = 0;
|
||||
VENTOY_LANGUAGE *g_language_data = NULL;
|
||||
VENTOY_LANGUAGE *g_cur_lang_data = NULL;
|
||||
|
||||
static int LoadCfgIni(void)
|
||||
{
|
||||
int value;
|
||||
|
||||
value = GetPrivateProfileInt(TEXT("Ventoy"), TEXT("SecureBoot"), 0, VENTOY_CFG_INI);
|
||||
|
||||
if (value == 1)
|
||||
{
|
||||
g_SecureBoot = TRUE;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WriteCfgIni(void)
|
||||
{
|
||||
WCHAR TmpBuf[128];
|
||||
|
||||
swprintf_s(TmpBuf, 128, TEXT("%d"), g_cur_lang_id);
|
||||
WritePrivateProfileString(TEXT("Ventoy"), TEXT("Language"), TmpBuf, VENTOY_CFG_INI);
|
||||
|
||||
swprintf_s(TmpBuf, 128, TEXT("%d"), g_SecureBoot);
|
||||
WritePrivateProfileString(TEXT("Ventoy"), TEXT("SecureBoot"), TmpBuf, VENTOY_CFG_INI);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GetExeVersionInfo(const char *FilePath)
|
||||
{
|
||||
UINT length;
|
||||
|
@ -124,15 +162,126 @@ static void OnComboxSelChange(HWND hCombox)
|
|||
UpdateWindow(g_DialogHwnd);
|
||||
}
|
||||
|
||||
static void UpdateItemString(int defaultLangId)
|
||||
{
|
||||
int i;
|
||||
HMENU SubMenu;
|
||||
HFONT hLangFont;
|
||||
HMENU hMenu = GetMenu(g_DialogHwnd);
|
||||
|
||||
g_cur_lang_id = defaultLangId;
|
||||
g_cur_lang_data = g_language_data + defaultLangId;
|
||||
|
||||
|
||||
|
||||
hLangFont = CreateFont(g_language_data[defaultLangId].FontSize, 0, 0, 0, 400, FALSE, FALSE, 0,
|
||||
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH, g_language_data[defaultLangId].FontFamily);
|
||||
|
||||
SendMessage(g_BtnInstallHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_BtnUpdateHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_StaticStatusHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_StaticLocalHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_StaticDiskHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_StaticDevHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
SendMessage(g_DialogHwnd, WM_SETFONT, (WPARAM)hLangFont, TRUE);
|
||||
|
||||
ModifyMenu(hMenu, 0, MF_BYPOSITION | MF_STRING, 0, _G(STR_MENU_OPTION));
|
||||
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DEV), _G(STR_DEVICE));
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_LOCAL), _G(STR_LOCAL_VER));
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DISK), _G(STR_DISK_VER));
|
||||
SetWindowText(g_StaticStatusHwnd, _G(STR_STATUS));
|
||||
|
||||
SetWindowText(g_BtnInstallHwnd, _G(STR_INSTALL));
|
||||
SetWindowText(g_BtnUpdateHwnd, _G(STR_UPDATE));
|
||||
|
||||
SubMenu = GetSubMenu(hMenu, 0);
|
||||
if (g_SecureBoot)
|
||||
{
|
||||
ModifyMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING | MF_CHECKED, 0, _G(STR_MENU_SECURE_BOOT));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModifyMenu(SubMenu, 0, MF_BYPOSITION | MF_STRING | MF_UNCHECKED, 0, _G(STR_MENU_SECURE_BOOT));
|
||||
}
|
||||
|
||||
ShowWindow(g_DialogHwnd, SW_HIDE);
|
||||
ShowWindow(g_DialogHwnd, SW_NORMAL);
|
||||
|
||||
//Update check
|
||||
for (i = 0; i < g_language_count; i++)
|
||||
{
|
||||
CheckMenuItem(hMenu, VTOY_MENU_LANGUAGE_BEGIN | i, MF_BYCOMMAND | MF_STRING | MF_UNCHECKED);
|
||||
}
|
||||
CheckMenuItem(hMenu, VTOY_MENU_LANGUAGE_BEGIN | defaultLangId, MF_BYCOMMAND | MF_STRING | MF_CHECKED);
|
||||
}
|
||||
|
||||
static void LanguageInit(void)
|
||||
{
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DEV), _G(STR_DEVICE));
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_LOCAL), _G(STR_LOCAL_VER));
|
||||
SetWindowText(GetDlgItem(g_DialogHwnd, IDC_STATIC_DISK), _G(STR_DISK_VER));
|
||||
SetWindowText(g_StaticStatusHwnd, _G(STR_STATUS));
|
||||
int i, j, k;
|
||||
int id, DefaultId;
|
||||
WCHAR Language[64];
|
||||
WCHAR TmpBuf[256];
|
||||
LANGID LangId = GetSystemDefaultUILanguage();
|
||||
HMENU SubMenu;
|
||||
HMENU hMenu = GetMenu(g_DialogHwnd);
|
||||
|
||||
SetWindowText(g_BtnInstallHwnd, _G(STR_INSTALL));
|
||||
SetWindowText(g_BtnUpdateHwnd, _G(STR_UPDATE));
|
||||
SubMenu = GetSubMenu(hMenu, 1);
|
||||
DeleteMenu(SubMenu, 0, MF_BYPOSITION);
|
||||
|
||||
g_language_data = (VENTOY_LANGUAGE *)malloc(sizeof(VENTOY_LANGUAGE)* VENTOY_MAX_LANGUAGE);
|
||||
memset(g_language_data, 0, sizeof(VENTOY_LANGUAGE)* VENTOY_MAX_LANGUAGE);
|
||||
|
||||
swprintf_s(Language, 64, L"StringDefine");
|
||||
for (i = 0; i < STR_ID_MAX; i++)
|
||||
{
|
||||
swprintf_s(TmpBuf, 256, L"%d", i);
|
||||
GET_INI_STRING(TmpBuf, g_language_data[0].StrId[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < VENTOY_MAX_LANGUAGE; i++)
|
||||
{
|
||||
swprintf_s(Language, 64, L"Language%d", i);
|
||||
GET_INI_STRING(TEXT("name"), g_language_data[i].Name);
|
||||
|
||||
if (g_language_data[i].Name[0] == '#')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
g_language_count++;
|
||||
Log("Find Language%d ...", i);
|
||||
|
||||
AppendMenu(SubMenu, MF_STRING | MF_BYCOMMAND, VTOY_MENU_LANGUAGE_BEGIN | i, g_language_data[i].Name);
|
||||
|
||||
GET_INI_STRING(TEXT("FontFamily"), g_language_data[i].FontFamily);
|
||||
g_language_data[i].FontSize = GetPrivateProfileInt(Language, TEXT("FontSize"), 10, VENTOY_LANGUAGE_INI);
|
||||
|
||||
for (j = 0; j < STR_ID_MAX; j++)
|
||||
{
|
||||
GET_INI_STRING(g_language_data[0].StrId[j], g_language_data[i].MsgString[j]);
|
||||
|
||||
for (k = 0; g_language_data[i].MsgString[j][k] && g_language_data[i].MsgString[j][k + 1]; k++)
|
||||
{
|
||||
if (g_language_data[i].MsgString[j][k] == '#' && g_language_data[i].MsgString[j][k + 1] == '@')
|
||||
{
|
||||
g_language_data[i].MsgString[j][k] = '\r';
|
||||
g_language_data[i].MsgString[j][k + 1] = '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DefaultId = (MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) == LangId) ? 0 : 1;
|
||||
id = GetPrivateProfileInt(TEXT("Ventoy"), TEXT("Language"), DefaultId, VENTOY_CFG_INI);
|
||||
if (id >= i)
|
||||
{
|
||||
id = DefaultId;
|
||||
}
|
||||
|
||||
UpdateItemString(id);
|
||||
}
|
||||
|
||||
static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
@ -149,6 +298,13 @@ static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||
g_StaticLocalVerHwnd = GetDlgItem(hWnd, IDC_STATIC_LOCAL_VER);
|
||||
g_StaticDiskVerHwnd = GetDlgItem(hWnd, IDC_STATIC_DISK_VER);
|
||||
g_BtnInstallHwnd = GetDlgItem(hWnd, IDC_BUTTON4);
|
||||
|
||||
|
||||
g_StaticDevHwnd = GetDlgItem(hWnd, IDC_STATIC_DEV);
|
||||
g_StaticLocalHwnd = GetDlgItem(hWnd, IDC_STATIC_LOCAL);
|
||||
g_StaticDiskHwnd = GetDlgItem(hWnd, IDC_STATIC_DISK);
|
||||
|
||||
|
||||
g_BtnUpdateHwnd = GetDlgItem(hWnd, IDC_BUTTON3);
|
||||
g_ProgressBarHwnd = GetDlgItem(hWnd, IDC_PROGRESS1);
|
||||
g_StaticStatusHwnd = GetDlgItem(hWnd, IDC_STATIC_STATUS);
|
||||
|
@ -160,8 +316,12 @@ static BOOL InitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
|||
SendMessage(g_ProgressBarHwnd, PBM_SETRANGE, (WPARAM)0, (LPARAM)(MAKELPARAM(0, PT_FINISH)));
|
||||
PROGRESS_BAR_SET_POS(PT_START);
|
||||
|
||||
SetMenu(hWnd, LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1)));
|
||||
|
||||
LoadCfgIni();
|
||||
LanguageInit();
|
||||
|
||||
|
||||
// Fill device combox
|
||||
hCombox = GetDlgItem(hWnd, IDC_COMBO1);
|
||||
for (i = 0; i < g_PhyDriveCount; i++)
|
||||
|
@ -358,6 +518,31 @@ static void OnUpdateBtnClick(void)
|
|||
g_ThreadHandle = CreateThread(NULL, 0, UpdateVentoyThread, (LPVOID)pPhyDrive, 0, NULL);
|
||||
}
|
||||
|
||||
static void MenuProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WORD CtrlID;
|
||||
HMENU hMenu = GetMenu(hWnd);
|
||||
|
||||
CtrlID = LOWORD(wParam);
|
||||
|
||||
if (CtrlID == 0)
|
||||
{
|
||||
g_SecureBoot = !g_SecureBoot;
|
||||
|
||||
if (g_SecureBoot)
|
||||
{
|
||||
CheckMenuItem(hMenu, 0, MF_BYCOMMAND | MF_STRING | MF_CHECKED);
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckMenuItem(hMenu, 0, MF_BYCOMMAND | MF_STRING | MF_UNCHECKED);
|
||||
}
|
||||
}
|
||||
else if (CtrlID >= VTOY_MENU_LANGUAGE_BEGIN && CtrlID < VTOY_MENU_LANGUAGE_BEGIN + g_language_count)
|
||||
{
|
||||
UpdateItemString(CtrlID - VTOY_MENU_LANGUAGE_BEGIN);
|
||||
}
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
@ -385,6 +570,10 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||
OnUpdateBtnClick();
|
||||
}
|
||||
|
||||
if (lParam == 0 && NotifyCode == 0)
|
||||
{
|
||||
MenuProc(hWnd, wParam, lParam);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -417,6 +606,7 @@ INT_PTR CALLBACK DialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lPara
|
|||
{
|
||||
EndDialog(hWnd, 0);
|
||||
}
|
||||
WriteCfgIni();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +620,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
|
||||
if (!IsFileExist(VENTOY_FILE_VERSION))
|
||||
{
|
||||
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
||||
if (IsDirExist("grub"))
|
||||
{
|
||||
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(NULL, _G(STR_INCORRECT_DIR), _G(STR_ERROR), MB_OK | MB_ICONERROR);
|
||||
}
|
||||
return ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -444,6 +641,8 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
|
||||
Ventoy2DiskInit();
|
||||
|
||||
|
||||
|
||||
g_hInst = hInstance;
|
||||
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue