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
if (!
MmIsAddressValid (VirtualAddress)) {
00057
return NULL;
00058 }
00059
00060
return VirtualAddress;
00061
00062 }
00063
00064 PVOID
00065 MmDbgWriteCheck (
00066 IN PVOID VirtualAddress,
00067 IN PHARDWARE_PTE Opaque
00068 )
00069
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
MMPTE TempPte;
00099
MMPTE PteContents;
00100
PMMPTE InputPte;
00101
PMMPTE PointerPte;
00102 LOGICAL LargePage;
00103
00104 InputPte = (
PMMPTE)Opaque;
00105
00106 InputPte->
u.Long = 0;
00107
00108
if (!
MmIsAddressValid (VirtualAddress)) {
00109
return NULL;
00110 }
00111
00112 PointerPte =
MiGetPdeAddress (VirtualAddress);
00113 LargePage =
TRUE;
00114
if (PointerPte->
u.Hard.LargePage == 0) {
00115 PointerPte =
MiGetPteAddress (VirtualAddress);
00116 LargePage =
FALSE;
00117 }
00118
00119
#if defined(NT_UP)
00120
if (PointerPte->
u.Hard.Write == 0)
00121
#else
00122
if (PointerPte->
u.Hard.Writable == 0)
00123
#endif
00124
{
00125
00126
00127
00128
00129
00130 PteContents = *PointerPte;
00131
00132 *InputPte = PteContents;
00133
00134
00135
00136
00137
00138
if (LargePage ==
TRUE) {
00139 TempPte =
ValidKernelPde;
00140 TempPte.
u.Hard.PageFrameNumber = PteContents.u.Hard.PageFrameNumber;
00141 TempPte.
u.Hard.LargePage = 1;
00142 }
00143
else {
00144
MI_MAKE_VALID_PTE (TempPte,
00145 PteContents.
u.Hard.PageFrameNumber,
00146
MM_READWRITE,
00147 PointerPte);
00148
#if !defined(NT_UP)
00149
TempPte.
u.Hard.Writable = 1;
00150
#endif
00151
}
00152
00153 *PointerPte = TempPte;
00154
00155 KeFillEntryTb ((PHARDWARE_PTE)PointerPte, VirtualAddress,
TRUE);
00156 }
00157
00158
return VirtualAddress;
00159 }
00160
00161
VOID
00162 MmDbgReleaseAddress (
00163 IN PVOID VirtualAddress,
00164 IN PHARDWARE_PTE Opaque
00165 )
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 {
00193
MMPTE TempPte;
00194
PMMPTE PointerPte;
00195
PMMPTE InputPte;
00196
00197 InputPte = (
PMMPTE)Opaque;
00198
00199
ASSERT (
MmIsAddressValid (VirtualAddress));
00200
00201
00202
00203
if (InputPte->
u.Long != 0) {
00204
00205 PointerPte =
MiGetPdeAddress (VirtualAddress);
00206
if (PointerPte->
u.Hard.LargePage == 0) {
00207 PointerPte =
MiGetPteAddress (VirtualAddress);
00208 }
00209
00210 TempPte = *InputPte;
00211 TempPte.
u.Hard.Dirty = 1;
00212
00213 *PointerPte = TempPte;
00214
00215 KeFillEntryTb ((PHARDWARE_PTE)PointerPte, VirtualAddress,
TRUE);
00216 }
00217
00218
return;
00219 }
00220
00221 PVOID64
00222 MmDbgReadCheck64 (
00223 IN PVOID64 VirtualAddress
00224 )
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 {
00254 UNREFERENCED_PARAMETER (VirtualAddress);
00255
00256
return NULL;
00257 }
00258
00259 PVOID64
00260 MmDbgWriteCheck64 (
00261 IN PVOID64 VirtualAddress
00262 )
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 {
00292 UNREFERENCED_PARAMETER (VirtualAddress);
00293
00294
return NULL;
00295 }
00296
00297 PVOID64
00298 MmDbgTranslatePhysicalAddress64 (
00299 IN PHYSICAL_ADDRESS PhysicalAddress
00300 )
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330 {
00331
MMPTE TempPte;
00332 PVOID BaseAddress;
00333
00334 BaseAddress =
MiGetVirtualAddressMappedByPte (
MmDebugPte);
00335
00336
KiFlushSingleTb (
TRUE, BaseAddress);
00337
00338 TempPte =
ValidKernelPte;
00339
00340 TempPte.
u.Hard.PageFrameNumber = (ULONG)(PhysicalAddress.QuadPart >>
PAGE_SHIFT);
00341
00342 *
MmDebugPte = TempPte;
00343
00344
return (PVOID64)((ULONG)BaseAddress +
BYTE_OFFSET(PhysicalAddress.LowPart));
00345 }