From 26b82125e5797c2c868f2649cfe263bbb3a70ded Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 31 Aug 2006 16:08:17 +0000 Subject: [PATCH] Change a very ugly done DbgPrint() function to a good implementation. Now Freeldr shows all DPRINTs from e.g. cmlib correctly. svn path=/trunk/; revision=23843 --- .../boot/freeldr/freeldr/reactos/reactos.c | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/reactos/reactos.c b/reactos/boot/freeldr/freeldr/reactos/reactos.c index 39bd4abc350..f76d8d280fe 100644 --- a/reactos/boot/freeldr/freeldr/reactos/reactos.c +++ b/reactos/boot/freeldr/freeldr/reactos/reactos.c @@ -870,10 +870,33 @@ LoadAndBootReactOS(PCSTR OperatingSystemName) #undef DbgPrint ULONG -DbgPrint(const char *Fmt, ...) +DbgPrint(const char *Format, ...) { - UiMessageBox(Fmt); - return 0; + va_list ap; + CHAR Buffer[512]; + ULONG Length; + + va_start(ap, Format); + + /* Construct a string */ + Length = _vsnprintf(Buffer, 512, Format, ap); + + /* Check if we went past the buffer */ + if (Length == -1) + { + /* Terminate it if we went over-board */ + Buffer[sizeof(Buffer) - 1] = '\n'; + + /* Put maximum */ + Length = sizeof(Buffer); + } + + /* Show it as a message box */ + UiMessageBox(Buffer); + + /* Cleanup and exit */ + va_end(ap); + return 0; } /* EOF */