Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

122 lines
3.7 KiB

/****************************** Module Header ******************************\
* Module Name: debug.c
*
* Copyright (c) 1985 - 1999, Microsoft Corporation
*
* This module contains random debugging related functions.
*
* History:
* 17-May-1991 DarrinM Created.
* 22-Jan-1992 IanJa ANSI/Unicode neutral (all debug output is ANSI)
\***************************************************************************/
#include "precomp.h"
#pragma hdrstop
/*
* Include stuff necessary to send a datagram to winsrv.
*/
#include "ntcsrmsg.h"
#include "csrmsg.h"
/**************************************************************************\
* ActivateDebugger
*
* Force an exception on the active application's context so it will break
* into the debugger.
*
* History:
* 05-10-91 DarrinM Created.
\***************************************************************************/
BOOL xxxActivateDebugger(
UINT fsModifiers)
{
USER_API_MSG m;
PACTIVATEDEBUGGERMSG a = &m.u.ActivateDebugger;
PEPROCESS Process;
HANDLE hDebugPort;
NTSTATUS Status;
if (fsModifiers & MOD_CONTROL) {
#if DBG
if (RipOutput(0, RIP_WARNING, "User debugger", 0, "", "Debug prompt", NULL)) {
DbgBreakPoint();
}
#endif
return FALSE;
} else if (fsModifiers & MOD_SHIFT) {
/*
* Bail out if the process is not being debugged.
*/
if (PsGetProcessDebugPort(gpepCSRSS) == NULL) {
return FALSE;
}
a->ClientId.UniqueProcess = PsGetProcessId(gpepCSRSS);
} else {
if (gpqForeground == NULL || gpqForeground->ptiKeyboard == NULL) {
return FALSE;
}
a->ClientId.UniqueProcess = PsGetThreadProcessId(gpqForeground->ptiKeyboard->pEThread);
a->ClientId.UniqueThread = PsGetThreadId(gpqForeground->ptiKeyboard->pEThread);
Status = LockProcessByClientId(a->ClientId.UniqueProcess, &Process);
/*
* Bail out if the process is not being debugged or the process id
* is invalid.
*/
if (!NT_SUCCESS(Status)) {
return FALSE;
}
hDebugPort = PsGetProcessDebugPort(Process);
UnlockProcess(Process);
if (hDebugPort == NULL) {
return FALSE;
}
}
/*
* Send the datagram to CSR.
*/
if (CsrApiPort != NULL) {
ULONG ArgLength = sizeof(*a);
ArgLength |= (ArgLength << 16);
ArgLength += ((sizeof( CSR_API_MSG ) - sizeof( m.u )) << 16) |
(FIELD_OFFSET( CSR_API_MSG, u ) - sizeof( m.h ));
m.h.u1.Length = ArgLength;
m.h.u2.ZeroInit = 0;
m.CaptureBuffer = NULL;
m.ApiNumber = CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX,
UserpActivateDebugger);
LeaveCrit();
Status = LpcRequestPort(CsrApiPort, (PPORT_MESSAGE)&m);
EnterCrit();
UserAssert(NT_SUCCESS(Status));
}
/*
* Don't eat this event unless we are breaking into CSR! Since we have
* choosen an arbitrary hot key like F12 for the debug key, we need to
* pass on the key to the application, or apps that want this key would
* never see it. If we had an api for installing a debug hot key
* (export or MOD_DEBUG flag to RegisterHotKey()), then it would be ok
* to eat because the user selected the hot key. But it is not ok to
* eat it as long as we've picked an arbitrary hot key.
*/
if (fsModifiers & MOD_SHIFT) {
return TRUE;
} else {
return FALSE;
}
}
DWORD GetRipComponent(
VOID)
{
return RIP_USERKRNL;
}