__stdcall and name decoration

E

Eric Twietmeyer

Hello,

I am wondering how it is that all of the windows base dlls, like
kernel32.dll specify that all of their functions are __stdcall and yet the
exported names from the dll are not decorated with the preceeding underscore
and following @ parameter byte count.

When I export a function from my dll with __stdcall specified, the name is
something of the form "_funcname@4". If I export with __cdecl calling
convention I have simply "funcname" in the exported functions list (from
dumpbin).

But all of the Win32 functions specified in WinBase.h, for instance,
LoadLibraryA, are specified WINAPI, which expands to __stdcall. But doing
dumpbin on Kernel32.dll shows that the name is simply "LoadLibraryA" and not
"_LoadLibraryA@4", or whatever.

Am I misunderstanding something? Or is there some special compiler switch
that will not decorate __stdcall names when reported by dumpbin?

I would like to use the __stdcall calling convention but allow users of the
library to call GetProcAddress by passing the undecorated name, as is done
for functions from Kernel32.dll.

Thanks in advance,

-Eric Twietmeyer
 
J

Jeff Partch [MVP]

Eric Twietmeyer said:
Hello,

I am wondering how it is that all of the windows base dlls, like
kernel32.dll specify that all of their functions are __stdcall and yet the
exported names from the dll are not decorated with the preceeding underscore
and following @ parameter byte count.

When I export a function from my dll with __stdcall specified, the name is
something of the form "_funcname@4". If I export with __cdecl calling
convention I have simply "funcname" in the exported functions list (from
dumpbin).

But all of the Win32 functions specified in WinBase.h, for instance,
LoadLibraryA, are specified WINAPI, which expands to __stdcall. But doing
dumpbin on Kernel32.dll shows that the name is simply "LoadLibraryA" and not
"_LoadLibraryA@4", or whatever.

Am I misunderstanding something? Or is there some special compiler switch
that will not decorate __stdcall names when reported by dumpbin?

I would like to use the __stdcall calling convention but allow users of the
library to call GetProcAddress by passing the undecorated name, as is done
for functions from Kernel32.dll.

I think you can do it with a *.def file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top