Autor Beitrag
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 01.04.06 15:06 
Hallo,

kann ich (wenn ja wie?) prüfen ob eine exe mit oder ohne Paramter gestartet wurde? Und wie könnte ich diesen ggf auslesen?

mfg

Moderiert von user profile iconNarses: Titel geändert, war: "Parameter auslesen".
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 01.04.06 15:14 
ausblenden Delphi-Quelltext
1:
paramstr();					

da die zahl des parameters den du haben willst
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Sa 01.04.06 15:23 
ausblenden Delphi-Quelltext
1:
paramcount()					


die anzahl der paramter
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 01.04.06 16:45 
oh, ne das war nicht das was ich meine, wie ich die parameter meiner anwendung auslese weiß ich schon ^^. Ne, ich meine ob ich die einer fremden laufenden Exe rausbekommen kann?!
Nico80
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39

WIN XP
DELPHI 2006
BeitragVerfasst: Fr 25.08.06 15:38 
user profile iconFabian W. hat folgendes geschrieben:
oh, ne das war nicht das was ich meine, wie ich die parameter meiner anwendung auslese weiß ich schon ^^. Ne, ich meine ob ich die einer fremden laufenden Exe rausbekommen kann?!


Frage stellt sich mir auch.


Hat jemand eine Lösung?
evilsoft.de
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39

XP
Delphi 7
BeitragVerfasst: Fr 25.08.06 16:41 
user profile iconFabian W. hat folgendes geschrieben:
oh, ne das war nicht das was ich meine, wie ich die parameter meiner anwendung auslese weiß ich schon ^^. Ne, ich meine ob ich die einer fremden laufenden Exe rausbekommen kann?!


ab in ne DLL mit dem Code und injecten!
Fabian W. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 27.08.06 18:23 
user profile iconevilsoft.de hat folgendes geschrieben:
user profile iconFabian W. hat folgendes geschrieben:
oh, ne das war nicht das was ich meine, wie ich die parameter meiner anwendung auslese weiß ich schon ^^. Ne, ich meine ob ich die einer fremden laufenden Exe rausbekommen kann?!


ab in ne DLL mit dem Code und injecten!
Wie meinen :?:
evilsoft.de
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39

XP
Delphi 7
BeitragVerfasst: Mi 30.08.06 21:42 
user profile iconFabian W. hat folgendes geschrieben:
user profile iconevilsoft.de hat folgendes geschrieben:
user profile iconFabian W. hat folgendes geschrieben:
oh, ne das war nicht das was ich meine, wie ich die parameter meiner anwendung auslese weiß ich schon ^^. Ne, ich meine ob ich die einer fremden laufenden Exe rausbekommen kann?!


ab in ne DLL mit dem Code und injecten!
Wie meinen :?:


habe mal was zusammen geschustert für dich!
habs übersichtlich gehalten, es geht optimaler!!
Du brauchst die Uall Komponenten!

Injector:
ausblenden volle Höhe Delphi-Quelltext
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
    { Private declarations }
  public
    { Public declarations }
    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.


DLL:
ausblenden volle Höhe Delphi-Quelltext
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:
library DLL;

uses
  Classes,
  windows,
  messages;

{$R *.res}

 type
  TMyRecord = packed record
    Para: string[255];
    i: Integer;
  end;
  PMyRecord = ^TMyRecord;

function getparams: String;
var
  i:Integer;
begin
  for i:=1 to ParamCount do
  begin
    Result := Result+ParamStr(i);
    if i < ParamCount then
      Result := Result +' ';
  end;
end;

var
  MyRecord: PMyRecord;
  cds: TCopyDataStruct;
  hWnd: THandle;
begin
 GetMem(MyRecord, sizeof(TMyRecord));
  try
    MyRecord.Para := getparams;
    MyRecord.i := ParamCount;
    cds.dwData := 0;
    cds.cbData := sizeof(TMyRecord);
    cds.lpData := MyRecord;
    hWnd := FindWindow(nil'Receiver');
    SendMessage(hWnd, WM_COPYDATA, HInstance, Integer(@cds));
  finally
    FreeMem(MyRecord, sizeof(TMyRecord));
  end;
end.


im Anhang nochmal ProjektDatein und exe + DLL!

Moderiert von user profile iconNarses: EXE-/DLL-Datei wegen Virenverdacht aus dem Archiv gelöscht.
Einloggen, um Attachments anzusehen!