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 bit:
FString UCreateAndLinkDLLTutBFL::GetHash256(FString parameterText)
{
char* parameterChar = TCHAR_TO_ANSI(*parameterText);
typedef char*(*_ComputeSha256Hash)(char* parameterText);
void *DLLHandle = NULL;
if (FPaths::FileExists(GetFilePath()))
{
DLLHandle = FPlatformProcess::GetDllHandle(*GetFilePath());
}
if (DLLHandle != NULL)
{
_ComputeSha256Hash DLLFuncPtr = NULL;
FString procName = "ComputeSha256Hash";
DLLFuncPtr = (_ComputeSha256Hash)FPlatformProcess::GetDllExport(DLLHandle, *procName);
if (DLLFuncPtr != NULL)
{
char* returnChar = DLLFuncPtr(parameterChar);
return (ANSI_TO_TCHAR(returnChar));
FPlatformProcess::FreeDllHandle(DLLHandle);
}
}
return "failedread"; // Return an error.
}
And the crash log that 32bit build
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: === Critical error: ===
[2020.04.25-19.08.32:481][ 77]LogWindows: Error:
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: Fatal error!
[2020.04.25-19.08.32:481][ 77]LogWindows: Error:
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000002c
[2020.04.25-19.08.32:481][ 77]LogWindows: Error:
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000000f7c406 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000013c5b8f Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a198b5 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a1be72 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x000000000181b80e Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000019f9d58 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a1bcfe Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000019f9a26 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003339c28 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003ba37e0 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003b937a7 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000033236cf Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003e93fc9 Axee24.exe!UnknownFunction []
[2020.04.25-19.08.32:481][ 77]LogWindows: Error:
[2020.04.25-19.08.32:488][ 77]LogExit: Executing StaticShutdownAfterError
[2020.04.25-19.08.32:489][ 77]LogWindows: FPlatformMisc::RequestExit(1)
[2020.04.25-19.08.32:489][ 77]LogCore: Engine exit requested (reason: Win RequestExit)
[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?