LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-11-2009, 08:08 AM   #1
jiikka
LQ Newbie
 
Registered: Jan 2009
Location: Chennai, India
Distribution: Redhat
Posts: 23

Rep: Reputation: 17
Question ‘ORIG_EAX’ undeclared ? ..


Hello folks ..
i get this error "‘ORIG_EAX’ undeclared" when i ran a ptrace program.
i guess it has to do something with the header file user.h ..
Is it my user.h is in a different location ,, ?
i have redhat distribution.

#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/user.h> /* For constants
ORIG_EAX etc */
int main()
{ pid_t child;
long orig_eax;
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("/bin/ls", "ls", NULL);
}
else {
wait(NULL);
orig_eax = ptrace(PTRACE_PEEKUSER,
child, 4 * ORIG_EAX,
NULL);
puts("The child made a "
"system call %ld\n", orig_eax);
ptrace(PTRACE_CONT, child, NULL, NULL);
}
return 0;
}



thank you folks ..
 
Old 05-30-2009, 02:11 PM   #2
mrli
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 1
jikka hi,

I also encountered a similar problem. I'm using Ubuntu 9.04. Here is my solution:

1. Originaly I got an error that there is no such library as linux/user.h
That is true, I have such file only in /usr/include/sys/user.h
The problem is - this file do not define the ORIG_EAX constant, instead it has the user_reg_struct which has a orig_eax member. Seems unlogical but I tried to change

#include <linux/user.h>

to

#include <sys/user.h>

Now the code above compiles but it returns wrong output (I think we are both following this tutorial: linuxjournal.com/article/6100)

2. So I looked up where ORIG_EAX is defined using:

find /usr/include/ -iname '*.h' | xargs grep 'ORIG_EAX' -sl

3. This gave me /usr/include/sys/reg.h which indeed has the constant ORIG_EAX (set to 11 in my case). So just change :

#include <linux/user.h>

to

#include <sys/reg.h>

And this works.
 
Old 06-07-2009, 03:35 PM   #3
tlogic
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
Thanks mrli that worked
 
Old 07-06-2009, 03:00 AM   #4
mzeeshanbhatti
LQ Newbie
 
Registered: Feb 2007
Location: Islamabad - Pakistan
Distribution: Linux - Fedora
Posts: 9

Rep: Reputation: Disabled
problem still persists in core 9

dear mrli...

i have used the above procedure in core 9 but this does not help me then i went in to define "# define ORIG_EAX 11" in simple.c of the net sample code given. its works well with the cimpilation

BUT i get the following system call no as;

The child made a system call -1

i think "-1" .. seemd to be an error.. can some body help me properly execute this net sample code for ptrace.

regards.

-zeeshan
 
Old 07-06-2009, 05:17 AM   #5
mzeeshanbhatti
LQ Newbie
 
Registered: Feb 2007
Location: Islamabad - Pakistan
Distribution: Linux - Fedora
Posts: 9

Rep: Reputation: Disabled
CODE:

----------------------------------------------
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/reg.h>

# define ORIG_EAX 11

int main()
{ pid_t child;
long orig_eax;
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("/bin/ls", "ls", NULL);
}
else {
wait(NULL);
orig_eax = ptrace(PTRACE_PEEKUSER,
child, 4 * ORIG_EAX,
NULL);
printf("The child made a "
"system call %ld\n", orig_eax);
ptrace(PTRACE_CONT, child, NULL, NULL);
}
return 0;
}

----------------------------------------------








OUTPUT:


----------------------------------------------
The child made a system call -1
[root@sbhatti Sample]# client client.c clint log-file.txt makefile makefile~ ptrace.c ptrace.c~ server server.c server.c~ syscall.c syscall.c~ trace
----------------------------------------------


Regards,

-zeeshan
 
Old 09-16-2009, 02:37 AM   #6
gliscor
LQ Newbie
 
Registered: Sep 2009
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by mzeeshanbhatti View Post
CODE:

----------------------------------------------
#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/reg.h>

# define ORIG_EAX 11

int main()
{ pid_t child;
long orig_eax;
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("/bin/ls", "ls", NULL);
}
else {
wait(NULL);
orig_eax = ptrace(PTRACE_PEEKUSER,
child, 4 * ORIG_EAX,
NULL);
printf("The child made a "
"system call %ld\n", orig_eax);
ptrace(PTRACE_CONT, child, NULL, NULL);
}
return 0;
}

----------------------------------------------
child = fork();
if(child == 0) {
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execl("/bin/ls", "ls", NULL);
}
else {
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
while(1) {
wait(&status);
if(WIFEXITED(status))
break;
ptrace(PTRACE_GETREGS, child, 0, &regs);
if(insyscall == 0) { /* Syscall entry */
insyscall = 1;
printf("Syscall : %ld ", ptrace(PTRACE_PEEKUSER, child, 4 * ORIG_EAX, NULL));
}
else { /* Syscall exit */
insyscall = 0;
}
ptrace(PTRACE_SYSCALL, child, NULL, NULL);
} /*while*/
}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find the definition of ORIG_EAX on 64bit? agemo Programming 4 12-10-2008 12:12 PM
CONFIG_Kernel_start undeclared first use in this function Aref Linux - Kernel 0 11-22-2008 05:39 AM
slackware qmail smtp_starttls undeclared hua Slackware 0 01-01-2008 01:47 PM
undeclared here (not in a function) ashlesha Linux - Software 2 08-23-2006 11:29 PM
Undeclared variable in Atmel drivers? Adam Shapiro Linux - Hardware 7 02-02-2003 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration