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

debugsup.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 debugsup.c 00008 00009 Abstract: 00010 00011 This module contains routines which provide support for the 00012 kernel debugger. 00013 00014 Author: 00015 00016 Lou Perazzoli (loup) 02-Aug-90 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #include "mi.h" 00023 00024 PVOID 00025 MmDbgReadCheck ( 00026 IN PVOID VirtualAddress 00027 ) 00028 00029 /*++ 00030 00031 Routine Description: 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 } 00063 00064 PVOID 00065 MmDbgWriteCheck ( 00066 IN PVOID VirtualAddress, 00067 IN PHARDWARE_PTE Opaque 00068 ) 00069 00070 /*++ 00071 00072 Routine Description: 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 } 00160 00161 VOID 00162 MmDbgReleaseAddress ( 00163 IN PVOID VirtualAddress, 00164 IN PHARDWARE_PTE Opaque 00165 ) 00166 00167 /*++ 00168 00169 Routine Description: 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 } 00220 00221 PVOID64 00222 MmDbgReadCheck64 ( 00223 IN PVOID64 VirtualAddress 00224 ) 00225 00226 /*++ 00227 00228 Routine Description: 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 } 00258 00259 PVOID64 00260 MmDbgWriteCheck64 ( 00261 IN PVOID64 VirtualAddress 00262 ) 00263 00264 /*++ 00265 00266 Routine Description: 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 } 00296 00297 PVOID64 00298 MmDbgTranslatePhysicalAddress64 ( 00299 IN PHYSICAL_ADDRESS PhysicalAddress 00300 ) 00301 00302 /*++ 00303 00304 Routine Description: 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 }

Generated on Sat May 15 19:39:39 2004 for test by doxygen 1.3.7