Node add-on for memory reading and writing! (finally!)
- open a process
- close the process (handle)
- list all open processes
- list all modules associated with a process
- find a certain module associated with a process
- read memory
- write to memory
TODO:
- pattern scanning
This is a Node add-on (for v0.12.x) and therefore requires node-gyp to use.
You may also need to follow these steps.
npm install memoryjs
For a complete example, view index.js.
Initialise:
varmemoryjs=require('memoryjs');varprocessName="chrome.exe";Open a process (sync):
varprocessObject=memoryjs.openProcess(processName);Open a process (async):
memoryjs.openProcess(processName,function(err,processObject){});Get all processes (sync):
varprocesses=memoryjs.getProcesses();Get all processes (async):
memoryjs.getProcesses(function(err,processes){});See the Documentation section of this README to see what a process object looks like.
Find a module (sync):
varmodule=memoryjs.findModule(moduleName,processId);Find a module (async):
memoryjs.findModule(moduleName,processId,function(err,module){});Get all modules (sync):
varmodules=memoryjs.getModules(processId);Get all modules (async):
memoryjs.getModules(processId,function(err,modules){});See the Documentation section of this README to see what a module object looks like.
Read from memory (sync):
memoryjs.readMemory(address,dataType);Read from memory (async):
memoryjs.readMemory(address,dataType,function(err,result){});Write to memory:
memoryjs.writeMemory(address,value,dataType);See the Documentation section of this README to see what values dataType can be.
Process object:
{cntThreads: 47,szExeFile: "csgo.exe",th32ProcessID: 10316,th32ParentProcessID: 7804,pcPriClassBase: 8}Module object:
{modBaseAddr: 468123648,modBaseSize: 80302080,szExePath: 'c:\\program files (x86)\\steam\\steamapps\\common\\counter-strike global offensive\\csgo\\bin\\client.dll',szModule: 'client.dll',th32ProcessID: 10316}When using the write or read functions, the data type parameter must be a string and be one of the following:
"int", "dword", "long", "float", "double", "bool", "boolean", "str", "string"
This is simply used to denote the type of data being read or written.
opens a process to be able to read from and write to it
- processName(string) - the name of the process to open
- callback(function) - has two parameters:
- err(string) - error message (empty if there were no errors)
- processObject(JSON [process object]) - information about the process
returnsprocess object (JSON) either directly or via the callback
closes the handle on the opened process
collects information about all the running processes
- callback(function) - has two parameters:
- err(string) - error message (empty if there were no errors)
- processes(array) - array of process object (JSON)
returns an array of process object (JSON) for all the running processes
finds a module associated with a given process
- moduleName(string) - the name of the module to find
- processId(int) - the id of the process in which to find the module
- callback(function) - has two parameters:
- err(string) - error message (empty if there were no errors)
- module(JSON [module object]) - information about the module
returnsmodule object (JSON) either directly or via the callback
gets all modules associated with a given process
- processId(int) - the id of the process in which to find the module
- callback(function) - has two parameters:
- err(string) - error message (empty if there were no errors)
- modules(array) - array of module object (JSON)
returns an array of module object (JSON) for all the modules found
reads the memory at a given address
- address(int) - the address in memory to read from
- dataType(string) - the data type to read into (definitions can be found at the top of this section)
- callback(function) - has two parameters:
- err(string) - error message (empty if there were no errors)
- value(any data type) - the value stored at the given address in memory
returns the value that has been read from memory
writes to an address in memory
- address(int) - the address in memory to write to
- value(any data type) - the data type of value must be either
number,stringorbooleanand is the value that will be written to the address in memory - dataType(string) the data type of the value (definitions can be found at the top of this section)
- callback(function) - has one parameter:
- err(string) - error message (empty if there were no errors)