-1
void  *entrypoint;
/*virtual address of process*/
fscanf(debuggedfile, "%p", &entrypoint);

where debuggedfile is the stream to an elf file at the offset where int entry point is. when i use ptrace(PTRACE_PEEKTEXT, 0, entrypoint, 0) it returns -1

rob
  • 345
  • 1
  • 5
  • 13

2 Answers2

1

ELF is a binary file format. fscanf is for reading from text files. Try fread instead.

MRAB
  • 20,356
  • 6
  • 40
  • 33
0

If you are writing code that parses ELF files, I would suggest using a standard library like libelf instead of coding your own ELF parser by hand.

That way you would let libelf handle the corner cases that arise occasionally, for example, ELF objects that use extended section numbering.

There are active open-source projects developing BSD licensed and GPL'ed implementations of libelf---take your pick.

jkoshy
  • 1,793
  • 15
  • 23
  • Thanks seems i'm not yet ready for doing this by myself (I always hate to use libraries cause i want to understand how everything works) I'll give it a try – rob Jul 18 '11 at 12:57