Author: tkreuzer
Date: Fri Oct 23 23:46:49 2009
New Revision: 43702
URL:
http://svn.reactos.org/svn/reactos?rev=43702&view=rev
Log:
Fix and simplify KdpSysReadControlSpace, hint by Stefan
Modified:
branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c
Modified: branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/ntosk…
==============================================================================
--- branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/ntoskrnl/kd64/amd64/kdsup.c [iso-8859-1] Fri Oct 23
23:46:49 2009
@@ -176,61 +176,46 @@
OUT PULONG ActualLength)
{
PVOID ControlStart;
- ULONG RealLength;
-
- if ((ULONG)BaseAddress <= 2)
- {
- PKPRCB Prcb = KiProcessorBlock[Processor];
- PKIPCR Pcr = CONTAINING_RECORD(Prcb, KIPCR, Prcb);
-
- switch ((ULONG_PTR)BaseAddress)
- {
- case AMD64_DEBUG_CONTROL_SPACE_KPCR:
- /* Copy a pointer to the Pcr */
- ControlStart = &Pcr;
- RealLength = sizeof(PVOID);
- break;
-
- case AMD64_DEBUG_CONTROL_SPACE_KPRCB:
- /* Copy a pointer to the Prcb */
- ControlStart = &Prcb;
- RealLength = sizeof(PVOID);
- break;
-
- case AMD64_DEBUG_CONTROL_SPACE_KSPECIAL:
- /* Copy SpecialRegisters */
- ControlStart = &Prcb->ProcessorState.SpecialRegisters;
- RealLength = sizeof(KSPECIAL_REGISTERS);
- break;
-
- case AMD64_DEBUG_CONTROL_SPACE_KTHREAD:
- /* Copy a pointer to the current Thread */
- ControlStart = &Prcb->CurrentThread;
- RealLength = sizeof(PVOID);
- break;
-
- default:
- RealLength = 0;
- ControlStart = NULL;
- ASSERT(FALSE);
- return STATUS_UNSUCCESSFUL;
- }
-
- if (RealLength < Length) Length = RealLength;
-
- /* Copy the memory */
- RtlCopyMemory(Buffer, ControlStart, Length);
- *ActualLength = Length;
-
- /* Finish up */
- return STATUS_SUCCESS;
- }
- else
- {
- /* Invalid request */
- *ActualLength = 0;
- return STATUS_UNSUCCESSFUL;
- }
+ PKPRCB Prcb = KiProcessorBlock[Processor];
+ PKIPCR Pcr = CONTAINING_RECORD(Prcb, KIPCR, Prcb);
+
+ switch (BaseAddress)
+ {
+ case AMD64_DEBUG_CONTROL_SPACE_KPCR:
+ /* Copy a pointer to the Pcr */
+ ControlStart = &Pcr;
+ *ActualLength = sizeof(PVOID);
+ break;
+
+ case AMD64_DEBUG_CONTROL_SPACE_KPRCB:
+ /* Copy a pointer to the Prcb */
+ ControlStart = &Prcb;
+ *ActualLength = sizeof(PVOID);
+ break;
+
+ case AMD64_DEBUG_CONTROL_SPACE_KSPECIAL:
+ /* Copy SpecialRegisters */
+ ControlStart = &Prcb->ProcessorState.SpecialRegisters;
+ *ActualLength = sizeof(KSPECIAL_REGISTERS);
+ break;
+
+ case AMD64_DEBUG_CONTROL_SPACE_KTHREAD:
+ /* Copy a pointer to the current Thread */
+ ControlStart = &Prcb->CurrentThread;
+ *ActualLength = sizeof(PVOID);
+ break;
+
+ default:
+ *ActualLength = 0;
+ ASSERT(FALSE);
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ /* Copy the memory */
+ RtlCopyMemory(Buffer, ControlStart, min(Length, *ActualLength));
+
+ /* Finish up */
+ return STATUS_SUCCESS;
}
NTSTATUS