dll注入

void Test()
{
    TCHAR dllPath[MAX_PATH]
= _T("你的dll名称及完整路径");
    HMODULE lib
= LoadLibrary(_T("kernel32.dll"));
    FARPROC proc
= GetProcAddress(lib, "LoadLibraryA");
    FreeLibrary(lib);
    HANDLE process
= OpenProcess(PROCESS_CREATE_THREAD|PROCESS_VM_OPERATION|PROCESS_VM_WRITE, FALSE, 1672);
    LPVOID param
= VirtualAllocEx(process, NULL, sizeof(dllPath), MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    BOOL b
= WriteProcessMemory(process, param, dllPath, sizeof(dllPath), NULL);
    HANDLE thread
= CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE)proc, param, 0, NULL);
    WaitForSingleObject(thread, INFINITE);
    VirtualFreeEx(process, param,
0, MEM_RELEASE);
    CloseHandle(thread);
    CloseHandle(process);
}

你可能感兴趣的:(thread)