1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,TlHelp32, uallhook, uallProcess;
type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; ListBox1: TListBox; Label1: TLabel; Button2: TButton; Label2: TLabel; Label3: TLabel; procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private public procedure WMCOPYDATA(var msg: TWMCopyData); message WM_COPYDATA; end;
var Form1: TForm1;
implementation
{$R *.dfm}
type TMyRecord = packed record Para: string[255]; i: Integer; end; PMyRecord = ^TMyRecord;
procedure GetProcessList(const aProcessList: TStrings); var Snap: THandle; ProcessE: TProcessEntry32; begin aProcessList.Clear; Snap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); try ProcessE.dwSize := SizeOf(ProcessE); if Process32First(Snap, ProcessE) then Repeat aProcessList.Add(ProcessE.szExeFile); until not Process32Next(Snap, ProcessE) else RaiseLastOSError; finally CloseHandle(Snap); end; end;
procedure TForm1.WMCOPYDATA(var msg: TWMCopyData); var MyRecord: PMyRecord; Para: String[255]; i:Integer; begin Edit1.Text := PMyRecord(msg.CopyDataStruct.lpData)^.Para; Label2.Caption := IntToStr(PMyRecord(msg.CopyDataStruct.lpData)^.i); if Edit1.Text = '' then Edit1.Text := '-Keine Parameter gefunden!'; end;
procedure TForm1.FormCreate(Sender: TObject); begin GetProcessList(ListBox1.Items); end;
procedure TForm1.Button2Click(Sender: TObject); begin GetProcessList(ListBox1.Items); end;
procedure TForm1.Button1Click(Sender: TObject); begin if ListBox1.ItemIndex > 1 then begin if NOT InjectLibrary(FindProcess(PCHAR(ListBox1.Items.Strings[ListBox1.ItemIndex])), PCHAR(ExtractFIlePath(ParamStr(0))+'DLL.dll')) then ShowMessage('Fehler beim Injecten!') else begin Edit1.Clear; sleep(100); if NOT UnloadLibrary(FindProcess(PCHAR(ListBox1.Items.Strings[ListBox1.ItemIndex])), 'DLL.dll') then ShowMessage('Fehler beim Entladen!'); end; end; end;
end. |