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

Class KernelMemory

g2all/700/lapse.js:1386–1497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1384 // we corrupt that instead for arbitrary read/write. pipe.pipe_map will be
1385 // clobbered with zeros but that's okay
1386 class KernelMemory {
1387 constructor(main_sd, worker_sd, pipes, pipe_addr) {
1388 this.main_sd = main_sd;
1389 this.worker_sd = worker_sd;
1390 this.rpipe = pipes[0];
1391 this.wpipe = pipes[1];
1392 this.pipe_addr = pipe_addr; // &pipe.pipe_buf
1393 this.pipe_addr2 = pipe_addr.add(0x10); // &pipe.pipe_buf.buffer
1394 this.rw_buf = new Buffer(0x14);
1395 this.addr_buf = new Buffer(0x14);
1396 this.data_buf = new Buffer(0x14);
1397 this.data_buf.write32(0xc, 0x40000000);
1398 }
1399
1400 _verify_len(len) {
1401 if (!(Number.isInteger(len) && 0 <= len <= 0xffffffff)) {
1402 throw TypeError("len not a 32-bit unsigned integer");
1403 }
1404 }
1405
1406 copyin(src, dst, len) {
1407 this._verify_len(len);
1408 const main = this.main_sd;
1409 const worker = this.worker_sd;
1410 const addr_buf = this.addr_buf;
1411 const data_buf = this.data_buf;
1412
1413 addr_buf.write64(0, this.pipe_addr);
1414 ssockopt(main, IPPROTO_IPV6, IPV6_PKTINFO, addr_buf);
1415
1416 data_buf.write64(0, 0);
1417 ssockopt(worker, IPPROTO_IPV6, IPV6_PKTINFO, data_buf);
1418
1419 addr_buf.write64(0, this.pipe_addr2);
1420 ssockopt(main, IPPROTO_IPV6, IPV6_PKTINFO, addr_buf);
1421
1422 addr_buf.write64(0, dst);
1423 ssockopt(worker, IPPROTO_IPV6, IPV6_PKTINFO, addr_buf);
1424
1425 sysi("write", this.wpipe, src, len);
1426 }
1427
1428 copyout(src, dst, len) {
1429 this._verify_len(len);
1430 const main = this.main_sd;
1431 const worker = this.worker_sd;
1432 const addr_buf = this.addr_buf;
1433 const data_buf = this.data_buf;
1434
1435 addr_buf.write64(0, this.pipe_addr);
1436 ssockopt(main, IPPROTO_IPV6, IPV6_PKTINFO, addr_buf);
1437
1438 data_buf.write32(0, 0x40000000);
1439 ssockopt(worker, IPPROTO_IPV6, IPV6_PKTINFO, data_buf);
1440
1441 addr_buf.write64(0, this.pipe_addr2);
1442 ssockopt(main, IPPROTO_IPV6, IPV6_PKTINFO, addr_buf);
1443

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected