I have some code (I assume Delphi) which uses only the EAX and EDX register for passing the arguments (and of course the stack if more are required). I looked which calling conventions would match, but I haven't found one which uses only EAX and EDX. AFAIK Borland fastcall/register is using EAX and EDX, but also ECX, which is not the case here.Can I tell IDA somehow about this calling convention? How would I do this?
Which calling convention to use for EAX/EDX in IDA
ida;calling conventions
you can add a function type by editing it (Key Y) and adding the name.I wrote a page to remind me about calling conventions at ASM level.Introductionthe original call is myfunc(0,1,2,3,4).standard order is first argument is pushed last.standard stack adjusting is 'callee cleanup' - after returning, the stack should be without its calling arguments. Note: the stack looks vertically like the call order.stdcall (stack only)push    4push    3push    2push    1push    0call    myfuncxor     eax,eaxretn    10Fastcall (ecx, edx)This is actually Microsoft's fastcall.push    4push    3push    2mov     edx,1xor     ecx,ecxcall    myfuncxor     eax,eaxretn    10CDECL & syscall (caller cleanup)push    4push    3push    2push    1push    0call    myfuncadd     esp,014xor     eax,eaxretn    10Pascal (reverse order, ebx saved, even if ebx is unused...)push    ebxpush    0push    1push    2push    3push    4call    myfuncxor     eax,eaxpop     ebxretn    10Fortran/watcall (eax, edx, ebx, ecx, then stack - ebx is saved)Apparently it's not so clear what the fortran calling convention is, and this one is even different from raymond's post's The __fortran calling convention isn't the calling convention used by FORTRAN.push    ebxpush    4mov     ecx,3mov     ebx,2mov     edx,1xor     eax,eaxcall    myfuncxor     eax,eaxpop     ebxretn    10Delphi 'registers' calling convention (default)Uses eax, ecx, edx as first 3 arguments. Other arguments are pushed on stack in reverse order.push    3push    4mov     ecx, 2mov     edx, 1xor     eax,eaxcall    myfuncxor     eax,eaxretn    10