mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 07:52:56 +00:00
- Replaced MmGetPageEntry with MmGetPageProtect/MmSetPageProtect in KdbOverwriteInst.
svn path=/trunk/; revision=10484
This commit is contained in:
parent
bc751c87d7
commit
a91173016c
1 changed files with 20 additions and 30 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: kdb.c,v 1.26 2004/08/10 01:49:36 navaraf Exp $
|
/* $Id: kdb.c,v 1.27 2004/08/10 19:49:25 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/dbg/kdb.c
|
* FILE: ntoskrnl/dbg/kdb.c
|
||||||
|
@ -165,7 +165,6 @@ volatile DWORD x_dr0 = 0, x_dr1 = 0, x_dr2 = 0, x_dr3 = 0, x_dr7 = 0;
|
||||||
|
|
||||||
extern LONG KdbDisassemble(ULONG Address);
|
extern LONG KdbDisassemble(ULONG Address);
|
||||||
extern LONG KdbGetInstLength(ULONG Address);
|
extern LONG KdbGetInstLength(ULONG Address);
|
||||||
extern PULONG MmGetPageEntry(PVOID PAddress, BOOL CreatePde);
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -408,49 +407,40 @@ KdbDecodeAddress(PUCHAR Buffer, PULONG Address)
|
||||||
NTSTATUS STATIC
|
NTSTATUS STATIC
|
||||||
KdbOverwriteInst(ULONG Address, PUCHAR PreviousInst, UCHAR NewInst)
|
KdbOverwriteInst(ULONG Address, PUCHAR PreviousInst, UCHAR NewInst)
|
||||||
{
|
{
|
||||||
PULONG BreakPtePtr;
|
|
||||||
ULONG SavedPte;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
/* Get the pte for the page containing the address. */
|
ULONG Protect;
|
||||||
BreakPtePtr = MmGetPageEntry((PVOID)PAGE_ROUND_DOWN(Address), FALSE);
|
/* Get the protection for the address. */
|
||||||
|
Protect = MmGetPageProtect(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address));
|
||||||
/* Return if that page isn't present. */
|
/* Return if that page isn't present. */
|
||||||
if (BreakPtePtr == NULL)
|
if (Protect & PAGE_NOACCESS)
|
||||||
{
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
if (!((*BreakPtePtr) & (1 << 0)))
|
|
||||||
{
|
{
|
||||||
return(STATUS_MEMORY_NOT_ALLOCATED);
|
return(STATUS_MEMORY_NOT_ALLOCATED);
|
||||||
}
|
}
|
||||||
/* Saved the old pte and enable write permissions. */
|
if (Protect & (PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ))
|
||||||
SavedPte = *BreakPtePtr;
|
{
|
||||||
(*BreakPtePtr) |= (1 << 1);
|
MmSetPageProtect(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address),
|
||||||
/* Flush the TLB. */
|
(Protect & ~(PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ)) | PAGE_READWRITE);
|
||||||
__asm__ __volatile__ ("movl %%cr3, %%eax\n\t"
|
}
|
||||||
"movl %%eax, %%cr3\n\t"
|
|
||||||
: : : "memory", "eax");
|
|
||||||
/* Copy the old instruction back to the caller. */
|
/* Copy the old instruction back to the caller. */
|
||||||
if (PreviousInst != NULL)
|
if (PreviousInst != NULL)
|
||||||
{
|
{
|
||||||
Status = MmSafeCopyFromUser(PreviousInst, (PUCHAR)Address, 1);
|
Status = MmSafeCopyFromUser(PreviousInst, (PUCHAR)Address, 1);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
if (Protect & (PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ))
|
||||||
}
|
{
|
||||||
|
MmSetPageProtect(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address), Protect);
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Copy the new instruction in its place. */
|
/* Copy the new instruction in its place. */
|
||||||
Status = MmSafeCopyToUser((PUCHAR)Address, &NewInst, 1);
|
Status = MmSafeCopyToUser((PUCHAR)Address, &NewInst, 1);
|
||||||
if (!NT_SUCCESS(Status))
|
if (Protect & (PAGE_READONLY|PAGE_EXECUTE|PAGE_EXECUTE_READ))
|
||||||
{
|
{
|
||||||
return(Status);
|
MmSetPageProtect(PsGetCurrentProcess(), (PVOID)PAGE_ROUND_DOWN(Address), Protect);
|
||||||
}
|
}
|
||||||
/* Restore the old pte. */
|
return Status;
|
||||||
*BreakPtePtr = SavedPte;
|
|
||||||
/* And flush the tlb again. */
|
|
||||||
__asm__ __volatile__ ("movl %%cr3, %%eax\n\t"
|
|
||||||
"movl %%eax, %%cr3\n\t"
|
|
||||||
: : : "memory", "eax");
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue