Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[ASM & C++] Pointer to Function

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Sun Jul 06, 2008 9:03 pm    Post subject: [ASM & C++] Pointer to Function Reply with quote

I am making some scripts into DLL's so I am just double checking this....

In C++ you can have a pointer to a function (yes you can, try it), so if I wanted to make this AA code into C++/ASM:

Code:
[Enable]
//alloc crap
//etc

CodeCave:
//shit
jmp returnhere

1D6C8F7A:
jmp CodeCave // *
nop
returnhere:


Wouldn't I need to make a pointer to a function at the line with the '*'?

If not what would I do.... I am not the best at ASM, I am going to learn it after python.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sun Jul 06, 2008 9:09 pm    Post subject: Reply with quote

If you wanna have the same effect as doing

Alloc(CodeCave, 128)

just do a __declspec(naked) function containing inline asm like so:

Code:
DWORD Return = 0x1D6C8F80;
void __declspec(naked) CodeCave()
{
   _asm
   {
        jmp dword ptr ds:[Return]
   }
}


then pointer editing like so:

Code:
*(BYTE*)0x1D6C8F7A = 0xE8; // Call
*(DWORD*)0x1D6C8F7B = ((DWORD)CodeCave - 0x1D6C8F7A - 5); // Distance for jump
*(BYTE*)0x1D6C8F7F = 0x90; // Nop

_________________
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Sun Jul 06, 2008 9:29 pm    Post subject: Reply with quote

I get it... Then in asm.... (I just prefer it.)

Code:
__asm
{
     jmp dword ptr ds:[CodeCave]
     nop
     Return:
}


Or I could do a call.... TY


P.S. I don't know what I didn't get that be4, i guess it is late + me a noob in asm.
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Jul 07, 2008 4:43 am    Post subject: Reply with quote

Chaosis13 wrote:
Or I could do a call....
Sure. You can do which ever you want, a jmp or call, depending on how do you build your cave. With a call, make sure that the stack doesn't get messed up.
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Mon Jul 07, 2008 7:30 am    Post subject: Reply with quote

Kk. I made my script, but I dont think I did something right.... Does this code look right:

Code:
Addy = Pointer + 0xABC; //Pointer = 0x12344321
Value = *(DWORD*)Addy;


I need Addy to = pointer + offset, and Value to = value of the address being pointed to. I tryed using this:
Code:
__asm
{
lea ....
}


But the compiler got angry...
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Mon Jul 07, 2008 9:05 am    Post subject: Reply with quote

Pointer points to Base Address Value + Offset, so it should look like:
Code:
(*(int*)Address) + offset


LEA and MOV are diffrent instructions, you know, LEA is used to load an address (Load Effective Address) and MOV moves data.
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Mon Jul 07, 2008 1:23 pm    Post subject: Reply with quote

Oh, ty. I thought LEA was for pointers....
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Mon Jul 07, 2008 1:36 pm    Post subject: Reply with quote

Code:
LEA - Load Effective Address
        Usage:  LEA     dest,src
        Modifies flags: None
        Transfers offset address of "src" to the destination register.
                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes
        reg,mem          2+EA   3     2     1            2-4
        - the MOV instruction can often save clock cycles when used in

        place of LEA on 8088 processors

        8D / r LEA r16,m Store effective address for m in register r16
        8D / r LEA r32,m Store effective address for m in register r32

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Mon Jul 07, 2008 5:38 pm    Post subject: Reply with quote

Wiccaan wrote:
Code:
LEA - Load Effective Address
        Usage:  LEA     dest,src
        Modifies flags: None
        Transfers offset address of "src" to the destination register.
                                 Clocks                 Size
        Operands         808x  286   386   486          Bytes
        reg,mem          2+EA   3     2     1            2-4
        - the MOV instruction can often save clock cycles when used in

        place of LEA on 8088 processors

        8D / r LEA r16,m Store effective address for m in register r16
        8D / r LEA r32,m Store effective address for m in register r32


Shouldn't you be crediting the Intel Reference Manual?

Code:

lea eax,[eax+4]


Makes eax a pointer to [eax+4]

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
Chaosis13
Master Cheater
Reputation: 0

Joined: 14 Aug 2007
Posts: 372

PostPosted: Mon Jul 07, 2008 6:12 pm    Post subject: Reply with quote

OWNED. And I don't know why LEA wasn't working for me, but it must have been my other code.... It is getting abit complicated...

TY for your help.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Jul 08, 2008 12:37 am    Post subject: Reply with quote

It's quoted, and I never said I wrote it.

Edit: On a side note, it came from the help files that come with MASM.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites