Commit d8fbd79d authored by longpanda's avatar longpanda
Browse files

1.0.29 release

parent 8c192a18
......@@ -9,6 +9,7 @@ print_usage() {
echo ' -i install ventoy to sdX (fail if disk already installed with ventoy)'
echo ' -I force install ventoy to sdX (no matter installed or not)'
echo ' -u update ventoy in sdX'
echo ' -l list Ventoy information in sdX'
echo ''
echo ' OPTION: (optional)'
echo ' -r SIZE_MB preserve some space at the bottom of the disk (only for install)'
......@@ -29,6 +30,8 @@ while [ -n "$1" ]; do
FORCE="Y"
elif [ "$1" = "-u" ]; then
MODE="update"
elif [ "$1" = "-l" ]; then
MODE="list"
elif [ "$1" = "-s" ]; then
SECUREBOOT="YES"
elif [ "$1" = "-g" ]; then
......@@ -42,7 +45,7 @@ while [ -n "$1" ]; do
RESERVE_SIZE_MB=$1
elif [ "$1" = "-V" ] || [ "$1" = "--version" ]; then
exit 0
elif [ "$1" == "-h" ] || [ "$1" = "--help" ]; then
elif [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
print_usage
exit 0
else
......@@ -76,7 +79,7 @@ if [ -e /sys/class/block/${DISK#/dev/}/start ]; then
exit 1
fi
if [ -n "$RESERVE_SPACE" ]; then
if [ -n "$RESERVE_SPACE" -a "$MODE" = "install" ]; then
if echo $RESERVE_SIZE_MB | grep -q '^[0-9][0-9]*$'; then
vtdebug "User will reserve $RESERVE_SIZE_MB MB disk space"
else
......@@ -104,6 +107,36 @@ else
exit 1
fi
if [ "$MODE" = "list" ]; then
version=$(get_disk_ventoy_version $DISK)
if [ $? -eq 0 ]; then
echo "Ventoy Version in Disk: $version"
vtPart1Type=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
if [ "$vtPart1Type" = "EE" ]; then
echo "Disk Partition Style : GPT"
else
echo "Disk Partition Style : MBR"
fi
vtPART2=$(get_disk_part_name $DISK 2)
rm -rf ./tmpmntp2 && mkdir ./tmpmntp2
mount $vtPART2 ./tmpmntp2 > /dev/null 2>&1
if [ -e ./tmpmntp2/EFI/BOOT/MokManager.efi ]; then
echo "Secure Boot Support : YES"
else
echo "Secure Boot Support : NO"
fi
umount ./tmpmntp2 > /dev/null 2>&1
rm -rf ./tmpmntp2
else
echo "Ventoy Version: NA"
fi
echo ""
exit 0
fi
#check mountpoint
grep "^$DISK" /proc/mounts | while read mtline; do
mtpnt=$(echo $mtline | awk '{print $2}')
......@@ -345,7 +378,7 @@ else
SHORT_PART2=${PART2#/dev/}
part2_start=$(cat /sys/class/block/$SHORT_PART2/start)
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
if [ "$PART1_TYPE" = "EE" ]; then
vtdebug "This is GPT partition style ..."
......@@ -355,8 +388,8 @@ else
vtdebug "This is MBR partition style ..."
dd status=none conv=fsync if=./boot/boot.img of=$DISK bs=1 count=440
PART1_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=446 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART2_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=462 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART1_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=446 status=none | hexdump -n1 -e '1/1 "%02X"')
PART2_ACTIVE=$(dd if=$DISK bs=1 count=1 skip=462 status=none | hexdump -n1 -e '1/1 "%02X"')
vtdebug "PART1_ACTIVE=$PART1_ACTIVE PART2_ACTIVE=$PART2_ACTIVE"
if [ "$PART1_ACTIVE" = "00" ] && [ "$PART2_ACTIVE" = "80" ]; then
......
......@@ -128,8 +128,8 @@ is_disk_contains_ventoy() {
return
fi
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART2_TYPE=$(dd if=$DISK bs=1 count=1 skip=466 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
PART2_TYPE=$(dd if=$DISK bs=1 count=1 skip=466 status=none | hexdump -n1 -e '1/1 "%02X"')
# if [ "$PART1_TYPE" != "EE" ]; then
# if [ "$PART2_TYPE" != "EF" ]; then
......@@ -139,7 +139,7 @@ is_disk_contains_ventoy() {
# fi
# fi
# PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | ./tool/hexdump -n1 -e '1/1 "%02X"')
# PART1_TYPE=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
# if [ "$PART1_TYPE" != "07" ]; then
# vtdebug "part1 type is $PART2_TYPE not 07"
# ventoy_false
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -287,18 +287,52 @@ End:
return rc;
}
static int IsUTF8Encode(const char *src)
{
int i;
const UCHAR *Byte = (const UCHAR *)src;
for (i = 0; i < MAX_PATH && Byte[i]; i++)
{
if (Byte[i] > 127)
{
return 1;
}
}
return 0;
}
static int Utf8ToUtf16(const char* src, WCHAR * dst)
{
int size = MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, 0);
return MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, size + 1);
}
static BOOL IsPathExist(BOOL Dir, const char *Fmt, ...)
{
va_list Arg;
HANDLE hFile;
DWORD Attr;
CHAR FilePath[MAX_PATH];
int UTF8 = 0;
CHAR FilePathA[MAX_PATH];
WCHAR FilePathW[MAX_PATH];
va_start(Arg, Fmt);
vsnprintf_s(FilePath, sizeof(FilePath), sizeof(FilePath), Fmt, Arg);
vsnprintf_s(FilePathA, sizeof(FilePathA), sizeof(FilePathA), Fmt, Arg);
va_end(Arg);
hFile = CreateFileA(FilePath, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
UTF8 = IsUTF8Encode(FilePathA);
if (UTF8)
{
Utf8ToUtf16(FilePathA, FilePathW);
hFile = CreateFileW(FilePathW, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
}
else
{
hFile = CreateFileA(FilePathA, FILE_READ_EA, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
}
if (INVALID_HANDLE_VALUE == hFile)
{
return FALSE;
......@@ -306,7 +340,14 @@ static BOOL IsPathExist(BOOL Dir, const char *Fmt, ...)
CloseHandle(hFile);
Attr = GetFileAttributesA(FilePath);
if (UTF8)
{
Attr = GetFileAttributesW(FilePathW);
}
else
{
Attr = GetFileAttributesA(FilePathA);
}
if (Dir)
{
......@@ -395,7 +436,14 @@ int VentoyMountISOByAPI(const char *IsoPath)
Log("VentoyMountISOByAPI <%s>", IsoPath);
if (IsUTF8Encode(IsoPath))
{
MultiByteToWideChar(CP_UTF8, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR)));
}
else
{
MultiByteToWideChar(CP_ACP, 0, IsoPath, (int)strlen(IsoPath), wFilePath, (int)(sizeof(wFilePath) / sizeof(WCHAR)));
}
memset(&StorageType, 0, sizeof(StorageType));
memset(&OpenParameters, 0, sizeof(OpenParameters));
......@@ -570,6 +618,7 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
DWORD dwBytes;
HANDLE hDrive;
CHAR PhyPath[MAX_PATH];
WCHAR PhyPathW[MAX_PATH];
STARTUPINFOA Si;
PROCESS_INFORMATION Pi;
GET_LENGTH_INFORMATION LengthInfo;
......@@ -577,7 +626,16 @@ int VentoyMountISOByImdisk(const char *IsoPath, DWORD PhyDrive)
Log("VentoyMountISOByImdisk %s", IsoPath);
sprintf_s(PhyPath, sizeof(PhyPath), "\\\\.\\PhysicalDrive%d", PhyDrive);
if (IsUTF8Encode(PhyPath))
{
Utf8ToUtf16(PhyPath, PhyPathW);
hDrive = CreateFileW(PhyPathW, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
}
else
{
hDrive = CreateFileA(PhyPath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
}
if (hDrive == INVALID_HANDLE_VALUE)
{
Log("Could not open the disk<%s>, error:%u", PhyPath, GetLastError());
......@@ -942,6 +1000,11 @@ static int VentoyHook(ventoy_os_param *param)
Log("Logical Drives=0x%x Path:<%s>", Drives, param->vtoy_img_path);
if (IsUTF8Encode(param->vtoy_img_path))
{
Log("This file is UTF8 encoding\n");
}
while (Drives)
{
if (Drives & 0x01)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment