From 14781c718372816730bb439f3a40a3527038b6a8 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Fri, 26 Nov 2021 17:30:09 +0100 Subject: [PATCH] winedbg: Use wide-char string literals. Signed-off-by: Eric Pouech Signed-off-by: Alexandre Julliard --- programs/winedbg/crashdlg.c | 21 +++++++-------------- programs/winedbg/tgt_active.c | 10 +++------- programs/winedbg/tgt_minidump.c | 4 ++-- programs/winedbg/types.c | 30 ++++++++++-------------------- programs/winedbg/winedbg.c | 3 +-- 5 files changed, 23 insertions(+), 45 deletions(-) diff --git a/programs/winedbg/crashdlg.c b/programs/winedbg/crashdlg.c index 1d32749c1a8..7d2c99f513a 100644 --- a/programs/winedbg/crashdlg.c +++ b/programs/winedbg/crashdlg.c @@ -158,21 +158,17 @@ static void save_crash_log( HWND hwnd ) HANDLE handle; DWORD err, written; WCHAR *p, path[MAX_PATH], buffer[1024]; - static const WCHAR default_name[] = { 'b','a','c','k','t','r','a','c','e','.','t','x','t',0 }; - static const WCHAR default_ext[] = { 't','x','t',0 }; - static const WCHAR txt_files[] = { '*','.','t','x','t',0 }; - static const WCHAR all_files[] = { '*','.','*',0 }; memset( &save, 0, sizeof(save) ); - lstrcpyW( path, default_name ); + lstrcpyW( path, L"backtrace.txt" ); LoadStringW( GetModuleHandleW(0), IDS_TEXT_FILES, buffer, ARRAY_SIZE(buffer)); p = buffer + lstrlenW(buffer) + 1; - lstrcpyW(p, txt_files); + lstrcpyW(p, L"*.txt"); p += lstrlenW(p) + 1; LoadStringW( GetModuleHandleW(0), IDS_ALL_FILES, p, ARRAY_SIZE(buffer) - (p - buffer) ); p += lstrlenW(p) + 1; - lstrcpyW(p, all_files); + lstrcpyW(p, L"*.*"); p += lstrlenW(p) + 1; *p = '\0'; @@ -184,7 +180,7 @@ static void save_crash_log( HWND hwnd ) save.nMaxFile = MAX_PATH; save.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING; - save.lpstrDefExt = default_ext; + save.lpstrDefExt = L"txt"; if (!GetSaveFileNameW( &save )) return; handle = CreateFileW( save.lpstrFile, GENERIC_WRITE, FILE_SHARE_READ, @@ -214,7 +210,6 @@ static void save_crash_log( HWND hwnd ) static INT_PTR WINAPI crash_dlg_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static const WCHAR openW[] = {'o','p','e','n',0}; switch (msg) { case WM_INITDIALOG: @@ -250,7 +245,7 @@ static INT_PTR WINAPI crash_dlg_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM case NM_CLICK: case NM_RETURN: if (wParam == IDC_STATIC_TXT2) - ShellExecuteW( NULL, openW, ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW ); + ShellExecuteW( NULL, L"open", ((NMLINK *)lParam)->item.szUrl, NULL, NULL, SW_SHOW ); break; } break; @@ -272,7 +267,6 @@ static INT_PTR WINAPI crash_dlg_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM static INT_PTR WINAPI details_dlg_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - static const WCHAR openW[] = {'o','p','e','n',0}; static POINT orig_size, min_size, edit_size, text_pos, save_pos, close_pos; switch (msg) @@ -345,7 +339,7 @@ static INT_PTR WINAPI details_dlg_proc( HWND hwnd, UINT msg, WPARAM wparam, LPAR case NM_CLICK: case NM_RETURN: if (wparam == IDC_STATIC_TXT2) - ShellExecuteW( NULL, openW, ((NMLINK *)lparam)->item.szUrl, NULL, NULL, SW_SHOW ); + ShellExecuteW( NULL, L"open", ((NMLINK *)lparam)->item.szUrl, NULL, NULL, SW_SHOW ); break; } break; @@ -368,7 +362,6 @@ static INT_PTR WINAPI details_dlg_proc( HWND hwnd, UINT msg, WPARAM wparam, LPAR int display_crash_dialog(void) { - static const WCHAR winedeviceW[] = {'w','i','n','e','d','e','v','i','c','e','.','e','x','e',0}; static const INITCOMMONCONTROLSEX init = { sizeof(init), ICC_LINK_CLASS }; /* dbg_curr_process->handle is not set */ @@ -380,7 +373,7 @@ int display_crash_dialog(void) hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dbg_curr_pid); g_ProgramName = get_program_name(hProcess); CloseHandle(hProcess); - if (!wcscmp( g_ProgramName, winedeviceW )) return TRUE; + if (!wcscmp( g_ProgramName, L"winedevice.exe" )) return TRUE; InitCommonControlsEx( &init ); return DialogBoxW(GetModuleHandleW(NULL), MAKEINTRESOURCEW(IDD_CRASH_DLG), NULL, crash_dlg_proc); } diff --git a/programs/winedbg/tgt_active.c b/programs/winedbg/tgt_active.c index 3372a001dfb..66156833fc6 100644 --- a/programs/winedbg/tgt_active.c +++ b/programs/winedbg/tgt_active.c @@ -294,8 +294,6 @@ static BOOL tgt_process_active_close_process(struct dbg_process* pcs, BOOL kill) void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bufsz) { - static const WCHAR dlladdr[] = {'D','L','L','_','%','0','8','l','x',0}; - memory_get_string_indirect(dbg_curr_process, name_addr, TRUE, buffer, bufsz); if (!buffer[0] && !GetModuleFileNameExW(dbg_curr_process->handle, mod_addr, buffer, bufsz)) { @@ -308,7 +306,7 @@ void fetch_module_name(void* name_addr, void* mod_addr, WCHAR* buffer, size_t bu memmove( buffer, buffer + 4, (lstrlenW(buffer + 4) + 1) * sizeof(WCHAR) ); } else - swprintf(buffer, bufsz, dlladdr, (ULONG_PTR)mod_addr); + swprintf(buffer, bufsz, L"DLL_%08lx", (ULONG_PTR)mod_addr); } } @@ -371,8 +369,7 @@ static unsigned dbg_handle_debug_event(DEBUG_EVENT* de) size = ARRAY_SIZE(u.buffer); if (!QueryFullProcessImageNameW( dbg_curr_process->handle, 0, u.buffer, &size )) { - static const WCHAR pcspid[] = {'P','r','o','c','e','s','s','_','%','0','8','x',0}; - swprintf( u.buffer, ARRAY_SIZE(u.buffer), pcspid, dbg_curr_pid); + swprintf( u.buffer, ARRAY_SIZE(u.buffer), L"Process_%08x", dbg_curr_pid); } WINE_TRACE("%04x:%04x: create process '%s'/%p @%p (%u<%u>)\n", @@ -669,10 +666,9 @@ static BOOL str2int(const char* str, DWORD_PTR* val) static HANDLE create_temp_file(void) { - static const WCHAR prefixW[] = {'w','d','b',0}; WCHAR path[MAX_PATH], name[MAX_PATH]; - if (!GetTempPathW( MAX_PATH, path ) || !GetTempFileNameW( path, prefixW, 0, name )) + if (!GetTempPathW( MAX_PATH, path ) || !GetTempFileNameW( path, L"wdb", 0, name )) return INVALID_HANDLE_VALUE; return CreateFileW( name, GENERIC_READ|GENERIC_WRITE|DELETE, FILE_SHARE_DELETE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0 ); diff --git a/programs/winedbg/tgt_minidump.c b/programs/winedbg/tgt_minidump.c index ab695371f17..368870bde42 100644 --- a/programs/winedbg/tgt_minidump.c +++ b/programs/winedbg/tgt_minidump.c @@ -204,7 +204,6 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) WCHAR exec_name[1024]; WCHAR nameW[1024]; unsigned len; - static const WCHAR default_exec_name[] = {'<','m','i','n','i','d','u','m','p','-','e','x','e','c','>',0}; /* fetch PID */ if (MiniDumpReadDumpStream(data->mapping, MiscInfoStream, NULL, &stream, NULL)) @@ -215,7 +214,8 @@ static enum dbg_start minidump_do_reload(struct tgt_process_minidump_data* data) } /* fetch executable name (it's normally the first one in module list) */ - lstrcpyW(exec_name, default_exec_name); + lstrcpyW(exec_name, L""); + if (MiniDumpReadDumpStream(data->mapping, ModuleListStream, NULL, &stream, NULL)) { mml = stream; diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 5751ce095cc..236373858d5 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -755,30 +755,20 @@ BOOL types_get_info(const struct dbg_type* type, IMAGEHLP_SYMBOL_TYPE_INFO ti, v tag == SymTagBaseType && SymGetTypeInfo(dbg_curr_process->handle, type->module, type->id, TI_GET_BASETYPE, &bt)) { - static const WCHAR voidW[] = {'v','o','i','d','\0'}; - static const WCHAR charW[] = {'c','h','a','r','\0'}; - static const WCHAR wcharW[] = {'W','C','H','A','R','\0'}; - static const WCHAR intW[] = {'i','n','t','\0'}; - static const WCHAR uintW[] = {'u','n','s','i','g','n','e','d',' ','i','n','t','\0'}; - static const WCHAR floatW[] = {'f','l','o','a','t','\0'}; - static const WCHAR boolW[] = {'b','o','o','l','\0'}; - static const WCHAR longW[] = {'l','o','n','g',' ','i','n','t','\0'}; - static const WCHAR ulongW[] = {'u','n','s','i','g','n','e','d',' ','l','o','n','g',' ','i','n','t','\0'}; - static const WCHAR complexW[] = {'c','o','m','p','l','e','x','\0'}; const WCHAR* name = NULL; switch (bt) { - case btVoid: name = voidW; break; - case btChar: name = charW; break; - case btWChar: name = wcharW; break; - case btInt: name = intW; break; - case btUInt: name = uintW; break; - case btFloat: name = floatW; break; - case btBool: name = boolW; break; - case btLong: name = longW; break; - case btULong: name = ulongW; break; - case btComplex: name = complexW; break; + case btVoid: name = L"void"; break; + case btChar: name = L"char"; break; + case btWChar: name = L"WCHAR"; break; + case btInt: name = L"int"; break; + case btUInt: name = L"unsigned int"; break; + case btFloat: name = L"float"; break; + case btBool: name = L"bool"; break; + case btLong: name = L"long int"; break; + case btULong: name = L"unsigned long int"; break; + case btComplex: name = L"complex"; break; default: WINE_FIXME("Unsupported basic type %u\n", bt); return FALSE; } X(WCHAR*) = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(name) + 1) * sizeof(WCHAR)); diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index 66ff5cc7c23..76ecea3f3ee 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -596,7 +596,6 @@ static void restart_if_wow64(void) if (IsWow64Process( GetCurrentProcess(), &is_wow64 ) && is_wow64) { - static const WCHAR winedbgW[] = {'\\','w','i','n','e','d','b','g','.','e','x','e',0}; STARTUPINFOW si; PROCESS_INFORMATION pi; WCHAR filename[MAX_PATH]; @@ -606,7 +605,7 @@ static void restart_if_wow64(void) memset( &si, 0, sizeof(si) ); si.cb = sizeof(si); GetSystemDirectoryW( filename, MAX_PATH ); - lstrcatW( filename, winedbgW ); + lstrcatW( filename, L"\\winedbg.exe" ); Wow64DisableWow64FsRedirection( &redir ); if (CreateProcessW( filename, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))