summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/lib/myutils.js35
-rw-r--r--src/js/main.js13
-rw-r--r--src/js/primitives/call.js4
3 files changed, 42 insertions, 10 deletions
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
diff --git a/src/js/main.js b/src/js/main.js
index 410b588..4c5ca98 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -8,8 +8,9 @@
var MAX_SLIDE = 0x3;
var MIN_SLIDE = 0x1;
-var ARM_THREAD_STATE = 0x1;
var ARM_THREAD_STATE_COUNT = 0x11;
+var ARM_THREAD_STATE = 0x1;
+var LOG_SYSLOG = 0x28;
try {
puts("we out here in jsc");
@@ -45,16 +46,10 @@ function main() {
printf("*(uint16_t*)base = 0x%x\n", read_u16(base));
printf("*(uint32_t*)base = 0x%x\n", read_u32(base));
- 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) {
- calls4arg("syslog", 0x28, sptr("get rekt from jsc %d (slide=%x)\n"), i, slide);
- calls4arg("sleep", 1, 0, 0, 0);
+ syslog(LOG_SYSLOG, "get rekt from jsc %d (slide=%x)\n", i, slide);
+ sleep(1);
i++;
}
diff --git a/src/js/primitives/call.js b/src/js/primitives/call.js
index 92d7d09..48fe8ae 100644
--- a/src/js/primitives/call.js
+++ b/src/js/primitives/call.js
@@ -196,6 +196,7 @@ function callnarg() {
* probably un-necessary now, keeping in just in case for now
*/
calls4arg("thread_resume", read_u32(th), 0, 0, 0);
+ calls4arg("usleep", 10000, 0, 0, 0);
/*
* spin wait for return
@@ -215,7 +216,8 @@ function callnarg() {
calls4arg("thread_suspend", read_u32(th), 0, 0, 0);
return read_u32(thread_state);
}
- calls4arg("usleep", 1000, 0, 0, 0);
+
+ calls4arg("usleep", 10000, 0, 0, 0);
}
}