1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

Compare commits

..

2 commits

Author SHA1 Message Date
Pete Batard
e495c691ea
[misc] fix GitHub Actions' MinGW compilation 2022-01-05 12:51:29 +00:00
Pete Batard
c28f9bc491
[misc] fix PVS-Studio warnings 2022-01-05 12:57:26 +01:00
29 changed files with 327 additions and 288 deletions

1
.gitattributes vendored
View file

@ -4,6 +4,7 @@
*.in eol=lf *.in eol=lf
*.m4 eol=lf *.m4 eol=lf
missing eol=lf missing eol=lf
compile eol=lf
configure eol=lf configure eol=lf
install-sh eol=lf install-sh eol=lf
*.sln eol=crlf *.sln eol=crlf

View file

@ -48,6 +48,7 @@ jobs:
install: >- install: >-
mingw-w64-${{ matrix.env }}-toolchain mingw-w64-${{ matrix.env }}-toolchain
base-devel base-devel
autotools
git git
upx upx

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # install - install a program, script, or datafile
scriptversion=2009-04-28.21; # UTC scriptversion=2020-11-14.01; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
@ -35,25 +35,21 @@ scriptversion=2009-04-28.21; # UTC
# FSF changes to this file are in the public domain. # FSF changes to this file are in the public domain.
# #
# Calling this script install-sh is preferred over install.sh, to prevent # Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it # 'make' implicit rules from creating a file called install from it
# when there is no Makefile. # when there is no Makefile.
# #
# This script is compatible with the BSD install script, but was written # This script is compatible with the BSD install script, but was written
# from scratch. # from scratch.
tab=' '
nl=' nl='
' '
IFS=" "" $nl" IFS=" $tab$nl"
# set DOITPROG to echo to test this script # Set DOITPROG to "echo" to test this script.
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-} doit=${DOITPROG-}
if test -z "$doit"; then doit_exec=${doit:-exec}
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path; # Put in absolute file names if you don't have them in your path;
# or use environment vars. # or use environment vars.
@ -68,22 +64,16 @@ mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm} rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip} stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir= posix_mkdir=
# Desired mode of installed file. # Desired mode of installed file.
mode=0755 mode=0755
# Create dirs (including intermediate dirs) using mode 755.
# This is like GNU 'install' as of coreutils 8.32 (2020).
mkdir_umask=22
backupsuffix=
chgrpcmd= chgrpcmd=
chmodcmd=$chmodprog chmodcmd=$chmodprog
chowncmd= chowncmd=
@ -97,7 +87,7 @@ dir_arg=
dst_arg= dst_arg=
copy_on_change=false copy_on_change=false
no_target_directory= is_target_a_directory=possibly
usage="\ usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@ -114,18 +104,28 @@ Options:
--version display version info and exit. --version display version info and exit.
-c (ignored) -c (ignored)
-C install only if different (preserve the last data modification time) -C install only if different (preserve data modification time)
-d create directories instead of installing files. -d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP. -g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE. -m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER. -o USER $chownprog installed files to USER.
-p pass -p to $cpprog.
-s $stripprog installed files. -s $stripprog installed files.
-S SUFFIX attempt to back up existing files, with suffix SUFFIX.
-t DIRECTORY install into DIRECTORY. -t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory. -T report an error if DSTFILE is a directory.
Environment variables override the default commands: Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG RMPROG STRIPPROG
By default, rm is invoked with -f; when overridden with RMPROG,
it's up to you to specify -f if you want it.
If -S is not specified, no backups are attempted.
Email bug reports to bug-automake@gnu.org.
Automake home page: https://www.gnu.org/software/automake/
" "
while test $# -ne 0; do while test $# -ne 0; do
@ -143,8 +143,7 @@ while test $# -ne 0; do
-m) mode=$2 -m) mode=$2
case $mode in case $mode in
*' '* | *' '* | *' *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2 echo "$0: invalid mode: $mode" >&2
exit 1;; exit 1;;
esac esac
@ -153,12 +152,23 @@ while test $# -ne 0; do
-o) chowncmd="$chownprog $2" -o) chowncmd="$chownprog $2"
shift;; shift;;
-p) cpprog="$cpprog -p";;
-s) stripcmd=$stripprog;; -s) stripcmd=$stripprog;;
-t) dst_arg=$2 -S) backupsuffix="$2"
shift;; shift;;
-T) no_target_directory=true;; -t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;; --version) echo "$0 $scriptversion"; exit $?;;
@ -173,6 +183,16 @@ while test $# -ne 0; do
shift shift
done done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create. # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified. # When -t is used, the destination is already specified.
@ -186,6 +206,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi fi
shift # arg shift # arg
dst_arg=$arg dst_arg=$arg
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done done
fi fi
@ -194,13 +218,26 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2 echo "$0: no input file specified." >&2
exit 1 exit 1
fi fi
# It's OK to call `install-sh -d' without argument. # It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories. # This can happen when creating conditional directories.
exit 0 exit 0
fi fi
if test -z "$dir_arg"; then if test -z "$dir_arg"; then
trap '(exit $?); exit' 1 2 13 15 if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes. # Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps. # However, 'strip' requires both read and write access to temps.
@ -228,9 +265,9 @@ fi
for src for src
do do
# Protect names starting with `-'. # Protect names problematic for 'test' and other utilities.
case $src in case $src in
-*) src=./$src;; -* | [=\(\)!]) src=./$src;;
esac esac
if test -n "$dir_arg"; then if test -n "$dir_arg"; then
@ -238,6 +275,10 @@ do
dstdir=$dst dstdir=$dst
test -d "$dstdir" test -d "$dstdir"
dstdir_status=$? dstdir_status=$?
# Don't chown directories that already exist.
if test $dstdir_status = 0; then
chowncmd=""
fi
else else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
@ -252,77 +293,38 @@ do
echo "$0: no destination specified." >&2 echo "$0: no destination specified." >&2
exit 1 exit 1
fi fi
dst=$dst_arg dst=$dst_arg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst;;
esac
# If destination is a directory, append the input filename; won't work # If destination is a directory, append the input filename.
# if double slashes aren't ignored.
if test -d "$dst"; then if test -d "$dst"; then
if test -n "$no_target_directory"; then if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2 echo "$0: $dst_arg: Is a directory" >&2
exit 1 exit 1
fi fi
dstdir=$dst dstdir=$dst
dst=$dstdir/`basename "$src"` dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0 dstdir_status=0
else else
# Prefer dirname, but fall back on a substitute if dirname fails. dstdir=`dirname "$dst"`
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir" test -d "$dstdir"
dstdir_status=$? dstdir_status=$?
fi fi
fi fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false obsolete_mkdir_used=false
if test $dstdir_status != 0; then if test $dstdir_status != 0; then
case $posix_mkdir in case $posix_mkdir in
'') '')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode. # With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask. # Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then if test -n "$dir_arg"; then
@ -332,43 +334,49 @@ do
fi fi
posix_mkdir=false posix_mkdir=false
case $umask in # The $RANDOM variable is not portable (e.g., dash). Use it
*[123567][0-7][0-7]) # here however when possible just to lower collision chance.
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
trap '
ret=$?
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
exit $ret
' 0
# Because "mkdir -p" follows existing symlinks and we likely work
# directly in world-writeable /tmp, make sure that the '$tmpdir'
# directory is successfully created first before we actually test
# 'mkdir -p'.
if (umask $mkdir_umask && if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 $mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then then
if test -z "$dir_arg" || { if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m. # Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't. # other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"` test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;; d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;; d????-?--*) different_mode=755;;
*) false;; *) false;;
esac && esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && { $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"` ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
} }
} }
then posix_mkdir=: then posix_mkdir=:
fi fi
rmdir "$tmpdir/d" "$tmpdir" rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else else
# Remove any dirs left behind by ancient mkdir implementations. # Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi fi
trap '' 0;; trap '' 0;;
esac;;
esac esac
if if
@ -379,38 +387,36 @@ do
then : then :
else else
# The umask is ridiculous, or mkdir does not conform to POSIX, # mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the # or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go. # directory the slow way, step by step, checking for races as we go.
case $dstdir in case $dstdir in
/*) prefix='/';; /*) prefix='/';;
-*) prefix='./';; [-=\(\)!]*) prefix='./';;
*) prefix='';; *) prefix='';;
esac esac
eval "$initialize_posix_glob"
oIFS=$IFS oIFS=$IFS
IFS=/ IFS=/
$posix_glob set -f set -f
set fnord $dstdir set fnord $dstdir
shift shift
$posix_glob set +f set +f
IFS=$oIFS IFS=$oIFS
prefixes= prefixes=
for d for d
do do
test -z "$d" && continue test X"$d" = X && continue
prefix=$prefix$d prefix=$prefix$d
if test -d "$prefix"; then if test -d "$prefix"; then
prefixes= prefixes=
else else
if $posix_mkdir; then if $posix_mkdir; then
(umask=$mkdir_umask && (umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently. # Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1 test -d "$prefix" || exit 1
@ -443,14 +449,25 @@ do
else else
# Make a couple of temp file names in the proper directory. # Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_ dsttmp=${dstdirslash}_inst.$$_
rmtmp=$dstdir/_rm.$$_ rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit. # Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name. # Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && (umask $cp_umask &&
{ test -z "$stripcmd" || {
# Create $dsttmp read-write so that cp doesn't create it read-only,
# which would cause strip to fail.
if test -z "$doit"; then
: >"$dsttmp" # No need to fork-exec 'touch'.
else
$doit touch "$dsttmp"
fi
}
} &&
$doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits. # and set any options; do chmod last to preserve setuid bits.
# #
@ -467,18 +484,22 @@ do
if $copy_on_change && if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 && set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f && set +f &&
test "$old" = "$new" && test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then then
rm -f "$dsttmp" rm -f "$dsttmp"
else else
# If $backupsuffix is set, and the file being installed
# already exists, attempt a backup. Don't worry if it fails,
# e.g., if mv doesn't support -f.
if test -n "$backupsuffix" && test -f "$dst"; then
$doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
fi
# Rename the file to the real destination. # Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
@ -493,9 +514,9 @@ do
# file should still install successfully. # file should still install successfully.
{ {
test ! -f "$dst" || test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null || $doit $rmcmd "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
} || } ||
{ echo "$0: cannot unlink or rename $dst" >&2 { echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1 (exit 1); exit 1
@ -512,10 +533,9 @@ do
done done
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:

View file

@ -1064,9 +1064,10 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
safe_release_dc(GetDlgItem(hDlg, IDC_MD5), hDC); safe_release_dc(GetDlgItem(hDlg, IDC_MD5), hDC);
for (i=(int)safe_strlen(image_path); (i>0)&&(image_path[i]!='\\'); i--); if (image_path != NULL) {
if (image_path != NULL) // VS code analysis has a false positive on this one for (i = (int)strlen(image_path); (i > 0) && (image_path[i] != '\\'); i--);
SetWindowTextU(hDlg, &image_path[i + 1]); SetWindowTextU(hDlg, &image_path[i + 1]);
}
// Set focus on the OK button // Set focus on the OK button
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDOK), TRUE); SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDOK), TRUE);
CenterDialog(hDlg, NULL); CenterDialog(hDlg, NULL);

View file

@ -655,6 +655,7 @@ BOOL GetDevices(DWORD devnum)
} }
// Also test for "_SD&" instead of "_SD_" and so on to allow for devices like // Also test for "_SD&" instead of "_SD_" and so on to allow for devices like
// "SCSI\DiskRicoh_Storage_SD&REV_3.0" to be detected. // "SCSI\DiskRicoh_Storage_SD&REV_3.0" to be detected.
assert(strlen(scsi_card_name_copy) > 1);
scsi_card_name_copy[strlen(scsi_card_name_copy) - 1] = '&'; scsi_card_name_copy[strlen(scsi_card_name_copy) - 1] = '&';
if (safe_strstr(buffer, scsi_card_name_copy) != NULL) { if (safe_strstr(buffer, scsi_card_name_copy) != NULL) {
props.is_CARD = TRUE; props.is_CARD = TRUE;
@ -668,7 +669,7 @@ BOOL GetDevices(DWORD devnum)
if (!SetupDiGetDeviceInstanceIdA(dev_info, &dev_info_data, device_instance_id, if (!SetupDiGetDeviceInstanceIdA(dev_info, &dev_info_data, device_instance_id,
sizeof(device_instance_id), &size)) { sizeof(device_instance_id), &size)) {
uprintf("SetupDiGetDeviceInstanceId failed: %s", WindowsErrorString()); uprintf("SetupDiGetDeviceInstanceId failed: %s", WindowsErrorString());
static_strcpy(device_instance_id, "<N/A>"); strcpy(device_instance_id, "<N/A>");
} }
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* DOS keyboard locale setup * DOS keyboard locale setup
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie> * Copyright © 2011-2021 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -982,6 +982,7 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
kb = "us"; kb = "us";
kbdrv = bFreeDOS?fd_get_kbdrv(kb):ms_get_kbdrv(kb); // Always succeeds kbdrv = bFreeDOS?fd_get_kbdrv(kb):ms_get_kbdrv(kb); // Always succeeds
} }
assert(kbdrv >= 0);
uprintf("Will use DOS keyboard '%s' [%s]\n", kb, kb_to_hr(kb)); uprintf("Will use DOS keyboard '%s' [%s]\n", kb, kb_to_hr(kb));
// Now get a codepage // Now get a codepage

View file

@ -301,8 +301,8 @@ errcode_t ext2fs_get_free_blocks2(ext2_filsys fs, blk64_t start, blk64_t finish,
if (!num) if (!num)
num = 1; num = 1;
c_ratio = 1 << ext2fs_get_bitmap_granularity(map); c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
b &= ~(c_ratio - 1); b &= ~((blk64_t)c_ratio - 1);
finish &= ~(c_ratio -1); finish &= ~((blk64_t)c_ratio - 1);
do { do {
if (b + num - 1 >= ext2fs_blocks_count(fs->super)) { if (b + num - 1 >= ext2fs_blocks_count(fs->super)) {
if (finish > start) if (finish > start)

View file

@ -1438,7 +1438,7 @@ static errcode_t xattr_array_update(struct ext2_xattr_handle *h,
return 0; return 0;
} }
if (h->ibody_count <= old_idx) { if (old_idx >= 0 && h->ibody_count <= old_idx) {
block_free += EXT2_EXT_ATTR_LEN(name_len); block_free += EXT2_EXT_ATTR_LEN(name_len);
if (!h->attrs[old_idx].ea_ino) if (!h->attrs[old_idx].ea_ino)
block_free += block_free +=

View file

@ -357,13 +357,8 @@ ext2fs_file_write_inline_data(ext2_file_t file, const void *buf,
file->pos += count; file->pos += count;
/* Update inode size */ /* Update inode size */
if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos) { if (count != 0 && EXT2_I_SIZE(&file->inode) < file->pos)
errcode_t rc; retval = ext2fs_file_set_size2(file, file->pos);
rc = ext2fs_file_set_size2(file, file->pos);
if (retval == 0)
retval = rc;
}
if (written) if (written)
*written = count; *written = count;

View file

@ -117,7 +117,7 @@ errcode_t ext2fs_make_generic_bitmap(errcode_t magic, ext2_filsys fs,
} else } else
bitmap->description = 0; bitmap->description = 0;
size = (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1); size = (((size_t)bitmap->real_end - bitmap->start) / 8) + 1;
/* Round up to allow for the BT x86 instruction */ /* Round up to allow for the BT x86 instruction */
size = (size + 7) & ~3; size = (size + 7) & ~3;
retval = ext2fs_get_mem(size, &bitmap->bitmap); retval = ext2fs_get_mem(size, &bitmap->bitmap);
@ -303,7 +303,7 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap)
} }
memset(bitmap32->bitmap, 0, memset(bitmap32->bitmap, 0,
(size_t) (((bitmap32->real_end - bitmap32->start) / 8) + 1)); (((size_t)bitmap32->real_end - bitmap32->start) / 8) + 1);
} }
errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap, errcode_t ext2fs_fudge_generic_bitmap_end(ext2fs_inode_bitmap gen_bitmap,

View file

@ -87,10 +87,11 @@ void ext2fs_free_inode_cache(struct ext2_inode_cache *icache)
return; return;
if (icache->buffer) if (icache->buffer)
ext2fs_free_mem(&icache->buffer); ext2fs_free_mem(&icache->buffer);
if (icache->cache) {
for (i = 0; i < icache->cache_size; i++) for (i = 0; i < icache->cache_size; i++)
ext2fs_free_mem(&icache->cache[i].inode); ext2fs_free_mem(&icache->cache[i].inode);
if (icache->cache)
ext2fs_free_mem(&icache->cache); ext2fs_free_mem(&icache->cache);
}
icache->buffer_blk = 0; icache->buffer_blk = 0;
ext2fs_free_mem(&icache); ext2fs_free_mem(&icache);
} }

View file

@ -278,7 +278,7 @@ static __inline BOOLEAN _IsMounted(IN HANDLE Handle)
{ {
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
PF_INIT(NtFsControlFile, NtDll); PF_INIT(NtFsControlFile, NtDll);
return (pfNtFsControlFile == NULL) ? STATUS_DLL_NOT_FOUND : return (pfNtFsControlFile == NULL) ? FALSE :
(BOOLEAN)(pfNtFsControlFile(Handle, 0, 0, 0, &IoStatusBlock, FSCTL_IS_VOLUME_MOUNTED, 0, 0, 0, 0) == STATUS_SUCCESS); (BOOLEAN)(pfNtFsControlFile(Handle, 0, 0, 0, &IoStatusBlock, FSCTL_IS_VOLUME_MOUNTED, 0, 0, 0, 0) == STATUS_SUCCESS);
} }

View file

@ -1175,6 +1175,7 @@ static BOOL SetupWinPE(char drive_letter)
for (i=1; i<size-32; i++) { for (i=1; i<size-32; i++) {
for (j=0; j<ARRAYSIZE(patch_str_org); j++) { for (j=0; j<ARRAYSIZE(patch_str_org); j++) {
if (safe_strnicmp(&buffer[i], patch_str_org[j], strlen(patch_str_org[j])-1) == 0) { if (safe_strnicmp(&buffer[i], patch_str_org[j], strlen(patch_str_org[j])-1) == 0) {
assert(index < 2);
uprintf(" 0x%08X: '%s' -> '%s'\n", i, &buffer[i], patch_str_rep[index][j]); uprintf(" 0x%08X: '%s' -> '%s'\n", i, &buffer[i], patch_str_rep[index][j]);
strcpy(&buffer[i], patch_str_rep[index][j]); strcpy(&buffer[i], patch_str_rep[index][j]);
i += (DWORD)max(strlen(patch_str_org[j]), strlen(patch_str_rep[index][j])); // in case org is a substring of rep i += (DWORD)max(strlen(patch_str_org[j]), strlen(patch_str_rep[index][j])); // in case org is a substring of rep
@ -2093,6 +2094,7 @@ DWORD WINAPI FormatThread(void* param)
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
PrintInfoDebug(0, MSG_227); PrintInfoDebug(0, MSG_227);
if (!CloseHandle(hLogicalVolume)) { if (!CloseHandle(hLogicalVolume)) {
hLogicalVolume = INVALID_HANDLE_VALUE;
uprintf("Could not close volume: %s", WindowsErrorString()); uprintf("Could not close volume: %s", WindowsErrorString());
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_ACCESS_DENIED;
goto out; goto out;

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* extfs formatting * extfs formatting
* Copyright © 2019-2020 Pete Batard <pete@akeo.ie> * Copyright © 2019-2021 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -212,6 +212,7 @@ const char* GetExtFsLabel(DWORD DriveIndex, uint64_t PartitionOffset)
r = ext2fs_open(volume_name, EXT2_FLAG_SKIP_MMP, 0, 0, manager, &ext2fs); r = ext2fs_open(volume_name, EXT2_FLAG_SKIP_MMP, 0, 0, manager, &ext2fs);
free(volume_name); free(volume_name);
if (r == 0) { if (r == 0) {
assert(ext2fs != NULL);
strncpy(label, ext2fs->super->s_volume_name, EXT2_LABEL_LEN); strncpy(label, ext2fs->super->s_volume_name, EXT2_LABEL_LEN);
label[EXT2_LABEL_LEN] = 0; label[EXT2_LABEL_LEN] = 0;
} }

View file

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Large FAT32 formatting * Large FAT32 formatting
* Copyright © 2007-2009 Tom Thornhill/Ridgecrop * Copyright © 2007-2009 Tom Thornhill/Ridgecrop
* Copyright © 2011-2020 Pete Batard <pete@akeo.ie> * Copyright © 2011-2021 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -414,7 +414,7 @@ BOOL FormatLargeFAT32(DWORD DriveIndex, uint64_t PartitionOffset, DWORD ClusterS
} }
for (i = 0; i < (SystemAreaSize + BurstSize - 1); i += BurstSize) { for (i = 0; i < (SystemAreaSize + BurstSize - 1); i += BurstSize) {
UpdateProgressWithInfo(OP_FORMAT, MSG_217, (uint64_t)i, (uint64_t)(SystemAreaSize + BurstSize)); UpdateProgressWithInfo(OP_FORMAT, MSG_217, (uint64_t)i, (uint64_t)SystemAreaSize + BurstSize);
CHECK_FOR_USER_CANCEL; CHECK_FOR_USER_CANCEL;
if (write_sectors(hLogicalVolume, BytesPerSect, i, BurstSize, pZeroSect) != (BytesPerSect * BurstSize)) { if (write_sectors(hLogicalVolume, BytesPerSect, i, BurstSize, pZeroSect) != (BytesPerSect * BurstSize)) {
die("Error clearing reserved sectors", ERROR_WRITE_FAULT); die("Error clearing reserved sectors", ERROR_WRITE_FAULT);

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Extract icon from executable and set autorun.inf * Extract icon from executable and set autorun.inf
* Copyright © 2012-2019 Pete Batard <pete@akeo.ie> * Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,6 +26,7 @@
#include <windows.h> #include <windows.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h" #include "missing.h"
@ -185,6 +186,7 @@ BOOL SetAutorun(const char* path)
uprintf("Created: %s", filename); uprintf("Created: %s", filename);
// .inf -> .ico // .inf -> .ico
assert(strlen(filename) >= 2);
filename[strlen(filename) - 1] = 'o'; filename[strlen(filename) - 1] = 'o';
filename[strlen(filename) - 2] = 'c'; filename[strlen(filename) - 2] = 'c';
return ExtractAppIcon(filename, FALSE); return ExtractAppIcon(filename, FALSE);

View file

@ -180,7 +180,7 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const
// Check for archiso loader/entries/*.conf files // Check for archiso loader/entries/*.conf files
if (safe_stricmp(psz_dirname, "/loader/entries") == 0) { if (safe_stricmp(psz_dirname, "/loader/entries") == 0) {
len = strlen(psz_basename); len = safe_strlen(psz_basename);
props->is_conf = ((len > 4) && (stricmp(&psz_basename[len - 5], ".conf") == 0)); props->is_conf = ((len > 4) && (stricmp(&psz_basename[len - 5], ".conf") == 0));
} }
@ -863,7 +863,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
size_t i, j, size, sl_index = 0; size_t i, j, size, sl_index = 0;
uint16_t sl_version; uint16_t sl_version;
FILE* fd; FILE* fd;
int r = 1; int k, r = 1;
iso9660_t* p_iso = NULL; iso9660_t* p_iso = NULL;
iso9660_pvd_t pvd; iso9660_pvd_t pvd;
udf_t* p_udf = NULL; udf_t* p_udf = NULL;
@ -969,8 +969,8 @@ out:
if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0)) if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0))
img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size; img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size;
// Remove trailing spaces from the label // Remove trailing spaces from the label
for (j=safe_strlen(img_report.label)-1; ((j>0)&&(isspaceU(img_report.label[j]))); j--) for (k=(int)safe_strlen(img_report.label)-1; ((k>0)&&(isspaceU(img_report.label[k]))); k--)
img_report.label[j] = 0; img_report.label[k] = 0;
// We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here // We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here
img_report.projected_size = total_blocks * ISO_BLOCKSIZE; img_report.projected_size = total_blocks * ISO_BLOCKSIZE;
// We will link the existing isolinux.cfg from a syslinux.cfg we create // We will link the existing isolinux.cfg from a syslinux.cfg we create

View file

@ -937,7 +937,7 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir,
if (su_length % 2) if (su_length % 2)
su_length--; su_length--;
if (su_length < 0 || su_length < sizeof (iso9660_xa_t)) if (su_length < sizeof (iso9660_xa_t))
return p_stat; return p_stat;
if (nope == b_xa) { if (nope == b_xa) {

View file

@ -89,12 +89,12 @@ static __inline uint8_t popcnt8(uint8_t val)
static __inline uint8_t popcnt64(register uint64_t u) static __inline uint8_t popcnt64(register uint64_t u)
{ {
u = (u & 0x5555555555555555) + ((u >> 1) & 0x5555555555555555); u = (u & 0x5555555555555555ULL) + ((u >> 1) & 0x5555555555555555ULL);
u = (u & 0x3333333333333333) + ((u >> 2) & 0x3333333333333333); u = (u & 0x3333333333333333ULL) + ((u >> 2) & 0x3333333333333333ULL);
u = (u & 0x0f0f0f0f0f0f0f0f) + ((u >> 4) & 0x0f0f0f0f0f0f0f0f); u = (u & 0x0f0f0f0f0f0f0f0fULL) + ((u >> 4) & 0x0f0f0f0f0f0f0f0fULL);
u = (u & 0x00ff00ff00ff00ff) + ((u >> 8) & 0x00ff00ff00ff00ff); u = (u & 0x00ff00ff00ff00ffULL) + ((u >> 8) & 0x00ff00ff00ff00ffULL);
u = (u & 0x0000ffff0000ffff) + ((u >> 16) & 0x0000ffff0000ffff); u = (u & 0x0000ffff0000ffffULL) + ((u >> 16) & 0x0000ffff0000ffffULL);
u = (u & 0x00000000ffffffff) + ((u >> 32) & 0x00000000ffffffff); u = (u & 0x00000000ffffffffULL) + ((u >> 32) & 0x00000000ffffffffULL);
return (uint8_t)u; return (uint8_t)u;
} }

View file

@ -821,7 +821,7 @@ static __inline int SHDeleteDirectoryExU(HWND hwnd, const char* pszPath, FILEOP_
int ret; int ret;
// String needs to be double NULL terminated, so we just use the length of the UTF-8 string // String needs to be double NULL terminated, so we just use the length of the UTF-8 string
// which is always expected to be larger than our UTF-16 one, and add 2 chars for good measure. // which is always expected to be larger than our UTF-16 one, and add 2 chars for good measure.
size_t wpszPath_len = strlen(pszPath) + 2; size_t wpszPath_len = (pszPath == NULL) ? 0 : strlen(pszPath) + 2;
// coverity[returned_null] // coverity[returned_null]
walloc(pszPath, wpszPath_len); walloc(pszPath, wpszPath_len);
SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL }; SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL };

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Elementary Unicode compliant find/replace parser * Elementary Unicode compliant find/replace parser
* Copyright © 2012-2020 Pete Batard <pete@akeo.ie> * Copyright © 2012-2021 Pete Batard <pete@akeo.ie>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -796,12 +796,19 @@ char* set_token_data_file(const char* token, const char* data, const char* filen
} }
out: out:
if (fd_in != NULL) fclose(fd_in); if (fd_in != NULL) {
if (fd_out != NULL) fclose(fd_out); fclose(fd_in);
fd_in = NULL;
}
if (fd_out != NULL) {
fclose(fd_out);
fd_out = NULL;
}
// If an insertion occurred, delete existing file and use the new one // If an insertion occurred, delete existing file and use the new one
if (ret != NULL) { if (ret != NULL) {
// We're in Windows text mode => Remove CRs if requested // We're in Windows text mode => Remove CRs if requested
if (wtmpname != NULL)
fd_in = _wfopen(wtmpname, L"rb"); fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb"); fd_out = _wfopen(wfilename, L"wb");
// Don't check fds // Don't check fds
@ -1052,7 +1059,7 @@ out:
if (fd_out != NULL) fclose(fd_out); if (fd_out != NULL) fclose(fd_out);
// If an insertion occurred, delete existing file and use the new one // If an insertion occurred, delete existing file and use the new one
if (ret != NULL) { if (ret != NULL && wtmpname != NULL && wfilename != NULL) {
// We're in Windows text mode => Remove CRs if requested // We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb"); fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb"); fd_out = _wfopen(wfilename, L"wb");
@ -1229,7 +1236,7 @@ out:
if (fd_out != NULL) fclose(fd_out); if (fd_out != NULL) fclose(fd_out);
// If a replacement occurred, delete existing file and use the new one // If a replacement occurred, delete existing file and use the new one
if (ret != NULL) { if (ret != NULL && wtmpname != NULL && wfilename != NULL) {
// We're in Windows text mode => Remove CRs if requested // We're in Windows text mode => Remove CRs if requested
fd_in = _wfopen(wtmpname, L"rb"); fd_in = _wfopen(wtmpname, L"rb");
fd_out = _wfopen(wfilename, L"wb"); fd_out = _wfopen(wfilename, L"wb");

View file

@ -4,7 +4,7 @@
* *
* Modified from Process Hacker: * Modified from Process Hacker:
* https://github.com/processhacker2/processhacker2/ * https://github.com/processhacker2/processhacker2/
* Copyright © 2017-2020 Pete Batard <pete@akeo.ie> * Copyright © 2017-2021 Pete Batard <pete@akeo.ie>
* Copyright © 2017 dmex * Copyright © 2017 dmex
* Copyright © 2009-2016 wj32 * Copyright © 2009-2016 wj32
* *
@ -506,6 +506,9 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
if (i >= handles->NumberOfHandles) if (i >= handles->NumberOfHandles)
break; break;
if (handleInfo == NULL)
continue;
// Don't bother with processes we can't access // Don't bother with processes we can't access
if (handleInfo->UniqueProcessId == last_access_denied_pid) if (handleInfo->UniqueProcessId == last_access_denied_pid)
continue; continue;
@ -609,7 +612,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
// The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later) // The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later)
if (!bGotCmdLine) { if (!bGotCmdLine) {
bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size); bGotCmdLine = (QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size) != FALSE);
if (bGotCmdLine) if (bGotCmdLine)
wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline)); wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline));
} }

View file

@ -751,9 +751,6 @@ static void EnableMBRBootOptions(BOOL enable, BOOL remove_checkboxes)
actual_enable_mbr = FALSE; actual_enable_mbr = FALSE;
mbr_selected_by_user = FALSE; mbr_selected_by_user = FALSE;
} }
if (boot_type == BT_NON_BOOTABLE) {
actual_enable_fix = FALSE;
}
} }
if (remove_checkboxes) { if (remove_checkboxes) {
@ -1135,6 +1132,7 @@ static void DisplayISOProps(void)
PRINT_ISO_PROP(HAS_WINPE(img_report), " Uses: WinPE %s", (img_report.uses_minint) ? "(with /minint)" : ""); PRINT_ISO_PROP(HAS_WINPE(img_report), " Uses: WinPE %s", (img_report.uses_minint) ? "(with /minint)" : "");
if (HAS_WININST(img_report)) { if (HAS_WININST(img_report)) {
inst_str[4] = '0' + img_report.wininst_index; inst_str[4] = '0' + img_report.wininst_index;
assert(strlen(img_report.wininst_path[0]) >= 3);
uprintf(" Uses: Install.%s%s (version %d.%d.%d%s)", &img_report.wininst_path[0][strlen(img_report.wininst_path[0]) - 3], uprintf(" Uses: Install.%s%s (version %d.%d.%d%s)", &img_report.wininst_path[0][strlen(img_report.wininst_path[0]) - 3],
(img_report.wininst_index > 1) ? inst_str : "", (img_report.wininst_version >> 24) & 0xff, (img_report.wininst_index > 1) ? inst_str : "", (img_report.wininst_version >> 24) & 0xff,
(img_report.wininst_version >> 16) & 0xff, (img_report.wininst_version >> 8) & 0xff, (img_report.wininst_version >> 16) & 0xff, (img_report.wininst_version >> 8) & 0xff,
@ -2218,6 +2216,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
static SHChangeNotifyEntry NotifyEntry; static SHChangeNotifyEntry NotifyEntry;
static DWORD_PTR thread_affinity[CHECKSUM_MAX + 1]; static DWORD_PTR thread_affinity[CHECKSUM_MAX + 1];
static HFONT hyperlink_font = NULL; static HFONT hyperlink_font = NULL;
static wchar_t wtooltip[128];
LONG lPos; LONG lPos;
BOOL set_selected_fs; BOOL set_selected_fs;
DRAWITEMSTRUCT* pDI; DRAWITEMSTRUCT* pDI;
@ -2234,7 +2233,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
char tmp[MAX_PATH], *log_buffer = NULL; char tmp[MAX_PATH], *log_buffer = NULL;
wchar_t* wbuffer = NULL; wchar_t* wbuffer = NULL;
loc_cmd* lcmd = NULL; loc_cmd* lcmd = NULL;
wchar_t wtooltip[128];
switch (message) { switch (message) {

View file

@ -132,7 +132,7 @@
#ifndef STRINGIFY #ifndef STRINGIFY
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#endif #endif
#define PERCENTAGE(percent, value) ((1ULL * percent * value) / 100ULL) #define PERCENTAGE(percent, value) ((1ULL * (percent) * (value)) / 100ULL)
#define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED) #define IsChecked(CheckBox_ID) (IsDlgButtonChecked(hMainDialog, CheckBox_ID) == BST_CHECKED)
#define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0) #define MB_IS_RTL (right_to_left_mode?MB_RTLREADING|MB_RIGHT:0)
#define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) goto out #define CHECK_FOR_USER_CANCEL if (IS_ERROR(FormatStatus) && (SCODE_CODE(FormatStatus) == ERROR_CANCELLED)) goto out
@ -149,7 +149,7 @@
((char*)(dst))[safe_min(count, dst_max)-1] = 0;} while(0) ((char*)(dst))[safe_min(count, dst_max)-1] = 0;} while(0)
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1) #define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src) #define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src)
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1)) #define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, (dst_max) - safe_strlen(dst) - 1))
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1) #define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src) #define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src)
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) #define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
@ -178,7 +178,7 @@ extern void _uprintfs(const char *str);
#define vvuprintf(...) do { if (verbose > 1) _uprintf(__VA_ARGS__); } while(0) #define vvuprintf(...) do { if (verbose > 1) _uprintf(__VA_ARGS__); } while(0)
#define suprintf(...) do { if (!bSilent) _uprintf(__VA_ARGS__); } while(0) #define suprintf(...) do { if (!bSilent) _uprintf(__VA_ARGS__); } while(0)
#define uuprintf(...) do { if (usb_debug) _uprintf(__VA_ARGS__); } while(0) #define uuprintf(...) do { if (usb_debug) _uprintf(__VA_ARGS__); } while(0)
#define ubprintf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 2, __VA_ARGS__); \ #define ubprintf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 4, __VA_ARGS__); \
ubuffer_pos = strlen(ubuffer); ubuffer[ubuffer_pos++] = '\r'; ubuffer[ubuffer_pos++] = '\n'; \ ubuffer_pos = strlen(ubuffer); ubuffer[ubuffer_pos++] = '\r'; ubuffer[ubuffer_pos++] = '\n'; \
ubuffer[ubuffer_pos] = 0; } while(0) ubuffer[ubuffer_pos] = 0; } while(0)
#define ubflush() do { if (ubuffer_pos) uprintf("%s", ubuffer); ubuffer_pos = 0; } while(0) #define ubflush() do { if (ubuffer_pos) uprintf("%s", ubuffer); ubuffer_pos = 0; } while(0)
@ -389,7 +389,7 @@ typedef struct {
BOOLEAN has_kolibrios; BOOLEAN has_kolibrios;
BOOLEAN uses_casper; BOOLEAN uses_casper;
BOOLEAN uses_minint; BOOLEAN uses_minint;
BOOLEAN compression_type; uint8_t compression_type;
winver_t win_version; // Windows ISO version winver_t win_version; // Windows ISO version
uint16_t sl_version; // Syslinux/Isolinux version uint16_t sl_version; // Syslinux/Isolinux version
char sl_version_str[12]; char sl_version_str[12];

View file

@ -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.18.1854" CAPTION "Rufus 3.18.1856"
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
@ -395,8 +395,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,18,1854,0 FILEVERSION 3,18,1856,0
PRODUCTVERSION 3,18,1854,0 PRODUCTVERSION 3,18,1856,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -414,13 +414,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.18.1854" VALUE "FileVersion", "3.18.1856"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2021 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.18.exe" VALUE "OriginalFilename", "rufus-3.18.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.18.1854" VALUE "ProductVersion", "3.18.1856"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -662,7 +662,7 @@ const char *WindowsErrorString(void)
size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
HRESULT_CODE(error_code), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), HRESULT_CODE(error_code), MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
&err_string[presize], sizeof(err_string)-(DWORD)strlen(err_string), NULL); &err_string[presize], (DWORD)(sizeof(err_string)-strlen(err_string)), NULL);
if (size == 0) { if (size == 0) {
format_error = GetLastError(); format_error = GetLastError();
if ((format_error) && (format_error != ERROR_MR_MID_NOT_FOUND) && (format_error != ERROR_MUI_FILE_NOT_LOADED)) if ((format_error) && (format_error != ERROR_MR_MID_NOT_FOUND) && (format_error != ERROR_MUI_FILE_NOT_LOADED))

View file

@ -155,9 +155,12 @@ void BrowseForFolder(void) {
dialog_showing++; dialog_showing++;
hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC, hr = CoCreateInstance(&CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
&IID_IFileOpenDialog, (LPVOID)&pfod); &IID_IFileOpenDialog, (LPVOID)&pfod);
if (FAILED(hr)) { if (FAILED(hr) || pfod == NULL) {
uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr); uprintf("CoCreateInstance for FileOpenDialog failed: error %X\n", hr);
if (pfod != NULL) {
IFileOpenDialog_Release(pfod);
pfod = NULL; // Just in case pfod = NULL; // Just in case
}
goto fallback; goto fallback;
} }
hr = IFileOpenDialog_SetOptions(pfod, FOS_PICKFOLDERS); hr = IFileOpenDialog_SetOptions(pfod, FOS_PICKFOLDERS);
@ -180,7 +183,7 @@ void BrowseForFolder(void) {
} }
hr = SHCreateItemFromParsingName(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path); hr = SHCreateItemFromParsingName(wpath, NULL, &IID_IShellItem, (LPVOID)&si_path);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr) && pfod != NULL) {
if (wpath != NULL) { if (wpath != NULL) {
IFileOpenDialog_SetFolder(pfod, si_path); IFileOpenDialog_SetFolder(pfod, si_path);
} }
@ -191,7 +194,7 @@ void BrowseForFolder(void) {
safe_free(wpath); safe_free(wpath);
hr = IFileOpenDialog_Show(pfod, hMainDialog); hr = IFileOpenDialog_Show(pfod, hMainDialog);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr) && pfod != NULL) {
hr = IFileOpenDialog_GetResult(pfod, &psi); hr = IFileOpenDialog_GetResult(pfod, &psi);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
IShellItem_GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath); IShellItem_GetDisplayName(psi, SIGDN_FILESYSPATH, &wpath);
@ -277,7 +280,10 @@ char* FileDialog(BOOL save, char* path, const ext_t* ext, DWORD options)
if (FAILED(hr)) { if (FAILED(hr)) {
SetLastError(hr); SetLastError(hr);
uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString()); uprintf("CoCreateInstance for FileOpenDialog failed: %s\n", WindowsErrorString());
if (pfd != NULL) {
IFileDialog_Release(pfd);
pfd = NULL; // Just in case pfd = NULL; // Just in case
}
goto fallback; goto fallback;
} }
@ -789,8 +795,8 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case IDC_MORE_INFO: case IDC_MORE_INFO:
assert(notification_more_info->callback != NULL);
if (notification_more_info != NULL) { if (notification_more_info != NULL) {
assert(notification_more_info->callback != NULL);
if (notification_more_info->id == MORE_INFO_URL) { if (notification_more_info->id == MORE_INFO_URL) {
ShellExecuteA(hDlg, "open", notification_more_info->url, NULL, NULL, SW_SHOWNORMAL); ShellExecuteA(hDlg, "open", notification_more_info->url, NULL, NULL, SW_SHOWNORMAL);
} else { } else {
@ -1613,7 +1619,7 @@ BOOL SetUpdateCheck(void)
} }
// If the user hasn't set the interval in the dialog, set to default // If the user hasn't set the interval in the dialog, set to default
if ( (ReadSetting32(SETTING_UPDATE_INTERVAL) == 0) || if ( (ReadSetting32(SETTING_UPDATE_INTERVAL) == 0) ||
((ReadSetting32(SETTING_UPDATE_INTERVAL) == -1) && enable_updates) ) (ReadSetting32(SETTING_UPDATE_INTERVAL) == -1) )
WriteSetting32(SETTING_UPDATE_INTERVAL, 86400); WriteSetting32(SETTING_UPDATE_INTERVAL, 86400);
} }
SetFidoCheck(); SetFidoCheck();
@ -2005,7 +2011,7 @@ static BOOL CALLBACK AlertPromptCallback(HWND hWnd, LPARAM lParam)
if (GetWindowTextU(hWnd, str, sizeof(str)) == 0) if (GetWindowTextU(hWnd, str, sizeof(str)) == 0)
return TRUE; return TRUE;
if (safe_strcmp(str, button_str) == 0) if (strcmp(str, button_str) == 0)
*found = TRUE; *found = TRUE;
return TRUE; return TRUE;
} }

View file

@ -194,7 +194,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
} }
/* Create ldlinux.sys file */ /* Create ldlinux.sys file */
static_sprintf(path, "%C:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[0]); static_sprintf(path, "%c:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[0]);
f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE, f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, NULL, CREATE_ALWAYS,
@ -236,7 +236,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
switch (file_system) { switch (file_system) {
case FS_NTFS: case FS_NTFS:
static_sprintf(tmp, "%C:\\", drive_letter); static_sprintf(tmp, "%c:\\", drive_letter);
vol_info.Handle = d_handle; vol_info.Handle = d_handle;
err = NtfsSectGetVolumeInfo(tmp, &vol_info); err = NtfsSectGetVolumeInfo(tmp, &vol_info);
if (err != ERROR_SUCCESS) { if (err != ERROR_SUCCESS) {
@ -333,7 +333,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
IGNORE_RETVAL(_chdirU(app_data_dir)); IGNORE_RETVAL(_chdirU(app_data_dir));
static_sprintf(path, "%s\\%s-%s", FILES_DIR, syslinux, embedded_sl_version_str[1]); static_sprintf(path, "%s\\%s-%s", FILES_DIR, syslinux, embedded_sl_version_str[1]);
IGNORE_RETVAL(_chdir(path)); IGNORE_RETVAL(_chdir(path));
static_sprintf(path, "%C:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[2]); static_sprintf(path, "%c:\\%s.%s", drive_letter, ldlinux, ldlinux_ext[2]);
fd = fopen(&path[3], "rb"); fd = fopen(&path[3], "rb");
if (fd == NULL) { if (fd == NULL) {
uprintf("Caution: No '%s' was provided. The target will be missing a required Syslinux file!", &path[3]); uprintf("Caution: No '%s' was provided. The target will be missing a required Syslinux file!", &path[3]);
@ -354,7 +354,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
goto out; goto out;
} }
/* Create mboot.c32 file */ /* Create mboot.c32 file */
static_sprintf(path, "%C:\\%s", drive_letter, mboot_c32); static_sprintf(path, "%c:\\%s", drive_letter, mboot_c32);
f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE, f_handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@ -368,7 +368,7 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system)
goto out; goto out;
} }
safe_closehandle(f_handle); safe_closehandle(f_handle);
static_sprintf(path, "%C:\\syslinux.cfg", drive_letter); static_sprintf(path, "%c:\\syslinux.cfg", drive_letter);
fd = fopen(path, "w"); fd = fopen(path, "w");
if (fd == NULL) { if (fd == NULL) {
uprintf("Could not create ReactOS 'syslinux.cfg'"); uprintf("Could not create ReactOS 'syslinux.cfg'");

View file

@ -575,8 +575,9 @@ void SetSectionHeaders(HWND hDlg)
SendDlgItemMessageA(hDlg, section_control_ids[i], WM_SETFONT, (WPARAM)hf, TRUE); SendDlgItemMessageA(hDlg, section_control_ids[i], WM_SETFONT, (WPARAM)hf, TRUE);
hCtrl = GetDlgItem(hDlg, section_control_ids[i]); hCtrl = GetDlgItem(hDlg, section_control_ids[i]);
memset(wtmp, 0, sizeof(wtmp)); memset(wtmp, 0, sizeof(wtmp));
GetWindowTextW(hCtrl, wtmp, ARRAYSIZE(wtmp) - 3); GetWindowTextW(hCtrl, wtmp, ARRAYSIZE(wtmp) - 4);
wlen = wcslen(wtmp); wlen = wcslen(wtmp);
assert(wlen < ARRAYSIZE(wtmp - 2));
wtmp[wlen++] = L' '; wtmp[wlen++] = L' ';
wtmp[wlen++] = L' '; wtmp[wlen++] = L' ';
SetWindowTextW(hCtrl, wtmp); SetWindowTextW(hCtrl, wtmp);
@ -788,8 +789,7 @@ void ToggleImageOptions(void)
if (image_option_txt[0] == 0) if (image_option_txt[0] == 0)
GetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt, sizeof(image_option_txt)); GetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), image_option_txt, sizeof(image_option_txt));
if ( ((has_wintogo) && !(image_options & IMOP_WINTOGO)) || if ((has_wintogo) != (image_options & IMOP_WINTOGO)) {
((!has_wintogo) && (image_options & IMOP_WINTOGO)) ) {
image_options ^= IMOP_WINTOGO; image_options ^= IMOP_WINTOGO;
if (image_options & IMOP_WINTOGO) { if (image_options & IMOP_WINTOGO) {
// Set the Windows To Go selection in the dropdown // Set the Windows To Go selection in the dropdown
@ -797,8 +797,7 @@ void ToggleImageOptions(void)
} }
} }
if (((has_persistence) && !(image_options & IMOP_PERSISTENCE)) || if ((has_persistence) != (image_options & IMOP_PERSISTENCE)) {
((!has_persistence) && (image_options & IMOP_PERSISTENCE))) {
image_options ^= IMOP_PERSISTENCE; image_options ^= IMOP_PERSISTENCE;
if (image_options & IMOP_PERSISTENCE) { if (image_options & IMOP_PERSISTENCE) {
SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_123)); SetWindowTextU(GetDlgItem(hMainDialog, IDS_IMAGE_OPTION_TXT), lmprintf(MSG_123));
@ -1069,7 +1068,7 @@ void CreateAdditionalControls(HWND hDlg)
hAdvancedDeviceToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE, hAdvancedDeviceToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_DEVICE_TOOLBAR, hMainInstance, NULL); 0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_DEVICE_TOOLBAR, hMainInstance, NULL);
SendMessage(hAdvancedDeviceToolbar, CCM_SETVERSION, (WPARAM)6, 0); SendMessage(hAdvancedDeviceToolbar, CCM_SETVERSION, (WPARAM)6, 0);
memset(tbToolbarButtons, 0, sizeof(TBBUTTON)); memset(tbToolbarButtons, 0, sizeof(tbToolbarButtons));
tbToolbarButtons[0].idCommand = IDC_ADVANCED_DRIVE_PROPERTIES; tbToolbarButtons[0].idCommand = IDC_ADVANCED_DRIVE_PROPERTIES;
tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE; tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE;
tbToolbarButtons[0].fsState = TBSTATE_ENABLED; tbToolbarButtons[0].fsState = TBSTATE_ENABLED;
@ -1091,7 +1090,7 @@ void CreateAdditionalControls(HWND hDlg)
hAdvancedFormatToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE, hAdvancedFormatToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, TOOLBAR_STYLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_FORMAT_TOOLBAR, hMainInstance, NULL); 0, 0, 0, 0, hMainDialog, (HMENU)IDC_ADVANCED_FORMAT_TOOLBAR, hMainInstance, NULL);
SendMessage(hAdvancedFormatToolbar, CCM_SETVERSION, (WPARAM)6, 0); SendMessage(hAdvancedFormatToolbar, CCM_SETVERSION, (WPARAM)6, 0);
memset(tbToolbarButtons, 0, sizeof(TBBUTTON)); memset(tbToolbarButtons, 0, sizeof(tbToolbarButtons));
tbToolbarButtons[0].idCommand = IDC_ADVANCED_FORMAT_OPTIONS; tbToolbarButtons[0].idCommand = IDC_ADVANCED_FORMAT_OPTIONS;
tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE; tbToolbarButtons[0].fsStyle = BTNS_SHOWTEXT | BTNS_AUTOSIZE;
tbToolbarButtons[0].fsState = TBSTATE_ENABLED; tbToolbarButtons[0].fsState = TBSTATE_ENABLED;