Download

[crash] Calling c# function with c++ in 32bit system

Hello everyone!
i was programming custom c# functions that not implemented in c++ by unreal engine 4
So i tried to look dll linking tutorials and did setup.
This is works 64 bit dll and game build, but not same for 32bit builds.
i did check dll is 32bit and confirmed with dependencywalker. also i checked game build is 32bit.
but when i’m trying to call a c# function ingame, it goes crash and cant understand why it is.
this could be engine bug?
The code that works with 64 bits:


 

  1. FString UCreateAndLinkDLLTutBFL::GetHash256(FString parameterText)
  1. {
  1. char* parameterChar = TCHAR_TO_ANSI(*parameterText);
  1. typedef char*(*_ComputeSha256Hash)(char* parameterText);
  1. void *DLLHandle = NULL;
  1. if (FPaths::FileExists(GetFilePath()))
  1. {
  1. DLLHandle = FPlatformProcess::GetDllHandle(*GetFilePath());
  1. }
  1. if (DLLHandle != NULL)
  1. {
  1. _ComputeSha256Hash DLLFuncPtr = NULL;
  1. FString procName = "ComputeSha256Hash";
  1. DLLFuncPtr = (_ComputeSha256Hash)FPlatformProcess::GetDllExport(DLLHandle, *procName);
  1. if (DLLFuncPtr != NULL)
  1. {
  1. char* returnChar = DLLFuncPtr(parameterChar);
  1. return (ANSI_TO_TCHAR(returnChar));
  1. FPlatformProcess::FreeDllHandle(DLLHandle);
  1. }
  1. }
  1. return "failedread"; // Return an error.
  1. }

 

And the crash log that 32bit build


 

  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: === Critical error: ===
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error:
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: Fatal error!
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error:
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000002c
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error:
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000000f7c406 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x00000000013c5b8f Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000001a198b5 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000001a1be72 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x000000000181b80e Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x00000000019f9d58 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000001a1bcfe Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x00000000019f9a26 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000003339c28 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000003ba37e0 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000003b937a7 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x00000000033236cf Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error: [Callstack] 0x0000000003e93fc9 Axee24.exe!UnknownFunction ]
  1. [2020.04.25-19.08.32:481] 77]LogWindows: Error:
  1. [2020.04.25-19.08.32:488] 77]LogExit: Executing StaticShutdownAfterError
  1. [2020.04.25-19.08.32:489] 77]LogWindows: FPlatformMisc::RequestExit(1)
  1. [2020.04.25-19.08.32:489] 77]LogCore: Engine exit requested (reason: Win RequestExit)
  1. [2020.04.25-19.08.32:492] 77]Log file closed, 04/25/20 22:08:32

 

there is no other explanatory log. What i am missing?

google “using COM dll in c++”

Already implemented and its work with 64 bit.
Just crashes when game is running 32 bit build. also this not fault to dll, because it crashes before reading the dll.