VentoyPlugson update

pull/1294/head
longpanda 3 years ago
parent 4bf43ab9d4
commit 293f677cbf

@ -187,7 +187,7 @@ fi
#change current directory to Ventoy disk
cd "$mtpnt"
LANG=en_US $OLDDIR/tool/$TOOLDIR/Plugson "$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
$OLDDIR/tool/$TOOLDIR/Plugson "$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
wID=$!
sleep 1

@ -189,6 +189,7 @@ cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
cp $OPT $tmpdir/tool/plugson.tar.xz $tmpdir/ventoy/
cp $OPT $LANG_DIR/languages.json $tmpdir/ventoy/
rm -rf $tmpdir/tool
rm -f $tmpdir/*.sh

@ -1,14 +1,5 @@
#!/bin/sh
output_hex_u32() {
hexval=$(printf '%08x' $1)
hex_B0=${hexval:0:2}
hex_B1=${hexval:2:2}
hex_B2=${hexval:4:2}
hex_B3=${hexval:6:2}
echo -en "\x$hex_B3\x$hex_B2\x$hex_B1\x$hex_B0"
}
if [ -n "$PKG_DATE" ]; then
plugson_verion=$PKG_DATE
else
@ -31,18 +22,8 @@ echo -n "$plugson_verion" > ./www/buildtime
tar cf www.tar www
xz --check=crc32 www.tar
xzdec=$(stat -c '%s' ./www.tar.xz)
echo xzdec=$xzdec
output_hex_u32 0x54535251 > ex.bin
output_hex_u32 $xzdec >> ex.bin
output_hex_u32 0xa4a3a2a1 >> ex.bin
cat ./vs/VentoyPlugson/Release/VentoyPlugson.exe ./www.tar.xz ex.bin > VentoyPlugson.exe
rm -f ./ex.bin
rm -f ../INSTALL/VentoyPlugson.exe
cp -a ./VentoyPlugson.exe ../INSTALL/VentoyPlugson.exe
cp -a ./vs/VentoyPlugson/Release/VentoyPlugson.exe ../INSTALL/VentoyPlugson.exe
rm -f ../INSTALL/tool/plugson.tar.xz
mv ./www.tar.xz ../INSTALL/tool/plugson.tar.xz

@ -143,6 +143,48 @@ ventoy_file * ventoy_tar_find_file(const char *path)
}
int ventoy_decompress_tar(char *tarbuf, int buflen, int *tarsize)
{
int rc = 1;
int inused = 0;
int BufLen = 0;
unsigned char *buffer = NULL;
char tarxz[MAX_PATH];
#if defined(_MSC_VER) || defined(WIN32)
scnprintf(tarxz, sizeof(tarxz), "%s\\ventoy\\%s", g_ventoy_dir, PLUGSON_TXZ);
#else
scnprintf(tarxz, sizeof(tarxz), "%s/tool/%s", g_ventoy_dir, PLUGSON_TXZ);
#endif
if (ventoy_read_file_to_buf(tarxz, 0, (void **)&buffer, &BufLen))
{
vlog("Failed to read file <%s>\n", tarxz);
return 1;
}
g_unxz_buffer = (unsigned char *)tarbuf;
g_unxz_len = 0;
unxz(buffer, BufLen, NULL, unxz_flush, NULL, &inused, unxz_error);
vlog("xzlen:%u rawdata size:%d\n", BufLen, g_unxz_len);
if (inused != BufLen)
{
vlog("Failed to unxz data %d %d\n", inused, BufLen);
rc = 1;
}
else
{
*tarsize = g_unxz_len;
rc = 0;
}
free(buffer);
return rc;
}
int ventoy_www_init(void)
{
int i = 0;

@ -20,6 +20,8 @@
#ifndef __VENTOY_UTIL_H__
#define __VENTOY_UTIL_H__
#define PLUGSON_TXZ "plugson.tar.xz"
#define check_free(p) if (p) free(p)
#define vtoy_safe_close_fd(fd) \
{\
@ -139,16 +141,6 @@ typedef struct tag_tar_head
}VENTOY_TAR_HEAD;
typedef struct VENTOY_MAGIC
{
uint32_t magic1; // 0x51 0x52 0x53 0x54
uint32_t xzlen; //
uint32_t magic2; // 0xa1 0xa2 0xa3 0xa4
}VENTOY_MAGIC;
#pragma pack()
#define VENTOY_UP_ALIGN(N, align) (((N) + ((align) - 1)) / (align) * (align))

@ -234,42 +234,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
return 0;
}
int ventoy_decompress_tar(char *tarbuf, int buflen, int *tarsize)
{
int rc = 1;
int inused = 0;
int BufLen = 0;
unsigned char *buffer = NULL;
char tarxz[MAX_PATH];
scnprintf(tarxz, sizeof(tarxz), "%s/tool/plugson.tar.xz", g_ventoy_dir);
if (ventoy_read_file_to_buf(tarxz, 0, (void **)&buffer, &BufLen))
{
vlog("Failed to read file <%s>\n", tarxz);
return 1;
}
g_unxz_buffer = (unsigned char *)tarbuf;
g_unxz_len = 0;
unxz(buffer, BufLen, NULL, unxz_flush, NULL, &inused, unxz_error);
vlog("xzlen:%u rawdata size:%d\n", BufLen, g_unxz_len);
if (inused != BufLen)
{
vlog("Failed to unxz data %d %d\n", inused, BufLen);
rc = 1;
}
else
{
*tarsize = g_unxz_len;
rc = 0;
}
free(buffer);
return rc;
}
static volatile int g_thread_stop = 0;
static pthread_t g_writeback_thread;

@ -683,75 +683,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
return 0;
}
int ventoy_decompress_tar(char *tarbuf, int buflen, int *tarsize)
{
int rc = 1;
int inused;
HANDLE hFile;
DWORD dwSize;
DWORD dwRead;
WCHAR FullPath[MAX_PATH];
BYTE *buffer;
VENTOY_MAGIC Magic;
GetModuleFileNameW(NULL, FullPath, MAX_PATH);
hFile = CreateFileW(FullPath, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
vlog("Failed to open self %u\n", LASTERR);
return 1;
}
dwSize = GetFileSize(hFile, NULL);
if (dwSize == INVALID_FILE_SIZE)
{
vlog("Invalid self exe size %u\n", LASTERR);
CHECK_CLOSE_HANDLE(hFile);
return 1;
}
buffer = malloc(dwSize);
if (!buffer)
{
vlog("Failed to malloc %u\n", dwSize);
CHECK_CLOSE_HANDLE(hFile);
return 1;
}
ReadFile(hFile, buffer, dwSize, &dwRead, NULL);
memcpy(&Magic, buffer + dwSize - sizeof(Magic), sizeof(Magic));
if (Magic.magic1 == 0x54535251 && Magic.magic2 == 0xa4a3a2a1)
{
g_unxz_buffer = (UCHAR *)tarbuf;
g_unxz_len = 0;
unxz(buffer + dwSize - Magic.xzlen - sizeof(Magic), Magic.xzlen, NULL, unxz_flush, NULL, &inused, unxz_error);
vlog("bigexe:%u xzlen:%u rawdata size:%d\n", dwSize, Magic.xzlen, g_unxz_len);
if (inused != Magic.xzlen)
{
vlog("Failed to unxz www %d\n", inused);
rc = 1;
}
else
{
*tarsize = g_unxz_len;
rc = 0;
}
}
else
{
vlog("Invalid magic 0x%x 0x%x\n", Magic.magic1, Magic.magic2);
rc = 1;
}
free(buffer);
CHECK_CLOSE_HANDLE(hFile);
return rc;
}
static volatile int g_thread_stop = 0;
static HANDLE g_writeback_thread;
static HANDLE g_writeback_event;

@ -10,6 +10,8 @@
#include <ventoy_disk.h>
#include <ventoy_http.h>
char g_ventoy_dir[MAX_PATH];
static BOOL g_running = FALSE;
static HWND g_refresh_button;
static HWND g_start_button;
@ -34,6 +36,7 @@ typedef enum MSGID
MSGID_BTN_STOP_TIP,
MSGID_BTN_EXIT_TIP,
MSGID_RUNNING_TIP,
MSGID_NO_TARXZ_TIP,
MSGID_BUTT
}MSGID;
@ -56,6 +59,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
L"停止运行后浏览器页面将会关闭,是否继续?",
L"当前服务正在运行,是否退出?",
L"请先关闭正在运行的 VentoyPlugson 程序!",
L"ventoy\\plugson.tar.xz 文件不存在,请在正确的目录下运行!",
};
const WCHAR *g_msg_en[MSGID_BUTT] =
{
@ -74,6 +78,7 @@ const WCHAR *g_msg_en[MSGID_BUTT] =
L"The browser page will close after stop, continue?",
L"Service is running, continue?",
L"Please close another running VentoyPlugson instance!",
L"ventoy\\plugson.tar.xz does not exist, please run under the correct directory!",
};
const WCHAR **g_msg_lang = NULL;
@ -485,9 +490,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
}
GetCurrentDirectoryA(MAX_PATH, g_cur_dir);
sprintf_s(g_ventoy_dir, sizeof(g_ventoy_dir), "%s", g_cur_dir);
sprintf_s(g_log_file, sizeof(g_log_file), "%s\\%s", g_cur_dir, LOG_FILE);
ventoy_log_init();
if (!ventoy_is_file_exist("%s\\ventoy\\%s", g_ventoy_dir, PLUGSON_TXZ))
{
MessageBoxW(NULL, g_msg_lang[MSGID_NO_TARXZ_TIP], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);
return 1;
}
ParseCmdLine(lpCmdLine, g_sysinfo.ip, g_sysinfo.port);
if (g_sysinfo.ip[0] == 0)

Loading…
Cancel
Save