Autor Beitrag
Terra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 12:25 
Hallo,

kann mir jemand weiterhelfen, der sich mit Assambler auskennt oder weiss, wie ich diesen Code in Delphi einbinde ???

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
SendInput proc cInputs, nInputs, cbSize
    
    push cbSize
    push nInputs
    push cInputs
    call Tunnel
    ret
    
  Tunnel:
    
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
    
  SendInput endp


habs schonmal so ausprobiert aber ich bekomm eine Fehlermeldung, das TUNNEL ein undeklarierter Bezeichner ist.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure sendinputtunnel(cInputs, nInputs, cbSize: Word);
begin
  asm
    push cbSize
    push nInputs
    push cInputs
    call Tunnel
    ret
  Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;
end;


Was muss ich denn bei tunnel noch deklarieren? Kenn mich mit Assambler numal garnicht aus.
Und ist mein vorgehen so überhaupt richtig? Will halt das SendInput von delphi mit dieser Procedure ersetzen.


Terra


Moderiert von user profile iconAXMD: Topic aus Sonstiges (Delphi) verschoben am Sa 03.06.2006 um 12:44
Moderiert von user profile iconAXMD: Code- durch Delphi-Tags ersetzt
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.06.06 12:42 
Das Problem mit unbekannten Labels hatten wir gestern erst. Wenn Du in Delphi Labels ohne @ am Anfang angibst, sind dies Prozedur-lokale Label und müssen deklariert werden. Wenn Du ein Label nur innerhalb eines Asm-Blocks brauchst, kannst Du einfach 2 @-Zeichen voranstellen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 12:47 
Also so: ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  call Tunnel
  ret
  @@Tunnel
  mov eax, 11F6h


dabei macht der mir den gleichen fehler...

Terra

PS: Danke für die schnelle Antwort.

PPS: Ach habs jetzt so gemacht ohne eine Fehlermeldung .. ist das so richtig? Möchte nichts kaputt machen. Wie gesagt, kenne mich mit Assambler kein Stück aus und hab schon viel darüber gehört.
Hab die Procedure rein Instinktiv erstellt und habe eigentlich garkeine Ahnung obs so richtig ist.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure sendinputtunnel(cInputs, nInputs, cbSize: Word);
begin
  asm
    push cbSize
    push nInputs
    push cInputs
    call @@Tunnel
    ret
  @@Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;
end;
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.06.06 13:02 
Nein ;-)

Aus
user profile iconTerra hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure sendinputtunnel(cInputs, nInputs, cbSize: Word);
begin
  asm
    push cbSize
    push nInputs
    push cInputs
    call Tunnel
    ret
  Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;
end;

wird einfach
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure sendinputtunnel(cInputs, nInputs, cbSize: Word);
asm
    push cbSize
    push nInputs
    push cInputs
    call @@Tunnel
    ret

@@Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
end;

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 13:10 
Hab ichs also oben doch noch richtig rausbekommen. So schwer ist Assambler ja garnicht. Dann schreib ich jetzt ein Betriebsystem *rofl*

Dann werd ich jetzt mal meine erste Assambler Prozedure ausprobieren... wenn ich mich nie wieder melde könnt ihr euch denken warum ^^

Kannste mir da noch ein bissel weiterhelfen ???

habe in delphi folgenden Aufruf:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
    Inp.Itype := INPUT_KEYBOARD;
    Inp.ki.wVk := Ord(UpCase(Str[xxi]));
    Inp.ki.dwFlags := 0;
    SendInputTunnel(1, Inp, SizeOf(Inp)); //<----- sende String


Allerdingst sagt mir Delphi jetzt, das bei SendInputTunnel ein (Incompatible type: "Word" and "tagINPUT") besteht. Ich peil das net... was mach ich denn jetzt?

Terra
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.06.06 13:23 
Dazu bräuchte ich mal die Deklaration deiner Input-Params.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 13:28 
OK, geb dir mal die relevanten Daten:

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:
procedure sendinputtunnel(cInputs: word; nInputs, cbSize: Word);
begin
  asm
    push cbSize
    push nInputs
    push cInputs
    call @@Tunnel
    ret
  @@Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;
end;

procedure TForm1.Timer5Timer(Sender: TObject);
var
    wnd5, wnd5_0: HWND;
    mx, my, I, w1, w2, xxi: integer;
    List: TList;
    ProcessId: DWORD;
    bsb1, bsb2: string;
    bsb11, bsb12: pansichar;
    Inp: TInput;
const
   Str: string = 'Terra'// nur test - wird durch edit-einträge ersetzt...
begin
  wnd5_0 := FindWindow('-/-','-/-');
  wnd5_0 := FindWindowEx(wnd5_0, 0'Edit'nil);
  wnd5 :=  FindWindow('-/-''-/-');

  if IsWindowVisible(wnd5_0) then
  if wnd5 <> 0 then
  begin
    Memo1.Lines.Add(find_LoginScreen_txt);
    sleep(200);
    Memo1.Lines.Add('drücke button'); //test
    

 ShowWindow(wnd5, SW_SHOW);

 for xxI := 1 to Length(Str) do
  begin
    // drücken
    Inp.Itype := INPUT_KEYBOARD;
    Inp.ki.wVk := Ord(UpCase(Str[xxi]));
    Inp.ki.dwFlags := 0;
    SendInputTunnel(1, Inp, SizeOf(Inp));

    // loslassen
    Inp.Itype := INPUT_KEYBOARD;
    Inp.ki.wVk := Ord(UpCase(Str[xxi]));
    Inp.ki.dwFlags := KEYEVENTF_KEYUP;
    SendInputTunnel(1, Inp, SizeOf(Inp));

    Application.ProcessMessages;
    Sleep(80);
  end;

   Timer5.Enabled := false;
  end;
end;


Ich hoffe das reicht insgesammt. Ansonsten musst du mir bitte nochmal genau sagen was du bräuchtest.

Terra
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.06.06 13:32 
Zeile 2 und 15 MÜSSEN weg, weil Du sonst Probleme mit den Stackframes bekommst. Daher war das bewusst bei mir ohne Begin\End geschrieben ;-)

Anonsten bräuchte ich die Deklaration von TInput.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 13:47 
Achsoooooo .. das ist mir garnicht aufgefallen ^^ *peinlich*

Ömpf ... woher bekomm ich denn die dekleration von TInput? .. das ist doch eine fertige Definition von Delphi oder sehe ich das Falsch? .. In der Hilfe konnte ich auch nix finden.

Oder bin ich jetzt so durch den Wind das ich vor lauter Bäumen den Wald nicht mehr sehe ???
Sorry, aber mich verfolgt ein Problem schon seit über 3 Wochen, wo ich jetzt hoffe mit dem Assambler Code diesen zu lösen.

Terra
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 03.06.06 13:53 
Einfachster Fall: Änder die Deklaration der Prozedur in procedure sendinputtunnel(cInputs: Dword; nInputs: Pointer; cbSize: Integer); ab und ergänze jeweils vor Inp in den Aufrufen ein @-Zeichen (also @Inp)... Dann sollte es gehen.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 14:13 
Herrlich .. keine Fehlermeldung mehr beim compilieren... soweit Danke.

Bekomm jetzt nur noch ein Fehler beim aufruf. (sobald das Programm auf den Assambler-Code zugreifen soll.

Zitat:
Access violation at address 34FD48B. Read of address 34FD48B.


Und nü? Nicht das ich zu faul wäre zu suchen aber in solchen sachen bin ich ein absoluter Noob.

Habs so gemacht wie du sagtest:
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:
procedure sendinputtunnel(cInputs: word; nInputs: Pointer; cbSize: Integer);
  asm
    push cbSize
    push nInputs
    push cInputs
    call @@Tunnel
    ret
  @@Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;

-----------------------------------------------------

for xxI := 1 to Length(Str) do
  begin
    // press
    Inp.Itype := INPUT_KEYBOARD;
    Inp.ki.wVk := Ord(UpCase(Str[xxi]));
    Inp.ki.dwFlags := 0;
    SendInputTunnel(1, @Inp, SizeOf(@Inp));

    // release
    Inp.Itype := INPUT_KEYBOARD;
    Inp.ki.wVk := Ord(UpCase(Str[xxi])); // setzte ich vor Inp ein @ gibbet ein Fehler
    Inp.ki.dwFlags := KEYEVENTF_KEYUP;
    SendInputTunnel(1, @Inp, SizeOf(@Inp)); // das @ vor Inp geht klar

    Application.ProcessMessages;
    Sleep(80);
  end;


Kannst du mir nur mal nebenbei mal was erklären, da du dich ja anscheinend mit Assambler auskennst.

ich habe das hier im Forum gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
unction Calc(x: Integer) : Integer;
asm
  MOV ECX, EAX
  JMP @@in

@@sumup:
  ADD EAX, ECX

@@in:
  DEC ECX
  JNZ @@sumup
end;

function Calc2(x: Integer): Integer;
asm
  MOV EDX, EAX
  IMUL EAX, EDX
  ADD EAX, EDX
  SHR EAX, 1
end;


In dem Code sind ja auch Sprunganweisungen angegeben "JMP", "JNZ". Kann ich auch einfach mit JMP @@Tunnel im Assamblercode eingeben anstelle von CALL. Wo liegen da die unterschiede?


Terra
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 03.06.06 14:58 
In Delphi gibt es SendInput ganz normal, das ist ein einfacher user32.dll export. Ich weiß nicht was du da für nen krüppel code zusammen bastelst...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function SendInput(cInputs: UINT; var pInputs: TInput; cbSize: Integer): UINT; stdcall;
asm
  mov eax, $11F6
  mov edx, $7FFE0300
  call dword ptr [edx]
end;


da ist der Nachbau, Funktioniert nur auf WindowsXP SP2 weils nen Fastcall benutzt

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 15:17 
Wie muss man denn den ASM-Code umschreiben, damit er auf allen XP-Rechnern läuft ????

Der "krüppel code" soll den nprotect/GameGuard tunneln, so das ich aus meinem Programm die Login-Daten an das Spiel senden kann. Mit dem normalen SendInput oder was noch von der user32.dll gehandelt wird funktioniert ja net bzw. wird vom GameGuard geblockt.

Da mir bis dato nichts dazu eingefallen ist das Problem zu lösen war ich auf der suche nach alternativen und habe halt den ASM-Code gefunden. Was dabei rausgekommen ist siehste ja oben.

Terra
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 03.06.06 16:15 
Schau an welche Servicenummer das unter 2k XPSp1 usw ist. also das MOV EAX, ...

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 16:39 
Ich hätte absolut kein Plan wonach ich suchen müsste. Kannst du mir da weiterhelfen ??

Terra
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 03.06.06 18:43 
Rufst du das SendInout in deinem oder in dem Programm was geschützt ist auf?

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
ReDoX
Hält's aus hier
Beiträge: 14

WinXP & Linux [VM]
Delphi 7 Professional
BeitragVerfasst: Sa 03.06.06 18:59 
user profile iconuall@ogc hat folgendes geschrieben:
Schau an welche Servicenummer das unter 2k XPSp1 usw ist. also das MOV EAX, ...


Wo kann man das denn nachgucken, gibts da ne Liste oder sowas in der Art?
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 20:03 
user profile iconuall@ogc hat folgendes geschrieben:
Rufst du das SendInout in deinem oder in dem Programm was geschützt ist auf?


Ich rufe SendInput in meinem Programm auf. Es soll somit ein Text aus einem Edit-Feld an das "Edit"-Feld im geschützem Programm gesendet werden.

Terra
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Sa 03.06.06 20:06 
Dann wird das auch nicht mit einem Nachbau der Funktion gehen.

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
Terra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 307

Windows 7 Ultimate
Delphi® XE3
BeitragVerfasst: Sa 03.06.06 22:41 
Naja, es sollte ja mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
@@Tunnel:
    mov eax, 11F6h
    mov edx, 7FFE0300h
    call dword ptr [edx]
    ret 0Ch
  end;

... getunnelt werden. Aber ich bekomm nur eine Fehlermeldung bei dem aufruf ...

Hat jemand eine Idee wie das anders gelöst werden kann. Irgendwie muss es funktionieren, da ich schonmal ein Programm gesehen habe, der das kann, was ich vorhabe.
(Ich würde es aber gerne selber programmieren)

Terra