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

Function resolve_import

g2all/700/module/memtools.js:154–172  ·  view source on GitHub ↗
(import_addr)

Source from the content-addressed store, hash-verified

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

Callers 6

dump_libkernelFunction · 0.90
dump_libcFunction · 0.90
get_basesFunction · 0.90
get_basesFunction · 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