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 


Hooking assembly (easy question for assembly ppl who know)
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Aug 15, 2008 6:53 pm    Post subject: Hooking assembly (easy question for assembly ppl who know) Reply with quote

lock

OLD TOPIC..


Last edited by pkedpker on Wed Aug 20, 2008 11:39 pm; edited 3 times in total
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Fri Aug 15, 2008 7:28 pm    Post subject: Reply with quote

Code:
0F702486 > 57                            PUSH EDI              ; I steal the size
0F702487   50                            PUSH EAX              ; I steal the packet pointer
0F702488   E8 C8EBFFFF                   CALL HACK.0F701055           ; I call int WINAPI MyRecvFunction(int size, char* packet)


Change the RecvFunction to this:
Code:

void Naked RecvFunction() {//my redirected function.
   __asm {

      push edi //size
      push eax //packet
      call MyRecvFunction
      jmp OriRecvFunction//+224 //back to original spot
      retn
   }
}


Crashing could be caused because your function prototype is incorrect. Notice that the first parameter is the pointer to the packet, and the 2nd parameter is the size of the packet (stack, first in last out).[/code]


Last edited by rapion124 on Fri Aug 15, 2008 8:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Aug 15, 2008 8:41 pm    Post subject: Reply with quote

oh yah..

but umm it goes into RecvFunction() the jmp to OriRecvFunction works.. and it never does the lines after that.. thats my real problem.


plus what u wrote on top.. is going to give me encrypted packet! I want it to call decrypt function in game.. then give me the packet out.. but it returns wrong place after it calls it. thats why jmp has to be first.. not after.. cuz it has to call decrypt function first.


Last edited by pkedpker on Sat Aug 16, 2008 1:15 am; edited 1 time in total
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Fri Aug 15, 2008 8:52 pm    Post subject: Reply with quote

Of course it doesn't... You jump to OriRecvFunction and execution continues there.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Aug 15, 2008 11:05 pm    Post subject: Reply with quote

exactly so how do i fix it? for it to continuue and give me some extra space to hook the eax ecx edi whatever i forgot but yah.. before it gets pop'd out
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Fri Aug 15, 2008 11:18 pm    Post subject: Reply with quote

Quote:
anyways I'm having a problem with after I hook the call that calls decrypt function
that means its never decrypted. ALSO why do you jump to your code in the call when you can just have the code in that call.
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Fri Aug 15, 2008 11:24 pm    Post subject: Reply with quote

yab but its all filled up.. i can't remove anything bad u know.
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Fri Aug 15, 2008 11:27 pm    Post subject: Reply with quote

Code:
006C84EB   . E8 3D8B030F                 CALL HACK.0F70102D
Use a call hook... to your procedure.
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sat Aug 16, 2008 1:10 am    Post subject: Reply with quote

I did you mean use a jmp?

what u see above is exactly what i used.. and your telling me what I already used..

the problem is that the RETN from the decrypt function goes back to the old position not inside my detoured function!..

if that happens how can i control it ehh.........

thing is.. if i dont call decrypt function I just call detour to mines.. I will just get a encrypted packet.. which is pointless to me.. but If i call the decrypt function.. It just ends up going back where it suppose to go???

HACK is my dll functions
game is the game functions.
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sat Aug 16, 2008 2:45 am    Post subject: Reply with quote

look into the call for any ways out. anyways i was saying its such a waste to do call XXX and then in XXX you jump to another location. instead just call XXX as XXX is your function.
_________________
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat Aug 16, 2008 10:23 am    Post subject: Reply with quote

When hooking, you can't use "call" because it screws up the stack. It's pretty complicated.

This is how it should go.

Normal code -> jmp HookedFunction -> *do stuff* -> Trampoline (execute overwritten bytes) -> jmp NormalCode + ReEntryOffset.

The problem is that in his Hook, he jumps back to the original function before executing his code. His re-entry position is also off. He should jump to the normal code after his hook.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sat Aug 16, 2008 1:45 pm    Post subject: Reply with quote

so i gotta replace all call's related to my problem to jmps.

also how do I get the offset for re-enty jmps work by adding offsets.. and my dll gets dynmatic offsets my dl functions cuz they loaded different locations everytime..

mayb first one has to be a call..... then inside that call of em are jmps? well ill keep trying

RAPION wrote:
The problem is that in his Hook, he jumps back to the original function before executing his code. His re-entry position is also off. He should jump to the normal code after his hook.



I want the original function to execute before my own code.. otherwise the packet will never get decrypted.? jmps are working even worse in my situation

man i feel like i need some live VNC help.
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sat Aug 16, 2008 3:06 pm    Post subject: Reply with quote

If done properly it doesn't really matter, you CAN use call.
_________________
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Sat Aug 16, 2008 3:39 pm    Post subject: Reply with quote

I used 2 calls in my own hack because Naked function has no assembly

putting a printf in it or something..
would screw up its assembly..

thats why i do assembly work in a empty function then after its done I re-route it a 3rd time to my normal function.

Thats how i think i see it..

so its like this... layout..

before HOOK:
GAME->GAME decrypt->pop size,pop packet

now after HOOK

GAME->Naked Function->GAME decrypt->back to Naked function->Now Back to my Hack function->now back to GAME->pop size,pop packet

but! it doesnt do that, it does this..

GAME->Naked Function->GAME decrypt->back to Naked function (Doesn't go here, just goes to game and pops size and packet!)->back to GAME->pop size,pop packet
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Sat Aug 16, 2008 3:42 pm    Post subject: Reply with quote

I advise you to learn what CALL/RETN really does.
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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