Compare commits

..

9 Commits

Author SHA1 Message Date
longpanda
8b975b5e80 1.0.49 release 2021-08-03 17:31:39 +08:00
MELERIX
2ab717cc66 Updated Spanish Translation (#1039) 2021-08-03 14:53:57 +08:00
longpanda
88793d548a Compatibility improvement for some WinPE 2021-08-03 14:53:29 +08:00
longpanda
5fea6eab7e Add Bulgarian language 2021-08-03 10:05:01 +08:00
Ida Bagus
5d55dc68ae Indonesian update (#1038) 2021-08-03 08:58:17 +08:00
VlatkoS
2c320aad60 Updated Macedonian language (#1037)
Updated Macedonian language
2021-08-03 08:57:54 +08:00
Hoàng Điềm Tĩnh
b63034b2c7 Update languages.json (#1036) 2021-08-03 08:57:43 +08:00
longpanda
6c113880e5 Fixed the boot issue for "StorageCraft Recovery Environment CrossPlatform" in UEFI mode. 2021-08-02 22:50:38 +08:00
longpanda
e2656c287b Compatibility improvement for some WinPE 2021-08-02 21:03:43 +08:00
11 changed files with 345 additions and 204 deletions

View File

@@ -69,6 +69,9 @@
#define VTOY_ARCH_CPIO "ventoy_x86.cpio" #define VTOY_ARCH_CPIO "ventoy_x86.cpio"
#endif #endif
#define ventoy_varg_4(arg) arg[0], arg[1], arg[2], arg[3]
#define ventoy_varg_8(arg) arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]
#define VTOY_PWD_CORRUPTED(err) \ #define VTOY_PWD_CORRUPTED(err) \
{\ {\
grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \ grub_printf("\n\n Password corrupted, will reboot after 5 seconds.\n\n"); \

View File

@@ -333,7 +333,9 @@ end:
static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName) static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
{ {
int i = 0; int i = 0;
int len = 0;
int dollar = 0; int dollar = 0;
int quotation = 0;
grub_file_t file = NULL; grub_file_t file = NULL;
char *buf = NULL; char *buf = NULL;
char *start = NULL; char *start = NULL;
@@ -382,6 +384,12 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
start++; start++;
} }
if (*start == '"')
{
quotation = 1;
start++;
}
while (*start) while (*start)
{ {
img = grub_zalloc(sizeof(initrd_info)); img = grub_zalloc(sizeof(initrd_info));
@@ -400,6 +408,16 @@ static grub_err_t ventoy_grub_cfg_initrd_collect(const char *fileName)
} }
} }
if (quotation)
{
len = (int)grub_strlen(img->name);
if (len > 2 && img->name[len - 1] == '"')
{
img->name[len - 1] = 0;
}
debug("Remove quotation <%s>\n", img->name);
}
if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name)) if (dollar == 1 || ventoy_find_initrd_by_name(g_initrd_img_list, img->name))
{ {
grub_free(img); grub_free(img);

View File

@@ -660,30 +660,22 @@ static wim_directory_entry * search_full_wim_dirent
static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir) static wim_directory_entry * search_replace_wim_dirent(void *meta_data, wim_directory_entry *dir)
{ {
wim_directory_entry *wim_dirent1 = NULL; wim_directory_entry *wim_dirent = NULL;
wim_directory_entry *wim_dirent2 = NULL;
const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL }; const char *pecmd_path[] = { "Windows", "System32", "pecmd.exe", NULL };
const char *wpeinit_path[] = { "Windows", "System32", "wpeinit.exe", NULL };
const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL }; const char *winpeshl_path[] = { "Windows", "System32", "winpeshl.exe", NULL };
wim_dirent1 = search_full_wim_dirent(meta_data, dir, pecmd_path); wim_dirent = search_full_wim_dirent(meta_data, dir, pecmd_path);
debug("search pecmd.exe %p\n", wim_dirent1); debug("search pecmd.exe %p\n", wim_dirent);
if (wim_dirent1) if (wim_dirent)
{ {
wim_dirent2 = search_full_wim_dirent(meta_data, dir, wpeinit_path); return wim_dirent;
debug("search wpeinit.exe %p\n", wim_dirent1);
if (wim_dirent2)
{
return wim_dirent2;
}
return wim_dirent1;
} }
wim_dirent1 = search_full_wim_dirent(meta_data, dir, winpeshl_path); wim_dirent = search_full_wim_dirent(meta_data, dir, winpeshl_path);
debug("search winpeshl.exe %p\n", wim_dirent1); debug("search winpeshl.exe %p\n", wim_dirent);
if (wim_dirent1) if (wim_dirent)
{ {
return wim_dirent1; return wim_dirent;
} }
return NULL; return NULL;
@@ -745,6 +737,27 @@ static grub_uint64_t ventoy_get_stream_len(wim_directory_entry *dir)
return offset; return offset;
} }
static int ventoy_update_stream_hash(wim_patch *patch, wim_directory_entry *dir)
{
grub_uint16_t i;
grub_uint64_t offset = 0;
wim_stream_entry *stream = (wim_stream_entry *)((char *)dir + dir->len);
for (i = 0; i < dir->streams; i++)
{
if (grub_memcmp(stream->hash.sha1, patch->old_hash.sha1, sizeof(wim_hash)) == 0)
{
debug("find target stream %u, name_len:%u upadte hash\n", i, stream->name_len);
grub_memcpy(stream->hash.sha1, &(patch->wim_data.bin_hash), sizeof(wim_hash));
}
offset += stream->len;
stream = (wim_stream_entry *)((char *)stream + stream->len);
}
return offset;
}
static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directory_entry *dir) static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directory_entry *dir)
{ {
if ((meta_data == NULL) || (dir == NULL)) if ((meta_data == NULL) || (dir == NULL))
@@ -772,6 +785,7 @@ static int ventoy_update_all_hash(wim_patch *patch, void *meta_data, wim_directo
if (dir->streams) if (dir->streams)
{ {
ventoy_update_stream_hash(patch, dir);
dir = (wim_directory_entry *)((char *)dir + dir->len + ventoy_get_stream_len(dir)); dir = (wim_directory_entry *)((char *)dir + dir->len + ventoy_get_stream_len(dir));
} }
else else
@@ -932,6 +946,7 @@ static int ventoy_update_before_chain(ventoy_os_param *param, char *isopath)
static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch) static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
{ {
int rc; int rc;
grub_uint16_t i;
grub_file_t file; grub_file_t file;
grub_uint32_t exe_len; grub_uint32_t exe_len;
grub_uint8_t *exe_data = NULL; grub_uint8_t *exe_data = NULL;
@@ -940,6 +955,7 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
wim_security_header *security = NULL; wim_security_header *security = NULL;
wim_directory_entry *rootdir = NULL; wim_directory_entry *rootdir = NULL;
wim_directory_entry *search = NULL; wim_directory_entry *search = NULL;
wim_stream_entry *stream = NULL;
wim_header *head = &(patch->wim_data.wim_header); wim_header *head = &(patch->wim_data.wim_header);
wim_tail *wim_data = &patch->wim_data; wim_tail *wim_data = &patch->wim_data;
@@ -1003,7 +1019,27 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
debug("find replace file at %p\n", search); debug("find replace file at %p\n", search);
grub_memcpy(&patch->old_hash, search->hash.sha1, sizeof(wim_hash)); grub_memset(&patch->old_hash, 0, sizeof(wim_hash));
if (grub_memcmp(&patch->old_hash, search->hash.sha1, sizeof(wim_hash)) == 0)
{
debug("search hash all 0, now do deep search\n");
stream = (wim_stream_entry *)((char *)search + search->len);
for (i = 0; i < search->streams; i++)
{
if (stream->name_len == 0)
{
grub_memcpy(&patch->old_hash, stream->hash.sha1, sizeof(wim_hash));
debug("new search hash: %02x %02x %02x %02x %02x %02x %02x %02x\n",
ventoy_varg_8(patch->old_hash.sha1));
break;
}
stream = (wim_stream_entry *)((char *)stream + stream->len);
}
}
else
{
grub_memcpy(&patch->old_hash, search->hash.sha1, sizeof(wim_hash));
}
debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size); debug("read lookup offset:%llu size:%llu\n", (ulonglong)head->lookup.offset, (ulonglong)head->lookup.raw_size);
lookup = grub_malloc(head->lookup.raw_size); lookup = grub_malloc(head->lookup.raw_size);
@@ -1030,8 +1066,8 @@ static int ventoy_wimdows_locate_wim(const char *disk, wim_patch *patch)
} }
else else
{ {
debug("failed to find lookup entry for replace file 0x%02x 0x%02x\n", debug("failed to find lookup entry for replace file %02x %02x %02x %02x\n",
patch->old_hash.sha1[0], patch->old_hash.sha1[1]); ventoy_varg_4(patch->old_hash.sha1));
} }
wim_data->wim_raw_size = (grub_uint32_t)file->size; wim_data->wim_raw_size = (grub_uint32_t)file->size;

View File

@@ -0,0 +1,38 @@
#!/ventoy/busybox/sh
#************************************************************************************
# Copyright (c) 2020, longpanda <admin@ventoy.net>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#************************************************************************************
. /ventoy/hook/ventoy-hook-lib.sh
wait_for_usb_disk_ready
vtdiskname=$(get_ventoy_disk_name)
if [ "$vtdiskname" = "unknown" ]; then
vtlog "ventoy disk not found"
exit 0
fi
vtlog "wait_for_usb_disk_ready $vtdiskname ..."
if echo $vtdiskname | $EGREP -q "nvme|mmc|nbd"; then
vtpart2=${vtdiskname}p2
else
vtpart2=${vtdiskname}2
fi
/ventoy/busybox/sh /ventoy/hook/suse/udev_disk_hook.sh "${vtpart2#/dev/}"

View File

@@ -63,6 +63,9 @@ if [ -e /etc/initrd.functions ] && $GREP -q 'HPIP' /etc/initrd.functions; then
$BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1 $BUSYBOX_PATH/mknod -m 660 /dev/console b 5 1
$SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions $SED "/CD_DEVICES=/a $BUSYBOX_PATH/sh $VTOY_PATH/hook/suse/disk_hook.sh" -i /etc/initrd.functions
$SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions $SED "/CD_DEVICES=/a CD_DEVICES=\"/dev/ventoy \$CD_DEVICES\"" -i /etc/initrd.functions
elif [ -f /scripts/udev_setup ]; then
echo "udev_setup" >> $VTLOG
echo "/ventoy/busybox/sh /ventoy/hook/suse/udev_setup_hook.sh" >> /scripts/udev_setup
else else
echo "SUSE" >> $VTLOG echo "SUSE" >> $VTLOG
ventoy_systemd_udevd_work_around ventoy_systemd_udevd_work_around

View File

@@ -45,6 +45,7 @@ if [ ! -f ./boot/boot.img ]; then
if [ -d ./grub ]; then if [ -d ./grub ]; then
echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it." echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it."
else else
echo "Current directory is $PWD"
echo "Please run under the correct directory!" echo "Please run under the correct directory!"
fi fi
exit 1 exit 1

View File

@@ -921,7 +921,7 @@ function legacy_windows_menu_func {
loopback loop "$1$2" loopback loop "$1$2"
fi fi
for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD"; do for file in "boot/bcd" "/efi/microsoft/boot/bcd" "SSTR/BCD" "boot/bce"; do
vt_windows_collect_wim_patch bcd (loop)/$file vt_windows_collect_wim_patch bcd (loop)/$file
done done
@@ -1844,7 +1844,7 @@ function img_unsupport_menuentry {
############################################################# #############################################################
############################################################# #############################################################
set VENTOY_VERSION="1.0.48" set VENTOY_VERSION="1.0.49"
#ACPI not compatible with Window7/8, so disable by default #ACPI not compatible with Window7/8, so disable by default
set VTOY_PARAM_NO_ACPI=1 set VTOY_PARAM_NO_ACPI=1

Binary file not shown.

Binary file not shown.

View File

@@ -639,7 +639,7 @@
"STR_MENU_OPTION":"Opción", "STR_MENU_OPTION":"Opción",
"STR_MENU_SECURE_BOOT":"Soporte De Arranque Seguro", "STR_MENU_SECURE_BOOT":"Soporte De Arranque Seguro",
"STR_MENU_PART_CFG":"Configuración De Partición", "STR_MENU_PART_CFG":"Configuración De Partición",
"STR_BTN_OK":"ACEPTAR", "STR_BTN_OK":"Aceptar",
"STR_BTN_CANCEL":"Cancelar", "STR_BTN_CANCEL":"Cancelar",
"STR_PRESERVE_SPACE":"Preservar algo de espacio al final del dispositivo", "STR_PRESERVE_SPACE":"Preservar algo de espacio al final del dispositivo",
"STR_SPACE_VAL_INVALID":"Valor inválido para espacio reservado", "STR_SPACE_VAL_INVALID":"Valor inválido para espacio reservado",
@@ -656,10 +656,10 @@
"STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicación: Servicio No Disponible", "STR_WEB_SERVICE_UNAVAILABLE":"Error de comunicación: Servicio No Disponible",
"STR_WEB_TOKEN_MISMATCH":" Estado del daemon actualizado, por favor reintenta más tarde.", "STR_WEB_TOKEN_MISMATCH":" Estado del daemon actualizado, por favor reintenta más tarde.",
"STR_WEB_SERVICE_BUSY":" El servicio está ocupado, por favor reintenta más tarde.", "STR_WEB_SERVICE_BUSY":" El servicio está ocupado, por favor reintenta más tarde.",
"STR_MENU_VTSI_CREATE":"Generate VTSI File", "STR_MENU_VTSI_CREATE":"Generar Archivo VTSI",
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?", "STR_VTSI_CREATE_TIP":"Esta vez no se escribirá al dispositivo, pero solo generará un archivo VTSI#@¿Continuar?",
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15Beta+) to write it to the device so as to complete the installation of Ventoy.", "STR_VTSI_CREATE_SUCCESS":"¡Archivo VTSI creado exitosamente!#@Puedes usar Rufus(3.15Beta+) para escribirlo al dispositivo a fin de completar la instalación de Ventoy.",
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.", "STR_VTSI_CREATE_FAILED":"Fallo en el archivo VTSI creado.",
"STRXXX":"" "STRXXX":""
}, },
{ {
@@ -1423,7 +1423,7 @@
"STR_WEB_SERVICE_BUSY":"Dịch vụ bận, vui lòng thử lại sau.", "STR_WEB_SERVICE_BUSY":"Dịch vụ bận, vui lòng thử lại sau.",
"STR_MENU_VTSI_CREATE":"Tạo tệp VTSI", "STR_MENU_VTSI_CREATE":"Tạo tệp VTSI",
"STR_VTSI_CREATE_TIP":"Lần này sẽ không ghi vào thiết bị, chỉ tạo một tệp VTSI#@Bạn muốn tiếp tục?", "STR_VTSI_CREATE_TIP":"Lần này sẽ không ghi vào thiết bị, chỉ tạo một tệp VTSI#@Bạn muốn tiếp tục?",
"STR_VTSI_CREATE_SUCCESS":"Tạo tệp VTSI thành công!#@Để hoàn thành cài đặt Ventoy, bạn có thể dùng Rufus(3.15Beta+) để khi tệp này vào thiết bị.", "STR_VTSI_CREATE_SUCCESS":"Tạo tệp VTSI thành công!#@Để hoàn thành cài đặt Ventoy, bạn có thể dùng Rufus (3.15 Beta+) để ghi tệp này vào thiết bị.",
"STR_VTSI_CREATE_FAILED":"Tạo tệp VTSI đã gặp lỗi.", "STR_VTSI_CREATE_FAILED":"Tạo tệp VTSI đã gặp lỗi.",
"STRXXX":"" "STRXXX":""
}, },
@@ -1523,10 +1523,10 @@
"STR_WEB_SERVICE_UNAVAILABLE":"Комуникациска грешка: Недостапен сервис", "STR_WEB_SERVICE_UNAVAILABLE":"Комуникациска грешка: Недостапен сервис",
"STR_WEB_TOKEN_MISMATCH":"Ажуриран статус на даемонот, молиме обидете се подоцна.", "STR_WEB_TOKEN_MISMATCH":"Ажуриран статус на даемонот, молиме обидете се подоцна.",
"STR_WEB_SERVICE_BUSY":"Сервисот е зафатен, молиме обидете се подоцна.", "STR_WEB_SERVICE_BUSY":"Сервисот е зафатен, молиме обидете се подоцна.",
"STR_MENU_VTSI_CREATE":"Generate VTSI File", "STR_MENU_VTSI_CREATE":"Генерирај VTSI датотека",
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?", "STR_VTSI_CREATE_TIP":"Овој пат ништо нема да се запише на уредот туку само ќе се генерира VTSI датотека#@Продолжи?",
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15Beta+) to write it to the device so as to complete the installation of Ventoy.", "STR_VTSI_CREATE_SUCCESS":"Успешно креирана VTSI датотека!#@Можете да го користите Rufus(3.15Beta+) за да ја запишете на уредот како и да ја комплетирате инсталацијата на Ventoy.",
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.", "STR_VTSI_CREATE_FAILED":"Креирањето на VTSI датотека е неуспешно.",
"STRXXX":"" "STRXXX":""
}, },
{ {
@@ -1669,17 +1669,17 @@
"STR_MENU_PART_STYLE":"Gaya Partisi", "STR_MENU_PART_STYLE":"Gaya Partisi",
"STR_DISK_2TB_MBR_ERROR":"Silakan pilih GPT untuk disk yang lebih dari 2TB", "STR_DISK_2TB_MBR_ERROR":"Silakan pilih GPT untuk disk yang lebih dari 2TB",
"STR_SHOW_ALL_DEV":"Show All Devices", "STR_SHOW_ALL_DEV":"Show All Devices",
"STR_PART_ALIGN_4KB":"Align partitions with 4KB", "STR_PART_ALIGN_4KB":"Meluruskan dengan partisi 4KB",
"STR_WEB_COMMUNICATION_ERR":"Communication error:", "STR_WEB_COMMUNICATION_ERR":"Kesalahan komunikasi:",
"STR_WEB_REMOTE_ABNORMAL":"Communication error: remote abnormal", "STR_WEB_REMOTE_ABNORMAL":"Kesalahan komunikasi: tidak normalnya kendali",
"STR_WEB_REQUEST_TIMEOUT":"Communication error: Request timed out", "STR_WEB_REQUEST_TIMEOUT":"Kesalahan komunikasi: Waktu permintaan habis",
"STR_WEB_SERVICE_UNAVAILABLE":"Communication error: Service Unavailable", "STR_WEB_SERVICE_UNAVAILABLE":"Kesalahan komunikasi: Layanan tidak tersedia",
"STR_WEB_TOKEN_MISMATCH":"Daemon status updated, please retry later.", "STR_WEB_TOKEN_MISMATCH":"Status daemon diperbarui, silakan coba lagi nanti.",
"STR_WEB_SERVICE_BUSY":"Service is busy, please retry later.", "STR_WEB_SERVICE_BUSY":"Layanan sedang sibuk, silakan coba lagi nanti.",
"STR_MENU_VTSI_CREATE":"Generate VTSI File", "STR_MENU_VTSI_CREATE":"Membuat berkas VTSI",
"STR_VTSI_CREATE_TIP":"This time will not write to the device, but only generate a VTSI file#@Continue?", "STR_VTSI_CREATE_TIP":"Saat ini tidak akan menuliskan di perangkat, tetapi hanya membuat berkas VTSI #@Lanjutkan?",
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15Beta+) to write it to the device so as to complete the installation of Ventoy.", "STR_VTSI_CREATE_SUCCESS":"Berkas VTSI berhasil dibuat#@Anda bisa menggunakan Rufus(3.15Beta+) untuk menulisnya ke perangkat untuk menyelesaikan instalasi Ventoy.",
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.", "STR_VTSI_CREATE_FAILED":"Berkas VTSI gagal dibuat.",
"STRXXX":"" "STRXXX":""
}, },
{ {
@@ -1885,5 +1885,56 @@
"STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15Beta+) to write it to the device so as to complete the installation of Ventoy.", "STR_VTSI_CREATE_SUCCESS":"VTSI file created successfully!#@You can use Rufus(3.15Beta+) to write it to the device so as to complete the installation of Ventoy.",
"STR_VTSI_CREATE_FAILED":"VTSI file created failed.", "STR_VTSI_CREATE_FAILED":"VTSI file created failed.",
"STRXXX":"" "STRXXX":""
},
{
"name":"Bulgarian (Български)",
"FontFamily":"Courier New",
"FontSize":16,
"Author":"jekovcar",
"STR_ERROR":"Грешка",
"STR_WARNING":"Предупреждение",
"STR_INFO":"Информация",
"STR_INCORRECT_DIR":"Моля, стартирайте в друга директория!",
"STR_INCORRECT_TREE_DIR":"Не ме стартирайте оттук, моля, изтеглете инсталационен пакет и го стартирайте в друго място.",
"STR_DEVICE":"Устройство",
"STR_LOCAL_VER":"Ventoy в пакета",
"STR_DISK_VER":"Ventoy на устройството",
"STR_STATUS":"Статус - ГОТОВ",
"STR_INSTALL":"Инсталирай",
"STR_UPDATE":"Обнови",
"STR_UPDATE_TIP":"Обновяването е безопасно, ISO-файловете няма да се променят.#@Продължаваме?",
"STR_INSTALL_TIP":"Диска ще се форматира и всички данни изтрият.#@Продължаваме?",
"STR_INSTALL_TIP2":"Диска ще се форматира и всички данни изтрият..#@ДЕЙСТВИТЕЛНО ще продължите?",
"STR_INSTALL_SUCCESS":"Поздрави!#@Ventoy бе успешно инсталиран на устройството.",
"STR_INSTALL_FAILED":"По време на инсталирането на Ventoy възникна грешка. Подсъединете устройството и опитайте отново. Проверете log.txt за грешки.",
"STR_UPDATE_SUCCESS":"Поздрави!#@Ventoy бе успешно обновен на устройството.",
"STR_UPDATE_FAILED":"По време на обновяването на Ventoy възникна грешка. Подсъединете устройството и опитайте отново. Проверете log.txt за грешки.",
"STR_WAIT_PROCESS":"Процеса е стартиран, моля изчакайте...",
"STR_MENU_OPTION":"Опции",
"STR_MENU_SECURE_BOOT":"Поддръжка на Secure Boot",
"STR_MENU_PART_CFG":"Допълнителен дял",
"STR_BTN_OK":"ОК",
"STR_BTN_CANCEL":"Отказ",
"STR_PRESERVE_SPACE":"Създай Допълнителен дял в края на диска",
"STR_SPACE_VAL_INVALID":"Неправилен размер на дяла",
"STR_MENU_CLEAR":"Изтрий Ventoy",
"STR_CLEAR_SUCCESS":"Ventoy бе успешно изтрит от устройството.",
"STR_CLEAR_FAILED":"По време на изтриването на Ventoy възникна грешка. Подсъединете устройството и опитайте отново. Проверете log.txt за грешки.",
"STR_MENU_PART_STYLE":"Стил на оразмеряване на дяловете",
"STR_DISK_2TB_MBR_ERROR":"Моля, изберете GPT за дискове по-големи от 2ТБ",
"STR_SHOW_ALL_DEV":"Покажи всички устройства",
"STR_PART_ALIGN_4KB":"Подравни дяловете с размер 4КБ",
"STR_WEB_COMMUNICATION_ERR":"Грешка при свързване:",
"STR_WEB_REMOTE_ABNORMAL":"Грешка при свързване: Отдалечената връзка е недействителна",
"STR_WEB_REQUEST_TIMEOUT":"Грешка при свързване: Изтекло време за изчакване на заявката",
"STR_WEB_SERVICE_UNAVAILABLE":"Грешка при свързване: Службата е недостъпна",
"STR_WEB_TOKEN_MISMATCH":"Статуса на агента е обновен. Повторете по-късно.",
"STR_WEB_SERVICE_BUSY":"Службата е заета, Повторете по-късно.",
"STR_MENU_VTSI_CREATE":"Generate VTSI File",
"STR_VTSI_CREATE_TIP":"Сега няма да се записва на диска, само ще се генерира VTSI файл#@Продължаваме?",
"STR_VTSI_CREATE_SUCCESS":"VTSI файла бе създаден успешно!#@Може да използвате Rufus(3.15+) да го запишете на устройството за инсталацията с Ventoy.",
"STR_VTSI_CREATE_FAILED":"VTSI файла създаване се провали.",
"STRXXX":""
} }
] ]

View File

@@ -33,6 +33,12 @@ static ventoy_windows_data g_windows_data;
static UINT8 g_os_param_reserved[32]; static UINT8 g_os_param_reserved[32];
static BOOL g_64bit_system = FALSE; static BOOL g_64bit_system = FALSE;
static ventoy_guid g_ventoy_guid = VENTOY_GUID; static ventoy_guid g_ventoy_guid = VENTOY_GUID;
static HANDLE g_vtoylog_mutex = NULL;
static HANDLE g_vtoyins_mutex = NULL;
#define VTOY_PID_FILE "X:\\Windows\\System32\\pidventoy"
#define MUTEX_LOCK(hmutex) if (hmutex != NULL) LockStatus = WaitForSingleObject(hmutex, INFINITE)
#define MUTEX_UNLOCK(hmutex) if (hmutex != NULL && WAIT_OBJECT_0 == LockStatus) ReleaseMutex(hmutex)
void Log(const char *Fmt, ...) void Log(const char *Fmt, ...)
{ {
@@ -41,25 +47,31 @@ void Log(const char *Fmt, ...)
FILE *File = NULL; FILE *File = NULL;
SYSTEMTIME Sys; SYSTEMTIME Sys;
char szBuf[1024]; char szBuf[1024];
DWORD LockStatus = 0;
DWORD PID = GetCurrentProcessId();
GetLocalTime(&Sys); GetLocalTime(&Sys);
Len += sprintf_s(szBuf, sizeof(szBuf), Len += sprintf_s(szBuf, sizeof(szBuf),
"[%4d/%02d/%02d %02d:%02d:%02d.%03d] ", "[%4d/%02d/%02d %02d:%02d:%02d.%03d] [%u] ",
Sys.wYear, Sys.wMonth, Sys.wDay, Sys.wYear, Sys.wMonth, Sys.wDay,
Sys.wHour, Sys.wMinute, Sys.wSecond, Sys.wHour, Sys.wMinute, Sys.wSecond,
Sys.wMilliseconds); Sys.wMilliseconds, PID);
va_start(Arg, Fmt); va_start(Arg, Fmt);
Len += vsnprintf_s(szBuf + Len, sizeof(szBuf)-Len, sizeof(szBuf)-Len, Fmt, Arg); Len += vsnprintf_s(szBuf + Len, sizeof(szBuf)-Len, sizeof(szBuf)-Len, Fmt, Arg);
va_end(Arg); va_end(Arg);
fopen_s(&File, "ventoy.log", "a+"); MUTEX_LOCK(g_vtoylog_mutex);
if (File)
{ fopen_s(&File, "ventoy.log", "a+");
fwrite(szBuf, 1, Len, File); if (File)
fwrite("\n", 1, 1, File); {
fclose(File); fwrite(szBuf, 1, Len, File);
} fwrite("\n", 1, 1, File);
fclose(File);
}
MUTEX_UNLOCK(g_vtoylog_mutex);
} }
@@ -1304,12 +1316,33 @@ End:
return rc; return rc;
} }
static int ventoy_check_create_directory(void)
{
if (IsDirExist("ventoy"))
{
Log("ventoy directory already exist");
}
else
{
Log("ventoy directory not exist, now create it.");
if (!CreateDirectoryA("ventoy", NULL))
{
Log("Failed to create ventoy directory err:%u", GetLastError());
return 1;
}
}
return 0;
}
int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile) int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
{ {
int rc = 1; int rc = 1;
int stat = 0;
DWORD Pos; DWORD Pos;
DWORD PeStart; DWORD PeStart;
DWORD FileSize; DWORD FileSize;
DWORD LockStatus = 0;
BYTE *Buffer = NULL; BYTE *Buffer = NULL;
CHAR ExeFileName[MAX_PATH]; CHAR ExeFileName[MAX_PATH];
@@ -1330,19 +1363,14 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
g_64bit_system = IsPe64(Buffer); g_64bit_system = IsPe64(Buffer);
Log("VentoyJump %dbit", g_64bit_system ? 64 : 32); Log("VentoyJump %dbit", g_64bit_system ? 64 : 32);
if (IsDirExist("ventoy")) MUTEX_LOCK(g_vtoyins_mutex);
stat = ventoy_check_create_directory();
MUTEX_UNLOCK(g_vtoyins_mutex);
if (stat != 0)
{ {
Log("ventoy directory already exist"); goto End;
} }
else
{
Log("ventoy directory not exist, now create it.");
if (!CreateDirectoryA("ventoy", NULL))
{
Log("Failed to create ventoy directory err:%u", GetLastError());
goto End;
}
}
for (PeStart = 0; PeStart < FileSize; PeStart += 16) for (PeStart = 0; PeStart < FileSize; PeStart += 16)
{ {
@@ -1373,14 +1401,18 @@ int VentoyJump(INT argc, CHAR **argv, CHAR *LunchFile)
PeStart += sizeof(ventoy_os_param) + sizeof(ventoy_windows_data); PeStart += sizeof(ventoy_os_param) + sizeof(ventoy_windows_data);
sprintf_s(LunchFile, MAX_PATH, "ventoy\\%s", GetFileNameInPath(ExeFileName)); sprintf_s(LunchFile, MAX_PATH, "ventoy\\%s", GetFileNameInPath(ExeFileName));
MUTEX_LOCK(g_vtoyins_mutex);
if (IsFileExist("%s", LunchFile)) if (IsFileExist("%s", LunchFile))
{ {
Log("vtoyjump multiple call..."); Log("vtoyjump multiple call ...");
rc = 0; rc = 0;
MUTEX_UNLOCK(g_vtoyins_mutex);
goto End; goto End;
} }
SaveBuffer2File(LunchFile, Buffer + PeStart, FileSize - PeStart); SaveBuffer2File(LunchFile, Buffer + PeStart, FileSize - PeStart);
MUTEX_UNLOCK(g_vtoyins_mutex);
break; break;
} }
} }
@@ -1410,159 +1442,102 @@ End:
return rc; return rc;
} }
static int GetPecmdParam(const char *argv, char *CallParamBuf, DWORD BufLen)
static int ventoy_append_process_id(const char *pidfile)
{ {
HKEY hKey; DWORD PID = 0;
LSTATUS Ret; FILE *fp = NULL;
DWORD dw;
DWORD Type;
CHAR *Pos = NULL;
CHAR CallParam[256] = { 0 };
CHAR FileName[MAX_PATH];
Log("GetPecmdParam <%s>", argv); PID = GetCurrentProcessId();
*CallParamBuf = 0; fopen_s(&fp, pidfile, "a+");
if (!fp)
strcpy_s(FileName, sizeof(FileName), argv);
for (dw = 0, Pos = FileName; *Pos; Pos++)
{ {
dw++;
*Pos = toupper(*Pos);
}
Log("dw=%lu argv=<%s>", dw, FileName);
if (dw >= 9 && strcmp(FileName + dw - 9, "PECMD.EXE") == 0)
{
Log("Get parameters for pecmd.exe");
Ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "System\\Setup", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dw);
if (ERROR_SUCCESS == Ret)
{
memset(FileName, 0, sizeof(FileName));
dw = sizeof(FileName);
Ret = RegQueryValueEx(hKey, "CmdLine", NULL, &Type, FileName, &dw);
if (ERROR_SUCCESS == Ret && Type == REG_SZ)
{
strcpy_s(CallParam, sizeof(CallParam), FileName);
Log("CmdLine:<%s>", CallParam);
if (_strnicmp(CallParam, "PECMD.EXE", 9) == 0)
{
Pos = CallParam + 9;
if (*Pos == ' ' || *Pos == '\t')
{
Pos++;
}
}
else
{
Pos = CallParam;
}
Log("CmdLine2:<%s>", Pos);
sprintf_s(CallParamBuf, BufLen, " %s", Pos);
}
else
{
Log("Failed to RegQueryValueEx %lu %lu", Ret, Type);
}
RegCloseKey(hKey);
return 1;
}
else
{
Log("Failed to create reg key %lu", Ret);
}
}
else
{
Log("This is NOT pecmd.exe");
}
return 0;
}
static int GetWpeInitParam(char **argv, int argc, char *CallParamBuf, DWORD BufLen)
{
int i;
DWORD dw;
CHAR *Pos = NULL;
CHAR FileName[MAX_PATH];
Log("GetWpeInitParam argc=%d", argc);
*CallParamBuf = 0;
strcpy_s(FileName, sizeof(FileName), argv[0]);
for (dw = 0, Pos = FileName; *Pos; Pos++)
{
dw++;
*Pos = toupper(*Pos);
}
Log("dw=%lu argv=<%s>", dw, FileName);
if (dw >= 11 && strcmp(FileName + dw - 11, "WPEINIT.EXE") == 0)
{
Log("Get parameters for WPEINIT.EXE");
for (i = 1; i < argc; i++)
{
strcat_s(CallParamBuf, BufLen, " ");
strcat_s(CallParamBuf, BufLen, argv[i]);
}
return 1; return 1;
} }
else
{
Log("This is NOT wpeinit.exe");
}
fprintf_s(fp, "%u\n", PID);
fclose(fp);
return 0; return 0;
} }
static int ventoy_get_instance_id(const char *pidfile)
{
int instance = 0;
FILE *fp = NULL;
char line[256];
fopen_s(&fp, pidfile, "r");
if (!fp)
{
return 1;
}
while (fgets(line, sizeof(line), fp))
{
instance++;
}
fclose(fp);
return instance + 1;
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int i = 0; int i = 0;
int rc = 0; int rc = 0;
CHAR *Pos = NULL; int id = 0;
CHAR CurDir[MAX_PATH]; CHAR *Pos = NULL;
CHAR LunchFile[MAX_PATH]; CHAR CurDir[MAX_PATH];
CHAR LunchFile[MAX_PATH];
CHAR CallParam[1024] = { 0 }; CHAR CallParam[1024] = { 0 };
STARTUPINFOA Si; DWORD LockStatus = 0;
PROCESS_INFORMATION Pi; STARTUPINFOA Si;
PROCESS_INFORMATION Pi;
if (argv[0] && argv[0][0] && argv[0][1] == ':') g_vtoylog_mutex = CreateMutexA(NULL, FALSE, "VTOYLOG_LOCK");
{ g_vtoyins_mutex = CreateMutexA(NULL, FALSE, "VTOYINS_LOCK");
GetCurrentDirectoryA(sizeof(CurDir), CurDir);
strcpy_s(LunchFile, sizeof(LunchFile), argv[0]); MUTEX_LOCK(g_vtoyins_mutex);
Pos = (char *)GetFileNameInPath(LunchFile); if (IsFileExist(VTOY_PID_FILE))
{
id = ventoy_get_instance_id(VTOY_PID_FILE);
}
else
{
id = 1;
}
ventoy_append_process_id(VTOY_PID_FILE);
MUTEX_UNLOCK(g_vtoyins_mutex);
strcat_s(CurDir, sizeof(CurDir), "\\"); if (argv[0] && argv[0][0] && argv[0][1] == ':')
strcat_s(CurDir, sizeof(CurDir), Pos);
if (_stricmp(argv[0], CurDir) != 0)
{
*Pos = 0;
SetCurrentDirectoryA(LunchFile);
}
}
Log("######## VentoyJump ##########");
Log("argc = %d argv[0] = <%s>", argc, argv[0]);
//special process for some WinPE
if (_stricmp(argv[0], "WPEINIT.EXE") == 0)
{ {
GetCurrentDirectoryA(sizeof(CurDir), CurDir); GetCurrentDirectoryA(sizeof(CurDir), CurDir);
if (_stricmp(CurDir, "X:\\") == 0)
strcpy_s(LunchFile, sizeof(LunchFile), argv[0]);
Pos = (char *)GetFileNameInPath(LunchFile);
strcat_s(CurDir, sizeof(CurDir), "\\");
strcat_s(CurDir, sizeof(CurDir), Pos);
if (_stricmp(argv[0], CurDir) != 0)
{ {
Log("Set current directory to system32"); *Pos = 0;
SetCurrentDirectoryA("X:\\Windows\\System32"); SetCurrentDirectoryA(LunchFile);
}
}
Log("######## VentoyJump [%d] ##########", id);
Log("argc = %d", argc);
for (i = 0; i < argc; i++)
{
Log("argv[%d]=<%s>", i, argv[i]);
if (i > 0)
{
strcat_s(CallParam, sizeof(CallParam), " ");
strcat_s(CallParam, sizeof(CallParam), argv[i]);
} }
} }
@@ -1577,11 +1552,6 @@ int main(int argc, char **argv)
Log("Current directory = <%s>", CurDir); Log("Current directory = <%s>", CurDir);
} }
if (0 == GetWpeInitParam(argv, argc, CallParam, sizeof(CallParam)))
{
GetPecmdParam(argv[0], CallParam, sizeof(CallParam));
}
GetStartupInfoA(&Si); GetStartupInfoA(&Si);
memset(LunchFile, 0, sizeof(LunchFile)); memset(LunchFile, 0, sizeof(LunchFile));
@@ -1595,7 +1565,28 @@ int main(int argc, char **argv)
rc = VentoyJump(argc, argv, LunchFile); rc = VentoyJump(argc, argv, LunchFile);
} }
Log("LunchFile=<%s> CallParam=<%s>", LunchFile, CallParam); Log("id=%d LunchFile=<%s> CallParam=<%s>", id, LunchFile, CallParam);
if (id == 1 && _stricmp(argv[0], "PECMD.EXE") == 0 && _stricmp(LunchFile, "ventoy\\PECMD.EXE") == 0)
{
MUTEX_LOCK(g_vtoyins_mutex);
id = ventoy_get_instance_id(VTOY_PID_FILE);
MUTEX_UNLOCK(g_vtoyins_mutex);
Log("Current instance id is: %d", id);
if (id == 2)
{
MoveFileA("PECMD.EXE", "PECMD_BACK.EXE");
CopyFileA("ventoy\\PECMD.EXE", "PECMD.EXE", TRUE);
sprintf_s(LunchFile, sizeof(LunchFile), "%s", "PECMD.EXE");
Log("Move original PECMD.EXE <%s>", LunchFile);
}
else
{
Log("%d instance started, don't move PECMD.EXE", id);
}
}
if (g_os_param_reserved[0] == 3) if (g_os_param_reserved[0] == 3)
{ {