0

I'm working on a DLL which contains function DLLEXPORT void* GetBase(HANDLE hProc) and when I compile it, I open it with Dependency Walker, and there's no function with name "GetBase". I can see only "?GetBase@@YAPAXPAX@Z". What's wrong with this? I'm using Visual C++ 2013 and I compiled it as release.

Smax Smaxović
  • 490
  • 2
  • 7
  • 16
  • You are building your code as C++. Is the file extension .cpp or .c? – cup Mar 26 '14 at 17:55
  • The file extension is ".cpp". – Smax Smaxović Mar 26 '14 at 17:56
  • 1
    This is entirely normal, a C++ compiler will *decorate* a function name. Necessary so that overloaded methods will have different linkage names. Use `extern "C"` to suppress it. Don't suppress it, it is a good way to avoid trouble when you change the function declaration and not update the code that uses it. – Hans Passant Mar 26 '14 at 17:57
  • Well, I used extern C and opened the file in Dependency walker. Now it doesnt show up anything. – Smax Smaxović Mar 26 '14 at 18:04
  • The other way is to just rename the file extension to .c and build it as a C DLL. – cup Mar 26 '14 at 21:10

1 Answers1

0

There's nothing "wrong" with your function. It's been "mangled"; in other words, the compiler's added type information to your function name. This is how C++ supports overloading: functions with the same name, but taking different parameters, will have different mangled function names.

Your DLL might also have debug info attached, which could be another source of name mangling.

With all that said, the "c" tag on your question is bothersome; C doesn't have overloading and as such doesn't need name mangling.

Community
  • 1
  • 1
cf stands with Monica
  • 7,919
  • 8
  • 29
  • 56