Comments (16)
I found why bug happen.
In memory.h, the type of the second parameter is DWORD instead of DWORD64.
It's why we cant pass number that is bigger than 32bits uint maximum value.
I fix it by replacing DWORD to DWORD64.
But we have another problem, in memoryjs.cc line 348, we get function argument with args[0]->Uint32Value()
method, this break number that is bigger than 4294967295.
I'm not native C programmer so i quickfix that by adding 4294967296 to args[0]->Uint32Value()
int result = Memory.readMemory<int>(process::hProcess, 4294967296 + args[0]->Uint32Value());
This way i can handle 64 bits memory address
from memoryjs.
#14 Should help fix this?
from memoryjs.
Was there a better type to use that was sized depending on what it's compiled for.
DWORD_PTR or was it LPVOID but would need a way to transmit the x64 numbers through to native?
Is there really no Uint64Value methods?
Seems not... https://bugs.chromium.org/p/v8/issues/detail?id=1339
Mozilla have a draft idea on this though. https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes/js-ctypes_reference/UInt64
We could pass parameters with buffers.
https://community.risingstack.com/using-buffers-node-js-c-plus-plus/
Or have the wrapper function pass an extra argument to flag it as an x64address then just internally in the native add the amount or subtract the amount.
Or by use of another module?
https://github.com/candu/node-int64-native
ffi gets around it by returning strings as double-precision floating point numbers are imprecise.
https://www.npmjs.com/package/ffi#v8-and-64-bit-types
A solution could also take into consideration if the methods should work with other architecture.
Undocumented methods also exist to read/write x64 from x86 but seems hacky....
from memoryjs.
I found out that uintptr_t is only part of the answer. https://github.com/Rob--/memoryjs/pull/14
After changing Uint32Value() to IntegerValue() in readMemory and DWORD to DWORD64 for the base address it was possible to get the correct values in 64 bit programs for pointers as well as for values.
from memoryjs.
You can see the changes in 3792f5d
from memoryjs.
@karlrobertjanicki awesome, it seems as though IntegerValue is the solution for 64 bit integers:
V8EXPORT uint32_t v8::Value::Uint32Value() const;
V8EXPORT int64_t v8::Value::IntegerValue() const;
In your fork you don't replace all instances of Uint32Value()
with IntegerValue()
though? Any time an address is passed from the Node.js user space to the add-on we should use IntegerValue()
to access it. I will look into updating the library soon with the relevant fixes.
Thanks!
from memoryjs.
I didn't replace all the instances of Uint32Value() with IntegerValue() because I only used pointer, float and dword. Long story short: because of laziness ;)
from memoryjs.
@karlrobertjanicki added in 646eb28.
Hopefully the library will be much more 64 bit compatible. Soon I will add explicit types such as int32_t
, uint32_t
and int64_t
. Right now, the library's int
type is simply int32_t
.
Also, there is no support for getting type uint64_t
from v8::Value (but there is support for int64_t
). One solution I've seen for this is getting the double value (NumberValue()
) and casting it to uint64_t
.
from memoryjs.
Closing for now, if there is still problems with 64 bit compatibility I will reopen the issue!
from memoryjs.
Thank you
from memoryjs.
One more thing. I think that the base address is only correct in 64 Bit addresses with:
https://github.com/karlrobertjanicki/memoryjs/blob/3792f5d44f465c09ce2d12f098d1eba26ed73fe5/lib/memoryjs.cc#L107
and
https://github.com/karlrobertjanicki/memoryjs/blob/3792f5d44f465c09ce2d12f098d1eba26ed73fe5/lib/module.cc#L17
DWORD64 did the trick.
from memoryjs.
@karlrobertjanicki addressed in abc9ee0.
from memoryjs.
Perfect :)
from memoryjs.
I have used memoryjs in a project. You can see the results on youtube
https://www.youtube.com/watch?v=gNiegwbILPg
from memoryjs.
@karlrobertjanicki Interesting project and awesome video!
from memoryjs.
Thank you. Without memoryjs this would not be possible. Awesome work
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.