Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [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:

    Code:
    1. FString UCreateAndLinkDLLTutBFL::GetHash256(FString parameterText)
    2. {
    3. char* parameterChar = TCHAR_TO_ANSI(*parameterText);
    4. typedef char*(*_ComputeSha256Hash)(char* parameterText);
    5. void *DLLHandle = NULL;
    6. if (FPaths::FileExists(GetFilePath()))
    7. {
    8. DLLHandle = FPlatformProcess::GetDllHandle(*GetFilePath());
    9. }
    10. if (DLLHandle != NULL)
    11. {
    12. _ComputeSha256Hash DLLFuncPtr = NULL;
    13. FString procName = "ComputeSha256Hash";
    14. DLLFuncPtr = (_ComputeSha256Hash)FPlatformProcess::GetDllExport(DLLHandle, *procName);
    15. if (DLLFuncPtr != NULL)
    16. {
    17. char* returnChar = DLLFuncPtr(parameterChar);
    18. return (ANSI_TO_TCHAR(returnChar));
    19. FPlatformProcess::FreeDllHandle(DLLHandle);
    20. }
    21. }
    22. return "failedread"; // Return an error.
    23. }
    And the crash log that 32bit build

    Code:
    1. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: === Critical error: ===
    2. [2020.04.25-19.08.32:481][ 77]LogWindows: Error:
    3. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: Fatal error!
    4. [2020.04.25-19.08.32:481][ 77]LogWindows: Error:
    5. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x0000002c
    6. [2020.04.25-19.08.32:481][ 77]LogWindows: Error:
    7. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000000f7c406 Axee24.exe!UnknownFunction []
    8. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000013c5b8f Axee24.exe!UnknownFunction []
    9. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a198b5 Axee24.exe!UnknownFunction []
    10. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a1be72 Axee24.exe!UnknownFunction []
    11. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x000000000181b80e Axee24.exe!UnknownFunction []
    12. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000019f9d58 Axee24.exe!UnknownFunction []
    13. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000001a1bcfe Axee24.exe!UnknownFunction []
    14. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000019f9a26 Axee24.exe!UnknownFunction []
    15. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003339c28 Axee24.exe!UnknownFunction []
    16. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003ba37e0 Axee24.exe!UnknownFunction []
    17. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003b937a7 Axee24.exe!UnknownFunction []
    18. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x00000000033236cf Axee24.exe!UnknownFunction []
    19. [2020.04.25-19.08.32:481][ 77]LogWindows: Error: [Callstack] 0x0000000003e93fc9 Axee24.exe!UnknownFunction []
    20. [2020.04.25-19.08.32:481][ 77]LogWindows: Error:
    21. [2020.04.25-19.08.32:488][ 77]LogExit: Executing StaticShutdownAfterError
    22. [2020.04.25-19.08.32:489][ 77]LogWindows: FPlatformMisc::RequestExit(1)
    23. [2020.04.25-19.08.32:489][ 77]LogCore: Engine exit requested (reason: Win RequestExit)
    24. [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?

    #2
    google "using COM dll in c++"

    Comment


      #3
      Originally posted by dreamdev View Post
      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.

      Comment

      Working...
      X