DWORD * Code;
DWORD * pRemote;
unsigned int InjectSize;
Code=(DWORD *)(GetModuleHandle(NULL));
InjectSize= PImageOptionalHeader((DWORD *)(int(Code)+PImageDosHeader(Code)->_lfanew+sizeof(DWORD)+sizeof(TImageFileHeader)))->SizeOfImage;
//ShowMessage(IntToStr(InjectSize));
//ShowMessage(IntToStr(DWORD(Code)));
DWORD Pid,Tid;
HANDLE ProcessHandle;
GetWindowThreadProcessId(FindWindow(NULL,"ok"), &Pid);
//ShowMessage(IntToStr(Pid));
ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS, false, Pid);
pRemote=(DWORD *)VirtualAllocEx(ProcessHandle,Code,InjectSize,MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
//ShowMessage("aa");
bool ret;
ret=WriteProcessMemory(ProcessHandle, pRemote, Code, InjectSize, &Tid);
//ShowMessage(IntToStr(ret));
// ShowMessage("bb");
CreateRemoteThread(ProcessHandle, NULL, 0x10000, (LPTHREAD_START_ROUTINE)0x58400000, Code, 0, NULL);
//CreateRemoteThread(ProcessHandle, NULL, 0,(LPTHREAD_START_ROUTINE)ok, NULL, 0, NULL);
// ShowMessage("cc");
CloseHandle(ProcessHandle);
下面是线程函数
void __stdcall ok()
{//ShowMessage("ok");
MessageBoxA(NULL,"a","a",MB_OK);
ShowMessage("ok"); <-------------只要加了这句立即出错。
}
以上是无DLL注入进程的关键代码,就是直接EXE注入。编译前加上#include <windows.hpp>
是不是CreateRemoteThread的线程中不能使用VCL窗口?
如果我要线程中用VCL窗口有别的办法么?
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课