1 #include "all.h"
2
3 void
setmousepoint(Point p)4 setmousepoint(Point p)
5 {
6 Ureg u;
7
8 memset(&u, 0, sizeof u);
9 u.cx = BackSetptrloc;
10 u.bx = (p.x<<16) | p.y;
11 backdoor(&u, 1);
12 }
13
14 Point
getmousepoint(void)15 getmousepoint(void)
16 {
17 Point p;
18 Ureg u;
19
20 memset(&u, 0, sizeof u);
21 u.cx = BackGetptrloc;
22 backdoor(&u, 0);
23 p.x = (signed)((u.ax>>16)&0xFFFF);
24 p.y = (signed)(u.ax & 0xFFFF);
25 return p;
26 }
27
28 int
getsnarflength(void)29 getsnarflength(void)
30 {
31 Ureg u;
32
33 memset(&u, 0, sizeof u);
34 u.cx = BackGetsellength;
35 backdoor(&u, 0);
36 return u.ax;
37 }
38
39 uint
getsnarfpiece(void)40 getsnarfpiece(void)
41 {
42 Ureg u;
43
44 memset(&u, 0, sizeof u);
45 u.cx = BackGetnextpiece;
46 backdoor(&u, 0);
47 return u.ax;
48 }
49
50 void
setsnarflength(uint len)51 setsnarflength(uint len)
52 {
53 Ureg u;
54
55 memset(&u, 0, sizeof u);
56 u.cx = BackSetsellength;
57 u.bx = len;
58 backdoor(&u, 1);
59 }
60
61 void
setsnarfpiece(uint p)62 setsnarfpiece(uint p)
63 {
64 Ureg u;
65
66 memset(&u, 0, sizeof u);
67 u.cx = BackSetnextpiece;
68 u.bx = p;
69 backdoor(&u, 1);
70 }
71
72 int
getversion(void)73 getversion(void)
74 {
75 Ureg u;
76 jmp_buf jb;
77
78 memset(&u, 0, sizeof u);
79 u.cx = BackGetversion;
80 memmove(jb, backdoorjmp, sizeof jb);
81 if(setjmp(backdoorjmp)){
82 memmove(backdoorjmp, jb, sizeof jb);
83 return -1;
84 }
85 backdoor(&u, 0);
86 memmove(backdoorjmp, jb, sizeof jb);
87 if(u.ax != VersionMagic || u.bx != BackMagic)
88 return -1;
89 return 0;
90 }
91
92 int
setdevicestate(uint id,int enable)93 setdevicestate(uint id, int enable)
94 {
95 Ureg u;
96
97 if(enable)
98 id |= 0x80000000;
99 memset(&u, 0, sizeof u);
100 u.cx = BackToggledev;
101 u.bx = id;
102 backdoor(&u, 0);
103 return u.ax;
104 }
105
106 int
getdeviceinfo(uint id,uint offset,uint * p)107 getdeviceinfo(uint id, uint offset, uint *p)
108 {
109 Ureg u;
110
111 memset(&u, 0, sizeof u);
112 u.bx = (id<<16) | offset;
113 u.cx = BackGetdevlistel;
114 backdoor(&u, 0);
115 *p = u.bx;
116 return u.ax;
117 }
118
119 void
setguistate(uint state)120 setguistate(uint state)
121 {
122 Ureg u;
123
124 memset(&u, 0, sizeof u);
125 u.bx = state;
126 u.cx = BackSetguiopt;
127 backdoor(&u, 1);
128 }
129
130 uint
getguistate(void)131 getguistate(void)
132 {
133 Ureg u;
134
135 memset(&u, 0, sizeof u);
136 u.cx = BackGetguiopt;
137 backdoor(&u, 0);
138 return u.ax;
139 }
140
141 uint
copystep(uint x)142 copystep(uint x)
143 {
144 Ureg u;
145
146 memset(&u, 0, sizeof u);
147 u.cx = BackHostcopy;
148 u.bx = x;
149 backdoor(&u, 0);
150 return u.ax;
151 }
152
153 void
gettime(uint * sec,uint * micro,uint * lag)154 gettime(uint *sec, uint *micro, uint *lag)
155 {
156 Ureg u;
157
158 memset(&u, 0, sizeof u);
159 u.cx = BackGettime;
160 backdoor(&u, 0);
161
162 *sec = u.ax;
163 *micro = u.bx;
164 *lag = u.cx;
165 }
166
167 void
stopcatchup(void)168 stopcatchup(void)
169 {
170 Ureg u;
171
172 memset(&u, 0, sizeof u);
173 u.cx = BackStopcatchup;
174 backdoor(&u, 0);
175 }
176