Coding

 Reply to this postStart new topic

memory things

badboy
post Jul 2 2012, 06:05 PM
Post #21


Trained Member

Posts: 76
From: Nederland, NL
Joined: 1-May 12



Thanks, it works now. I can finally start with seriously messing up my game tongue.gif

I think the function I choose will do, but does anyone a function which is called every frame?
Go to the top of the page
 
+Quote Post
LINK/2012
post Jul 2 2012, 06:13 PM
Post #22


I will kill you

Posts: 126
Joined: 13-May 11



CGame__Process (0x53BEE0) ?
Not sure if is called each frame but I guess that it is...
Go to the top of the page
 
+Quote Post
badboy
post Jul 7 2012, 04:07 PM
Post #23


Trained Member

Posts: 76
From: Nederland, NL
Joined: 1-May 12



What if I want to call more functions:

CODE
DEFINE_HOOKER( hook )
{
    if (start == 0)
        Main();

    ASM
    {
        mov eax, 0x442AD0
        jmp eax  
    }
}


void Main()
{
    DWORD* CPlayer = (DWORD*)0xB7CD98;
    
    RequestModel(400, 0);
    LoadRequestedModels(1);
    start = 1;
}


How do I get the ESP value right, can I just call and pop esp. Or do I also have to mov eax, xx or push eax?
CODE
void RequestModel(DWORD id, DWORD unknown)
{
    __asm
    {
        push    unknown
        push    id
        push    0x4087E0
        pop      id
        pop      unknown
    }
}


And in the load requested models function, " arg_0 = byte ptr 4" VS doesn't want to compile if I try to push a byte.
Go to the top of the page
 
+Quote Post
LINK/2012
post Jul 7 2012, 05:14 PM
Post #24


I will kill you

Posts: 126
Joined: 13-May 11



QUOTE
What if I want to call more functions:

Yes, you can, and is like what you did.

But, you should take care of somethings:
*Your hook (if it's not replacing a call...) must be a naked function (http://msdn.microsoft.com/en-us/library/5ekezyy2%28v=vs.80%29.aspx).
*You should take care of the registers, because any function is free to modify the value of EAX, ECX and EDX without pushing they, so If there's any important information there, you should save it!


QUOTE
How do I get the ESP value right, can I just call and pop esp. Or do I also have to mov eax, xx or push eax?

QUOTE
And in the load requested models function, " arg_0 = byte ptr 4" VS doesn't want to compile if I try to push a byte.

The stack can only hold 32bits values.
So, what if you want a 8bit value?
You should say to the assembler that you want a byte in the value pointed by [].

CODE
mov al, byte ptr [esp+4] // I want a byte at [esp+4]


This post has been edited by LINK2012: Jul 7 2012, 05:17 PM
Go to the top of the page
 
+Quote Post
badboy
post Jul 8 2012, 04:22 PM
Post #25


Trained Member

Posts: 76
From: Nederland, NL
Joined: 1-May 12



Ok, thanks for all the help thumbsup.gif
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: