[ACCEPTED]-How to find the calling convention of a third party dll?-dll

Accepted answer
Score: 32

If the symbol begins with a _ but has no 3 @, then it's __cdecl. If it begins with _ and has 2 a @ it's __stdcall. If it begins with @ and has another 1 @, it's __fastcall.

source

Score: 2

While trying to figure out why I was getting 11 unresolved symbols when linking against 10 a third-party dll I stumbled upon a (sort 9 of) programmatic solution.

I wrote a small 8 program against the Windows API using UnDecorateSymbolName from 7 Dbghelp.hto decode the mangling scheme:

#include "Windows.h"
#include "Dbghelp.h"
#include "tchar.h"

int _tmain(int argc, _TCHAR* argv[])
{
    CHAR out[512];
    UnDecorateSymbolName(
        // Mangled symbol
        "?OFFReader@IO@OpenMesh@@YGAAV_OFFReader_@12@XZ",
        out,
        // Length of symbol
        46,
        UNDNAME_32_BIT_DECODE);
}

There are 6 definitely prettier ways to do it. I just 5 run it in a debugger and look at the contents 4 of out.

Also worth noting, contrary to Ignacio's 3 answer, the difference between the mangled 2 names for the cdecl methods in the dll and the 1 stdcall methods being looked for was YAAAV vs. YGAAV.

More Related questions