| View previous topic :: View next topic |
| Author |
Message |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Mon Dec 24, 2007 8:13 pm Post subject: [ASM] Calculating a Relative Address |
|
|
How might one go about calculating a relative address?
I've tried Google, but nothing showed up; I was going to try CEF, but something strayed me away... (Look at the picture if you don't get it)
_________________
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Mon Dec 24, 2007 8:21 pm Post subject: |
|
|
Obtain base address.
Anyways, you weren't being specific enough.
_________________
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Mon Dec 24, 2007 8:28 pm Post subject: |
|
|
Ok, well what I meant was:
If you are given an opcode, for example
The way you would find its array of bytes is to get the opcode's defined bytes for those specified parameters (in that case, parameter), which is
then still the rel32 bytes in reverse on the back.
How do you calculate the rel32 from that?
_________________
|
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Mon Dec 24, 2007 9:10 pm Post subject: |
|
|
| Code: |
(Destination - (Base + 5))
|
so if we wanted to do call 01002ff5 from 00500000...
01002ff5 - 00500005 = 00B02FF0
expressed in little endian byte notation is:
_________________
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Mon Dec 24, 2007 11:15 pm Post subject: |
|
|
Damn it appalsap, I get back to the computer and I see this thread and feel like helping, and you beat me too it.
Anyways, to OP: Its best to make an array such as this:
| Code: | | unsigned char jump[] = { 0xe8 /*0xe9 for JMP*/, 0x00, 0x00, 0x00, 0x00 }; |
Then constructing the jump using memcpy (or the intrinsic function __movsb()).
Oh, and for the sake of simplicity you could just reduce the formula to: (To - From - 5). You be surprised how many people don't realize this when all it is is basic math.
|
|
| Back to top |
|
 |
DoomsDay Grandmaster Cheater
Reputation: 0
Joined: 06 Jan 2007 Posts: 768 Location: %HomePath%
|
Posted: Tue Dec 25, 2007 9:39 am Post subject: |
|
|
| Flyte wrote: | Damn it appalsap, I get back to the computer and I see this thread and feel like helping, and you beat me too it.  | Welcome to the club
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Wed Dec 26, 2007 2:09 pm Post subject: |
|
|
Alright, thanks a ton everyone. The dll should be finished by the end of today.
_________________
|
|
| Back to top |
|
 |
"A" Grandmaster Cheater Supreme
Reputation: 0
Joined: 26 Dec 2007 Posts: 1589 Location: Deme,Broa,Scaina
|
Posted: Wed Dec 26, 2007 7:09 pm Post subject: |
|
|
| i no this hummm gold on lol
|
|
| Back to top |
|
 |
|