Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

debug.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: debug.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This module contains random debugging related functions. 00007 * 00008 * History: 00009 * 17-May-1991 DarrinM Created. 00010 * 22-Jan-1992 IanJa ANSI/Unicode neutral (all debug output is ANSI) 00011 \***************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 /* 00017 * Include stuff necessary to send a datagram to winsrv. 00018 */ 00019 #include "ntcsrmsg.h" 00020 #include "csrmsg.h" 00021 00022 /**************************************************************************\ 00023 * ActivateDebugger 00024 * 00025 * Force an exception on the active application's context so it will break 00026 * into the debugger. 00027 * 00028 * History: 00029 * 05-10-91 DarrinM Created. 00030 \***************************************************************************/ 00031 00032 BOOL xxxActivateDebugger( 00033 UINT fsModifiers) 00034 { 00035 ULONG ArgLength; 00036 USER_API_MSG m; 00037 PACTIVATEDEBUGGERMSG a = &m.u.ActivateDebugger; 00038 PEPROCESS Process; 00039 HANDLE hDebugPort; 00040 NTSTATUS Status; 00041 if (fsModifiers & MOD_CONTROL) { 00042 #if DBG 00043 if (RipOutput(0, RIP_WARNING, "User debugger", 0, "Debug prompt", NULL)) { 00044 DbgBreakPoint(); 00045 } 00046 #endif 00047 return FALSE; 00048 } else if (fsModifiers & MOD_SHIFT) { 00049 00050 /* 00051 * Bail out if the process is not being debugged. 00052 */ 00053 if (gpepCSRSS->DebugPort == NULL) 00054 return FALSE; 00055 00056 a->ClientId.UniqueProcess = gpepCSRSS->UniqueProcessId; 00057 } else { 00058 00059 if ((gpqForeground == NULL) || (gpqForeground->ptiKeyboard == NULL)) 00060 return FALSE; 00061 00062 a->ClientId = gpqForeground->ptiKeyboard->pEThread->Cid; 00063 00064 LeaveCrit(); 00065 Status = LockProcessByClientId(a->ClientId.UniqueProcess, &Process); 00066 EnterCrit(); 00067 00068 /* 00069 * Bail out if the process is not being debugged or the process id 00070 * is invalid. 00071 */ 00072 if (!NT_SUCCESS(Status)) 00073 return FALSE; 00074 00075 hDebugPort = Process->DebugPort; 00076 UnlockProcess(Process); 00077 00078 if (hDebugPort == NULL) 00079 return FALSE; 00080 } 00081 00082 /* 00083 * Send the datagram to CSR 00084 */ 00085 if (CsrApiPort != NULL) { 00086 ArgLength = sizeof(*a); 00087 ArgLength |= (ArgLength << 16); 00088 ArgLength += ((sizeof( CSR_API_MSG ) - sizeof( m.u )) << 16) | 00089 (FIELD_OFFSET( CSR_API_MSG, u ) - sizeof( m.h )); 00090 m.h.u1.Length = ArgLength; 00091 m.h.u2.ZeroInit = 0; 00092 m.CaptureBuffer = NULL; 00093 m.ApiNumber = CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00094 UserpActivateDebugger); 00095 LeaveCrit(); 00096 Status = LpcRequestPort(CsrApiPort, (PPORT_MESSAGE)&m); 00097 EnterCrit(); 00098 UserAssert(NT_SUCCESS(Status)); 00099 } 00100 00101 /* 00102 * Don't eat this event unless we are breaking into CSR! Since we have 00103 * choosen an arbitrary hot key like F12 for the debug key, we need to 00104 * pass on the key to the application, or apps that want this key would 00105 * never see it. If we had an api for installing a debug hot key 00106 * (export or MOD_DEBUG flag to RegisterHotKey()), then it would be ok 00107 * to eat because the user selected the hot key. But it is not ok to 00108 * eat it as long as we've picked an arbitrary hot key. scottlu. 00109 */ 00110 if (fsModifiers & MOD_SHIFT) 00111 return TRUE; 00112 else 00113 return FALSE; 00114 } 00115 00116 DWORD GetRipComponent(VOID) { return RIP_USERKRNL; } 00117 00118 DWORD GetDbgTagFlags(int tag) 00119 { 00120 #if DEBUGTAGS 00121 return (gpsi != NULL ? gpsi->adwDBGTAGFlags[tag] : 0); 00122 #else 00123 return 0; 00124 UNREFERENCED_PARAMETER(tag); 00125 #endif // DEBUGTAGS 00126 } 00127 00128 DWORD GetRipPID(VOID) { return (gpsi != NULL ? gpsi->wRIPPID : 0); } 00129 DWORD GetRipFlags(VOID) { return (gpsi != NULL ? gpsi->wRIPFlags : RIPF_DEFAULT); } 00130 00131 VOID SetRipFlags(DWORD dwRipFlags, DWORD dwRipPID) 00132 { 00133 _SetRipFlags(dwRipFlags, dwRipPID); 00134 } 00135 00136 VOID SetDbgTag(int tag, DWORD dwBitFlags) 00137 { 00138 _SetDbgTag(tag, dwBitFlags); 00139 } 00140

Generated on Sat May 15 19:39:39 2004 for test by doxygen 1.3.7