summaryrefslogtreecommitdiff
path: root/architecture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'architecture.cpp')
-rw-r--r--architecture.cpp104
1 files changed, 102 insertions, 2 deletions
diff --git a/architecture.cpp b/architecture.cpp
index 821f4c7b..78c41dd3 100644
--- a/architecture.cpp
+++ b/architecture.cpp
@@ -140,8 +140,8 @@ BNArchitecture* Architecture::GetAssociatedArchitectureByAddressCallback(void* c
}
-bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, uint64_t addr,
- size_t maxLen, BNInstructionInfo* result)
+bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, uint64_t addr, size_t maxLen,
+ BNInstructionInfo* result)
{
Architecture* arch = (Architecture*)ctxt;
@@ -152,6 +152,19 @@ bool Architecture::GetInstructionInfoCallback(void* ctxt, const uint8_t* data, u
}
+bool Architecture::GetRelocationInfoCallback(void* ctxt, BNBinaryView* view, uint64_t relocType,
+ BNRelocationInfo* result)
+{
+ Architecture* arch = (Architecture*)ctxt;
+
+ BNRelocationInfo info = *result;
+ Ref<BinaryView> bv = new BinaryView(BNNewViewReference(view));
+ bool ok = arch->GetRelocationInfo(bv, relocType, info);
+ *result = info;
+ return ok;
+}
+
+
bool Architecture::GetInstructionTextCallback(void* ctxt, const uint8_t* data, uint64_t addr,
size_t* len, BNInstructionTextToken** result, size_t* count)
{
@@ -443,6 +456,33 @@ bool Architecture::SkipAndReturnValueCallback(void* ctxt, uint8_t* data, uint64_
}
+// bool Architecture::ApplyPERelocationCallback(void* ctxt, BNBinaryView* view, BNRelocation* rel, uint8_t* data, size_t len)
+// {
+// Architecture* arch = (Architecture*)ctxt;
+// Ref<BinaryView> bv = new BinaryView(BNNewViewReference(view));
+// Ref<Relocation> reloc = new Relocation(BNNewRelocationReference(rel));
+// return arch->ApplyPERelocation(bv, reloc, data, len);
+// }
+
+
+bool Architecture::ApplyELFRelocationCallback(void* ctxt, BNBinaryView* view, BNRelocationInfo* rel, uint8_t* data, size_t len)
+{
+ Architecture* arch = (Architecture*)ctxt;
+ Ref<BinaryView> bv = new BinaryView(BNNewViewReference(view));
+ BNRelocationInfo reloc = *rel;
+ return arch->ApplyELFRelocation(bv, reloc, data, len);
+}
+
+
+// bool Architecture::ApplyMachoRelocationCallback(void* ctxt, BNBinaryView* view, BNRelocation* rel, uint8_t* data, size_t len)
+// {
+// Architecture* arch = (Architecture*)ctxt;
+// Ref<BinaryView> bv = new BinaryView(BNNewViewReference(view));
+// Ref<Relocation> reloc = new Relocation(BNNewRelocationReference(rel));
+// return arch->ApplyMachoRelocation(bv, reloc, data, len);
+// }
+
+
void Architecture::Register(Architecture* arch)
{
BNCustomArchitecture callbacks;
@@ -486,6 +526,11 @@ void Architecture::Register(Architecture* arch)
callbacks.alwaysBranch = AlwaysBranchCallback;
callbacks.invertBranch = InvertBranchCallback;
callbacks.skipAndReturnValue = SkipAndReturnValueCallback;
+ // callbacks.applyPERelocation = ApplyPERelocationCallback;
+ callbacks.applyELFRelocation = ApplyELFRelocationCallback;
+ // callbacks.applyMachoRelocation = ApplyMachoRelocationCallback;
+ callbacks.getRelocationInfo = GetRelocationInfoCallback;
+
arch->AddRefForRegistration();
BNRegisterArchitecture(arch->m_nameForRegister.c_str(), &callbacks);
}
@@ -897,6 +942,37 @@ Ref<Platform> Architecture::GetStandalonePlatform()
}
+// bool Architecture::ApplyPERelocation(BinaryView* view, Relocation* rel, uint8_t* dest, size_t len)
+// {
+// (void)view;
+// (void)rel;
+// (void)dest;
+// (void)len;
+// return true;
+// }
+
+
+bool Architecture::ApplyELFRelocation(BinaryView* view, BNRelocationInfo& rel, uint8_t* dest, size_t len)
+{
+ (void)view;
+ (void)rel;
+ (void)dest;
+ (void)len;
+
+ return true;
+}
+
+
+// bool Architecture::ApplyMachoRelocation(BinaryView* view, Relocation* rel, uint8_t* dest, size_t len)
+// {
+// (void)view;
+// (void)rel;
+// (void)dest;
+// (void)len;
+// return true;
+// }
+
+
CoreArchitecture::CoreArchitecture(BNArchitecture* arch): Architecture(arch)
{
}
@@ -1202,3 +1278,27 @@ bool CoreArchitecture::SkipAndReturnValue(uint8_t* data, uint64_t addr, size_t l
{
return BNArchitectureSkipAndReturnValue(m_object, data, addr, len, value);
}
+
+
+// bool CoreArchitecture::ApplyPERelocation(BinaryView* view, Relocation* rel, uint8_t* dest, size_t len)
+// {
+// return BNArchitectureApplyPERelocation(m_object, view->GetObject(), rel->GetObject(), dest, len);
+// }
+
+
+bool CoreArchitecture::ApplyELFRelocation(BinaryView* view, BNRelocationInfo& rel, uint8_t* dest, size_t len)
+{
+ return BNArchitectureApplyELFRelocation(m_object, view->GetObject(), &rel, dest, len);
+}
+
+
+// bool CoreArchitecture::ApplyMachoRelocation(BinaryView* view, Relocation* rel, uint8_t* dest, size_t len)
+// {
+// return BNArchitectureApplyMachoRelocation(m_object, view->GetObject(), rel->GetObject(), dest, len);
+// }
+
+
+bool CoreArchitecture::GetRelocationInfo(BinaryView* view, uint64_t relocType, BNRelocationInfo& reloc)
+{
+ return BNGetRelocationInfo(m_object, view->GetObject(), relocType, &reloc);
+} \ No newline at end of file