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.
19 /* $Id: trace.c,v 1.2 2002/09/07 15:12:41 chorns Exp $
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 #define NTOS_USER_MODE
37 /* GLOBALS *******************************************************************/
39 static NTDLL_TRACE_TABLE TraceTable
;
40 static BOOLEAN TraceTableValid
= FALSE
;
42 /* FUNCTIONS *****************************************************************/
48 UNICODE_STRING SectionName
;
49 OBJECT_ATTRIBUTES ObjectAttributes
;
52 PROCESS_BASIC_INFORMATION Pbi
;
58 Status
= NtQueryInformationProcess(NtCurrentProcess(),
59 ProcessBasicInformation
,
63 if (!NT_SUCCESS(Status
))
68 sprintf(Buffer
, "\\??\\TraceSection%d", Pbi
.UniqueProcessId
);
70 InitializeObjectAttributes(&ObjectAttributes
,
75 Status
= NtOpenSection(&SectionHandle
,
78 if (!NT_SUCCESS(Status
))
86 Status
= NtMapViewOfSection(SectionHandle
,
90 sizeof(NTDLL_TRACE_TABLE
),
96 if (!NT_SUCCESS(Status
))
98 NtClose(SectionHandle
);
101 NtClose(SectionHandle
);
103 memcpy(&TraceTable
, BaseAddress
, sizeof(TraceTable
));
104 TraceTableValid
= TRUE
;
106 Status
= NtUnmapViewOfSection(NtCurrentProcess(), BaseAddress
);
108 return(STATUS_SUCCESS
);
112 RtlPrintTrace(ULONG Flag
, PCH Format
, ...)
117 if (!TraceTableValid
)
121 if (TraceTable
.Flags
[Flag
/ BITS_IN_CHAR
] & (1 << (Flag
% BITS_IN_CHAR
)))
123 va_start(ap
, Format
);
124 vsprintf(FString
, Format
, ap
);