SharpMonoInjector
SharpMonoInjector copied to clipboard
add better error handling for processes whose memory can't be read
Win10, when hitting Refresh in the GUI, was getting an exception here of "Failed to read process memory", which was unhandled and caused the app to crash. https://github.com/wh0am15533/SharpMonoInjector/blob/ae35e071a4ad56caf5aba390a9fc09a17e29d9a7/SharpMonoInjector/Memory.cs#L62
Weirdly, this is for an unrelated EXE I didn't care about - JetBrains.ReSharper.Host64.exe (my Jetbrains visual studio plugin)
This PR catches exceptions like this, logs them, and skips the offending EXE. With it in place, I can pick up the EXE I care about and things go well from there.
I also modified the logging to reduce code copy+paste.
I could have made this PR a little cleaner and separated the logging cleanup from the exception handling but.... :shrug: If that's an issue, let me know I'll clean it up.
Thanks! Btw, ever consider doing releases here on Github instead of on the forum? Just easier to deal with, unless there's a reason to keep it on the forum.
-Dom