From 8aa848b46739852179971e7088e884e0b4f1bf39 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 10 Dec 2014 21:59:01 +0100 Subject: [PATCH 1/6] DBG: StringList typedef --- x64_dbg_dbg/stringutils.cpp | 4 ++-- x64_dbg_dbg/stringutils.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/stringutils.cpp b/x64_dbg_dbg/stringutils.cpp index 6d101370..b9ea5da6 100644 --- a/x64_dbg_dbg/stringutils.cpp +++ b/x64_dbg_dbg/stringutils.cpp @@ -3,7 +3,7 @@ #include #include -std::vector StringUtils::Split(const String & s, char delim, std::vector & elems) +StringList StringUtils::Split(const String & s, char delim, std::vector & elems) { std::stringstream ss(s); String item; @@ -16,7 +16,7 @@ std::vector StringUtils::Split(const String & s, char delim, std::vector return elems; } -std::vector StringUtils::Split(const String & s, char delim) +StringList StringUtils::Split(const String & s, char delim) { std::vector elems; Split(s, delim, elems); diff --git a/x64_dbg_dbg/stringutils.h b/x64_dbg_dbg/stringutils.h index 48a41bae..302566a2 100644 --- a/x64_dbg_dbg/stringutils.h +++ b/x64_dbg_dbg/stringutils.h @@ -6,12 +6,14 @@ typedef std::string String; typedef std::wstring WString; +typedef std::vector StringList; +typedef std::vector WStringList; class StringUtils { public: - static std::vector Split(const String & s, char delim, std::vector & elems); - static std::vector Split(const String & s, char delim); + static StringList Split(const String & s, char delim, std::vector & elems); + static StringList Split(const String & s, char delim); static String Trim(const String & s); static String TrimLeft(const String & s); static String TrimRight(const String & s); From 11bc98c371c6de4a4194173df3314415cf851821 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Wed, 10 Dec 2014 23:07:18 +0100 Subject: [PATCH 2/6] DBG+GUI: (hopefully) fixed some random bugs with the status label --- x64_dbg_dbg/console.cpp | 6 ++---- x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x64_dbg_dbg/console.cpp b/x64_dbg_dbg/console.cpp index de10e662..8a82b91a 100644 --- a/x64_dbg_dbg/console.cpp +++ b/x64_dbg_dbg/console.cpp @@ -1,7 +1,5 @@ #include "console.h" -static char msg[66000]; - void dputs(const char* text) { dprintf("%s\n", text); @@ -11,7 +9,7 @@ void dprintf(const char* format, ...) { va_list args; va_start(args, format); - *msg = 0; - vsnprintf(msg, sizeof(msg), format, args); + Memory msg(66000); + vsnprintf(msg, msg.size(), format, args); GuiAddLogMessage(msg); } diff --git a/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp b/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp index ce27c241..24dde11e 100644 --- a/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp +++ b/x64_dbg_gui/Project/Src/Gui/StatusLabel.cpp @@ -44,6 +44,7 @@ void StatusLabel::debugStateChangedSlot(DBGSTATE state) default: break; } + this->repaint(); } void StatusLabel::logUpdate(QString message) @@ -52,4 +53,5 @@ void StatusLabel::logUpdate(QString message) labelText = ""; labelText += message; setText(labelText); + this->repaint(); } From 90c7c2393a81270b30a78eb8b3e190a881bfb955 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Thu, 11 Dec 2014 17:49:36 +0100 Subject: [PATCH 3/6] DBG: added suspend/resume all threads --- help/resumeallthreads_threadresumeall.htm | 36 ++++++++++++++++++++ help/suspendallthreads_threadsuspendall.htm | 24 +++++++++++++ help/x64_dbg.wcp | Bin 83876 -> 85136 bytes x64_dbg_dbg/debugger_commands.cpp | 18 ++++++++++ x64_dbg_dbg/debugger_commands.h | 2 ++ x64_dbg_dbg/thread.cpp | 26 ++++++++++++++ x64_dbg_dbg/thread.h | 3 ++ x64_dbg_dbg/x64_dbg.cpp | 2 ++ 8 files changed, 111 insertions(+) create mode 100644 help/resumeallthreads_threadresumeall.htm create mode 100644 help/suspendallthreads_threadsuspendall.htm diff --git a/help/resumeallthreads_threadresumeall.htm b/help/resumeallthreads_threadresumeall.htm new file mode 100644 index 00000000..b098b6cb --- /dev/null +++ b/help/resumeallthreads_threadresumeall.htm @@ -0,0 +1,36 @@ + + + +resumeallthreads/threadresumeall + + + + + + + +

resumeallthreads[,threadresumeall]
Resume all threads in the debuggee.

+

+ + +arguments + +  +
+
+ +This command has no arguments.

+

+ + +result
This command does not set any result +variables.

+

 

+ \ No newline at end of file diff --git a/help/suspendallthreads_threadsuspendall.htm b/help/suspendallthreads_threadsuspendall.htm new file mode 100644 index 00000000..6ace5501 --- /dev/null +++ b/help/suspendallthreads_threadsuspendall.htm @@ -0,0 +1,24 @@ + + + +suspendallthreads/threadsuspendall + + + + + + + +

suspendallthreads[,threadsuspendall]
Suspend all threads in the debuggee.

+

arguments 
This command has no arguments.

+

result
This command does not set any result +variables.

+ \ No newline at end of file diff --git a/help/x64_dbg.wcp b/help/x64_dbg.wcp index 390969236ae42b48217bf9738d94c61e9d3b73b9..d38b1f3528f950fb55087c41aff7b7a0a90a4692 100644 GIT binary patch delta 4596 zcmai2dstN0wV%xZ5=8`p1W_l5ibxKJGsnX?Ao3DNVh~Y@A;b`fs7MtNkSH}isG8R} z;{1@EAklF$cfuux;3GyGMSR3qFV}#j)EcT5t+m7`QcJC|uyw2Vp{qf$VdG0RYc!>rV$Bjw zktSc0r&&QiWtsv_39aPON~tCatEZ3Vb{`gjq6Bf=e>{Ly)5mhp5lq6v1P4>#7pKR? zL^J9Vf*>U%q9I8jItN0s1NPy;u=xgHAldS)s!_Ak)6DxvK#Bu+DS@Rn7 z38OIop@gm!hgQ+VASo>hH)rb5HnRxXNg1%3gdsoEELR=I=9JM`pX6mt77#Scfy1Xo z^vtS;b;i4BOOGU5M%fM!!R>Rzz3DcCn93PouaR*Hld zMx#14miLWi;mDce=~^0#;OFDvm}B?QYZOg1HfKhmBAo=iFb18oV_}#p61@nubM0E< zz|N0JT!sbta{{?xGMhjeR{2dr@jOpjO2&nG4$MxMuxGwm`?{tWN$Vm}us}rqTqC*` zIQY#GOhjX*1&=e*QTd`kV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SLCRyG$Rc@eGSl$e zi9|)$<4HVMV1cx}Cz(CM#YYr+Jw(}wq-8$x5Fz`w)J$fHJZv&c;T;Jq5SIrM>E99^ zXQ?cCY*XCBcQbbFVRnG0q_Qwxo=oQblUSiLH1g_4C}RgwC}ZZt|7W6~%oh4hpkJir z{gWAeNq#5sT}jN#`yZv9P08dHX&PQ7P;4Vo=qS%(kzY|qF`Mg_X{sL9{oR05GW8UUW7J($!T{kw-Das7jrxO0CG-mDR%{d)w zqoo|)BeNV*V!11m@>iVBb|dcvk&AlP$qT2^-9x9cd_~jn!D)ojF!k=;9W&{o3E0tv-q8WHPfdGVtz9vhv5!KsoQsW?6Kt@3Ywy5__`Q1nv^)v`8Z{Gk7}XdDuvK zK0Tc>b@FF)NPaHM<>o93t~7&INz?M&Y~uIL8Fa!(wnBg@NyO+?CN`f} Date: Fri, 12 Dec 2014 15:45:38 +0100 Subject: [PATCH 4/6] DBG: resolve shortcut files --- x64_dbg_dbg/_global.cpp | 55 +++++++++++++++++++++++++++++++ x64_dbg_dbg/_global.h | 1 + x64_dbg_dbg/debugger_commands.cpp | 6 ++++ 3 files changed, 62 insertions(+) diff --git a/x64_dbg_dbg/_global.cpp b/x64_dbg_dbg/_global.cpp index fc47cee8..eb935d7a 100644 --- a/x64_dbg_dbg/_global.cpp +++ b/x64_dbg_dbg/_global.cpp @@ -1,4 +1,6 @@ #include "_global.h" +#include +#include #include HINSTANCE hInst; @@ -194,4 +196,57 @@ bool IsWow64() //x64_dbg supports WinXP SP3 and later only, so ignore the GetProcAddress crap :D IsWow64Process(GetCurrentProcess(), &bIsWow64Process); return !!bIsWow64Process; +} + +//Taken from: http://www.cplusplus.com/forum/windows/64088/ +bool ResolveShortcut(HWND hwnd, const wchar_t* szShortcutPath, char* szResolvedPath, size_t nSize) +{ + if(szResolvedPath == NULL) + return SUCCEEDED(E_INVALIDARG); + + //Initialize COM stuff + CoInitialize(NULL); + + //Get a pointer to the IShellLink interface. + IShellLink* psl = NULL; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if(SUCCEEDED(hres)) + { + //Get a pointer to the IPersistFile interface. + IPersistFile* ppf = NULL; + hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf); + if(SUCCEEDED(hres)) + { + //Load the shortcut. + hres = ppf->Load(szShortcutPath, STGM_READ); + + if(SUCCEEDED(hres)) + { + //Resolve the link. + hres = psl->Resolve(hwnd, 0); + + if(SUCCEEDED(hres)) + { + //Get the path to the link target. + char szGotPath[MAX_PATH] = {0}; + hres = psl->GetPath(szGotPath, _countof(szGotPath), NULL, SLGP_SHORTPATH); + + if(SUCCEEDED(hres)) + { + strcpy_s(szResolvedPath, nSize, szGotPath); + } + } + } + + //Release the pointer to the IPersistFile interface. + ppf->Release(); + } + + //Release the pointer to the IShellLink interface. + psl->Release(); + } + + //Uninitialize COM stuff + CoUninitialize(); + return SUCCEEDED(hres); } \ No newline at end of file diff --git a/x64_dbg_dbg/_global.h b/x64_dbg_dbg/_global.h index 1f8beea5..92f7feed 100644 --- a/x64_dbg_dbg/_global.h +++ b/x64_dbg_dbg/_global.h @@ -122,6 +122,7 @@ bool GetFileNameFromHandle(HANDLE hFile, char* szFileName); bool settingboolget(const char* section, const char* name); arch GetFileArchitecture(const char* szFileName); bool IsWow64(); +bool ResolveShortcut(HWND hwnd, const wchar_t* szShortcutPath, char* szResolvedPath, size_t nSize); #include "dynamicmem.h" diff --git a/x64_dbg_dbg/debugger_commands.cpp b/x64_dbg_dbg/debugger_commands.cpp index 7cd6f920..944cb40c 100644 --- a/x64_dbg_dbg/debugger_commands.cpp +++ b/x64_dbg_dbg/debugger_commands.cpp @@ -20,6 +20,12 @@ CMDRESULT cbDebugInit(int argc, char* argv[]) static char arg1[deflen] = ""; if(!argget(*argv, arg1, 0, false)) return STATUS_ERROR; + char szResolvedPath[MAX_PATH] = ""; + if(ResolveShortcut(GuiGetWindowHandle(), StringUtils::Utf8ToUtf16(arg1).c_str(), szResolvedPath, _countof(szResolvedPath))) + { + dprintf("resolved shortcut \"%s\"->\"%s\"\n", arg1, szResolvedPath); + strcpy_s(arg1, szResolvedPath); + } if(!FileExists(arg1)) { dputs("file does not exist!"); From 94fad3a0c4bd257f10c664641c555df8421c861c Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 12 Dec 2014 15:46:17 +0100 Subject: [PATCH 5/6] GUI: do not check file extensions (for dragging & dropping .lnk or other files) --- x64_dbg_gui/Project/Src/Gui/MainWindow.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp index 9fd64d46..688d8b68 100644 --- a/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp +++ b/x64_dbg_gui/Project/Src/Gui/MainWindow.cpp @@ -586,13 +586,10 @@ void MainWindow::dropEvent(QDropEvent* pEvent) if(pEvent->mimeData()->hasUrls()) { QString filename = QDir::toNativeSeparators(pEvent->mimeData()->urls()[0].toLocalFile()); - if(filename.contains(".exe", Qt::CaseInsensitive) || filename.contains(".dll", Qt::CaseInsensitive)) - { - if(DbgIsDebugging()) - DbgCmdExecDirect("stop"); - QString cmd; - DbgCmdExec(cmd.sprintf("init \"%s\"", filename.toUtf8().constData()).toUtf8().constData()); - } + if(DbgIsDebugging()) + DbgCmdExecDirect("stop"); + QString cmd; + DbgCmdExec(cmd.sprintf("init \"%s\"", filename.toUtf8().constData()).toUtf8().constData()); pEvent->acceptProposedAction(); } } From 208e216a35616de102e653ca419724b294f0031b Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 12 Dec 2014 16:56:01 +0100 Subject: [PATCH 6/6] LAUNCHER: resolve .lnk shortcuts --- x64_dbg_launcher/x64_dbg_launcher.cpp | 64 ++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/x64_dbg_launcher/x64_dbg_launcher.cpp b/x64_dbg_launcher/x64_dbg_launcher.cpp index 2239e07d..f4f2ec64 100644 --- a/x64_dbg_launcher/x64_dbg_launcher.cpp +++ b/x64_dbg_launcher/x64_dbg_launcher.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include enum arch { @@ -98,6 +100,59 @@ static void CreateUnicodeFile(const wchar_t* file) CloseHandle(hFile); } +//Taken from: http://www.cplusplus.com/forum/windows/64088/ +static bool ResolveShortcut(HWND hwnd, const wchar_t* szShortcutPath, char* szResolvedPath, size_t nSize) +{ + if(szResolvedPath == NULL) + return SUCCEEDED(E_INVALIDARG); + + //Initialize COM stuff + CoInitialize(NULL); + + //Get a pointer to the IShellLink interface. + IShellLink* psl = NULL; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if(SUCCEEDED(hres)) + { + //Get a pointer to the IPersistFile interface. + IPersistFile* ppf = NULL; + hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf); + if(SUCCEEDED(hres)) + { + //Load the shortcut. + hres = ppf->Load(szShortcutPath, STGM_READ); + + if(SUCCEEDED(hres)) + { + //Resolve the link. + hres = psl->Resolve(hwnd, 0); + + if(SUCCEEDED(hres)) + { + //Get the path to the link target. + char szGotPath[MAX_PATH] = {0}; + hres = psl->GetPath(szGotPath, _countof(szGotPath), NULL, SLGP_SHORTPATH); + + if(SUCCEEDED(hres)) + { + strcpy_s(szResolvedPath, nSize, szGotPath); + } + } + } + + //Release the pointer to the IPersistFile interface. + ppf->Release(); + } + + //Release the pointer to the IShellLink interface. + psl->Release(); + } + + //Uninitialize COM stuff + CoUninitialize(); + return SUCCEEDED(hres); +} + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { CoInitialize(NULL); //fixed some crash @@ -192,10 +247,15 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi } if(argc == 2) //one argument -> execute debugger { + wchar_t szPath[MAX_PATH] = L""; + wcscpy_s(szPath, argv[1]); + char szResolvedPath[MAX_PATH] = ""; + if(ResolveShortcut(0, szPath, szResolvedPath, _countof(szResolvedPath))) + MultiByteToWideChar(CP_ACP, 0, szResolvedPath, -1, szPath, _countof(szPath)); std::wstring cmdLine = L"\""; - cmdLine += argv[1]; + cmdLine += szPath; cmdLine += L"\""; - switch(GetFileArchitecture(argv[1])) + switch(GetFileArchitecture(szPath)) { case x32: if(sz32Path[0])