* How to set up struct pt_regs in assembly?
@ 2003-08-22 0:24 dante
2003-08-22 4:20 ` linuxassembly
0 siblings, 1 reply; 2+ messages in thread
From: dante @ 2003-08-22 0:24 UTC (permalink / raw)
To: linux-assembly
Hi everyone,
I'm having some problems writing the assembly code to set up the eax,
ebx, ecx and edx registers for a int 0x80 call to sys_execve on 2.4
kernels. In C, the function is defined as int sys_execve(struct pt_regs
regs) where struct pt_regs is defined in <asm/ptrace.h>. I don't know
what to put into eax-edx to get (struct pt_regs regs) right.
In 2.2 it was easy, you just did (in nasm):
; int sys_execve(const char *filename, char const argv[], char const envp[]
%macro execve 3
mov ebx,%1 ; ptr to null terminated string containing program
mov ecx,%2 ; ptr to null terminated string of arguments
mov edx,%3 ; ptr to null terminated string of environment
mov eax,11
int 0x80
%endmacro
global _start
section .data
shell db "/bin/sh",0
nothing db 0
section .text
_start: execve shell, nothing, nothing
What is the equivalent for 2.4 kernels?
-------------------------------------------------------------------
Anthony G. Basile, Ph.D.
Director of Information Technology,
D'Youville College,
320 Porter Ave.
Buffalo NY, 14201
Work: (716) 881-8197 (voicemail)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to set up struct pt_regs in assembly?
2003-08-22 0:24 How to set up struct pt_regs in assembly? dante
@ 2003-08-22 4:20 ` linuxassembly
0 siblings, 0 replies; 2+ messages in thread
From: linuxassembly @ 2003-08-22 4:20 UTC (permalink / raw)
To: dante; +Cc: linux-assembly
> section .data
> shell db "/bin/sh",0
> nothing db 0
>
> section .text
> _start: execve shell, nothing, nothing
Remember that the argv and envp parameters are pointers to arrays of
pointers, not pointers to strings. If you want empty arrays, your
'nothing' variable needs to be 'dd 0', not 'db 0'.
For a longer example, if you wanted some environment variables and a proper
argv, the code would look like this:
mov eax, 11 ; ( I'm assuming that's the correct call number )
mov ebx, pathname
mov ecx, argv
mov edx, envp
int 0x80
...and then later...
pathname db "/bin/cat", 0
argv dd arg0, arg1, 0
envp dd var1, var2, 0
arg0 db "cat", 0
arg1 db "/dev/urandom", 0
var1 db "THIS=that", 0
var2 db "THESE=those", 0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-08-22 4:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-22 0:24 How to set up struct pt_regs in assembly? dante
2003-08-22 4:20 ` linuxassembly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).