Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dadigang
Ventoy
Commits
293f677c
Commit
293f677c
authored
Dec 02, 2021
by
longpanda
Browse files
VentoyPlugson update
parent
4bf43ab9
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
58 additions
and
136 deletions
+58
-136
INSTALL/VentoyPlugson.sh
INSTALL/VentoyPlugson.sh
+1
-1
INSTALL/ventoy_pack.sh
INSTALL/ventoy_pack.sh
+1
-0
Plugson/pack.sh
Plugson/pack.sh
+1
-20
Plugson/src/Core/ventoy_util.c
Plugson/src/Core/ventoy_util.c
+42
-0
Plugson/src/Core/ventoy_util.h
Plugson/src/Core/ventoy_util.h
+2
-10
Plugson/src/Core/ventoy_util_linux.c
Plugson/src/Core/ventoy_util_linux.c
+0
-36
Plugson/src/Core/ventoy_util_windows.c
Plugson/src/Core/ventoy_util_windows.c
+0
-69
Plugson/src/main_windows.c
Plugson/src/main_windows.c
+11
-0
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
+0
-0
No files found.
INSTALL/VentoyPlugson.sh
View file @
293f677c
...
@@ -187,7 +187,7 @@ fi
...
@@ -187,7 +187,7 @@ fi
#change current directory to Ventoy disk
#change current directory to Ventoy disk
cd
"
$mtpnt
"
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
=
$!
wID
=
$!
sleep
1
sleep
1
...
...
INSTALL/ventoy_pack.sh
View file @
293f677c
...
@@ -189,6 +189,7 @@ cp $OPT Ventoy2Disk_*.exe $tmpdir/altexe/
...
@@ -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/
cp
$OPT
$LANG_DIR
/languages.json
$tmpdir
/ventoy/
rm
-rf
$tmpdir
/tool
rm
-rf
$tmpdir
/tool
rm
-f
$tmpdir
/
*
.sh
rm
-f
$tmpdir
/
*
.sh
...
...
Plugson/pack.sh
View file @
293f677c
#!/bin/sh
#!/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
if
[
-n
"
$PKG_DATE
"
]
;
then
plugson_verion
=
$PKG_DATE
plugson_verion
=
$PKG_DATE
else
else
...
@@ -31,18 +22,8 @@ echo -n "$plugson_verion" > ./www/buildtime
...
@@ -31,18 +22,8 @@ echo -n "$plugson_verion" > ./www/buildtime
tar
cf www.tar www
tar
cf www.tar www
xz
--check
=
crc32 www.tar
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
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
rm
-f
../INSTALL/tool/plugson.tar.xz
mv
./www.tar.xz ../INSTALL/tool/plugson.tar.xz
mv
./www.tar.xz ../INSTALL/tool/plugson.tar.xz
...
...
Plugson/src/Core/ventoy_util.c
View file @
293f677c
...
@@ -143,6 +143,48 @@ ventoy_file * ventoy_tar_find_file(const char *path)
...
@@ -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
ventoy_www_init
(
void
)
{
{
int
i
=
0
;
int
i
=
0
;
...
...
Plugson/src/Core/ventoy_util.h
View file @
293f677c
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
#ifndef __VENTOY_UTIL_H__
#ifndef __VENTOY_UTIL_H__
#define __VENTOY_UTIL_H__
#define __VENTOY_UTIL_H__
#define PLUGSON_TXZ "plugson.tar.xz"
#define check_free(p) if (p) free(p)
#define check_free(p) if (p) free(p)
#define vtoy_safe_close_fd(fd) \
#define vtoy_safe_close_fd(fd) \
{\
{\
...
@@ -139,16 +141,6 @@ typedef struct tag_tar_head
...
@@ -139,16 +141,6 @@ typedef struct tag_tar_head
}
VENTOY_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()
#pragma pack()
#define VENTOY_UP_ALIGN(N, align) (((N) + ((align) - 1)) / (align) * (align))
#define VENTOY_UP_ALIGN(N, align) (((N) + ((align) - 1)) / (align) * (align))
...
...
Plugson/src/Core/ventoy_util_linux.c
View file @
293f677c
...
@@ -234,42 +234,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
...
@@ -234,42 +234,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
return
0
;
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
volatile
int
g_thread_stop
=
0
;
static
pthread_t
g_writeback_thread
;
static
pthread_t
g_writeback_thread
;
...
...
Plugson/src/Core/ventoy_util_windows.c
View file @
293f677c
...
@@ -683,75 +683,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
...
@@ -683,75 +683,6 @@ int ventoy_write_buf_to_file(const char *FileName, void *Bufer, int BufLen)
return
0
;
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
volatile
int
g_thread_stop
=
0
;
static
HANDLE
g_writeback_thread
;
static
HANDLE
g_writeback_thread
;
static
HANDLE
g_writeback_event
;
static
HANDLE
g_writeback_event
;
...
...
Plugson/src/main_windows.c
View file @
293f677c
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
#include <ventoy_disk.h>
#include <ventoy_disk.h>
#include <ventoy_http.h>
#include <ventoy_http.h>
char
g_ventoy_dir
[
MAX_PATH
];
static
BOOL
g_running
=
FALSE
;
static
BOOL
g_running
=
FALSE
;
static
HWND
g_refresh_button
;
static
HWND
g_refresh_button
;
static
HWND
g_start_button
;
static
HWND
g_start_button
;
...
@@ -34,6 +36,7 @@ typedef enum MSGID
...
@@ -34,6 +36,7 @@ typedef enum MSGID
MSGID_BTN_STOP_TIP
,
MSGID_BTN_STOP_TIP
,
MSGID_BTN_EXIT_TIP
,
MSGID_BTN_EXIT_TIP
,
MSGID_RUNNING_TIP
,
MSGID_RUNNING_TIP
,
MSGID_NO_TARXZ_TIP
,
MSGID_BUTT
MSGID_BUTT
}
MSGID
;
}
MSGID
;
...
@@ -56,6 +59,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
...
@@ -56,6 +59,7 @@ const WCHAR *g_msg_cn[MSGID_BUTT] =
L"停止运行后浏览器页面将会关闭,是否继续?"
,
L"停止运行后浏览器页面将会关闭,是否继续?"
,
L"当前服务正在运行,是否退出?"
,
L"当前服务正在运行,是否退出?"
,
L"请先关闭正在运行的 VentoyPlugson 程序!"
,
L"请先关闭正在运行的 VentoyPlugson 程序!"
,
L"ventoy
\\
plugson.tar.xz 文件不存在,请在正确的目录下运行!"
,
};
};
const
WCHAR
*
g_msg_en
[
MSGID_BUTT
]
=
const
WCHAR
*
g_msg_en
[
MSGID_BUTT
]
=
{
{
...
@@ -74,6 +78,7 @@ 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"The browser page will close after stop, continue?"
,
L"Service is running, continue?"
,
L"Service is running, continue?"
,
L"Please close another running VentoyPlugson instance!"
,
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
;
const
WCHAR
**
g_msg_lang
=
NULL
;
...
@@ -485,9 +490,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
...
@@ -485,9 +490,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
}
}
GetCurrentDirectoryA
(
MAX_PATH
,
g_cur_dir
);
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
);
sprintf_s
(
g_log_file
,
sizeof
(
g_log_file
),
"%s
\\
%s"
,
g_cur_dir
,
LOG_FILE
);
ventoy_log_init
();
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
);
ParseCmdLine
(
lpCmdLine
,
g_sysinfo
.
ip
,
g_sysinfo
.
port
);
if
(
g_sysinfo
.
ip
[
0
]
==
0
)
if
(
g_sysinfo
.
ip
[
0
]
==
0
)
...
...
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
View file @
293f677c
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment