Last active
November 11, 2022 00:28
-
-
Save jabyrd3/2dff8b4296834da6d6939880b1a3d347 to your computer and use it in GitHub Desktop.
read raw mem given pid and start/end range nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {open, read} from 'fs'; | |
export default (pid, rawStart, rawEnd) => { | |
return new Promise((res, rej) => { | |
// 4d674600000-4d674640000 rw-p 00000000 00:00 0 | |
const start = parseInt(`0x${rawStart}`, 16); | |
const end = parseInt(`0x${rawEnd}`, 16); | |
const length = end - start; | |
const buffer = Buffer.alloc(length); | |
open(`/proc/${pid}/mem`, 'r', (err, fd) => { | |
read(fd, buffer, 0, length, start, (err, bytesRead, buffer) => { | |
res(buffer); | |
}); | |
}); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment