1
0
Fork 0

more strings translated

This commit is contained in:
torusrxxx 2016-08-21 15:21:22 +08:00
parent 3282b0d4ea
commit 638fca28e4
15 changed files with 525 additions and 460 deletions

View File

@ -11,16 +11,18 @@
\brief x64dbg library instance.
*/
HINSTANCE hInst;
//#define ENABLE_MEM_TRACE
/**
\brief Number of allocated buffers by emalloc(). This should be 0 when x64dbg ends.
*/
static int emalloc_count = 0;
#ifdef ENABLE_MEM_TRACE
/**
\brief Path for debugging, used to create an allocation trace file on emalloc() or efree(). Not used.
*/
static char alloctrace[MAX_PATH] = "";
static char alloctrace[MAX_PATH] = "memtrace.txt";
#endif
/**
\brief Allocates a new buffer.
@ -40,11 +42,11 @@ void* emalloc(size_t size, const char* reason)
}
memset(a, 0, size);
emalloc_count++;
/*
#ifdef ENABLE_MEM_TRACE
FILE* file = fopen(alloctrace, "a+");
fprintf(file, "DBG%.5d: alloc:" fhex ":%s:" fhex "\n", emalloc_count, a, reason, size);
fprintf(file, "DBG%.5d: alloc:%p:%s:%p\n", emalloc_count, a, reason, size);
fclose(file);
*/
#endif //ENABLE_MEM_TRACE
return a;
}
@ -74,11 +76,11 @@ void* erealloc(void* ptr, size_t size, const char* reason)
void efree(void* ptr, const char* reason)
{
emalloc_count--;
/*
#ifdef ENABLE_MEM_TRACE
FILE* file = fopen(alloctrace, "a+");
fprintf(file, "DBG%.5d: free:" fhex ":%s\n", emalloc_count, ptr, reason);
fprintf(file, "DBG%.5d: free:%p:%s\n", emalloc_count, ptr, reason);
fclose(file);
*/
#endif //ENABLE_MEM_TRACE
GlobalFree(ptr);
}
@ -101,6 +103,7 @@ int memleaks()
return emalloc_count;
}
#ifdef ENABLE_MEM_TRACE
/**
\brief Sets the path for the allocation trace file.
\param file UTF-8 filepath.
@ -109,6 +112,7 @@ void setalloctrace(const char* file)
{
strcpy_s(alloctrace, file);
}
#endif //ENABLE_MEM_TRACE
/**
\brief A function to determine if a string is contained in a specifically formatted 'array string'.

View File

@ -36,13 +36,13 @@ PLUG_IMPEXP void _plugin_logprintf(const char* format, ...)
va_list args;
va_start(args, format);
dprintf_args(format, args);
dprintf_args_untranslated(format, args);
va_end(args);
}
PLUG_IMPEXP void _plugin_logputs(const char* text)
{
dputs(text);
dputs_untranslated(text);
}
PLUG_IMPEXP void _plugin_debugpause()

View File

@ -98,7 +98,7 @@ bool FunctionPass::Analyse()
std::sort(funcs.begin(), funcs.end());
funcs.erase(std::unique(funcs.begin(), funcs.end()), funcs.end());
dprintf("%u functions\n", funcs.size());
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions\n"), funcs.size());
FunctionDelRange(m_VirtualStart, m_VirtualEnd - 1, false);
for(auto & func : funcs)
@ -142,7 +142,7 @@ void FunctionPass::AnalysisWorker(duint Start, duint End, std::vector<FunctionDe
if(!MemIsValidReadPtr(destination))
continue;
dprintf("Indirect pointer: 0x%p 0x%p\n", blockItr->Target, destination);
dprintf(QT_TRANSLATE_NOOP("DBG", "Indirect pointer: 0x%p 0x%p\n"), blockItr->Target, destination);
}
// Destination must be within analysis limits

View File

@ -75,9 +75,9 @@ void ExceptionDirectoryAnalysis::Analyse()
return true;
});
dprintf("%u functions discovered!\n", mFunctions.size());
dprintf(QT_TRANSLATE_NOOP("DBG", "%u functions discovered!\n"), mFunctions.size());
#else //x32
dprintf("This kind of analysis doesn't work on x32 executables...\n");
dputs(QT_TRANSLATE_NOOP("DBG", "This kind of analysis doesn't work on x32 executables...\n"));
#endif // _WIN64
}

View File

@ -61,3 +61,35 @@ void dprintf_args(const char* Format, va_list Args)
GuiAddLogMessageAsync(buffer);
}
/**
\brief Print a line with text, terminated with a newline to the console.
\param text The text to print.
*/
void dputs_untranslated(const char* Text)
{
// Only append the newline if the caller didn't
size_t textlen = strlen(Text);
if(Text[textlen - 1] != '\n')
{
Memory<char*> buffer(textlen + 2, "dputs");
memcpy(buffer(), Text, textlen);
buffer()[textlen] = '\n';
buffer()[textlen + 1] = '\0';
GuiAddLogMessageAsync(buffer());
}
else
GuiAddLogMessageAsync(Text);
}
/**
\brief Print a formatted string to the console.
\param format The printf format to use (see documentation of printf for more information).
\param Args The argument buffer passed to the string parser.
*/
void dprintf_args_untranslated(const char* Format, va_list Args)
{
char buffer[16384];
vsnprintf_s(buffer, _TRUNCATE, Format, Args);
GuiAddLogMessageAsync(buffer);
}

View File

@ -6,5 +6,7 @@
void dputs(const char* Text);
void dprintf(const char* Format, ...);
void dprintf_args(const char* Format, va_list Args);
void dputs_untranslated(const char* Text);
void dprintf_args_untranslated(const char* Format, va_list Args);
#endif // _CONSOLE_H

View File

@ -38,7 +38,7 @@ void DbSave(DbLoadSaveType saveType)
{
EXCLUSIVE_ACQUIRE(LockDatabase);
dputs("Saving database...");
dputs(QT_TRANSLATE_NOOP("DBG", "Saving database..."));
DWORD ticks = GetTickCount();
JSON root = json_object();
@ -106,7 +106,7 @@ void DbSave(DbLoadSaveType saveType)
// Dump JSON to disk (overwrite any old files)
if(!FileHelper::WriteAllText(dbpath, jsonText))
{
dputs("\nFailed to write database file!");
dputs(QT_TRANSLATE_NOOP("DBG", "\nFailed to write database file!"));
json_free(jsonText);
json_decref(root);
return;
@ -134,9 +134,9 @@ void DbLoad(DbLoadSaveType loadType)
return;
if(loadType == DbLoadSaveType::CommandLine)
dputs("Loading commandline...");
dputs(QT_TRANSLATE_NOOP("DBG", "Loading commandline..."));
else
dprintf("Loading database...");
dputs(QT_TRANSLATE_NOOP("DBG", "Loading database..."));
DWORD ticks = GetTickCount();
// Multi-byte (UTF8) file path converted to UTF16
@ -151,7 +151,7 @@ void DbLoad(DbLoadSaveType loadType)
// Check return code
if(useCompression && lzmaStatus != LZ4_SUCCESS && lzmaStatus != LZ4_INVALID_ARCHIVE)
{
dputs("\nInvalid database file!");
dputs(QT_TRANSLATE_NOOP("DBG", "\nInvalid database file!"));
return;
}
}
@ -161,7 +161,7 @@ void DbLoad(DbLoadSaveType loadType)
if(!FileHelper::ReadAllText(dbpath, databaseText))
{
dputs("\nFailed to read database file!");
dputs(QT_TRANSLATE_NOOP("DBG", "\nFailed to read database file!"));
return;
}
@ -175,7 +175,7 @@ void DbLoad(DbLoadSaveType loadType)
if(!root)
{
dputs("\nInvalid database file (JSON)!");
dputs(QT_TRANSLATE_NOOP("DBG", "\nInvalid database file (JSON)!"));
return;
}
@ -264,7 +264,7 @@ void DbSetPath(const char* Directory, const char* ModulePath)
if(!CreateDirectoryW(StringUtils::Utf8ToUtf16(Directory).c_str(), nullptr))
{
if(GetLastError() != ERROR_ALREADY_EXISTS)
dprintf("Warning: Failed to create database folder '%s'. Path may be read only.\n", Directory);
dprintf(QT_TRANSLATE_NOOP("DBG", "Warning: Failed to create database folder '%s'. Path may be read only.\n"), Directory);
}
}
@ -312,6 +312,6 @@ void DbSetPath(const char* Directory, const char* ModulePath)
sprintf_s(dbpath, "%s\\%s.%s", dbbasepath, dbName, dbType);
}
dprintf("Database file: %s\n", dbpath);
dprintf(QT_TRANSLATE_NOOP("DBG", "Database file: %s\n"), dbpath);
}
}

View File

@ -635,7 +635,7 @@ static void cbGenericBreakpoint(BP_TYPE bptype, void* ExceptionAddress = nullptr
if(!(bpPtr && bpPtr->enabled)) //invalid / disabled breakpoint hit (most likely a bug)
{
SHARED_RELEASE();
dputs("Breakpoint reached not in list!");
dputs(QT_TRANSLATE_NOOP("DBG", "Breakpoint reached not in list!"));
DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), true);
//lock
lock(WAITID_RUN);
@ -881,7 +881,7 @@ bool cbSetModuleBreakpoints(const BREAKPOINT* bp)
DWORD drx = 0;
if(!GetUnusedHardwareBreakPointRegister(&drx))
{
dputs("You can only set 4 hardware breakpoints");
dputs(QT_TRANSLATE_NOOP("DBG", "You can only set 4 hardware breakpoints"));
return false;
}
int titantype = bp->titantype;
@ -1323,7 +1323,7 @@ static void cbExitThread(EXIT_THREAD_DEBUG_INFO* ExitThread)
std::vector<THREADINFO> threads;
ThreadGetList(threads);
if(!threads.size())
dputs("No threads left to switch to (bug?)");
dputs(QT_TRANSLATE_NOOP("DBG", "No threads left to switch to (bug?)"));
hActiveThread = threads[0].Handle;
}
DWORD dwThreadId = ((DEBUG_EVENT*)GetDebugData())->dwThreadId;
@ -1360,9 +1360,9 @@ static void cbSystemBreakpoint(void* ExceptionData) // TODO: System breakpoint e
//log message
if(bIsAttached)
dputs("Attach breakpoint reached!");
dputs(QT_TRANSLATE_NOOP("DBG", "Attach breakpoint reached!"));
else
dputs("System breakpoint reached!");
dputs(QT_TRANSLATE_NOOP("DBG", "System breakpoint reached!"));
bSkipExceptions = false; //we are not skipping first-chance exceptions
//plugin callbacks
@ -1432,7 +1432,7 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll)
dprintf(QT_TRANSLATE_NOOP("DBG", "TLS Callbacks: %d\n"), NumberOfCallBacks);
Memory<duint*> TLSCallBacks(NumberOfCallBacks * sizeof(duint), "cbLoadDll:TLSCallBacks");
if(!TLSGrabCallBackDataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), TLSCallBacks(), &NumberOfCallBacks))
dputs("Failed to get TLS callback addresses!");
dputs(QT_TRANSLATE_NOOP("DBG", "Failed to get TLS callback addresses!"));
else
{
duint ImageBase = GetPE32DataW(StringUtils::Utf8ToUtf16(DLLDebugFileName).c_str(), 0, UE_IMAGEBASE);
@ -1610,15 +1610,15 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
detachInfo.fdProcessInfo = fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs("DetachDebuggerEx failed...");
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
else
dputs("Detached!");
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
isDetachedByUser = false;
return;
}
else if(isPausedByUser)
{
dputs("paused!");
dputs(QT_TRANSLATE_NOOP("DBG", "paused!"));
SetNextDbgContinueStatus(DBG_CONTINUE);
//update memory map
MemUpdateMap();
@ -1910,9 +1910,9 @@ void cbDetach()
detachInfo.fdProcessInfo = fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs("DetachDebuggerEx failed...");
dputs(QT_TRANSLATE_NOOP("DBG", "DetachDebuggerEx failed..."));
else
dputs("Detached!");
dputs(QT_TRANSLATE_NOOP("DBG", "Detached!"));
return;
}
@ -2241,7 +2241,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
BOOL wow64 = false, mewow64 = false;
if(!IsWow64Process(fdProcessInfo->hProcess, &wow64) || !IsWow64Process(GetCurrentProcess(), &mewow64))
{
dputs("IsWow64Process failed!");
dputs(QT_TRANSLATE_NOOP("DBG", "IsWow64Process failed!"));
StopDebug();
unlock(WAITID_STOP);
return;
@ -2249,9 +2249,9 @@ static void debugLoopFunction(void* lpParameter, bool attach)
if((mewow64 && !wow64) || (!mewow64 && wow64))
{
#ifdef _WIN64
dputs("Use x32dbg to debug this process!");
dputs(QT_TRANSLATE_NOOP("DBG", "Use x32dbg to debug this process!"));
#else
dputs("Use x64dbg to debug this process!");
dputs(QT_TRANSLATE_NOOP("DBG", "Use x64dbg to debug this process!"));
#endif // _WIN64
unlock(WAITID_STOP);
return;
@ -2336,7 +2336,7 @@ static void debugLoopFunction(void* lpParameter, bool attach)
TraceRecord.clear();
GuiSetDebugState(stopped);
GuiUpdateAllViews();
dputs("Debugging stopped!");
dputs(QT_TRANSLATE_NOOP("DBG", "Debugging stopped!"));
varset("$hp", (duint)0, true);
varset("$pid", (duint)0, true);
if(hProcessToken)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -58,9 +58,9 @@ void MemUpdateMap()
if(bReserved)
{
if(duint(curPage.mbi.BaseAddress) != allocationBase)
sprintf_s(curPage.info, "Reserved (" fhex ")", allocationBase);
sprintf_s(curPage.info, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Reserved (%p)")), allocationBase);
else
strcpy_s(curPage.info, "Reserved");
strcpy_s(curPage.info, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Reserved")));
}
else if(!ModNameFromAddr(pageStart, curPage.info, true))
{
@ -199,7 +199,7 @@ void MemUpdateMap()
if(pageBase == tebBase)
{
sprintf_s(page.info, "Thread %X TEB", threadId);
sprintf_s(page.info, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Thread %X TEB")), threadId);
break;
}
else if(pageBase == tebBaseWow64)
@ -207,7 +207,7 @@ void MemUpdateMap()
#ifndef _WIN64
if(pageSize == (3 * PAGE_SIZE))
{
sprintf_s(page.info, "Thread %X WoW64 TEB", threadId);
sprintf_s(page.info, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Thread %X WoW64 TEB")), threadId);
break;
}
#endif // ndef _WIN64
@ -224,7 +224,7 @@ void MemUpdateMap()
duint stackAddr = (duint)tib.StackLimit;
if(stackAddr >= pageBase && stackAddr < (pageBase + pageSize))
sprintf_s(page.info, "Thread %X Stack", threadId);
sprintf_s(page.info, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Thread %X Stack")), threadId);
}
}

View File

@ -85,9 +85,9 @@ String MnemonicHelp::getUniversalMnemonic(const String & mnem)
String MnemonicHelp::getDescription(const char* mnem, int depth)
{
if(mnem == nullptr)
return "Invalid mnemonic!";
return GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Invalid mnemonic!"));
if(depth == 10)
return "Too many redirections...";
return GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Too many redirections..."));
SHARED_ACQUIRE(LockMnemonicHelp);
auto mnemuni = getUniversalMnemonic(mnem);
auto found = MnemonicMap.find(mnemuni);
@ -114,11 +114,11 @@ String MnemonicHelp::getDescription(const char* mnem, int depth)
String MnemonicHelp::getBriefDescription(const char* mnem)
{
if(mnem == nullptr)
return "Invalid mnemonic!";
return GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Invalid mnemonic!"));
SHARED_ACQUIRE(LockMnemonicHelp);
auto mnemLower = StringUtils::ToLower(mnem);
if(mnemLower == "???")
return "invalid instruction";
return GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "invalid instruction"));
auto found = MnemonicBriefMap.find(mnemLower);
if(found == MnemonicBriefMap.end())
{

View File

@ -185,7 +185,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
{
// Notify the user of the error
if(Error)
strcpy_s(Error, MAX_ERROR_SIZE, "No patches to apply");
strcpy_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "No patches to apply")));
return -1;
}
@ -200,7 +200,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(_stricmp(List[i].mod, moduleName))
{
if(Error)
sprintf_s(Error, MAX_ERROR_SIZE, "Not all patches are in module %s", moduleName);
sprintf_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Not all patches are in module %s")), moduleName);
return -1;
}
@ -212,7 +212,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(!moduleBase)
{
if(Error)
sprintf_s(Error, MAX_ERROR_SIZE, "Failed to get base of module %s", moduleName);
sprintf_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Failed to get base of module %s")), moduleName);
return -1;
}
@ -222,7 +222,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(!ModPathFromAddr(moduleBase, modPath, MAX_PATH))
{
if(Error)
sprintf_s(Error, MAX_ERROR_SIZE, "Failed to get module path of module %s", moduleName);
sprintf_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Failed to get module path of module %s")), moduleName);
return -1;
}
@ -234,7 +234,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(!CopyFileW(srcPath.c_str(), dstPath.c_str(), false))
{
if(Error)
strcpy_s(Error, MAX_ERROR_SIZE, "Failed to make a copy of the original file (patch target is in use?)");
strcpy_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Failed to make a copy of the original file (patch target is in use?)")));
return -1;
}
@ -245,7 +245,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(fileAttrs == INVALID_FILE_ATTRIBUTES)
{
if(Error)
strcpy_s(Error, MAX_ERROR_SIZE, "Unable to obtain attributes for copied file");
strcpy_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Unable to obtain attributes for copied file")));
return -1;
}
@ -260,7 +260,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(!StaticFileLoadW(dstPath.c_str(), UE_ACCESS_ALL, false, &fileHandle, &loadedSize, &fileMap, &fileMapVa))
{
if(Error)
strcpy_s(Error, MAX_ERROR_SIZE, "StaticFileLoad failed");
strcpy_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "StaticFileLoad failed")));
return -1;
}
@ -285,7 +285,7 @@ int PatchFile(const PATCHINFO* List, int Count, const char* FileName, char* Erro
if(!StaticFileUnloadW(dstPath.c_str(), true, fileHandle, loadedSize, fileMap, fileMapVa))
{
if(Error)
strcpy_s(Error, MAX_ERROR_SIZE, "StaticFileUnload failed");
strcpy_s(Error, MAX_ERROR_SIZE, GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "StaticFileUnload failed")));
return -1;
}

View File

@ -79,7 +79,8 @@ static bool scriptcreatelinemap(const char* filename)
String filedata;
if(!FileHelper::ReadAllText(filename, filedata))
{
GuiScriptError(0, "FileHelper::ReadAllText failed...");
String TranslatedString = GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "FileHelper::ReadAllText failed..."));
GuiScriptError(0, TranslatedString.c_str());
return false;
}
auto len = filedata.length();
@ -305,7 +306,8 @@ static CMDRESULT scriptinternalcmdexec(const char* cmd)
{
if(!scriptstack.size()) //nothing on the stack
{
GuiScriptMessage("Script finished!");
String TranslatedString = GuiTranslateDbg(QT_TRANSLATE_NOOP("DBG", "Script finished!"));
GuiScriptMessage(TranslatedString.c_str());
return STATUS_EXIT;
}
scriptIp = scriptstack.back(); //set scriptIp to the call address (scriptinternalstep will step over it)

View File

@ -41,7 +41,7 @@ static CMDRESULT cbStrLen(int argc, char* argv[])
{
if(argc < 2)
{
dputs("not enough arguments!");
dputs(QT_TRANSLATE_NOOP("DBG", "not enough arguments!"));
return STATUS_ERROR;
}
dprintf("\"%s\"[%d]\n", argv[1], strlen(argv[1]));
@ -69,7 +69,7 @@ static CMDRESULT cbScriptDll(int argc, char* argv[])
{
if(argc < 2)
{
dputs("not enough arguments!");
dputs(QT_TRANSLATE_NOOP("DBG", "not enough arguments!"));
return STATUS_ERROR;
}
return DbgScriptDllExec(argv[1]) ? STATUS_CONTINUE : STATUS_ERROR;
@ -373,13 +373,13 @@ static DWORD WINAPI DbgScriptDllExecThread(void* a)
auto hScriptDll = info->hScriptDll;
delete info;
dprintf("[Script DLL] Calling export \"AsyncStart\"...\n");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] Calling export \"AsyncStart\"...\n"));
AsyncStart();
dprintf("[Script DLL] \"AsyncStart\" returned!\n");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] \"AsyncStart\" returned!\n"));
dprintf("[Script DLL] Calling FreeLibrary...");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] Calling FreeLibrary..."));
if(FreeLibrary(hScriptDll))
dprintf("success!\n");
dputs(QT_TRANSLATE_NOOP("DBG", "success!\n"));
else
dprintf("failure (%08X)...\n", GetLastError());
@ -402,7 +402,7 @@ static bool DbgScriptDllExec(const char* dll)
auto AsyncStart = SCRIPTDLLSTART(GetProcAddress(hScriptDll, "AsyncStart"));
if(AsyncStart)
{
dprintf("[Script DLL] Creating thread to call the export \"AsyncStart\"...\n");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] Creating thread to call the export \"AsyncStart\"...\n"));
CloseHandle(CreateThread(nullptr, 0, DbgScriptDllExecThread, new DLLSCRIPTEXECTHREADINFO(hScriptDll, AsyncStart), 0, nullptr)); //on-purpose memory leak here
}
else
@ -410,16 +410,16 @@ static bool DbgScriptDllExec(const char* dll)
auto Start = SCRIPTDLLSTART(GetProcAddress(hScriptDll, "Start"));
if(Start)
{
dprintf("[Script DLL] Calling export \"Start\"...\n");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] Calling export \"Start\"...\n"));
Start();
dprintf("[Script DLL] \"Start\" returned!\n");
dputs(QT_TRANSLATE_NOOP("DBG", "[Script DLL] \"Start\" returned!\n"));
}
else
dprintf("[Script DLL] Failed to find the exports \"AsyncStart\" or \"Start\" (%08X)!\n", GetLastError());
dprintf("[Script DLL] Calling FreeLibrary...");
if(FreeLibrary(hScriptDll))
dprintf("success!\n");
dputs(QT_TRANSLATE_NOOP("DBG", "success!\n"));
else
dprintf("failure (%08X)...\n", GetLastError());
}
@ -451,7 +451,7 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
dputs(QT_TRANSLATE_NOOP("DBG", "Initializing Yara..."));
if(yr_initialize() != ERROR_SUCCESS)
return "Failed to initialize Yara!";
dputs("Getting directory information...");
dputs(QT_TRANSLATE_NOOP("DBG", "Getting directory information..."));
wchar_t wszDir[deflen] = L"";
if(!GetModuleFileNameW(hInst, wszDir, deflen))
return "GetModuleFileNameW failed!";
@ -466,7 +466,9 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
strcpy_s(scriptDllDir, dir);
strcat_s(scriptDllDir, "\\scripts\\");
DeleteFileW(StringUtils::Utf8ToUtf16(alloctrace).c_str());
#ifdef ENABLE_MEM_TRACE
setalloctrace(alloctrace);
#endif //ENABLE_MEM_TRACE
initDataInstMap();
// Load mnemonic help database
@ -584,33 +586,33 @@ extern "C" DLL_EXPORT const char* _dbg_dbginit()
extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
{
dputs("Stopping running debuggee...");
dputs(QT_TRANSLATE_NOOP("DBG", "Stopping running debuggee..."));
cbDebugStop(0, 0);
dputs("Aborting scripts...");
dputs(QT_TRANSLATE_NOOP("DBG", "Aborting scripts..."));
scriptabort();
dputs("Waiting for the debuggee to be stopped...");
dputs(QT_TRANSLATE_NOOP("DBG", "Waiting for the debuggee to be stopped..."));
wait(WAITID_STOP); //after this, debugging stopped
dputs("Unloading plugins...");
dputs(QT_TRANSLATE_NOOP("DBG", "Unloading plugins..."));
pluginunload();
dputs("Stopping command thread...");
dputs(QT_TRANSLATE_NOOP("DBG", "Stopping command thread..."));
bStopCommandLoopThread = true;
MsgFreeStack(gMsgStack);
WaitForThreadTermination(hCommandLoopThread);
dputs("Cleaning up allocated data...");
dputs(QT_TRANSLATE_NOOP("DBG", "Cleaning up allocated data..."));
cmdfree();
varfree();
yr_finalize();
Capstone::GlobalFinalize();
dputs("Checking for mem leaks...");
dputs(QT_TRANSLATE_NOOP("DBG", "Checking for mem leaks..."));
if(memleaks())
dprintf("%d memory leak(s) found!\n", memleaks());
dprintf(QT_TRANSLATE_NOOP("DBG", "%d memory leak(s) found!\n"), memleaks());
else
DeleteFileW(StringUtils::Utf8ToUtf16(alloctrace).c_str());
dputs("Cleaning up wait objects...");
dputs(QT_TRANSLATE_NOOP("DBG", "Cleaning up wait objects..."));
waitdeinitialize();
dputs("Cleaning up debugger threads...");
dputs(QT_TRANSLATE_NOOP("DBG", "Cleaning up debugger threads..."));
dbgstop();
dputs("Saving notes...");
dputs(QT_TRANSLATE_NOOP("DBG", "Saving notes..."));
char* text = nullptr;
GuiGetGlobalNotes(&text);
if(text)
@ -620,7 +622,7 @@ extern "C" DLL_EXPORT void _dbg_dbgexitsignal()
}
else
DeleteFileW(StringUtils::Utf8ToUtf16(notesFile).c_str());
dputs("Exit signal processed successfully!");
dputs(QT_TRANSLATE_NOOP("DBG", "Exit signal processed successfully!"));
bIsStopped = true;
}