mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 14:25:52 +00:00
- Implement DbgkpConvertKernelToUserStateChange. I just remembered that there's actually 3 debug subsystems in NT: Win32, Native and Kernel, so this structure will still need to be heavily parsed at the Win32 level (in kernel32) before user-mode debuggers can work (so I'll have to write a small native-mode debugger test app to test this implementation first).
- Implement DbgkpMarkProcessPeb. svn path=/trunk/; revision=24577
This commit is contained in:
parent
2a37845ce0
commit
d9b18cdbb2
2 changed files with 139 additions and 45 deletions
|
@ -1,13 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS Kernel
|
||||||
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
* FILE: ntoskrnl/dbgk/dbgkutil.c
|
* FILE: ntoskrnl/dbgk/dbgkutil.c
|
||||||
* PURPOSE: User-Mode Debugging Support, Internal Debug Functions.
|
* PURPOSE: User-Mode Debugging Support, Internal Debug Functions.
|
||||||
*
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
#include <ntoskrnl.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
@ -19,39 +18,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgkCreateThread(PVOID StartAddress)
|
DbgkCreateThread(PVOID StartAddress)
|
||||||
{
|
{
|
||||||
#if 0
|
/* FIXME */
|
||||||
LPC_DBG_MESSAGE Message;
|
|
||||||
LPC_DBG_MESSAGE Reply;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
if (PsGetCurrentThread()->ThreadsProcess->DebugPort == NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Message.Header.MessageSize = sizeof(LPC_DBG_MESSAGE);
|
|
||||||
Message.Header.DataSize = sizeof(LPC_DBG_MESSAGE) -
|
|
||||||
sizeof(LPC_MESSAGE);
|
|
||||||
Message.Type = DBG_EVENT_CREATE_THREAD;
|
|
||||||
Message.Status = STATUS_SUCCESS;
|
|
||||||
Message.Data.CreateThread.Reserved = 0;
|
|
||||||
Message.Data.CreateThread.StartAddress = StartAddress;
|
|
||||||
|
|
||||||
/* FIXME: Freeze all threads in process */
|
|
||||||
|
|
||||||
/* Send the message to the process's debug port and wait for a reply */
|
|
||||||
Status =
|
|
||||||
LpcSendDebugMessagePort(PsGetCurrentThread()->ThreadsProcess->DebugPort,
|
|
||||||
&Message,
|
|
||||||
&Reply);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: Examine reply */
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
|
||||||
* PROJECT: ReactOS Kernel
|
* PROJECT: ReactOS Kernel
|
||||||
* FILE: ntoskrnl/dbgk/debug.c
|
* LICENSE: GPL - See COPYING in the top level directory
|
||||||
|
* FILE: ntoskrnl/dbgk/dbgkobj.c
|
||||||
* PURPOSE: User-Mode Debugging Support, Debug Object Management.
|
* PURPOSE: User-Mode Debugging Support, Debug Object Management.
|
||||||
*
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||||
* PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
@ -318,16 +317,144 @@ NTAPI
|
||||||
DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
DbgkpConvertKernelToUserStateChange(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||||
IN PDEBUG_EVENT DebugEvent)
|
IN PDEBUG_EVENT DebugEvent)
|
||||||
{
|
{
|
||||||
/* FIXME: TODO */
|
/* Start by copying the client ID */
|
||||||
return;
|
WaitStateChange->AppClientId = DebugEvent->ClientId;
|
||||||
|
|
||||||
|
/* Now check which kind of event this was */
|
||||||
|
switch (DebugEvent->ApiMsg.ApiNumber)
|
||||||
|
{
|
||||||
|
/* New process */
|
||||||
|
case DbgKmCreateProcessApi:
|
||||||
|
|
||||||
|
/* Set the right native code */
|
||||||
|
WaitStateChange->NewState = DbgCreateProcessStateChange;
|
||||||
|
|
||||||
|
/* Copy the information */
|
||||||
|
WaitStateChange->StateInfo.CreateProcessInfo.NewProcess =
|
||||||
|
DebugEvent->ApiMsg.CreateProcess;
|
||||||
|
|
||||||
|
/* Clear the file handle for us */
|
||||||
|
DebugEvent->ApiMsg.CreateProcess.FileHandle = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* New thread */
|
||||||
|
case DbgKmCreateThreadApi:
|
||||||
|
|
||||||
|
/* Set the right native code */
|
||||||
|
WaitStateChange->NewState = DbgCreateThreadStateChange;
|
||||||
|
|
||||||
|
/* Copy information */
|
||||||
|
WaitStateChange->StateInfo.CreateThread.NewThread.StartAddress =
|
||||||
|
DebugEvent->ApiMsg.CreateThread.StartAddress;
|
||||||
|
WaitStateChange->StateInfo.CreateThread.NewThread.SubSystemKey =
|
||||||
|
DebugEvent->ApiMsg.CreateThread.SubSystemKey;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Exception (or breakpoint/step) */
|
||||||
|
case DbgKmExceptionApi:
|
||||||
|
|
||||||
|
/* Look at the exception code */
|
||||||
|
if (DebugEvent->ApiMsg.Exception.ExceptionRecord.ExceptionCode ==
|
||||||
|
STATUS_BREAKPOINT)
|
||||||
|
{
|
||||||
|
/* Update this as a breakpoint exception */
|
||||||
|
WaitStateChange->NewState = DbgBreakpointStateChange;
|
||||||
|
}
|
||||||
|
else if (DebugEvent->ApiMsg.Exception.ExceptionRecord.ExceptionCode ==
|
||||||
|
STATUS_SINGLE_STEP)
|
||||||
|
{
|
||||||
|
/* Update this as a single step exception */
|
||||||
|
WaitStateChange->NewState = DbgSingleStepStateChange;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Otherwise, set default exception */
|
||||||
|
WaitStateChange->NewState = DbgExceptionStateChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the exception record */
|
||||||
|
WaitStateChange->StateInfo.Exception.ExceptionRecord =
|
||||||
|
DebugEvent->ApiMsg.Exception.ExceptionRecord;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Process exited */
|
||||||
|
case DbgKmExitProcessApi:
|
||||||
|
|
||||||
|
/* Set the right native code and copy the exit code */
|
||||||
|
WaitStateChange->NewState = DbgExitProcessStateChange;
|
||||||
|
WaitStateChange->StateInfo.ExitProcess.ExitStatus =
|
||||||
|
DebugEvent->ApiMsg.ExitProcess.ExitStatus;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Thread exited */
|
||||||
|
case DbgKmExitThreadApi:
|
||||||
|
|
||||||
|
/* Set the right native code */
|
||||||
|
WaitStateChange->NewState = DbgExitThreadStateChange;
|
||||||
|
WaitStateChange->StateInfo.ExitThread.ExitStatus =
|
||||||
|
DebugEvent->ApiMsg.ExitThread.ExitStatus;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* DLL Load */
|
||||||
|
case DbgKmLoadDllApi:
|
||||||
|
|
||||||
|
/* Set the native code */
|
||||||
|
WaitStateChange->NewState = DbgLoadDllStateChange;
|
||||||
|
|
||||||
|
/* Copy the data */
|
||||||
|
WaitStateChange->StateInfo.LoadDll = DebugEvent->ApiMsg.LoadDll;
|
||||||
|
|
||||||
|
/* Clear the file handle for us */
|
||||||
|
DebugEvent->ApiMsg.LoadDll.FileHandle = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* DLL Unload */
|
||||||
|
case DbgKmUnloadDllApi:
|
||||||
|
|
||||||
|
/* Set the native code and copy the address */
|
||||||
|
WaitStateChange->NewState = DbgUnloadDllStateChange;
|
||||||
|
WaitStateChange->StateInfo.UnloadDll.BaseAddress =
|
||||||
|
DebugEvent->ApiMsg.UnloadDll.BaseAddress;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
/* Shouldn't happen */
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
DbgkpMarkProcessPeb(IN PEPROCESS Process)
|
DbgkpMarkProcessPeb(IN PEPROCESS Process)
|
||||||
{
|
{
|
||||||
/* FIXME: TODO */
|
KAPC_STATE ApcState;
|
||||||
return;
|
PAGED_CODE();
|
||||||
|
|
||||||
|
/* Acquire process rundown */
|
||||||
|
if (!ExAcquireRundownProtection(&Process->RundownProtect)) return;
|
||||||
|
|
||||||
|
/* Make sure we have a PEB */
|
||||||
|
if (Process->Peb)
|
||||||
|
{
|
||||||
|
/* Attach to the process */
|
||||||
|
KeStackAttachProcess(&Process->Pcb, &ApcState);
|
||||||
|
|
||||||
|
/* Acquire the debug port mutex */
|
||||||
|
ExAcquireFastMutex(&DbgkpProcessDebugPortMutex);
|
||||||
|
|
||||||
|
/* Set the IsBeingDebugged member of the PEB */
|
||||||
|
Process->Peb->BeingDebugged = (Process->DebugPort) ? TRUE: FALSE;
|
||||||
|
|
||||||
|
/* Release lock */
|
||||||
|
ExReleaseFastMutex(&DbgkpProcessDebugPortMutex);
|
||||||
|
|
||||||
|
/* Detach from the process */
|
||||||
|
KeUnstackDetachProcess(&ApcState);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Release rundown protection */
|
||||||
|
ExReleaseRundownProtection(&Process->RundownProtect);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue