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
executable bases
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Re: executable bases
No. That's why there's executable file formats, like ELF.
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: executable bases
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
oh, alright, thanks
- Troy Martin
- Member
- Posts: 1686
- Joined: Fri Apr 18, 2008 4:40 pm
- Location: Langley, Vancouver, BC, Canada
- Contact:
Re: executable bases
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
I personally dont recommend that. It is hackish imho and creates an unnecessary dependency between the calling program and OS.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.
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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- salil_bhagurkar
- Member
- Posts: 261
- Joined: Mon Feb 19, 2007 10:40 am
- Location: India
Re: executable bases
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..