------------------------------------------------------------------------------------ #include int main(int argc, char *argv[]) { char buffer[20]; dumpcode(buffer, 20); sprintf(buffer, "cat /proc/%d/maps", getpid()); system(buffer); } ------------------------------------------------------------------------------------ [root@localhost gate]# ./test 0xbfe87080 00 00 00 00 00 00 00 00 a8 70 e8 bf 82 86 04 08 .........p...... 0xbfe87090 00 00 00 00 .... 0015f000-00174000 r-xp 00000000 08:02 728672 /lib/ld-2.3.2.so 00174000-00175000 rw-p 00015000 08:02 728672 /lib/ld-2.3.2.so 003f6000-00529000 r-xp 00000000 08:02 81031 /lib/tls/libc-2.3.2.so 00529000-0052c000 rw-p 00132000 08:02 81031 /lib/tls/libc-2.3.2.so 0052c000-0052f000 rw-p 00000000 00:00 0 08048000-08049000 r-xp 00000000 08:02 875252 /home/gate/test 08049000-0804a000 rw-p 00000000 08:02 875252 /home/gate/test bf50f000-bf510000 rw-p 00000000 00:00 0 bf516000-bf517000 rw-p 00000000 00:00 0 bfe86000-c0000000 rw-p fff1b000 00:00 0 [root@localhost gate]# ./test 0xbfef1c40 00 00 00 00 00 00 00 00 68 1c ef bf 82 86 04 08 ........h....... 0xbfef1c50 00 00 00 00 .... 00302000-00317000 r-xp 00000000 08:02 728672 /lib/ld-2.3.2.so 00317000-00318000 rw-p 00015000 08:02 728672 /lib/ld-2.3.2.so 00c11000-00d44000 r-xp 00000000 08:02 81031 /lib/tls/libc-2.3.2.so 00d44000-00d47000 rw-p 00132000 08:02 81031 /lib/tls/libc-2.3.2.so 00d47000-00d4a000 rw-p 00000000 00:00 0 08048000-08049000 r-xp 00000000 08:02 875252 /home/gate/test 08049000-0804a000 rw-p 00000000 08:02 875252 /home/gate/test bf5be000-bf5bf000 rw-p 00000000 00:00 0 bf5c5000-bf5c6000 rw-p 00000000 00:00 0 bfef1000-c0000000 rw-p fffdc000 00:00 0 [root@localhost gate]# ------------------------------------------------------------------------------------ (gdb) disass main Dump of assembler code for function main: 0x08048616 : push %ebp 0x08048617 : mov %esp,%ebp 0x08048619 : sub $0x28,%esp 0x0804861c : and $0xfffffff0,%esp 0x0804861f : mov $0x0,%eax 0x08048624 : sub %eax,%esp 0x08048626 : sub $0x8,%esp 0x08048629 : push $0x14 0x0804862b : lea 0xffffffd8(%ebp),%eax 0x0804862e : push %eax 0x0804862f : call 0x8048461 0x08048634 : add $0x10,%esp 0x08048637 : sub $0x4,%esp 0x0804863a : sub $0xc,%esp 0x0804863d : call 0x8048308 0x08048642 : add $0xc,%esp 0x08048645 : push %eax 0x08048646 : push $0x8048757 0x0804864b : lea 0xffffffd8(%ebp),%eax 0x0804864e : push %eax 0x0804864f : call 0x8048358 0x08048654 : add $0x10,%esp 0x08048657 : sub $0xc,%esp 0x0804865a : lea 0xffffffd8(%ebp),%eax 0x0804865d : push %eax 0x0804865e : call 0x8048328 0x08048663 : add $0x10,%esp 0x08048666 : leave 0x08048667 : ret End of assembler dump. (gdb)