]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
VentoyPlugson update
authorlongpanda <admin@ventoy.net>
Thu, 2 Dec 2021 02:55:37 +0000 (10:55 +0800)
committerlongpanda <admin@ventoy.net>
Thu, 2 Dec 2021 02:55:37 +0000 (10:55 +0800)
INSTALL/VentoyPlugson.sh
INSTALL/ventoy_pack.sh
Plugson/pack.sh
Plugson/src/Core/ventoy_util.c
Plugson/src/Core/ventoy_util.h
Plugson/src/Core/ventoy_util_linux.c
Plugson/src/Core/ventoy_util_windows.c
Plugson/src/main_windows.c
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe

index 4573fbc105422e075d9bb566e9f580bea8110b77..c398432c46fb4bb5ec1f3ccf54933c8363b444d1 100644 (file)
@@ -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
 
index da72c7a09dc0f64f499429ac9336cd1c75ee2579..013cf475dde2ee2a1fd46348a5e54ac7185439ae 100644 (file)
@@ -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
index f40c6c782fa614e05787084fedc9e6a1ecc7b74d..6eed00edd4496e25036047919bb8a87306ced6ab 100644 (file)
@@ -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
index d13cc9be759a48ab53c866a8d286b95789832613..d6ce0106a7dfb8d3550b00a0bf3ed6eb01ebebe7 100644 (file)
@@ -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;
index bfff7a6ae1041f2f041e8d5ce06cfb194132fa7e..5866c0b83b6437a140fcd6abedf68ef2e88b8b96 100644 (file)
@@ -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))
index fa799a92df7faaaee608948e5c8bf0e184ede1bc..69b6022f47a2da4fcada87f6577926dc33a65cab 100644 (file)
@@ -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;
index 24da3eca350a7b8a524dc7f3cd2b59583a969745..b65f773d3b7620819dd8fdd99251bf5c400b5aa3 100644 (file)
@@ -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;
index 910dfe53746262d91d49d07e8a3bfe1ca7ce8096..67d6ee0fa43bb77a30205b0e5cac82e4761b7298 100644 (file)
@@ -10,6 +10,8 @@
 #include <ventoy_disk.h>\r
 #include <ventoy_http.h>\r
 \r
+char g_ventoy_dir[MAX_PATH];
+\r
 static BOOL g_running = FALSE;\r
 static HWND g_refresh_button;\r
 static HWND g_start_button;\r
@@ -34,6 +36,7 @@ typedef enum MSGID
        MSGID_BTN_STOP_TIP, \r
        MSGID_BTN_EXIT_TIP,\r
        MSGID_RUNNING_TIP,\r
+       MSGID_NO_TARXZ_TIP,\r
 \r
     MSGID_BUTT\r
 }MSGID;\r
@@ -56,6 +59,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
        L"Í£Ö¹ÔËÐкóä¯ÀÀÆ÷Ò³Ãæ½«»á¹Ø±Õ£¬ÊÇ·ñ¼ÌÐø£¿",\r
        L"µ±Ç°·þÎñÕýÔÚÔËÐУ¬ÊÇ·ñÍ˳ö£¿",\r
        L"ÇëÏȹرÕÕýÔÚÔËÐеĠVentoyPlugson ³ÌÐò£¡",\r
+       L"ventoy\\plugson.tar.xz Îļþ²»´æÔÚ£¬ÇëÔÚÕýÈ·µÄĿ¼ÏÂÔËÐУ¡",\r
 };\r
 const WCHAR *g_msg_en[MSGID_BUTT] =\r
 {\r
@@ -74,6 +78,7 @@ const WCHAR *g_msg_en[MSGID_BUTT] =
        L"The browser page will close after stop, continue?",\r
        L"Service is running, continue?",\r
        L"Please close another running VentoyPlugson instance!",\r
+       L"ventoy\\plugson.tar.xz does not exist, please run under the correct directory!",\r
 };\r
 \r
 const WCHAR **g_msg_lang = NULL;\r
@@ -485,9 +490,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
        }\r
 \r
        GetCurrentDirectoryA(MAX_PATH, g_cur_dir);\r
+       sprintf_s(g_ventoy_dir, sizeof(g_ventoy_dir), "%s", g_cur_dir);\r
        sprintf_s(g_log_file, sizeof(g_log_file), "%s\\%s", g_cur_dir, LOG_FILE);\r
        ventoy_log_init();\r
 \r
+    if (!ventoy_is_file_exist("%s\\ventoy\\%s", g_ventoy_dir, PLUGSON_TXZ))\r
+    {        \r
+               MessageBoxW(NULL, g_msg_lang[MSGID_NO_TARXZ_TIP], g_msg_lang[MSGID_ERROR], MB_OK | MB_ICONERROR);\r
+        return 1;\r
+    }\r
 \r
        ParseCmdLine(lpCmdLine, g_sysinfo.ip, g_sysinfo.port);\r
        if (g_sysinfo.ip[0] == 0)\r
index 3d6fdd815cd6b7b8fadd62b7c1b4a75e7aa9ec9c..7c4a7645b5b0d8b2cb6b6d88699b870a2b2d2e61 100644 (file)
Binary files a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe and b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe differ