Page 1 of 1
executable bases
Posted: Sat Jun 13, 2009 9:54 pm
by VolTeK
is there a certain opcode in a file that i can find to tel me where the file will be loaded? where the base should be
example
org 1000h
Re: executable bases
Posted: Sat Jun 13, 2009 10:09 pm
by pcmattman
No. That's why there's executable file formats, like ELF.
Re: executable bases
Posted: Sat Jun 13, 2009 11:16 pm
by Troy Martin
Nope. That's one the points of a relocatable executable file format. Even a simple 2^x byte executable header is perfect for this.
Re: executable bases
Posted: Sat Jun 13, 2009 11:59 pm
by VolTeK
oh, alright, thanks
Re: executable bases
Posted: Sun Jun 14, 2009 9:56 am
by Troy Martin
What I would suggest is passing the base from the kernel to the program in a register such as DX (or EDX in pmode) so the program can then play with that.
Re: executable bases
Posted: Sun Jun 14, 2009 10:40 am
by neon
What I would suggest is passing the base from the kernel to the program in a register such as DX (or EDX in pmode) so the program can then play with that.
I personally dont recommend that. It is hackish imho and creates an unnecessary dependency between the calling program and OS.
If the program is needing to know where it is located at, there are nicer methods of obtaining that information. ie; like the program calling a API function to obtain it.
Just my 2 cents.
Re: executable bases
Posted: Sun Jun 14, 2009 10:49 am
by salil_bhagurkar
I think it should be possible (just to prove the concept) by locating an absolute jump/call within the first few instructions of the program. This would require some minimal disassembly of the program. By assuming an alignment of the program in the memory, it should be possible to inaccurately determine the load address..