//---------------------------------------------------------------- // showproc.s // // This program uses Linux kernel services to open and read // from the system's pseudo-file named '/proc/self/maps' to // display the memory-map that Linux created for this task. // // assemble using: $ as showproc.s -o showproc.o // and link using: $ ld showproc.o -o showproc // // programmer: ALLAN CRUSE // written on: 13 FEB 2006 //---------------------------------------------------------------- .equ sys_exit, 1 .equ sys_read, 3 .equ sys_write, 4 .equ sys_open, 5 .equ O_RDONLY, 0 .equ STDOUT, 1 .equ BUFSIZE, 4096 .section .data filename: .asciz "/proc/self/maps" .section .bss filesiz: .space 4 file_id: .space 4 buffer: .space BUFSIZE .section .text _start: # open the pseudo-file for reading mov $sys_open, %eax lea filename, %ebx mov $O_RDONLY, %ecx int $0x80 mov %eax, file_id # read from the pseudo-file mov $sys_read, %eax mov file_id, %ebx lea buffer, %ecx mov $BUFSIZE, %edx int $0x80 mov %eax, filesiz # show the buffer's contents mov $sys_write, %eax mov $STDOUT, %ebx lea buffer, %ecx mov filesiz, %edx int $0x80 # terminate this program mov $sys_exit, %eax xor %ebx, %ebx int $0x80 .global _start .end