I have written a non-Qt C DLL compiled with mingw using the QtCreator IDE.
When I inject the DLL into a process, the DLL causes that process to crash at a certain line of code. I found this line to be the culprit through the use of OutputDebugString
. I know how to fix the line and the DLL works when that line is modified. However, for the purpose of learning how to use a debugger, I have left the line broken and unmodified.
How would I use the QtCreator debugger to find that same exact line is causing the problem? When QtCreator is set to compile in debug mode, pressing F5 results in the following dialog because there is no EXE:
Debug from the DLL project Set breakpoints in the DLL project. Right-click the DLL project and choose Set as Startup Project. Make sure the Solutions Configuration field is set to Debug. Press F5, click the green Start arrow, or select Debug > Start Debugging.
Creating dll seems an easy task in Qt. In Qt creator, click File/New File or Project/Projects/Library/C++ Library, then simply choose a name, you will create a dll project. Click “build”, you will see the . dll generated in the debug or release directory.
The solution is to run the debugger attached to the executable before injecting the DLL. The DLL must be built in debug configuration and its project needs to be opened. Attach the debugger using instructions here and inject the DLL. If executable crashes you should see the stack trace and your DLL code when you click on selected stack frame. But be careful: if you corrupted the memory of the process the stack trace might be incomplete or incorrect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With