Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hey folks,
I want to cheat in Linux, that is changing the memory of programs at runtime. Kcheat doesn't build anymore, and I didn't find anything comparable, so I thought of throwing together my own little tool.
I learnt that in order to access /proc/PID/mem, I have to attach first with ptrace. But I'm stumped already at the very beginning. I run the following program under sudo:
#!/usr/bin/perl use strict; use diagnostics; use Sys::Ptrace qw(ptrace PTRACE_ATTACH); ptrace PTRACE_ATTACH, 9701; open my $fh, '<', '/proc/9701/mem' or die "could not open mem for read +ing: $!"; my $buf; while (1) { my $res = read $fh, $buf, 8*1024; die "could not read 8KB from mem: $!" unless defined $res; exit if 0 == $res; print $buf; };
This bombs out with "Input/output error at ptrace.pl line 12.". I don't understand why.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing proc/memory
by betterworld (Curate) on Jul 31, 2006 at 23:48 UTC | |
by Anonymous Monk on Aug 01, 2006 at 00:03 UTC | |
|
Re: Accessing proc/memory
by shmem (Chancellor) on Jul 31, 2006 at 22:38 UTC | |
by Anonymous Monk on Jul 31, 2006 at 23:40 UTC | |
by shmem (Chancellor) on Aug 01, 2006 at 00:15 UTC | |
|
Re: Accessing proc/memory
by hv (Prior) on Aug 02, 2006 at 11:50 UTC |