DllMain

导出DllMain

也可以看看:
https://github.com/HackerajOfficial/injectAllTheThings/blob/master/rdll/dllmain.cpp

#include <Windows.h>
#include <stdio.h>

#define printf(x) MessageBoxW(NULL, L##x, L"提示", MB_OK)

__declspec(dllexport)
    BOOL WINAPI DllMain(
        HINSTANCE hinstDLL, // handle to DLL module
        DWORD fdwReason,    // reason for calling function
        LPVOID lpReserved)  // reserved
{
    // Perform actions based on the reason for calling.
    switch (fdwReason)
    {
    case DLL_PROCESS_ATTACH:
        // Initialize once for each new process.
        // Return FALSE to fail DLL load.
        printf("附加到进程");
        break;

    case DLL_THREAD_ATTACH:
        // Do thread-specific initialization.
        printf("附加到线程");
        break;

    case DLL_THREAD_DETACH:
        // Do thread-specific cleanup.
        printf("从线程分离");
        break;

    case DLL_PROCESS_DETACH:
        // Perform any necessary cleanup.
        printf("从进程分离");
        break;
    }
    return TRUE; // Successful DLL_PROCESS_ATTACH.
}
posted @ 2022-01-26 16:02  develon  阅读(54)  评论(0编辑  收藏  举报