1 | /* $Id: $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * spy1 - header for structure and protptypes shared with the hook.
|
---|
5 | *
|
---|
6 | * Copyright (c) 2006 knut st. osmundsen <bird@anduin.net>
|
---|
7 | *
|
---|
8 | * GPL
|
---|
9 | *
|
---|
10 | */
|
---|
11 |
|
---|
12 | #ifndef __spy1_h__
|
---|
13 | #define __spy1_h__
|
---|
14 |
|
---|
15 | /** @name Various OS/2 stuff from the DDK.
|
---|
16 | * Mainly from video/rel/.../pmwinp.mac and pmwinx.h.
|
---|
17 | * @{ */
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Keyboard event.
|
---|
21 | */
|
---|
22 | typedef struct _KBDEVENT { /* kevt */
|
---|
23 | BYTE monFlags; /* Open, Close and Flush monitor flags */
|
---|
24 | BYTE scancode; /* Original scan code (actually high byte of
|
---|
25 | monitor flags */
|
---|
26 | BYTE xlatedchar; /* Output of interrupt level character translation
|
---|
27 | table */
|
---|
28 |
|
---|
29 | BYTE xlatedscan; /* Translated scan code. Different only for
|
---|
30 | the enhanced keyboard */
|
---|
31 |
|
---|
32 | USHORT shiftDBCS; /* DBCS shift state and status */
|
---|
33 | USHORT shiftstate; /* Current state of shift keys */
|
---|
34 | ULONG time; /* millisecond counter time stamp */
|
---|
35 | USHORT ddFlags; /* Keyboard device driver flags */
|
---|
36 | } KBDEVENT;
|
---|
37 | typedef KBDEVENT *PKBDEVENT;
|
---|
38 |
|
---|
39 | // guess MON_* are for the monFlags field.
|
---|
40 | #define MON_OPEN EQU 0001H
|
---|
41 | #define MON_CLOSE EQU 0002H
|
---|
42 | #define MON_FLUSH EQU 0004H
|
---|
43 | // guess KSS_* is for the shiftstate field.
|
---|
44 | #define KSS_SYSREQ EQU 8000H
|
---|
45 | #define KSS_CAPSLOCK EQU 4000H
|
---|
46 | #define KSS_NUMLOCK EQU 2000H
|
---|
47 | #define KSS_SCROLLLOCK EQU 1000H
|
---|
48 | #define KSS_RIGHTALT EQU 0800H
|
---|
49 | #define KSS_RIGHTCTRL EQU 0400H
|
---|
50 | #define KSS_LEFTALT EQU 0200H
|
---|
51 | #define KSS_LEFTCTRL EQU 0100H
|
---|
52 | #define KSS_INSERTON EQU 0080H
|
---|
53 | #define KSS_CAPSLOCKON EQU 0040H
|
---|
54 | #define KSS_NUMLOCKON EQU 0020H
|
---|
55 | #define KSS_SCROLLLOCKON EQU 0010H
|
---|
56 | #define KSS_EITHERALT EQU 0008H
|
---|
57 | #define KSS_EITHERCTRL EQU 0004H
|
---|
58 | #define KSS_LEFTSHIFT EQU 0002H
|
---|
59 | #define KSS_RIGHTSHIFT EQU 0001H
|
---|
60 | #define KSS_EITHERSHIFT EQU 0003H
|
---|
61 | /* Valid values for ddFlags field */
|
---|
62 | #define KDD_MONFLAG1 0x8000 // bird: conflicts with KDD_KC_LONEKEY - relevant for VIOCHAR?
|
---|
63 | #define KDD_MONFLAG2 0x4000 // bird: conflicts with KDD_KC_PREVDOWN - relevant for VIOCHAR?
|
---|
64 | #define KDD_RESERVED 0x3C00
|
---|
65 | #define KDD_ACCENTED 0x0200
|
---|
66 | #define KDD_MULTIMAKE 0x0100
|
---|
67 | #define KDD_SECONDARY 0x0080
|
---|
68 | #define KDD_BREAK 0x0040
|
---|
69 | #define KDD_EXTENDEDKEY 0x0020
|
---|
70 | #define KDD_ACTIONFIELD 0x001F
|
---|
71 | #define KDD_KC_LONEKEY 0x8000
|
---|
72 | #define KDD_KC_PREVDOWN 0x4000
|
---|
73 | #define KDD_KC_KEYUP 0x2000
|
---|
74 | #define KDD_KC_ALT 0x1000
|
---|
75 | #define KDD_KC_CTRL 0x0800
|
---|
76 | #define KDD_KC_SHIFT 0x0400
|
---|
77 | #define KDD_KC_FLAGS 0x0FC00
|
---|
78 | /* Valid values for KDD_ACTIONFIELD portion of ddFlags field */
|
---|
79 | #define KDD_PUTINKIB 0x0000
|
---|
80 | #define KDD_ACK 0x0001
|
---|
81 | #define KDD_PREFIXKEY 0x0002
|
---|
82 | #define KDD_OVERRUN 0x0003
|
---|
83 | #define KDD_RESEND 0x0004
|
---|
84 | #define KDD_REBOOTKEY 0x0005
|
---|
85 | #define KDD_DUMPKEY 0x0006
|
---|
86 | #define KDD_SHIFTKEY 0x0007
|
---|
87 | #define KDD_PAUSEKEY 0x0008
|
---|
88 | #define KDD_PSEUDOPAUSE 0x0009
|
---|
89 | #define KDD_WAKEUPKEY 0x000A
|
---|
90 | #define KDD_BADACCENT 0x000B
|
---|
91 | #define KDD_HOTKEY 0x000C
|
---|
92 | #define KDD_ACCENTKEY 0x0010
|
---|
93 | #define KDD_BREAKKEY 0x0011
|
---|
94 | #define KDD_PSEUDOBREAK 0x0012
|
---|
95 | #define KDD_PRTSCKEY 0x0013
|
---|
96 | #define KDD_PRTECHOKEY 0x0014
|
---|
97 | #define KDD_PSEUDOPRECH 0x0015
|
---|
98 | #define KDD_STATUSCHG 0x0016
|
---|
99 | #define KDD_WRITTENKEY 0x0017
|
---|
100 | #define KDD_UNDEFINED 0x001F
|
---|
101 |
|
---|
102 | /// PMWIN.174
|
---|
103 | KBDEVENT KbdPacket[2];
|
---|
104 |
|
---|
105 | /** @} */
|
---|
106 |
|
---|
107 |
|
---|
108 | /** The event type. */
|
---|
109 | typedef enum SPY1EVENTTYPE
|
---|
110 | {
|
---|
111 | /** The usual invalid entry. */
|
---|
112 | SPY1EVENTTYPE_INVALID = 0,
|
---|
113 | /** A qmsg being removed.
|
---|
114 | * SPY1EVENT::u::Msg contains the message. */
|
---|
115 | SPY1EVENTTYPE_MSG_REMOVED,
|
---|
116 | /** A qmsg being peeked at.
|
---|
117 | * SPY1EVENT::u::Msg contains the message. */
|
---|
118 | SPY1EVENTTYPE_MSG_PEEK
|
---|
119 | } SPY1EVENTTYPE;
|
---|
120 |
|
---|
121 | /**
|
---|
122 | * A recorded event.
|
---|
123 | */
|
---|
124 | typedef struct SPY1EVENT
|
---|
125 | {
|
---|
126 | /** the type of event. */
|
---|
127 | SPY1EVENTTYPE enmType;
|
---|
128 | /** The process in which we recorded the event. */
|
---|
129 | ULONG pid;
|
---|
130 | /** The thread in which we recorded the event. */
|
---|
131 | ULONG tid;
|
---|
132 | /** The hook type which recorded the event. */
|
---|
133 | ULONG ulHook;
|
---|
134 | /** Type specific data. */
|
---|
135 | union
|
---|
136 | {
|
---|
137 | /** A message. */
|
---|
138 | QMSG Msg;
|
---|
139 | /* ... more ... */
|
---|
140 | } u;
|
---|
141 | } SPY1EVENT, *PSPY1EVENT;
|
---|
142 |
|
---|
143 |
|
---|
144 | int EXPENTRY SetHooks(HAB hab);
|
---|
145 | int EXPENTRY ReleaseHooks(HAB hab);
|
---|
146 | int EXPENTRY GetEvent(PSPY1EVENT pEvent, ULONG ulTimeout);
|
---|
147 |
|
---|
148 |
|
---|
149 | /** @name The hook functions.
|
---|
150 | * @{ */
|
---|
151 | BOOL EXPENTRY InputHook(HAB hab, PQMSG pQmsg, ULONG fs);
|
---|
152 | VOID EXPENTRY JournalRecordHook(HAB hab, PQMSG pQmsg);
|
---|
153 | /** @} */
|
---|
154 |
|
---|
155 | #endif
|
---|
156 |
|
---|