News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

calling function specifying the address

Started by hot_emil, January 01, 2006, 10:32:10 PM

Previous topic - Next topic

hot_emil

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 

zooba

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

hot_emil

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

zooba

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

hot_emil

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?

MichaelW

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.

eschew obfuscation

P1