Comments (2)
Currently this library only really supports UTF-8 (well, ASCII). You could take a look at the code if you want to give it a go yourself. Basically right now the library reads one byte at a time at the given memory address until it encounters a null terminator, and treats every byte it encounters as a char. If you know how UTF16 strings are stored in memory (specifically, what type of UTF16 you are targeting) you should be able to easily edit the method for how strings are read.
In JS the current method is basically just:
const chars = [];
let offset = 0x0;
while (true) {
const char = readMemory(handle, address + offset);
if (char === '\0') break; // null terminator, end of string
chars.push(char);
offset += 1; // size of 1 char
}
const string = chars.join('');
To read UTF16, it would most likely involve reading 2 bytes at a time instead of just one (but then processing those 2 bytes into 1 char, and it could be either little endian or big endian). I would happily implement support for more string types into the library, I am just not sure where to find a good resource as a basis (that defines all string types, how to determine the endianness, etc).
from memoryjs.
You can also use memoryjs.readBuffer to read a buffer if you know the size
ex
var buff = memoryjs.readBuffer(handle, address, 8*2)
var text = buff.toString("utf16le")
console.log(text)
8 here is the length of the string, and its 2 bytes per character (8*2)
you can switch utf16le with other supported formats
-
utf8
-
utf16le
-
latin1
-
base64
-
hex
-
ascii
-
binary
-
ucs2
In my case there is a byte in memory I am also reading that contains the length of the string so this works great for me. If you don't know the length you can read in 2 bytes at a time until you hit the term code for the implementation the program you are reading from uses. In my case it has a 0x00 0x00
at the end of the string.
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
- Idea: External thread trace
- 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.