MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / resolve_import

Function resolve_import

g2all/900/module/memtools.js:159–179  ·  view source on GitHub ↗
(import_addr)

Source from the content-addressed store, hash-verified

157}
158
159export function resolve_import(import_addr) {
160 if (import_addr.read16(0) !== 0x25ff) {
161 throw Error(
162 `instruction at ${import_addr} is not of the form: jmp qword`
163 + ' [rip + X]');
164 }
165 // module_function_import:
166 // jmp qword [rip + X]
167 // ff 25 xx xx xx xx // signed 32-bit displacement
168 const disp = import_addr.read32(2);
169 // assume disp and offset are 32-bit integers
170 // x | 0 will always be a signed integer
171 const offset = (disp | 0) + 6;
172 // The rIP value used by "jmp [rip + X]" instructions is actually the rIP
173 // of the next instruction. This means that the actual address used is
174 // [rip + X + sizeof(jmp_insn)], where sizeof(jmp_insn) is the size of the
175 // jump instruction, which is 6 in this case.
176 const function_addr = import_addr.readp(offset);
177
178 return function_addr;
179}
180
181export function init_syscall_array(
182 syscall_array,

Callers 4

dump_libkernelFunction · 0.90
dump_libcFunction · 0.90
get_basesFunction · 0.90
get_basesFunction · 0.90

Calls 3

read16Method · 0.45
read32Method · 0.45
readpMethod · 0.45

Tested by

no test coverage detected