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 


C++ PMX to Delphi PMX

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Sat Aug 09, 2008 7:38 pm    Post subject: C++ PMX to Delphi PMX Reply with quote

So I tryed to convert the dll. So I was wondering would this work:

Code:
function PostMessageX(
hWnd:HWND;
MSG:UINT;
WPARAM:wParam;
LPARAM:lParam):BOOL;stdcall;
var
PMA:pointer;
adr:cardinal;
Begin
PMA:=GetProcAddress(LoadLibrary('USER32.DLL'),'PostMessageA');
asm
mov eax,PMA
add eax,5
mov adr,eax
end;
asm
mov edi, edi
push ebp
mov ebp, esp
jmp PMA
end;
end;


And Im having trouble exporting it so... Can't test it.
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Sat Aug 09, 2008 8:21 pm    Post subject: Reply with quote

Edit* Oopps sorry.


Code:


function PostMessageX( Wnd:HWND; MSG:UINT; WPARAM:wP; LPARAM: lP ):BOOL;stdcall;
var
PMA: ULONG;
Begin
PMA:= (DWORD( GetProcAddress(LoadLibrary('USER32.DLL'),'PostMessageA'))) + 5;
asm
mov edi, edi
push ebp
mov ebp, esp
jmp PMA
end;
end;



Last edited by slippppppppp on Sun Aug 10, 2008 12:11 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address MSN Messenger
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat Aug 09, 2008 8:46 pm    Post subject: Reply with quote

@slippppppppp:
You should initialize the re-entry address during initialization. It's more efficient that way.

Code:

DWORD dwPostMessageA = DWORD(GetProcAddress(GetModuleHandle("user32.dll"), "PostMessageA"));
DWORD dwPostMessageAR = dwPostMessageA + 5;

__declspec(naked) BOOL WINAPI __stdcall PostMessageAT( HWND hWnd, UINT Msg, LPARAM lParam, WPARAM wParam)
{
    __asm
    {
        mov edi, edi
        push ebp
        mov ebp, esp
        jmp [dwPostMessageAR]
    }
}


With Delphi, add the assembler directive to the prototype.
Back to top
View user's profile Send private message
GMZorita
Grandmaster Cheater Supreme
Reputation: 0

Joined: 21 Mar 2007
Posts: 1361

PostPosted: Sun Aug 10, 2008 6:04 am    Post subject: Reply with quote

You guys do realize that you dont need the:
Code:
mov edi, edi

Right?

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

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sun Aug 10, 2008 7:57 am    Post subject: Reply with quote

GMZorita wrote:
You guys do realize that you dont need the:
Code:
mov edi, edi

Right?


It's a place holder so the bytes align to 5 for hot patching. So? Doesn't hurt to include it. Who knows, you might want to hook your own hook lolz.
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Sun Aug 10, 2008 8:41 am    Post subject: Reply with quote

Code:
function PMH(hWnd:HWND;MSG:UINT;WPARAM:wParam;LPARAM:lParam):BOOL; stdcall;
asm
        jmp @start
        @dllhk: db 'user32.dll',0
        @cmd: db 'PostMessageA',0
        @start:
        lea eax, @dllhk
        push eax
        call LoadLibraryA
   lea ecx, @cmd
        push ecx
        push eax
        call GetProcAddress
        add eax,5
        jmp eax
end;


Some guy helped me with this though.
Back to top
View user's profile Send private message
Anden100
Grandmaster Cheater
Reputation: 0

Joined: 20 Apr 2007
Posts: 668

PostPosted: Sun Aug 10, 2008 9:29 am    Post subject: Reply with quote

rEakW0n wrote:
Code:
function PMH(hWnd:HWND;MSG:UINT;WPARAM:wParam;LPARAM:lParam):BOOL; stdcall;
asm
        jmp @start
        @dllhk: db 'user32.dll',0
        @cmd: db 'PostMessageA',0
        @start:
        lea eax, @dllhk
        push eax
        call LoadLibraryA
   lea ecx, @cmd
        push ecx
        push eax
        call GetProcAddress
        add eax,5
        jmp eax
end;


Some guy helped me with this though.


Kinda messy with so much asm O.o, ive been using this for ages:
Code:
function PMX(
hWnd:HWND;
MSG:UINT;
WPARAM:wParam;
LPARAM:lParam):BOOL;stdcall;
var DblWord:DWORD;
    hHandle:THandle;
begin
hHandle:=LoadLibrary('user32.dll');
DblWord:=DWORD(GetProcAddress(hHandle,'PostMessageA'))+5;
 asm
 mov edi,edi
 push ebp
 mov esp,ebp
 jmp [DblWord]
 end;
end;
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Sun Aug 10, 2008 12:08 pm    Post subject: Reply with quote

slippppppppp wrote:
Edit* Oopps sorry.


Code:


function PostMessageX( Wnd:HWND; MSG:UINT; WPARAM:wP; LPARAM: lP ):BOOL;stdcall;
var
PMA: ULONG;
Begin
PMA:=GetProcAddress(LoadLibrary('USER32.DLL'),'PostMessageA') + 5;
asm
mov edi, edi
push ebp
mov ebp, esp
jmp PMA
end;
end;



Edit: Oh sorry ddn't see u made it into dword.
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