Intermittent crashes in C++ application when calling C# dll

0

I have written a plugin for a C++ application. The application is open source however I am not well versed in C++ so I wanted to ask the community here if my analysis of the problem was accurate and if you could recommend the best ways to proceed with debugging.

The plugin I have written is in C#, there is a template provided by the author of the application which I used to build the plugin. The application is X64dbg, I have provided a link to the template and the main application below.

Template
X64dbg

The problem I am having is that when the debugger is attached to an application (only when it is attached to an application (not all applications), unattached there are no problems) it will crash as soon as the plugin is called. This persists for 10-15 crashes and then starts to work fine until a reboot.

As mentioned above it is not present all the time however it is persistent across applications. So if it consistently crashes an application it will do it every time on reboot. If an application normally works it is fine every time you try.

The error code in event viewer is: 0xC0000005
The Event data is: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException

I have tried putting checks everywhere I can think of to find this null pointer however all attempts have so far been unsuccessful.

My best guess is that it is something to do with how the CLR loads a DLL? So do you know what may be causing the issue or steps to take in identifying what might be causing the issue? Also if anyone has any detailed information on what happens when unmanaged code calls managed code on Windows that would also be very helpful.

I am clutching at straws here so any advise you can give on how to go about identifying the next steps to take to rectify the problem really would be helpful.

c#
c++
windows
clr
asked on Stack Overflow Apr 10, 2020 by John164

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0