diff options
| author | spv420 <unomilliono@gmail.com> | 2022-04-24 07:20:06 -0400 |
|---|---|---|
| committer | spv420 <unomilliono@gmail.com> | 2022-04-24 07:20:06 -0400 |
| commit | 7fdce8d27df9fa1288238c4829961f1e97f71c31 (patch) | |
| tree | 55341eb727e7c4167716da5e1098d64149dc3435 | |
| parent | 3c408adb44ba743dee19ed8cf101bf687e6cf84c (diff) | |
yeet
| -rw-r--r-- | src/js/main.js | 12 | ||||
| -rw-r--r-- | src/js/primitives/call.js | 37 |
2 files changed, 41 insertions, 8 deletions
diff --git a/src/js/main.js b/src/js/main.js index 4028ed6..410b588 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -37,8 +37,6 @@ function main() { init_sptr_heap(); -// var i = 0; - puts("we out here"); puts("I came through a portal holding a 40 and a blunt. Do you really wanna test me right now?"); @@ -47,11 +45,11 @@ function main() { printf("*(uint16_t*)base = 0x%x\n", read_u16(base)); printf("*(uint32_t*)base = 0x%x\n", read_u32(base)); - callnarg(sym_cache["printf"], sptr("Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n"), 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); - callnarg(sym_cache["printf"], sptr("Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n"), 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); - callnarg(sym_cache["printf"], sptr("Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n"), 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); - callnarg(sym_cache["printf"], sptr("Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n"), 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); - callnarg(sym_cache["printf"], sptr("Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n"), 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); + scall("printf", "Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n", 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); + scall("printf", "Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n", 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); + scall("printf", "Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n", 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); + scall("printf", "Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n", 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); + scall("printf", "Hello world! %x %x %x %x %x %x %x %x %x %x %x %x %x\n", 0x420, 0x69, 0x1337, 0x13371337, 0xb1a7e17, 0x41424344); var i = 0; while (true) { diff --git a/src/js/primitives/call.js b/src/js/primitives/call.js index 49a9e79..92d7d09 100644 --- a/src/js/primitives/call.js +++ b/src/js/primitives/call.js @@ -219,6 +219,41 @@ function callnarg() { } } -function callsnarg() { +/* + * call with symbol + */ +function scall() { + /* + * this calls dlsym with the first arg, then uses the address it returns + * to call. so you can call with a symbol name instead of an address + */ + + if (arguments.length < 1) { + return printf("warning: scall called without args. arguments.length=%d\n", arguments.length); + } + + var sym = arguments[0]; + + if (sym in sym_cache) { + var addy = sym_cache[sym]; + } else { + var dlsym_addy = read_u32(reserve_addr + 24 + slid); + var shc_slide = read_u32(reserve_addr + 20 + slid); + var addy = call4arg(dlsym_addy + shc_slide, 0xfffffffe, sptr(sym), 0, 0); + sym_cache[sym] = addy; + } + + var args_to_pass = new Array(); + + args_to_pass.push(addy); + + for (var i = 1; i < arguments.length; i++) { + if (arguments[i].constructor === String) { + args_to_pass.push(sptr(arguments[i])); + } else { + args_to_pass.push(arguments[i]); + } + } + return callnarg.apply(this, args_to_pass); }
\ No newline at end of file |
