Search code examples
c++dlldllexportdumpbin

why the @number symbol at the end of an exported dll function


I have a dll that contains more then 400 function, and my exe file is using only 15 function from the dll, so i need to create a new dll and export the functions and fake their return values to simulate an output of a more complex system.

What i have tried :

 #include "stdafx.h"

//the compiler complains about the '@20'

__declspec ( dllexport ) XLStatus _xlActivateChannel@20(XLportHandle,  XLuint64, unsigned int, unsigned int)
{
    return 0;
} 

// causing the exe to crash

dumpbin /exports vxlapi.dll (original dll): show duplicate function names (not for all functions)

ordinal  name
         _xlActivateChannel@20
14       xlActivateChannel

Note : in the header file of the dll, the functions are declared like so:

DECL_STDXL_FUNC ( xlActivateChannel, XLACTIVATECHANNEL, (
                  XLportHandle  portHandle,
                  XLaccess      accessMask,
                  unsigned int  busType,
                  unsigned int  flags)
                  );

in dumpbin / export dll why there are function names starting with an '_' underscore and ending with '@number' , Note: the exe is using the let's say(decorated) functions, and how can i create a new dll and export functions that contains @,


Solution

  • The "@n" is used by the stdcall calling convention. You don't need to mention it in your declaration, you just need to change your declaration to stdcall so that the compiler knows they need to be decorated with "@n" suffixes. Like this:

    __declspec ( dllexport ) XLStatus __stdcall _xlActivateChannel(XLportHandle,  XLuint64, unsigned int, unsigned int)