mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[cmp] upgrade Bled to latest
This commit is contained in:
parent
72cfb89154
commit
c1613ab7fc
9 changed files with 36 additions and 18 deletions
|
@ -21,6 +21,8 @@ typedef long long int(*unpacker_t)(transformer_state_t *xstate);
|
||||||
smallint bb_got_signal;
|
smallint bb_got_signal;
|
||||||
uint64_t bb_total_rb;
|
uint64_t bb_total_rb;
|
||||||
printf_t bled_printf = NULL;
|
printf_t bled_printf = NULL;
|
||||||
|
read_t bled_read = NULL;
|
||||||
|
write_t bled_write = NULL;
|
||||||
progress_t bled_progress = NULL;
|
progress_t bled_progress = NULL;
|
||||||
unsigned long* bled_cancel_request;
|
unsigned long* bled_cancel_request;
|
||||||
static bool bled_initialized = 0;
|
static bool bled_initialized = 0;
|
||||||
|
@ -228,12 +230,15 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
|
||||||
* void progress_function(const uint64_t read_bytes);
|
* void progress_function(const uint64_t read_bytes);
|
||||||
* - point to an unsigned long variable, to be used to cancel operations when set to non zero
|
* - point to an unsigned long variable, to be used to cancel operations when set to non zero
|
||||||
*/
|
*/
|
||||||
int bled_init(printf_t print_function, progress_t progress_function, unsigned long* cancel_request)
|
int bled_init(printf_t print_function, read_t read_function, write_t write_function,
|
||||||
|
progress_t progress_function, unsigned long* cancel_request)
|
||||||
{
|
{
|
||||||
if (bled_initialized)
|
if (bled_initialized)
|
||||||
return -1;
|
return -1;
|
||||||
bled_initialized = true;
|
bled_initialized = true;
|
||||||
bled_printf = print_function;
|
bled_printf = print_function;
|
||||||
|
bled_read = read_function;
|
||||||
|
bled_write = write_function;
|
||||||
bled_progress = progress_function;
|
bled_progress = progress_function;
|
||||||
bled_cancel_request = cancel_request;
|
bled_cancel_request = cancel_request;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
typedef void (*printf_t) (const char* format, ...);
|
typedef void (*printf_t) (const char* format, ...);
|
||||||
typedef void (*progress_t) (const uint64_t read_bytes);
|
typedef void (*progress_t) (const uint64_t read_bytes);
|
||||||
|
typedef int (*read_t)(int fd, void* buf, unsigned int count);
|
||||||
|
typedef int (*write_t)(int fd, const void* buf, unsigned int count);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BLED_COMPRESSION_NONE = 0,
|
BLED_COMPRESSION_NONE = 0,
|
||||||
|
@ -46,11 +48,13 @@ int64_t bled_uncompress_from_buffer_to_buffer(const char* src, const size_t src_
|
||||||
* When the parameters are not NULL you can:
|
* When the parameters are not NULL you can:
|
||||||
* - specify the printf-like function you want to use to output message
|
* - specify the printf-like function you want to use to output message
|
||||||
* void print_function(const char* format, ...);
|
* void print_function(const char* format, ...);
|
||||||
|
* - specify the read/write functions you want to use;
|
||||||
* - specify the function you want to use to display progress, based on number of source archive bytes read
|
* - specify the function you want to use to display progress, based on number of source archive bytes read
|
||||||
* void progress_function(const uint64_t read_bytes);
|
* void progress_function(const uint64_t read_bytes);
|
||||||
* - point to an unsigned long variable, to be used to cancel operations when set to non zero
|
* - point to an unsigned long variable, to be used to cancel operations when set to non zero
|
||||||
*/
|
*/
|
||||||
int bled_init(printf_t print_function, progress_t progress_function, unsigned long* cancel_request);
|
int bled_init(printf_t print_function, read_t read_function, write_t write_function,
|
||||||
|
progress_t progress_function, unsigned long* cancel_request);
|
||||||
|
|
||||||
/* This call frees any resource used by the library */
|
/* This call frees any resource used by the library */
|
||||||
void bled_exit(void);
|
void bled_exit(void);
|
||||||
|
|
|
@ -125,6 +125,8 @@ typedef struct _llist_t {
|
||||||
|
|
||||||
extern void (*bled_printf) (const char* format, ...);
|
extern void (*bled_printf) (const char* format, ...);
|
||||||
extern void (*bled_progress) (const uint64_t processed_bytes);
|
extern void (*bled_progress) (const uint64_t processed_bytes);
|
||||||
|
extern int (*bled_read)(int fd, void* buf, unsigned int count);
|
||||||
|
extern int (*bled_write)(int fd, const void* buf, unsigned int count);
|
||||||
extern unsigned long* bled_cancel_request;
|
extern unsigned long* bled_cancel_request;
|
||||||
|
|
||||||
#define xfunc_die() longjmp(bb_error_jmp, 1)
|
#define xfunc_die() longjmp(bb_error_jmp, 1)
|
||||||
|
@ -159,9 +161,9 @@ static inline int fnmatch(const char *pattern, const char *string, int flags) {r
|
||||||
static inline pid_t wait(int* status) { *status = 4; return -1; }
|
static inline pid_t wait(int* status) { *status = 4; return -1; }
|
||||||
#define wait_any_nohang wait
|
#define wait_any_nohang wait
|
||||||
|
|
||||||
/* This override enables the display of a progress based on the number of bytes read */
|
/* This enables the display of a progress based on the number of bytes read */
|
||||||
extern uint64_t bb_total_rb;
|
extern uint64_t bb_total_rb;
|
||||||
static inline int full_read(int fd, void *buf, size_t count) {
|
static inline int full_read(int fd, void *buf, unsigned int count) {
|
||||||
int rb;
|
int rb;
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -179,12 +181,12 @@ static inline int full_read(int fd, void *buf, size_t count) {
|
||||||
|
|
||||||
if (fd == bb_virtual_fd) {
|
if (fd == bb_virtual_fd) {
|
||||||
if (bb_virtual_pos + count > bb_virtual_len)
|
if (bb_virtual_pos + count > bb_virtual_len)
|
||||||
count = bb_virtual_len - bb_virtual_pos;
|
count = (unsigned int)(bb_virtual_len - bb_virtual_pos);
|
||||||
memcpy(buf, &bb_virtual_buf[bb_virtual_pos], count);
|
memcpy(buf, &bb_virtual_buf[bb_virtual_pos], count);
|
||||||
bb_virtual_pos += count;
|
bb_virtual_pos += count;
|
||||||
rb = (int)count;
|
rb = (int)count;
|
||||||
} else {
|
} else {
|
||||||
rb = _read(fd, buf, (int)count);
|
rb = (bled_read != NULL) ? bled_read(fd, buf, count) : _read(fd, buf, count);
|
||||||
}
|
}
|
||||||
if (rb > 0) {
|
if (rb > 0) {
|
||||||
bb_total_rb += rb;
|
bb_total_rb += rb;
|
||||||
|
@ -194,13 +196,17 @@ static inline int full_read(int fd, void *buf, size_t count) {
|
||||||
return rb;
|
return rb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int full_write(int fd, const void* buffer, unsigned int count)
|
||||||
|
{
|
||||||
|
return (bled_write != NULL) ? bled_write(fd, buffer, count) : _write(fd, buffer, count);
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct tm *localtime_r(const time_t *timep, struct tm *result) {
|
static inline struct tm *localtime_r(const time_t *timep, struct tm *result) {
|
||||||
if (localtime_s(result, timep) != 0)
|
if (localtime_s(result, timep) != 0)
|
||||||
result = NULL;
|
result = NULL;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define full_write _write
|
|
||||||
#define safe_read full_read
|
#define safe_read full_read
|
||||||
#define lstat stat
|
#define lstat stat
|
||||||
#define xmalloc malloc
|
#define xmalloc malloc
|
||||||
|
|
|
@ -42,9 +42,12 @@ ssize_t FAST_FUNC transformer_write(transformer_state_t *xstate, const void *buf
|
||||||
memcpy(xstate->mem_output_buf + pos, buf, bufsize);
|
memcpy(xstate->mem_output_buf + pos, buf, bufsize);
|
||||||
xstate->mem_output_size += bufsize;
|
xstate->mem_output_size += bufsize;
|
||||||
} else {
|
} else {
|
||||||
nwrote = full_write(xstate->dst_fd, buf, (unsigned)bufsize);
|
nwrote = full_write(xstate->dst_fd, buf, (unsigned int)bufsize);
|
||||||
if (nwrote != (ssize_t)bufsize) {
|
if (nwrote != (ssize_t)bufsize) {
|
||||||
bb_perror_msg("write error - %d bytes written but %d expected", (int)nwrote, (int)bufsize);
|
if (nwrote < 0)
|
||||||
|
bb_perror_msg("write error: %d", (int)nwrote);
|
||||||
|
else
|
||||||
|
bb_perror_msg("write error: %d bytes written but %d expected", (int)nwrote, (int)bufsize);
|
||||||
nwrote = -1;
|
nwrote = -1;
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,7 +220,7 @@ static __inline uint64_t bswap_64(uint64_t x)
|
||||||
#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
|
#elif defined(BYTE_ORDER) && BYTE_ORDER == LITTLE_ENDIAN
|
||||||
# define BB_BIG_ENDIAN 0
|
# define BB_BIG_ENDIAN 0
|
||||||
# define BB_LITTLE_ENDIAN 1
|
# define BB_LITTLE_ENDIAN 1
|
||||||
#elif defined(__386__) || defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_ARM) || (defined(_M_ARM64))
|
#elif defined(__386__) || defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
|
||||||
# define BB_BIG_ENDIAN 0
|
# define BB_BIG_ENDIAN 0
|
||||||
# define BB_LITTLE_ENDIAN 1
|
# define BB_LITTLE_ENDIAN 1
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2262,7 +2262,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage)
|
||||||
|
|
||||||
if (img_report.compression_type != BLED_COMPRESSION_NONE) {
|
if (img_report.compression_type != BLED_COMPRESSION_NONE) {
|
||||||
uprintf("Writing compressed image...");
|
uprintf("Writing compressed image...");
|
||||||
bled_init(_uprintf, update_progress, &FormatStatus);
|
bled_init(_uprintf, NULL, NULL, update_progress, &FormatStatus);
|
||||||
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
bled_ret = bled_uncompress_with_handles(hSourceImage, hPhysicalDrive, img_report.compression_type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
if ((bled_ret < 0) && (SCODE_CODE(FormatStatus) != ERROR_CANCELLED)) {
|
if ((bled_ret < 0) && (SCODE_CODE(FormatStatus) != ERROR_CANCELLED)) {
|
||||||
|
|
|
@ -916,7 +916,7 @@ static DWORD WINAPI DownloadISOThread(LPVOID param)
|
||||||
free(sig);
|
free(sig);
|
||||||
uprintf("Signature is valid ✓");
|
uprintf("Signature is valid ✓");
|
||||||
uncompressed_size = *((uint64_t*)&compressed[5]);
|
uncompressed_size = *((uint64_t*)&compressed[5]);
|
||||||
if ((uncompressed_size < 1 * MB) && (bled_init(_uprintf, NULL, &FormatStatus) >= 0)) {
|
if ((uncompressed_size < 1 * MB) && (bled_init(_uprintf, NULL, NULL, NULL, &FormatStatus) >= 0)) {
|
||||||
fido_script = malloc((size_t)uncompressed_size);
|
fido_script = malloc((size_t)uncompressed_size);
|
||||||
size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA);
|
size = bled_uncompress_from_buffer_to_buffer(compressed, dwCompressedSize, fido_script, (size_t)uncompressed_size, BLED_COMPRESSION_LZMA);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.9.1589"
|
CAPTION "Rufus 3.9.1590"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -394,8 +394,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,9,1589,0
|
FILEVERSION 3,9,1590,0
|
||||||
PRODUCTVERSION 3,9,1589,0
|
PRODUCTVERSION 3,9,1590,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -413,13 +413,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.9.1589"
|
VALUE "FileVersion", "3.9.1590"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2019 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.9.exe"
|
VALUE "OriginalFilename", "rufus-3.9.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.9.1589"
|
VALUE "ProductVersion", "3.9.1590"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
|
@ -250,7 +250,7 @@ BOOL IsCompressedBootableImage(const char* path)
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
FormatStatus = 0;
|
FormatStatus = 0;
|
||||||
bled_init(_uprintf, NULL, &FormatStatus);
|
bled_init(_uprintf, NULL, NULL, NULL, &FormatStatus);
|
||||||
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
dc = bled_uncompress_to_buffer(path, (char*)buf, MBR_SIZE, file_assoc[i].type);
|
||||||
bled_exit();
|
bled_exit();
|
||||||
if (dc != MBR_SIZE) {
|
if (dc != MBR_SIZE) {
|
||||||
|
|
Loading…
Reference in a new issue