Hey guys im working on creating a new function in legacy visual C++ 6.0 dll project, so that a C# dll can call into, however i unable to do so due to name mangling and it seems no matter what I do I can’t stop it, (i used dumpbin to view the names) here is the relevant code
this is a really trimmed down verstion of the header file
#ifdef _V7SSCOMM_CPP_
#define _DECL_V7COMM_DLL __declspec(dllexport)
#else
#define _DECL_V7COMM_DLL __declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
_DECL_V7COMM_DLL DWORD V7ssGetFileDirInfoUnicode(LPCSTR szSign, V7_FILE_LIST_TYPE eListType, LPCSTR szServer, LPCSTR szLibrary, LPCSTR szExt, DWORD *pdwFileCnt, wchar_t *pbyFileBuf, DWORD *pdwFileBufSize);
#ifdef __cplusplus
}
#endif
#endif
and for the cpp file
_DECL_V7COMM_DLL DWORD V7ssGetFileDirInfoUnicode(LPCSTR szSign,
V7_FILE_LIST_TYPE eListType,
LPCSTR szServer, LPCSTR szLibrary, LPCSTR szExt,
DWORD *pdwFileCnt, wchar_t *pbyFileBuf, DWORD *pdwFileBufSize)
{
if (!szSign || !szServer || !szLibrary || !szExt || !pdwFileCnt || !pbyFileBuf || !pdwFileBufSize)
return (RPC_S_INVALID_ARG);
error_status_t Error = rpcGetFileDirInfoUnicode(
/* [in] */ g_hRpcBinding,
/* [in, string] */ (unsigned char *)szSign,
/* [in] */ (unsigned long)eListType,
/* [in, string] */ (unsigned char *)szServer,
/* [in, string] */ (unsigned char *)szLibrary,
/* [in, string] */ (unsigned char *)szExt,
/* [out] */ (unsigned long *)pdwFileCnt,
/* [out, size_is(*pdwFileBufSize)] */ (wchar_t *)pbyFileBuf,
/* [in, out] */ (unsigned long *)pdwFileBufSize);
return (Error);
} // end V7ssGetFileDirInfoUnicode()
dumpbin returns the following
1 0 00001401 ?V7ssGetFileDirInfoUnicode@@YAKPBDW4tag_V7_FILE_LIST_TYPE@@000PAKPAG2@Z
not what i wanted ideally it would only be V7ssGetFileDirInfoUnicode
As far as i can tell and from what i have been reading the way i trying to do this means i don’t need to define this in the .def file. What is odd, is im following the same extact setup as pre-existing functions that show up correctly.
I would be grateful for any help.Thanks!
Update
the .def file option works as far as not name mangling, that being said the MIDL compiler is not creating the RPC stub, I think these two issues are related.
also here is the MIDL version, taken from the C file iteself
/* this ALWAYS GENERATED file contains the RPC server stubs */
/* File created by MIDL compiler version 5.01.0164 */
/* at Wed Sep 21 08:57:22 2011
*/
/* Compiler settings for V7Rpc.idl:
Os (OptLev=s), W1, Zp8, env=Win32, ms_ext, c_ext
error checks: allocation ref bounds_check enum stub_data
*/
//@@MIDL_FILE_HEADING( )
If you are certain that you included the header file from the
.cppfile, then you might try adding a.deffile to your project. There might be other ways, but that has always seemed to be a critical part in reducing the name mangling in the exports. The contents would look something like this.