00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#include "mi.h"
00023
00024 PVOID
00025 MmDbgReadCheck (
00026 IN PVOID VirtualAddress
00027 )
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 {
00058
if ((VirtualAddress >= (PVOID)
KSEG0_BASE) &&
00059 (VirtualAddress < (PVOID)
KSEG2_BASE)) {
00060
return VirtualAddress;
00061 }
00062
00063
if (!
MmIsAddressValid (VirtualAddress)) {
00064
if (KiProbeEntryTb(VirtualAddress)) {
00065
return VirtualAddress;
00066 }
00067
return NULL;
00068 }
00069
00070
return VirtualAddress;
00071 }
00072
00073 PVOID
00074 MmDbgWriteCheck (
00075 IN PVOID VirtualAddress
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
00105
00106
00107
00108
00109
00110
00111 {
00112
PMMPTE PointerPte;
00113
00114
if ((VirtualAddress >= (PVOID)
KSEG0_BASE) &&
00115 (VirtualAddress < (PVOID)
KSEG2_BASE)) {
00116
return VirtualAddress;
00117 }
00118
00119
if (!
MmIsAddressValid (VirtualAddress)) {
00120
00121
00122
00123
00124
00125
if (KiProbeEntryTb(VirtualAddress)) {
00126
return VirtualAddress;
00127 }
00128
return NULL;
00129 }
00130
00131 PointerPte =
MiGetPteAddress (VirtualAddress);
00132
00133
if ((ULONG) VirtualAddress <
KSEG0_BASE && PointerPte->
u.Hard.Dirty == 0) {
00134
return NULL;
00135 }
00136
00137
return VirtualAddress;
00138 }
00139
00140 PVOID64
00141 MmDbgReadCheck64 (
00142 IN PVOID64 VirtualAddress
00143 )
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 {
00174
00175
#ifdef VLM_SUPPORT
00176
if (!MmIsAddressValid64 (VirtualAddress)) {
00177
return NULL;
00178 }
00179
00180
return VirtualAddress;
00181
#else
00182
return NULL;
00183
#endif
00184
}
00185
00186 PVOID64
00187 MmDbgWriteCheck64 (
00188 IN PVOID64 VirtualAddress
00189 )
00190
00191
00192
00193
00194
00195
00196
00197
00198
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
00224 {
00225
#ifdef VLM_SUPPORT
00226
PMMPTE PointerPte;
00227
00228
if (!MmIsAddressValid64 (VirtualAddress)) {
00229
return NULL;
00230 }
00231
00232 PointerPte =
MiGetPteAddress64 (VirtualAddress);
00233
00234
if (PointerPte->
u.Hard.Dirty == 0) {
00235
return NULL;
00236 }
00237
00238
return VirtualAddress;
00239
#else
00240
return NULL;
00241
#endif
00242
}
00243
00244 PVOID
00245 MmDbgTranslatePhysicalAddress (
00246 IN PHYSICAL_ADDRESS PhysicalAddress
00247 )
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 {
00280 PVOID BaseAddress;
00281
PMMPTE BasePte;
00282
PMMPFN Pfn1;
00283 ULONG Page;
00284
00285 BasePte =
MmDebugPte + (
MM_NUMBER_OF_COLORS - 1);
00286 BasePte = (
PMMPTE)((ULONG)BasePte & ~(
MM_COLOR_MASK <<
PTE_SHIFT));
00287
00288 Page = (ULONG)(PhysicalAddress.QuadPart >>
PAGE_SHIFT);
00289
00290
if ((Page > (LONGLONG)
MmHighestPhysicalPage) ||
00291 (Page < (LONGLONG)
MmLowestPhysicalPage)) {
00292
return NULL;
00293 }
00294
00295 Pfn1 =
MI_PFN_ELEMENT (Page);
00296
00297
if (!
MmIsAddressValid (Pfn1)) {
00298
return NULL;
00299 }
00300
00301 BasePte = BasePte + Pfn1->
u3.e1.PageColor;
00302
00303 BaseAddress =
MiGetVirtualAddressMappedByPte (BasePte);
00304
00305
KiFlushSingleTb (
TRUE, BaseAddress);
00306
00307 *BasePte =
ValidKernelPte;
00308 BasePte->
u.Hard.PageFrameNumber = Page;
00309
return (PVOID)((ULONG)BaseAddress +
BYTE_OFFSET(PhysicalAddress.LowPart));
00310 }