一个工程文件,一个窗体form1,窗体上有timer及其它控件
工程文件去掉了
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
并加入了
Procedure WinMain(); stdcall;
end;
再加注入代码运行后注入到SVCHOST,并执行到winMain()部分
问题是:
如何写代码,可以使form1建立消息循环,使timer事件得以执行
工程文件去掉了
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
并加入了
Procedure WinMain(); stdcall;
end;
再加注入代码运行后注入到SVCHOST,并执行到winMain()部分
问题是:
如何写代码,可以使form1建立消息循环,使timer事件得以执行
解决方案 »
- [水一下]没有人对XE2做界面发表发表意见吗?(散分)
- 用Delphi 能获取其他应用程序窗口里的控件结果吗?
- delphi调用fastreport变量
- 各们大侠:rave report 报表如何导出到EXCEL表中?在此谢过了!!
- 这代码错在哪儿?请楼主指教?
- 求助:indy的IdHTTP控件GET流文件时,形成的文件大小问题
- 有没有这样的结构try..except..finally..end
- 哪位大虾有reportbuilder for delphi7 安装文件的密码 鄙人不胜感激! 高分酬谢!
- 已知OICQ号,如何获知是否在线?如果在线,如何获得其IP地址?
- 如何屏蔽掉DELPHI的隐含调用post方法!??
- 关于cxgrid中添加checkbox
- 额,搞不定delphi的TComboBox控件问题!!!
1、用DELPHI7新建一个应用程序;
2、在form1上加上Timer;事件代码如下:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
timer1.Interval:=5000;
showmessage(PChar('Timer事件发生了。'));
end;
按F9运行后,每5秒弹出提示。
现在,在菜单点工程——查看源代码,
将工程文件program Project1的内容换成以下内容:program Project1;uses
Forms,Windows,messages,
Unit1 in 'Unit1.pas' {Form1};{$R *.res}Procedure WinMain(); stdcall;
begin
begin
while True do
begin
sleep(1000); //注入SVCHOST后到这里循环
end;
end;
//ExitProcess(0);
end;//以下为网上抄来的注入SVHOST代码
var
St: TStartupInfo;
Pr: TProcessInformation;
InjectSize: dword;
Code: pointer;
Injected: pointer;
BytesWritten: dword;
Context: _CONTEXT;
const
injectprocess='svchost.exe';begin
ZeroMemory(@St, SizeOf(TStartupInfo));
St.cb := SizeOf(TStartupInfo);
St.wShowWindow := SW_SHOW;
if CreateProcess(nil, injectprocess, nil, nil, false, Create_SUSPENDED, nil, nil, St, Pr) then
begin
Code := pointer(GetModuleHandle(nil));
InjectSize := PImageOptionalHeader(pointer(integer(Code) + PImageDosHeader(Code)._lfanew +
SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
Injected := VirtualAllocEx(Pr.hProcess, Code, InjectSize, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(Pr.hProcess, Injected, Code, InjectSize, BytesWritten);
Context.ContextFlags := CONTEXT_FULL;
GetThreadContext(Pr.hThread, Context);
Context.Eip := dword(@WinMain);
SetThreadContext(Pr.hThread, Context);
ResumeThread(Pr.hThread);end;end.重新F9运行后,可以在windows的任务管理器中看到新产生了svchost.exe进程。
但是,要怎样才能让FORM1上Timer事件发生,显示出showmessage(PChar('Timer事件发生了。'));这一句的效果?
怎么看都没明白
注入 是DLL注入EXE
EXE 代码 注入 EXE 我还没见过
WinMain 应该写在DLL 里
让Svchost 加载这DLL 就可以了Context.Eip := dword(@WinMain);
//WinMain是你的 Project1的地址 不可能 让Svchost 执行到 Project 里
//每个进程都有独立的代码数据空间
如果你只是要定时做些事情,可以在dll
的begin end 写个循环就ok了