[misc] pre 1.0.3 update

* fixed remaining Clang warnings in badblocks.c and configure.ac
* removed beta and updated version to 1.0.3
This commit is contained in:
Pete Batard 2011-12-12 21:14:33 +00:00
parent d59854ef4f
commit 57de1cbe40
7 changed files with 87 additions and 165 deletions

View File

@ -32,7 +32,7 @@ s/^[ \t]*PRODUCTVERSION[ \t]*\(.*\),\(.*\),\(.*\),.*/ PRODUCTVERSION \1,\2,\3,@@
s/^\([ \t]*\)VALUE[ \t]*"FileVersion",[ \t]*"\(.*\)\..*"/\1VALUE "FileVersion", "\2.@@TAGVER@@"/ s/^\([ \t]*\)VALUE[ \t]*"FileVersion",[ \t]*"\(.*\)\..*"/\1VALUE "FileVersion", "\2.@@TAGVER@@"/
s/^\([ \t]*\)VALUE[ \t]*"ProductVersion",[ \t]*"\(.*\)\..*"/\1VALUE "ProductVersion", "\2.@@TAGVER@@"/ s/^\([ \t]*\)VALUE[ \t]*"ProductVersion",[ \t]*"\(.*\)\..*"/\1VALUE "ProductVersion", "\2.@@TAGVER@@"/
# TODO: revert ' ' to '"' below when out of beta # TODO: revert ' ' to '"' below when out of beta
s/^\(.*\)"Rufus v\(.*\)\.\(.*\) \(.*\)/\1"Rufus v\2.@@TAGVER@@ \4/ s/^\(.*\)"Rufus v\(.*\)\.\(.*\)"\(.*\)/\1"Rufus v\2.@@TAGVER@@"\4/
s/^\(.*\)"Version \(.*\) (Build \(.*\))"\(.*\)/\1"Version \2 (Build @@TAGVER@@)"\4/ s/^\(.*\)"Version \(.*\) (Build \(.*\))"\(.*\)/\1"Version \2 (Build @@TAGVER@@)"\4/
_EOF _EOF

22
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for rufus 1.0.2. # Generated by GNU Autoconf 2.68 for rufus 1.0.3.
# #
# Report bugs to <https://github.com/pbatard/rufus/issues>. # Report bugs to <https://github.com/pbatard/rufus/issues>.
# #
@ -559,8 +559,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='rufus' PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus' PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='1.0.2' PACKAGE_VERSION='1.0.3'
PACKAGE_STRING='rufus 1.0.2' PACKAGE_STRING='rufus 1.0.3'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='https://github.com/pbatard/rufus' PACKAGE_URL='https://github.com/pbatard/rufus'
@ -1200,7 +1200,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures rufus 1.0.2 to adapt to many kinds of systems. \`configure' configures rufus 1.0.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1266,7 +1266,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of rufus 1.0.2:";; short | recursive ) echo "Configuration of rufus 1.0.3:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1354,7 +1354,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
rufus configure 1.0.2 rufus configure 1.0.3
generated by GNU Autoconf 2.68 generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc. Copyright (C) 2010 Free Software Foundation, Inc.
@ -1409,7 +1409,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 1.0.2, which was It was created by rufus $as_me 1.0.3, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@ $ $0 $@
@ -2224,7 +2224,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='rufus' PACKAGE='rufus'
VERSION='1.0.2' VERSION='1.0.3'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -3362,7 +3362,7 @@ $as_echo "#define _GNU_SOURCE /**/" >>confdefs.h
# Clang needs an explicit WIN32_WINNT defined else it produces warnings # Clang needs an explicit WIN32_WINNT defined else it produces warnings
# in msapi_utf8.h - including winver.h only doesn't work # in msapi_utf8.h - including winver.h only doesn't work
AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501" AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501 -D_WIN32_WINNT=0x501"
AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined" AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined"
# Debug logging # Debug logging
@ -3982,7 +3982,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by rufus $as_me 1.0.2, which was This file was extended by rufus $as_me 1.0.3, which was
generated by GNU Autoconf 2.68. Invocation command line was generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -4036,7 +4036,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
rufus config.status 1.0.2 rufus config.status 1.0.3
configured by $0, generated by GNU Autoconf 2.68, configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -1,4 +1,4 @@
AC_INIT([rufus], [1.0.2], [https://github.com/pbatard/rufus/issues], [rufus], [https://github.com/pbatard/rufus]) AC_INIT([rufus], [1.0.3], [https://github.com/pbatard/rufus/issues], [rufus], [https://github.com/pbatard/rufus])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
@ -33,7 +33,7 @@ AC_DEFINE([_GNU_SOURCE], [], [Use GNU extensions])
# Clang needs an explicit WIN32_WINNT defined else it produces warnings # Clang needs an explicit WIN32_WINNT defined else it produces warnings
# in msapi_utf8.h - including winver.h only doesn't work # in msapi_utf8.h - including winver.h only doesn't work
AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501" AM_CFLAGS="${AM_CFLAGS} -DWINVER=0x501 -D_WIN32_IE=0x501 -D_WIN32_WINNT=0x501"
AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined" AM_LDFLAGS="${AM_LDFLAGS} -Wl,-no-undefined"
# Debug logging # Debug logging

View File

@ -274,8 +274,6 @@ static void ext2fs_badblocks_list_iterate_end(ext2_badblocks_iterate iter)
*/ */
static int v_flag = 1; /* verbose */ static int v_flag = 1; /* verbose */
static int s_flag = 1; /* show progress of test */ static int s_flag = 1; /* show progress of test */
static int t_flag = 0; /* number of test patterns */
static unsigned int *t_patts = NULL; /* test patterns */
static int cancel_ops = 0; /* abort current operation */ static int cancel_ops = 0; /* abort current operation */
static int cur_pattern, nr_pattern; static int cur_pattern, nr_pattern;
static int cur_op; static int cur_op;
@ -481,26 +479,17 @@ static unsigned int test_ro (HANDLE hDrive, blk_t last_block,
ext2fs_badblocks_list_iterate (bb_iter, &next_bad); ext2fs_badblocks_list_iterate (bb_iter, &next_bad);
} while (next_bad && next_bad < first_block); } while (next_bad && next_bad < first_block);
if (t_flag) { blkbuf = allocate_buffer(blocks_at_once * block_size);
blkbuf = allocate_buffer((blocks_at_once + 1) * block_size);
} else {
blkbuf = allocate_buffer(blocks_at_once * block_size);
}
if (!blkbuf) if (!blkbuf)
{ {
uprintf("could not allocate buffers\n"); uprintf("could not allocate buffers\n");
cancel_ops = -1; cancel_ops = -1;
return 0; return 0;
} }
if (t_flag) {
uprintf("Checking for bad blocks in read-only mode\n");
pattern_fill(blkbuf + blocks_at_once * block_size,
t_patts[0], block_size);
}
tryout = blocks_at_once; tryout = blocks_at_once;
currently_testing = first_block; currently_testing = first_block;
num_blocks = last_block - 1; num_blocks = last_block - 1;
if (!t_flag && (s_flag || v_flag)) { if (s_flag || v_flag) {
// Printstatus // Printstatus
uprintf("Checking for bad blocks (read-only test): \n"); uprintf("Checking for bad blocks (read-only test): \n");
} }
@ -526,16 +515,6 @@ static unsigned int test_ro (HANDLE hDrive, blk_t last_block,
if (currently_testing + tryout > last_block) if (currently_testing + tryout > last_block)
tryout = last_block - currently_testing; tryout = last_block - currently_testing;
got = do_read(hDrive, blkbuf, tryout, block_size, currently_testing); got = do_read(hDrive, blkbuf, tryout, block_size, currently_testing);
if (t_flag) {
/* test the comparison between all the
blocks successfully read */
int i;
for (i = 0; i < got; ++i)
if (memcmp (blkbuf+i*block_size,
blkbuf+blocks_at_once*block_size,
block_size))
bb_count += bb_output(currently_testing + i, CORRUPTION_ERROR);
}
if (got == 0 && tryout == 1) if (got == 0 && tryout == 1)
bb_count += bb_output(currently_testing++, READ_ERROR); bb_count += bb_output(currently_testing++, READ_ERROR);
currently_testing += got; currently_testing += got;
@ -566,8 +545,7 @@ static unsigned int test_ro (HANDLE hDrive, blk_t last_block,
static unsigned int test_rw(HANDLE hDrive, blk_t last_block, int block_size, blk_t first_block, unsigned int blocks_at_once) static unsigned int test_rw(HANDLE hDrive, blk_t last_block, int block_size, blk_t first_block, unsigned int blocks_at_once)
{ {
unsigned char *buffer = NULL, *read_buffer; unsigned char *buffer = NULL, *read_buffer;
const unsigned int patterns[] = EXT2_RW_PATTERNS; const unsigned int pattern[] = EXT2_RW_PATTERNS;
const unsigned int *pattern;
int i, tryout, got, pat_idx; int i, tryout, got, pat_idx;
unsigned int bb_count = 0; unsigned int bb_count = 0;
blk_t recover_block = ~0; blk_t recover_block = ~0;
@ -583,16 +561,10 @@ static unsigned int test_rw(HANDLE hDrive, blk_t last_block, int block_size, blk
uprintf("Checking for bad blocks in read-write mode\n"); uprintf("Checking for bad blocks in read-write mode\n");
uprintf("From block %lu to %lu\n", (unsigned long) first_block, (unsigned long) last_block - 1); uprintf("From block %lu to %lu\n", (unsigned long) first_block, (unsigned long) last_block - 1);
if (t_flag) { nr_pattern = ARRAYSIZE(pattern);
pattern = t_patts;
nr_pattern = t_flag;
} else {
pattern = patterns;
nr_pattern = ARRAYSIZE(patterns);
}
cur_pattern = 0; cur_pattern = 0;
for (pat_idx = 0; pat_idx < nr_pattern; pat_idx++) { for (pat_idx = 0; pat_idx < ARRAYSIZE(pattern); pat_idx++) {
if (cancel_ops) goto out; if (cancel_ops) goto out;
pattern_fill(buffer, pattern[pat_idx], blocks_at_once * block_size); pattern_fill(buffer, pattern[pat_idx], blocks_at_once * block_size);
num_blocks = last_block - 1; num_blocks = last_block - 1;
@ -694,8 +666,7 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block,
unsigned char *blkbuf, *save_ptr, *test_ptr, *read_ptr; unsigned char *blkbuf, *save_ptr, *test_ptr, *read_ptr;
unsigned char *test_base, *save_base, *read_base; unsigned char *test_base, *save_base, *read_base;
int tryout, i; int tryout, i;
const unsigned int patterns[] = { ~0 }; const unsigned int pattern[] = { ~0 };
const unsigned int *pattern;
int pat_idx; int pat_idx;
int got, used2, written; int got, used2, written;
blk_t save_currently_testing; blk_t save_currently_testing;
@ -760,17 +731,9 @@ static unsigned int test_nd(HANDLE hDrive, blk_t last_block,
exit(1); exit(1);
} }
if (t_flag) { nr_pattern = ARRAYSIZE(pattern);
pattern = t_patts; for (pat_idx = 0; pat_idx < ARRAYSIZE(pattern); pat_idx++) {
nr_pattern = t_flag; pattern_fill(test_base, pattern[pat_idx], blocks_at_once * block_size);
} else {
pattern = patterns;
nr_pattern = ARRAYSIZE(patterns);
}
for (pat_idx = 0; pat_idx < nr_pattern; pat_idx++) {
pattern_fill(test_base, pattern[pat_idx],
blocks_at_once * block_size);
buf_used = 0; buf_used = 0;
bb_count = 0; bb_count = 0;
save_ptr = save_base; save_ptr = save_base;
@ -963,7 +926,6 @@ BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size,
SetTimer(hMainDialog, TID_BADBLOCKS_UPDATE, 1000, alarm_intr); SetTimer(hMainDialog, TID_BADBLOCKS_UPDATE, 1000, alarm_intr);
report->bb_count = test_func(hPhysicalDrive, last_block, block_size, first_block, EXT2_BLOCKS_AT_ONCE); report->bb_count = test_func(hPhysicalDrive, last_block, block_size, first_block, EXT2_BLOCKS_AT_ONCE);
KillTimer(hMainDialog, TID_BADBLOCKS_UPDATE); KillTimer(hMainDialog, TID_BADBLOCKS_UPDATE);
free(t_patts);
free(bb_list->list); free(bb_list->list);
free(bb_list); free(bb_list);
// TODO: report first problem block for each error or create a report file // TODO: report first problem block for each error or create a report file

View File

@ -61,6 +61,7 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command,
switch(Command) { switch(Command) {
case FCC_PROGRESS: case FCC_PROGRESS:
// TODO: send this percentage to the status bar
percent = (DWORD*)pData; percent = (DWORD*)pData;
PrintStatus(0, "Formatting: %d%% completed.\n", *percent); PrintStatus(0, "Formatting: %d%% completed.\n", *percent);
// uprintf("%d percent completed.\n", *percent); // uprintf("%d percent completed.\n", *percent);

View File

@ -105,75 +105,39 @@ static BOOL DefineClusterSizes(void)
default_fs = FS_UNKNOWN; default_fs = FS_UNKNOWN;
memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize)); memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize));
if (SelectedDrive.DiskSize < 8*MB) { if (SelectedDrive.DiskSize < 8*MB) {
// TODO: muck with FAT12 and Small FAT16 like Microsoft does to support small drives? // TODO: muck with FAT12 and Small FAT16 like Microsoft does
uprintf("This application does not support volumes smaller than 8 MB\n"); uprintf("This application does not support volumes smaller than 8 MB yet\n");
goto out; goto out;
} }
/*
* The following is MS's allowed cluster sizes for FAT16 and FAT32:
*
* FAT16
* 31M : 512 - 4096
* 63M : 1024 - 8192
* 127M : 2048 - 16k
* 255M : 4096 - 32k
* 511M : 8192 - 64k
* 1023M: 16k - 64k
* 2047M: 32k - 64k
* 4095M: 64k
* 4GB+ : N/A
*
* FAT32
* 31M : N/A
* 63M : N/A (NB unlike MS, we're allowing 512-512 here - UNTESTED)
* 127M : 512 - 1024
* 255M : 512 - 2048
* 511M : 512 - 4096
* 1023M: 512 - 8192
* 2047M: 512 - 16k
* 4095M: 1024 - 32k
* 7GB : 2048 - 64k
* 15GB : 4096 - 64k
* 31GB : 8192 - 64k
* 32GB+: possible but N/A from Microsoft (see below)
*/
// FAT 16 // FAT 16
if (SelectedDrive.DiskSize < 4*GB) { if (SelectedDrive.DiskSize < 4*GB) {
SelectedDrive.ClusterSize[FS_FAT16].Allowed = 0x00001E00; // TODO: Refine the following according to size
SelectedDrive.ClusterSize[FS_FAT16].Allowed = 0x0001FE00;
for (i=32; i<=4096; i<<=1) { // 8 MB -> 4 GB for (i=32; i<=4096; i<<=1) { // 8 MB -> 4 GB
if (SelectedDrive.DiskSize < i*MB) { if (SelectedDrive.DiskSize < i*MB) {
SelectedDrive.ClusterSize[FS_FAT16].Default = 16*(ULONG)i; SelectedDrive.ClusterSize[FS_FAT16].Default = 16*(ULONG)i;
break; break;
} }
SelectedDrive.ClusterSize[FS_FAT16].Allowed <<= 1;
} }
SelectedDrive.ClusterSize[FS_FAT16].Allowed &= 0x0001FE00;
} }
// FAT 32 // FAT 32
// > 32GB FAT32 is not supported by MS (and likely FormatEx) but is feasible if (SelectedDrive.DiskSize < 256*MB) {
// See: http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm // TODO: Refine the following according to size
// < 32 MB FAT32 is not allowed by FormatEx SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x0001FE00;
if ((SelectedDrive.DiskSize >= 32*MB) && (SelectedDrive.DiskSize < 32*GB)) { for (i=64; i<=256; i<<=1) { // 8 MB -> 256 MB
SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x000001F8;
for (i=32; i<=(32*1024); i<<=1) { // 32 MB -> 32 GB
if (SelectedDrive.DiskSize < i*MB) { if (SelectedDrive.DiskSize < i*MB) {
SelectedDrive.ClusterSize[FS_FAT32].Default = 8*(ULONG)i; SelectedDrive.ClusterSize[FS_FAT32].Default = 8*(ULONG)i;
break; break;
} }
SelectedDrive.ClusterSize[FS_FAT32].Allowed <<= 1;
} }
SelectedDrive.ClusterSize[FS_FAT32].Allowed &= 0x0001FE00; } else if (SelectedDrive.DiskSize < 32*GB) {
SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x0001FE00;
// Default cluster sizes in the 256MB to 32 GB range do not follow the rule above for (i=8; i<=32; i<<=1) { // 256 MB -> 32 GB
if (SelectedDrive.DiskSize >= 256*MB) { if (SelectedDrive.DiskSize < i*GB) {
for (i=8; i<=32; i<<=1) { // 256 MB -> 32 GB SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*1024;
if (SelectedDrive.DiskSize < i*GB) { break;
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*1024;
break;
}
} }
} }
} }
@ -228,7 +192,7 @@ out:
static BOOL SetClusterSizes(int FSType) static BOOL SetClusterSizes(int FSType)
{ {
char szClustSize[64]; char szClustSize[64];
int i, k, default_index = 0; int i, default_index = 0;
ULONG j; ULONG j;
IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize)); IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize));
@ -244,15 +208,14 @@ static BOOL SetClusterSizes(int FSType)
return FALSE; return FALSE;
} }
for(i=0,j=0x200,k=0;j<0x10000000;i++,j<<=1) { for(i=0,j=0x200;j<0x10000000;i++,j<<=1) {
if (j & SelectedDrive.ClusterSize[FSType].Allowed) { if (j & SelectedDrive.ClusterSize[FSType].Allowed) {
safe_sprintf(szClustSize, sizeof(szClustSize), "%s", ClusterSizeLabel[i]); safe_sprintf(szClustSize, sizeof(szClustSize), "%s", ClusterSizeLabel[i]);
if (j == SelectedDrive.ClusterSize[FSType].Default) { if (j == SelectedDrive.ClusterSize[FSType].Default) {
safe_strcat(szClustSize, sizeof(szClustSize), " (Default)"); safe_strcat(szClustSize, sizeof(szClustSize), " (Default)");
default_index = k; default_index = i;
} }
IGNORE_RETVAL(ComboBox_SetItemData(hClusterSize, ComboBox_AddStringU(hClusterSize, szClustSize), j)); IGNORE_RETVAL(ComboBox_SetItemData(hClusterSize, ComboBox_AddStringU(hClusterSize, szClustSize), j));
k++;
} }
} }
@ -700,39 +663,40 @@ void UpdateProgress(int op, float percent)
/* /*
* Set or restore a Local Group Policy DWORD key indexed by szPath/SzPolicy * Set or restore a Local Group Policy DWORD key indexed by szPath/SzPolicy
*/ */
#pragma push_macro("INTERFACE")
#undef INTERFACE
#define INTERFACE IGroupPolicyObject
#define REGISTRY_EXTENSION_GUID { 0x35378EAC, 0x683F, 0x11D2, {0xA8, 0x9A, 0x00, 0xC0, 0x4F, 0xBB, 0xCF, 0xA2} }
#define GPO_OPEN_LOAD_REGISTRY 1
#define GPO_SECTION_MACHINE 2
typedef enum _GROUP_POLICY_OBJECT_TYPE { typedef enum _GROUP_POLICY_OBJECT_TYPE {
GPOTypeLocal = 0, GPOTypeRemote, GPOTypeDS GPOTypeLocal = 0,GPOTypeRemote,GPOTypeDS
} GROUP_POLICY_OBJECT_TYPE, *PGROUP_POLICY_OBJECT_TYPE; } GROUP_POLICY_OBJECT_TYPE,*PGROUP_POLICY_OBJECT_TYPE;
DECLARE_INTERFACE_(IGroupPolicyObject, IUnknown) {
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE; #define REGISTRY_EXTENSION_GUID { 0x35378EAC,0x683F,0x11D2, {0xA8,0x9A,0x00,0xC0,0x4F,0xBB,0xCF,0xA2} }
STDMETHOD_(ULONG, AddRef) (THIS) PURE; #define GPO_OPEN_LOAD_REGISTRY 0x00000001
STDMETHOD_(ULONG, Release) (THIS) PURE; #define GPO_SECTION_MACHINE 2
STDMETHOD(New) (THIS_ LPOLESTR pszDomainName, LPOLESTR pszDisplayName, DWORD dwFlags) PURE;
STDMETHOD(OpenDSGPO) (THIS_ LPOLESTR pszPath, DWORD dwFlags) PURE; #undef INTERFACE
STDMETHOD(OpenLocalMachineGPO) (THIS_ DWORD dwFlags) PURE; #define INTERFACE IGroupPolicyObject
STDMETHOD(OpenRemoteMachineGPO) (THIS_ LPOLESTR pszComputerName, DWORD dwFlags) PURE; DECLARE_INTERFACE_(IGroupPolicyObject,IUnknown) {
STDMETHOD(Save) (THIS_ BOOL bMachine, BOOL bAdd,GUID *pGuidExtension, GUID *pGuid) PURE; STDMETHOD(QueryInterface) (THIS_ REFIID riid,LPVOID *ppvObj) PURE;
STDMETHOD(Delete) (THIS) PURE; STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD(GetName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; STDMETHOD_(ULONG,Release) (THIS) PURE;
STDMETHOD(GetDisplayName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; STDMETHOD(New) (THIS_ LPOLESTR pszDomainName,LPOLESTR pszDisplayName,DWORD dwFlags) PURE;
STDMETHOD(SetDisplayName) (THIS_ LPOLESTR pszName) PURE; STDMETHOD(OpenDSGPO) (THIS_ LPOLESTR pszPath,DWORD dwFlags) PURE;
STDMETHOD(GetPath) (THIS_ LPOLESTR pszPath, int cchMaxPath) PURE; STDMETHOD(OpenLocalMachineGPO) (THIS_ DWORD dwFlags) PURE;
STDMETHOD(GetDSPath) (THIS_ DWORD dwSection, LPOLESTR pszPath ,int cchMaxPath) PURE; STDMETHOD(OpenRemoteMachineGPO) (THIS_ LPOLESTR pszComputerName,DWORD dwFlags) PURE;
STDMETHOD(GetFileSysPath) (THIS_ DWORD dwSection, LPOLESTR pszPath, int cchMaxPath) PURE; STDMETHOD(Save) (THIS_ BOOL bMachine, BOOL bAdd,GUID *pGuidExtension,GUID *pGuid) PURE;
STDMETHOD(GetRegistryKey) (THIS_ DWORD dwSection, HKEY *hKey) PURE; STDMETHOD(Delete) (THIS) PURE;
STDMETHOD(GetOptions) (THIS_ DWORD *dwOptions) PURE; STDMETHOD(GetName) (THIS_ LPOLESTR pszName,int cchMaxLength) PURE;
STDMETHOD(SetOptions) (THIS_ DWORD dwOptions, DWORD dwMask) PURE; STDMETHOD(GetDisplayName) (THIS_ LPOLESTR pszName,int cchMaxLength) PURE;
STDMETHOD(GetType) (THIS_ GROUP_POLICY_OBJECT_TYPE *gpoType) PURE; STDMETHOD(SetDisplayName) (THIS_ LPOLESTR pszName) PURE;
STDMETHOD(GetMachineName) (THIS_ LPOLESTR pszName, int cchMaxLength) PURE; STDMETHOD(GetPath) (THIS_ LPOLESTR pszPath,int cchMaxPath) PURE;
STDMETHOD(GetPropertySheetPages) (THIS_ HPROPSHEETPAGE **hPages, UINT *uPageCount) PURE; STDMETHOD(GetDSPath) (THIS_ DWORD dwSection,LPOLESTR pszPath,int cchMaxPath) PURE;
}; STDMETHOD(GetFileSysPath) (THIS_ DWORD dwSection,LPOLESTR pszPath,int cchMaxPath) PURE;
typedef IGroupPolicyObject *LPGROUPPOLICYOBJECT; STDMETHOD(GetRegistryKey) (THIS_ DWORD dwSection,HKEY *hKey) PURE;
STDMETHOD(GetOptions) (THIS_ DWORD *dwOptions) PURE;
STDMETHOD(SetOptions) (THIS_ DWORD dwOptions,DWORD dwMask) PURE;
STDMETHOD(GetType) (THIS_ GROUP_POLICY_OBJECT_TYPE *gpoType) PURE;
STDMETHOD(GetMachineName) (THIS_ LPOLESTR pszName,int cchMaxLength) PURE;
STDMETHOD(GetPropertySheetPages) (THIS_ HPROPSHEETPAGE **hPages,UINT *uPageCount) PURE;
};
typedef IGroupPolicyObject *LPGROUPPOLICYOBJECT;
BOOL SetLGP(BOOL bRestore, const char* szPath, const char* szPolicy, DWORD dwValue) BOOL SetLGP(BOOL bRestore, const char* szPath, const char* szPolicy, DWORD dwValue)
{ {
@ -742,7 +706,7 @@ BOOL SetLGP(BOOL bRestore, const char* szPath, const char* szPolicy, DWORD dwVal
HRESULT hr; HRESULT hr;
IGroupPolicyObject* pLGPO; IGroupPolicyObject* pLGPO;
// These statuc values are used to restore initial state // These statuc values are used to restore initial state
static BOOL existing_key = FALSE; static BOOL key_was_present = FALSE;
static DWORD original_val; static DWORD original_val;
HKEY path_key = NULL, policy_key = NULL; HKEY path_key = NULL, policy_key = NULL;
// MSVC is finicky about these ones => redefine them // MSVC is finicky about these ones => redefine them
@ -791,20 +755,20 @@ BOOL SetLGP(BOOL bRestore, const char* szPath, const char* szPolicy, DWORD dwVal
goto error; goto error;
} }
if ((disp == REG_OPENED_EXISTING_KEY) && (!bRestore) && (!existing_key)) { if ((disp == REG_OPENED_EXISTING_KEY) && (!bRestore) && (!key_was_present)) {
// backup existing value for restore // backup existing value for restore
existing_key = TRUE; key_was_present = TRUE;
regtype = REG_DWORD; regtype = REG_DWORD;
r = RegQueryValueExA(policy_key, szPolicy, NULL, &regtype, (LPBYTE)&original_val, &val_size); r = RegQueryValueExA(policy_key, szPolicy, NULL, &regtype, (LPBYTE)&original_val, &val_size);
if (r == ERROR_FILE_NOT_FOUND) { if (r == ERROR_FILE_NOT_FOUND) {
// The Key exists but not its value, which is OK // The Key exists but not its value, which is OK
existing_key = FALSE; key_was_present = FALSE;
} else if (r != ERROR_SUCCESS) { } else if (r != ERROR_SUCCESS) {
uprintf("SetLGP: Failed to read original %s policy value - error %x\n", szPolicy, r); uprintf("SetLGP: Failed to read original %s policy value - error %x\n", szPolicy, r);
} }
} }
if ((!bRestore) || (existing_key)) { if ((!bRestore) || (key_was_present)) {
val = (bRestore)?original_val:dwValue; val = (bRestore)?original_val:dwValue;
r = RegSetValueExA(policy_key, szPolicy, 0, REG_DWORD, (BYTE*)&val, sizeof(val)); r = RegSetValueExA(policy_key, szPolicy, 0, REG_DWORD, (BYTE*)&val, sizeof(val));
} else { } else {
@ -822,11 +786,7 @@ BOOL SetLGP(BOOL bRestore, const char* szPath, const char* szPolicy, DWORD dwVal
uprintf("SetLGP: Unable to apply %s policy - error %x\n", szPolicy, hr); uprintf("SetLGP: Unable to apply %s policy - error %x\n", szPolicy, hr);
goto error; goto error;
} else { } else {
if ((bRestore) && (!existing_key)) { uprintf("SetLGP: Successfully %s %s policy\n", (bRestore)?"restored":"disabled", szPolicy);
uprintf("SetLGP: Successfully removed %s policy key\n", szPolicy);
} else {
uprintf("SetLGP: Successfully %s %s policy to 0x%08X\n", (bRestore)?"restored":"set", szPolicy, val);
}
} }
RegCloseKey(path_key); RegCloseKey(path_key);
@ -839,7 +799,6 @@ error:
if (pLGPO != NULL) pLGPO->lpVtbl->Release(pLGPO); if (pLGPO != NULL) pLGPO->lpVtbl->Release(pLGPO);
return FALSE; return FALSE;
} }
#pragma pop_macro("INTERFACE")
/* /*
* Toggle controls according to operation * Toggle controls according to operation

View File

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278 IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.2.90 (Beta)" CAPTION "Rufus v1.0.3.91"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -59,12 +59,12 @@ CAPTION "About Rufus"
FONT 8, "Microsoft Sans Serif", 400, 0, 0x0 FONT 8, "Microsoft Sans Serif", 400, 0, 0x0
BEGIN BEGIN
ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20 ICON IDI_ICON,IDC_ABOUT_ICON,11,8,20,20
LTEXT "Rufus - The Reliable USB Formatting Utility *BETA*",IDC_RUFUS_BOLD,46,8,240,10,SS_NOPREFIX | SS_NOTIFY LTEXT "Rufus - The Reliable USB Formatting Utility",IDC_RUFUS_BOLD,46,8,240,10,SS_NOPREFIX | SS_NOTIFY
LTEXT "Copyright (c) 2011 Pete Batard",IDC_STATIC,46,36,139,8 LTEXT "Copyright (c) 2011 Pete Batard",IDC_STATIC,46,36,139,8
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9 "SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.2 (Build 90)",IDC_STATIC,46,19,78,8 LTEXT "Version 1.0.3 (Build 91)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -163,8 +163,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,2,90 FILEVERSION 1,0,3,91
PRODUCTVERSION 1,0,2,90 PRODUCTVERSION 1,0,3,91
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -181,13 +181,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "akeo.ie" VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.2.90" VALUE "FileVersion", "1.0.3.91"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.2.90" VALUE "ProductVersion", "1.0.3.91"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"