library mbutdll;
{$W-,K+,S-}
{$C MOVEABLE PRELOAD PERMANENT} {gleiche Attribute wie Unit SYSTEM}
{$D Mittlere Maustaste mit Doppelklick}
{01/02: Beachtung Linkshänder-Maus; jedoch nicht dynamisch, sondern
Festlegung beim Laden der DLL}
uses WinProcs,WinTypes,Win31;
type
PtrRec=record
Ofs,Sel:Word;
end;
procedure Mouse_Event; far; external 'USER' index 299;
const
ME_Code: TFarProc=@Mouse_Event; {Mouse_Event Adresse}
ButtonDown: Word=2; {=8 für Linkshänder}
ButtonUp: Word=4; {=16 für Linkshänder}
var
ME_Data: Pointer; {Daten-Zeiger}
OrigBytes: array[0..4] of Byte; {Original-Bytes}
procedure HookProc; far; forward;
procedure UpdateSel; assembler;
asm push PtrRec[ME_Code].Sel
push PtrRec[ME_Data].Sel
call PrestoChangoSelector
mov PtrRec[ME_Data].Sel,ax
end;
procedure SetBreak; assembler;
asm les di,[ME_Data]
mov al,$EA {Code für "Far Jump"}
cld
stosb
mov ax,offset HookProc
stosw
mov ax,cs {eigenes Codesegment}
stosw
end;
procedure SetBytes; assembler; {gleichzeitig: Uninstall}
asm les di,[ME_Data]
mov si,offset OrigBytes
mov cx,5
cld
rep movsb {Original-Bytes zurückspielen}
end;
procedure HookProc; {far;} assembler;
asm push ds
push seg @data
pop ds
pushf
push es
pusha
call UpdateSel {Falls Verschiebungen auftraten:korrigieren}
call SetBytes
popa
pop es
popf
test al,$60 {Mittlere Maustaste betreffend?}
jz @@1 {nein}
test al,$20 {Mittlere Maustaste drücken?}
jz @@2 {nein, Loslaß-Code}
and al,not $20 {Mittl. Maustaste Drücke-Code weg!}
or al,byte ptr [ButtonDown] {Stattdessen linke Maustaste drücken}
push dx {Anzahl Maustasten retten}
call [ME_Code] {an Windows}
pop dx
mov ax,[ButtonUp] {Linke Taste loslassen}
xor bx,bx {keine Bewegung!}
xor cx,cx
push dx
call [ME_Code]
pop dx
mov ax,[ButtonDown] {Linke Taste ohne Bewegung nochmal drücken}
xor bx,bx
xor cx,cx
jmp @@1
@@2: and al,not $40 {Mittlere Maustaste Loslaß-Code weg!}
or al,byte ptr [ButtonUp] {Stattdessen linke Maustaste loslassen}
@@1: call [ME_Code]
pushf
push es
pusha
call SetBreak
popa
pop es
popf
pop ds
end;
procedure HookInstall; assembler;
asm les si,[ME_Code]
mov PtrRec[ME_Data].Ofs,si
push es
call AllocSelector
mov PtrRec[ME_Data].Sel,ax
call UpdateSel
push ds
pop es {ES nun Datensegment}
push ds
lds si,[ME_Data]
mov di,offset OrigBytes
mov cx,5
cld
rep movsb
pop ds
call SetBreak {Breakpoint setzen}
end;
procedure HookUninstall; assembler;
asm call SetBytes
push PtrRec[ME_Data].Sel
call FreeSelector {Alias-Selektor freigeben}
end;
var
OldExit: Pointer;
procedure NewExit;
begin
ExitProc:=OldExit;
HookUninstall;
end;
begin
if GetSystemMetrics(SM_SwapButton)<>0 then begin
ButtonDown:=8;
ButtonUp:=$10;
end;
HookInstall;
OldExit:=ExitProc;
ExitProc:=@NewExit;
end.
Detected encoding: OEM (CP437) | 1
|
|