Jump to content
Worm64

Call winapi functions from inline asm

Recommended Posts

Posted (edited)

A fost un mic pariu cu @Usr6.M-am gandit sa il postez aici pentru cine vrea sa foloseasca functii din windows.h in asm.


#include "windows.h"

char a2[]="usr6";
char a3[]="Salut";
int main()
{
__asm
{
mov eax,0
push eax
mov eax,offset a3
push eax
mov eax,offset a2
push eax
mov eax,0
push eax
call DWORD PTR MessageBox
pop ebx
pop ebx
pop ebx
pop ebx
}
}

Edited by Worm64
  • Upvote 1
Posted

Nu e nevoie sa pui totul in EAX inainte de push.

Iar eliberarea memoriei NU se face pentru WinAPI (ex, MessageBox) deoarece au calling convention __stdcall. Functiile din C au calling convention __cdecl si acolo e necesara acea secventa "pop ebx..." dar nu se face asa, se face mai rapid cu incrementarea ESP-ului: add ESP, 0x10 (adica 16 bytes).

Info:

1. Calling Conventions Demystified - CodeProject

2. Using Win32 calling conventions

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...