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 


Inline Assembly/

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

Joined: 26 May 2009
Posts: 37

PostPosted: Fri Jul 31, 2009 12:42 pm    Post subject: Inline Assembly/ Reply with quote

Code:

__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %ebp, %esp;"
        "jmp DWORD PTR [myAddress];"
        );

}


How do I place a jump in at&t syntax, searched for a long time... compiler keeps telling me that PTR is junk lolz.
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Jul 31, 2009 12:54 pm    Post subject: Re: Inline Assembly/ Reply with quote

azfk wrote:
Code:

__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %ebp, %esp;"
        "jmp DWORD PTR [myAddress];"
        );

}


How do I place a jump in at&t syntax, searched for a long time... compiler keeps telling me that PTR is junk lolz.


__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
__asm{
push ebp
mov ebp,esp
jmp DWORD PTR [myAddress]
}

}
Back to top
View user's profile Send private message
azfk
Cheater
Reputation: 0

Joined: 26 May 2009
Posts: 37

PostPosted: Fri Jul 31, 2009 1:05 pm    Post subject: Reply with quote

GCC compiler = at&t
Back to top
View user's profile Send private message
Cheat Engine User
Something epic
Ban
Reputation: 61

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Fri Jul 31, 2009 1:20 pm    Post subject: Reply with quote

jmpl myAddress(,1)
Back to top
View user's profile Send private message
azfk
Cheater
Reputation: 0

Joined: 26 May 2009
Posts: 37

PostPosted: Fri Jul 31, 2009 1:49 pm    Post subject: Reply with quote

HOHO GREAT

that works but.. now i'm getting some dumb error


Code:

DWORD myAddress = NULL;

__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %esp, %ebp;"
        "jmpl myAddress(,1);"
        );
}

int main(void)
{
    int length, repeats, c, a, dwMilliseconds;
    CHAR string_input [1024];


Says 'undefined reference to myaddress' but i thought i made it global O.O
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Fri Jul 31, 2009 5:19 pm    Post subject: Reply with quote

why is MyAddress NULL.
_________________
Back to top
View user's profile Send private message
azfk
Cheater
Reputation: 0

Joined: 26 May 2009
Posts: 37

PostPosted: Fri Jul 31, 2009 5:57 pm    Post subject: Reply with quote

I thought i had to initialize it as NULL

Code:

#define _WIN32_WINNT 0x0501

#include <windows.h>
#include <string.h>

DWORD myAddress;

__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %esp, %ebp;"
        "jmpl myAddress(,1);"
        );
}

int main(void)
{
    int length, repeats, c, a, dwMilliseconds;

    myAddress = (DWORD)GetProcAddress(LoadLibrary("user32.dll"),"SendInput")+5;


taking stabs here
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Fri Jul 31, 2009 7:25 pm    Post subject: Reply with quote

azfk wrote:
I thought i had to initialize it as NULL

Code:

#define _WIN32_WINNT 0x0501

#include <windows.h>
#include <string.h>

DWORD myAddress;

__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %esp, %ebp;"
        "jmpl myAddress(,1);"
        );
}

int main(void)
{
    int length, repeats, c, a, dwMilliseconds;

    myAddress = (DWORD)GetProcAddress(LoadLibrary("user32.dll"),"SendInput")+5;


taking stabs here


does that still not work? And you didn't even show initializing myAddress to something other than NULL in the other example

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

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sat Aug 01, 2009 1:26 pm    Post subject: Reply with quote

Code:
mov eax,myAddress
jmp eax

or
Code:
mov eax,[myAddress]
jmp eax

Not sure

oib111 posted this, might be a help aswell:
Code:
DWORD myDIP = (DWORD)GetProcAddress(LoadLibrary("d3d9.dll"), "DrawIndexedPrimitive")+5;

_declspec(naked) HRESULT DIP(D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount) {
   _asm {
      push ebp
      mov ebp, esp
      jmp dword ptr ds:[myDIP];
   }
}
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Sat Aug 01, 2009 7:45 pm    Post subject: Reply with quote

bad code.. globals..use all the code in separated functions..
_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
azfk
Cheater
Reputation: 0

Joined: 26 May 2009
Posts: 37

PostPosted: Sat Aug 01, 2009 8:55 pm    Post subject: Reply with quote

umm this code is determined at runtime (the address), not at compile, and I did put this code outside like this

Code:

#include <windows.h>
#include <string.h>

DWORD myAddress = (DWORD)GetProcAddress(LoadLibrary("user32.dll"),"SendInput")+5;


__declspec(naked) void SendInputM(UINT nInputs, LPINPUT pInputs, int cbSize)
{
    asm(
        "pushl %ebp;"
        "movl %esp, %ebp;"
        "jmpl myAddress(,1);"
        );
}


but i recently noticed that, I thought I would put it inside the main function, I know some compilers allow this, I'll just switch compilers I guess.
Back to top
View user's profile Send private message
BanMe
Master Cheater
Reputation: 0

Joined: 29 Nov 2005
Posts: 375
Location: Farmington NH, USA

PostPosted: Sat Aug 01, 2009 9:55 pm    Post subject: Reply with quote

cant do that..unless you make the strings for it in the code..so that when the hook is written to the target code it doesnt rely on 'data that isnt there'...so you can't just force inline the GetProcAddress function like your thinking...you could use a heap by allocating it dynamicily in the hook routine using RtlProcessHeap..and RtlAllocateHeap you could then use the heap to store your strings or other parameters or w/e..or you could make your dll always load at a certain location and use hardcode offsets..
_________________
don't +rep me..i do not wish to have "status" or "recognition" from you or anyone.. thank you.
Back to top
View user's profile Send private message MSN Messenger
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