编辑代码

#include <Windows.h>
#include "Inject.h"
#include "driver.h"

int main()
{
    HWND hwnd = FindWindowA("WinPlayer", NULL);
    if(!hwnd)
    {
        std::cerr << "[ERROR] 请打开游戏!" << std::endl;
        system("pause");
    }
    DWORD pid;
    GetWindowThreadProcessId(hwnd, &pid);
    HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
    if (hProcess == NULL)
    {
        std::cerr << "[ERROR] Could not open process : " << std::hex << GetLastError() << std::endl;
        system("pause");
        return 0;
    }
    if(!Inject::inject(hProcess))
    {
        std::cerr << "[ERROR] inject failed ! " << std::endl;
    }
    else
    {
        std::cout << "[+] 注入成功!" << std::endl;
    }
    system("pause");
    return 0;
}