自己写的一个delphi远线程注入函数
function LoadLib(dwPID:DWORD;DLLPath:string):Boolean;stdcall;var
dw:DWORD;
hProcess:THandle;
hThread:THandle;
lpszRemoteFiles:LPWSTR;
pfnThreadRtn:Pointer;
LibPath:LPWSTR;
begin
LibPath:=StringToOleStr(DLLPath);
hProcess:=OpenProcess(PROCESS_ALL_ACCESS,False,dwPID);
Result:=False;
if hProcess=0 then
begin
MessageBox(0,PChar('Unable OpenProcess,fail! error:'+ IntToStr(GetLastError)),'error',MB_OK+ MB_ICONERROR);
Exit;
end;
lpszRemoteFiles:=LPWSTR(VirtualAllocEx(hProcess,nil,sizeof(WCHAR)*lstrlenW(LibPath)+1,MEM_COMMIT, PAGE_READWRITE));
if lpszRemoteFiles=nil then
begin
MessageBox(0,PChar('Unable Apply Space,fail! error:'+ IntToStr(GetLastError)),'error',MB_OK+ MB_ICONERROR);
Exit;
end;
if WriteProcessMemory(hProcess,lpszRemoteFiles,LibPath,sizeof(WCHAR)*lstrlenW(LibPath)+1,dw)=False then
begin
MessageBox(0,PChar('Unable Write Adderss,fail! error:'+ IntToStr(GetLastError)),'error',MB_OK+ MB_ICONERROR);
Exit;
end;
pfnThreadRtn:=GetProcAddress(GetModuleHandle('Kernel32.dll'),'LoadLibraryW');
if pfnThreadRtn=nil then
begin
MessageBox(0,PChar('Unable Get Function Adderss,fail! error:'+ IntToStr(GetLastError)),'error',MB_OK+ MB_ICONERROR);
Exit;
end;
hThread:=CreateRemoteThread(hProcess,nil,0,pfnThreadRtn,lpszRemoteFiles,0,dw);
if hThread=0 then Exit;
WaitForSingleObject(hThread,INFINITE);
VirtualFreeEx(hProcess,lpszRemoteFiles,0,MEM_RELEASE);
CloseHandle(hThread);
CloseHandle(hProcess);
Result:=True;
end;
**** Hidden Message ***** 学无止境。{:3_41:} 不知道我能用不 来学习下,嘿嘿 感谢分享,好东西 学习学习!!~~~~再感谢下LZ 不错的东西 嘻嘻 这个不错 很强大
页:
[1]