Rob-- / memoryjs

Read and write process memory in Node.js (Windows API functions exposed via Node bindings)
MIT License
632 stars 86 forks source link

Just pushed a commit (3be70b051025327db5d5f54cd5a1f777dea75943) that I think should enable this now (not on NPM yet). I wasn't familiar with memory mapped files before working on this change, but from my little testing it seems like you should be able to replicate this C# logic with memoryjs now. Updated the README with an example ([documentation](https://github.com/Rob--/memoryjs#memory-mapped-files-1)). #108

Closed staceywhitmore-inl closed 1 year ago

staceywhitmore-inl commented 1 year ago
          Just pushed a commit (3be70b051025327db5d5f54cd5a1f777dea75943) that I think should enable this now (not on NPM yet). I wasn't familiar with memory mapped files before working on this change, but from my little testing it seems like you should be able to replicate this C# logic with memoryjs now. Updated the README with an example ([documentation](https://github.com/Rob--/memoryjs#memory-mapped-files-1)).

To achieve what you want, this should work:

const processObject = memoryjs.openProcess("example.exe");
const fileHandle = memoryjs.openFileMapping("MappedFooFile");

const baseAddress = memoryjs.mapViewOfFile(processObject.handle, fileHandle.handle, 0, 8, memoryjs.PAGE_READONLY);
const ask = memoryjs.readMemory(processObject.handle, baseAddress, memoryjs.DOUBLE);

This will map the first 8 bytes (size of double) of the memory mapped file to your target process memory and return the address. You just need to read the double at this address now to get the ASK value.

Originally posted by @Rob-- in https://github.com/Rob--/memoryjs/issues/101#issuecomment-1318070180

staceywhitmore-inl commented 1 year ago

When I try this I receive the following error: TypeError: memoryjs.openFileMapping is not a function When I looked the src code in node_modules I couldn't find any occurrence of the method openFileMapping(). Am I missing a step?

Rob-- commented 1 year ago

This change is not yet published to NPM. If you need this functionality, you can pull this repository directly. I'll publish it to NPM soon.