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

Pointer problem #47

Closed Zungam1 closed 5 years ago

Zungam1 commented 5 years ago

I saw in the last reports some issues or more some difficutlies in understanding how to use pointers in memoryjs. Im also struggling with pointers in memoryjs, so is this framework already dead?

Here the pointer: https://imgur.com/3eXW7LL ` const memoryjs = require('memoryjs'); let offset_life = 0x01FC50F8;

const memRead = async() => {

memoryjs.openProcess("SildMerlin_x64Steam.exe", async(error, processObject) => {
    if(error){
        console.log('1ERR:' + error)
        return;
    }else{
        console.log(processObject)
    }

    memoryjs.findModule(processObject.szExeFile, processObject.th32ProcessID, async (error, processModule) => {
        if (error) {
            console.log('2ERR:' + error)
            return;
        } else {
            console.log(processModule)
        }

        let life = memoryjs.readMemory(processObject.handle, (processModule.modBaseAddr + offset_life), 'int');
        console.log(life);
    });

});

}

memRead(); `

i would really like to know why the pointer cannot be found, btw in CE and C++ its not a problem, please enlight me

p410n3 commented 5 years ago

According to your screenshot, that is a multi level pointer. You cant just use ONE offset and jump straight to it, you have to go step by step.

For example, from my CSGO project:

//offsets
const oLocalPlayer = mem.getLocalPlayer(csgo.handle, client.szModule); //Get via signature
const oTeamNum = 0xF4; //netvar, stays static usually, even after updates

//Values in memory
localPlayer = mem.readMemory(handle, client + oLocalPlayer, mem.DWORD);
myTeamNum = mem.readMemory(handle, localPlayer + oTeamNum, mem.INT);

So you need to follow the first pointer, pointing to a struct or something in memory. Add an offset to that and follow the next pointer etc.

Additionally, such long multi level pointers are uncommon, I am sure you can reduce its depth. For a good recent tutorial, watch this: https://www.youtube.com/watch?v=elI6vZR6HGE

EDIT: I also suspect you should not read values from memory inside the findModule method. But I am not 100% sure on this. I recommend you use the sync methods instead of the async ones for now, much simpler to deal with. Async stuff can get very tricky at times, and is not always neccesary to begin with.

Zungam1 commented 5 years ago

Thanks, that video was really helpfull