From 964e0731f36247a82ac9387885ac8b60ec827bf9 Mon Sep 17 00:00:00 2001 From: GLindor Date: Sun, 21 Feb 2016 17:16:48 -0500 Subject: [PATCH 1/3] Add Icon to right click Context menu for shell extension. --- src/launcher/x64_dbg_launcher.cpp | 41 ++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/launcher/x64_dbg_launcher.cpp b/src/launcher/x64_dbg_launcher.cpp index 61230374..7273f3bc 100644 --- a/src/launcher/x64_dbg_launcher.cpp +++ b/src/launcher/x64_dbg_launcher.cpp @@ -153,7 +153,7 @@ static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* def */ #define SHELLEXT_EXE_KEY L"exefile\\shell\\Debug with x64dbg\\Command" - +#define SHELLEXT_ICON_EXE_KEY L"exefile\\shell\\Debug with x64dbg" /** @def SHELLEXT_DLL_KEY @@ -161,7 +161,7 @@ static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* def */ #define SHELLEXT_DLL_KEY L"dllfile\\shell\\Debug with x64dbg\\Command" - +#define SHELLEXT_ICON_DLL_KEY L"dllfile\\shell\\Debug with x64dbg" /** @fn static void RegisterShellExtension(const wchar_t* key, const wchar_t* command) @@ -171,17 +171,36 @@ static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* def @param command The command. */ -static void RegisterShellExtension(const wchar_t* key, const wchar_t* command) +static BOOL RegisterShellExtension(const wchar_t* key, const wchar_t* command) { HKEY hKey; + BOOL result = TRUE; + if(RegCreateKeyW(HKEY_CLASSES_ROOT, key, &hKey) != ERROR_SUCCESS) { MessageBoxW(0, L"RegCreateKeyA failed!", L"Running as Admin?", MB_ICONERROR); - return; + return !result; } - if(RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) - MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); + if (RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) + { + MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); + result = !result; + } RegCloseKey(hKey); + return result; +} + +static void AddIcon(const wchar_t* key, const wchar_t* command) +{ + HKEY pKey; + if (RegOpenKeyExW(HKEY_CLASSES_ROOT, key, 0, KEY_ALL_ACCESS, &pKey) != ERROR_SUCCESS) + MessageBoxW(0, L"RegOpenKeyExW Failed!", L"Running as Admin?", MB_ICONERROR); + + if (RegSetValueExW(pKey, L"Icon", 0, REG_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) + MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); + + RegCloseKey(pKey); + return; } static void CreateUnicodeFile(const wchar_t* file) @@ -350,10 +369,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi } if(MessageBoxW(0, L"Do you want to register a shell extension?", L"Question", MB_YESNO | MB_ICONQUESTION) == IDYES) { - wchar_t szLauncherCommand[MAX_PATH] = L""; + wchar_t szLauncherCommand[MAX_PATH] = L""; + wchar_t szIconCommand[MAX_PATH] = L""; swprintf_s(szLauncherCommand, _countof(szLauncherCommand), L"\"%s\" \"%%1\"", szModulePath); - RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand); - RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand); + swprintf_s(szIconCommand, _countof(szIconCommand), L"\"%s\",0", szModulePath); + if (RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand)) + AddIcon(SHELLEXT_ICON_EXE_KEY, szIconCommand); + if (RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand)) + AddIcon(SHELLEXT_ICON_DLL_KEY, szIconCommand); } if(bDoneSomething) MessageBoxW(0, L"New configuration written!", L"Done!", MB_ICONINFORMATION); From efd85800d19e95a00dcb262396445a73ae44697f Mon Sep 17 00:00:00 2001 From: GLindor Date: Sun, 21 Feb 2016 19:46:51 -0500 Subject: [PATCH 2/3] Style changes. --- src/launcher/x64_dbg_launcher.cpp | 44 +++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/launcher/x64_dbg_launcher.cpp b/src/launcher/x64_dbg_launcher.cpp index 7273f3bc..f0230999 100644 --- a/src/launcher/x64_dbg_launcher.cpp +++ b/src/launcher/x64_dbg_launcher.cpp @@ -174,33 +174,33 @@ static bool BrowseFileOpen(HWND owner, const wchar_t* filter, const wchar_t* def static BOOL RegisterShellExtension(const wchar_t* key, const wchar_t* command) { HKEY hKey; - BOOL result = TRUE; - + BOOL result = TRUE; + if(RegCreateKeyW(HKEY_CLASSES_ROOT, key, &hKey) != ERROR_SUCCESS) { MessageBoxW(0, L"RegCreateKeyA failed!", L"Running as Admin?", MB_ICONERROR); return !result; } - if (RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) - { - MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); - result = !result; - } + if(RegSetValueExW(hKey, 0, 0, REG_EXPAND_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) + { + MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); + result = !result; + } RegCloseKey(hKey); - return result; + return result; } static void AddIcon(const wchar_t* key, const wchar_t* command) { - HKEY pKey; - if (RegOpenKeyExW(HKEY_CLASSES_ROOT, key, 0, KEY_ALL_ACCESS, &pKey) != ERROR_SUCCESS) - MessageBoxW(0, L"RegOpenKeyExW Failed!", L"Running as Admin?", MB_ICONERROR); + HKEY pKey; + if(RegOpenKeyExW(HKEY_CLASSES_ROOT, key, 0, KEY_ALL_ACCESS, &pKey) != ERROR_SUCCESS) + MessageBoxW(0, L"RegOpenKeyExW Failed!", L"Running as Admin?", MB_ICONERROR); - if (RegSetValueExW(pKey, L"Icon", 0, REG_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) - MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); + if(RegSetValueExW(pKey, L"Icon", 0, REG_SZ, (LPBYTE)command, (wcslen(command) + 1) * sizeof(wchar_t)) != ERROR_SUCCESS) + MessageBoxW(0, L"RegSetValueExA failed!", L"Running as Admin?", MB_ICONERROR); - RegCloseKey(pKey); - return; + RegCloseKey(pKey); + return; } static void CreateUnicodeFile(const wchar_t* file) @@ -369,14 +369,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi } if(MessageBoxW(0, L"Do you want to register a shell extension?", L"Question", MB_YESNO | MB_ICONQUESTION) == IDYES) { - wchar_t szLauncherCommand[MAX_PATH] = L""; - wchar_t szIconCommand[MAX_PATH] = L""; + wchar_t szLauncherCommand[MAX_PATH] = L""; + wchar_t szIconCommand[MAX_PATH] = L""; swprintf_s(szLauncherCommand, _countof(szLauncherCommand), L"\"%s\" \"%%1\"", szModulePath); - swprintf_s(szIconCommand, _countof(szIconCommand), L"\"%s\",0", szModulePath); - if (RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand)) - AddIcon(SHELLEXT_ICON_EXE_KEY, szIconCommand); - if (RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand)) - AddIcon(SHELLEXT_ICON_DLL_KEY, szIconCommand); + swprintf_s(szIconCommand, _countof(szIconCommand), L"\"%s\",0", szModulePath); + if(RegisterShellExtension(SHELLEXT_EXE_KEY, szLauncherCommand)) + AddIcon(SHELLEXT_ICON_EXE_KEY, szIconCommand); + if(RegisterShellExtension(SHELLEXT_DLL_KEY, szLauncherCommand)) + AddIcon(SHELLEXT_ICON_DLL_KEY, szIconCommand); } if(bDoneSomething) MessageBoxW(0, L"New configuration written!", L"Done!", MB_ICONINFORMATION); From 42e34286aa357be50df6810ef778b85d94bc30f7 Mon Sep 17 00:00:00 2001 From: GLindor Date: Sun, 21 Feb 2016 19:53:40 -0500 Subject: [PATCH 3/3] ran astylewhore --- src/gui/Src/Gui/CPUStack.cpp | 2 +- src/gui/Src/Gui/CPUWidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/Src/Gui/CPUStack.cpp b/src/gui/Src/Gui/CPUStack.cpp index b7ed2fae..f1c685b7 100644 --- a/src/gui/Src/Gui/CPUStack.cpp +++ b/src/gui/Src/Gui/CPUStack.cpp @@ -165,7 +165,7 @@ void CPUStack::setupContextMenu() int maxDumps = mMultiDump->getMaxCPUTabs(); for(int i = 0; i < maxDumps; i++) { - QAction* action = new QAction(QString("Dump %1)").arg(i+1), this); + QAction* action = new QAction(QString("Dump %1)").arg(i + 1), this); connect(action, SIGNAL(triggered()), this, SLOT(followinDumpNSlot())); mFollowInDumpMenu->addAction(action); mFollowInDumpActions.push_back(action); diff --git a/src/gui/Src/Gui/CPUWidget.cpp b/src/gui/Src/Gui/CPUWidget.cpp index e0ea59c5..2c70563e 100644 --- a/src/gui/Src/Gui/CPUWidget.cpp +++ b/src/gui/Src/Gui/CPUWidget.cpp @@ -52,7 +52,7 @@ CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget) mDump = new CPUMultiDump(mDisas, 5, 0); //dump widget ui->mBotLeftFrameLayout->addWidget(mDump); - mStack = new CPUStack(mDump,0); //stack widget + mStack = new CPUStack(mDump, 0); //stack widget ui->mBotRightFrameLayout->addWidget(mStack); }