我还在做我的同一个项目(如果你想知道我为什么问这么多问题。)无论如何我从编译器切换,从 mingw32 (mingw.org) 到 MinGW-w64 (mingw-w64.sourceforge.net/)
虽然项目编译良好,没有任何错误,但注入器不起作用,没有给出任何错误或其他东西。这是来源:
int Inject(DWORD pID)
{
HANDLE hProcess;
if (!(hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pID)))
return 0;
char* szDllName = "subclass64.dll";
LPVOID LoadLibraryAddress;
if ((LoadLibraryAddress = (LPVOID)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA")) == NULL)
{
char buf[32];
sprintf(buf, "%d", GetLastError());
MessageBox(0, buf, "", 0);
CloseHandle(hProcess);
return 0;
}
LPVOID lpStringAddress;
if ((lpStringAddress = (LPVOID)VirtualAllocEx(hProcess, NULL, strlen(szDllName), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE)) == NULL)
{
char buf[32];
sprintf(buf, "%d", GetLastError());
MessageBox(0, buf, "", 0);
CloseHandle(hProcess);
return 0;
}
if (WriteProcessMemory(hProcess, lpStringAddress, szDllName, strlen(szDllName), NULL) == 0)
{
char buf[32];
sprintf(buf, "%d", GetLastError());
MessageBox(0, buf, "", 0);
CloseHandle(hProcess);
return 0;
}
HANDLE hThread;
if ((hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)LoadLibraryAddress, lpStringAddress, 0, NULL)) == NULL)
{
char buf[32];
sprintf(buf, "%d", GetLastError());
MessageBox(0, buf, "", 0);
CloseHandle(hProcess);
return 0;
}
CloseHandle(hProcess);
return 1;
}
我也进行了调试,但没有得到任何奇怪的值:
(gdb) p hProcess
$1 = (HANDLE) 0xec
(gdb) p LoadLibraryAddress
$2 = (LPVOID) 0x7f9de0528ac <LoadLibraryA>
(gdb) p lpStringAddress
$3 = (LPVOID) 0x8a4d10000
(gdb) p hThread
$4 = (HANDLE) 0xf0
(gdb) p GetLastError()
$5 = 0
DLL 没有任何问题,因为它可以与另一个 DLL 注入器(来自互联网)一起正常工作
编辑:它适用于虚拟/测试应用程序,但它不适用于例如记事本(它适用于使用第三方注入器。)
希望有人可以帮助我,问候