[NTOS:PS] Use KD routine to safely read memory from thread stack

Should fix a crash when hitting TAB+(Whatever I typed that triggerred this)
This commit is contained in:
Jérôme Gardou 2021-05-10 19:09:53 +02:00
parent 0fb3c1e91e
commit 04e9251612

View file

@ -70,9 +70,24 @@ PspDumpThreads(BOOLEAN IncludeSystem)
/* Walk it */
while(Ebp != 0 && Ebp >= (PULONG)Thread->Tcb.StackLimit)
{
/* Print what's on the stack */
DbgPrint("%.8X %.8X%s", Ebp[0], Ebp[1], (i % 8) == 7 ? "\n" : " ");
Ebp = (PULONG)Ebp[0];
ULONG EbpContent[2];
ULONG MemoryCopied;
NTSTATUS Status;
/* Get stack frame content */
Status = KdpCopyMemoryChunks((ULONG64)(ULONG_PTR)Ebp,
EbpContent,
sizeof(EbpContent),
sizeof(EbpContent),
MMDBG_COPY_UNSAFE,
&MemoryCopied);
if (!NT_SUCCESS(Status) || (MemoryCopied < sizeof(EbpContent)))
{
break;
}
DbgPrint("%.8X %.8X%s", EbpContent[0], EbpContent[1], (i % 8) == 7 ? "\n" : " ");
Ebp = (PULONG)EbpContent[0];
i++;
}