From 4d6d46c204808ce9ef179fbc2fd9b6aedcf9390f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 7 Oct 2022 14:36:33 +0200 Subject: [PATCH 1/3] Fix a crash when closing with the window open Closes #12 Closes #5 --- ClawSearch/plugin.cpp | 69 ++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/ClawSearch/plugin.cpp b/ClawSearch/plugin.cpp index 3ddd1ab..47db4e6 100644 --- a/ClawSearch/plugin.cpp +++ b/ClawSearch/plugin.cpp @@ -2,26 +2,28 @@ #include "csMain.h" -enum -{ - MENU_OPENSEARCH -}; - -PLUG_EXPORT void CBINITDEBUG(CBTYPE cbType, PLUG_CB_INITDEBUG* info) +static void executeOnGuiThreadAndWait(void(*worker)()) { + struct Context + { + HANDLE event; + void(*worker)(); + }; + auto context = Context{ CreateEventW(nullptr, true, false, nullptr), worker }; + GuiExecuteOnGuiThreadEx([](void* data) + { + auto context = (Context*)data; + context->worker(); + SetEvent(context->event); + }, &context); + WaitForSingleObject(context.event, INFINITE); + CloseHandle(context.event); } -PLUG_EXPORT void CBSTOPDEBUG(CBTYPE cbType, PLUG_CB_STOPDEBUG* info) -{ -} - -PLUG_EXPORT void CBEXCEPTION(CBTYPE cbType, PLUG_CB_EXCEPTION* info) -{ -} - -PLUG_EXPORT void CBDEBUGEVENT(CBTYPE cbType, PLUG_CB_DEBUGEVENT* info) +enum { -} + MENU_OPENSEARCH +}; PLUG_EXPORT void CBMENUENTRY(CBTYPE cbType, PLUG_CB_MENUENTRY* info) { @@ -38,33 +40,40 @@ PLUG_EXPORT void CBMENUENTRY(CBTYPE cbType, PLUG_CB_MENUENTRY* info) //Initialize your plugin data here. bool pluginInit(PLUG_INITSTRUCT* initStruct) { - IupOpen(nullptr, nullptr); - IupControlsOpen(); + return true; //Return false to cancel loading the plugin. +} - IupSetGlobal("LOCKLOOP", "YES"); +//Do GUI/Menu related things here. +void pluginSetup() +{ + _plugin_menuaddentry(hMenu, MENU_OPENSEARCH, "Open search dialog"); + _plugin_menuaddentry(hMenuDump, MENU_OPENSEARCH, "ClawSearch"); - return true; //Return false to cancel loading the plugin. + // Initialize the UI on the same thread as x64dbg's UI + executeOnGuiThreadAndWait([] + { + IupOpen(nullptr, nullptr); + IupControlsOpen(); + + IupSetGlobal("LOCKLOOP", "YES"); + }); } //Deinitialize your plugin data here (clearing menus optional). bool pluginStop() { - CloseSearch(); - IupClose(); - _plugin_menuclear(hMenu); _plugin_menuclear(hMenuDisasm); _plugin_menuclear(hMenuDump); _plugin_menuclear(hMenuStack); - return true; -} + executeOnGuiThreadAndWait([] + { + CloseSearch(); + IupClose(); + }); -//Do GUI/Menu related things here. -void pluginSetup() -{ - _plugin_menuaddentry(hMenu, MENU_OPENSEARCH, "Open search dialog"); - _plugin_menuaddentry(hMenuDump, MENU_OPENSEARCH, "ClawSearch"); + return true; } // Hack for Iup From 8575431f08d3f3e5f4e8899997bfcb460ba4c07f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 7 Oct 2022 14:37:05 +0200 Subject: [PATCH 2/3] Output the binaries in the local folder --- ClawSearch/ClawSearch.vcxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ClawSearch/ClawSearch.vcxproj b/ClawSearch/ClawSearch.vcxproj index 876fd23..746410f 100644 --- a/ClawSearch/ClawSearch.vcxproj +++ b/ClawSearch/ClawSearch.vcxproj @@ -71,23 +71,19 @@ .dp32 - D:\RootApps\x64_dbg\x32\plugins\ $(SolutionDir)iup\include;$(IncludePath) .dp32 - D:\RootApps\x64_dbg\x32\plugins\ $(SolutionDir)iup\include;$(IncludePath) $(SolutionDir)iup\;$(LibraryPath) .dp64 - D:\RootApps\x64_dbg\x64\plugins\ $(SolutionDir)iup\include;$(IncludePath) .dp64 - D:\RootApps\x64_dbg\x64\plugins\ $(SolutionDir)iup\include;$(IncludePath) From b76e727af4ae16206af8b84f8b739196d81c995f Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Fri, 7 Oct 2022 14:40:54 +0200 Subject: [PATCH 3/3] Add build+release workflow with GitHub Actions --- .github/workflows/build.yml | 45 +++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ 2 files changed, 47 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..90a7f06 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Visual Studio + +on: [push, pull_request] + +jobs: + build: + # Skip building pull requests from the same repository + if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }} + runs-on: windows-2019 + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Build + run: | + msbuild.exe ${{ github.event.repository.name }}.sln /m /verbosity:minimal /t:Rebuild /p:Configuration=Release /p:Platform=x64 + xcopy x64\Release\*.dp64 package\x64\plugins\ + msbuild.exe ${{ github.event.repository.name }}.sln /m /verbosity:minimal /t:Rebuild /p:Configuration=Release /p:Platform=x86 + xcopy Release\*.dp32 package\x32\plugins\ + + - uses: actions/upload-artifact@v2 + with: + name: ${{ github.event.repository.name }}-${{ github.sha }} + path: package/ + + - name: Compress artifacts + uses: papeloto/action-zip@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + files: package/ + dest: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip + + - name: Release + uses: softprops/action-gh-release@v1 + if: ${{ startsWith(github.ref, 'refs/tags/') }} + with: + prerelease: ${{ contains(github.ref, '-pre') }} + files: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6857d1e..b5c6460 100644 --- a/.gitignore +++ b/.gitignore @@ -253,3 +253,5 @@ paket-files/ # JetBrains Rider .idea/ *.sln.iml + +/package/