Autor Beitrag
LittleBen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: So 24.03.13 17:54 
Schönen Sonntag zusammen,
ich habe ein kleines Problem mit Windows 7 x64: Und zwar habe ich mal eine kleine DLL gefunden, mit der man Maus-und Tastatureingaben hooken kann. Das benötige ich, um ein System kurzeitige zu blockieren, um in der Firma Programmupdates durchzuführen (dass keiner dazwischen funkt). Unter Windowx 7 x86 hat das wunderbar funktioniert, seit x64 nicht mehr.
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:
library Blocker;

uses
  WinTypes,
  WinProcs,
  Messages,
  Dialogs,
  SysUtils;

var
  HookHandle, MouseHandle: HHOOK;

function KeyHook(Code: integer; WParam: word; lParam: Longint): Longint; stdcall;
begin
 Result:= CallNextHookEx(HookHandle, Code, 00);
end;

function MouseHook(Code: integer; WParam: word; lParam: Longint): Longint; stdcall;
begin
 Result:= CallNextHookEx(MouseHandle, Code, 00);
end;

procedure SetKeyHook; export;
begin
 HookHandle:=SetWindowsHookEx(WH_KEYBOARD, @KeyHook, hInstance, 0);
 MouseHandle:=SetWindowsHookEx(WH_MOUSE, @MouseHook, hInstance, 0);
end;

procedure DelKeyHook; export;
begin
  if HookHandle <> 0 then
   UnhookWindowsHookEx(HookHandle);
  HookHandle:=0;
  if MouseHandle <> 0 then
   UnhookWindowsHookEx(MouseHandle);
  MouseHandle:=0;
  HookHandle:=0;
end;

exports
  SetKeyHook name 'SetKeyHook',
  DelKeyHook name 'DelKeyHook';

begin
end.

In den Funktionen KeyHook und MausHook fange ich die Eingabe einfach ab und sende eine "leere Nachricht" weiter. Das sniffen würde funktionieren, brauche ich aber nicht.

Hat jemand eine Idee, woran das liegt?

Viele Grüße
Littleben
jfheins
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 918
Erhaltene Danke: 158

Win 10
VS 2013, VS2015
BeitragVerfasst: So 24.03.13 19:55 
Es liegt daran, dass 32bit Prozesse nur 32bit dlls laden und 64bit Prozesse nur 64bit dlls.

Sofern z.B. der Explorer ein 64bit Prozess ist, erreichst du ihn damit nicht mehr. Du brauchst eine 64bit dll (zusätzlich zu deiner 32bit dll) und sie muss einen anderen Namen haben.
LittleBen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 258
Erhaltene Danke: 4

Win 7, Mac OS
Delphi 7
BeitragVerfasst: So 24.03.13 20:37 
Ergibt Sinn ^^ Vielen Dank!!!