Calling Win32 API from Assembly Language
How do I call a win32 API function from assembly language?
Basically I need to call functions from kernel32.dll from assembly language.
How do I call a win32 API function from assembly language?
Basically I need to call functions from kernel32.dll from assembly language.
Win32 APIs are just stdcall C functions , so this is a specific instance of a more general question: how to call a C-function form another DLL w/ stdcall calling convention from assembly.
In general, The easiest way to answer "how do i do X" in assembly is to do X in C and then look at the generated assembly from the C compiler under a debugger (in Visual Studio, you can right click and do "Show Disassembly".
The exact syntax will depend on your assembler.
SachinPatole
Please bear in mind that I am very biased, having written a suite of free tools to write whole Windows programs in assembler.
These are the "Go" tools available from here.
In fact, writing Windows programs in assembler is simple, and fun! Here you are using a very low level language (assembler), combined with a very high level language (Windows) - a perfect combination. Actually, I have added to my tools several enhancements to make Windows programming easier.
Anyway, to get back to your question, here is a call to MessageBoxW showing how easy it is to do (as an example):-
INVOKE MessageBoxW, [hWnd], L'Message title', L'Hello SachinPatole', 40h
You could replace the 40h with the appropriate constant name if you prefer (information sign and ok button). If you specify STRINGS+UNICODE you don't need the L in the strings.
Jeremy Gordon