2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/vdm/vdmmain.c
5 * PURPOSE: VDM Support Services
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
15 /* GLOBALS *******************************************************************/
17 static UCHAR OrigIVT
[1024];
18 static UCHAR OrigBDA
[256];
20 /* PRIVATE FUNCTIONS *********************************************************/
26 PCHAR start
= MmCreateHyperspaceMapping(0);
27 memcpy(OrigIVT
, start
, 1024);
28 memcpy(OrigBDA
, start
+0x400, 256);
29 MmDeleteHyperspaceMapping(start
);
34 Ki386VdmEnablePentiumExtentions(VOID
)
36 DPRINT1("VME detected but not yet supported\n");
41 KeI386VdmInitialize(VOID
)
44 OBJECT_ATTRIBUTES ObjectAttributes
;
47 UCHAR KeyValueInfo
[sizeof(KEY_VALUE_BASIC_INFORMATION
) + 30];
50 /* Make sure that there is a WOW key */
51 RtlInitUnicodeString(&Name
,
52 L
"\\Registry\\Machine\\System\\CurrentControlSet\\"
54 InitializeObjectAttributes(&ObjectAttributes
,
59 Status
= ZwOpenKey(&RegHandle
, KEY_READ
, &ObjectAttributes
);
60 if (!NT_SUCCESS(Status
)) return;
62 /* Check if VME is enabled */
63 RtlInitUnicodeString(&Name
, L
"DisableVme");
64 Status
= ZwQueryValueKey(RegHandle
,
66 KeyValueBasicInformation
,
70 if (!NT_SUCCESS(Status
))
72 /* Not present, so check if the CPU supports VME */
73 if (KeGetPcr()->Prcb
->FeatureBits
& KF_V86_VIS
)
75 /* Enable them. FIXME: Use IPI */
76 Ki386VdmEnablePentiumExtentions();
77 KeI386VirtualIntExtensions
= TRUE
;
85 /* PUBLIC FUNCTIONS **********************************************************/
92 NtVdmControl(IN ULONG ControlCode
,
98 /* Check which control code this is */
101 /* VDM Execution start */
102 case VdmStartExecution
:
104 /* Call the sub-function */
105 Status
= VdmpStartExecution();
110 /* Pretty much a hack, since a lot more needs to happen */
111 memcpy(ControlData
, OrigIVT
, 1024);
112 memcpy((PVOID
)((ULONG_PTR
)ControlData
+ 1024), OrigBDA
, 256);
113 Status
= STATUS_SUCCESS
;
119 DPRINT1("Unknown VDM call: %lx\n", ControlCode
);
120 Status
= STATUS_INVALID_PARAMETER
;
123 /* Return the status */