Is it possible to do something like this:
.data?
myPointer dd ?
myPointer PROTO :DWORD, :DWORD, :DWORd
.code
GetModuleHandle ....
GetProcAddress .....
mov myPointer, eax
invoke myPointer, arg1, arg2, arg3
rather than having to push?
This example doesn't work for me.
Thanks!
I don't believe it will in any case, not sure why though. If you don't mind using macros, there are several "invoke" simulators/clones available from many authors on this board.
Hope this helps, Ehtyar.
I'll check the macros out. Thanks Eht. Btw, how have you been? Haven't talked to you on irc in a while. I gave up with Firebot and got a new laptop and 2 rats.
Here's what I do.
t_myproc typedef proto :dword,:dword,:dword
p_myproc typedef ptr t_myproc
.data?
myproc p_myproc ?
.code
...
invoke myproc,1,2,3
This is how you can call externals (e.g. API's) directly (e.g. CALL [00402020]) instead of indirectly.
Yay! Thank you sinsi.
I wonder though if there is a way to do it shorter like perhaps
pCreateDevice (ptr Direct3DCreate9) ?
I tried that though and it doesn't work.
I'll do some experimenting and get back to you guys if I find anything worthwhile
:U
Another question, sorry if I am asking so many.
How can I force masm to make my exe load a dll even though I never call an export from it.
I don't want to use loadlibrary or any api.
I mean, I want to make windows loader automatically load that dll for my program.
I found that I can just put a call SomeExport in the code section and that'll do it but it's a dirty hack. Any better ways?
Quote from: jag on February 08, 2007, 03:45:16 AM
How can I force masm to make my exe load a dll even though I never call an export from it.
I don't want to use loadlibrary or any api.
I mean, I want to make windows loader automatically load that dll for my program.
Why would you want to do that?
I'm debugging another program and the program creates a com object using a dll at a later time (it doesn't load the dll right away.)
I want my program to put some hooks on the functions from that dll.
I don't actually want to call any functions from the dll though.
I just want to apply some hooks.
Quote from: jag on February 08, 2007, 04:26:09 AM
I'm debugging another program
Uh-uh...sounds like a bit of RE...sorry, no can help.
Hey Jag :D Saw you were in klepto today, but missed ya. Hopefully catch you soon. Thanks for the help sinsi :)
Ehtyar.
Here is my method using invoke :
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.data
user32 db 'user32.dll',0
function db 'MessageBoxA',0
caption db 'Hello!',0
message db 'MessageBoxA called via pointer',0
MsgBox db 0FFh,025h ; define manually a jump entry
dd pMessageBox
MessageBox EQU <pr4 PTR MsgBox>
.data?
hLib dd ?
pMessageBox dd ?
.code
start:
invoke LoadLibrary,ADDR user32
mov hLib,eax
invoke GetProcAddress,eax,ADDR function
mov pMessageBox,eax
invoke MessageBox,0,ADDR message,ADDR caption,0
invoke FreeLibrary,hLib
invoke ExitProcess,0
END start
[attachment deleted by admin]