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 extern FARPROC gpfnAttachRoutine; 00017 00018 /**************************************************************************\ 00019 * ActivateDebugger 00020 * 00021 * Force an exception on the active application's context so it will break 00022 * into the debugger. 00023 * 00024 * History: 00025 * 05-10-91 DarrinM Created. 00026 \***************************************************************************/ 00027 00028 ULONG SrvActivateDebugger( 00029 IN OUT PCSR_API_MSG m, 00030 IN OUT PCSR_REPLY_STATUS ReplyStatus) 00031 { 00032 PACTIVATEDEBUGGERMSG a = (PACTIVATEDEBUGGERMSG)&m->u.ApiMessageData; 00033 PCSR_THREAD Thread; 00034 NTSTATUS Status; 00035 00036 UNREFERENCED_PARAMETER(ReplyStatus); 00037 00038 /* 00039 * If the process is CSR, break 00040 */ 00041 if (a->ClientId.UniqueProcess == NtCurrentTeb()->ClientId.UniqueProcess) { 00042 DbgBreakPoint(); 00043 return STATUS_SUCCESS; 00044 } 00045 00046 /* 00047 * Impersonate the client if this is a user mode request. 00048 */ 00049 if (m->h.u2.s2.Type == LPC_REQUEST) { 00050 if (!CsrImpersonateClient(NULL)) { 00051 return STATUS_UNSUCCESSFUL; 00052 } 00053 } 00054 00055 /* 00056 * Lock the client thread 00057 */ 00058 Status = CsrLockThreadByClientId(a->ClientId.UniqueThread, &Thread); 00059 if (NT_SUCCESS(Status)) { 00060 ASSERT(a->ClientId.UniqueProcess == Thread->ClientId.UniqueProcess); 00061 00062 /* 00063 * Now that everything is set, rtlremote call to a debug breakpoint. 00064 * This causes the process to enter the debugger with a breakpoint. 00065 */ 00066 Status = RtlRemoteCall( 00067 Thread->Process->ProcessHandle, 00068 Thread->ThreadHandle, 00069 (PVOID)gpfnAttachRoutine, 00070 0, 00071 NULL, 00072 TRUE, 00073 FALSE 00074 ); 00075 UserAssert(NT_SUCCESS(Status)); 00076 Status = NtAlertThread(Thread->ThreadHandle); 00077 UserAssert(NT_SUCCESS(Status)); 00078 CsrUnlockThread(Thread); 00079 } 00080 00081 /* 00082 * Stop impersonating the client. 00083 */ 00084 if (m->h.u2.s2.Type == LPC_REQUEST) { 00085 CsrRevertToSelf(); 00086 } 00087 00088 return Status; 00089 } 00090 00091

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