I read an article some time ago from a guy who demonstrated how one can directly call a function in user32.dll in assembly (NASM) by its memory address. I do not have the article anymore but I'm trying to reproduce the experiment.
The function I want to execute is MessageBoxA in user32.dll and on my computer, the function should be located at the address 0x76cd75c0.
Here is the function:
int MessageBoxA(
HWND hWnd, # NULL
LPCSTR IpText, # text
LPCSTR IpCaption, # title
UINT uType # style
);
Here is the program:
global _main
section .data
msgText: db 'Hello World', 0
msgCaption: db 'Title', 0
section .text
_main:
push 0
push msgCaption
push msgText
push 0
call 0x76cd75c0
add esp, 4
ret 0x10
For compiling the program I use:
nasm –f win32 message_box.asm
However, I receive this error message:
error: Win32 COFF does not correctly support relative references to absolute
addresses
It doesn't matter if I use the normal address or the relative address, I receive the same error message anyway.
Anybody who knows what's the problem?