MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / getAddressMap

Function getAddressMap

KittyMemoryEx/KittyMemoryEx.cpp:346–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344 }
345
346 ProcMap getAddressMap(pid_t pid, uintptr_t address, const std::vector<ProcMap> &maps)
347 {
348 if (!address)
349 return {};
350
351 address = KittyUtils::untagHeepPtr(address);
352
353 if (!maps.empty())
354 {
355 auto it = std::lower_bound(maps.begin(), maps.end(), address, [](const ProcMap &m, uintptr_t val) {
356 return m.endAddress <= val;
357 });
358
359 if (it != maps.end() && address >= it->startAddress && address < it->endAddress)
360 {
361 return *it;
362 }
363 }
364 else
365 {
366 auto pmaps = getAllMaps(pid);
367 auto it = std::lower_bound(pmaps.begin(), pmaps.end(), address, [](const ProcMap &m, uintptr_t val) {
368 return m.endAddress <= val;
369 });
370
371 if (it != pmaps.end() && address >= it->startAddress && address < it->endAddress)
372 {
373 return *it;
374 }
375 }
376
377 return {};
378 }
379
380#ifdef __ANDROID__
381 std::string getAppDirectory(const std::string &pkg)

Callers 10

_callFunctionFromMethod · 0.85
_callSyscallMethod · 0.85
ElfScannerMethod · 0.85
getAllELFsMethod · 0.85
findRemoteSymbolMethod · 0.85
initMethod · 0.85
allSoInfoMethod · 0.85
infoFromSoInfo_Method · 0.85

Calls 3

untagHeepPtrFunction · 0.85
getAllMapsFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected