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

[core] use GetTickCount64() always where possible

* Damn you XP!!!
* Also some more code cleanup
This commit is contained in:
Pete Batard 2016-02-24 16:10:54 +00:00
parent d20eb9262b
commit 250d46e401
15 changed files with 67 additions and 54 deletions

View file

@ -778,8 +778,8 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
DWORD WINAPI SumThread(void* param) DWORD WINAPI SumThread(void* param)
{ {
HANDLE h = INVALID_HANDLE_VALUE; HANDLE h = INVALID_HANDLE_VALUE;
DWORD rSize = 0, LastRefresh = 0; DWORD rSize = 0;
uint64_t rb; uint64_t rb, LastRefresh = 0;
char buffer[4096]; char buffer[4096];
SHA1_CONTEXT sha1_ctx; SHA1_CONTEXT sha1_ctx;
SHA256_CONTEXT sha256_ctx; SHA256_CONTEXT sha256_ctx;
@ -804,8 +804,8 @@ DWORD WINAPI SumThread(void* param)
md5_init(&md5_ctx); md5_init(&md5_ctx);
for (rb = 0; ; rb += rSize) { for (rb = 0; ; rb += rSize) {
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*rb) / (1.0f*img_report.projected_size); format_percent = (100.0f*rb) / (1.0f*img_report.projected_size);
PrintInfo(0, MSG_271, format_percent); PrintInfo(0, MSG_271, format_percent);
SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent/100.0f)*MAX_PROGRESS), 0); SendMessage(hProgress, PBM_SETPOS, (WPARAM)((format_percent/100.0f)*MAX_PROGRESS), 0);

View file

@ -31,6 +31,7 @@
#include <string.h> #include <string.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h"
#include "resource.h" #include "resource.h"
#include "dos.h" #include "dos.h"
@ -325,7 +326,7 @@ static BOOL ExtractMSDOS(const char* path)
goto out; goto out;
// Sanity check // Sanity check
if (DiskImageSize < 700*1024) { if (DiskImageSize < 700*KB) {
uprintf("MS-DOS disk image is too small (%d bytes)\n", dllname, DiskImageSize); uprintf("MS-DOS disk image is too small (%d bytes)\n", dllname, DiskImageSize);
goto out; goto out;
} }

View file

@ -1189,7 +1189,7 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
// This helps us reselect the partition scheme option that was used when creating the // This helps us reselect the partition scheme option that was used when creating the
// drive in Rufus. As far as I can tell, Windows doesn't care much if this signature // drive in Rufus. As far as I can tell, Windows doesn't care much if this signature
// isn't unique for USB drives. // isn't unique for USB drives.
CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:GetTickCount(); CreateDisk.Mbr.Signature = mbr_uefi_marker?MBR_UEFI_MARKER:(DWORD)_GetTickCount64();
DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR; DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR;
DriveLayoutEx.PartitionCount = 4; // Must be multiple of 4 for MBR DriveLayoutEx.PartitionCount = 4; // Must be multiple of 4 for MBR

View file

@ -55,7 +55,7 @@
*/ */
DWORD FormatStatus; DWORD FormatStatus;
badblocks_report report; badblocks_report report;
static DWORD LastRefresh; static uint64_t LastRefresh;
static float format_percent = 0.0f; static float format_percent = 0.0f;
static int task_number = 0; static int task_number = 0;
extern const int nb_steps[FS_MAX]; extern const int nb_steps[FS_MAX];
@ -623,8 +623,8 @@ static BOOL FormatFAT32(DWORD DriveIndex)
format_percent = 0.0f; format_percent = 0.0f;
for (i=0; i<(SystemAreaSize+BurstSize-1); i+=BurstSize) { for (i=0; i<(SystemAreaSize+BurstSize-1); i+=BurstSize) {
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*i)/(1.0f*(SystemAreaSize+BurstSize)); format_percent = (100.0f*i)/(1.0f*(SystemAreaSize+BurstSize));
PrintInfo(0, MSG_217, format_percent); PrintInfo(0, MSG_217, format_percent);
UpdateProgress(OP_FORMAT, format_percent); UpdateProgress(OP_FORMAT, format_percent);
@ -1460,8 +1460,8 @@ DWORD WINAPI CloseFormatPromptThread(LPVOID param) {
void update_progress(const uint64_t processed_bytes) void update_progress(const uint64_t processed_bytes)
{ {
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*processed_bytes)/(1.0f*img_report.projected_size); format_percent = (100.0f*processed_bytes)/(1.0f*img_report.projected_size);
PrintInfo(0, MSG_261, format_percent); PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent); UpdateProgress(OP_FORMAT, format_percent);
@ -1613,8 +1613,8 @@ DWORD WINAPI FormatThread(void* param)
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment // http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1)))); aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1))));
for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) { for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) {
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb) / (1.0f*SelectedDrive.DiskSize); format_percent = (100.0f*wb) / (1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_286, format_percent); PrintInfo(0, MSG_286, format_percent);
UpdateProgress(OP_FORMAT, format_percent); UpdateProgress(OP_FORMAT, format_percent);
@ -1762,8 +1762,8 @@ DWORD WINAPI FormatThread(void* param)
} }
if (rSize == 0) if (rSize == 0)
break; break;
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb)/(1.0f*img_report.projected_size); format_percent = (100.0f*wb)/(1.0f*img_report.projected_size);
PrintInfo(0, MSG_261, format_percent); PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent); UpdateProgress(OP_FORMAT, format_percent);
@ -2084,8 +2084,8 @@ DWORD WINAPI SaveImageThread(void* param)
} }
if (rSize == 0) if (rSize == 0)
break; break;
if (GetTickCount() > LastRefresh + 25) { if (_GetTickCount64() > LastRefresh + 25) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
format_percent = (100.0f*wb)/(1.0f*SelectedDrive.DiskSize); format_percent = (100.0f*wb)/(1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_261, format_percent); PrintInfo(0, MSG_261, format_percent);
UpdateProgress(OP_FORMAT, format_percent); UpdateProgress(OP_FORMAT, format_percent);

View file

@ -28,6 +28,7 @@
#include <string.h> #include <string.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h"
#include "resource.h" #include "resource.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"

View file

@ -446,7 +446,7 @@ static void CALLBACK OutputMessageTimeout(HWND hWnd, UINT uMsg, UINT_PTR idEvent
KillTimer(hMainDialog, idEvent); KillTimer(hMainDialog, idEvent);
bOutputTimerArmed[i] = FALSE; bOutputTimerArmed[i] = FALSE;
PrintMessage[i](output_msg[i]); PrintMessage[i](output_msg[i]);
last_msg_time[i] = GetTickCount64(); last_msg_time[i] = _GetTickCount64();
} }
static void OutputMessage(BOOL info, char* msg) static void OutputMessage(BOOL info, char* msg)
@ -459,7 +459,7 @@ static void OutputMessage(BOOL info, char* msg)
output_msg[i] = msg; output_msg[i] = msg;
} else { } else {
// Find if we need to arm a timer // Find if we need to arm a timer
delta = GetTickCount64() - last_msg_time[i]; delta = _GetTickCount64() - last_msg_time[i];
if (delta < MSG_DELAY) { if (delta < MSG_DELAY) {
// Not enough time has elapsed since our last output => arm a timer // Not enough time has elapsed since our last output => arm a timer
output_msg[i] = msg; output_msg[i] = msg;
@ -467,7 +467,7 @@ static void OutputMessage(BOOL info, char* msg)
bOutputTimerArmed[i] = TRUE; bOutputTimerArmed[i] = TRUE;
} else { } else {
PrintMessage[i](msg); PrintMessage[i](msg);
last_msg_time[i] = GetTickCount64(); last_msg_time[i] = _GetTickCount64();
} }
} }
} }

View file

@ -51,6 +51,12 @@ static __inline void *_reallocf(void *ptr, size_t size) {
return ret; return ret;
} }
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */
#define _RT_ICON MAKEINTRESOURCEA(3)
#define _RT_DIALOG MAKEINTRESOURCEA(5)
#define _RT_RCDATA MAKEINTRESOURCEA(10)
#define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11))
/* UI redefinitions for WDK and MinGW */ /* UI redefinitions for WDK and MinGW */
#ifndef PBM_SETSTATE #ifndef PBM_SETSTATE
#define PBM_SETSTATE (WM_USER+16) #define PBM_SETSTATE (WM_USER+16)
@ -212,3 +218,13 @@ typedef struct _ATTACH_VIRTUAL_DISK_PARAMETERS {
#if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY) #if !defined(ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY)
#define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174) #define ERROR_INTERNET_LOGIN_FAILURE_DISPLAY_ENTITY_BODY (INTERNET_ERROR_BASE + 174)
#endif #endif
/* Clang/MinGW32 has an issue with intptr_t */
#ifndef _UINTPTR_T_DEFINED
#define _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif

View file

@ -31,6 +31,7 @@
#include <inttypes.h> #include <inttypes.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h"
#include "resource.h" #include "resource.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"
#include "localization.h" #include "localization.h"
@ -38,7 +39,7 @@
#include "settings.h" #include "settings.h"
/* Maximum download chunk size, in bytes */ /* Maximum download chunk size, in bytes */
#define DOWNLOAD_BUFFER_SIZE 10240 #define DOWNLOAD_BUFFER_SIZE 10*KB
/* Default delay between update checks (1 day) */ /* Default delay between update checks (1 day) */
#define DEFAULT_UPDATE_INTERVAL (24*3600) #define DEFAULT_UPDATE_INTERVAL (24*3600)

View file

@ -94,6 +94,7 @@ OPENED_LIBRARIES_VARS;
HINSTANCE hMainInstance; HINSTANCE hMainInstance;
HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL; HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL;
MY_BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 }; MY_BUTTON_IMAGELIST bi_iso = { 0 }, bi_up = { 0 }, bi_down = { 0 };
GetTickCount64_t pfGetTickCount64 = NULL;
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH]; char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
char* image_path = NULL; char* image_path = NULL;
float fScale = 1.0f; float fScale = 1.0f;
@ -2038,7 +2039,8 @@ void SaveVHD(void)
*/ */
static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
static DWORD DeviceNum = 0, LastRefresh = 0; static DWORD DeviceNum = 0;
static uint64_t LastRefresh = 0;
static BOOL first_log_display = TRUE, isMarquee = FALSE; static BOOL first_log_display = TRUE, isMarquee = FALSE;
static ULONG ulRegister = 0; static ULONG ulRegister = 0;
static LPITEMIDLIST pidlDesktop = NULL; static LPITEMIDLIST pidlDesktop = NULL;
@ -2078,15 +2080,15 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case DBT_DEVICEARRIVAL: case DBT_DEVICEARRIVAL:
case DBT_DEVICEREMOVECOMPLETE: case DBT_DEVICEREMOVECOMPLETE:
case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change
LastRefresh = GetTickCount(); // Don't care about 49.7 days rollback of GetTickCount() LastRefresh = _GetTickCount64();
KillTimer(hMainDialog, TID_REFRESH_TIMER); KillTimer(hMainDialog, TID_REFRESH_TIMER);
GetUSBDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList))); GetUSBDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)));
user_changed_label = FALSE; user_changed_label = FALSE;
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case DBT_DEVNODES_CHANGED: case DBT_DEVNODES_CHANGED:
// If it's been more than a second since last device refresh, arm a refresh timer // If it's been more than a second since last device refresh, arm a refresh timer
if (GetTickCount() > LastRefresh + 1000) { if (_GetTickCount64() > LastRefresh + 1000) {
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer); SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer);
} }
break; break;
@ -2789,6 +2791,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
#endif #endif
uprintf("*** " APPLICATION_NAME " init ***\n"); uprintf("*** " APPLICATION_NAME " init ***\n");
PF_INIT(GetTickCount64, kernel32);
// Reattach the console, if we were started from commandline // Reattach the console, if we were started from commandline
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) { if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
@ -3009,7 +3012,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
uprintf("Failed to enable AutoMount"); uprintf("Failed to enable AutoMount");
} }
} }
srand((unsigned int)GetTickCount()); srand((unsigned int)_GetTickCount64());
relaunch: relaunch:
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]); uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);

View file

@ -23,7 +23,7 @@
#if defined(_MSC_VER) #if defined(_MSC_VER)
// Disable some VS2012 Code Analysis warnings // Disable some VS2012 Code Analysis warnings
#pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP #pragma warning(disable: 4996) // Ignore deprecated (eg. GetVersionEx()), as we have to contend with XP
#pragma warning(disable: 28159) // VS2012 wants us to use GetTickCount64(), but it's not available on XP #pragma warning(disable: 28159) // We use GetTickCount64() where possible, but it's not available on XP
#pragma warning(disable: 6258) // I know what I'm using TerminateThread for #pragma warning(disable: 6258) // I know what I'm using TerminateThread for
#endif #endif
@ -537,16 +537,6 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \ if (pf##proc == NULL) {uprintf("Unable to locate %s() in %s.dll: %s\n", \
#proc, #name, WindowsErrorString()); goto out;} } while(0) #proc, #name, WindowsErrorString()); goto out;} } while(0)
/* Clang/MinGW32 has an issue with intptr_t */
#ifndef _UINTPTR_T_DEFINED
#define _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif
/* Custom application errors */ /* Custom application errors */
#define FAC(f) (f<<16) #define FAC(f) (f<<16)
#define APPERR(err) (APPLICATION_ERROR_MASK|err) #define APPERR(err) (APPLICATION_ERROR_MASK|err)
@ -563,8 +553,7 @@ static __inline HMODULE GetLibraryHandle(char* szLibraryName) {
#define ERROR_CANT_ASSIGN_LETTER 0x120B #define ERROR_CANT_ASSIGN_LETTER 0x120B
#define ERROR_CANT_MOUNT_VOLUME 0x120C #define ERROR_CANT_MOUNT_VOLUME 0x120C
/* Why oh why does Microsoft have to make everybody suffer with their braindead use of Unicode? */ /* GetTickCount64 not being available on XP is a massive bother */
#define _RT_ICON MAKEINTRESOURCEA(3) PF_TYPE(WINAPI, ULONGLONG, GetTickCount64, (void));
#define _RT_DIALOG MAKEINTRESOURCEA(5) extern GetTickCount64_t pfGetTickCount64;
#define _RT_RCDATA MAKEINTRESOURCEA(10) #define _GetTickCount64() ((pfGetTickCount64 != NULL)?(uint64_t)pfGetTickCount64():(uint64_t)GetTickCount())
#define _RT_GROUP_ICON MAKEINTRESOURCEA((ULONG_PTR)(MAKEINTRESOURCEA(3) + 11))

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
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 2.8.866" CAPTION "Rufus 2.8.867"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -320,8 +320,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,8,866,0 FILEVERSION 2,8,867,0
PRODUCTVERSION 2,8,866,0 PRODUCTVERSION 2,8,867,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -338,13 +338,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", "2.8.866" VALUE "FileVersion", "2.8.867"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2016 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", "2.8.866" VALUE "ProductVersion", "2.8.867"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -31,7 +31,7 @@ extern char* ini_file;
#define SETTING_LAST_UPDATE "LastUpdateCheck" #define SETTING_LAST_UPDATE "LastUpdateCheck"
#define SETTING_UPDATE_INTERVAL "UpdateCheckInterval" #define SETTING_UPDATE_INTERVAL "UpdateCheckInterval"
#define SETTING_INCLUDE_BETAS "CheckForBetas" #define SETTING_INCLUDE_BETAS "CheckForBetas"
#define SETTING_COMM_CHECK "CommCheck" #define SETTING_COMM_CHECK "CommCheck64"
#define SETTING_LOCALE "Locale" #define SETTING_LOCALE "Locale"
#define SETTING_DISABLE_LGP "DisableLGP" #define SETTING_DISABLE_LGP "DisableLGP"

View file

@ -35,6 +35,7 @@
#include <richedit.h> #include <richedit.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h"
#include "resource.h" #include "resource.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"
#include "localization.h" #include "localization.h"
@ -1358,14 +1359,14 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
BOOL SetUpdateCheck(void) BOOL SetUpdateCheck(void)
{ {
BOOL enable_updates; BOOL enable_updates;
DWORD commcheck = GetTickCount(); uint64_t commcheck = _GetTickCount64();
notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback }; notification_info more_info = { IDD_UPDATE_POLICY, UpdateCallback };
char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe"; char filename[MAX_PATH] = "", exename[] = APPLICATION_NAME ".exe";
size_t fn_len, exe_len; size_t fn_len, exe_len;
// Test if we can read and write settings. If not, forget it. // Test if we can read and write settings. If not, forget it.
WriteSetting32(SETTING_COMM_CHECK, commcheck); WriteSetting64(SETTING_COMM_CHECK, commcheck);
if (ReadSetting32(SETTING_COMM_CHECK) != commcheck) if (ReadSetting64(SETTING_COMM_CHECK) != commcheck)
return FALSE; return FALSE;
settings_commcheck = TRUE; settings_commcheck = TRUE;

View file

@ -27,6 +27,7 @@
#include <ctype.h> #include <ctype.h>
#include "rufus.h" #include "rufus.h"
#include "missing.h"
#include "resource.h" #include "resource.h"
#include "msapi_utf8.h" #include "msapi_utf8.h"
#include "localization.h" #include "localization.h"

View file

@ -103,7 +103,7 @@ static char sevenzip_path[MAX_PATH];
static const char conectix_str[] = VHD_FOOTER_COOKIE; static const char conectix_str[] = VHD_FOOTER_COOKIE;
static uint32_t wim_nb_files, wim_proc_files; static uint32_t wim_nb_files, wim_proc_files;
static BOOL count_files; static BOOL count_files;
static DWORD LastRefresh; static uint64_t LastRefresh;
static BOOL Get7ZipPath(void) static BOOL Get7ZipPath(void)
{ {
@ -573,12 +573,12 @@ DWORD WINAPI WimProgressCallback(DWORD dwMsgId, WPARAM wParam, LPARAM lParam, PV
wim_nb_files++; wim_nb_files++;
} else { } else {
wim_proc_files++; wim_proc_files++;
if (GetTickCount() > LastRefresh + 100) { if (_GetTickCount64() > LastRefresh + 100) {
// At the end of an actual apply, the WIM API re-lists a bunch of directories it // At the end of an actual apply, the WIM API re-lists a bunch of directories it
// already processed, so we end up with more entries than counted - ignore those. // already processed, so we end up with more entries than counted - ignore those.
if (wim_proc_files > wim_nb_files) if (wim_proc_files > wim_nb_files)
wim_proc_files = wim_nb_files; wim_proc_files = wim_nb_files;
LastRefresh = GetTickCount(); LastRefresh = _GetTickCount64();
// x^3 progress, so as not to give a better idea right from the onset // x^3 progress, so as not to give a better idea right from the onset
// as to the dismal speed with which the WIM API can actually apply files... // as to the dismal speed with which the WIM API can actually apply files...
apply_percent = 4.636942595f * ((float)wim_proc_files) / ((float)wim_nb_files); apply_percent = 4.636942595f * ((float)wim_proc_files) / ((float)wim_nb_files);