Untitled

 avatar
unknown
plain_text
5 months ago
1.1 kB
4
Indexable
#include <windows.h>
#include <iostream>

typedef BOOL(WINAPI* DllMainFunc)(HINSTANCE, DWORD, LPVOID);

int main() {
    // 加载 DLL
    HMODULE hDLL = LoadLibrary(L"ualapi.dll");
    if (hDLL == NULL) {
        DWORD errorCode = GetLastError();
        std::cerr << "Failed to load DLL, error code: " << errorCode << std::endl;
        return 1;
    }

    // 获取 DllMain 地址
    DllMainFunc dllMain = (DllMainFunc)GetProcAddress(hDLL, "DllMain");
    if (dllMain == NULL) {
        DWORD errorCode = GetLastError();
        std::cerr << "Failed to get address of DllMain function, error code: " << errorCode << std::endl;
        FreeLibrary(hDLL);
        return 1;
    }

    // 调用 DllMain 函数
    if (!dllMain((HINSTANCE)hDLL, DLL_PROCESS_ATTACH, NULL)) {
        std::cerr << "Failed to execute DllMain function" << std::endl;
        FreeLibrary(hDLL);
        return 1;
    }

    std::cout << "DllMain called successfully" << std::endl;

    // 卸载 DLL
    FreeLibrary(hDLL);

    return 0;
}
Editor is loading...
Leave a Comment