Rob-- / memoryjs

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

Problems when using with electron. #96

Open Runc2333 opened 2 years ago

Runc2333 commented 2 years ago

Program working fine when in 'preview' mode (I mean yarn electron:serve), but memoryjs.openProcess(process.th32ProcessID); throws Error: unable to find process after being packed by electron-builder. Here's my code:

const signature = '75 6E 61 6D 65 3D 27';
const rc_clients = memoryjs.getProcesses().filter(p => p.szExeFile === "rc3.exe");
let accounts = [];
for (let process of rc_clients) {
    const process_object = memoryjs.openProcess(process.th32ProcessID);
    let pat = memoryjs.findPattern(process_object.handle, signature, memoryjs.NORMAL, 0);
    let mem = memoryjs.readBuffer(process_object.handle, pat, 256);
    // ...
}
return accounts;

Target process is 32-bit, using vue-electron-builder, node version is 32-bit too, have tried npm run build32, requestedExecutionLevel: requireAdministrator, externals: ['memoryjs'], but none of these work. Hope to get some help from here, thanks in advance.

Rob-- commented 1 year ago

Hey, if you are still having problems it would be helpful to log some information. Can you print/log rc_clients and confirm the process ids returned by memoryjs match the process ids in Task Manager? If we know memoryjs.openProcess is being called on a valid process id, then it could be a permissions issue.

Error: unable to find process happens when memoryjs can't find the process, or if it found it but wasn't able to obtain a handle to the process. I'll add an item to the TODO list to add more granularity to the error messages, to make it clear if the process could not be found or if it's just that a handle couldn't be obtained.