Rob-- / memoryjs

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

Sync readmemory not working #25

Closed p410n3 closed 6 years ago

p410n3 commented 6 years ago
X:\Dokumente\p410n3.JS\node_modules\memoryjs\index.js:64
    memoryjs.readMemory(handle, address, dataType.toLowerCase(), callback);
             ^

TypeError: fourth argument must be a function
    at Object.readMemory (X:\Dokumente\p410n3.JS\node_modules\memoryjs\index.js:
64:14)
    at Object.<anonymous> (X:\Dokumente\p410n3.JS\node_modules\memoryjs\example1
.js:86:61)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
p410n3 commented 6 years ago

https://github.com/p410n3/memoryjs/commit/da1c08f46c7bbb536580fc3d05f7c878674db449

p410n3 commented 6 years ago

Here some more in depth explanation:

The module exports either the async or the synchronous version of the readmemory function here in the index.js of memoryJS:

readMemory(handle, address, dataType, callback) {
  if (arguments.length === 2) {
    return memoryjs.readMemory(handle, address, dataType.toLowerCase());
  }
  memoryjs.readMemory(handle, address, dataType.toLowerCase(), callback);
},

The error is here: if (arguments.length === 2) The previous version of memoryJS used only two arguments for the sync function and 3 for the async. So the 2 needs to be a 3, because it assumes I am trying to call the async function, which I am not.

And as you see, without my fix the examples inside the modules throws errors too.

at Object.<anonymous> (X:\Dokumente\p410n3.JS\node_modules\memoryjs\example1.js:86:61) Given that, I know its an error in memoryJS.

You can confirm this by installing memoryJS and then doing:

cd ./node_modules/memoryjs
node example1.js
LiamKarlMitchell commented 6 years ago

Confirming, needs to be === 3

p410n3 commented 6 years ago

I added a fix for findpattern too. Same problem

EDIT: Its in the pull req I made btw

p410n3 commented 6 years ago

Fixed in https://github.com/Rob--/memoryjs/pull/24