diff options
| author | Peter LaFosse <peter@vector35.com> | 2018-08-26 15:31:12 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2018-08-26 15:31:12 -0400 |
| commit | fe925b01df7934785aa5dc67d23c577f13ad42e6 (patch) | |
| tree | 8a2e05c645c6be7dbc12897cb1a696f16066b8af /relocationhandler.cpp | |
| parent | 4fdd54f690e538ddb4e38248144ef3d3e0f817da (diff) | |
Add support for new constant type EXTERN_PTR
Diffstat (limited to 'relocationhandler.cpp')
| -rw-r--r-- | relocationhandler.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/relocationhandler.cpp b/relocationhandler.cpp index cda9bf0d..b077a82d 100644 --- a/relocationhandler.cpp +++ b/relocationhandler.cpp @@ -37,6 +37,7 @@ RelocationHandler::RelocationHandler() handler.freeObject = FreeCallback; handler.getRelocationInfo = GetRelocationInfoCallback; handler.applyRelocation = ApplyRelocationCallback; + handler.getOperandForExternalRelocation = GetOperandForExternalRelocationCallback; AddRefForRegistration(); m_object = BNCreateRelocationHandler(&handler); @@ -77,6 +78,16 @@ bool RelocationHandler::ApplyRelocationCallback(void* ctxt, BNBinaryView* view, } +size_t RelocationHandler::GetOperandForExternalRelocationCallback(void* ctxt, const uint8_t* data, uint64_t addr, + size_t length, BNLowLevelILFunction* il, BNRelocation* reloc) +{ + RelocationHandler* handler = (RelocationHandler*)ctxt; + Ref<LowLevelILFunction> func(new LowLevelILFunction(BNNewLowLevelILFunctionReference(il))); + Ref<Relocation> relocObj = new Relocation(BNNewRelocationReference(reloc)); + return handler->GetOperandForExternalRelocation(data, addr, length, func, relocObj); +} + + bool RelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, std::vector<BNRelocationInfo>& result) { (void)view; @@ -89,9 +100,18 @@ bool RelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture bool RelocationHandler::ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len) { - return BNRelocationHandlerDefaultApplyRelocation(m_object, view->GetObject(), arch->GetObject(), BNNewRelocationReference(reloc->GetObject()), dest, len); + return BNRelocationHandlerDefaultApplyRelocation(m_object, view->GetObject(), arch->GetObject(), + BNNewRelocationReference(reloc->GetObject()), dest, len); } + +size_t RelocationHandler::GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length, + Ref<LowLevelILFunction> il, Ref<Relocation> relocation) +{ + return BN_INVALID_OPERAND; +} + + CoreRelocationHandler::CoreRelocationHandler(BNRelocationHandler* handler) : RelocationHandler(handler) { } @@ -114,4 +134,12 @@ bool CoreRelocationHandler::GetRelocationInfo(Ref<BinaryView> view, Ref<Architec for (size_t i = 0; i < result.size(); i++) result[i] = results[i]; return status; +} + + +size_t CoreRelocationHandler::GetOperandForExternalRelocation(const uint8_t* data, uint64_t addr, size_t length, + Ref<LowLevelILFunction> il, Ref<Relocation> relocation) +{ + return BNRelocationHandlerGetOperandForExternalRelocation(m_object, data, addr, length, il->GetObject(), + relocation->GetObject()); }
\ No newline at end of file |
