mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[loc] fix crash when two Rufus applications are running
* Closes #261 * Also remove the need for a separate get_loc_data_file call to initialize the en-US messages * Also fix a possible issue with setLGP
This commit is contained in:
parent
83a9ec472c
commit
0f02284164
3 changed files with 29 additions and 34 deletions
33
src/parser.c
33
src/parser.c
|
@ -352,11 +352,13 @@ out:
|
||||||
/*
|
/*
|
||||||
* Parse a locale section in a localization file (UTF-8, no BOM)
|
* Parse a locale section in a localization file (UTF-8, no BOM)
|
||||||
* NB: this call is reentrant for the "base" command support
|
* NB: this call is reentrant for the "base" command support
|
||||||
|
* TODO: Working on memory rather than on file would improve performance
|
||||||
*/
|
*/
|
||||||
BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd)
|
BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd)
|
||||||
{
|
{
|
||||||
size_t bufsize = 1024;
|
size_t bufsize = 1024;
|
||||||
static FILE* fd = NULL;
|
static FILE* fd = NULL;
|
||||||
|
static BOOL populate_default = FALSE;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
int r = 0, line_nr_incr = 1;
|
int r = 0, line_nr_incr = 1;
|
||||||
|
@ -367,30 +369,29 @@ BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd)
|
||||||
// The default locale is always the first one
|
// The default locale is always the first one
|
||||||
loc_cmd* default_locale = list_entry(locale_list.next, loc_cmd, list);
|
loc_cmd* default_locale = list_entry(locale_list.next, loc_cmd, list);
|
||||||
|
|
||||||
// We keep a default message table populated with the en-US messages.
|
if ((lcmd == NULL) || (default_locale == NULL)) {
|
||||||
// Ensure that it got properly initialized first.
|
uprintf("localization: no %slocale", (default_locale == NULL)?"default ":" ");
|
||||||
if ((msg_table == NULL) && (lcmd != NULL)) {
|
goto out;
|
||||||
uprintf("localization: default message table has not been populated!");
|
}
|
||||||
return FALSE;
|
|
||||||
} else if ((msg_table != NULL) && (lcmd == NULL)) {
|
if (msg_table == NULL) {
|
||||||
uprintf("localization: default message table has already been populated!");
|
// Initialize the default message table (usually en-US)
|
||||||
return FALSE;
|
msg_table = default_msg_table;
|
||||||
|
uprintf("localization: initializing default message table");
|
||||||
|
populate_default = TRUE;
|
||||||
|
get_loc_data_file(filename, default_locale);
|
||||||
|
populate_default = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reentrant) {
|
if (!reentrant) {
|
||||||
if ((filename == NULL) || (filename[0] == 0))
|
if ((filename == NULL) || (filename[0] == 0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
if (!populate_default) {
|
||||||
if (lcmd == default_locale) {
|
if (lcmd == default_locale) {
|
||||||
// The default locale has already been populated => nothing to do
|
// The default locale has already been populated => nothing to do
|
||||||
msg_table = default_msg_table;
|
msg_table = default_msg_table;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (lcmd == NULL) {
|
|
||||||
// Fill the default table
|
|
||||||
lcmd = default_locale;
|
|
||||||
msg_table = default_msg_table;
|
|
||||||
} else {
|
|
||||||
// Fill the current table
|
|
||||||
msg_table = current_msg_table;
|
msg_table = current_msg_table;
|
||||||
}
|
}
|
||||||
free_dialog_list();
|
free_dialog_list();
|
||||||
|
@ -404,10 +405,6 @@ BOOL get_loc_data_file(const char* filename, loc_cmd* lcmd)
|
||||||
old_loc_line_nr = loc_line_nr;
|
old_loc_line_nr = loc_line_nr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lcmd == NULL) {
|
|
||||||
uprintf("Spock gone crazy error!\n");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
offset = (long)lcmd->num[0];
|
offset = (long)lcmd->num[0];
|
||||||
end_offset = (long)lcmd->num[1];
|
end_offset = (long)lcmd->num[1];
|
||||||
start_line = lcmd->line_nr;
|
start_line = lcmd->line_nr;
|
||||||
|
|
|
@ -2064,7 +2064,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
{
|
{
|
||||||
const char* old_wait_option = "/W";
|
const char* old_wait_option = "/W";
|
||||||
int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultUILanguage();
|
int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultUILanguage();
|
||||||
BOOL attached_console = FALSE, external_loc_file = FALSE;
|
BOOL attached_console = FALSE, external_loc_file = FALSE, lgp_set = FALSE;
|
||||||
BYTE* loc_data;
|
BYTE* loc_data;
|
||||||
DWORD loc_size, Size;
|
DWORD loc_size, Size;
|
||||||
char tmp_path[MAX_PATH], loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL;
|
char tmp_path[MAX_PATH], loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL;
|
||||||
|
@ -2215,10 +2215,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||||
|
|
||||||
// We use local group policies rather than direct registry manipulation
|
// We use local group policies rather than direct registry manipulation
|
||||||
// 0x9e disables removable and fixed drive notifications
|
// 0x9e disables removable and fixed drive notifications
|
||||||
SetLGP(FALSE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
|
lgp_set = SetLGP(FALSE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
|
||||||
|
|
||||||
// Populate the default locale (so that we can produce English messages in the log)
|
|
||||||
get_loc_data_file(loc_file, NULL);
|
|
||||||
|
|
||||||
relaunch:
|
relaunch:
|
||||||
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);
|
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);
|
||||||
|
@ -2343,6 +2340,7 @@ out:
|
||||||
for (i=0; i<argc; i++) safe_free(argv[i]);
|
for (i=0; i<argc; i++) safe_free(argv[i]);
|
||||||
safe_free(argv);
|
safe_free(argv);
|
||||||
}
|
}
|
||||||
|
if (lgp_set)
|
||||||
SetLGP(TRUE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0);
|
SetLGP(TRUE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0);
|
||||||
if (attached_console)
|
if (attached_console)
|
||||||
DetachConsole();
|
DetachConsole();
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
IDD_DIALOG DIALOGEX 12, 12, 206, 329
|
||||||
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.4.2.365"
|
CAPTION "Rufus v1.4.2.366"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
|
||||||
|
@ -288,8 +288,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,4,2,365
|
FILEVERSION 1,4,2,366
|
||||||
PRODUCTVERSION 1,4,2,365
|
PRODUCTVERSION 1,4,2,366
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -306,13 +306,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.4.2.365"
|
VALUE "FileVersion", "1.4.2.366"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2013 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.4.2.365"
|
VALUE "ProductVersion", "1.4.2.366"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue