本文整理自网络,侵删。
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 serial number of an usb flash drive 获取u盘硬件序列号
Delphi sendmessage这个函数有很多奇妙的用途
Delphi android应用程序中的java ui线程中执行处理
更多相关阅读请进入《Delphi》频道 >>