[misc] fix VS2012 Code Analysis warnings

* Only for files that aren't part of external dependencies
* Also update copyright date
This commit is contained in:
Pete Batard 2013-01-09 21:54:28 +00:00
parent ae43dfd721
commit c4cb9d03c1
12 changed files with 76 additions and 38 deletions

View file

@ -7,7 +7,7 @@
* *
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o * Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o
* Copyright 1999 by David Beattie * Copyright 1999 by David Beattie
* Copyright 2011-2012 by Pete Batard * Copyright 2011-2013 by Pete Batard
* *
* This file is based on the minix file system programs fsck and mkfs * This file is based on the minix file system programs fsck and mkfs
* written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi> * written and copyrighted by Linus Torvalds <Linus.Torvalds@cs.helsinki.fi>
@ -121,6 +121,7 @@ static errcode_t bb_u64_list_add(bb_u64_list bb, uint64_t blk)
bb->size -= 100; bb->size -= 100;
return BB_ET_NO_MEMORY; return BB_ET_NO_MEMORY;
} }
memset(&bb->list[bb->size-100], 0, 100 * sizeof(uint64_t));
} }
/* /*

View file

@ -2,7 +2,7 @@
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll * DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll
* (MS WinME DOS) or from the embedded FreeDOS resource files * (MS WinME DOS) or from the embedded FreeDOS resource files
* Copyright (c) 2011-2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2011-2013 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
@ -178,7 +178,10 @@ static BOOL Patch_COMMAND_COM(HANDLE hFile)
return FALSE; return FALSE;
} }
SetFilePointer(hFile, 0x650c, NULL, FILE_BEGIN); SetFilePointer(hFile, 0x650c, NULL, FILE_BEGIN);
ReadFile(hFile, data, size, &size, NULL); if (!ReadFile(hFile, data, size, &size, NULL)) {
uprintf(" could not read data\n");
return FALSE;
}
if (memcmp(data, expected, sizeof(expected)) != 0) { if (memcmp(data, expected, sizeof(expected)) != 0) {
uprintf(" unexpected binary data\n"); uprintf(" unexpected binary data\n");
return FALSE; return FALSE;
@ -202,7 +205,10 @@ static BOOL Patch_IO_SYS(HANDLE hFile)
return FALSE; return FALSE;
} }
SetFilePointer(hFile, 0x3a8, NULL, FILE_BEGIN); SetFilePointer(hFile, 0x3a8, NULL, FILE_BEGIN);
ReadFile(hFile, data, size, &size, NULL); if (!ReadFile(hFile, data, size, &size, NULL)) {
uprintf(" could not read data\n");
return FALSE;
}
if (memcmp(data, expected, sizeof(expected)) != 0) { if (memcmp(data, expected, sizeof(expected)) != 0) {
uprintf(" unexpected binary data\n"); uprintf(" unexpected binary data\n");
return FALSE; return FALSE;
@ -307,6 +313,7 @@ static BOOL ExtractMSDOS(const char* path)
int i, j; int i, j;
BOOL r = TRUE; BOOL r = TRUE;
HMODULE hDLL; HMODULE hDLL;
HGLOBAL hRes;
HRSRC hDiskImage; HRSRC hDiskImage;
char locale_path[MAX_PATH]; char locale_path[MAX_PATH];
char* extractlist[] = { "MSDOS SYS", "COMMAND COM", "IO SYS", "MODE COM", char* extractlist[] = { "MSDOS SYS", "COMMAND COM", "IO SYS", "MODE COM",
@ -331,8 +338,10 @@ static BOOL ExtractMSDOS(const char* path)
FreeLibrary(hDLL); FreeLibrary(hDLL);
return FALSE; return FALSE;
} }
DiskImage = (BYTE*)LockResource(LoadResource(hDLL, hDiskImage)); hRes = LoadResource(hDLL, hDiskImage);
if (DiskImage == NULL) { if (hRes != NULL)
DiskImage = (BYTE*)LockResource(hRes);
if ((hRes == NULL) || (DiskImage == NULL) ){
uprintf("Unable to access disk image in %s: %s\n", dllname, WindowsErrorString()); uprintf("Unable to access disk image in %s: %s\n", dllname, WindowsErrorString());
FreeLibrary(hDLL); FreeLibrary(hDLL);
return FALSE; return FALSE;

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 (c) 2011-2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2011-2013 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
@ -410,7 +410,10 @@ static const char* get_kb(void)
// need an KLID which GetKeyboardLayoutNameA() does return ...but only as a // need an KLID which GetKeyboardLayoutNameA() does return ...but only as a
// string of an hex value... // string of an hex value...
GetKeyboardLayoutNameA(kbid_str); GetKeyboardLayoutNameA(kbid_str);
sscanf(kbid_str, "%x", &kbid); if (sscanf(kbid_str, "%x", &kbid) == 0) {
uprintf("Could not scan keyboard layout name - falling back to US as default\n");
kbid = 0x00000409;
}
uprintf("Windows KBID 0x%08x\n", kbid); uprintf("Windows KBID 0x%08x\n", kbid);
for (pass=0; pass<3; pass++) { for (pass=0; pass<3; pass++) {

View file

@ -180,7 +180,7 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label)
strncpy(VolumeLabel, AutorunLabel, sizeof(VolumeLabel)); strncpy(VolumeLabel, AutorunLabel, sizeof(VolumeLabel));
safe_free(AutorunLabel); safe_free(AutorunLabel);
*label = VolumeLabel; *label = VolumeLabel;
} else if (GetVolumeInformationW(wDrivePath, wVolumeLabel, sizeof(wVolumeLabel), } else if (GetVolumeInformationW(wDrivePath, wVolumeLabel, ARRAYSIZE(wVolumeLabel),
NULL, NULL, NULL, NULL, 0) && *wVolumeLabel) { NULL, NULL, NULL, NULL, 0) && *wVolumeLabel) {
wchar_to_utf8_no_alloc(wVolumeLabel, VolumeLabel, sizeof(VolumeLabel)); wchar_to_utf8_no_alloc(wVolumeLabel, VolumeLabel, sizeof(VolumeLabel));
*label = VolumeLabel; *label = VolumeLabel;

View file

@ -1,9 +1,9 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* ISO file extraction * ISO file extraction
* Copyright (c) 2011-2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2011-2013 Pete Batard <pete@akeo.ie>
* Based on libcdio's iso & udf samples: * Based on libcdio's iso & udf samples:
* Copyright (c) 2003-2011 Rocky Bernstein <rocky@gnu.org> * Copyright (c) 2003-2012 Rocky Bernstein <rocky@gnu.org>
* *
* 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
@ -185,7 +185,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
uprintf("Error allocating file name\n"); uprintf("Error allocating file name\n");
goto out; goto out;
} }
i_length = safe_sprintf(psz_fullpath, i_length, "%s%s/%s", psz_extract_dir, psz_path, psz_basename); i_length = _snprintf(psz_fullpath, i_length, "%s%s/%s", psz_extract_dir, psz_path, psz_basename);
if (i_length < 0) { if (i_length < 0) {
goto out; goto out;
} }
@ -292,7 +292,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
if ((p_iso == NULL) || (psz_path == NULL)) if ((p_iso == NULL) || (psz_path == NULL))
return 1; return 1;
i_length = safe_sprintf(psz_fullpath, sizeof(psz_fullpath), "%s%s/", psz_extract_dir, psz_path); i_length = _snprintf(psz_fullpath, sizeof(psz_fullpath), "%s%s/", psz_extract_dir, psz_path);
if (i_length < 0) if (i_length < 0)
return 1; return 1;
psz_basename = &psz_fullpath[i_length]; psz_basename = &psz_fullpath[i_length];

View file

@ -2,7 +2,7 @@
* MSAPI_UTF8: Common API calls using UTF-8 strings * MSAPI_UTF8: Common API calls using UTF-8 strings
* Compensating for what Microsoft should have done a long long time ago. * Compensating for what Microsoft should have done a long long time ago.
* *
* Copyright (c) 2010-2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2010-2013 Pete Batard <pete@akeo.ie>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -27,6 +27,10 @@
#include <direct.h> #include <direct.h>
#pragma once #pragma once
#if defined(_MSC_VER)
// disable VS2012 Code Analysis warnings that are intentional
#pragma warning(disable: 6387) // Don't care about bad params
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Networking functionality (web file download, check for update, etc.) * Networking functionality (web file download, check for update, etc.)
* Copyright (c) 2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2012-2013 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
@ -270,6 +270,7 @@ BOOL DownloadFile(const char* url, const char* file, HWND hProgressDialog)
uprintf("Unable to decode URL: %s\n", WindowsErrorString()); uprintf("Unable to decode URL: %s\n", WindowsErrorString());
goto out; goto out;
} }
hostname[sizeof(hostname)-1] = 0;
// Open an Internet session // Open an Internet session
for (i=5; (i>0) && (!InternetGetConnectedState(&dwFlags, 0)); i--) { for (i=5; (i>0) && (!InternetGetConnectedState(&dwFlags, 0)); i--) {
@ -476,8 +477,9 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
if ((!InternetCrackUrlA(server_url, (DWORD)safe_strlen(server_url), 0, &UrlParts)) || (!InternetGetConnectedState(&dwFlags, 0))) if ((!InternetCrackUrlA(server_url, (DWORD)safe_strlen(server_url), 0, &UrlParts)) || (!InternetGetConnectedState(&dwFlags, 0)))
goto out; goto out;
hostname[sizeof(hostname)-1] = 0;
_snprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d.%d", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]); safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d.%d", rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[3]);
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (hSession == NULL) if (hSession == NULL)
goto out; goto out;

View file

@ -1,6 +1,6 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Copyright © 2011-2012 Pete Batard <pete@akeo.ie> * Copyright © 2011-2013 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
@ -395,7 +395,7 @@ static BOOL GetDriveInfo(void)
DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No", DriveLayout->PartitionEntry[i].Mbr.BootIndicator?"Yes":"No",
DriveLayout->PartitionEntry[i].Mbr.RecognizedPartition?"Yes":"No", DriveLayout->PartitionEntry[i].Mbr.RecognizedPartition?"Yes":"No",
DriveLayout->PartitionEntry[i].Mbr.HiddenSectors); DriveLayout->PartitionEntry[i].Mbr.HiddenSectors);
tmp_pos = safe_sprintf(&tmp[tmp_pos], sizeof(tmp)-tmp_pos, "Partition %d: %s (%s)\n", tmp_pos = _snprintf(&tmp[tmp_pos], sizeof(tmp)-tmp_pos, "Partition %d: %s (%s)\n",
i+1, GetPartitionType(part_type), size_to_hr(DriveLayout->PartitionEntry[i].PartitionLength)); i+1, GetPartitionType(part_type), size_to_hr(DriveLayout->PartitionEntry[i].PartitionLength));
} }
} }
@ -525,7 +525,7 @@ static BOOL PopulateProperties(int ComboIndex)
{ {
double HumanReadableSize; double HumanReadableSize;
char capacity[64]; char capacity[64];
static char *suffix[] = { "KB", "MB", "GB", "TB", "PB"}; static char *suffix[] = { "B", "KB", "MB", "GB", "TB", "PB"};
char no_label[] = STR_NO_LABEL; char no_label[] = STR_NO_LABEL;
int i, fs; int i, fs;
@ -547,7 +547,7 @@ static BOOL PopulateProperties(int ComboIndex)
EnableBootOptions((fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); EnableBootOptions((fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
HumanReadableSize = (double)SelectedDrive.DiskSize; HumanReadableSize = (double)SelectedDrive.DiskSize;
for (i=0; i<ARRAYSIZE(suffix); i++) { for (i=1; i<ARRAYSIZE(suffix); i++) {
HumanReadableSize /= 1024.0; HumanReadableSize /= 1024.0;
if (HumanReadableSize < 512.0) { if (HumanReadableSize < 512.0) {
safe_sprintf(capacity, sizeof(capacity), "%0.2f %s", HumanReadableSize, suffix[i]); safe_sprintf(capacity, sizeof(capacity), "%0.2f %s", HumanReadableSize, suffix[i]);
@ -751,6 +751,10 @@ static BOOL GetUSBDevices(DWORD devnum)
continue; continue;
} }
} }
if (devint_detail_data == NULL) {
uprintf("SetupDiGetDeviceInterfaceDetail (dummy) - no data was allocated\n");
continue;
}
if(!SetupDiGetDeviceInterfaceDetailA(dev_info, &devint_data, devint_detail_data, size, &size, NULL)) { if(!SetupDiGetDeviceInterfaceDetailA(dev_info, &devint_data, devint_detail_data, size, &size, NULL)) {
uprintf("SetupDiGetDeviceInterfaceDetail (actual) failed: %s\n", WindowsErrorString()); uprintf("SetupDiGetDeviceInterfaceDetail (actual) failed: %s\n", WindowsErrorString());
continue; continue;
@ -1207,7 +1211,7 @@ BOOL CALLBACK ISOProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
hISOProgressBar = GetDlgItem(hDlg, IDC_PROGRESS); hISOProgressBar = GetDlgItem(hDlg, IDC_PROGRESS);
hISOFileName = GetDlgItem(hDlg, IDC_ISO_FILENAME); hISOFileName = GetDlgItem(hDlg, IDC_ISO_FILENAME);
// Use maximum granularity for the progress bar // Use maximum granularity for the progress bar
SendMessage(hISOProgressBar, PBM_SETRANGE, 0, MAX_PROGRESS<<16); SendMessage(hISOProgressBar, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
return TRUE; return TRUE;
case UM_ISO_INIT: case UM_ISO_INIT:
iso_op_in_progress = TRUE; iso_op_in_progress = TRUE;
@ -1450,7 +1454,7 @@ void InitDialog(HWND hDlg)
SetTaskbarProgressState(TASKBAR_NORMAL); SetTaskbarProgressState(TASKBAR_NORMAL);
// Use maximum granularity for the progress bar // Use maximum granularity for the progress bar
SendMessage(hProgress, PBM_SETRANGE, 0, MAX_PROGRESS<<16); SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
// Fill up the passes // Fill up the passes
IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, "1 Pass")); IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, "1 Pass"));
IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, "2 Passes")); IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, "2 Passes"));
@ -1902,9 +1906,9 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
GetUSBDevices(DeviceNum); GetUSBDevices(DeviceNum);
if (!IS_ERROR(FormatStatus)) { if (!IS_ERROR(FormatStatus)) {
// This is the only way to achieve instantenous progress transition to 100% // This is the only way to achieve instantenous progress transition to 100%
SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS+1)<<16); SendMessage(hProgress, PBM_SETRANGE, 0, ((MAX_PROGRESS+1)<<16) & 0xFFFF0000);
SendMessage(hProgress, PBM_SETPOS, (MAX_PROGRESS+1), 0); SendMessage(hProgress, PBM_SETPOS, (MAX_PROGRESS+1), 0);
SendMessage(hProgress, PBM_SETRANGE, 0, MAX_PROGRESS<<16); SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
SetTaskbarProgressState(TASKBAR_NOPROGRESS); SetTaskbarProgressState(TASKBAR_NOPROGRESS);
PrintStatus(0, FALSE, "DONE"); PrintStatus(0, FALSE, "DONE");
} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) { } else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
@ -1931,7 +1935,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
*/ */
// If we ever need to process more than one commandline arguments, uncomment the following parts // If we ever need to process more than one commandline arguments, uncomment the following parts
// typedef int (CDECL *__wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*); // typedef int (CDECL *__wgetmainargs_t)(int*, wchar_t***, wchar_t***, int, int*);
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
#else
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
#endif
{ {
// int i, argc = 0, si = 0; // int i, argc = 0, si = 0;
// char** argv = NULL; // char** argv = NULL;
@ -1976,7 +1984,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
hMainInstance = hInstance; hMainInstance = hInstance;
// Initialize COM for folder selection // Initialize COM for folder selection
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
// Some dialogs have Rich Edit controls and won't display without this // Some dialogs have Rich Edit controls and won't display without this
if (LoadLibraryA("Riched20.dll") == NULL) { if (LoadLibraryA("Riched20.dll") == NULL) {

View file

@ -1,6 +1,6 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Copyright © 2011-2012 Pete Batard <pete@akeo.ie> * Copyright © 2011-2013 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
@ -19,6 +19,11 @@
#include <winioctl.h> // for DISK_GEOMETRY #include <winioctl.h> // for DISK_GEOMETRY
#include <stdint.h> #include <stdint.h>
#if defined(_MSC_VER)
// Disable some VS2012 Code Analysis warnings
#pragma warning(disable: 28159) // VS2012 wants us to use GetTickCount64(), but it's not available on XP
#endif
#pragma once #pragma once
/* Program options */ /* Program options */
@ -63,7 +68,7 @@
#define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count) #define safe_strnicmp(str1, str2, count) _strnicmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2), count)
#define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0) #define safe_closehandle(h) do {if (h != INVALID_HANDLE_VALUE) {CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_unlockclose(h) do {if (h != INVALID_HANDLE_VALUE) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0) #define safe_unlockclose(h) do {if (h != INVALID_HANDLE_VALUE) {UnlockDrive(h); CloseHandle(h); h = INVALID_HANDLE_VALUE;}} while(0)
#define safe_sprintf _snprintf #define safe_sprintf(dst, count, ...) do {_snprintf(dst, count, __VA_ARGS__); (dst)[(count)-1] = 0; } while(0)
#define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str)) #define safe_strlen(str) ((((char*)str)==NULL)?0:strlen(str))
#define safe_strdup _strdup #define safe_strdup _strdup
#if defined(_MSC_VER) #if defined(_MSC_VER)

View file

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316 IDD_DIALOG DIALOGEX 12, 12, 206, 316
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.3.0.215" CAPTION "Rufus v1.3.0.216"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14 DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -274,8 +274,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,215 FILEVERSION 1,3,0,216
PRODUCTVERSION 1,3,0,215 PRODUCTVERSION 1,3,0,216
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -292,13 +292,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.3.0.215" VALUE "FileVersion", "1.3.0.216"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "(c) 2011-2012 Pete Batard (GPL v3)" VALUE "LegalCopyright", "(c) 2011-2012 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.3.0.215" VALUE "ProductVersion", "1.3.0.216"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -1,7 +1,7 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Standard I/O Routines (logging, status, etc.) * Standard I/O Routines (logging, status, etc.)
* Copyright (c) 2011-2012 Pete Batard <pete@akeo.ie> * Copyright (c) 2011-2013 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
@ -107,7 +107,7 @@ void DumpBufferHex(void *buf, size_t size)
*/ */
const char *WindowsErrorString(void) const char *WindowsErrorString(void)
{ {
static char err_string[256]; static char err_string[256] = {0};
DWORD size; DWORD size;
DWORD error_code, format_error; DWORD error_code, format_error;

View file

@ -1,9 +1,9 @@
/* /*
* Rufus: The Reliable USB Formatting Utility * Rufus: The Reliable USB Formatting Utility
* Standard Dialog Routines (Browse for folder, About, etc) * Standard Dialog Routines (Browse for folder, About, etc)
* Copyright © 2011-2012 Pete Batard <pete@akeo.ie> * Copyright © 2011-2013 Pete Batard <pete@akeo.ie>
* *
* Based on zadig_stdlg.c, part of libwdi: http://libwdi.sf.net * Based on zadig_stdlg.c, part of libwdi: http://libwdi.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
@ -114,12 +114,15 @@ void StrArrayCreate(StrArray* arr, size_t initial_size)
void StrArrayAdd(StrArray* arr, const char* str) void StrArrayAdd(StrArray* arr, const char* str)
{ {
char** old_table;
if ((arr == NULL) || (arr->Table == NULL)) if ((arr == NULL) || (arr->Table == NULL))
return; return;
if (arr->Index == arr->Max) { if (arr->Index == arr->Max) {
arr->Max *= 2; arr->Max *= 2;
old_table = arr->Table;
arr->Table = (char**)realloc(arr->Table, arr->Max*sizeof(char*)); arr->Table = (char**)realloc(arr->Table, arr->Max*sizeof(char*));
if (arr->Table == NULL) { if (arr->Table == NULL) {
free(old_table);
uprintf("Could not reallocate string array\n"); uprintf("Could not reallocate string array\n");
return; return;
} }
@ -700,6 +703,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
tr.chrg.cpMin = enl->chrg.cpMin; tr.chrg.cpMin = enl->chrg.cpMin;
tr.chrg.cpMax = enl->chrg.cpMax; tr.chrg.cpMax = enl->chrg.cpMax;
SendMessageW(enl->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr); SendMessageW(enl->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
wUrl[ARRAYSIZE(wUrl)-1] = 0;
ShellExecuteW(hDlg, L"open", wUrl, NULL, NULL, SW_SHOWNORMAL); ShellExecuteW(hDlg, L"open", wUrl, NULL, NULL, SW_SHOWNORMAL);
} }
break; break;
@ -970,7 +974,8 @@ void DestroyAllTooltips(void)
/* Determine if a Windows is being displayed or not */ /* Determine if a Windows is being displayed or not */
BOOL IsShown(HWND hDlg) BOOL IsShown(HWND hDlg)
{ {
WINDOWPLACEMENT placement; WINDOWPLACEMENT placement = {0};
placement.length = sizeof(WINDOWPLACEMENT);
if (!GetWindowPlacement(hDlg, &placement)) if (!GetWindowPlacement(hDlg, &placement))
return FALSE; return FALSE;
switch (placement.showCmd) { switch (placement.showCmd) {
@ -1282,7 +1287,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
update.version[0], update.version[1], update.version[2], update.version[3]); update.version[0], update.version[1], update.version[2], update.version[3]);
SetWindowTextA(GetDlgItem(hDlg, IDC_LATEST_VERSION), tmp); SetWindowTextA(GetDlgItem(hDlg, IDC_LATEST_VERSION), tmp);
SetWindowTextA(GetDlgItem(hDlg, IDC_DOWNLOAD_URL), update.download_url); SetWindowTextA(GetDlgItem(hDlg, IDC_DOWNLOAD_URL), update.download_url);
SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE, 0, MAX_PROGRESS<<16); SendMessage(GetDlgItem(hDlg, IDC_PROGRESS), PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
if (update.download_url == NULL) if (update.download_url == NULL)
EnableWindow(GetDlgItem(hDlg, IDC_DOWNLOAD), FALSE); EnableWindow(GetDlgItem(hDlg, IDC_DOWNLOAD), FALSE);
break; break;
@ -1301,6 +1306,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
tr.chrg.cpMin = enl->chrg.cpMin; tr.chrg.cpMin = enl->chrg.cpMin;
tr.chrg.cpMax = enl->chrg.cpMax; tr.chrg.cpMax = enl->chrg.cpMax;
SendMessageW(enl->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr); SendMessageW(enl->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
wUrl[ARRAYSIZE(wUrl)-1] = 0;
ShellExecuteW(hDlg, L"open", wUrl, NULL, NULL, SW_SHOWNORMAL); ShellExecuteW(hDlg, L"open", wUrl, NULL, NULL, SW_SHOWNORMAL);
} }
break; break;