Source code of Windows XP (NT5)
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.

168 lines
4.7 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 LibMain 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 LibMain.
  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 LibMain.
  33. //
  34. TCHAR* g_pszHelpFile = NULL;
  35. // The name of the on-line ROUTER help file. Initialized in LibMain.
  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. HANDLE g_hmutexCallbacks = NULL;
  42. LONG g_ulCallbacksActive = 0L; //Change this for whistler bug 341662 gangz
  43. BOOL g_fTerminateAsap = FALSE;
  44. // ----------------------------------------------------------------------------
  45. // Rasdlg DLL entrypoint
  46. // ----------------------------------------------------------------------------
  47. BOOL
  48. LibMain(
  49. HANDLE hinstDll,
  50. DWORD fdwReason,
  51. LPVOID lpReserved )
  52. // This routine is called by the system on various events such as the
  53. // process attachment and detachment. See Win32 DllEntryPoint
  54. // documentation.
  55. //
  56. // Returns true if successful, false otherwise.
  57. //
  58. {
  59. if (fdwReason == DLL_PROCESS_ATTACH)
  60. {
  61. // Initialize trace and assert support.
  62. //
  63. DEBUGINIT( "RASDLG" );
  64. // Initialize fusion
  65. // For whistler bug 349866
  66. //
  67. SHFusionInitializeFromModuleID(hinstDll, 128);
  68. // Stash the DLL instance handle for use in the dialog/window calls
  69. // later.
  70. //
  71. g_hinstDll = hinstDll;
  72. // Register the context ID atom for use in the Windows XxxProp calls
  73. // which are used to associate a context with a dialog window handle.
  74. //
  75. g_contextId = (LPCTSTR )GlobalAddAtom( TEXT("RASDLG") );
  76. if (!g_contextId)
  77. return FALSE;
  78. // Initialize the TreeList custom control
  79. //
  80. TL_Init( hinstDll );
  81. // Load the name of our on-line help file.
  82. //
  83. g_pszHelpFile = PszFromId( hinstDll, SID_HelpFile );
  84. // Load the name of our on-line help file.
  85. //
  86. g_pszRouterHelpFile = PszFromId( hinstDll, SID_RouterHelpFile );
  87. // Initialize the Phonebook library.
  88. //
  89. if (InitializePbk() != 0)
  90. {
  91. return FALSE;
  92. }
  93. // Mutex protecting count of active RasDial callbacks.
  94. //
  95. if (!(g_hmutexCallbacks = CreateMutex( NULL, FALSE, NULL )))
  96. {
  97. return FALSE;
  98. }
  99. // [pmay] Allow the ras server ui to initialize
  100. RassrvHandleProcessAttach(hinstDll, lpReserved);
  101. }
  102. else if (fdwReason == DLL_PROCESS_DETACH)
  103. {
  104. // [pmay] Allow the ras server ui to cleanup
  105. RassrvHandleProcessDetach(hinstDll, lpReserved);
  106. // Remove the context ID atom we registered at initialization.
  107. //
  108. GlobalDeleteAtom( LOWORD( g_contextId ) );
  109. // Unload the wizard bitmap.
  110. //
  111. if (g_hbmWizard)
  112. DeleteObject( (HGDIOBJ )g_hbmWizard );
  113. // Free the on-line help file string.
  114. //
  115. Free0( g_pszHelpFile );
  116. Free0( g_pszRouterHelpFile );
  117. /* Uninitialize the Phonebook library.
  118. */
  119. TerminatePbk();
  120. if (g_hmutexCallbacks)
  121. {
  122. CloseHandle( g_hmutexCallbacks );
  123. }
  124. /* Unload dynamically loaded DLLs, if any.
  125. */
  126. UnloadRas();
  127. //For whistler bug 349866
  128. //
  129. SHFusionUninitialize();
  130. /* Terminate trace and assert support.
  131. */
  132. DEBUGTERM();
  133. }
  134. return TRUE;
  135. }