Skip to content

Commit 27ef129

Browse files
authored
Merge pull request #13 from mrexodia/gui-crash
Fix GUI crash
2 parents 8431127 + b76e727 commit 27ef129

File tree

4 files changed

+86
-34
lines changed

4 files changed

+86
-34
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Visual Studio
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
# Skip building pull requests from the same repository
8+
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) }}
9+
runs-on: windows-2019
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
with:
14+
submodules: recursive
15+
16+
- name: Add msbuild to PATH
17+
uses: microsoft/[email protected]
18+
19+
- name: Build
20+
run: |
21+
msbuild.exe ${{ github.event.repository.name }}.sln /m /verbosity:minimal /t:Rebuild /p:Configuration=Release /p:Platform=x64
22+
xcopy x64\Release\*.dp64 package\x64\plugins\
23+
msbuild.exe ${{ github.event.repository.name }}.sln /m /verbosity:minimal /t:Rebuild /p:Configuration=Release /p:Platform=x86
24+
xcopy Release\*.dp32 package\x32\plugins\
25+
26+
- uses: actions/upload-artifact@v2
27+
with:
28+
name: ${{ github.event.repository.name }}-${{ github.sha }}
29+
path: package/
30+
31+
- name: Compress artifacts
32+
uses: papeloto/action-zip@v1
33+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
34+
with:
35+
files: package/
36+
dest: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip
37+
38+
- name: Release
39+
uses: softprops/action-gh-release@v1
40+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
41+
with:
42+
prerelease: ${{ contains(github.ref, '-pre') }}
43+
files: ${{ github.event.repository.name }}-${{ github.ref_name }}.zip
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,5 @@ paket-files/
253253
# JetBrains Rider
254254
.idea/
255255
*.sln.iml
256+
257+
/package/

ClawSearch/ClawSearch.vcxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,19 @@
7171
<PropertyGroup Label="UserMacros" />
7272
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
7373
<TargetExt>.dp32</TargetExt>
74-
<OutDir>D:\RootApps\x64_dbg\x32\plugins\</OutDir>
7574
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
7675
</PropertyGroup>
7776
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7877
<TargetExt>.dp32</TargetExt>
79-
<OutDir>D:\RootApps\x64_dbg\x32\plugins\</OutDir>
8078
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
8179
<LibraryPath>$(SolutionDir)iup\;$(LibraryPath)</LibraryPath>
8280
</PropertyGroup>
8381
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
8482
<TargetExt>.dp64</TargetExt>
85-
<OutDir>D:\RootApps\x64_dbg\x64\plugins\</OutDir>
8683
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
8784
</PropertyGroup>
8885
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
8986
<TargetExt>.dp64</TargetExt>
90-
<OutDir>D:\RootApps\x64_dbg\x64\plugins\</OutDir>
9187
<IncludePath>$(SolutionDir)iup\include;$(IncludePath)</IncludePath>
9288
</PropertyGroup>
9389
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

ClawSearch/plugin.cpp

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22

33
#include "csMain.h"
44

5-
enum
6-
{
7-
MENU_OPENSEARCH
8-
};
9-
10-
PLUG_EXPORT void CBINITDEBUG(CBTYPE cbType, PLUG_CB_INITDEBUG* info)
5+
static void executeOnGuiThreadAndWait(void(*worker)())
116
{
7+
struct Context
8+
{
9+
HANDLE event;
10+
void(*worker)();
11+
};
12+
auto context = Context{ CreateEventW(nullptr, true, false, nullptr), worker };
13+
GuiExecuteOnGuiThreadEx([](void* data)
14+
{
15+
auto context = (Context*)data;
16+
context->worker();
17+
SetEvent(context->event);
18+
}, &context);
19+
WaitForSingleObject(context.event, INFINITE);
20+
CloseHandle(context.event);
1221
}
1322

14-
PLUG_EXPORT void CBSTOPDEBUG(CBTYPE cbType, PLUG_CB_STOPDEBUG* info)
15-
{
16-
}
17-
18-
PLUG_EXPORT void CBEXCEPTION(CBTYPE cbType, PLUG_CB_EXCEPTION* info)
19-
{
20-
}
21-
22-
PLUG_EXPORT void CBDEBUGEVENT(CBTYPE cbType, PLUG_CB_DEBUGEVENT* info)
23+
enum
2324
{
24-
}
25+
MENU_OPENSEARCH
26+
};
2527

2628
PLUG_EXPORT void CBMENUENTRY(CBTYPE cbType, PLUG_CB_MENUENTRY* info)
2729
{
@@ -38,33 +40,40 @@ PLUG_EXPORT void CBMENUENTRY(CBTYPE cbType, PLUG_CB_MENUENTRY* info)
3840
//Initialize your plugin data here.
3941
bool pluginInit(PLUG_INITSTRUCT* initStruct)
4042
{
41-
IupOpen(nullptr, nullptr);
42-
IupControlsOpen();
43+
return true; //Return false to cancel loading the plugin.
44+
}
4345

44-
IupSetGlobal("LOCKLOOP", "YES");
46+
//Do GUI/Menu related things here.
47+
void pluginSetup()
48+
{
49+
_plugin_menuaddentry(hMenu, MENU_OPENSEARCH, "Open search dialog");
50+
_plugin_menuaddentry(hMenuDump, MENU_OPENSEARCH, "ClawSearch");
4551

46-
return true; //Return false to cancel loading the plugin.
52+
// Initialize the UI on the same thread as x64dbg's UI
53+
executeOnGuiThreadAndWait([]
54+
{
55+
IupOpen(nullptr, nullptr);
56+
IupControlsOpen();
57+
58+
IupSetGlobal("LOCKLOOP", "YES");
59+
});
4760
}
4861

4962
//Deinitialize your plugin data here (clearing menus optional).
5063
bool pluginStop()
5164
{
52-
CloseSearch();
53-
IupClose();
54-
5565
_plugin_menuclear(hMenu);
5666
_plugin_menuclear(hMenuDisasm);
5767
_plugin_menuclear(hMenuDump);
5868
_plugin_menuclear(hMenuStack);
5969

60-
return true;
61-
}
70+
executeOnGuiThreadAndWait([]
71+
{
72+
CloseSearch();
73+
IupClose();
74+
});
6275

63-
//Do GUI/Menu related things here.
64-
void pluginSetup()
65-
{
66-
_plugin_menuaddentry(hMenu, MENU_OPENSEARCH, "Open search dialog");
67-
_plugin_menuaddentry(hMenuDump, MENU_OPENSEARCH, "ClawSearch");
76+
return true;
6877
}
6978

7079
// Hack for Iup

0 commit comments

Comments
 (0)