The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: hot_emil on January 01, 2006, 10:32:10 PM

Title: calling function specifying the address
Post by: hot_emil on January 01, 2006, 10:32:10 PM
HI. Happy New year!
How can i call a function lets say MessageBoxA specifying its address , lets say
push MB_OK
push offset Msg
push  offset Msg2
push 0
call[its address here]
someone said to me that address is 077E8B6A7h.But i still cant call that way
waiting for reply 
Title: Re: calling function specifying the address
Post by: zooba on January 01, 2006, 10:39:35 PM
Any of the following:

invoke MessageBoxA, 0, offset Msg2, offset Msg, MB_OK

push MB_OK
push offset Msg
push offset Msg2
push 0
call MessageBoxA


invoke LoadLibrary, offset szUSER32DLL  ; szUSER32DLL byte "user32.dll", 0
invoke GetProcAddress, eax, offset szMessageBoxA ; szMessageBoxA byte "MessageBoxA", 0
push MB_OK
push offset Msg
push offset Msg2
push 0
call eax
; Notice that 'invoke' won't accept 'eax' as a function name


The first one has the advantage of simplicity and type-checking (assuming you're using the include files), the last has the advantage of being dynamically linked rather than statically linked. The second one is the 'old-fashioned' way but it still has its uses (but they're quite advanced :wink)

Cheers,

Zooba
Title: Re: calling function specifying the address
Post by: hot_emil on January 01, 2006, 10:51:37 PM
heheh. Thx for answer. but it is not what i want.
I said MessageBoxA is forexample. Maybe i dont know it is name.And i dont know its library name , then how can i use GetProcAddress.
Lets say I want to call a function of the game. I dont know its name and Library. i want to call it by specifying its address.
I seeked the address of MessageBoXA from Debugger , but still cant call,
for example

push ebp
mov ebp,esp
xor edi,edi
push edi
mov byte ptr[ebp-04h],48h
mov byte ptr[ebp-03h],69h
mov byte ptr[ebp-02h],21h
mov edx, 077E8B6A7h  (address of MessageBox as i know)
push edx
push edi
lea edx,[ebp-04h]
push edx
push edx
push edi
call dword ptr[ebp-08h]

but it fails to run
Title: Re: calling function specifying the address
Post by: zooba on January 01, 2006, 10:54:37 PM
Quote from: hot_emil on January 01, 2006, 10:51:37 PM
Maybe i dont know it is name.And i dont know its library name

If you don't know its name or library name, it probably doesn't belong to you. You've mentioned game, are you attempting to make a trainer? You won't get much of an answer around here unkess you explain exactly what it is you're doing.

Cheers,

Zooba
Title: Re: calling function specifying the address
Post by: hot_emil on January 01, 2006, 11:02:50 PM
I play one game. And want to move units with program. I have to know where the function  resides-its address , to call it.
I began it first with MessageBoxa, if it is success, i will make it with that "move" function.
SO how can i call that damn "move" function?
Title: Re: calling function specifying the address
Post by: MichaelW on January 02, 2006, 09:22:02 AM
hot-emil,

I'm not sure just what you are trying to do here, but I have a strong suspicion that it's not good, or even legal. If it's not your game then you need to leave it alone. If it is your game then you have no need to do what you are asking about. Topic locked.

Title: Re: calling function specifying the address
Post by: P1 on January 02, 2006, 03:19:40 PM
Which game ???

Regards,  P1  :8)