IN ULONG Level)
{
/* Call the INT2D Service */
- //return STATUS_SUCCESS;
return DebugService(BREAKPOINT_PRINT,
DebugString->Buffer,
DebugString->Length,
IN va_list ap,
IN BOOLEAN HandleBreakpoint)
{
- NTSTATUS Status;
+ NTSTATUS Status = STATUS_SUCCESS;
ANSI_STRING DebugString;
CHAR Buffer[512];
- PCHAR pBuffer = Buffer;
- ULONG pBufferSize = sizeof(Buffer);
- ULONG Length;
+ ULONG Length, PrefixLength;
EXCEPTION_RECORD ExceptionRecord;
/* Check if we should print it or not */
- if (ComponentId != -1 && !NtQueryDebugFilterState(ComponentId, Level))
+ if ((ComponentId != -1) && !(NtQueryDebugFilterState(ComponentId, Level)))
{
/* This message is masked */
- return STATUS_SUCCESS;
+ return Status;
}
/* For user mode, don't recursively DbgPrint */
- if (RtlpSetInDbgPrint(TRUE)) return STATUS_SUCCESS;
-
- /* Initialize the length to 8 */
- DebugString.Length = 0;
+ if (RtlpSetInDbgPrint(TRUE)) return Status;
- /* Handle the prefix */
- if (Prefix && *Prefix)
+ /* Guard against incorrect pointers */
+ _SEH_TRY
{
- /* Get the length */
- DebugString.Length = strlen(Prefix);
-
- /* Normalize it */
- if(DebugString.Length > sizeof(Buffer))
- {
- DebugString.Length = sizeof(Buffer);
- }
+ /* Get the length and normalize it */
+ PrefixLength = strlen(Prefix);
+ if (PrefixLength > sizeof(Buffer)) PrefixLength = sizeof(Buffer);
/* Copy it */
- strncpy(Buffer, Prefix, DebugString.Length);
+ strncpy(Buffer, Prefix, PrefixLength);
- /* Set the pointer and update the size */
- pBuffer = &Buffer[DebugString.Length];
- pBufferSize -= DebugString.Length;
+ /* Do the printf */
+ Length = _vsnprintf(Buffer + PrefixLength,
+ sizeof(Buffer) - PrefixLength,
+ Format,
+ ap);
}
-
- /* Setup the ANSI String */
- DebugString.Buffer = Buffer;
- DebugString.MaximumLength = sizeof(Buffer);
- Length = _vsnprintf(pBuffer, pBufferSize, Format, ap);
+ _SEH_HANDLE
+ {
+ /* Fail */
+ Length = PrefixLength = 0;
+ Status = _SEH_GetExceptionCode();
+ }
+ _SEH_END;
+ if (!NT_SUCCESS(Status)) return Status;
/* Check if we went past the buffer */
if (Length == -1)
/* Put maximum */
Length = sizeof(Buffer);
}
+ else
+ {
+ /* Add the prefix */
+ Length += PrefixLength;
+ }
- /* Update length */
- DebugString.Length += (USHORT)Length;
+ /* Build the string */
+ DebugString.Length = Length;
+ DebugString.Buffer = Buffer;
/* First, let the debugger know as well */
if (RtlpCheckForActiveDebugger(FALSE))
if (Status == STATUS_BREAKPOINT)
{
/* Breakpoint */
- DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
+ //DbgBreakPointWithStatus(DBG_STATUS_CONTROL_C);
Status = STATUS_SUCCESS;
}
}
IN va_list ap)
{
/* Call the internal routine that also handles ControlC */
- return vDbgPrintExWithPrefixInternal(NULL,
+ return vDbgPrintExWithPrefixInternal("",
ComponentId,
Level,
Format,
DbgPrint(PCCH Format,
...)
{
+ ULONG n;
va_list ap;
/* Call the internal routine that also handles ControlC */
va_start(ap, Format);
- return vDbgPrintExWithPrefixInternal(NULL,
+ n = vDbgPrintExWithPrefixInternal("",
-1,
DPFLTR_ERROR_LEVEL,
Format,
ap,
TRUE);
va_end(ap);
+ return n;
}
/*
IN PCCH Format,
...)
{
+ ULONG n;
va_list ap;
/* Call the internal routine that also handles ControlC */
va_start(ap, Format);
- return vDbgPrintExWithPrefixInternal(NULL,
+ n = vDbgPrintExWithPrefixInternal("",
ComponentId,
Level,
Format,
ap,
TRUE);
va_end(ap);
+ return n;
}
/*
DbgPrintReturnControlC(PCH Format,
...)
{
+ ULONG n;
va_list ap;
/* Call the internal routine that also handles ControlC */
va_start(ap, Format);
- return vDbgPrintExWithPrefixInternal(NULL,
+ n = vDbgPrintExWithPrefixInternal("",
-1,
DPFLTR_ERROR_LEVEL,
Format,
ap,
FALSE);
+ va_end(ap);
+ return n;
}
/*
NTAPI
DbgLoadImageSymbols(IN PANSI_STRING Name,
IN PVOID Base,
- IN ULONG ProcessId)
+ IN ULONG_PTR ProcessId)
{
PIMAGE_NT_HEADERS NtHeader;
KD_SYMBOLS_INFO SymbolInfo;