|
| 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