MCPcopy Create free account
hub / github.com/axhlzy/FridaDebugger / resolve

Function resolve

scripts/function-stalker.js:86–114  ·  view source on GitHub ↗
(addr)

Source from the content-addressed store, hash-verified

84})();
85
86function resolve(addr) {
87 if (!addr || addr.isNull()) return { lib: null, text: "(null)" };
88 const key = addr.toString();
89 const hit = symCache.get(key);
90 if (hit) return hit;
91 let out = { lib: null, text: key };
92 if (dladdr) {
93 try {
94 if (dladdr(addr, dlInfo) !== 0) {
95 const fname = dlInfo.readPointer();
96 const fbase = dlInfo.add(8).readPointer();
97 const sname = dlInfo.add(16).readPointer();
98 const saddr = dlInfo.add(24).readPointer();
99 const lib = fname.isNull() ? null : (fname.readCString() || "").split("/").pop();
100 let text;
101 if (!sname.isNull()) {
102 const nm = sname.readCString();
103 const off = addr.sub(saddr);
104 text = off.compare(0) === 0 ? `${nm} @ ${lib}` : `${nm}+0x${off.toString(16)} @ ${lib}`;
105 } else if (lib) {
106 text = `${lib}+0x${addr.sub(fbase).toString(16)}`;
107 } else { text = key; }
108 out = { lib, text };
109 }
110 } catch (e) {}
111 }
112 symCache.set(key, out);
113 return out;
114}
115
116// --- resolve a target string to an absolute address -------------------------
117// "mod+0xoff" | "0xoff@mod" | "0xabs" | "symbolName"

Callers 4

excludeAllButTargetsOnceFunction · 0.70
symFunction · 0.70
formatEventFunction · 0.70
installFunction · 0.70

Calls 1

addMethod · 0.80

Tested by

no test coverage detected