00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
#include "ki.h"
00027
#pragma hdrstop
00028
#include "vdmntos.h"
00029
00030 #define IDT_ACCESS_DPL_USER 0x6000
00031 #define IDT_ACCESS_TYPE_386_TRAP 0xF00
00032 #define IDT_ACCESS_TYPE_286_TRAP 0x700
00033 #define IDT_ACCESS_PRESENT 0x8000
00034 #define LDT_MASK 4
00035
00036
00037
00038
00039
00040 BOOLEAN
00041
Ki386GetSelectorParameters(
00042 IN USHORT Selector,
00043 OUT PULONG Flags,
00044 OUT PULONG Base,
00045 OUT PULONG Limit
00046 );
00047
00048
00049
00050
00051
00052
VOID
00053
Ki386LoadTargetInt21Entry (
00054 IN PKIPI_CONTEXT SignalDone,
00055 IN PVOID Parameter1,
00056 IN PVOID Parameter2,
00057 IN PVOID Parameter3
00058 );
00059
00060 #define KiLoadInt21Entry() \
00061
KeGetPcr()->IDT[0x21] = PsGetCurrentProcess()->Pcb.Int21Descriptor
00062
00063
NTSTATUS
00064 Ke386SetVdmInterruptHandler (
00065
PKPROCESS Process,
00066 ULONG Interrupt,
00067 USHORT Selector,
00068 ULONG Offset,
00069 BOOLEAN Gate32
00070 )
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 {
00103
00104 KIRQL OldIrql;
00105 BOOLEAN LocalProcessor;
00106 KAFFINITY TargetProcessors;
00107 PKPRCB Prcb;
00108 KIDTENTRY IdtDescriptor;
00109 ULONG Flags, Base, Limit;
00110
00111
00112
00113
00114
00115
00116
00117
if (Interrupt != 0x21 ||
Offset >= (ULONG)MM_HIGHEST_USER_ADDRESS ||
00118 !
Ki386GetSelectorParameters(Selector, &Flags, &Base, &Limit) ){
00119
return(STATUS_INVALID_PARAMETER);
00120 }
00121
00122
00123
00124
00125
00126 IdtDescriptor.Offset = (
USHORT)
Offset;
00127 IdtDescriptor.Selector = Selector | RPL_MASK |
LDT_MASK;
00128 IdtDescriptor.ExtendedOffset = (
USHORT)(
Offset >> 16);
00129 IdtDescriptor.Access =
IDT_ACCESS_DPL_USER |
IDT_ACCESS_PRESENT;
00130
if (Gate32) {
00131 IdtDescriptor.Access |=
IDT_ACCESS_TYPE_386_TRAP;
00132
00133 }
else {
00134 IdtDescriptor.Access |=
IDT_ACCESS_TYPE_286_TRAP;
00135 }
00136
00137
00138
00139
00140
00141
KiLockContextSwap(&OldIrql);
00142
00143
00144
00145
00146
00147 Process->Int21Descriptor = IdtDescriptor;
00148
00149
00150
00151
00152
00153
#if !defined(NT_UP)
00154
00155 Prcb =
KeGetCurrentPrcb();
00156 TargetProcessors = Process->
ActiveProcessors & ~Prcb->SetMember;
00157
if (TargetProcessors != 0) {
00158
KiIpiSendPacket(TargetProcessors,
00159
Ki386LoadTargetInt21Entry,
00160
NULL,
00161
NULL,
00162
NULL);
00163 }
00164
00165
#endif
00166
00167
KiLoadInt21Entry();
00168
00169
#if !defined(NT_UP)
00170
00171
00172
00173
00174
00175
00176
if (TargetProcessors != 0) {
00177
KiIpiStallOnPacketTargets(TargetProcessors);
00178 }
00179
00180
#endif
00181
00182
00183
00184
00185
00186
KiUnlockContextSwap(OldIrql);
00187
return STATUS_SUCCESS;
00188 }
00189
00190
#if !defined(NT_UP)
00191
00192
00193
VOID
00194 Ki386LoadTargetInt21Entry (
00195 IN PKIPI_CONTEXT PacketContext,
00196 IN PVOID Parameter1,
00197 IN PVOID Parameter2,
00198 IN PVOID Parameter3
00199 )
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 {
00218
00219
00220
00221
00222
00223
KiLoadInt21Entry();
00224
KiIpiSignalPacketDone(PacketContext);
00225
return;
00226 }
00227
00228
#endif