From 202fff8a0da664f8aa4e03e9e9e11fe0b8d87199 Mon Sep 17 00:00:00 2001 From: spv420 Date: Sun, 24 Apr 2022 07:27:47 -0400 Subject: yeet --- src/js/lib/myutils.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/js/lib') diff --git a/src/js/lib/myutils.js b/src/js/lib/myutils.js index 08ba89e..0106402 100644 --- a/src/js/lib/myutils.js +++ b/src/js/lib/myutils.js @@ -25,4 +25,39 @@ function printf() { } return calls4arg.apply(this, args_to_pass); +} + +function syslog() { + if (arguments.length > 4) { + return printf("warning: tried to printf with %d args, max %d.\n", arguments.length, 4); + } + + var args_to_pass = new Array(); + + sym = "syslog"; + + 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; + } + + args_to_pass.push(addy); + + for (var i = 0; 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); +} + +function sleep(t) { + return calls4arg("sleep", t, 0, 0, 0); } \ No newline at end of file -- cgit v1.2.3