diff options
| author | Rusty Wagner <rusty.wagner@gmail.com> | 2023-06-13 11:29:42 -0600 |
|---|---|---|
| committer | Rusty Wagner <rusty.wagner@gmail.com> | 2023-06-13 16:46:47 -0400 |
| commit | 52eb0de5dcddaee2b8bd3122512ae4c20e0e9545 (patch) | |
| tree | 8543df055ebc32d32283c0231cbeb6c7fd424533 /platform/decree/platform_decree.cpp | |
| parent | adb7ef55fc4e24f03e6faf353cc9122ee07c714f (diff) | |
Move platform submodules into API
Diffstat (limited to 'platform/decree/platform_decree.cpp')
| -rw-r--r-- | platform/decree/platform_decree.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/platform/decree/platform_decree.cpp b/platform/decree/platform_decree.cpp new file mode 100644 index 00000000..a0eb2b32 --- /dev/null +++ b/platform/decree/platform_decree.cpp @@ -0,0 +1,66 @@ +#include "binaryninjaapi.h" + +using namespace BinaryNinja; +using namespace std; + + +class DecreeX86Platform: public Platform +{ +public: + DecreeX86Platform(Architecture* arch): Platform(arch, "decree-x86") + { + Ref<CallingConvention> cc; + + cc = arch->GetCallingConventionByName("cdecl"); + if (cc) + { + RegisterDefaultCallingConvention(cc); + RegisterCdeclCallingConvention(cc); + } + + cc = arch->GetCallingConventionByName("regparm"); + if (cc) + RegisterFastcallCallingConvention(cc); + + cc = arch->GetCallingConventionByName("stdcall"); + if (cc) + RegisterStdcallCallingConvention(cc); + + cc = arch->GetCallingConventionByName("linux-syscall"); + if (cc) + SetSystemCallConvention(cc); + } +}; + + +extern "C" +{ + BN_DECLARE_CORE_ABI_VERSION + +#ifndef DEMO_VERSION + BINARYNINJAPLUGIN void CorePluginDependencies() + { + AddOptionalPluginDependency("arch_x86"); + AddOptionalPluginDependency("view_elf"); + } +#endif + +#ifdef DEMO_VERSION + bool DecreePluginInit() +#else + BINARYNINJAPLUGIN bool CorePluginInit() +#endif + { + Ref<Architecture> x86 = Architecture::GetByName("x86"); + if (x86) + { + Ref<Platform> platform; + + platform = new DecreeX86Platform(x86); + Platform::Register("decree", platform); + BinaryViewType::RegisterPlatform("ELF", 'C', x86, platform); + } + + return true; + } +} |
