-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfmouse.asm
executable file
·171 lines (115 loc) · 3.44 KB
/
fmouse.asm
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
;/*
;* fmouse.asm
;*
;* Virtual Device Driver that sends fake
;* mouse movements to the VMOUSE driver
;* to feign a mouse motion
;*
;* date: Nov., 28 2000
;* (C) Adrian Glaubitz
;*/
.386p ; yes, we wanna use 386 protected mode instructions
INCLUDE Vmm.inc
INCLUDE Vmd.inc
WM_MOVEMOUSE Equ 0FFEH
WM_SETMOUSE Equ 0FFFH
; virtual device declaration
Declare_Virtual_Device FMOUSE, 4, 0, FMouse_Control, Undefined_Device_ID
VxD_LOCKED_DATA_SEG
InputBfAdress dd 0
CurrentX dd 0
CurrentY dd 0
ButtonStatus db 0
VxD_LOCKED_DATA_ENDS
VxD_LOCKED_CODE_SEG
BeginProc FMouse_Control
Control_Dispatch SYS_DYNAMIC_DEVICE_INIT, FMouse_Dynamic_Init
Control_Dispatch SYS_DYNAMIC_DEVICE_EXIT, FMouse_Dynamic_Exit
Control_Dispatch W32_DEVICEIOCONTROL, FMouse_DeviceIOControl
clc
ret
EndProc FMouse_Control
; W32_DEVICEIOCONTROL message handler
BeginProc FMouse_DeviceIOControl
; load DIOCParams.dwIoControl into EAX
mov eax, [esi + 12]
; jump corresponding to the dwIOControl member
mov edx, [esi + 16]
mov [InputBfAdress], edx
cmp eax, DIOC_OPEN
jz short DeviceIOControlOpen
cmp eax, DIOC_CLOSEHANDLE
jz short DeviceIOControlCloseHandle
cmp eax, WM_MOVEMOUSE
jz short MoveMouse
cmp eax, WM_SETMOUSE
jz short SetMouse
DeviceIOControlDone:
clc
ret
DeviceIOControlOpen:
; must return 0 in EAX
xor eax, eax
jmp short DeviceIOControlDone
DeviceIOControlCloseHandle:
; must return VXD_SUCCESS in EAX
mov eax, VXD_SUCCESS
jmp short DeviceIOControlDone
; it is very likely that it's not needed to check the coordinates
; whether they exceed a special bounding, is it ?
MoveMouse:
VxDcall VMD_Get_Version ; is this the fixed version of vmouse ?
cmp ax, 400h
jb short DeviceIOControlDone
mov edx, [InputBfAdress]
mov eax, [edx] ; DWORD PTR [[esi + 16]]
add [CurrentX], eax
mov eax, [edx + 4] ; DWORD PTR [[esi + 16] + 4]
add [CurrentY], eax
mov [ButtonStatus], 0
; prepare them for call
mov esi, [CurrentX]
mov edi, [CurrentY]
mov al, [ButtonStatus]
; post them to VMOUSE
VxDcall VMD_Post_Absolute_Pointer_Message
jmp short DeviceIOControlDone
SetMouse:
; set values
; sorry for the mass of mov's, but if i use
; "mov DeltaX, [esi + 16]" i get an A2023
VxDcall VMD_Get_Version ; is this the fixed version of vmouse ?
cmp ax, 400h
jb short DeviceIOControlDone
mov edx, [InputBfAdress]
mov eax, [edx] ; DWORD PTR [[esi + 16]]
mov [CurrentX], eax
mov eax, [edx + 4] ; DWORD PTR [[esi + 16] + 4]
mov [CurrentY], eax
mov al, [edx + 8] ; BYTE PTR [[esi + 16] + 8]
mov [ButtonStatus], al
; prepare them for call
mov esi, [CurrentX]
mov edi, [CurrentY]
mov al, [ButtonStatus]
; post them to VMOUSE
VxDcall VMD_Post_Absolute_Pointer_Message
jmp DeviceIOControlDone
EndProc FMouse_DeviceIOControl
; SYS_DYNAMIC_DEVICE_EXIT message handler
BeginProc FMouse_Dynamic_Exit
mov eax, 1
clc
ret
EndProc FMouse_Dynamic_Exit
VxD_LOCKED_CODE_ENDS
VxD_ICODE_SEG
; SYS_DYNAMIC_DEVICE_INIT message handler
BeginProc FMouse_Dynamic_Init
mov eax, 1
clc
ret
EndProc FMouse_Dynamic_Init
VxD_ICODE_ENDS
END