3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/ke/i386/vdm.c
6 * PURPOSE: Virtual DOS machine support
8 * PROGRAMMERS: David Welch (welch@mcmail.com)
11 /* INCLUDES *****************************************************************/
14 #include <internal/debug.h>
16 #if defined (ALLOC_PRAGMA)
17 #pragma alloc_text(INIT, NtEarlyInitVdm)
21 /* GLOBALS *******************************************************************/
23 static UCHAR OrigIVT
[1024];
24 static UCHAR OrigBDA
[256];
25 /* static UCHAR OrigEBDA[]; */
27 extern VOID
Ki386RetToV86Mode(PKV86M_REGISTERS InRegs
,
28 PKV86M_REGISTERS OutRegs
);
30 /* FUNCTIONS *****************************************************************/
35 /* GCC 3.4 warns if NULL is passed in parameter 2 to the standard function memcpy */
36 PVOID start
= (PVOID
)0x0;
39 * Save various BIOS data tables. At this point the lower 4MB memory
40 * map is still active so we can just copy the data from low memory.
42 memcpy(OrigIVT
, start
, 1024);
43 memcpy(OrigBDA
, (PVOID
)0x400, 256);
49 NTSTATUS STDCALL
NtVdmControl(ULONG ControlCode
,
52 KPROCESSOR_MODE PreviousMode
;
53 NTSTATUS Status
= STATUS_SUCCESS
;
55 PreviousMode
= ExGetPreviousMode();
57 if (PreviousMode
!= KernelMode
)
64 ProbeForWrite(ControlData
,
67 memcpy(ControlData
, OrigIVT
, 1024);
71 ProbeForWrite(ControlData
,
74 memcpy(ControlData
, OrigBDA
, 256);
79 KV86M_REGISTERS V86Registers
;
81 ProbeForWrite(ControlData
,
82 sizeof(KV86M_REGISTERS
),
86 sizeof(KV86M_REGISTERS
));
88 /* FIXME: This should use ->VdmObjects */
89 KeGetCurrentProcess()->Unused
= 1;
90 Ki386RetToV86Mode(&V86Registers
, &V86Registers
);
92 /* FIXME: This should use ->VdmObjects */
93 KeGetCurrentProcess()->Unused
= 0;
97 sizeof(KV86M_REGISTERS
));
104 Status
= _SEH_GetExceptionCode();