00043 :
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 {
00065 va_list arglist;
00066 UCHAR
Buffer[512];
00067
int cb;
00068 STRING Output;
00069
NTSTATUS Status = STATUS_SUCCESS;
00070
#if !defined(BLDR_KERNEL_RUNTIME) && !defined(NTOS_KERNEL_RUNTIME)
00071
00072
if (NtCurrentTeb()->InDbgPrint) {
00073
return STATUS_SUCCESS;
00074 }
00075 NtCurrentTeb()->InDbgPrint =
TRUE;
00076
#endif
00077
00078
00079
00080
00081
00082 va_start(arglist, Format);
00083
00084
#if !defined(BLDR_KERNEL_RUNTIME)
00085
__try {
00086 cb = _vsnprintf(Buffer,
sizeof(Buffer), Format, arglist);
00087 } __except (EXCEPTION_EXECUTE_HANDLER) {
00088
Status = GetExceptionCode();
00089 }
00090
#else
00091
cb = _vsnprintf(Buffer,
sizeof(Buffer), Format, arglist);
00092
#endif
00093
00094 va_end(arglist);
00095
00096
if (!
NT_SUCCESS(Status)) {
00097
#if !defined(BLDR_KERNEL_RUNTIME) && !defined(NTOS_KERNEL_RUNTIME)
00098
NtCurrentTeb()->InDbgPrint =
FALSE;
00099
#endif
00100
return Status;
00101 }
00102
00103
if (cb == -1) {
00104 cb =
sizeof(
Buffer);
00105
Buffer[
sizeof(
Buffer) - 1] =
'\n';
00106 }
00107 Output.Buffer =
Buffer;
00108 Output.Length = (
USHORT) cb;
00109
00110
00111
00112
00113
00114
00115
00116
#if !defined(BLDR_KERNEL_RUNTIME) && !defined(NTOS_KERNEL_RUNTIME)
00117
#if !i386
00118
00119
00120
00121
00122
00123
if (NtCurrentPeb()->FastPebLockRoutine !=
NULL)
00124
#endif
00125
if (NtCurrentPeb()->BeingDebugged) {
00126
EXCEPTION_RECORD ExceptionRecord;
00127
00128
00129
00130
00131
00132 ExceptionRecord.ExceptionCode = DBG_PRINTEXCEPTION_C;
00133 ExceptionRecord.ExceptionRecord = (PEXCEPTION_RECORD)
NULL;
00134 ExceptionRecord.NumberParameters = 2;
00135 ExceptionRecord.ExceptionFlags = 0;
00136 ExceptionRecord.ExceptionInformation[ 0 ] = Output.Length + 1;
00137 ExceptionRecord.ExceptionInformation[ 1 ] = (ULONG_PTR)(Output.Buffer);
00138
RtlRaiseException( &ExceptionRecord );
00139
#if !defined(BLDR_KERNEL_RUNTIME) && !defined(NTOS_KERNEL_RUNTIME)
00140
NtCurrentTeb()->InDbgPrint =
FALSE;
00141
#endif
00142
return STATUS_SUCCESS;
00143 }
00144
#endif
00145
Status =
DebugPrint( &Output );
00146
if (
Status == STATUS_BREAKPOINT) {
00147 DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
00148
Status = STATUS_SUCCESS;
00149 }
00150
#if !defined(BLDR_KERNEL_RUNTIME) && !defined(NTOS_KERNEL_RUNTIME)
00151
NtCurrentTeb()->InDbgPrint =
FALSE;
00152
#endif
00153
return Status;
00154 }