Quote:
|
Originally Posted by yaa
But this is not true. It depends entirely on how your compiler and linker lay out your code in the binary. Without doing anything special and without touching optimization flags, taking your example, I even got to the point that dummy's code was placed BEFORE main's code in the compiled binary!
yaa
|
Maybe this is correct when dealing with the main function, but I've used many times this example below and found it to work fine, but i do always compile it from a seperate .cpp this method can be useful for when adding complicated hooks or patches to a piece of code and placing the new function in a cave or new section
Code:
void funct1()
{
funct1code...
}
void funct2()
{
funct2code...
}
void funct3()
{
funct3code...
}
void dummy()
{
}
#define funct1size ((DWORD)funct2-(DWORD)funct1))
#define funct2size ((DWORD)funct3-(DWORD)funct2))
#define funct3size ((DWORD)dummy-(DWORD)funct3))