Home > Back-end >  How to debug C dynamic library?
How to debug C dynamic library?

Time:08-19

How to debug the dynamic library conveniently and quickly vs2022?

If Xenos injection is used, nothing is output (random process)

If it passes through the attached process, it does not enter any breakpoint (random process)

#include "pch.h"

#include <iostream>

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {

        std::system("ls>1.txt");
    case DLL_PROCESS_ATTACH:
        OutputDebugString(TEXT("INterdll"));
        break;
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

CodePudding user response:

I would create a minimal test application that uses the library and then debug the application.

CodePudding user response:

In Visual Studio 2022 you can debug your own library by attaching to the application which uses your library. When I usually develop C libraries, I create a separate project which called <MyLibrary>Tests and connect enter image description here

When you press it, you'll be able to find your application which is using your library currently.

And, As I understand on my last work place, the best way to debug your library is make your small GUI application with some buttons for testing. It's pretty enough to make python simple app to check it

Hope I was useful, bye

  • Related