mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
- Implement KdpWriteControlSpace.
- Fix a bug in KdpSetContext. - Use DR_MASK and DR7_OVERRIDE_V in KiUpdateDr7, KiRecordDr7 instead of DR_ACTIVE_MASK. - We now get DbgKdContinueApi2 from WinDBG meaning that the first phase of KD communication is almost over! svn path=/branches/alex-kd-branch/; revision=25854
This commit is contained in:
parent
bf616180df
commit
69a6af0124
4 changed files with 58 additions and 9 deletions
|
@ -494,6 +494,7 @@ Author:
|
|||
#define DR6_LEGAL 0xE00F
|
||||
#define DR7_LEGAL 0xFFFF0155
|
||||
#define DR7_ACTIVE 0x55
|
||||
#define DR7_OVERRIDE_V 0x04
|
||||
#define DR7_RESERVED_MASK 0xDC00
|
||||
#define DR7_OVERRIDE_MASK 0xF0000
|
||||
|
||||
|
|
|
@ -240,6 +240,55 @@ KdpReadControlSpace(IN PDBGKD_MANIPULATE_STATE64 State,
|
|||
&KdpContext);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdpWriteControlSpace(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||
IN PSTRING Data,
|
||||
IN PCONTEXT Context)
|
||||
{
|
||||
PDBGKD_WRITE_MEMORY64 WriteMemory = &State->u.WriteMemory;
|
||||
STRING Header;
|
||||
ULONG Length;
|
||||
PVOID ControlStart;
|
||||
|
||||
/* Setup the header */
|
||||
Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
|
||||
Header.Buffer = (PCHAR)State;
|
||||
|
||||
/* Make sure that this is a valid request */
|
||||
Length = WriteMemory->TransferCount;
|
||||
if ((((ULONG)WriteMemory->TargetBaseAddress + Length) <=
|
||||
sizeof(KPROCESSOR_STATE)) &&
|
||||
(State->Processor < KeNumberProcessors))
|
||||
{
|
||||
/* Set the proper address */
|
||||
ControlStart = (PVOID)((ULONG_PTR)WriteMemory->TargetBaseAddress +
|
||||
(ULONG_PTR)&KiProcessorBlock[State->Processor]->
|
||||
ProcessorState);
|
||||
|
||||
/* Copy the memory */
|
||||
RtlCopyMemory(ControlStart, Data->Buffer, Data->Length);
|
||||
Length = Data->Length;
|
||||
|
||||
/* Finish up */
|
||||
State->ReturnStatus = STATUS_SUCCESS;
|
||||
WriteMemory->ActualBytesWritten = Length;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Invalid request */
|
||||
Data->Length = 0;
|
||||
State->ReturnStatus = STATUS_UNSUCCESSFUL;
|
||||
WriteMemory->ActualBytesWritten = 0;
|
||||
}
|
||||
|
||||
/* Send the reply */
|
||||
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
|
||||
&Header,
|
||||
Data,
|
||||
&KdpContext);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdpRestoreBreakpoint(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||
|
@ -335,7 +384,7 @@ KdpSetContext(IN PDBGKD_MANIPULATE_STATE64 State,
|
|||
/* Setup the header */
|
||||
Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
|
||||
Header.Buffer = (PCHAR)State;
|
||||
ASSERT(Data->Length == 0);
|
||||
ASSERT(Data->Length == sizeof(CONTEXT));
|
||||
|
||||
/* Make sure that this is a valid request */
|
||||
if (State->Processor < KeNumberProcessors)
|
||||
|
@ -472,8 +521,7 @@ SendPacket:
|
|||
case DbgKdWriteControlSpaceApi:
|
||||
|
||||
/* FIXME: TODO */
|
||||
Ke386SetCr2(DbgKdWriteControlSpaceApi);
|
||||
while (TRUE);
|
||||
KdpWriteControlSpace(&ManipulateState, &Data, Context);
|
||||
break;
|
||||
|
||||
case DbgKdReadIoSpaceApi:
|
||||
|
|
|
@ -49,7 +49,6 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
|
|||
}
|
||||
|
||||
/* Enter the debugger */
|
||||
while (TRUE);
|
||||
Entered = KdEnterDebugger(TrapFrame, ExceptionFrame);
|
||||
|
||||
/*
|
||||
|
@ -63,6 +62,7 @@ KdpReport(IN PKTRAP_FRAME TrapFrame,
|
|||
sizeof(CONTEXT));
|
||||
|
||||
/* Report the new state */
|
||||
Ke386SetCr2(TrapFrame->HardwareEsp);
|
||||
#if 0
|
||||
Status = KdpReportExceptionStateChange(ExceptionRecord,
|
||||
&Prcb->ProcessorState.
|
||||
|
|
|
@ -90,7 +90,7 @@ KiUpdateDr7(IN ULONG Dr7)
|
|||
ULONG DebugMask = KeGetCurrentThread()->DispatcherHeader.DebugActive;
|
||||
|
||||
/* Check if debugging is enabled */
|
||||
if (DebugMask & DR_ACTIVE_MASK)
|
||||
if (DebugMask & DR_MASK(DR7_OVERRIDE_V))
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT((DebugMask & DR_REG_MASK) != 0);
|
||||
|
@ -133,11 +133,11 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
|
|||
Result = FALSE;
|
||||
|
||||
/* Check the DR mask */
|
||||
NewMask &= 0x7F;
|
||||
NewMask &= ~(DR_MASK(7));
|
||||
if (NewMask & DR_REG_MASK)
|
||||
{
|
||||
/* Set the active mask */
|
||||
NewMask |= DR_ACTIVE_MASK;
|
||||
NewMask |= DR_MASK(DR7_OVERRIDE_V);
|
||||
|
||||
/* Set DR7 override */
|
||||
*DrMask = DR7_OVERRIDE_MASK;
|
||||
|
@ -154,8 +154,8 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
|
|||
Result = NewMask ? TRUE: FALSE;
|
||||
|
||||
/* Update the mask to disable debugging */
|
||||
NewMask &= ~DR_ACTIVE_MASK;
|
||||
NewMask |= 0x80;
|
||||
NewMask &= ~(DR_MASK(DR7_OVERRIDE_V));
|
||||
NewMask |= DR_MASK(7);
|
||||
}
|
||||
|
||||
/* Check if caller wants the new mask */
|
||||
|
|
Loading…
Reference in a new issue