// 注入Dll.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { //1 得到要被注入进程的句柄 HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE,792 ); //2 将要注入的DLL的路径写入进程空间 //2.1 先申请一块空间 LPVOID pMem = VirtualAllocEx(hProcess, NULL, 50, MEM_COMMIT, PAGE_READWRITE); //2.2 开始写入 SIZE_T Num = 0; WriteProcessMemory(hProcess, pMem, "D:\Dll.dll", strlen("D:\Dll.dll") + 1, &Num); LPVOID pLoadLibrary = GetProcAddress( GetModuleHandle(L"Kernel32.dll"), "LoadLibraryA" ); CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)pLoadLibrary, pMem,NULL,NULL ); return 0; }