binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

demangle_ms not properly handling calling conventions

Open 0x1F9F1 opened this issue 6 years ago • 2 comments

Binary Ninja Version: 1.1.1762-dev, 49d18786 Platform: Windows 10 (10.0)

When calling demangle_ms, the returned Type just returns None for .calling_convention, although .tokens does show it.

>>> demangled = demangle_ms(Architecture['x86'], '?TestFunction@@YAIXZ')
>>> demangled
(<type: uint32_t __cdecl (void)>, ['TestFunction'])
>>> demangled[0].calling_convention is None
True
>>> demangled = demangle_ms(Architecture['x86'], '??0Callback@@QAE@XZ')
>>> demangled
(<type: public: __thiscall (void)>, ['Callback', 'Callback'])
>>> demangled[0].calling_convention is None
True

0x1F9F1 avatar Jul 09 '19 19:07 0x1F9F1

Yeah this is the line of code that does that:

result->m_callingConventionName = NoCallingConvention; //TODO: add calling convention stuff

This is slightly tricky because we don't really want to trust mangled names, because they can lie, especially with "thiscall" it will take some thought to do this properly.

plafosse avatar Jul 09 '19 19:07 plafosse

I see. Is there any way to query the raw calling convention name in the meantime?

0x1F9F1 avatar Jul 09 '19 19:07 0x1F9F1

Fixed in 3.1.3761

plafosse avatar Oct 13 '22 16:10 plafosse