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

Method ReadExportNode

view/kernelcache/core/KernelCache.cpp:1795–1859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1793
1794
1795void KernelCache::ReadExportNode(Ref<BinaryView> view, std::vector<Ref<Symbol>>& symbolList, KernelCacheMachOHeader& header, DataBuffer& buffer, uint64_t textBase,
1796 const std::string& currentText, size_t cursor, uint32_t endGuard)
1797{
1798
1799 if (cursor > endGuard)
1800 throw ReadException();
1801
1802 uint64_t terminalSize = readValidULEB128(buffer, cursor);
1803 uint64_t childOffset = cursor + terminalSize;
1804 if (terminalSize != 0) {
1805 uint64_t imageOffset = 0;
1806 uint64_t flags = readValidULEB128(buffer, cursor);
1807 if (!(flags & EXPORT_SYMBOL_FLAGS_REEXPORT))
1808 {
1809 imageOffset = readValidULEB128(buffer, cursor);
1810 // auto symbolType = view->GetAnalysisFunctionsForAddress(textBase + imageOffset).size() ? FunctionSymbol : DataSymbol;
1811 {
1812 if (!currentText.empty() && textBase + imageOffset)
1813 {
1814 uint32_t sectionFlags;
1815 BNSymbolType type;
1816 for (auto s : header.sections)
1817 {
1818 if (s.addr < textBase + imageOffset)
1819 {
1820 if (s.addr + s.size > textBase + imageOffset)
1821 {
1822 sectionFlags = s.flags;
1823 }
1824 }
1825 }
1826 if ((sectionFlags & S_ATTR_PURE_INSTRUCTIONS) == S_ATTR_PURE_INSTRUCTIONS
1827 || (sectionFlags & S_ATTR_SOME_INSTRUCTIONS) == S_ATTR_SOME_INSTRUCTIONS)
1828 type = FunctionSymbol;
1829 else
1830 type = DataSymbol;
1831
1832#if EXPORT_TRIE_DEBUG
1833 // BNLogInfo("export: %s -> 0x%llx", n.text.c_str(), image.baseAddress + n.offset);
1834#endif
1835 auto sym = new Symbol(type, currentText, textBase + imageOffset);
1836 symbolList.push_back(sym);
1837 }
1838 }
1839 }
1840 }
1841 cursor = childOffset;
1842 uint8_t childCount = buffer[cursor];
1843 cursor++;
1844 if (cursor > endGuard)
1845 throw ReadException();
1846 for (uint8_t i = 0; i < childCount; ++i)
1847 {
1848 std::string childText;
1849 while (buffer[cursor] != 0 & cursor <= endGuard)
1850 childText.push_back(buffer[cursor++]);
1851 cursor++;
1852 if (cursor > endGuard)

Callers

nothing calls this directly

Calls 4

ReadExceptionClass · 0.85
push_backMethod · 0.80
readValidULEB128Function · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected