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 链接转换为本地文件路径

Delphi获取宽带ip

Delphi 的编译指令(1): $define、$undef、$ifdef、$else、$endif

winapi 字符及字符串函数(3): charupper - 字符或字符串转大写

Delphi now 返回当前日期及时间

Delphi getwebbrowserhtml 获取网页源代码

Delphi中操作olevariant、variant和stream

Delphi 比较图片是否相同

Delphi xe5 将Delphi code从winos 迁移到ios与android

Delphi android拍照报错

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



打赏

取消

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

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

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

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

评论

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