| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sat Aug 09, 2008 7:38 pm Post subject: C++ PMX to Delphi PMX |
|
|
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 |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Sat Aug 09, 2008 8:21 pm Post subject: |
|
|
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 |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Sat Aug 09, 2008 8:46 pm Post subject: |
|
|
@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 |
|
 |
GMZorita Grandmaster Cheater Supreme
Reputation: 0
Joined: 21 Mar 2007 Posts: 1361
|
Posted: Sun Aug 10, 2008 6:04 am Post subject: |
|
|
You guys do realize that you dont need the:
Right? _________________
Gone |
|
| Back to top |
|
 |
rapion124 Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Mar 2007 Posts: 1095
|
Posted: Sun Aug 10, 2008 7:57 am Post subject: |
|
|
| GMZorita wrote: | You guys do realize that you dont need the:
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 |
|
 |
Reak I post too much
Reputation: 0
Joined: 15 May 2007 Posts: 3496
|
Posted: Sun Aug 10, 2008 8:41 am Post subject: |
|
|
| 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 |
|
 |
Anden100 Grandmaster Cheater
Reputation: 0
Joined: 20 Apr 2007 Posts: 668
|
Posted: Sun Aug 10, 2008 9:29 am Post subject: |
|
|
| 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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Aug 10, 2008 12:08 pm Post subject: |
|
|
| 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 |
|
 |
|