Skip to content

Commit 44270a1

Browse files
committed
Init
1 parent fe08c79 commit 44270a1

2 files changed

Lines changed: 97 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 2.8.11)
2+
3+
project(dbgPlugin CXX C)
4+
5+
set(x64dbgfolder C:/tools/x64dbg )
6+
7+
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${x64dbgfolder}/release/x32/plugins)
8+
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${x64dbgfolder}/release/x32/plugins)
9+
10+
include_directories( ${x64dbgfolder} )
11+
LINK_DIRECTORIES( ${x64dbgfolder}/pluginsdk )
12+
13+
14+
add_library(dbgPlugin SHARED
15+
main.cc
16+
)
17+
18+
target_link_libraries(dbgPlugin x32dbg x32bridge )
19+
set_target_properties(dbgPlugin PROPERTIES SUFFIX ".dp32")

main.cc

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#include <windows.h>
2+
#include "pluginsdk/_plugins.h"
3+
4+
#ifndef DLL_EXPORT
5+
#define DLL_EXPORT __declspec(dllexport)
6+
#endif //DLL_EXPORT
7+
8+
#define plugin_name "testplugin"
9+
#define plugin_version 1
10+
11+
int pluginHandle;
12+
HWND hwndDlg;
13+
int hMenu;
14+
int hMenuDisasm;
15+
int hMenuDump;
16+
int hMenuStack;
17+
18+
bool exec(int argc, char* argv[]) {
19+
for(unsigned i = 1;i < argc;i++) {
20+
DbgCmdExec(argv[i]);
21+
}
22+
return true;
23+
}
24+
25+
bool printMemoryRegion(int argc, char* argv[]) {
26+
size_t length = 16;
27+
if(argc == 1)
28+
return true;
29+
if(argc > 2) {
30+
length = atoi(argv[2]);
31+
}
32+
33+
auto memPtr = DbgValFromString(argv[1]);
34+
35+
_plugin_logprintf("0x%x (%d):", memPtr, length);
36+
for(unsigned i = 0;i < length;i++) {
37+
uint8_t buf = 0;
38+
DbgMemRead(memPtr + i, &buf, 1);
39+
_plugin_logprintf("%02x ", buf);
40+
}
41+
_plugin_logprintf("\n");
42+
return true;
43+
}
44+
45+
extern "C" DLL_EXPORT bool pluginit(PLUG_INITSTRUCT* initStruct)
46+
{
47+
initStruct->pluginVersion = plugin_version;
48+
initStruct->sdkVersion = PLUG_SDKVERSION;
49+
strcpy(initStruct->pluginName, plugin_name);
50+
pluginHandle = initStruct->pluginHandle;
51+
52+
_plugin_logprintf("[TEST] pluginHandle: %d\n", pluginHandle);
53+
if(!_plugin_registercommand(pluginHandle, "printMemoryRegion", printMemoryRegion, false))
54+
_plugin_logputs("[TEST] error registering the \"printMemoryRegion\" command!");
55+
if(!_plugin_registercommand(pluginHandle, "exec", exec, false))
56+
_plugin_logputs("[TEST] error registering the \"exec\" command!");
57+
58+
return true;
59+
}
60+
61+
extern "C" DLL_EXPORT bool plugstop()
62+
{
63+
return true;
64+
}
65+
66+
extern "C" DLL_EXPORT void plugsetup(PLUG_SETUPSTRUCT* setupStruct)
67+
{
68+
hwndDlg = setupStruct->hwndDlg;
69+
hMenu = setupStruct->hMenu;
70+
hMenuDisasm = setupStruct->hMenuDisasm;
71+
hMenuDump = setupStruct->hMenuDump;
72+
hMenuStack = setupStruct->hMenuStack;
73+
}
74+
75+
extern "C" DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
76+
{
77+
return TRUE;
78+
}

0 commit comments

Comments
 (0)