From 48dde167f37ffee6ba22597cddbe0a2ce638848d Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 4 Mar 2024 01:28:00 +0100 Subject: [PATCH] Minor cleanup & ensure the plugin API is C compatible --- src/bridge/bridgemain.h | 12 ++++++------ src/dbg/_apichecker.c | 7 +++++++ src/dbg/_global.cpp | 1 - src/dbg/_plugin_types.h | 4 +++- src/dbg/_plugins.cpp | 2 +- src/dbg/_plugins.h | 2 +- src/dbg/bridgemain.h | 2 ++ src/dbg/x64dbg_dbg.vcxproj | 2 ++ src/dbg/x64dbg_dbg.vcxproj.filters | 6 ++++++ 9 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 src/dbg/_apichecker.c create mode 100644 src/dbg/bridgemain.h diff --git a/src/bridge/bridgemain.h b/src/bridge/bridgemain.h index 05ade979..7a694243 100644 --- a/src/bridge/bridgemain.h +++ b/src/bridge/bridgemain.h @@ -1,14 +1,14 @@ #ifndef _BRIDGEMAIN_H_ #define _BRIDGEMAIN_H_ -#include +#include #ifndef __cplusplus #include #define DEFAULT_PARAM(name, value) name #else #define DEFAULT_PARAM(name, value) name = value -#endif +#endif // __cplusplus //default structure alignments forced #ifdef _WIN64 @@ -36,7 +36,7 @@ typedef signed long dsint; #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus //Bridge defines #define MAX_SETTING_SIZE 65536 @@ -147,7 +147,7 @@ BRIDGE_IMPEXP const wchar_t* BridgeUserDirectory(); #ifdef __cplusplus } -#endif +#endif // __cplusplus //list structure (and C++ wrapper) #include "bridgelist.h" @@ -157,7 +157,7 @@ BRIDGE_IMPEXP const wchar_t* BridgeUserDirectory(); #ifdef __cplusplus extern "C" { -#endif +#endif // __cplusplus //Debugger defines #define MAX_LABEL_SIZE 256 @@ -1477,7 +1477,7 @@ BRIDGE_IMPEXP DWORD GuiGetMainThreadId(); #ifdef __cplusplus } -#endif +#endif // __cplusplus // Some useful C++ wrapper classes #ifdef __cplusplus diff --git a/src/dbg/_apichecker.c b/src/dbg/_apichecker.c new file mode 100644 index 00000000..91028f5d --- /dev/null +++ b/src/dbg/_apichecker.c @@ -0,0 +1,7 @@ +// HACK: pretend we are in the same environment as a plugin +//#define PLUG_IMPEXP +#ifdef BUILD_DBG +#undef BUILD_DBG +#endif // BUILD_DBG + +#include "_plugins.h" diff --git a/src/dbg/_global.cpp b/src/dbg/_global.cpp index 7985360b..9dc27030 100644 --- a/src/dbg/_global.cpp +++ b/src/dbg/_global.cpp @@ -3,7 +3,6 @@ \brief Implements the global class. */ -#include #include "_global.h" #include #include diff --git a/src/dbg/_plugin_types.h b/src/dbg/_plugin_types.h index db3264c0..8e017e32 100644 --- a/src/dbg/_plugin_types.h +++ b/src/dbg/_plugin_types.h @@ -12,12 +12,14 @@ #else +#include + #ifdef __GNUC__ #include "dbghelp/dbghelp.h" #else #pragma warning(push) #pragma warning(disable:4091) -#include +#include #pragma warning(pop) #endif // __GNUC__ diff --git a/src/dbg/_plugins.cpp b/src/dbg/_plugins.cpp index 688ca77c..e614a547 100644 --- a/src/dbg/_plugins.cpp +++ b/src/dbg/_plugins.cpp @@ -163,7 +163,7 @@ bool _plugin_registerexprfunction(int pluginHandle, const char* name, int argc, return pluginexprfuncregister(pluginHandle, name, argc, cbFunction, userdata); } -bool _plugin_registerexprfunctionex(int pluginHandle, const char* name, const ValueType & returnType, const ValueType* argTypes, size_t argCount, CBPLUGINEXPRFUNCTIONEX cbFunction, void* userdata) +bool _plugin_registerexprfunctionex(int pluginHandle, const char* name, ValueType returnType, const ValueType* argTypes, size_t argCount, CBPLUGINEXPRFUNCTIONEX cbFunction, void* userdata) { return pluginexprfuncregisterex(pluginHandle, name, returnType, argTypes, argCount, cbFunction, userdata); } diff --git a/src/dbg/_plugins.h b/src/dbg/_plugins.h index 01ee0590..bc27925b 100644 --- a/src/dbg/_plugins.h +++ b/src/dbg/_plugins.h @@ -348,7 +348,7 @@ PLUG_IMPEXP bool _plugin_menuentryremove(int pluginHandle, int hEntry); PLUG_IMPEXP void _plugin_startscript(CBPLUGINSCRIPT cbScript); PLUG_IMPEXP bool _plugin_waituntilpaused(); PLUG_IMPEXP bool _plugin_registerexprfunction(int pluginHandle, const char* name, int argc, CBPLUGINEXPRFUNCTION cbFunction, void* userdata); -PLUG_IMPEXP bool _plugin_registerexprfunctionex(int pluginHandle, const char* name, const ValueType & returnType, const ValueType* argTypes, size_t argCount, CBPLUGINEXPRFUNCTIONEX cbFunction, void* userdata); +PLUG_IMPEXP bool _plugin_registerexprfunctionex(int pluginHandle, const char* name, ValueType returnType, const ValueType* argTypes, size_t argCount, CBPLUGINEXPRFUNCTIONEX cbFunction, void* userdata); PLUG_IMPEXP bool _plugin_unregisterexprfunction(int pluginHandle, const char* name); PLUG_IMPEXP bool _plugin_unload(const char* pluginName); PLUG_IMPEXP bool _plugin_load(const char* pluginName); diff --git a/src/dbg/bridgemain.h b/src/dbg/bridgemain.h new file mode 100644 index 00000000..c6566419 --- /dev/null +++ b/src/dbg/bridgemain.h @@ -0,0 +1,2 @@ +// NOTE: this file is only here to make _apichecker.c compile +#include "../bridge/bridgemain.h" diff --git a/src/dbg/x64dbg_dbg.vcxproj b/src/dbg/x64dbg_dbg.vcxproj index 8d50f869..4eb27c79 100644 --- a/src/dbg/x64dbg_dbg.vcxproj +++ b/src/dbg/x64dbg_dbg.vcxproj @@ -114,6 +114,7 @@ + @@ -155,6 +156,7 @@ + diff --git a/src/dbg/x64dbg_dbg.vcxproj.filters b/src/dbg/x64dbg_dbg.vcxproj.filters index 3fb8ddee..c2c4d91b 100644 --- a/src/dbg/x64dbg_dbg.vcxproj.filters +++ b/src/dbg/x64dbg_dbg.vcxproj.filters @@ -458,6 +458,9 @@ Source Files\Symbols + + Source Files\Interfaces/Exports + @@ -898,5 +901,8 @@ Header Files\Third Party\LLVMDemangle + + Header Files\Interfaces/Exports + \ No newline at end of file