VM-Exit handler for I/O Instructions (in/out).
25{
30
31
32
33
34
35
36
37
38 union
39 {
43
45 UINT64 AsUInt64;
46
47 } PortValue;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 if (IoQualification.StringInstruction)
66 {
67
68
69
70
71 PortValue.AsPtr = (
PVOID)(IoQualification.DirectionOfAccess ==
AccessIn ? GuestRegs->
rdi : GuestRegs->
rsi);
72 }
73 else
74 {
75
76
77
78 PortValue.AsPtr = &GuestRegs->
rax;
79 }
80
81
82
83
84 Port = (
UINT16)IoQualification.PortNumber;
85
86
87
88
89
90
91 Count = IoQualification.RepPrefixed ? (GuestRegs->
rcx & 0xffffffff) : 1;
92
93 Size = (
UINT32)(IoQualification.SizeOfAccess + 1);
94
95 switch (IoQualification.DirectionOfAccess)
96 {
98 if (IoQualification.StringInstruction)
99 {
100 switch (Size)
101 {
102 case 1:
104 break;
105 case 2:
107 break;
108 case 4:
110 break;
111 }
112 }
113 else
114 {
115
116
117
118
119
120 switch (Size)
121 {
122 case 1:
123 *PortValue.AsBytePtr =
IoInByte(Port);
124 break;
125 case 2:
126 *PortValue.AsWordPtr =
IoInWord(Port);
127 break;
128 case 4:
130 break;
131 }
132 }
133 break;
134
136 if (IoQualification.StringInstruction)
137 {
138 switch (Size)
139 {
140 case 1:
142 break;
143 case 2:
145 break;
146 case 4:
148 break;
149 }
150 }
151 else
152 {
153
154
155
156
157
158 switch (Size)
159 {
160 case 1:
162 break;
163 case 2:
165 break;
166 case 4:
168 break;
169 }
170 }
171 break;
172 }
173
174 if (IoQualification.StringInstruction)
175 {
176
177
178
179
180
181
182
183 UINT64 GpReg = IoQualification.DirectionOfAccess ==
AccessIn ? GuestRegs->
rdi : GuestRegs->
rsi;
184
185 if (Flags.DirectionFlag)
186 {
187 GpReg -= Count * Size;
188 }
189 else
190 {
191 GpReg += Count * Size;
192 }
193
194
195
196
197
198 if (IoQualification.RepPrefixed)
199 {
201 }
202 }
203}
UINT32 IoInDword(UINT16 port)
Definition IoHandler.h:55
VOID IoOutByteString(UINT16 port, UINT8 *data, UINT32 count)
Definition IoHandler.h:97
VOID IoInByteString(UINT16 port, UINT8 *data, UINT32 size)
Definition IoHandler.h:61
VOID IoOutByte(UINT16 port, UINT8 value)
Definition IoHandler.h:79
VOID IoOutWordString(UINT16 port, UINT16 *data, UINT32 count)
Definition IoHandler.h:103
@ AccessOut
Definition IoHandler.h:24
@ AccessIn
Definition IoHandler.h:25
UINT16 IoInWord(UINT16 port)
Definition IoHandler.h:49
UINT8 IoInByte(UINT16 port)
Definition IoHandler.h:43
VOID IoOutDword(UINT16 port, UINT32 value)
Definition IoHandler.h:91
VOID IoInDwordString(UINT16 port, UINT32 *data, UINT32 size)
Definition IoHandler.h:73
VOID IoInWordString(UINT16 port, UINT16 *data, UINT32 size)
Definition IoHandler.h:67
VOID IoOutDwordString(UINT16 port, UINT32 *data, UINT32 count)
Definition IoHandler.h:109
VOID IoOutWord(UINT16 port, UINT16 value)
Definition IoHandler.h:85
GUEST_REGS * Regs
Definition State.h:326
UINT64 rdi
Definition BasicTypes.h:148
UINT64 rax
Definition BasicTypes.h:141
UINT64 rcx
Definition BasicTypes.h:142
UINT64 rsi
Definition BasicTypes.h:147