uses
Winapi.tlHelp32, URLMon, ShellApi;
var
RunningApplicationId: HWND;
Dllolduguyer: string;
ExEismi: string;
function Inject(const DLLFileName: AnsiString; const ProcessID: Cardinal): Boolean;
var
hProcess: THandle;
hThread: THandle;
BaseAddress: Pointer;
Size: NativeUInt;
ThreadID: DWORD;
begin
Result := False;
hProcess := OpenProcess(PROCESS_ALL_ACCESS, False, ProcessID);
if (hProcess <> 0) then
begin
BaseAddress := VirtualAllocEx(hProcess, nil, Length(DLLFileName) + 1, MEM_COMMIT, PAGE_READWRITE );
if BaseAddress <> nil then
begin
WriteProcessMemory(hProcess, BaseAddress, PAnsiChar(DLLFileName), Length(DLLFileName) + 1, Size);
if NativeUInt(Length(DLLFileName) + 1) = Size then
begin
hThread := CreateRemoteThread(hProcess, nil, 0, GetProcAddress(LoadLibrary('kernel32.dll'), 'LoadLibraryA' ), BaseAddress, 0, ThreadID);
Result := hThread <> 0;
WaitForSingleObject(hThread, INFINITE);
end
end;
VirtualFreeEx(hProcess, BaseAddress, 0, MEM_RELEASE);
CloseHandle(hProcess);
end;
end;
function GetPIDbyProcessName(processName:String): HWND;
var
GotProcess: Boolean;
tempHandle: tHandle;
procE: tProcessEntry32;
begin
tempHandle := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
procE.dwSize := SizeOf(procE);
GotProcess := Process32First(tempHandle, procE);
{$B-}
if GotProcess and (procE.szExeFile <> processName) then
begin
repeat
GotProcess := Process32Next(tempHandle, procE);
until (not GotProcess) or (procE.szExeFile = processName);
end;
{$B+}
if GotProcess then
Result := procE.th32ProcessID
else
Result := 0;
CloseHandle(tempHandle);
end;
procedure XİnjectPanel;
begin
RunningApplicationId := GetPIDbyProcessName(ExEismi);
if RunningApplicationId <> 0 then
begin
if Inject(AnsiString(Dllolduguyer), RunningApplicationId) then
begin
//inject edildikden sonra vermesini istdiğin mesaj
ShowMessage('Injection complete');
end
else
begin
//inject edilmediğinde vermesini istdiğin mesaj
ShowMessage('FAILED!');
end;
end
else
begin
ShowMessage('Process cound not be found');
end;
end;
function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end;