Author: ion
Date: Mon Mar 5 23:10:26 2007
New Revision: 26007
URL:
http://svn.reactos.org/svn/reactos?rev=26007&view=rev
Log:
- Implement KdpQueryMemory (KdQueryMemoryApi).
- Setting and clearing breakpoints now works! (At least the simple ones with F9/bp/bc).
And they actually get hit properly.
Modified:
trunk/reactos/include/reactos/windbgkd.h
trunk/reactos/ntoskrnl/kd64/kdapi.c
Modified: trunk/reactos/include/reactos/windbgkd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/windbgkd.h…
==============================================================================
--- trunk/reactos/include/reactos/windbgkd.h (original)
+++ trunk/reactos/include/reactos/windbgkd.h Mon Mar 5 23:10:26 2007
@@ -126,6 +126,22 @@
#define DBGKD_64BIT_PROTOCOL_VERSION2 6
//
+// Query Memory Address Spaces
+//
+#define DBGKD_QUERY_MEMORY_VIRTUAL 0
+#define DBGKD_QUERY_MEMORY_PROCESS 0
+#define DBGKD_QUERY_MEMORY_SESSION 1
+#define DBGKD_QUERY_MEMORY_KERNEL 2
+
+//
+// Query Memory Flags
+//
+#define DBGKD_QUERY_MEMORY_READ 0x01
+#define DBGKD_QUERY_MEMORY_WRITE 0x02
+#define DBGKD_QUERY_MEMORY_EXECUTE 0x04
+#define DBGKD_QUERY_MEMORY_FIXED 0x08
+
+//
// KD Packet Structure
//
typedef struct _KD_PACKET
Modified: trunk/reactos/ntoskrnl/kd64/kdapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdapi.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ trunk/reactos/ntoskrnl/kd64/kdapi.c Mon Mar 5 23:10:26 2007
@@ -16,13 +16,62 @@
VOID
NTAPI
+KdpQueryMemory(IN PDBGKD_MANIPULATE_STATE64 State,
+ IN PCONTEXT Context)
+{
+ PDBGKD_QUERY_MEMORY Memory = &State->u.QueryMemory;
+ STRING Header;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ /* Validate the address space */
+ if (Memory->AddressSpace == DBGKD_QUERY_MEMORY_VIRTUAL)
+ {
+ /* Check if this is process memory */
+ if ((PVOID)(LONG_PTR)Memory->Address < MmHighestUserAddress)
+ {
+ /* It is */
+ Memory->AddressSpace = DBGKD_QUERY_MEMORY_PROCESS;
+ }
+ else
+ {
+ /* FIXME: Check if it's session space */
+ Memory->AddressSpace = DBGKD_QUERY_MEMORY_KERNEL;
+ }
+
+ /* Set flags */
+ Memory->Flags = DBGKD_QUERY_MEMORY_READ |
+ DBGKD_QUERY_MEMORY_WRITE |
+ DBGKD_QUERY_MEMORY_EXECUTE;
+ }
+ else
+ {
+ /* Invalid */
+ Status = STATUS_INVALID_PARAMETER;
+ }
+
+ /* Return structure */
+ State->ReturnStatus = Status;
+ Memory->Reserved = 0;
+
+ /* Build header */
+ Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
+ Header.Buffer = (PCHAR)State;
+
+ /* Send the packet */
+ KdSendPacket(PACKET_TYPE_KD_STATE_MANIPULATE,
+ &Header,
+ NULL,
+ &KdpContext);
+}
+
+VOID
+NTAPI
KdpWriteBreakpoint(IN PDBGKD_MANIPULATE_STATE64 State,
IN PSTRING Data,
IN PCONTEXT Context)
{
PDBGKD_WRITE_BREAKPOINT64 Breakpoint = &State->u.WriteBreakPoint;
STRING Header;
- NTSTATUS Status;
/* Build header */
Header.Length = sizeof(DBGKD_MANIPULATE_STATE64);
@@ -35,7 +84,12 @@
if (!Breakpoint->BreakPointHandle)
{
/* We failed */
- Status = STATUS_UNSUCCESSFUL;
+ State->ReturnStatus = STATUS_UNSUCCESSFUL;
+ }
+ else
+ {
+ /* Success! */
+ State->ReturnStatus = STATUS_SUCCESS;
}
/* Send the packet */
@@ -816,9 +870,8 @@
case DbgKdQueryMemoryApi:
- /* FIXME: TODO */
- Ke386SetCr2(DbgKdQueryMemoryApi);
- while (TRUE);
+ /* Query memory */
+ KdpQueryMemory(&ManipulateState, Context);
break;
case DbgKdSwitchPartition: