test: i386/debugsup.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# debugsup.c File Reference

`#include "mi.h"`

Go to the source code of this file.

## Functions

PVOID | MmDbgReadCheck (IN PVOID VirtualAddress)
PVOID | MmDbgWriteCheck (IN PVOID VirtualAddress, IN PHARDWARE_PTE Opaque)
VOID | MmDbgReleaseAddress (IN PVOID VirtualAddress, IN PHARDWARE_PTE Opaque)
PVOID64 | MmDbgReadCheck64 (IN PVOID64 VirtualAddress)
PVOID64 | MmDbgWriteCheck64 (IN PVOID64 VirtualAddress)
PVOID64 | MmDbgTranslatePhysicalAddress64 (IN PHYSICAL_ADDRESS PhysicalAddress)

## Function Documentation

PVOID MmDbgReadCheck | ( | IN PVOID | VirtualAddress | ) |

Definition at line 25 of file i386/debugsup.c.

References MmIsAddressValid(), and NULL.

    00031                    :
    00032
    00033     i386/486 implementation specific:
    00034
    00035     This routine checks the specified virtual address and if it is
    00036     valid and readable, it returns that virtual address, otherwise
    00037     it returns NULL.
    00038
    00039 Arguments:
    00040
    00041     VirtualAddress - Supplies the virtual address to check.
    00042
    00043 Return Value:
    00044
    00045     Returns NULL if the address is not valid or readable, otherwise
    00046     returns the virtual address.
    00047
    00048 Environment:
    00049
    00050     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    00051
    00052 --*/
    00053
    00054 {
    00055
    00056     if (!MmIsAddressValid (VirtualAddress)) {
    00057         return NULL;
    00058     }
    00059
    00060     return VirtualAddress;
    00061
    00062 }

PVOID64 MmDbgReadCheck64 | ( | IN PVOID64 | VirtualAddress | ) |

Definition at line 222 of file i386/debugsup.c.

References NULL.

    00228                    :
    00229
    00230     i386/486 implementation specific:
    00231
    00232     This routine checks the specified virtual address and if it is
    00233     valid and readable, it returns that virtual address, otherwise
    00234     it returns NULL.
    00235
    00236     NO 64-bit support, returns NULL.
    00237
    00238 Arguments:
    00239
    00240     VirtualAddress - Supplies the virtual address to check.
    00241
    00242 Return Value:
    00243
    00244     Returns NULL if the address is not valid or readable, otherwise
    00245     returns the virtual address of the corresponding virtual address.
    00246
    00247 Environment:
    00248
    00249     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    00250
    00251 --*/
    00252
    00253 {
    00254     UNREFERENCED_PARAMETER (VirtualAddress);
    00255
    00256     return NULL;
    00257 }

VOID MmDbgReleaseAddress | ( | IN PVOID | VirtualAddress,
|  | IN PHARDWARE_PTE | Opaque
| ) |

Definition at line 162 of file i386/debugsup.c.

References ASSERT, MiGetPdeAddress, MiGetPteAddress, MmIsAddressValid(), TRUE, and _MMPTE::u.

    00169                    :
    00170
    00171     i386/486 implementation specific:
    00172
    00173     This routine resets the specified virtual address access permissions
    00174     to its original state.
    00175
    00176 Arguments:
    00177
    00178     VirtualAddress - Supplies the virtual address to check.
    00179
    00180     Opaque - Supplies an opaque pointer.
    00181
    00182 Return Value:
    00183
    00184     None.
    00185
    00186 Environment:
    00187
    00188     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    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     // LWFIX: checksum regen and clear checksum flag
    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 }

PVOID64 MmDbgTranslatePhysicalAddress64 | ( | IN PHYSICAL_ADDRESS | PhysicalAddress | ) |

Definition at line 298 of file i386/debugsup.c.

References BYTE_OFFSET, KiFlushSingleTb(), MiGetVirtualAddressMappedByPte, MmDebugPte, PAGE_SHIFT, TRUE, _MMPTE::u, and ValidKernelPte.

    00304                    :
    00305
    00306     i386/486 implementation specific:
    00307
    00308     This routine maps the specified physical address and returns
    00309     the virtual address which maps the physical address.
    00310
    00311     The next call to MmDbgTranslatePhysicalAddress removes the
    00312     previous physical address translation, hence on a single
    00313     physical address can be examined at a time (can't cross page
    00314     boundaries).
    00315
    00316 Arguments:
    00317
    00318     PhysicalAddress - Supplies the physical address to map and translate.
    00319
    00320 Return Value:
    00321
    00322     The virtual address which corresponds to the physical address.
    00323
    00324 Environment:
    00325
    00326     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    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 }
    }

PVOID MmDbgWriteCheck | ( | IN PVOID | VirtualAddress,
|  | IN PHARDWARE_PTE | Opaque
| ) |

Definition at line 65 of file i386/debugsup.c.

References FALSE, MI_MAKE_VALID_PTE, MiGetPdeAddress, MiGetPteAddress, MM_READWRITE, MmIsAddressValid(), NULL, TRUE, _MMPTE::u, and ValidKernelPde.

    00072                    :
    00073
    00074     i386/486 implementation specific:
    00075
    00076     This routine checks the specified virtual address and if it is
    00077     valid and writable, it returns that virtual address, otherwise
    00078     it returns NULL.
    00079
    00080 Arguments:
    00081
    00082     VirtualAddress - Supplies the virtual address to check.
    00083
    00084     Opaque - Supplies an opaque pointer.
    00085
    00086 Return Value:
    00087
    00088     Returns NULL if the address is not valid or writable, otherwise
    00089     returns the virtual address.
    00090
    00091 Environment:
    00092
    00093     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    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         // PTE is not writable, make it so.
    00128         //
    00129
    00130         PteContents = *PointerPte;
    00131
    00132         *InputPte = PteContents;
    00133
    00134         //
    00135         // Modify the PTE to ensure write permissions.
    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 }

PVOID64 MmDbgWriteCheck64 | ( | IN PVOID64 | VirtualAddress | ) |

Definition at line 260 of file i386/debugsup.c.

References NULL.

    00266                    :
    00267
    00268     i386/486 implementation specific:
    00269
    00270     This routine checks the specified virtual address and if it is
    00271     valid and writable, it returns that virtual address, otherwise
    00272     it returns NULL.
    00273
    00274 Arguments:
    00275
    00276     VirtualAddress - Supplies the virtual address to check.
    00277
    00278 Return Value:
    00279
    00280     Returns NULL if the address is not valid or writable, otherwise
    00281     returns the virtual address of the corresponding virtual address.
    00282
    00283     NO 64-bit support, returns NULL.
    00284
    00285 Environment:
    00286
    00287     Kernel mode IRQL at DISPATCH_LEVEL or greater.
    00288
    00289 --*/
    00290
    00291 {
    00292     UNREFERENCED_PARAMETER (VirtualAddress);
    00293
    00294     return NULL;
    00295 }