Exetools  

Go Back   Exetools > General > General Discussion

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 11-05-2007, 01:39
Darren Darren is offline
Friend
 
Join Date: May 2003
Posts: 28
Rept. Given: 3
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 16
Thanks Rcvd at 5 Times in 4 Posts
Darren Reputation: 0
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))

Last edited by Darren; 11-05-2007 at 02:07.
Reply With Quote
 

Thread Tools
Display Modes

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
Calculating relative jnz opcode sizes in a custom code generator redbull General Discussion 3 09-15-2005 23:54
Writing 4 bytes to COM Port AgentSmith General Discussion 3 04-08-2005 01:25
Damaged stolen bytes *RemedY* General Discussion 9 05-22-2004 16:58
22 stolen bytes? SvensK General Discussion 2 11-06-2003 17:13


All times are GMT +8. The time now is 04:56.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )