Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. dllmain.c
  5. Abstract:
  6. Revision History:
  7. --*/
  8. #include "pch.h"
  9. #pragma hdrstop
  10. #include <debug.h>
  11. CRITICAL_SECTION g_csLock;
  12. HINSTANCE g_hinst;
  13. #if DBG
  14. ULONG DavClientDebugFlag = 0;
  15. #define DAVNP_PARAMETERS_KEY L"System\\CurrentControlSet\\Services\\WebClient\\Parameters"
  16. #define DAVNP_DEBUG_KEY L"ClientDebug"
  17. #endif
  18. extern LONG g_cRefCount;
  19. #define DAV_NETWORK_PROVIDER L"SYSTEM\\CurrentControlSet\\Services\\WebClient\\NetworkProvider"
  20. #define DAV_NETWORK_PROVIDER_NAME L"Name"
  21. WCHAR DavClientDisplayName[MAX_PATH];
  22. BOOL
  23. WINAPI
  24. DllMain (
  25. HINSTANCE hinst,
  26. DWORD dwReason,
  27. LPVOID pvReserved
  28. )
  29. /*++
  30. Routine Description:
  31. The DllMain routine for the davclnt.dll. DllMain should do as little work
  32. as possible.
  33. Arguments:
  34. hinst - Instance handle of the DLL.
  35. dwReason - The reason for this function to be called by the system.
  36. pvReserved - Indicated whether the DLL was implicitly or explicitly loaded.
  37. Return Value:
  38. TRUE.
  39. --*/
  40. {
  41. DWORD WStatus = ERROR_SUCCESS;
  42. HKEY KeyHandle = NULL;
  43. ULONG ValueType = 0, ValueSize = 0;
  44. if (DLL_PROCESS_ATTACH == dwReason) {
  45. //
  46. // DisableThreadLibraryCalls tells the loader we don't need to
  47. // be informed of DLL_THREAD_ATTACH and DLL_THREAD_DETACH events.
  48. //
  49. DisableThreadLibraryCalls (hinst);
  50. //
  51. // Syncrhonization support --
  52. // Unless you have *measured* lock contention, you should only need
  53. // one lock for the entire DLL. (and maybe you don't even need one.)
  54. //
  55. try {
  56. InitializeCriticalSection ( &(g_csLock) );
  57. } except(EXCEPTION_EXECUTE_HANDLER) {
  58. ULONG WStatus = GetExceptionCode();
  59. }
  60. // Save our instance handle in a global variable to be used
  61. // when loading resources etc.
  62. //
  63. g_hinst = hinst;
  64. g_cRefCount = 0;
  65. //
  66. // Read the DAV Network Provider Name out of the registry.
  67. //
  68. DavClientDisplayName[0] = L'\0';
  69. WStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
  70. DAV_NETWORK_PROVIDER,
  71. 0,
  72. KEY_QUERY_VALUE,
  73. &(KeyHandle));
  74. if (WStatus == ERROR_SUCCESS) {
  75. ValueSize = sizeof(DavClientDisplayName);
  76. WStatus = RegQueryValueExW(KeyHandle,
  77. DAV_NETWORK_PROVIDER_NAME,
  78. 0,
  79. &(ValueType),
  80. (LPBYTE)&(DavClientDisplayName),
  81. &(ValueSize));
  82. RegCloseKey(KeyHandle);
  83. } else {
  84. DavClientDisplayName[0] = L'\0';
  85. }
  86. #if DBG
  87. //
  88. // Read DebugFlags value from the registry. If the entry exists, the global
  89. // filter "DavClientDebugFlag" is set to this value. This value is used in
  90. // filtering the debug messages.
  91. //
  92. WStatus = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
  93. DAVNP_PARAMETERS_KEY,
  94. 0,
  95. KEY_QUERY_VALUE,
  96. &(KeyHandle));
  97. if (WStatus == ERROR_SUCCESS) {
  98. ValueSize = sizeof(DavClientDebugFlag);
  99. WStatus = RegQueryValueExW(KeyHandle,
  100. DAVNP_DEBUG_KEY,
  101. 0,
  102. &(ValueType),
  103. (LPBYTE)&(DavClientDebugFlag),
  104. &(ValueSize));
  105. RegCloseKey(KeyHandle);
  106. }
  107. #endif
  108. } else if (DLL_PROCESS_DETACH == dwReason) {
  109. DeleteCriticalSection (&g_csLock);
  110. }
  111. return TRUE;
  112. }