15-07-2011, 06:24 PM
السلام عليكم
أنظر هذه الدالة أخي
و هنالك مثال في المرفقات
أنظر هذه الدالة أخي
كود :
function InjectDLL( DLLSource : string; ProcessDestination : string ) : Boolean;
var
LibName : Pointer;
hProcess : THandle;
ThreadHandle: THandle;
OctEcrit : Cardinal;
TheadID : DWORD;
begin
Result := False;
AjustePrivileges;
hProcess := OpenProcess( PROCESS_ALL_ACCESS, FALSE, FindProcess( ProcessDestination ) );
if (hProcess = 0) then Exit;
LibName := VirtualAllocEx( hProcess, nil, Length(DLLSource) + 1, MEM_COMMIT, PAGE_READWRITE );
if ( LibName <> nil ) then
begin
WriteProcessMemory( hProcess, LibName, PChar(DLLSource), Length(DLLSource) + 1, OctEcrit );
if ( (Length(DLLSource) + 1) <> OctEcrit ) then Exit;
le process
ThreadHandle := CreateRemoteThread( hProcess, nil, 0, GetProcAddress( LoadLibrary('kernel32.dll'), 'LoadLibraryA' ), LibName, 0, TheadID );
Result := ( ThreadHandle <> 0 );
WaitForSingleObject( ThreadHandle, INFINITE );
end else Result := False;
VirtualFreeEx( hProcess, LibName, 0, MEM_RELEASE );
CloseHandle( hProcess );
end;
