Autor Beitrag
SAiBOT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: Fr 31.08.07 18:22 
Hi all,
Ich versuche schon länger baloontips zu lokalisieren und auszuwerten, nur leider stürzt der gehookte Prozess ständig nach dem auslösen des baloontips ab!

Hier mal mein Code.... vll kann mir jemand sagen wo das Problem liegt!

(selber Code wurde auch mit der HookCode Funktion von madshi und den uall Komponenten getestet, das Problem besteht bei jeder Kombination!

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:
library bth;

uses
  windows,
  madCodeHook,
  dialogs,
  Controls,
  sysutils;

var
next_CreateWindowExA: function(dwExStyle: DWORD; lpClassName: PAnsiChar;
                               lpWindowName: PAnsiChar; dwStyle: DWORD; X, Y, nWidth, nHeight: Integer;
                               hWndParent: HWND; hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND; stdcall;

function my_CreateWindowExA(dwExStyle: DWORD; lpClassName: PAnsiChar;
                            lpWindowName: PAnsiChar; dwStyle: DWORD; X, Y, nWidth, nHeight: Integer;
                            hWndParent: HWND; hMenu: HMENU; hInstance: HINST; lpParam: Pointer): HWND; stdcall;
begin
  Result := next_CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle,
                              X,Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
  if lpClassName = 'tooltips_class32' then
    MessageBox(0, PCHAR(IntToStr(X)+' - '+IntToStr(Y)), 'CreateWindowExA-Hook'0);
end;

procedure injectmain;
begin
  madCodeHook.HookAPI('user32.dll''CreateWindowExA',@my_CreateWindowExA, @next_CreateWindowExA);
end;

procedure uninjectmain;
begin
  madCodeHook.UnhookAPI(@next_CreateWindowExA);
end;

procedure dllmain(dwReason: integer);
begin
  case dwreason of
    DLL_PROCESS_ATTACH:
      injectmain;
    DLL_PROCESS_DETACH:
      uninjectmain;
  end;
end;

begin
  DLLProc := @DLLMain;
  DLLMain(1);
end.
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 29.09.07 17:40 
Hi,
im Prinzip machst du alles richtig. Aber achte auf folgende Sachen:
1) benutzt keine units ausser system/windows. insbesondere keine vcl (dialogs etc)
2) achte daruaf, dass keine Rekursion entseht (MessageBox ruft vill intern selbst CreateWindowEx auf [glaub nich aber nur so zur info])

anonsten die Hooking tips auf madshi.net mal durchlesen und ggf dort im FOrum nachfragen

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit
SAiBOT Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 323
Erhaltene Danke: 6

XP SP2; 7
D7; D2009
BeitragVerfasst: So 10.02.08 12:15 
Es besteht keine Rekursion, mir ist aufgefallen das nur die "Explorer.exe" nach dem injecten und Callen der API-Funktion abstürzt!
Warum auch immer :cry:
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: Mi 05.03.08 13:48 
mach mal:
ausblenden Delphi-Quelltext
1:
2:
  if lpClassName = 'tooltips_class32' then
    MessageBox(0, PCHAR(IntToStr(X)+' - '+IntToStr(Y)), 'CreateWindowExA-Hook'0);

weg und schaub ob es dann geht

generell keine delphi internen funktionen nehmen: inttostr / strcat usw. sondern die aus der kernel32.dll


Sollte es dennoch nicht gehen: Sicher dass noch kein Hook installiert ist bei der explorer.exe? Einfach mal debuggen :)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit