Comments (7)
Note: I'm happy to implement this should I need it, will see how I go.
from memoryjs.
Do I understand it correctly that this would allow me to read/write generic structs from and to memory just like the vector types?
If this is the case I would very much like to see this in a future version, as it's exactly what I'm gonna need for a project of mine.
from memoryjs.
Yes. I think he already did it if I understood his email correctly.
from memoryjs.
@LiamKarlMitchell to write generic structs to memory we could always just create a helper function inside the library?
// Method 1: the `value` arg contains the details (if struct data type varies):
const vector = [{
type: memoryjs.FLOAT,
data: 1.23,
}, {
type: memoryjs.FLOAT,
data: 4.56,
}, {
type: memoryjs.INT,
data: 420,
}];
memoryjs.writeMemory(handle, address, vector);
// Method 2: if struct data type doesn't vary:
const vector = [1.23, 4.56, 7.89];
memoryjs.writeMemory(handle, address, vector, memoryjs.FLOAT);
And inside writeMemory we do a check to see if the value
is an object, in which case we know it's a struct and iterate over the array:
let offset = 0x0;
value.forEach(({ type, data }) => {
memoryjs.writeMemory(handle, address + offset, data, type.toLowerCase());
if (type === memoryjs.FLOAT) offset += 0x4;
// etc, offset could be optionally defined by the `value` param
});
Another solution is to just use a library like node-struct and let people manually form an actual buffer themselves and then we can just write that to memory directly. I don't know too much about buffers so just let me know if I'm overthinking here or if there's a simpler solution!
from memoryjs.
You could yes.
I've used concentrate and dissolve modules for a project in the past.
https://github.com/deoxxa/concentrate
Found it easier to add own/new data types to them.
Also made a script to turn .h struct into .js files which made it easy :)
from memoryjs.
v.3.1.0: reading/writing of buffers added in c009eed
For information about writing or reading structures, refer to the generic structures section of the readme.
Functions added:
readBuffer(handle, address, size[, callback])
writeBuffer(handle, address, buffer)
@LiamKarlMitchell I've added a buffer read/write example here. Hopefully this is what you and @PostCrafter were looking for!
If you're happy to share your script here I'm sure others would find it useful :)
from memoryjs.
Great stuff thanks @Rob--
from memoryjs.
Related Issues (20)
- How to read shared memory channel? (Windows) HOT 5
- Reading an address that is a BigInt throwing errors? HOT 3
- The library can't read memory for me can someone help me figure it out? HOT 2
-
- Any way to get module exports? HOT 2
- Add "Windows only" to readme HOT 2
- Usage with electron HOT 2
- 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)). HOT 2
- Error reading BigInt pointer HOT 6
- Feature: Open process using th32ProcessID instead of process name(multiple processes same name) HOT 2
- functionTest.cpp does not work on x64 builds HOT 1
- Using Cheat Engine Pointer HOT 6
- Writing to an adres using pointers HOT 2
- Little Endian Support HOT 3
- add pointer or int64 parameters on callFunction?
- publish/release newest version to npm? :) HOT 2
- Linux/Unix support HOT 2
- setProtection is not available in latest version HOT 1
- Problems when using with electron. HOT 1
- Hi Rob, HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memoryjs.