A quick post on how to debug injected DLLs through Visual Studio. This is rather straightforward, but it seems like a fair amount of people are unaware that this can be done. It might possibly because programs typically don’t have DLLs injected to them at runtime, so perhaps people think that debugging them can’t be done in a straightforward way. Fortunately, if you attach to the target process beforehand and inject a DLL, the Visual Studio debugger will detect the loaded DLL and allow for an ordinary debugging experience. The steps are rather simple:
1. Choose to attach to a process through the “Debug” menu in Visual Studio.
2. Select the target process from the list and attach.
3. Attach to the process and verify that breakpoints can get hit.
And that’s all there is to it. All of the useful features of the Visual Studio debugger are now available for debugging the injected DLLs.