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 


Auto assembler and code caves

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

Joined: 23 Apr 2009
Posts: 43
Location: in a glitch

PostPosted: Fri Aug 07, 2009 8:06 pm    Post subject: Auto assembler and code caves Reply with quote

ok

For some reason im having trouble doing this auto assembler script in-to a code cave i have all my other ones working but this one. Here is my auto assembler script

Code:
[ENABLE]
alloc(newmem,2048)
label(returnhere)
label(originalcode)
label(x_location)
label(y_location)
label(z_location)
registersymbol(x_location)
registersymbol(y_location)
registersymbol(z_location)
label(exit)

005F723B:
jmp newmem
returnhere:

newmem:



mov ecx,x_location
mov ecx,[ecx]
cmp ecx,0
//je originalcode
mov [eax+04],ecx

mov ecx,y_location
mov ecx,[ecx]
cmp ecx,0
//je originalcode
mov [eax+0c],ecx

mov ecx,z_location
mov ecx,[ecx]
cmp ecx,0
//je originalcode
mov [eax+08],ecx

x_location:
dd 00000000

y_location:
dd 00000000

z_location:
dd 00000000

originalcode:
mov ecx,[eax]
mov edx,[eax+04]
exit:
jmp returnhere



[DISABLE]
dealloc(newmem)
005F723B: // 8B 08 8B 50 04 89 4C 24 20
mov ecx,[eax]
mov edx,[eax+04]






And here is my code cave which is failing


here is the call

Code:
                  if (CH_Teleport == 1)
   {
         DWORD teleportAddress = 0x005F723B;
      *(BYTE*)teleportAddress = 0xe9; // defining jump opcode
      *(DWORD*)(teleportAddress+1) = JMP(teleportAddress,teleport1);
   }   

                  if (CH_Teleport == 0)
   {
         DWORD teleportAddress = 0x005F723B;
      *(BYTE*)teleportAddress = 0xe9; // defining jump opcode
      *(DWORD*)(teleportAddress+1) = JMP(teleportAddress,teleport0);
   }   



Code:
DWORD teleportend =0x005f7240;



__declspec(naked) void teleport0 ()
{

  __asm
  {
mov ecx,[eax]
mov edx,[eax+0x04]
jmp dword ptr ds:[teleportend]
  }
}


DWORD dwRet = 0x05F723B+5;
void __declspec(naked) teleport1()
{
   DWORD xLoc,yLoc ,zLoc ;
   xLoc = 0x00000000;
   yLoc = 0x00000000;
   zLoc = 0x00000000;
   __asm
   {
mov ecx,xLoc
mov ecx,[ecx]
cmp ecx,0x0
je originalcode
mov [eax+0x0c],ecx

mov ecx,zLoc
mov ecx,[ecx]
cmp ecx,0x0
je originalcode
mov [eax+0x08],ecx
originalcode:
   mov ecx,[eax]
   mov edx,[eax+0x04]
exit:
   jmp dword ptr ds: [teleportend] ;
   }
}






The cheat engine auto assembler script works perfectly, but my code cave causes the game to error

_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Fri Aug 07, 2009 9:10 pm    Post subject: Reply with quote

When you're messing with pointers in inline assembly for VC's compiler, you should always do dword ptr...

Example.

Instead of

Code:
mov ebx, [eax+4]


Change it to

Code:
mov ebx, dword ptr[eax+4]
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Fri Aug 07, 2009 10:26 pm    Post subject: Reply with quote

Don't do those local variable definitions (xLoc,yLoc,zLoc). You're fucking up the stack. Just put them right outside the function (global).

When you define a local variable it is stored on the stack.

What you are doing is using the stack, then your function never gets a chance to clean it up because you are jmping back to the game's static memory.
Back to top
View user's profile Send private message
Ind3siszive
Cheater
Reputation: 0

Joined: 23 Apr 2009
Posts: 43
Location: in a glitch

PostPosted: Fri Aug 07, 2009 10:53 pm    Post subject: Reply with quote

Quote:
Don't do those local variable definitions (xLoc,yLoc,zLoc). You're fucking up the stack. Just put them right outside the function (global).

When you define a local variable it is stored on the stack.

What you are doing is using the stack, then your function never gets a chance to clean it up because you are jmping back to the game's static memory.



Thats what i did originally but rajinn from augmented skills suggested i do it that way, ill restart this and try again then edit this













Something like this?? because i believe this errors me too



Code:
//teleport
DWORD  x_location = 0x00000000;
DWORD  y_location = 0x00000000;
DWORD  z_location = 0x00000000;
DWORD teleportend =0x005f7240;



__declspec(naked) void teleport0 ()
{

  __asm
  {
mov ecx,dword ptr [eax]
mov edx,dword ptr [eax+0x04]
jmp dword ptr ds:[teleportend]
  }
}


DWORD dwRet = 0x05F723B+5;
void __declspec(naked) teleport1()
{

   __asm
   {
      

      
      mov ecx,dword ptr ds: [x_location]
      mov ecx,dword ptr [ecx]
       cmp ecx,0
       //je originalcode
       mov [eax+04],ecx

      mov ecx,dword ptr ds: [x_location]
      mov ecx,dword ptr[ecx]
      cmp ecx,0x0
      //je teleport0
      mov [eax+0x0c],ecx

      mov ecx, dword ptr ds: [z_location]
       mov ecx, dword ptr[ecx]
       cmp ecx,0x0
       //je teleport0
       mov [eax+0x08],ecx
   jmp dword ptr ds: [teleport0] ;
   }
}

_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
S3NSA
:3
Reputation: 1

Joined: 06 Dec 2006
Posts: 1908
Location: England.

PostPosted: Sat Aug 08, 2009 4:34 pm    Post subject: Reply with quote

Code:
mov ecx,dword ptr ds: [x_location]
mov ecx,dword ptr [ecx]
mov ecx,dword ptr ds: [x_location]
mov ecx,dword ptr[ecx]       mov ecx, dword ptr ds: [z_location]
mov ecx, dword ptr[ecx]

You're apparently doing it wrong. According to some illiterate and ignorant nigerian on xchat. Goes by the name of flannel or something.
Back to top
View user's profile Send private message Visit poster's website
Ind3siszive
Cheater
Reputation: 0

Joined: 23 Apr 2009
Posts: 43
Location: in a glitch

PostPosted: Sat Aug 08, 2009 9:44 pm    Post subject: Reply with quote

lol, that doesn't really make much sense, and it still makes the game error,

i need to


Code:

mov [eax+0x0c],ecx



mov [eax+0x08],ecx


and

mov [eax+04],ecx


somewhere dont I?





anyone else see anything wrong.[/code]

_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sat Aug 08, 2009 11:27 pm    Post subject: Reply with quote

Address definition:

Code:
DWORD dwHookAddress = 0x005F723B;




hook code:

Code:
DWORD x_location = 0, y_location = 0, z_location = 0;

void __declspec(naked) __stdcall hook()
{
mov ecx,[x_location]
mov [eax+04],ecx

mov ecx,[y_location]
mov [eax+0c],ecx

mov ecx,[z_location]
mov [eax+08],ecx

mov ecx,[eax]
mov edx,[eax+04]

jmp dword ptr ds:[dwHookAddress+5]
}




To enable:

Code:
*(BYTE*)dwHookAddress = 0xE9;
*(DWORD*)(dwHookAddress+1) = JMP(dwHookAddress,hook);







Btw, idk why you commented those JE's lol. now your values will stay at 0.
Back to top
View user's profile Send private message
Ind3siszive
Cheater
Reputation: 0

Joined: 23 Apr 2009
Posts: 43
Location: in a glitch

PostPosted: Sun Aug 09, 2009 1:38 am    Post subject: Reply with quote

thanks bud it works great, only problem is that the game updated a little, and only one axis is working but thanks a bunch Smile +rep
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sun Aug 09, 2009 2:40 am    Post subject: Reply with quote

Lol are you sure the game update is the problem ? The problem looks to me like you're not modifying the x/y at all because you took out those JE's.
Back to top
View user's profile Send private message
Ind3siszive
Cheater
Reputation: 0

Joined: 23 Apr 2009
Posts: 43
Location: in a glitch

PostPosted: Sun Aug 09, 2009 11:13 pm    Post subject: Reply with quote

maybe your right, but the x teleport works, y and z dont however
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Mon Aug 10, 2009 12:41 am    Post subject: Reply with quote

Code:
mov edx,[eax+04]




You only put X-Axis into EDX ;____;

Reverse harder.

Actually, did you try the original script lol

And ya, reverse harder plz.
Back to top
View user's profile Send private message
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