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

Class Reader

g2all/900/psfree.js:308–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308class Reader {
309 constructor(rstr, rstr_view) {
310 this.rstr = rstr;
311 this.rstr_view = rstr_view;
312 this.m_data = rstr_view.read64(off.strimpl_m_data);
313 }
314
315 read8_at(offset) {
316 const str = this.rstr;
317 return str.charCodeAt(offset) >>> 0;
318 }
319
320 read32_at(offset) {
321 const str = this.rstr;
322 return (
323 str.charCodeAt(offset)
324 | str.charCodeAt(offset + 1) << 8
325 | str.charCodeAt(offset + 2) << 16
326 | str.charCodeAt(offset + 3) << 24
327 ) >>> 0;
328 }
329
330 read64_at(offset) {
331 return sread64(this.rstr, offset);
332 }
333
334 read64(addr) {
335 this.rstr_view.write64(off.strimpl_m_data, addr);
336 return sread64(this.rstr, 0);
337 }
338
339 set_addr(addr) {
340 this.rstr_view.write64(off.strimpl_m_data, addr);
341 }
342
343 // remember to use this to fix up the StringImpl before freeing it
344 restore() {
345 this.rstr_view.write64(off.strimpl_m_data, this.m_data);
346 this.rstr_view.write32(off.strimpl_strlen, original_strlen);
347 }
348}
349
350// we now have a double free on the fastMalloc heap
351async function make_rdr(view) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected