name-decoration

Can I programatically deduce the calling convention used by a C++ dll?

旧街凉风 提交于 2019-12-06 02:41:48
问题 Imagine you'd like to write a program that tests functions in a c++ dll file. You should enable the user to select a dll (we assume we are talking about c++ dlls). He should be able to obtain a list of all functions exported by the dll. Then, the user should be able to select a function name from the list, manually input a list of arguments ( the arguments are all basic types, like int, double, bool or char arrays (e.g. c-type strings) ) and attempt to run the selected function with the

Can't access variable in C++ DLL from a C app

自作多情 提交于 2019-12-05 04:49:10
I'm stuck on a fix to a legacy Visual C++ 6 app. In the C++ DLL source I have put extern "C" _declspec(dllexport) char* MyNewVariable = 0; which results in MyNewVariable showing up (nicely undecorated) in the export table (as shown by dumpbin /exports blah.dll). However, I can't figure out how to declare the variable so that I can access it in a C source file. I have tried various things, including _declspec(dllimport) char* MyNewVariable; but that just gives me a linker error: unresolved external symbol "__declspec(dllimport) char * MyNewVariable" (__imp_?MyNewVariable@@3PADA) extern "C"

GCC compiling a dll with __stdcall

♀尐吖头ヾ 提交于 2019-12-05 02:58:59
When we compile a dll using __stdcall inside visual studio 2008 the compiled function names inside the dll are. FunctionName Though when we compile the same dll using GCC using wx-dev-cpp GCC appends the number of paramers the function has, so the name of the function using Dependency walker looks like. FunctionName@numberOfParameters or == FunctionName@8 How do you tell GCC compiler to remove @nn from exported symbols in the dll? __stdcall decorates the function name by adding an underscore to the start, and the number of bytes of parameters to the end (separated by @). So, a function: void _

Cannot call DLL import entry, C# -> C++, EntryPointNotFoundException

微笑、不失礼 提交于 2019-12-02 22:17:06
问题 I'm trying to call from C# a function in a custom DLL written in C++. However I'm getting the warning during code analysis and the error at runtime: Warning: CA1400 : Microsoft.Interoperability : Correct the declaration of 'SafeNativeMethods.SetHook()' so that it correctly points to an existing entry point in 'wi.dll'. The unmanaged entry point name currently linked to is SetHook. Error: System.EntryPointNotFoundException was unhandled. Unable to find an entry point named 'SetHook' in DLL 'wi

Cannot call DLL import entry, C# -> C++, EntryPointNotFoundException

与世无争的帅哥 提交于 2019-12-02 11:38:54
I'm trying to call from C# a function in a custom DLL written in C++. However I'm getting the warning during code analysis and the error at runtime: Warning: CA1400 : Microsoft.Interoperability : Correct the declaration of 'SafeNativeMethods.SetHook()' so that it correctly points to an existing entry point in 'wi.dll'. The unmanaged entry point name currently linked to is SetHook. Error: System.EntryPointNotFoundException was unhandled. Unable to find an entry point named 'SetHook' in DLL 'wi.dll'. Both projects wi.dll and C# exe has been compiled in to the same DEBUG folder, both files reside

How do I increase the allowed decorated name length in VC9 (MSVC 2008)?

浪子不回头ぞ 提交于 2019-12-02 07:45:21
问题 I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's

How do I increase the allowed decorated name length in VC9 (MSVC 2008)?

◇◆丶佛笑我妖孽 提交于 2019-12-02 06:28:27
I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's the best way to get over this? For legacy code reasons, the MSDN suggestion of replacing typedefs with

Why GetProcAddress doesn't work?

霸气de小男生 提交于 2019-12-01 04:00:13
问题 First, I create a simple dll called SimpleDll.dll , its head file: // SimpleDll.h #ifdef MYLIBAPI #else #define MYLIBAPI __declspec(dllimport) #endif MYLIBAPI int Add(int a. int b); its source code: // SimpleDll.c #include <windows.h> #define MYLIBAPI __declspec(dllexport) #include "SimpleDll.h" int Add(int a, int b) { return a + b; } Then I call it in another project, and it works fine: // TestSimpleDll.c #include "stdafx.h" #include <windows.h> #include "SimpleDll.h" #pragma comment(lib,

C++ name space confusion - std:: vs :: vs no prefix on a call to tolower?

落花浮王杯 提交于 2019-11-30 21:23:52
Why is this? transform(theWord.begin(), theWord.end(), theWord.begin(), std::tolower); - does not work transform(theWord.begin(), theWord.end(), theWord.begin(), tolower); - does not work but transform(theWord.begin(), theWord.end(), theWord.begin(), ::tolower); - does work theWord is a string. I am using namespace std; Why does it work with the prefix :: and not the with the std:: or with nothing? thanks for your help. using namespace std; instructs the compiler to search for undecorated names (ie, ones without :: s) in std as well as the root namespace. Now, the tolower you're looking at is

Using C++ DLLs with different compiler versions

て烟熏妆下的殇ゞ 提交于 2019-11-29 04:40:34
This question is related to "How to make consistent dll binaries across VS versions ?" We have applications and DLLs built with VC6 and a new application built with VC9. The VC9-app has to use DLLs compiled with VC6, most of which are written in C and one in C++. The C++ lib is problematic due to name decoration/mangling issues. Compiling everything with VC9 is currently not an option as there appear to be some side effects. Resolving these would be quite time consuming. I can modify the C++ library, however it must be compiled with VC6. The C++ lib is essentially an OO-wrapper for another C