NO

Author Topic: Calling API functions in inline assembly code  (Read 4731 times)

Offline Vortex

  • Member
  • *
  • Posts: 864
    • http://www.vortex.masmcode.com
Calling API functions in inline assembly code
« on: February 27, 2022, 02:02:00 PM »
Hello,

Here is a quick example :

Code: [Select]
// Source code built with PellesC 11.00.2

#include <stdio.h>
#include <windows.h>
char t1[]="This is a test1.";
char t2[]="This is a test2.";

int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, WCHAR *pszCmdLine, int nCmdShow)
{
__asm{

push 0
push OFFSET t1
push OFFSET t1
        push 0
call DWORD PTR [MessageBox]
}

MessageBox(0,t2,t2,0);
return 0;
}

The API function MessageBox in the inline asm block should be enclosed between square brackets otherwise wrong call to API will lead to application crash.

Code it... That's all...