From 52eb0de5dcddaee2b8bd3122512ae4c20e0e9545 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 13 Jun 2023 11:29:42 -0600 Subject: Move platform submodules into API --- platform/decree/platform_decree.cpp | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 platform/decree/platform_decree.cpp (limited to 'platform/decree/platform_decree.cpp') 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 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 x86 = Architecture::GetByName("x86"); + if (x86) + { + Ref platform; + + platform = new DecreeX86Platform(x86); + Platform::Register("decree", platform); + BinaryViewType::RegisterPlatform("ELF", 'C', x86, platform); + } + + return true; + } +} -- cgit v1.3.1