diff --git a/reactos/include/ntdll/ntdll.h b/reactos/include/ntdll/ntdll.h index d34ef0292d7..1a1b342a523 100644 --- a/reactos/include/ntdll/ntdll.h +++ b/reactos/include/ntdll/ntdll.h @@ -1,14 +1,13 @@ -extern void dprintf(char* fmt,...); -#define UNIMPLEMENTED dprintf("%s in %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__); +#define UNIMPLEMENTED DbgPrint("%s in %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__); #ifdef NDEBUG #define DPRINT(args...) #else -#define DPRINT(args...) do { dprintf("(NTDLL:%s:%d) ",__FILE__,__LINE__); dprintf(args); } while(0); +#define DPRINT(args...) do { DbgPrint("(NTDLL:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); #endif -#define DPRINT1(args...) do { dprintf("(NTDLL:%s:%d) ",__FILE__,__LINE__); dprintf(args); } while(0); +#define DPRINT1(args...) do { DbgPrint("(NTDLL:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b)) #define ROUNDDOWN(a,b) (((a)/(b))*(b)) diff --git a/reactos/lib/ntdll/dbg/print.c b/reactos/lib/ntdll/dbg/print.c index 78588711be6..4d43b20549c 100644 --- a/reactos/lib/ntdll/dbg/print.c +++ b/reactos/lib/ntdll/dbg/print.c @@ -1,6 +1,12 @@ -/* $Id: print.c,v 1.1 2000/01/10 20:31:23 ekohl Exp $ +/* $Id: print.c,v 1.2 2000/01/18 12:04:16 ekohl Exp $ * - + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: lib/ntdll/dbg/print.c + * PURPOSE: Debug output + * PROGRAMMER: Eric Kohl + * UPDATE HISTORY: + * Created 28/12/1999 */ #include @@ -8,30 +14,36 @@ #include #include + +/* FUNCTIONS ***************************************************************/ + +ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2); +__asm__ ("\n\t.global _DbgService\n\t" + "_DbgService:\n\t" + "mov 4(%esp), %eax\n\t" + "mov 8(%esp), %ecx\n\t" + "mov 12(%esp), %edx\n\t" + "int $0x2D\n\t" + "ret\n\t"); + ULONG -DbgPrint (PCH Format, ...) +DbgPrint(PCH Format, ...) { - CHAR Buffer[512]; - va_list ap; - UNICODE_STRING UnicodeString; - ANSI_STRING AnsiString; + ANSI_STRING DebugString; + CHAR Buffer[512]; + va_list ap; - va_start (ap, Format); - vsprintf (Buffer, Format, ap); - va_end (ap); + /* init ansi string */ + DebugString.Buffer = Buffer; + DebugString.MaximumLength = 512; - RtlInitAnsiString (&AnsiString, - Buffer); - RtlAnsiStringToUnicodeString (&UnicodeString, - &AnsiString, - TRUE); + va_start (ap, Format); + DebugString.Length = _vsnprintf (Buffer, 512, Format, ap); + va_end (ap); - /* FIXME: send string to debugging subsystem */ - NtDisplayString (&UnicodeString); + DbgService (1, &DebugString, NULL); - RtlFreeUnicodeString (&UnicodeString); - - return (strlen (Buffer)); + return (ULONG)DebugString.Length; } /* EOF */ diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c index 80a325b74f7..b4ccb06dc16 100644 --- a/reactos/lib/ntdll/ldr/startup.c +++ b/reactos/lib/ntdll/ldr/startup.c @@ -1,4 +1,4 @@ -/* $Id: startup.c,v 1.14 1999/12/30 01:51:38 dwelch Exp $ +/* $Id: startup.c,v 1.15 2000/01/18 12:04:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -109,7 +109,7 @@ VOID LdrStartup(PPEB Peb, PEDosHeader->e_lfanew == 0L || *(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC) { - dprintf("Image has bad header\n"); + DbgPrint("Image has bad header\n"); ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL); } @@ -124,7 +124,7 @@ VOID LdrStartup(PPEB Peb, if (EntryPoint == NULL) { - dprintf("Failed to initialize image\n"); + DbgPrint("Failed to initialize image\n"); ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL); } @@ -134,10 +134,10 @@ VOID LdrStartup(PPEB Peb, Status = CsrConnectToServer(); if (!NT_SUCCESS(Status)) { - dprintf("Failed to connect to csrss.exe: expect trouble\n"); + DbgPrint("Failed to connect to csrss.exe: expect trouble\n"); } -// dprintf("Transferring control to image at %x\n",EntryPoint); +// DbgPrint("Transferring control to image at %x\n",EntryPoint); Status = EntryPoint(Peb); ZwTerminateProcess(NtCurrentProcess(),Status); } diff --git a/reactos/lib/ntdll/ldr/utils.c b/reactos/lib/ntdll/ldr/utils.c index 0bded1647a4..3c2674838c2 100644 --- a/reactos/lib/ntdll/ldr/utils.c +++ b/reactos/lib/ntdll/ldr/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.22 1999/12/26 15:50:46 dwelch Exp $ +/* $Id: utils.c,v 1.23 2000/01/18 12:04:31 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -138,7 +138,7 @@ NTSTATUS LdrLoadDll (PDLL* Dll, ); if (!NT_SUCCESS(Status)) { - dprintf("Dll open of %s failed: Status = 0x%08x\n", + DbgPrint("Dll open of %s failed: Status = 0x%08x\n", fqname, Status); return Status; } @@ -230,7 +230,7 @@ NTSTATUS LdrLoadDll (PDLL* Dll, ); if (!NT_SUCCESS(Status)) { - dprintf("NTDLL.LDR: map view of section failed (Status %x)\n", + DbgPrint("NTDLL.LDR: map view of section failed (Status %x)\n", Status); ZwClose(FileHandle); return(Status); @@ -458,7 +458,7 @@ LdrGetExportByOrdinal ( Module->BaseAddress, ExportDir->AddressOfFunctions ); - dprintf( + DbgPrint( "LdrGetExportByOrdinal(Ordinal %d) = %x\n", Ordinal, ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]] @@ -549,7 +549,7 @@ LdrGetExportByName ( } } - dprintf("LdrGetExportByName() = failed to find %s\n",SymbolName); + DbgPrint("LdrGetExportByName() = failed to find %s\n",SymbolName); return NULL; } @@ -777,7 +777,7 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders, ); if ((*ImportAddressList) == NULL) { - dprintf("Failed to import %s\n", pName); + DbgPrint("Failed to import %s\n", pName); return STATUS_UNSUCCESSFUL; } } @@ -852,7 +852,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase, Status = LdrPerformRelocations(NTHeaders, ImageBase); if (!NT_SUCCESS(Status)) { - dprintf("LdrPerformRelocations() failed\n"); + DbgPrint("LdrPerformRelocations() failed\n"); return NULL; } } @@ -868,7 +868,7 @@ PEPFUNC LdrPEStartup (PVOID ImageBase, Status = LdrFixupImports(NTHeaders, ImageBase); if (!NT_SUCCESS(Status)) { - dprintf("LdrFixupImports() failed\n"); + DbgPrint("LdrFixupImports() failed\n"); return NULL; } } diff --git a/reactos/lib/ntdll/main/dllmain.c b/reactos/lib/ntdll/main/dllmain.c index cb868384679..a4abf26888e 100644 --- a/reactos/lib/ntdll/main/dllmain.c +++ b/reactos/lib/ntdll/main/dllmain.c @@ -1,4 +1,5 @@ -/* +/* $Id: dllmain.c,v 1.6 2000/01/18 12:04:45 ekohl Exp $ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/ntdll/main/dllmain.c @@ -11,25 +12,6 @@ #include #include -void dprintf(char* fmt,...) -{ - char buffer[512]; - va_list ap; - WCHAR bufferw[512]; - UNICODE_STRING UnicodeString; - ULONG i; - - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - for (i=0; buffer[i] != 0; i++) - { - bufferw[i] = buffer[i]; - } - bufferw[i] = 0; - RtlInitUnicodeString(&UnicodeString, bufferw); - NtDisplayString(&UnicodeString); - va_end(ap); -} BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDll, DWORD fdwReason,