mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] improve logging data
* Display the selected locate as well as LGP info in the log * Also fix some potential Coverity warnings
This commit is contained in:
parent
3924d2847d
commit
afec69c428
10 changed files with 73 additions and 38 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
*.a
|
||||
*.aps
|
||||
*.appx
|
||||
*.db
|
||||
*.db-shm
|
||||
*.db-wal
|
||||
|
@ -18,6 +19,7 @@
|
|||
*.obj
|
||||
*.opendb
|
||||
*.opt
|
||||
*.patch
|
||||
*.pc
|
||||
*.pdb
|
||||
*.plg
|
||||
|
@ -40,6 +42,8 @@ config.guess
|
|||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
cov-int
|
||||
cov-int.zip
|
||||
embedded.loc
|
||||
rufus_files
|
||||
depcomp
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
@echo off
|
||||
"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool" sign /v /sha1 655f6413a8f721e3286ace95025c9e0ea132a984 /fd SHA1 /tr http://timestamp.comodoca.com/rfc3161 /td SHA1 %1
|
||||
if ERRORLEVEL 1 goto out
|
||||
"C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool" sign /as /v /sha1 5759b23dc8f45e9120a7317f306e5b6890b612f0 /fd SHA256 /tr http://timestamp.comodoca.com/rfc3161 /td SHA256 %1
|
||||
:out
|
||||
exit
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Localization functions, a.k.a. "Everybody is doing it wrong but me!"
|
||||
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2013-2017 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* 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
|
||||
|
@ -642,8 +642,6 @@ WORD get_language_id(loc_cmd* lcmd)
|
|||
wchar_t wlang[5];
|
||||
LANGID lang_id = GetUserDefaultUILanguage();
|
||||
|
||||
// Log will be reset, so we need to use the buffered uprintf() to get our messages to the user
|
||||
ubclear();
|
||||
if (lcmd == NULL)
|
||||
return MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ static __inline DWORD FormatMessageU(DWORD dwFlags, LPCVOID lpSource, DWORD dwMe
|
|||
DWORD dwLanguageId, char* lpBuffer, DWORD nSize, va_list *Arguments)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nSize);
|
||||
ret = FormatMessageW(dwFlags, lpSource, dwMessageId, dwLanguageId, wlpBuffer, nSize, Arguments);
|
||||
err = GetLastError();
|
||||
|
@ -170,6 +171,7 @@ static __inline BOOL SHGetPathFromIDListU(LPCITEMIDLIST pidl, char* pszPath)
|
|||
{
|
||||
BOOL ret = FALSE;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(pszPath, MAX_PATH);
|
||||
ret = SHGetPathFromIDListW(pidl, wpszPath);
|
||||
err = GetLastError();
|
||||
|
@ -246,6 +248,7 @@ static __inline int LoadStringU(HINSTANCE hInstance, UINT uID, LPSTR lpBuffer, i
|
|||
{
|
||||
int ret;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nBufferMax);
|
||||
ret = LoadStringW(hInstance, uID, wlpBuffer, nBufferMax);
|
||||
err = GetLastError();
|
||||
|
@ -273,6 +276,7 @@ static __inline int GetWindowTextU(HWND hWnd, char* lpString, int nMaxCount)
|
|||
{
|
||||
int ret = 0;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpString, nMaxCount);
|
||||
ret = GetWindowTextW(hWnd, wlpString, nMaxCount);
|
||||
err = GetLastError();
|
||||
|
@ -332,6 +336,7 @@ static __inline UINT GetDlgItemTextU(HWND hDlg, int nIDDlgItem, char* lpString,
|
|||
{
|
||||
UINT ret = 0;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpString, nMaxCount);
|
||||
ret = GetDlgItemTextW(hDlg, nIDDlgItem, wlpString, nMaxCount);
|
||||
err = GetLastError();
|
||||
|
@ -458,6 +463,7 @@ static __inline BOOL GetTextExtentPointU(HDC hdc, const char* lpString, LPSIZE l
|
|||
static __inline DWORD GetCurrentDirectoryU(DWORD nBufferLength, char* lpBuffer)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nBufferLength);
|
||||
ret = GetCurrentDirectoryW(nBufferLength, wlpBuffer);
|
||||
err = GetLastError();
|
||||
|
@ -472,6 +478,7 @@ static __inline DWORD GetCurrentDirectoryU(DWORD nBufferLength, char* lpBuffer)
|
|||
static __inline UINT GetSystemDirectoryU(char* lpBuffer, UINT uSize)
|
||||
{
|
||||
UINT ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, uSize);
|
||||
ret = GetSystemDirectoryW(wlpBuffer, uSize);
|
||||
err = GetLastError();
|
||||
|
@ -486,6 +493,7 @@ static __inline UINT GetSystemDirectoryU(char* lpBuffer, UINT uSize)
|
|||
static __inline UINT GetSystemWindowsDirectoryU(char* lpBuffer, UINT uSize)
|
||||
{
|
||||
UINT ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, uSize);
|
||||
ret = GetSystemWindowsDirectoryW(wlpBuffer, uSize);
|
||||
err = GetLastError();
|
||||
|
@ -500,6 +508,7 @@ static __inline UINT GetSystemWindowsDirectoryU(char* lpBuffer, UINT uSize)
|
|||
static __inline DWORD GetTempPathU(DWORD nBufferLength, char* lpBuffer)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nBufferLength);
|
||||
ret = GetTempPathW(nBufferLength, wlpBuffer);
|
||||
err = GetLastError();
|
||||
|
@ -516,6 +525,7 @@ static __inline DWORD GetTempFileNameU(char* lpPathName, char* lpPrefixString, U
|
|||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
wconvert(lpPathName);
|
||||
wconvert(lpPrefixString);
|
||||
// coverity[returned_null]
|
||||
walloc(lpTempFileName, MAX_PATH);
|
||||
ret = GetTempFileNameW(wlpPathName, wlpPrefixString, uUnique, wlpTempFileName);
|
||||
err = GetLastError();
|
||||
|
@ -532,6 +542,7 @@ static __inline DWORD GetTempFileNameU(char* lpPathName, char* lpPrefixString, U
|
|||
static __inline DWORD GetModuleFileNameU(HMODULE hModule, char* lpFilename, DWORD nSize)
|
||||
{
|
||||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(lpFilename, nSize);
|
||||
ret = GetModuleFileNameW(hModule, wlpFilename, nSize);
|
||||
err = GetLastError();
|
||||
|
@ -548,6 +559,7 @@ static __inline DWORD GetFullPathNameU(const char* lpFileName, DWORD nBufferLeng
|
|||
DWORD ret = 0, err = ERROR_INVALID_DATA;
|
||||
wchar_t* wlpFilePart;
|
||||
wconvert(lpFileName);
|
||||
// coverity[returned_null]
|
||||
walloc(lpBuffer, nBufferLength);
|
||||
|
||||
// lpFilePart is not supported
|
||||
|
@ -595,6 +607,7 @@ static __inline int SHDeleteDirectoryExU(HWND hwnd, const char* pszPath, FILEOP_
|
|||
// 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.
|
||||
size_t wpszPath_len = strlen(pszPath) + 2;
|
||||
// coverity[returned_null]
|
||||
walloc(pszPath, wpszPath_len);
|
||||
SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL };
|
||||
utf8_to_wchar_no_alloc(pszPath, wpszPath, (int)wpszPath_len);
|
||||
|
@ -788,6 +801,7 @@ static __inline BOOL SetupCopyOEMInfU(const char* SourceInfFileName, const char*
|
|||
DWORD err = ERROR_INVALID_DATA;
|
||||
wconvert(SourceInfFileName);
|
||||
wconvert(OEMSourceMediaLocation);
|
||||
// coverity[returned_null]
|
||||
walloc(DestinationInfFileName, DestinationInfFileNameSize);
|
||||
|
||||
// DestinationInfFileNameComponent is not supported
|
||||
|
@ -898,6 +912,7 @@ static __inline BOOL SetupDiGetDeviceRegistryPropertyU(HDEVINFO DeviceInfoSet, P
|
|||
{
|
||||
BOOL ret = FALSE;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
// coverity[returned_null]
|
||||
walloc(PropertyBuffer, PropertyBufferSize);
|
||||
|
||||
ret = SetupDiGetDeviceRegistryPropertyW(DeviceInfoSet, DeviceInfoData, Property,
|
||||
|
@ -920,7 +935,9 @@ static __inline BOOL GetVolumeInformationU(LPCSTR lpRootPathName, LPSTR lpVolume
|
|||
BOOL ret = FALSE;
|
||||
DWORD err = ERROR_INVALID_DATA;
|
||||
wconvert(lpRootPathName);
|
||||
// coverity[returned_null]
|
||||
walloc(lpVolumeNameBuffer, nVolumeNameSize);
|
||||
// coverity[returned_null]
|
||||
walloc(lpFileSystemNameBuffer, nFileSystemNameSize);
|
||||
|
||||
ret = GetVolumeInformationW(wlpRootPathName, wlpVolumeNameBuffer, nVolumeNameSize,
|
||||
|
|
|
@ -86,10 +86,14 @@ static __inline BOOL _GetRegistryKey(HKEY key_root, const char* key_name, DWORD
|
|||
if (i != 0) {
|
||||
// Prefix with "SOFTWARE" if needed
|
||||
if (_strnicmp(key_name, software_prefix, sizeof(software_prefix) - 1) != 0) {
|
||||
if (i + sizeof(software_prefix) >= sizeof(long_key_name))
|
||||
return FALSE;
|
||||
strcpy(long_key_name, software_prefix);
|
||||
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
|
||||
long_key_name[sizeof(software_prefix) + i - 1] = 0;
|
||||
} else {
|
||||
if (i >= sizeof(long_key_name))
|
||||
return FALSE;
|
||||
safe_strcpy(long_key_name, sizeof(long_key_name), key_name);
|
||||
long_key_name[i] = 0;
|
||||
}
|
||||
|
@ -157,10 +161,14 @@ static __inline BOOL _SetRegistryKey(HKEY key_root, const char* key_name, DWORD
|
|||
} else {
|
||||
// Prefix with "SOFTWARE" if needed
|
||||
if (_strnicmp(key_name, software_prefix, sizeof(software_prefix) - 1) != 0) {
|
||||
if (i + sizeof(software_prefix) >= sizeof(long_key_name))
|
||||
goto out;
|
||||
strcpy(long_key_name, software_prefix);
|
||||
safe_strcat(long_key_name, sizeof(long_key_name), key_name);
|
||||
long_key_name[sizeof(software_prefix) + i - 1] = 0;
|
||||
} else {
|
||||
if (i >= sizeof(long_key_name))
|
||||
goto out;
|
||||
safe_strcpy(long_key_name, sizeof(long_key_name), key_name);
|
||||
long_key_name[i] = 0;
|
||||
}
|
||||
|
|
15
src/rufus.c
15
src/rufus.c
|
@ -1644,7 +1644,7 @@ static INT_PTR CALLBACK InfoCallback(HWND hCtrl, UINT message, WPARAM wParam, LP
|
|||
return CallWindowProc(info_original_proc, hCtrl, message, wParam, lParam);
|
||||
}
|
||||
|
||||
void InitDialog(HWND hDlg)
|
||||
static void InitDialog(HWND hDlg)
|
||||
{
|
||||
HINSTANCE hShell32DllInst, hUserLanguagesCplDllInst, hINetCplDllInst;
|
||||
HIMAGELIST hLangToolbarImageList;
|
||||
|
@ -1933,7 +1933,7 @@ static void PrintStatusTimeout(const char* str, BOOL val)
|
|||
PrintStatus(STATUS_MSG_TIMEOUT, (val)?MSG_250:MSG_251, str);
|
||||
}
|
||||
|
||||
void ShowLanguageMenu(RECT rcExclude)
|
||||
static void ShowLanguageMenu(RECT rcExclude)
|
||||
{
|
||||
TPMPARAMS tpm;
|
||||
HMENU menu;
|
||||
|
@ -1968,7 +1968,7 @@ void ShowLanguageMenu(RECT rcExclude)
|
|||
DestroyMenu(menu);
|
||||
}
|
||||
|
||||
void SetBoot(int fs, int tt)
|
||||
static void SetBoot(int fs, int tt)
|
||||
{
|
||||
int i;
|
||||
char tmp[32];
|
||||
|
@ -2018,7 +2018,7 @@ void SetBoot(int fs, int tt)
|
|||
}
|
||||
}
|
||||
|
||||
void SaveVHD(void)
|
||||
static void SaveVHD(void)
|
||||
{
|
||||
static IMG_SAVE img_save = { 0 };
|
||||
char filename[128];
|
||||
|
@ -2082,7 +2082,7 @@ void SaveVHD(void)
|
|||
}
|
||||
}
|
||||
|
||||
void SaveISO(void)
|
||||
static void SaveISO(void)
|
||||
{
|
||||
static IMG_SAVE img_save = { 0 };
|
||||
char filename[33] = "disc_image.iso";
|
||||
|
@ -3174,7 +3174,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
|||
}
|
||||
|
||||
relaunch:
|
||||
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);
|
||||
ubpushf("Localization set to '%s'", selected_locale->txt[0]);
|
||||
right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
|
||||
SetProcessDefaultLayout(right_to_left_mode?LAYOUT_RTL:0);
|
||||
if (get_loc_data_file(loc_file, selected_locale))
|
||||
|
@ -3207,7 +3207,7 @@ relaunch:
|
|||
|
||||
// Set the hook to automatically close Windows' "You need to format the disk in drive..." prompt
|
||||
if (!SetFormatPromptHook())
|
||||
uprintf("Warning:Could not set 'Format Disk' prompt auto-close");
|
||||
uprintf("Warning: Could not set 'Format Disk' prompt auto-close");
|
||||
|
||||
ShowWindow(hDlg, SW_SHOWNORMAL);
|
||||
UpdateWindow(hDlg);
|
||||
|
@ -3452,6 +3452,7 @@ out:
|
|||
SetLGP(TRUE, &existing_key, ep_reg, "NoDriveTypeAutorun", 0);
|
||||
if ((nWindowsVersion > WINDOWS_XP) && (!automount) && (!SetAutoMount(FALSE)))
|
||||
uprintf("Failed to restore AutoMount to disabled");
|
||||
ubpop();
|
||||
// Unconditional delete with retry, just in case...
|
||||
for (i = 0; (!DeleteFileA(cmdline_hogger)) && (i <= 10); i++)
|
||||
Sleep(200);
|
||||
|
|
11
src/rufus.h
11
src/rufus.h
|
@ -77,6 +77,7 @@
|
|||
#define MAX_FAT32_SIZE 2.0f // Threshold above which we disable FAT32 formatting (in TB)
|
||||
#define FAT32_CLUSTER_THRESHOLD 1.011f // For FAT32, cluster size changes don't occur at power of 2 boundaries but sligthly above
|
||||
#define DD_BUFFER_SIZE 65536 // Minimum size of the buffer we use for DD operations
|
||||
#define UBUFFER_SIZE 2048
|
||||
#define RUFUS_URL "https://rufus.akeo.ie"
|
||||
#define DOWNLOAD_URL RUFUS_URL "/downloads"
|
||||
#define FILES_URL RUFUS_URL "/files"
|
||||
|
@ -121,9 +122,10 @@
|
|||
#ifdef RUFUS_DEBUG
|
||||
extern void _uprintf(const char *format, ...);
|
||||
#define uprintf(...) _uprintf(__VA_ARGS__)
|
||||
#define ubclear() do { ubuffer[0] = 0; } while (0);
|
||||
#define ubpushf(...) static_sprintf(ubuffer, __VA_ARGS__)
|
||||
#define ubpop() uprintf("%s", ubuffer)
|
||||
#define ubpushf(...) do { safe_sprintf(&ubuffer[ubuffer_pos], UBUFFER_SIZE - ubuffer_pos - 2, __VA_ARGS__); \
|
||||
ubuffer_pos = strlen(ubuffer); ubuffer[ubuffer_pos++] = '\r'; ubuffer[ubuffer_pos++] = '\n'; \
|
||||
ubuffer[ubuffer_pos] = 0; } while(0)
|
||||
#define ubpop() do { if (ubuffer_pos) uprintf("%s", ubuffer); ubuffer_pos = 0; } while(0)
|
||||
#define vuprintf(...) if (verbose) _uprintf(__VA_ARGS__)
|
||||
#define vvuprintf(...) if (verbose > 1) _uprintf(__VA_ARGS__)
|
||||
#define suprintf(...) if (!bSilent) _uprintf(__VA_ARGS__)
|
||||
|
@ -392,7 +394,8 @@ extern uint16_t rufus_version[3], embedded_sl_version[2];
|
|||
extern int nWindowsVersion;
|
||||
extern int nWindowsBuildNumber;
|
||||
extern char WindowsVersionStr[128];
|
||||
extern char ubuffer[256];
|
||||
extern size_t ubuffer_pos;
|
||||
extern char ubuffer[UBUFFER_SIZE];
|
||||
extern char embedded_sl_version_str[2][12];
|
||||
extern RUFUS_UPDATE update;
|
||||
extern int dialog_showing;
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 242, 376
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 2.15.1091"
|
||||
CAPTION "Rufus 2.15.1092"
|
||||
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
|
||||
|
@ -334,8 +334,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 2,15,1091,0
|
||||
PRODUCTVERSION 2,15,1091,0
|
||||
FILEVERSION 2,15,1092,0
|
||||
PRODUCTVERSION 2,15,1092,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -352,13 +352,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "2.15.1091"
|
||||
VALUE "FileVersion", "2.15.1092"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "2.15.1091"
|
||||
VALUE "ProductVersion", "2.15.1092"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
37
src/stdfn.c
37
src/stdfn.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Standard Windows function calls
|
||||
* Copyright © 2013-2016 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2013-2017 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* 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
|
||||
|
@ -717,19 +717,19 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
// We need an IGroupPolicyObject instance to set a Local Group Policy
|
||||
hr = CoCreateInstance(&my_CLSID_GroupPolicyObject, NULL, CLSCTX_INPROC_SERVER, &my_IID_IGroupPolicyObject, (LPVOID*)&pLGPO);
|
||||
if (FAILED(hr)) {
|
||||
uprintf("SetLGP: CoCreateInstance failed; hr = %x\n", hr);
|
||||
ubpushf("SetLGP: CoCreateInstance failed; hr = %x", hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
hr = pLGPO->lpVtbl->OpenLocalMachineGPO(pLGPO, GPO_OPEN_LOAD_REGISTRY);
|
||||
if (FAILED(hr)) {
|
||||
uprintf("SetLGP: OpenLocalMachineGPO failed - error %x\n", hr);
|
||||
ubpushf("SetLGP: OpenLocalMachineGPO failed - error %x", hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
hr = pLGPO->lpVtbl->GetRegistryKey(pLGPO, GPO_SECTION_MACHINE, &path_key);
|
||||
if (FAILED(hr)) {
|
||||
uprintf("SetLGP: GetRegistryKey failed - error %x\n", hr);
|
||||
ubpushf("SetLGP: GetRegistryKey failed - error %x", hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -737,7 +737,7 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
r = RegCreateKeyExA(path_key, p->szPath, 0, NULL, 0, KEY_SET_VALUE | KEY_QUERY_VALUE,
|
||||
NULL, &policy_key, &disp);
|
||||
if (r != ERROR_SUCCESS) {
|
||||
uprintf("SetLGP: Failed to open LGPO path %s - error %x\n", p->szPath, hr);
|
||||
ubpushf("SetLGP: Failed to open LGPO path %s - error %x", p->szPath, hr);
|
||||
policy_key = NULL;
|
||||
goto error;
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
// The Key exists but not its value, which is OK
|
||||
*(p->bExistingKey) = FALSE;
|
||||
} else if (r != ERROR_SUCCESS) {
|
||||
uprintf("SetLGP: Failed to read original %s policy value - error %x\n", p->szPolicy, r);
|
||||
ubpushf("SetLGP: Failed to read original %s policy value - error %x", p->szPolicy, r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
r = RegDeleteValueA(policy_key, p->szPolicy);
|
||||
}
|
||||
if (r != ERROR_SUCCESS) {
|
||||
uprintf("SetLGP: RegSetValueEx / RegDeleteValue failed - error %x\n", r);
|
||||
ubpushf("SetLGP: RegSetValueEx / RegDeleteValue failed - error %x", r);
|
||||
}
|
||||
RegCloseKey(policy_key);
|
||||
policy_key = NULL;
|
||||
|
@ -770,13 +770,13 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
// Apply policy
|
||||
hr = pLGPO->lpVtbl->Save(pLGPO, TRUE, (p->bRestore)?FALSE:TRUE, &ext_guid, &snap_guid);
|
||||
if (hr != S_OK) {
|
||||
uprintf("SetLGP: Unable to apply %s policy - error %x\n", p->szPolicy, hr);
|
||||
ubpushf("SetLGP: Unable to apply %s policy - error %x", p->szPolicy, hr);
|
||||
goto error;
|
||||
} else {
|
||||
if ((!p->bRestore) || (*(p->bExistingKey))) {
|
||||
uprintf("SetLGP: Successfully %s %s policy to 0x%08X\n", (p->bRestore)?"restored":"set", p->szPolicy, val);
|
||||
ubpushf("SetLGP: Successfully %s %s policy to 0x%08X", (p->bRestore)?"restored":"set", p->szPolicy, val);
|
||||
} else {
|
||||
uprintf("SetLGP: Successfully removed %s policy key\n", p->szPolicy);
|
||||
ubpushf("SetLGP: Successfully removed %s policy key", p->szPolicy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -785,8 +785,10 @@ DWORD WINAPI SetLGPThread(LPVOID param)
|
|||
return TRUE;
|
||||
|
||||
error:
|
||||
if (path_key != NULL) RegCloseKey(path_key);
|
||||
if (pLGPO != NULL) pLGPO->lpVtbl->Release(pLGPO);
|
||||
if (path_key != NULL)
|
||||
RegCloseKey(path_key);
|
||||
if (pLGPO != NULL)
|
||||
pLGPO->lpVtbl->Release(pLGPO);
|
||||
return FALSE;
|
||||
}
|
||||
#pragma pop_macro("INTERFACE")
|
||||
|
@ -798,17 +800,17 @@ BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* s
|
|||
HANDLE thread_id;
|
||||
|
||||
if (ReadSettingBool(SETTING_DISABLE_LGP)) {
|
||||
uprintf("LPG handling disabled, per settings");
|
||||
ubpushf("LPG handling disabled, per settings");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
thread_id = CreateThread(NULL, 0, SetLGPThread, (LPVOID)¶ms, 0, NULL);
|
||||
if (thread_id == NULL) {
|
||||
uprintf("SetLGP: Unable to start thread");
|
||||
ubpushf("SetLGP: Unable to start thread");
|
||||
return FALSE;
|
||||
}
|
||||
if (WaitForSingleObject(thread_id, 60000) != WAIT_OBJECT_0) {
|
||||
uprintf("SetLGP: Killing stuck thread!");
|
||||
if (WaitForSingleObject(thread_id, 5000) != WAIT_OBJECT_0) {
|
||||
ubpushf("SetLGP: Killing stuck thread!");
|
||||
TerminateThread(thread_id, 0);
|
||||
CloseHandle(thread_id);
|
||||
return FALSE;
|
||||
|
@ -877,8 +879,7 @@ BOOL IsCurrentProcessElevated(void)
|
|||
goto out;
|
||||
}
|
||||
r = (te.TokenIsElevated != 0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
uprintf("Note: UAC is either disabled or not available");
|
||||
if (!AllocateAndInitializeSid(&auth, 2, SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &psid))
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
* Globals
|
||||
*/
|
||||
HWND hStatus;
|
||||
char ubuffer[256]; // Buffer for ubpushf() messages we don't log right away
|
||||
size_t ubuffer_pos = 0;
|
||||
char ubuffer[UBUFFER_SIZE]; // Buffer for ubpushf() messages we don't log right away
|
||||
|
||||
#ifdef RUFUS_DEBUG
|
||||
void _uprintf(const char *format, ...)
|
||||
|
|
Loading…
Reference in a new issue