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.

190 lines
5.4 KiB

  1. // Copyright (c) 1995, Microsoft Corporation, all rights reserved
  2. //
  3. // main.c
  4. // Remote Access Common Dialog APIs
  5. // Main routines
  6. //
  7. // 06/20/95 Steve Cobb
  8. #include "rasdlgp.h"
  9. #include "treelist.h" // for TL_Init: RasMonitorDlg only
  10. #define INCL_ENCRYPT
  11. #include <rassrvp.h> // [pmay] private header merges this project with ras server ui
  12. //-----------------------------------------------------------------------------
  13. // Rasdlg globals
  14. //-----------------------------------------------------------------------------
  15. // IMPORTANT: No globals may be defined that do not work properly when the DLL
  16. // is called by multiple threads within a single process.
  17. //
  18. // Handle of the DLL instance set from the corresponding DllMain parameter.
  19. //
  20. HINSTANCE g_hinstDll = NULL;
  21. // The atom identifying our context property suitable for use by the Windows
  22. // XxxProp APIs. A Prop is used to associate context information with a
  23. // property sheet. The atom is registered in DllMain.
  24. //
  25. LPCTSTR g_contextId = NULL;
  26. // The handle of the RAS wizard bitmap. This is needed only because
  27. // DLGEDIT.EXE is currently unable to produce the RC syntax necessary to
  28. // create a self-contained SS_BITMAP control, so the image must be set at
  29. // run-time. See also SetWizardBitmap().
  30. //
  31. HBITMAP g_hbmWizard = NULL;
  32. // The name of the on-line help file. Initialized in DllMain.
  33. //
  34. TCHAR* g_pszHelpFile = NULL;
  35. // The name of the on-line ROUTER help file. Initialized in DllMain.
  36. //
  37. TCHAR* g_pszRouterHelpFile = NULL;
  38. // Count of RasDial callbacks active and the flag telling the dialer to
  39. // terminate them ASAP, plus the mutex that protects these fields.
  40. //
  41. LONG g_ulCallbacksActive = 0L; //Change this for whistler bug 341662 gangz
  42. BOOL g_fTerminateAsap = FALSE;
  43. //for XPSP2 511810, .Net 668164
  44. CRITICAL_SECTION g_csCallBacks;
  45. // For whistler 460931
  46. CRITICAL_SECTION g_csDiagTab;
  47. // ----------------------------------------------------------------------------
  48. // Rasdlg DLL entrypoint
  49. // ----------------------------------------------------------------------------
  50. BOOL
  51. DllMain(
  52. HANDLE hinstDll,
  53. DWORD fdwReason,
  54. LPVOID lpReserved )
  55. // This routine is called by the system on various events such as the
  56. // process attachment and detachment. See Win32 DllEntryPoint
  57. // documentation.
  58. //
  59. // Returns true if successful, false otherwise.
  60. //
  61. {
  62. if (fdwReason == DLL_PROCESS_ATTACH)
  63. {
  64. // Initialize trace and assert support.
  65. //
  66. DEBUGINIT( "RASDLG" );
  67. // Initialize fusion
  68. // For whistler bug 349866
  69. //
  70. SHFusionInitializeFromModuleID(hinstDll, 128);
  71. // Stash the DLL instance handle for use in the dialog/window calls
  72. // later.
  73. //
  74. g_hinstDll = hinstDll;
  75. // Register the context ID atom for use in the Windows XxxProp calls
  76. // which are used to associate a context with a dialog window handle.
  77. //
  78. g_contextId = (LPCTSTR )GlobalAddAtom( TEXT("RASDLG") );
  79. if (!g_contextId)
  80. return FALSE;
  81. //[gangz] For whistler 460931
  82. __try
  83. {
  84. InitializeCriticalSection( & g_csDiagTab );
  85. }
  86. __except(EXCEPTION_EXECUTE_HANDLER)
  87. {
  88. return FALSE;
  89. }
  90. //for XPSP2 511810, .Net 668164
  91. // CriticalSection protecting count of active RasDial callbacks.
  92. //
  93. __try
  94. {
  95. InitializeCriticalSection( &g_csCallBacks);
  96. }
  97. __except(EXCEPTION_EXECUTE_HANDLER)
  98. {
  99. return FALSE;
  100. }
  101. // Initialize the TreeList custom control
  102. //
  103. TL_Init( hinstDll );
  104. // Load the name of our on-line help file.
  105. //
  106. g_pszHelpFile = PszFromId( hinstDll, SID_HelpFile );
  107. // Load the name of our on-line help file.
  108. //
  109. g_pszRouterHelpFile = PszFromId( hinstDll, SID_RouterHelpFile );
  110. // Initialize the Phonebook library.
  111. //
  112. if (InitializePbk() != 0)
  113. {
  114. return FALSE;
  115. }
  116. // [pmay] Allow the ras server ui to initialize
  117. RassrvHandleProcessAttach(hinstDll, lpReserved);
  118. }
  119. else if (fdwReason == DLL_PROCESS_DETACH)
  120. {
  121. //[gangz] for whistler bug 460931
  122. DeleteCriticalSection( & g_csDiagTab );
  123. //for .net 511810
  124. DeleteCriticalSection( & g_csCallBacks);
  125. // [pmay] Allow the ras server ui to cleanup
  126. RassrvHandleProcessDetach(hinstDll, lpReserved);
  127. // Remove the context ID atom we registered at initialization.
  128. //
  129. GlobalDeleteAtom( LOWORD( g_contextId ) );
  130. // Unload the wizard bitmap.
  131. //
  132. if (g_hbmWizard)
  133. DeleteObject( (HGDIOBJ )g_hbmWizard );
  134. // Free the on-line help file string.
  135. //
  136. Free0( g_pszHelpFile );
  137. Free0( g_pszRouterHelpFile );
  138. /* Uninitialize the Phonebook library.
  139. */
  140. TerminatePbk();
  141. /* Unload dynamically loaded DLLs, if any.
  142. */
  143. UnloadRas();
  144. //For whistler bug 349866
  145. //
  146. SHFusionUninitialize();
  147. /* Terminate trace and assert support.
  148. */
  149. DEBUGTERM();
  150. }
  151. return TRUE;
  152. }