我现在掌握了不用dll也能代码注入的技术就是有一个inject函数 把要插入进程的句柄和要插入的函数名前加一个"@"
当作参数传递过去就行了,如下:
procedure Inject(ProcessHandle: longword; EntryPoint: pointer);本来是很好用的但是我这里有一份带窗体的程序的代码 想让它插到某个pid里
原来的dpr文件是这样的:program server;uses
Forms,
mainserve in 'mainserve.pas' {ServerForm};begin
Application.Initialize;
Application.CreateForm(TServerForm, ServerForm);
Application.Run;
end.我改成了:program server;uses
Forms,windows,
mainserve in 'mainserve.pas' {ServerForm};procedure main();begin
Application.Initialize;
Application.CreateForm(TServerForm, ServerForm);
Application.Run;
end;
var
ProcessHandle, PID: longword;beginPID:=1252;//当前我运行的某个IE的PID
ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID);//打开进程
Inject(ProcessHandle, @Main);//插入代码
CloseHandle(ProcessHandle);//关闭线程句柄
end.那个mainserve.pas没作改动编译没错 一运行就出错说 某个内存引用的某个内存不能为writen 结果IE就关了
我的改动并没错呀??我怀疑这个错误和程序里有窗体有关 但是用到了timer 是不是就不能去掉窗体??我的怀疑正确吗????
当作参数传递过去就行了,如下:
procedure Inject(ProcessHandle: longword; EntryPoint: pointer);本来是很好用的但是我这里有一份带窗体的程序的代码 想让它插到某个pid里
原来的dpr文件是这样的:program server;uses
Forms,
mainserve in 'mainserve.pas' {ServerForm};begin
Application.Initialize;
Application.CreateForm(TServerForm, ServerForm);
Application.Run;
end.我改成了:program server;uses
Forms,windows,
mainserve in 'mainserve.pas' {ServerForm};procedure main();begin
Application.Initialize;
Application.CreateForm(TServerForm, ServerForm);
Application.Run;
end;
var
ProcessHandle, PID: longword;beginPID:=1252;//当前我运行的某个IE的PID
ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID);//打开进程
Inject(ProcessHandle, @Main);//插入代码
CloseHandle(ProcessHandle);//关闭线程句柄
end.那个mainserve.pas没作改动编译没错 一运行就出错说 某个内存引用的某个内存不能为writen 结果IE就关了
我的改动并没错呀??我怀疑这个错误和程序里有窗体有关 但是用到了timer 是不是就不能去掉窗体??我的怀疑正确吗????
aphex的不用DLL远程注入是
GetWindowThreadProcessId(FindWindow('Shell_TrayWnd', nil), @Pid);
//获取Exp进程的PID码,Shell_TrayWnd为类名,相关的需用SPY++来查看ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, Pid); //打开进程hModule := Pointer(GetModuleHandle(nil));
//这里得到的值为一个返回一个指针型变量,指向内容包括自身映像的基址和长度Extent := PImageOptionalHeader(Pointer(integer(hModule) + PImageDosHeader(hModule)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
//得到内存映像的长度VirtualFreeEx(ProcessHandle, hModule, 0, MEM_RELEASE);
//在Exp进程的内存范围内分配一个足够长度的内存hModule_News := VirtualAllocEx(ProcessHandle, hModule, Extent, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
//确定起始基址和内存映像基址的位置WriteProcessMemory(ProcessHandle, hModule_News, hModule, Extent, Size);
//确定上面各项数据后,这里开始进行操作CreateRemoteThread(ProcessHandle, nil, 0, @Download, hModule, 0, ThreadId);
//建立远程线程,至此注入过程完成CloseHandle(ProcessHandle);
偶把我的程序定义成个过程 然后用他这样的方法去注入. 结果跟LX一样...
高手详细说下吧..