From aa7adb232e8993c0429bf8ac0b63b050c3548fa2 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 23 Dec 2008 07:07:33 +0000 Subject: [PATCH] KDFS-windows-afsrdr-npdll-20081222 LICENSE BSD Add ..\AFSRedirector\NetworkProvider "Debug" registry value to control the use of OutputDebugString debugging messages. --- src/WINNT/afsrdr/npdll/AFS_Npdll.c | 32 +++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/WINNT/afsrdr/npdll/AFS_Npdll.c b/src/WINNT/afsrdr/npdll/AFS_Npdll.c index 194c49926b..c2bdf38704 100644 --- a/src/WINNT/afsrdr/npdll/AFS_Npdll.c +++ b/src/WINNT/afsrdr/npdll/AFS_Npdll.c @@ -43,6 +43,8 @@ #include #include +#define AFS_DEBUG_TRACE 1 + #ifndef WNNC_NET_OPENAFS #define WNNC_NET_OPENAFS 0x00390000 #endif @@ -63,8 +65,6 @@ // Common information // -//#define AFS_DEBUG_TRACE 1 - ULONG _cdecl AFSDbgPrint( PWCHAR Format, ... ); #define WNNC_DRIVER( major, minor ) ( major * 0x00010000 + minor ) @@ -1327,6 +1327,29 @@ NPCloseEnum( HANDLE hEnum ) return WN_SUCCESS; } +static BOOL +Debug(void) +{ + static int init = 0; + static BOOL debug = 0; + + if ( !init ) { + HKEY hk; + + if (RegOpenKey (HKEY_LOCAL_MACHINE, + TEXT("SYSTEM\\CurrentControlSet\\Services\\AFSRedirector\\NetworkProvider"), &hk) == 0) + { + DWORD dwSize = sizeof(BOOL); + DWORD dwType = REG_DWORD; + RegQueryValueEx (hk, TEXT("Debug"), NULL, &dwType, (PBYTE)&debug, &dwSize); + RegCloseKey (hk); + } + init = 1; + } + + return debug; +} + ULONG _cdecl AFSDbgPrint( @@ -1336,8 +1359,11 @@ AFSDbgPrint( { ULONG rc = 0; WCHAR wszbuffer[255]; - va_list marker; + + if ( !Debug() ) + return 0; + va_start( marker, Format ); { rc = wvsprintf( wszbuffer, Format, marker );