3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * PROJECT: ReactOS kernel
22 * PURPOSE: Tracing library calls
23 * FILE: lib/ntdll/rtl/trace.c
24 * PROGRAMER: David Welch <welch@cwcom.net>
27 /* INCLUDES *****************************************************************/
29 #include <ddk/ntddk.h>
30 #include <ntdll/trace.h>
36 /* GLOBALS *******************************************************************/
38 static NTDLL_TRACE_TABLE TraceTable;
39 static BOOLEAN TraceTableValid = FALSE;
41 /* FUNCTIONS *****************************************************************/
47 UNICODE_STRING SectionName;
48 OBJECT_ATTRIBUTES ObjectAttributes;
51 PROCESS_BASIC_INFORMATION Pbi;
57 Status = NtQueryInformationProcess(NtCurrentProcess(),
58 ProcessBasicInformation,
62 if (!NT_SUCCESS(Status))
67 sprintf(Buffer, "\\??\\TraceSection%d", Pbi.UniqueProcessId);
69 InitializeObjectAttributes(&ObjectAttributes,
74 Status = NtOpenSection(&SectionHandle,
77 if (!NT_SUCCESS(Status))
85 Status = NtMapViewOfSection(SectionHandle,
89 sizeof(NTDLL_TRACE_TABLE),
95 if (!NT_SUCCESS(Status))
97 NtClose(SectionHandle);
100 NtClose(SectionHandle);
102 memcpy(&TraceTable, BaseAddress, sizeof(TraceTable));
103 TraceTableValid = TRUE;
105 Status = NtUnmapViewOfSection(NtCurrentProcess(), BaseAddress);
107 return(STATUS_SUCCESS);
111 RtlPrintTrace(ULONG Flag, PCH Format, ...)
116 if (!TraceTableValid)
120 if (TraceTable.Flags[Flag / BITS_IN_CHAR] & (1 << (Flag % BITS_IN_CHAR)))
122 va_start(ap, Format);
123 vsprintf(FString, Format, ap);