Closed agaertner closed 5 months ago
I am trying to call exported functions from my C++ program. However, it crashes/freezes on call.
I have setup a few test methods to check if the dll works at all and it already crashes on the very first test which is one without a signature.
code snippet .NET Framwork 4.7.2
[DllExport("TestFunc1", CallingConvention.StdCall)] [return: MarshalAs(UnmanagedType.LPUTF8Str)] public static string TestFunc1() { return string.Empty; }
In C++:
// .h extern "C" { typedef char* (__cdecl *exTestFunc1)(); } class DllMngr { public: char* testFunc1(); private: HINSTANCE m_dllHandle; exTestFunc1 m_exTestFunc1; } // .cpp m_exTestFunc1 =reinterpret_cast<exTestFunc1>(fetchMethodHandle("TestFunc1", l_result)); char* DllMngr::testFunc1() { if (!m_dllHandle) { return "Dll not loaded."; } return m_exTestFunc1(); } // call char* l_test1 = m_DllMngr->testFunc1();
I believe there might be some incompatibilities or the export settings are wrong. Do note that my dll handles are valid and my method handles are valid as well. Everything gets loaded correctly before trying to call it.
Any help would be appreciated.
The project I load the dll in is x86
. . .
The question is related to:
DllExport -version
Data
Installed: True; 1.7.4+c1cc52f; invoked: Project type: Cs Storage: ProjectFiles Compiler.Platform: x86 Compiler.ordinalsBase: 1 Compiler.rSysObj: False Compiler.ourILAsm: False Compiler.customILAsm: Compiler.genExpLib: False Compiler.peCheck: PeIl Compiler.patches: None PreProc.Type: None PreProc.Cmd: PostProc.Type: None PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath) PostProc.Cmd: SignAssembly: Identifier: 0F4F22C1-DBBF-4C9D-A96F-07554B0D45DF Instance: C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\amd64\MSBuild.exe Project path: C:\_dev\lib_ext\crypto\GNUPG_Decrypt\0.0.1.0\Source\GNUPG_Decrypt.csproj Action: Configure PlatformTarget: x86 TargetFramework: TargetFrameworks: TargetFrameworkVersion: v4.7.2 RootNamespace: GNUPG_Decrypt AssemblyName: GNUPG_Decrypt MgrArgs: -packages libs -dxp-version actual -action Configure MetaLib: tools\raw\lib\net20\DllExport.dll MetaCor: tools\raw\lib\netstd\DllExport.dll Proxy: StoragePath: .net.dllexport.targets ddNS: GNUPG_Decrypt ddNS max buffer: 500 UseCecil: True intermediateFiles: False timeout: 30000 Options: None RootPath: C:\_dev\lib_ext\crypto\GNUPG_Decrypt\0.0.1.0\Source\ PkgPath: C:\_dev\lib_ext\crypto\GNUPG_Decrypt\0.0.1.0\Source\libs\\DllExport\ SlnFile: SlnDir: C:\_dev\lib_ext\crypto\GNUPG_Decrypt\0.0.1.0\Source\ DxpTarget: tools\net.r_eg.DllExport.targets MsgGuiLevel: -1 LockIfError:
I got it to work in a little test C++ project created with Visual Studio 2012. The project where it doesn't work was created with Embarcadero XE2.
I am trying to call exported functions from my C++ program. However, it crashes/freezes on call.
I have setup a few test methods to check if the dll works at all and it already crashes on the very first test which is one without a signature.
code snippet .NET Framwork 4.7.2
In C++:
I believe there might be some incompatibilities or the export settings are wrong. Do note that my dll handles are valid and my method handles are valid as well. Everything gets loaded correctly before trying to call it.
Any help would be appreciated.
The project I load the dll in is x86
. . .
The question is related to:
DllExport -version
: 1.7.4.29858+c1cc52fData
tab: