summaryrefslogtreecommitdiff
path: root/platform/decree/platform_decree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'platform/decree/platform_decree.cpp')
-rw-r--r--platform/decree/platform_decree.cpp66
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;
+ }
+}