MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ReadFunctionTable

Method ReadFunctionTable

view/sharedcache/core/MachO.cpp:9–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace BinaryNinja;
8
9std::vector<uint64_t> SharedCacheMachOHeader::ReadFunctionTable(VirtualMemory& vm) const
10{
11 // NOTE: The funcoff is relative to the file of the linkedit segment.
12 uint64_t funcStartsAddress = GetLinkEditFileBase() + functionStarts.funcoff;
13 auto funcStarts = vm.ReadBuffer(funcStartsAddress, functionStarts.funcsize);
14 uint64_t curfunc = textBase;
15 uint64_t curOffset = 0;
16
17 std::vector<uint64_t> functionTable = {};
18 auto current = static_cast<const uint8_t*>(funcStarts.GetData());
19 auto end = current + funcStarts.GetLength();
20 while (current != end)
21 {
22 curOffset = readLEB128(current, end);
23 // TODO: Verify this is the correct behavior.
24 // Skip unmapped functions.
25 if (curOffset == 0 || !vm.IsAddressMapped(curfunc))
26 continue;
27 curfunc += curOffset;
28 uint64_t target = curfunc;
29 functionTable.push_back(target);
30 }
31 return functionTable;
32}
33
34std::optional<SharedCacheMachOHeader> SharedCacheMachOHeader::ParseHeaderForAddress(
35 std::shared_ptr<VirtualMemory> vm, uint64_t address, const std::string& imagePath)

Callers 1

ApplyHeaderMethod · 0.80

Calls 6

IsAddressMappedMethod · 0.80
push_backMethod · 0.80
readLEB128Function · 0.70
ReadBufferMethod · 0.45
GetDataMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected