frida / frida-gum

Cross-platform instrumentation and introspection library written in C
https://frida.re
Other
727 stars 240 forks source link

iterator.context is undefined #764

Closed K4r1it0 closed 8 months ago

K4r1it0 commented 8 months ago

transform iterator.context is always undefined is this normal?

[Local::PID::1590667 ]-> TypeError: cannot read property 'rax' of undefined
    at transform (<input>:19)
Process.enumerateThreads().forEach(thread => {
            Stalker.follow(thread.id, {
                events: {
                    call: true, // Call events can be enabled if needed
                    ret: false, // Return events
                    exec: false, // Execution events
                    block: false, // Block events
                    compile: false // Compilation events
                },
                onReceive(events) {
                    // Process the captured events if needed
                },
                transform: function (iterator) {
                    var instruction = iterator.next();
                    do {
                        if (instruction.mnemonic === 'syscall') {
                            const context = iterator.context;
                            console.log(context);
                            console.log('Syscall number (from rax): ' + context.rax);

                            // Additional logic for syscall handling
                        }
                        iterator.keep();
                    } while (iterator.next() !== null);
                }
            });
        });