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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
/*++
Copyright (c) 1991 Microsoft Corporation
Module Name:
vdm.h
Abstract:
This include file defines the usermode visible portions of the vdm support
Author:
Revision History:
--*/
/* XLATOFF */
#ifndef _VDM_H_
#define _VDM_H_
typedef enum _VdmServiceClass {
VdmStartExecution, // is also defined in ntos\ke\i386\biosa.asm
VdmQueueInterrupt,
VdmDelayInterrupt,
VdmInitialize,
VdmFeatures,
VdmSetInt21Handler,
VdmQueryDir,
VdmPrinterDirectIoOpen,
VdmPrinterDirectIoClose,
} VDMSERVICECLASS, *PVDMSERVICECLASS;
#if defined (_NTDEF_)
NTSTATUS
NtVdmControl(
IN VDMSERVICECLASS Service,
IN OUT PVOID ServiceData
);
typedef struct _VdmQueryDirInfo {
HANDLE FileHandle;
PVOID FileInformation;
ULONG Length;
PUNICODE_STRING FileName;
ULONG FileIndex;
} VDMQUERYDIRINFO, *PVDMQUERYDIRINFO;
#endif
/*
* The Vdm Virtual Ica
* note: this structure definition is duplicated in
* mvdm\softpc\base\inc\ica.c. KEEP IN SYNC
*
*/
typedef struct _VdmVirtualIca{
LONG ica_count[8]; /* Count of Irq pending not in irr */
LONG ica_int_line; /* Current pending interrupt */
LONG ica_cpu_int; /* The state of the INT line to the CPU */
USHORT ica_base; /* Interrupt base address for cpu */
USHORT ica_hipri; /* Line no. of highest priority line */
USHORT ica_mode; /* Various single-bit modes */
UCHAR ica_master; /* 1 = Master; 0 = Slave */
UCHAR ica_irr; /* Interrupt Request Register */
UCHAR ica_isr; /* In Service Register */
UCHAR ica_imr; /* Interrupt Mask Register */
UCHAR ica_ssr; /* Slave Select Register */
} VDMVIRTUALICA, *PVDMVIRTUALICA;
//
// copied from softpc\base\system\ica.c
//
#define ICA_AEOI 0x0020
#define ICA_SMM 0x0200
#define ICA_SFNM 0x0100
#if defined(i386)
#define VDM_PM_IRETBOPSEG 0x147
#define VDM_PM_IRETBOPOFF 0x6
#define VDM_PM_IRETBOPSIZE 8
#else
#define VDM_PM_IRETBOPSEG 0xd3
#define VDM_PM_IRETBOPOFF 0x0
#define VDM_PM_IRETBOPSIZE 4
#endif
#define VDM_RM_IRETBOPSIZE 4
// VDM state which was earlier in vdmtib->flags has been moved to
// dos arena at following fixed address.
#ifdef _VDMNTOS_
#define FIXED_NTVDMSTATE_LINEAR VdmFixedStateLinear
#define FIXED_NTVDMSTATE_SIZE 4
#else // _VDMNTOS_
/* XLATON */
#if defined(_PC98_)
#define FIXED_NTVDMSTATE_SEGMENT 0x60
#else // !_PC98_
#define FIXED_NTVDMSTATE_SEGMENT 0x70
#endif // _PC98_
#define FIXED_NTVDMSTATE_OFFSET 0x14
#define FIXED_NTVDMSTATE_LINEAR ((FIXED_NTVDMSTATE_SEGMENT << 4) + FIXED_NTVDMSTATE_OFFSET)
#define FIXED_NTVDMSTATE_SIZE 4
/* XLATOFF */
#endif // _VDMNTOS_
#if defined (i386)
// defined on x86 only since on mips we must reference thru sas
#define pNtVDMState ((PULONG)FIXED_NTVDMSTATE_LINEAR)
#endif
/* XLATON */
//
// Vdm State Flags
//
#define VDM_INT_HARDWARE 0x00000001
#define VDM_INT_TIMER 0x00000002
// A bitMask which includes all interrupts
#define VDM_INTERRUPT_PENDING (VDM_INT_HARDWARE | VDM_INT_TIMER)
#define VDM_BREAK_EXCEPTIONS 0x00000008
#define VDM_BREAK_DEBUGGER 0x00000010
#define VDM_PROFILE 0x00000020
#define VDM_ANALYZE_PROFILE 0x00000040
#define VDM_32BIT_APP 0x00000100
#define VDM_VIRTUAL_INTERRUPTS 0x00000200
#define VDM_ON_MIPS 0x00000400
#define VDM_EXEC 0x00000800
#define VDM_RM 0x00001000
#define VDM_WOWBLOCKED 0x00100000
#define VDM_IDLEACTIVITY 0x00200000
#define VDM_TIMECHANGE 0x00400000
#define VDM_WOWHUNGAPP 0x00800000
#define VDM_PE_MASK 0x80000000
/* XLATOFF */
//
// If the size of the structure is changed, ke\i386\instemul.asm must
// be modified too. If not, it will fail to build
//
#pragma pack(1)
typedef struct _Vdm_InterruptHandler {
USHORT CsSelector;
USHORT Flags;
ULONG Eip;
} VDM_INTERRUPTHANDLER, *PVDM_INTERRUPTHANDLER;
#pragma pack()
typedef struct _Vdm_FaultHandler {
USHORT CsSelector;
USHORT SsSelector;
ULONG Eip;
ULONG Esp;
ULONG Flags;
} VDM_FAULTHANDLER, *PVDM_FAULTHANDLER;
#pragma pack(1)
/* XLATON */
typedef struct _VdmPmStackInfo { /* VDMTIB */
USHORT LockCount;
USHORT Flags;
USHORT SsSelector;
USHORT SaveSsSelector;
ULONG SaveEsp;
ULONG SaveEip;
ULONG DosxIntIret;
ULONG DosxIntIretD;
ULONG DosxFaultIret;
ULONG DosxFaultIretD;
} VDM_PMSTACKINFO, *PVDM_PMSTACKINFO;
/* XLATOFF */
#pragma pack()
#if defined(i386)
typedef struct _VdmIcaUserData {
PVOID pIcaLock; // rtl critical section
PVDMVIRTUALICA pIcaMaster;
PVDMVIRTUALICA pIcaSlave;
PULONG pDelayIrq;
PULONG pUndelayIrq;
PULONG pDelayIret;
PULONG pIretHooked;
PULONG pAddrIretBopTable;
PHANDLE phWowIdleEvent;
}VDMICAUSERDATA, *PVDMICAUSERDATA;
typedef struct _VdmDelayIntsServiceData {
ULONG Delay; /* Delay Time in usecs */
ULONG DelayIrqLine; /* IRQ Number of ints delayed */
HANDLE hThread; /* Thread Handle of CurrentMonitorTeb */
}VDMDELAYINTSDATA, *PVDMDELAYINTSDATA;
typedef struct _VDMSET_INT21_HANDLER_DATA {
ULONG Selector;
ULONG Offset;
BOOLEAN Gate32;
}VDMSET_INT21_HANDLER_DATA, *PVDMSET_INT21_HANDLER_DATA;
#if defined (_NTDEF_)
NTSTATUS
NtVdmControl(
IN VDMSERVICECLASS Service,
IN OUT PVOID ServiceData
);
//
// Interrupt handler flags
//
#define VDM_INT_INT_GATE 0x00000001
#define VDM_INT_TRAP_GATE 0x00000000
#define VDM_INT_32 0x00000002
#define VDM_INT_16 0x00000000
typedef enum _VdmEventClass {
VdmIO,
VdmStringIO,
VdmMemAccess,
VdmIntAck,
VdmBop,
VdmError,
VdmIrq13,
VdmMaxEvent
} VDMEVENTCLASS, *PVDMEVENTCLASS;
// VdmPrinterInfo
#define VDM_NUMBER_OF_LPT 3
#define PRT_MODE_NO_SIMULATION 1
#define PRT_MODE_SIMULATE_STATUS_PORT 2
#define PRT_MODE_DIRECT_IO 3
#define PRT_MODE_VDD_CONNECTED 4
#define PRT_DATA_BUFFER_SIZE 16
typedef struct _Vdm_Printer_Info {
PUCHAR prt_State;
PUCHAR prt_Control;
PUCHAR prt_Status;
PUCHAR prt_HostState;
USHORT prt_PortAddr[VDM_NUMBER_OF_LPT];
HANDLE prt_Handle[VDM_NUMBER_OF_LPT];
UCHAR prt_Mode[VDM_NUMBER_OF_LPT];
USHORT prt_BytesInBuffer[VDM_NUMBER_OF_LPT];
UCHAR prt_Buffer[VDM_NUMBER_OF_LPT][PRT_DATA_BUFFER_SIZE];
ULONG prt_Scratch;
} VDM_PRINTER_INFO, *PVDM_PRINTER_INFO;
typedef struct _VdmIoInfo {
USHORT PortNumber;
USHORT Size;
BOOLEAN Read;
} VDMIOINFO, *PVDMIOINFO;
typedef struct _VdmFaultInfo{
ULONG FaultAddr;
ULONG RWMode;
} VDMFAULTINFO, *PVDMFAULTINFO;
typedef struct _VdmStringIoInfo {
USHORT PortNumber;
USHORT Size;
BOOLEAN Rep;
BOOLEAN Read;
ULONG Count;
ULONG Address;
} VDMSTRINGIOINFO, *PVDMSTRINGIOINFO;
typedef ULONG VDMBOPINFO;
typedef NTSTATUS VDMERRORINFO;
typedef ULONG VDMINTACKINFO;
#define VDMINTACK_RAEOIMASK 0x0000ffff
#define VDMINTACK_SLAVE 0x00010000
#define VDMINTACK_AEOI 0x00020000
typedef struct _VdmEventInfo {
ULONG Size;
VDMEVENTCLASS Event;
ULONG InstructionSize;
union {
VDMIOINFO IoInfo;
VDMSTRINGIOINFO StringIoInfo;
VDMBOPINFO BopNumber;
VDMFAULTINFO FaultInfo;
VDMERRORINFO ErrorStatus;
VDMINTACKINFO IntAckInfo;
};
} VDMEVENTINFO, *PVDMEVENTINFO;
// Sudeepb 12-Mar-1993
// Scratch areas are used from VDMTib to get user space while
// in kernel. This allows us to make Nt APIs (faster) from kernel
// rather than Zw apis (slower). These are currently being used
// for DOS read/write.
typedef struct _Vdm_Tib {
ULONG Size;
VDM_INTERRUPTHANDLER VdmInterruptHandlers[256];
VDM_FAULTHANDLER VdmFaultHandlers[32];
CONTEXT MonitorContext;
CONTEXT VdmContext;
VDMEVENTINFO EventInfo;
VDM_PRINTER_INFO PrinterInfo;
ULONG TempArea1[2]; // Scratch area
ULONG TempArea2[2]; // Scratch aArea
VDM_PMSTACKINFO PmStackInfo;
} VDM_TIB, *PVDM_TIB;
#define EFLAGS_TF_MASK 0x00000100
#define EFLAGS_NT_MASK 0x00004000
//
// Feature flags returned by NtVdmControl(VdmFeatures...)
//
// System/processor supports fast emulation for IF instructions
#define V86_VIRTUAL_INT_EXTENSIONS 0x00000001 // in v86 mode
#define PM_VIRTUAL_INT_EXTENSIONS 0x00000002 // in protected mode (non-flat)
#endif // if defined _NTDEF_
#endif
#endif
|