I'm calling an imported function (through DllImport) of a DLL provided by a hardware company. I'm getting a "critical error detected c0000374 A breakpoint instruction (__debugbreak() statement or a similar call) was executed in ABC.exe."
Since I have no source code access to the DLL and the hardware company confirmed that there's no __debugbreak() introduced in their code. I wonder what went wrong.
Here's the debug output if it helps. It started with the function I tried to call "R_CardID" and then it ended with the error message. On top of this, it happens only on the first call, subsequent calls will not trigger the error. While this is fine in the Debug mode but I can't deploy the app because, in the Release mode, the app will crash and terminate itself when it hits the error.
3a18:48cc @ 162306656 - LdrpGetProcedureAddress - INFO: Locating procedure "R_CardID" by name
3a18:48cc @ 162306656 - LdrpPreprocessDllName - INFO: DLL api-ms-win-security-isolationpolicy-l1-2-0.dll was redirected to C:\Windows\SYSTEM32\sechost.dll by API set
3a18:48cc @ 162306656 - LdrpLoadDllInternal - ENTER: DLL name: C:\Windows\SYSTEM32\sechost.dll
3a18:48cc @ 162306656 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:48cc @ 162306656 - LdrpGetProcedureAddress - INFO: Locating procedure "GetEmbeddedImageMitigationPolicy" by name
3a18:1c34 @ 162306671 - LdrpPreprocessDllName - INFO: DLL api-ms-win-rtcore-ntuser-private-l1-1-4.dll was redirected to C:\Windows\SYSTEM32\user32.dll by API set
3a18:1c34 @ 162306671 - LdrpLoadDllInternal - ENTER: DLL name: C:\Windows\SYSTEM32\user32.dll
3a18:1c34 @ 162306671 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:1c34 @ 162306671 - LdrpGetProcedureAddress - INFO: Loading procedure 0xa25 by ordinal
3a18:1c34 @ 162306828 - LdrGetDllHandleEx - ENTER: DLL name: oleaut32.dll
3a18:1c34 @ 162306828 - LdrpFindLoadedDllInternal - RETURN: Status: 0x00000000
3a18:1c34 @ 162306828 - LdrGetDllHandleEx - RETURN: Status: 0x00000000
3a18:1c34 @ 162306828 - LdrpCallTlsInitializers - INFO: Calling TLS callback 64752600 for DLL "C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_def655a57f98ffe7\igc32.dll" at 63810000
3a18:1c34 @ 162306828 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAAE0 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:1c34 @ 162306828 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAB60 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:1c34 @ 162306828 - LdrpGetProcedureAddress - INFO: Locating procedure "DecodePointer" by name
3a18:1c34 @ 162306828 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:1c34 @ 162306828 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:1c34 @ 162306828 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDecodePointer" by name
3a18:48cc @ 162306890 - LdrLoadDll - ENTER: DLL name: ntdll.dll
3a18:48cc @ 162306890 - LdrpLoadDllInternal - ENTER: DLL name: ntdll.dll
3a18:48cc @ 162306890 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:48cc @ 162306890 - LdrLoadDll - RETURN: Status: 0x00000000
3a18:48cc @ 162306890 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlGetNtSystemRoot" by name
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 0 : 8 bytes copied from 75A680A0 to 0952EC58
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 1 : 12 bytes copied from 75099000 to 0E8996C0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 2 : 8 bytes copied from 75F110CC to 0952ECA0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 3 : 8 bytes copied from 75E028E4 to 0952E9A0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 4 : 8 bytes copied from 76D848A4 to 0952E9D0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 5 : 8 bytes copied from 796AB9B4 to 0952E9E8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 6 : 8 bytes copied from 69140B7C to 0952EA00
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 7 : 8 bytes copied from 57D1A000 to 0952EA18
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 8 : 8 bytes copied from 72D25000 to 0952EA30
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 9 : 12 bytes copied from 75654F04 to 0E899A20
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 10 : 8 bytes copied from 6D67E3A8 to 0952EA48
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 11 : 8 bytes copied from 6B74F75C to 0952EA60
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 12 : 12 bytes copied from 732CEE90 to 0E899820
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 13 : 8 bytes copied from 79846014 to 094D3F60
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 14 : 8 bytes copied from 7691318C to 094D3EA0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 15 : 8 bytes copied from 7556D9E0 to 094D3EB8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 16 : 8 bytes copied from 6BECEA08 to 094D41E8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 17 : 8 bytes copied from 79A64C10 to 094D4200
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 18 : 8 bytes copied from 79AD3538 to 094D4188
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 19 : 8 bytes copied from 67877A3C to 094D41A0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 20 : 8 bytes copied from 5775B718 to 094D3510
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 21 : 8 bytes copied from 564871CC to 094D32A0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 22 : 328 bytes copied from 57B0F9E0 to 09645648
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 23 : 8 bytes copied from 60BBCDFC to 094D3498
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 24 : 8 bytes copied from 7608123C to 094D3360
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 25 : 8 bytes copied from 7BC50000 to 094D3258
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 26 : 8 bytes copied from 7BFF3000 to 094D3468
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 27 : 8 bytes copied from 628C6000 to 094D34B0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 28 : 8 bytes copied from 5C9CB0E8 to 094D32B8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 29 : 8 bytes copied from 57528364 to 094D32E8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 30 : 12 bytes copied from 6C46A440 to 0E8998C0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 31 : 164 bytes copied from 6C2FC880 to 0961E528
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 33 : 8 bytes copied from 6B50CF50 to 094D3390
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 32 : 1452 bytes copied from 65424848 to 098589D8
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 34 : 8 bytes copied from 574C2784 to 094D33C0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 35 : 8 bytes copied from 7AA475A0 to 094D35A0
3a18:02f0 @ 162307015 - LdrpAllocateTls - INFO: TlsVector 0E5C8368 Index 36 : 8 bytes copied from 7ABAFD30 to 094D3930
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "DecodePointer" by name
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDecodePointer" by name
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "DecodePointer" by name
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDecodePointer" by name
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "EncodePointer" by name
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEncodePointer" by name
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "DecodePointer" by name
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:02f0 @ 162307015 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:02f0 @ 162307015 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDecodePointer" by name
3a18:02f0 @ 162307015 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAAE0 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:02f0 @ 162307015 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAB60 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:02f0 @ 162307015 - LdrpCallTlsInitializers - INFO: Calling TLS callback 64752600 for DLL "C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_def655a57f98ffe7\igc32.dll" at 63810000
Critical error detected c0000374
A breakpoint instruction (__debugbreak() statement or a similar call) was executed in ABC.exe.
3a18:02f0 @ 162308515 - LdrpCallTlsInitializers - INFO: Calling TLS callback 64752600 for DLL "C:\Windows\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_def655a57f98ffe7\igc32.dll" at 63810000
3a18:02f0 @ 162308515 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAAE0 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:02f0 @ 162308515 - LdrpCallTlsInitializers - INFO: Calling TLS callback 579CAB60 for DLL "C:\Windows\SYSTEM32\UIAutomationCore.dll" at 57930000
3a18:02f0 @ 162308515 - LdrpGetProcedureAddress - INFO: Locating procedure "DecodePointer" by name
3a18:02f0 @ 162308515 - LdrpLoadDllInternal - ENTER: DLL name: NTDLL.DLL
3a18:02f0 @ 162308515 - LdrpLoadDllInternal - RETURN: Status: 0x00000000
3a18:02f0 @ 162308515 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDecodePointer" by name
Exception thrown at 0x776C6CF3 (ntdll.dll) in abc.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77703960).
Unhandled exception at 0x776C6CF3 (ntdll.dll) in abc.exe: 0xC0000374: A heap has been corrupted (parameters: 0x77703960).