I am trying to track a certain value in a game to analyze the cause of a crash (basically, it goes to null at one point and I would like to know what exactly puts that to null as it causes issues later on). I am relatively a beginner in C# reversing as well as using DnSpy, but I couldn't find an exact way to do so leading me to believe either the feature isn't possible or if it is, I am unaware of it.

My goal is to be informed of where exactly it puts it to null with preferably a stacktrace. The best I was able to do was to breakpoint a bunch and hope for the best, but I quickly realised this is very inefficient and there has to be a better way to do this.

If it isn't possible in DnSpy itself, can I use other tools to accomplish the same thing?

If it helps, it's a Unity game which I replaced its mono dll so the DnSpy debugger works, but it can only put breakpoints in the code, not break whenever something changes at all. I can see the value in the watcher, but that's not enough.

  • what is this thing that gets null? Field, a property? – Paweł Łukasik Feb 15 at 10:32
  • The answer is "Data breakpoint" in a regular dot.net debugger - see stackoverflow.com/a/55486743/150978 – Robert Feb 15 at 13:01
  • it says that it only track properties, so it looks like it doesn't give that much benefits over a normal breakpoint. Also does Unity support .net core 3? – Paweł Łukasik Feb 15 at 13:23
  • it is a structure field, not a property. As for using a regular debugger, unfortunately this would require complete decompilation of the code dll which has many intricacies that makes this difficult so the best way to track it would some a breakpoint triggered on change with the dnspy debugger. I also forgot to mention this set to null happens in one frame making it difficult to spot what is causing it. – aldelaro5 Feb 15 at 16:52
  • @aldelaro5 with a field that's difficult and probably dnSpy doesn't have such functionality. One could try with WinDbg and HW breakpoint but with all the GC going on might not work – Paweł Łukasik Feb 16 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.