Skip to content

Error reading BigInt pointer #114

Open
@alorodri

Description

@alorodri

Hello!

In this code, it fails to read the memory from the first pointer, when it sums the offset and tries to readMemory again the new address. Elden Ring is a x64 game, I compiled memoryjs with build64 and I had no problem getting the first ptr value. The problem comes with the second readMemory call, because the first returns a BigInt, then when I call again I must pass an address that is a BigInt, and then it shows me that error:

C:\Users\alope\source\repos\electronTestWindows\node_modules\memoryjs\index.js:49
    return memoryjs.readMemory(handle, address, dataType.toLowerCase());
                    ^

Error: Error in native callback
    at Object.readMemory (C:\Users\alope\source\repos\electronTestWindows\node_modules\memoryjs\index.js:49:21)
    at readMemory (C:\Users\alope\source\repos\electronTestWindows\test.js:16:26)
    at Object.<anonymous> (C:\Users\alope\source\repos\electronTestWindows\test.js:24:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.17.1

Some useful data:

Object process

{
  dwSize: 304,
  th32ProcessID: 30796,
  cntThreads: 97,
  th32ParentProcessID: 32248,
  pcPriClassBase: 8,
  szExeFile: 'eldenring.exe',
  handle: 564,
  modBaseAddr: 2061870039768
}

That's my code:

const memoryjs = require("memoryjs");

function readMemory() {
  const processName = "eldenring.exe";
  const offset1 = 0x3cd4d88;
  const offset2 = 0x94;

  const processObject = memoryjs.openProcess(processName);
  const baseAddress = processObject.modBaseAddr;
  const ptrToValue = memoryjs.readMemory(
    processObject.handle,
    baseAddress + offset1,
    memoryjs.PTR
  );

  const value = memoryjs.readMemory(
    processObject.handle,
    ptrToValue + BigInt(offset2),
    memoryjs.INT64
  );
  console.log(value);
}

readMemory();

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions