diff options
| author | spv420 <spv@spv.sh> | 2022-08-01 00:17:01 -0400 |
|---|---|---|
| committer | spv420 <spv@spv.sh> | 2022-08-01 00:17:01 -0400 |
| commit | b7e55484bed9438c470e8f4e011d3d3a7e131960 (patch) | |
| tree | 69095ff92a7ef4e340c93e055370b0c3238bf35d /src/stage4/lib | |
| parent | 919024c399a2affae5d9271a93a83fb6cd8e3986 (diff) | |
fuck
Diffstat (limited to 'src/stage4/lib')
| -rw-r--r-- | src/stage4/lib/mach.js | 6 | ||||
| -rw-r--r-- | src/stage4/lib/native_ptr.js | 51 | ||||
| -rw-r--r-- | src/stage4/lib/str.js | 9 |
3 files changed, 60 insertions, 6 deletions
diff --git a/src/stage4/lib/mach.js b/src/stage4/lib/mach.js new file mode 100644 index 0000000..d9e6b6a --- /dev/null +++ b/src/stage4/lib/mach.js @@ -0,0 +1,6 @@ +function MACH_MSGH_BITS(remote, local) { + return ((remote) | ((local) << 8)); +} + +var MACH_MSGH_BITS_COMPLEX = 0x80000000; +var MACH_MSG_TYPE_MAKE_SEND_ONCE = 21;
\ No newline at end of file diff --git a/src/stage4/lib/native_ptr.js b/src/stage4/lib/native_ptr.js index aa79130..1ae7644 100644 --- a/src/stage4/lib/native_ptr.js +++ b/src/stage4/lib/native_ptr.js @@ -5,8 +5,6 @@ class native_ptr { this.count = arguments[0]; var our_proto = Object.getPrototypeOf(this); - p0laris_log(JSON.stringify(Object.getPrototypeOf(this))); - if (our_proto.predef == true) { this.size = our_proto.size; this.buf_to_obj = our_proto.buf_to_obj; @@ -44,6 +42,8 @@ class native_ptr { n = 0; } + var buf_yahtzee = read_buf(this.addy + (n * this.size), this.size); + return this.buf_to_obj(read_buf(this.addy + (n * this.size), this.size)); } @@ -140,6 +140,20 @@ function u32xn_to_u8xn(buf) { return ret; } +function u8xn_to_u32xn(buf) { + var ret = new Uint32Array(buf.length >>> 2); + + for (var i = 0; i < buf.length; i += 4) { + var tmp = [buf[(i) + 0], + buf[(i) + 1], + buf[(i) + 2], + buf[(i) + 3]]; + ret[i >> 2] = u8x4_to_u32(tmp); + } + + return ret; +} + /* typedef struct{ mach_msg_bits_t msgh_bits; @@ -151,13 +165,38 @@ typedef struct{ } mach_msg_header_t; */ function mach_msg_header_t_buf_to_obj(buf) { - var ret = new Uint8Array(24); + var arr = u8xn_to_u32xn(buf); + var ret = {}; + + ret.msgh_bits = arr[0]; + ret.msgh_size = arr[1]; + ret.msgh_remote_port = arr[2]; + ret.msgh_local_port = arr[3]; + ret.msgh_voucher_port = arr[4]; + ret.msgh_id = arr[5]; + + return ret; } -function Request_sp_buf_to_obj(buf) { +function mach_msg_header_t_obj_to_buf(obj) { + var arr = [obj.msgh_bits, + obj.msgh_size, + obj.msgh_remote_port, + obj.msgh_local_port, + obj.msgh_voucher_port, + obj.msgh_id]; + var ret = u32xn_to_u8xn(arr); + return ret; +} + +function Request_sp_buf_to_obj(buf) { +// var arr = [buf.msg] } +var mach_msg_header_t = native_ptr_type(24, + mach_msg_header_t_buf_to_obj, + mach_msg_header_t_obj_to_buf); var mach_msg_ool_ports_descriptor_t = native_ptr_type(12, - mach_msg_ool_ports_descriptor_t_buf_to_obj, - mach_msg_ool_ports_descriptor_t_obj_to_buf);
\ No newline at end of file + mach_msg_ool_ports_descriptor_t_buf_to_obj, + mach_msg_ool_ports_descriptor_t_obj_to_buf);
\ No newline at end of file diff --git a/src/stage4/lib/str.js b/src/stage4/lib/str.js new file mode 100644 index 0000000..3d543a0 --- /dev/null +++ b/src/stage4/lib/str.js @@ -0,0 +1,9 @@ +function dump_u32xn(buf) { + var s = ""; + + for (var i = 0; i < buf.length; i++) { + s += pad_left(buf[i].toString(16), "0", 8); + } + + return s; +}
\ No newline at end of file |
