DBG: more unicode support (now x32_dbg doesn't import any *A() function)
This commit is contained in:
parent
192b0e3e37
commit
ebae693694
|
@ -31,7 +31,6 @@ static char szIniFile[1024] = "";
|
|||
//Bridge
|
||||
BRIDGE_IMPEXP const char* BridgeInit()
|
||||
{
|
||||
//TODO: utf8
|
||||
///Settings load
|
||||
if(!GetModuleFileNameA(0, szIniFile, 1024))
|
||||
return "Error getting module path!";
|
||||
|
@ -241,7 +240,6 @@ BRIDGE_IMPEXP bool DbgGetLabelAt(duint addr, SEGMENTREG segment, char* text) //(
|
|||
|
||||
BRIDGE_IMPEXP bool DbgSetLabelAt(duint addr, const char* text)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!text || strlen(text) >= MAX_LABEL_SIZE || !addr)
|
||||
return false;
|
||||
ADDRINFO info;
|
||||
|
@ -268,7 +266,6 @@ BRIDGE_IMPEXP bool DbgGetCommentAt(duint addr, char* text) //comment (not live)
|
|||
|
||||
BRIDGE_IMPEXP bool DbgSetCommentAt(duint addr, const char* text)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!text || strlen(text) >= MAX_COMMENT_SIZE || !addr)
|
||||
return false;
|
||||
ADDRINFO info;
|
||||
|
|
|
@ -82,7 +82,6 @@ extern "C" DLL_EXPORT bool _dbg_isjumpgoingtoexecute(duint addr)
|
|||
|
||||
extern "C" DLL_EXPORT bool _dbg_addrinfoget(duint addr, SEGMENTREG segment, ADDRINFO* addrinfo)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!DbgIsDebugging())
|
||||
return false;
|
||||
bool retval = false;
|
||||
|
|
|
@ -117,7 +117,6 @@ bool scmp(const char* a, const char* b)
|
|||
|
||||
void formathex(char* string)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
Memory<char*> new_string(len + 1, "formathex:new_string");
|
||||
|
@ -130,7 +129,6 @@ void formathex(char* string)
|
|||
|
||||
void formatdec(char* string)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
Memory<char*> new_string(len + 1, "formatdec:new_string");
|
||||
|
|
|
@ -1501,9 +1501,8 @@ bool IsProcessElevated()
|
|||
return !!IsAdminMember;
|
||||
}
|
||||
|
||||
static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
|
||||
static bool readwritejitkey(wchar_t* jit_key_value, DWORD* jit_key_vale_size, char* key, arch arch_in, arch* arch_out, readwritejitkey_error_t* error, bool write)
|
||||
{
|
||||
//TODO: utf8
|
||||
DWORD key_flags;
|
||||
DWORD lRv;
|
||||
HKEY hKey;
|
||||
|
@ -1564,7 +1563,7 @@ static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char*
|
|||
if(lRv != ERROR_SUCCESS)
|
||||
return false;
|
||||
|
||||
lRv = RegSetValueExA(hKey, key, 0, REG_SZ, (BYTE*) jit_key_value, (DWORD)(* jit_key_vale_size) + 1);
|
||||
lRv = RegSetValueExW(hKey, ConvertUtf8ToUtf16(key).c_str(), 0, REG_SZ, (BYTE*)jit_key_value, (DWORD)(*jit_key_vale_size) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1572,7 +1571,7 @@ static bool readwritejitkey(char* jit_key_value, DWORD* jit_key_vale_size, char*
|
|||
if(lRv != ERROR_SUCCESS)
|
||||
return false;
|
||||
|
||||
lRv = RegQueryValueExA(hKey, key, 0, NULL, (LPBYTE)jit_key_value, jit_key_vale_size);
|
||||
lRv = RegQueryValueExW(hKey, ConvertUtf8ToUtf16(key).c_str(), 0, NULL, (LPBYTE)jit_key_value, jit_key_vale_size);
|
||||
if(lRv != ERROR_SUCCESS)
|
||||
{
|
||||
if(error != NULL)
|
||||
|
@ -1698,7 +1697,7 @@ bool dbggetpagerights(uint addr, char* rights)
|
|||
|
||||
bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
|
||||
{
|
||||
char jit_entry[4];
|
||||
wchar_t jit_entry[4] = L"";
|
||||
DWORD jit_entry_size = sizeof(jit_entry) - 1;
|
||||
readwritejitkey_error_t rw_error;
|
||||
|
||||
|
@ -1712,9 +1711,9 @@ bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_
|
|||
}
|
||||
return false;
|
||||
}
|
||||
if(_strcmpi(jit_entry, "1") == 0)
|
||||
if(_wcsicmp(jit_entry, L"1") == 0)
|
||||
*auto_on = true;
|
||||
else if(_strcmpi(jit_entry, "0") == 0)
|
||||
else if(_wcsicmp(jit_entry, L"0") == 0)
|
||||
*auto_on = false;
|
||||
else
|
||||
return false;
|
||||
|
@ -1723,11 +1722,11 @@ bool dbggetjitauto(bool* auto_on, arch arch_in, arch* arch_out, readwritejitkey_
|
|||
|
||||
bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
|
||||
{
|
||||
DWORD auto_string_size = sizeof("1");
|
||||
DWORD auto_string_size = sizeof(L"1");
|
||||
readwritejitkey_error_t rw_error;
|
||||
if(!auto_on)
|
||||
{
|
||||
char jit_entry[4];
|
||||
wchar_t jit_entry[4] = L"";
|
||||
DWORD jit_entry_size = sizeof(jit_entry) - 1;
|
||||
if(!readwritejitkey(jit_entry, &jit_entry_size, "Auto", arch_in, arch_out, &rw_error, false))
|
||||
{
|
||||
|
@ -1735,7 +1734,7 @@ bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_e
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if(!readwritejitkey(auto_on ? "1" : "0", &auto_string_size, "Auto", arch_in, arch_out, &rw_error, true))
|
||||
if(!readwritejitkey(auto_on ? L"1" : L"0", &auto_string_size, "Auto", arch_in, arch_out, &rw_error, true))
|
||||
{
|
||||
if(rw_error_out != NULL)
|
||||
*rw_error_out = rw_error;
|
||||
|
@ -1746,14 +1745,16 @@ bool dbgsetjitauto(bool auto_on, arch arch_in, arch* arch_out, readwritejitkey_e
|
|||
|
||||
bool dbggetjit(char jit_entry[JIT_ENTRY_MAX_SIZE], arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
|
||||
{
|
||||
DWORD jit_entry_size = JIT_ENTRY_MAX_SIZE;
|
||||
wchar_t wszJitEntry[JIT_ENTRY_MAX_SIZE] = L"";
|
||||
DWORD jit_entry_size = JIT_ENTRY_MAX_SIZE * sizeof(wchar_t);
|
||||
readwritejitkey_error_t rw_error;
|
||||
if(!readwritejitkey(jit_entry, &jit_entry_size, "Debugger", arch_in, arch_out, &rw_error, false))
|
||||
if(!readwritejitkey(wszJitEntry, &jit_entry_size, "Debugger", arch_in, arch_out, &rw_error, false))
|
||||
{
|
||||
if(rw_error_out != NULL)
|
||||
*rw_error_out = rw_error;
|
||||
return false;
|
||||
}
|
||||
strcpy_s(jit_entry, JIT_ENTRY_MAX_SIZE, ConvertUtf16ToUtf8(wszJitEntry).c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1762,7 +1763,7 @@ bool dbggetdefjit(char* jit_entry)
|
|||
char path[JIT_ENTRY_DEF_SIZE];
|
||||
path[0] = '"';
|
||||
wchar_t wszPath[MAX_PATH] = L"";
|
||||
GetModuleFileNameW(GetModuleHandleA(NULL), wszPath, MAX_PATH);
|
||||
GetModuleFileNameW(GetModuleHandleW(NULL), wszPath, MAX_PATH);
|
||||
strcpy(&path[1], ConvertUtf16ToUtf8(wszPath).c_str());
|
||||
strcat(path, ATTACH_CMD_LINE);
|
||||
strcpy(jit_entry, path);
|
||||
|
@ -1771,10 +1772,9 @@ bool dbggetdefjit(char* jit_entry)
|
|||
|
||||
bool dbgsetjit(char* jit_cmd, arch arch_in, arch* arch_out, readwritejitkey_error_t* rw_error_out)
|
||||
{
|
||||
//TODO: utf8
|
||||
DWORD jit_cmd_size = (DWORD)strlen(jit_cmd);
|
||||
DWORD jit_cmd_size = (DWORD)strlen(jit_cmd) * sizeof(wchar_t);
|
||||
readwritejitkey_error_t rw_error;
|
||||
if(!readwritejitkey(jit_cmd, & jit_cmd_size, "Debugger", arch_in, arch_out, & rw_error, true))
|
||||
if(!readwritejitkey((wchar_t*)ConvertUtf8ToUtf16(jit_cmd).c_str(), & jit_cmd_size, "Debugger", arch_in, arch_out, & rw_error, true))
|
||||
{
|
||||
if(rw_error_out != NULL)
|
||||
*rw_error_out = rw_error;
|
||||
|
@ -1927,7 +1927,6 @@ static bool fixgetcommandlinesbase(uint new_command_line_unicode, uint new_comma
|
|||
|
||||
bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
|
||||
{
|
||||
//TODO: UTF-8
|
||||
cmdline_error_t cmd_line_error_aux;
|
||||
UNICODE_STRING new_command_line;
|
||||
SIZE_T size;
|
||||
|
@ -1948,7 +1947,7 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
|
|||
Memory<wchar_t*> command_linewstr(new_command_line.Length);
|
||||
|
||||
// Covert to Unicode.
|
||||
if(!MultiByteToWideChar(CP_ACP, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr, (int)cmd_line_size + 1))
|
||||
if(!MultiByteToWideChar(CP_UTF8, 0, cmd_line, (int)cmd_line_size + 1, command_linewstr, (int)cmd_line_size + 1))
|
||||
{
|
||||
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
|
||||
return false;
|
||||
|
@ -1993,7 +1992,6 @@ bool dbgsetcmdline(const char* cmd_line, cmdline_error_t* cmd_line_error)
|
|||
|
||||
bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error)
|
||||
{
|
||||
//TODO: UTF-8
|
||||
SIZE_T size;
|
||||
UNICODE_STRING CommandLine;
|
||||
cmdline_error_t cmd_line_error_aux;
|
||||
|
@ -2024,8 +2022,8 @@ bool dbggetcmdline(char** cmd_line, cmdline_error_t* cmd_line_error)
|
|||
|
||||
*cmd_line = (char*)emalloc(cmd_line_size, "dbggetcmdline:cmd_line");
|
||||
|
||||
//Convert TO ASCII
|
||||
if(!WideCharToMultiByte(CP_ACP, 0, wstr_cmd, (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
|
||||
//Convert TO UTF-8
|
||||
if(!WideCharToMultiByte(CP_UTF8, 0, wstr_cmd, (int)wstr_cmd_size, * cmd_line, (int)cmd_line_size, NULL, NULL))
|
||||
{
|
||||
efree(*cmd_line);
|
||||
cmd_line_error->type = CMDL_ERR_CONVERTUNICODE;
|
||||
|
|
|
@ -14,7 +14,6 @@ static bool bScyllaLoaded = false;
|
|||
|
||||
CMDRESULT cbDebugInit(int argc, char* argv[])
|
||||
{
|
||||
//TODO: utf8
|
||||
if(DbgIsDebugging())
|
||||
DbgCmdExecDirect("stop");
|
||||
|
||||
|
@ -810,7 +809,7 @@ static DWORD WINAPI scyllaThread(void* lpParam)
|
|||
{
|
||||
typedef INT (WINAPI * SCYLLASTARTGUI)(DWORD pid, HINSTANCE mod);
|
||||
SCYLLASTARTGUI ScyllaStartGui = 0;
|
||||
HINSTANCE hScylla = LoadLibraryA("Scylla.dll");
|
||||
HINSTANCE hScylla = LoadLibraryW(L"Scylla.dll");
|
||||
if(!hScylla)
|
||||
{
|
||||
dputs("error loading Scylla.dll!");
|
||||
|
|
|
@ -334,7 +334,6 @@ bool disasmispossiblestring(uint addr)
|
|||
|
||||
bool disasmgetstringat(uint addr, STRING_TYPE* type, char* ascii, char* unicode, int maxlen)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(type)
|
||||
*type = str_none;
|
||||
if(!disasmispossiblestring(addr))
|
||||
|
|
|
@ -223,7 +223,7 @@ CMDRESULT cbInstrChd(int argc, char* argv[])
|
|||
dputs("directory doesn't exist");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
SetCurrentDirectoryA(argv[1]);
|
||||
SetCurrentDirectoryW(ConvertUtf8ToUtf16(argv[1]).c_str());
|
||||
dputs("current directory changed!");
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
@ -934,7 +934,6 @@ CMDRESULT cbInstrGetstr(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbInstrCopystr(int argc, char* argv[])
|
||||
{
|
||||
//TODO: utf8
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
|
@ -983,7 +982,6 @@ CMDRESULT cbInstrCopystr(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbInstrFind(int argc, char* argv[])
|
||||
{
|
||||
//TODO: utf8
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
|
@ -1035,7 +1033,6 @@ CMDRESULT cbInstrFind(int argc, char* argv[])
|
|||
|
||||
CMDRESULT cbInstrFindAll(int argc, char* argv[])
|
||||
{
|
||||
//TODO: utf8
|
||||
if(argc < 3)
|
||||
{
|
||||
dputs("not enough arguments!");
|
||||
|
|
|
@ -55,7 +55,6 @@ mathformat:
|
|||
*/
|
||||
void mathformat(char* text)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(text);
|
||||
Memory<char*> temp(len + 1, "mathformat:temp");
|
||||
memset(temp, 0, len + 1);
|
||||
|
@ -70,7 +69,6 @@ void mathformat(char* text)
|
|||
*/
|
||||
bool mathcontains(const char* text)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(*text == '-') //ignore negative values
|
||||
text++;
|
||||
int len = (int)strlen(text);
|
||||
|
@ -238,7 +236,6 @@ static void fillpair(EXPRESSION* expstruct, int pos, int layer)
|
|||
|
||||
static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
|
||||
{
|
||||
//TODO: utf8
|
||||
int layer = endlayer;
|
||||
int len = (int)strlen(expression);
|
||||
for(int i = 0; i < len; i++)
|
||||
|
@ -267,7 +264,6 @@ static int matchpairs(EXPRESSION* expstruct, char* expression, int endlayer)
|
|||
|
||||
static int expressionformat(char* exp)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(exp);
|
||||
int open = 0;
|
||||
int close = 0;
|
||||
|
@ -363,7 +359,6 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
{
|
||||
int highestop = 0;
|
||||
int highestop_pos = 0;
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
bool negative = false;
|
||||
if(*string == '-')
|
||||
|
@ -397,7 +392,6 @@ bool mathfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
if(string[highestop_pos] == '~')
|
||||
{
|
||||
right = ~right;
|
||||
//TODO: utf8
|
||||
if(!strlen(strleft))
|
||||
{
|
||||
*value = right;
|
||||
|
|
|
@ -228,7 +228,6 @@ void memfree(HANDLE hProcess, uint addr)
|
|||
|
||||
static int formathexpattern(char* string)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
_strupr(string);
|
||||
Memory<char*> new_string(len + 1, "formathexpattern:new_string");
|
||||
|
@ -242,7 +241,6 @@ static int formathexpattern(char* string)
|
|||
|
||||
static bool patterntransform(const char* text, std::vector<PATTERNBYTE>* pattern)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!text or !pattern)
|
||||
return false;
|
||||
pattern->clear();
|
||||
|
|
|
@ -153,14 +153,14 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
|
|||
sprintf(error, "failed to get base of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
char szOriginalName[MAX_PATH] = "";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
|
||||
wchar_t szOriginalName[MAX_PATH] = L"";
|
||||
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szOriginalName, MAX_PATH))
|
||||
{
|
||||
if(error)
|
||||
sprintf(error, "failed to get module path of module %s", modname);
|
||||
return -1;
|
||||
}
|
||||
if(!CopyFileA(szOriginalName, szFileName, false))
|
||||
if(!CopyFileW(szOriginalName, ConvertUtf8ToUtf16(szFileName).c_str(), false))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "failed to make a copy of the original file (patch target is in use?)");
|
||||
|
@ -170,7 +170,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
|
|||
DWORD LoadedSize;
|
||||
HANDLE FileMap;
|
||||
ULONG_PTR FileMapVA;
|
||||
if(StaticFileLoad((char*)szFileName, UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
if(StaticFileLoadW(ConvertUtf8ToUtf16(szFileName).c_str(), UE_ACCESS_ALL, false, &FileHandle, &LoadedSize, &FileMap, &FileMapVA))
|
||||
{
|
||||
int patched = 0;
|
||||
for(int i = 0; i < count; i++)
|
||||
|
@ -182,7 +182,7 @@ int patchfile(const PATCHINFO* patchlist, int count, const char* szFileName, cha
|
|||
*ptr = patchlist[i].newbyte;
|
||||
patched++;
|
||||
}
|
||||
if(!StaticFileUnload((char*)szFileName, true, FileHandle, LoadedSize, FileMap, FileMapVA))
|
||||
if(!StaticFileUnloadW(ConvertUtf8ToUtf16(szFileName).c_str(), true, FileHandle, LoadedSize, FileMap, FileMapVA))
|
||||
{
|
||||
if(error)
|
||||
strcpy(error, "StaticFileUnload failed");
|
||||
|
|
|
@ -14,20 +14,20 @@ static std::vector<PLUG_MENU> pluginMenuList;
|
|||
void pluginload(const char* pluginDir)
|
||||
{
|
||||
//load new plugins
|
||||
char currentDir[deflen] = "";
|
||||
GetCurrentDirectoryA(deflen, currentDir);
|
||||
SetCurrentDirectoryA(pluginDir);
|
||||
wchar_t currentDir[deflen] = L"";
|
||||
GetCurrentDirectoryW(deflen, currentDir);
|
||||
SetCurrentDirectoryW(ConvertUtf8ToUtf16(pluginDir).c_str());
|
||||
char searchName[deflen] = "";
|
||||
#ifdef _WIN64
|
||||
sprintf(searchName, "%s\\*.dp64", pluginDir);
|
||||
#else
|
||||
sprintf(searchName, "%s\\*.dp32", pluginDir);
|
||||
#endif // _WIN64
|
||||
WIN32_FIND_DATA foundData;
|
||||
HANDLE hSearch = FindFirstFileA(searchName, &foundData);
|
||||
WIN32_FIND_DATAW foundData;
|
||||
HANDLE hSearch = FindFirstFileW(ConvertUtf8ToUtf16(searchName).c_str(), &foundData);
|
||||
if(hSearch == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
SetCurrentDirectoryA(currentDir);
|
||||
SetCurrentDirectoryW(currentDir);
|
||||
return;
|
||||
}
|
||||
PLUG_DATA pluginData;
|
||||
|
@ -36,8 +36,8 @@ void pluginload(const char* pluginDir)
|
|||
//set plugin data
|
||||
pluginData.initStruct.pluginHandle = curPluginHandle;
|
||||
char szPluginPath[MAX_PATH] = "";
|
||||
sprintf(szPluginPath, "%s\\%s", pluginDir, foundData.cFileName);
|
||||
pluginData.hPlugin = LoadLibraryA(szPluginPath); //load the plugin library
|
||||
sprintf_s(szPluginPath, "%s\\%s", pluginDir, ConvertUtf16ToUtf8(foundData.cFileName).c_str());
|
||||
pluginData.hPlugin = LoadLibraryW(ConvertUtf8ToUtf16(szPluginPath).c_str()); //load the plugin library
|
||||
if(!pluginData.hPlugin)
|
||||
{
|
||||
dprintf("[PLUGIN] Failed to load plugin: %s\n", foundData.cFileName);
|
||||
|
@ -185,8 +185,8 @@ void pluginload(const char* pluginDir)
|
|||
}
|
||||
curPluginHandle++;
|
||||
}
|
||||
while(FindNextFileA(hSearch, &foundData));
|
||||
SetCurrentDirectoryA(currentDir);
|
||||
while(FindNextFileW(hSearch, &foundData));
|
||||
SetCurrentDirectoryW(currentDir);
|
||||
}
|
||||
|
||||
static void plugincmdunregisterall(int pluginHandle)
|
||||
|
@ -260,7 +260,6 @@ void plugincbcall(CBTYPE cbType, void* callbackInfo)
|
|||
|
||||
bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cbCommand, bool debugonly)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
|
||||
return false;
|
||||
PLUG_COMMAND plugCmd;
|
||||
|
@ -275,7 +274,6 @@ bool plugincmdregister(int pluginHandle, const char* command, CBPLUGINCOMMAND cb
|
|||
|
||||
bool plugincmdunregister(int pluginHandle, const char* command)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!command or strlen(command) >= deflen or strstr(command, "\1"))
|
||||
return false;
|
||||
int listsize = (int)pluginCommandList.size();
|
||||
|
@ -295,7 +293,6 @@ bool plugincmdunregister(int pluginHandle, const char* command)
|
|||
|
||||
int pluginmenuadd(int hMenu, const char* title)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!title or !strlen(title))
|
||||
return -1;
|
||||
int nFound = -1;
|
||||
|
@ -320,7 +317,6 @@ int pluginmenuadd(int hMenu, const char* title)
|
|||
|
||||
bool pluginmenuaddentry(int hMenu, int hEntry, const char* title)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!title or !strlen(title) or hEntry == -1)
|
||||
return false;
|
||||
int pluginHandle = -1;
|
||||
|
|
|
@ -62,8 +62,7 @@ static int scriptinternalstep(int fromIp) //internal step routine
|
|||
|
||||
static bool scriptcreatelinemap(const char* filename)
|
||||
{
|
||||
//TODO: utf8
|
||||
HANDLE hFile = CreateFileA(filename, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
HANDLE hFile = CreateFileW(ConvertUtf8ToUtf16(filename).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
GuiScriptError(0, "CreateFile failed...");
|
||||
|
@ -206,7 +205,6 @@ static bool scriptcreatelinemap(const char* filename)
|
|||
char newraw[MAX_SCRIPT_LINE_SIZE] = "";
|
||||
strcpy(newraw, cur.raw);
|
||||
argformat(newraw);
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(newraw);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(newraw[i] == ' ')
|
||||
|
@ -314,7 +312,6 @@ static bool scriptisruncommand(const char* cmdlist)
|
|||
|
||||
static bool scriptisinternalcommand(const char* text, const char* cmd)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(text);
|
||||
int cmdlen = (int)strlen(cmd);
|
||||
if(cmdlen > len)
|
||||
|
|
|
@ -11,7 +11,6 @@ struct SYMBOLCBDATA
|
|||
|
||||
static BOOL CALLBACK EnumSymbols(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(pSymInfo->Name);
|
||||
SYMBOLINFO curSymbol;
|
||||
memset(&curSymbol, 0, sizeof(SYMBOLINFO));
|
||||
|
@ -102,10 +101,10 @@ void symdownloadallsymbols(const char* szSymbolStore)
|
|||
{
|
||||
dprintf("downloading symbols for %s...\n", modList.at(i).name);
|
||||
uint modbase = modList.at(i).base;
|
||||
char szModulePath[MAX_PATH] = "";
|
||||
if(!GetModuleFileNameExA(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH))
|
||||
wchar_t szModulePath[MAX_PATH] = L"";
|
||||
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModulePath, MAX_PATH))
|
||||
{
|
||||
dprintf("GetModuleFileNameExA("fhex") failed!\n", modbase);
|
||||
dprintf("GetModuleFileNameExW("fhex") failed!\n", modbase);
|
||||
continue;
|
||||
}
|
||||
if(!SymUnloadModule64(fdProcessInfo->hProcess, (DWORD64)modbase))
|
||||
|
@ -113,7 +112,7 @@ void symdownloadallsymbols(const char* szSymbolStore)
|
|||
dprintf("SymUnloadModule64("fhex") failed!\n", modbase);
|
||||
continue;
|
||||
}
|
||||
if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, szModulePath, 0, (DWORD64)modbase, 0, 0, 0))
|
||||
if(!SymLoadModuleEx(fdProcessInfo->hProcess, 0, ConvertUtf16ToUtf8(szModulePath).c_str(), 0, (DWORD64)modbase, 0, 0, 0))
|
||||
{
|
||||
dprintf("SymLoadModuleEx("fhex") failed!\n", modbase);
|
||||
continue;
|
||||
|
@ -127,7 +126,6 @@ void symdownloadallsymbols(const char* szSymbolStore)
|
|||
|
||||
bool symfromname(const char* name, uint* addr)
|
||||
{
|
||||
//TODO: utf8
|
||||
if(!name or !strlen(name) or !addr or !_strnicmp(name, "ordinal", 7)) //skip 'OrdinalXXX'
|
||||
return false;
|
||||
char buffer[sizeof(SYMBOL_INFO) + MAX_LABEL_SIZE * sizeof(char)];
|
||||
|
|
|
@ -988,64 +988,64 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
|
|||
strcpy(modname, name);
|
||||
modname[apiname - name] = 0;
|
||||
apiname++;
|
||||
//TODO: utf8
|
||||
if(!strlen(apiname))
|
||||
return false;
|
||||
uint modbase = modbasefromname(modname);
|
||||
char szModName[MAX_PATH];
|
||||
if(!GetModuleFileNameEx(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH))
|
||||
wchar_t szModName[MAX_PATH] = L"";
|
||||
if(!GetModuleFileNameExW(fdProcessInfo->hProcess, (HMODULE)modbase, szModName, MAX_PATH))
|
||||
{
|
||||
if(!silent)
|
||||
dprintf("could not get filename of module "fhex"\n", modbase);
|
||||
}
|
||||
else
|
||||
{
|
||||
char szBaseName[256] = "";
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(szModName);
|
||||
while(szModName[len] != '\\')
|
||||
len--;
|
||||
strcpy_s(szBaseName, szModName + len + 1);
|
||||
HMODULE mod = LoadLibraryExA(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if(!mod)
|
||||
wchar_t* szBaseName = wcschr(szModName, L'\\');
|
||||
if(szBaseName)
|
||||
{
|
||||
if(!silent)
|
||||
dprintf("unable to load library %s\n", szBaseName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint addr = (uint)GetProcAddress(mod, apiname);
|
||||
if(!addr) //not found
|
||||
szBaseName++;
|
||||
HMODULE mod = LoadLibraryExW(szModName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if(!mod)
|
||||
{
|
||||
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
|
||||
addr = modbase;
|
||||
else
|
||||
if(!silent)
|
||||
dprintf("unable to load library %s\n", szBaseName);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint addr = (uint)GetProcAddress(mod, apiname);
|
||||
if(!addr) //not found
|
||||
{
|
||||
uint ordinal;
|
||||
if(valfromstring(apiname, &ordinal))
|
||||
if(!_stricmp(apiname, "base") or !_stricmp(apiname, "imagebase") or !_stricmp(apiname, "header"))
|
||||
addr = modbase;
|
||||
else
|
||||
{
|
||||
addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
|
||||
if(!addr and !ordinal)
|
||||
addr = modbase;
|
||||
uint ordinal;
|
||||
if(valfromstring(apiname, &ordinal))
|
||||
{
|
||||
addr = (uint)GetProcAddress(mod, (LPCSTR)(ordinal & 0xFFFF));
|
||||
if(!addr and !ordinal)
|
||||
addr = modbase;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeLibrary(mod);
|
||||
if(addr) //found!
|
||||
{
|
||||
if(value_size)
|
||||
*value_size = sizeof(uint);
|
||||
if(hexonly)
|
||||
*hexonly = true;
|
||||
uint rva;
|
||||
if(addr == modbase)
|
||||
rva = 0;
|
||||
else
|
||||
rva = addr - (uint)mod;
|
||||
*value = modbase + rva;
|
||||
return true;
|
||||
FreeLibrary(mod);
|
||||
if(addr) //found!
|
||||
{
|
||||
if(value_size)
|
||||
*value_size = sizeof(uint);
|
||||
if(hexonly)
|
||||
*hexonly = true;
|
||||
uint rva;
|
||||
if(addr == modbase)
|
||||
rva = 0;
|
||||
else
|
||||
rva = addr - (uint)mod;
|
||||
*value = modbase + rva;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!silent)
|
||||
dputs("unknown error");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1061,20 +1061,20 @@ bool valapifromstring(const char* name, uint* value, int* value_size, bool print
|
|||
{
|
||||
for(unsigned int i = 0; i < cbNeeded / sizeof(HMODULE); i++)
|
||||
{
|
||||
char szModuleName[MAX_PATH] = "";
|
||||
if(GetModuleFileNameExA(fdProcessInfo->hProcess, hMods[i], szModuleName, sizeof(szModuleName)))
|
||||
wchar_t szModuleName[MAX_PATH] = L"";
|
||||
if(GetModuleFileNameExW(fdProcessInfo->hProcess, hMods[i], szModuleName, MAX_PATH))
|
||||
{
|
||||
char* szBaseName = strchr(szModuleName, '\\');
|
||||
wchar_t* szBaseName = wcschr(szModuleName, L'\\');
|
||||
if(szBaseName)
|
||||
{
|
||||
szBaseName++;
|
||||
HMODULE hModule = LoadLibraryExA(szModuleName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
HMODULE hModule = LoadLibraryExW(szModuleName, 0, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if(hModule)
|
||||
{
|
||||
ULONG_PTR funcAddress = (ULONG_PTR)GetProcAddress(hModule, name);
|
||||
if(funcAddress)
|
||||
{
|
||||
if(!_stricmp(szBaseName, "kernelbase.dll"))
|
||||
if(!_wcsicmp(szBaseName, L"kernelbase.dll"))
|
||||
kernelbase = found;
|
||||
uint rva = funcAddress - (uint)hModule;
|
||||
addrfound[found] = (uint)hMods[i] + rva;
|
||||
|
@ -1127,7 +1127,6 @@ static bool isdecnumber(const char* string)
|
|||
return false;
|
||||
decAdd++;
|
||||
}
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string + decAdd);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(!isdigit(string[i + decAdd]))
|
||||
|
@ -1147,7 +1146,6 @@ static bool ishexnumber(const char* string)
|
|||
add = 1;
|
||||
if(!string[add]) //only an indicator, no number
|
||||
return false;
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string + add);
|
||||
for(int i = 0; i < len; i++)
|
||||
if(!isxdigit(string[i + add])) //all must be hex digits
|
||||
|
@ -1166,7 +1164,6 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
}
|
||||
else if(mathcontains(string)) //handle math
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
Memory<char*> newstring(len * 2, "valfromstring:newstring");
|
||||
if(strstr(string, "[")) //memory brackets: []
|
||||
|
@ -1221,7 +1218,6 @@ bool valfromstring(const char* string, uint* value, bool silent, bool baseonly,
|
|||
*isvar = true;
|
||||
return true;
|
||||
}
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
Memory<char*> newstring(len * 2, "valfromstring:newstring");
|
||||
if(strstr(string, "["))
|
||||
|
@ -1378,7 +1374,6 @@ bool valtostring(const char* string, uint* value, bool silent)
|
|||
dputs("not debugging");
|
||||
return false;
|
||||
}
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(string);
|
||||
Memory<char*> newstring(len * 2, "valfromstring:newstring");
|
||||
if(strstr(string, "[")) //memory brackets: []
|
||||
|
@ -1433,7 +1428,6 @@ bool valtostring(const char* string, uint* value, bool silent)
|
|||
return false;
|
||||
}
|
||||
bool ok = setregister(string, *value);
|
||||
//TODO: utf8
|
||||
Memory<char*> regName(strlen(string) + 1, "valtostring:regname");
|
||||
strcpy(regName, string);
|
||||
_strlwr(regName);
|
||||
|
|
|
@ -185,7 +185,6 @@ bool varset(const char* name, uint value, bool setreadonly)
|
|||
bool varset(const char* name, const char* string, bool setreadonly)
|
||||
{
|
||||
VAR_VALUE varvalue;
|
||||
//TODO: utf8
|
||||
int size = (int)strlen(string);
|
||||
varvalue.size = size;
|
||||
varvalue.type = VAR_STRING;
|
||||
|
|
|
@ -54,7 +54,6 @@ static CMDRESULT cbStrLen(int argc, char* argv[])
|
|||
dputs("not enough arguments!");
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
//TODO: utf8
|
||||
dprintf("\"%s\"[%d]\n", argv[1], strlen(argv[1]));
|
||||
return STATUS_CONTINUE;
|
||||
}
|
||||
|
@ -218,7 +217,6 @@ static bool cbCommandProvider(char* cmd, int maxlen)
|
|||
MESSAGE msg;
|
||||
msgwait(gMsgStack, &msg);
|
||||
char* newcmd = (char*)msg.param1;
|
||||
//TODO: utf8
|
||||
if(strlen(newcmd) >= deflen)
|
||||
{
|
||||
dprintf("command cut at ~%d characters\n", deflen);
|
||||
|
@ -231,7 +229,6 @@ static bool cbCommandProvider(char* cmd, int maxlen)
|
|||
|
||||
extern "C" DLL_EXPORT bool _dbg_dbgcmdexec(const char* cmd)
|
||||
{
|
||||
//TODO: utf8
|
||||
int len = (int)strlen(cmd);
|
||||
char* newcmd = (char*)emalloc((len + 1) * sizeof(char), "_dbg_dbgcmdexec:newcmd");
|
||||
strcpy(newcmd, cmd);
|
||||
|
@ -259,24 +256,25 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
|||
dbginit();
|
||||
dbgfunctionsinit();
|
||||
json_set_alloc_funcs(emalloc_json, efree_json);
|
||||
wchar_t wszDir[deflen] = L"";
|
||||
if(!GetModuleFileNameW(hInst, wszDir, deflen))
|
||||
return "GetModuleFileNameW failed!";
|
||||
char dir[deflen] = "";
|
||||
if(!GetModuleFileNameA(hInst, dir, deflen))
|
||||
return "GetModuleFileNameA failed!";
|
||||
//TODO: utf8
|
||||
strcpy_s(dir, ConvertUtf16ToUtf8(wszDir).c_str());
|
||||
int len = (int)strlen(dir);
|
||||
while(dir[len] != '\\')
|
||||
len--;
|
||||
dir[len] = 0;
|
||||
strcpy(alloctrace, dir);
|
||||
PathAppendA(alloctrace, "\\alloctrace.txt");
|
||||
DeleteFileA(alloctrace);
|
||||
DeleteFileW(ConvertUtf8ToUtf16(alloctrace).c_str());
|
||||
setalloctrace(alloctrace);
|
||||
strcpy(dbbasepath, dir); //debug directory
|
||||
PathAppendA(dbbasepath, "db");
|
||||
CreateDirectoryA(dbbasepath, 0); //create database directory
|
||||
CreateDirectoryW(ConvertUtf8ToUtf16(dbbasepath).c_str(), 0); //create database directory
|
||||
strcpy(szSymbolCachePath, dir);
|
||||
PathAppendA(szSymbolCachePath, "symbols");
|
||||
SetCurrentDirectoryA(dir);
|
||||
SetCurrentDirectoryW(ConvertUtf8ToUtf16(dir).c_str());;
|
||||
gMsgStack = msgallocstack();
|
||||
if(!gMsgStack)
|
||||
return "Could not allocate message stack!";
|
||||
|
@ -286,7 +284,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
|
|||
char plugindir[deflen] = "";
|
||||
strcpy(plugindir, dir);
|
||||
PathAppendA(plugindir, "plugins");
|
||||
CreateDirectoryA(plugindir, 0);
|
||||
CreateDirectoryW(ConvertUtf8ToUtf16(plugindir).c_str(), 0);
|
||||
pluginload(plugindir);
|
||||
//handle command line
|
||||
int argc = 0;
|
||||
|
|
|
@ -81,7 +81,7 @@ static bool BrowseFileOpen(HWND owner, const char* filter, const char* defext, c
|
|||
memset(&ofstruct, 0, sizeof(ofstruct));
|
||||
ofstruct.lStructSize = sizeof(ofstruct);
|
||||
ofstruct.hwndOwner = owner;
|
||||
ofstruct.hInstance = GetModuleHandleA(0);
|
||||
ofstruct.hInstance = GetModuleHandleW(0);
|
||||
ofstruct.lpstrFilter = filter;
|
||||
ofstruct.lpstrFile = filename;
|
||||
ofstruct.nMaxFile = filename_size - 1;
|
||||
|
@ -107,7 +107,6 @@ void RegisterShellExtension(const char* key, const char* command)
|
|||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
//TODO: utf8
|
||||
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
|
||||
{
|
||||
CoInitialize(NULL); //fixed some crash
|
||||
|
|
Loading…
Reference in New Issue