Skip to content

Commit

Permalink
Merge pull request #13 from mrexodia/gui-crash
Browse files Browse the repository at this point in the history
Fix GUI crash
  • Loading branch information
codecat authored Oct 7, 2022
2 parents 8431127 + b76e727 commit 27ef129
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 34 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,5 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml

/package/
4 changes: 0 additions & 4 deletions ClawSearch/ClawSearch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.dp32</TargetExt>
<OutDir>D:\RootApps\x64_dbg\x32\plugins\</OutDir>
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.dp32</TargetExt>
<OutDir>D:\RootApps\x64_dbg\x32\plugins\</OutDir>
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
<LibraryPath>$(SolutionDir)iup\;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetExt>.dp64</TargetExt>
<OutDir>D:\RootApps\x64_dbg\x64\plugins\</OutDir>
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetExt>.dp64</TargetExt>
<OutDir>D:\RootApps\x64_dbg\x64\plugins\</OutDir>
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand Down
69 changes: 39 additions & 30 deletions ClawSearch/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down

0 comments on commit 27ef129

Please sign in to comment.