Author: ion
Date: Tue Feb 20 00:30:26 2007
New Revision: 25846
URL:
http://svn.reactos.org/svn/reactos?rev=25846&view=rev
Log:
- 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)"
Modified:
branches/alex-kd-branch/reactos/ntoskrnl/include/internal/ke.h
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kddata.c
branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c
Modified: branches/alex-kd-branch/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/include/internal/ke.h (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/include/internal/ke.h Tue Feb 20 00:30:26
2007
@@ -151,7 +151,7 @@
extern UCHAR KiDebugRegisterContextOffsets[9];
extern ULONG KiFreezeFlag;
extern ULONG KeTimeIncrement;
-extern PVOID KiBugCheckData;
+extern ULONG_PTR KiBugCheckData[5];
/* MACROS *************************************************************************/
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdapi.c Tue Feb 20 00:30:26 2007
@@ -89,12 +89,82 @@
}
}
-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 @@
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 @@
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 @@
{
case DbgKdReadVirtualMemoryApi:
- /* FIXME: TODO */
- Ke386SetCr2(DbgKdReadVirtualMemoryApi);
- while (TRUE);
+ /* Read virtual memory */
+ KdpReadVirtualMemory(&ManipulateState, &Data, Context);
break;
case DbgKdWriteVirtualMemoryApi:
@@ -292,9 +360,8 @@
case DbgKdGetVersionApi:
- /* FIXME: TODO */
- Ke386SetCr2(DbgKdGetVersionApi);
- while (TRUE);
+ /* Get version data */
+ KdpGetVersion(&ManipulateState);
break;
case DbgKdWriteBreakPointExApi:
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kddata.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kddata.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kddata.c Tue Feb 20 00:30:26 2007
@@ -340,7 +340,7 @@
{0}, // ExpNumberOfPagedPools
{PtrToUlong(&KeTimeIncrement)},
{PtrToUlong(&KeBugcheckCallbackListHead)},
- {PtrToUlong(&KiBugCheckData)},
+ {PtrToUlong(KiBugCheckData)},
{PtrToUlong(&IopErrorLogListHead)},
{PtrToUlong(&ObpRootDirectoryObject)},
{PtrToUlong(&ObpTypeObjectType)},
Modified: branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c
URL:
http://svn.reactos.org/svn/reactos/branches/alex-kd-branch/reactos/ntoskrnl…
==============================================================================
--- branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c (original)
+++ branches/alex-kd-branch/reactos/ntoskrnl/kd64/kdinit.c Tue Feb 20 00:30:26 2007
@@ -109,8 +109,8 @@
#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 @@
/* 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 @@
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))))