3

I'm using DLLImport to import a library provided by a hardware company and I'm writing my code in .NET Framework to consume the API provided by the DLL.

In one of the methods, when triggered, Visual Studio returns "A breakpoint instruction (__debugbreak() statement or a similar call) was executed in XXX.exe." while I'm in Debug mode. When switching to Release mode, the application crash and Visual Studio just stop the execution.

How do I escape the error/debugbreak so the application won't be triggering this error or I can bypass it?

JeeShen Lee
  • 3,476
  • 5
  • 39
  • 59
  • 3
    If they included an unconditional debugbreak in their dll, they should [undo](https://stackoverflow.com/a/472521/11683) that. – GSerg Jun 06 '22 at 09:58
  • You might want to give this trick a try: [replace int3 with nop](https://stackoverflow.com/a/115238/579749) which replace the debugbreak with a NOP opcode. – victor6510 Jun 11 '22 at 09:41

1 Answers1

2

After a few days of research, it turns out that the error was caused by a memory leakage "0xC0000374: A heap has been corrupted".

It was because of the memory leakage, it triggers the __debugbreak. The DLL library owner confirms that there's none __debugbreak in their code.

More information of how to solve the memory leaks is covered in this StackOverflow thread.

JeeShen Lee
  • 3,476
  • 5
  • 39
  • 59
  • GC (.NET) memory leaks won’t cause heap corruption - this suggests a significant security vulnerability exists in the third-party library you’re using. Have you brought this to the attention of the vendor’s security team? – Dai Jun 29 '22 at 07:27