mirror of
https://github.com/reactos/reactos.git
synced 2024-07-01 18:24:24 +00:00
- Implement KdpSysGetVersion, KdpGetVersion, KdpReadVirtualMemory.
- Fix bugs in KdInitSystem; some 64-bit pointers must be sign-extneded, not zero-extended (thanks Myria!) - Properly read kernel base instead of kernel stack. - Fix compile issue due to incorrect KiBugCheckData definition. - WinDBG reports: "Connected to Windows Vista 16199 x86 compatible target, ptr64 FALSE. Kernel Debugger connection established. (Initial Breakpoint requested)" svn path=/branches/alex-kd-branch/; revision=25846
This commit is contained in:
parent
b9cd3f2d9d
commit
1654674e55
|
@ -151,7 +151,7 @@ extern UCHAR KiDebugRegisterTrapOffsets[9];
|
|||
extern UCHAR KiDebugRegisterContextOffsets[9];
|
||||
extern ULONG KiFreezeFlag;
|
||||
extern ULONG KeTimeIncrement;
|
||||
extern PVOID KiBugCheckData;
|
||||
extern ULONG_PTR KiBugCheckData[5];
|
||||
|
||||
/* MACROS *************************************************************************/
|
||||
|
||||
|
|
|
@ -89,12 +89,82 @@ KdpSetContextState(IN PDBGKD_WAIT_STATE_CHANGE64 WaitStateChange,
|
|||
}
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
VOID
|
||||
NTAPI
|
||||
KdpSysGetVersion(IN PDBGKD_GET_VERSION64 Version)
|
||||
{
|
||||
/* Copy the version block */
|
||||
RtlCopyMemory(Version, &KdVersionBlock, sizeof(DBGKD_GET_VERSION64));
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdpGetVersion(IN PDBGKD_MANIPULATE_STATE64 State)
|
||||
{
|
||||
STRING Header;
|
||||
|
||||
/* Fill out the header */
|
||||
Header.Length = sizeof(DBGKD_GET_VERSION64);
|
||||
Header.Buffer = (PCHAR)State;
|
||||
|
||||
/* Get the version block */
|
||||
KdpSysGetVersion(&State->u.GetVersion64);
|
||||
|
||||
/* Fill out the state */
|
||||
State->ApiNumber = DbgKdGetVersionApi;
|
||||
State->ReturnStatus = STATUS_SUCCESS;
|
||||
|
||||
/* Send the packet */
|
||||
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
|
||||
&Header,
|
||||
NULL,
|
||||
&KdpContext);
|
||||
}
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
KdpReadVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State,
|
||||
IN PSTRING Data,
|
||||
IN PCONTEXT Context)
|
||||
{
|
||||
STRING Header;
|
||||
ULONG Length = State->u.ReadMemory.TransferCount;
|
||||
|
||||
/* Validate length */
|
||||
if (Length > (PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64)))
|
||||
{
|
||||
/* Overflow, set it to maximum possible */
|
||||
Length = PACKET_MAX_SIZE - sizeof(DBGKD_MANIPULATE_STATE64);
|
||||
}
|
||||
|
||||
/* Copy data */
|
||||
RtlCopyMemory(Data->Buffer,
|
||||
(PVOID)(ULONG_PTR)State->u.ReadMemory.TargetBaseAddress,
|
||||
Length);
|
||||
Data->Length = Length;
|
||||
|
||||
/* Fill out the header */
|
||||
Header.Length = sizeof(DBGKD_GET_VERSION64);
|
||||
Header.Buffer = (PCHAR)State;
|
||||
|
||||
/* Fill out the state */
|
||||
State->ReturnStatus = STATUS_SUCCESS;
|
||||
State->u.ReadMemory.ActualBytesRead = Length;
|
||||
|
||||
/* Send the packet */
|
||||
KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
|
||||
&Header,
|
||||
Data,
|
||||
&KdpContext);
|
||||
}
|
||||
|
||||
|
||||
KCONTINUE_STATUS
|
||||
NTAPI
|
||||
KdpSendWaitContinue(IN ULONG PacketType,
|
||||
IN PSTRING SendHeader,
|
||||
IN PSTRING SendData OPTIONAL,
|
||||
IN OUT PCONTEXT ContextRecord)
|
||||
IN OUT PCONTEXT Context)
|
||||
{
|
||||
STRING Data, Header;
|
||||
DBGKD_MANIPULATE_STATE64 ManipulateState;
|
||||
|
@ -113,7 +183,7 @@ SendPacket:
|
|||
KdSendPacket(PacketType, SendHeader, SendData, &KdpContext);
|
||||
|
||||
/* If the debugger isn't present anymore, just return success */
|
||||
if (KdDebuggerNotPresent) return TRUE;
|
||||
if (KdDebuggerNotPresent) return ContinueSuccess;
|
||||
|
||||
/* Main processing Loop */
|
||||
for (;;)
|
||||
|
@ -122,7 +192,6 @@ SendPacket:
|
|||
do
|
||||
{
|
||||
/* Wait to get a reply to our packet */
|
||||
ManipulateState.ApiNumber = 0xFFFFFFFF;
|
||||
RecvCode = KdReceivePacket(PACKET_TYPE_KD_STATE_MANIPULATE,
|
||||
&Header,
|
||||
&Data,
|
||||
|
@ -138,9 +207,8 @@ SendPacket:
|
|||
{
|
||||
case DbgKdReadVirtualMemoryApi:
|
||||
|
||||
/* FIXME: TODO */
|
||||
Ke386SetCr2(DbgKdReadVirtualMemoryApi);
|
||||
while (TRUE);
|
||||
/* Read virtual memory */
|
||||
KdpReadVirtualMemory(&ManipulateState, &Data, Context);
|
||||
break;
|
||||
|
||||
case DbgKdWriteVirtualMemoryApi:
|
||||
|
@ -292,9 +360,8 @@ SendPacket:
|
|||
|
||||
case DbgKdGetVersionApi:
|
||||
|
||||
/* FIXME: TODO */
|
||||
Ke386SetCr2(DbgKdGetVersionApi);
|
||||
while (TRUE);
|
||||
/* Get version data */
|
||||
KdpGetVersion(&ManipulateState);
|
||||
break;
|
||||
|
||||
case DbgKdWriteBreakPointExApi:
|
||||
|
|
|
@ -340,7 +340,7 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
|
|||
{0}, // ExpNumberOfPagedPools
|
||||
{PtrToUlong(&KeTimeIncrement)},
|
||||
{PtrToUlong(&KeBugcheckCallbackListHead)},
|
||||
{PtrToUlong(&KiBugCheckData)},
|
||||
{PtrToUlong(KiBugCheckData)},
|
||||
{PtrToUlong(&IopErrorLogListHead)},
|
||||
{PtrToUlong(&ObpRootDirectoryObject)},
|
||||
{PtrToUlong(&ObpTypeObjectType)},
|
||||
|
|
|
@ -109,8 +109,8 @@ KdInitSystem(IN ULONG BootPhase,
|
|||
#endif
|
||||
|
||||
/* Save Pointers to Loaded Module List and Debugger Data */
|
||||
KdVersionBlock.PsLoadedModuleList = (ULONG64)&PsLoadedModuleList;
|
||||
KdVersionBlock.DebuggerDataList = (ULONG64)&KdpDebuggerDataListHead;
|
||||
KdVersionBlock.PsLoadedModuleList = (ULONGLONG)(LONG_PTR)&PsLoadedModuleList;
|
||||
KdVersionBlock.DebuggerDataList = (ULONGLONG)(LONG_PTR)&KdpDebuggerDataListHead;
|
||||
|
||||
/* Set protocol limits */
|
||||
KdVersionBlock.MaxStateChange = DbgKdMaximumStateChange -
|
||||
|
@ -126,8 +126,13 @@ KdInitSystem(IN ULONG BootPhase,
|
|||
/* Check if we have a loader block */
|
||||
if (LoaderBlock)
|
||||
{
|
||||
/* Get the image entry */
|
||||
LdrEntry = CONTAINING_RECORD(LoaderBlock->LoadOrderListHead.Flink,
|
||||
LDR_DATA_TABLE_ENTRY,
|
||||
InLoadOrderLinks);
|
||||
|
||||
/* Save the Kernel Base */
|
||||
KdVersionBlock.KernBase = (ULONG64)LoaderBlock->KernelStack;
|
||||
KdVersionBlock.KernBase =(ULONGLONG)(LONG_PTR)LdrEntry->DllBase;
|
||||
|
||||
/* Check if we have a command line */
|
||||
CommandLine = LoaderBlock->LoadOptions;
|
||||
|
@ -167,14 +172,14 @@ KdInitSystem(IN ULONG BootPhase,
|
|||
else
|
||||
{
|
||||
/* Called from a bugcheck...Save the Kernel Base */
|
||||
KdVersionBlock.KernBase = PsNtosImageBase;
|
||||
KdVersionBlock.KernBase = (ULONGLONG)(LONG_PTR)PsNtosImageBase;
|
||||
|
||||
/* Unconditionally enable KD */
|
||||
EnableKd = TRUE;
|
||||
}
|
||||
|
||||
/* Set the Kernel Base in the Data Block */
|
||||
KdDebuggerDataBlock.KernBase = KdVersionBlock.KernBase;
|
||||
KdDebuggerDataBlock.KernBase = (ULONG_PTR)PsNtosImageBase;
|
||||
|
||||
/* Initialize the debugger if requested */
|
||||
if ((EnableKd) && (NT_SUCCESS(KdDebuggerInitialize0(LoaderBlock))))
|
||||
|
|
Loading…
Reference in a new issue