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.

158 lines
4.5 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 2000-2002 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: DllMain.cpp
  6. * Content: Defines the entry point for the DLL application.
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 02/21/2000 mjn Created
  12. * 06/07/2000 rmt Bug #34383 Must provide CLSID for each IID to fix issues with Whistler
  13. * 06/15/2000 rmt Bug #33617 - Must provide method for providing automatic launch of DirectPlay instances
  14. * 07/21/2000 RichGr IA64: Use %p format specifier for 32/64-bit pointers.
  15. * 08/18/2000 rmt Bug #42751 - DPLOBBY8: Prohibit more than one lobby client or lobby app per process
  16. * 08/30/2000 rmt Whistler Bug #171824 - PREFIX Bug
  17. * 04/12/2001 VanceO Moved granting registry permissions into common.
  18. * 06/16/2001 rodtoll WINBUG #416983 - RC1: World has full control to HKLM\Software\Microsoft\DirectPlay\Applications on Personal
  19. * Implementing mirror of keys into HKCU. Algorithm is now:
  20. * - Read of entries tries HKCU first, then HKLM
  21. * - Enum of entires is combination of HKCU and HKLM entries with duplicates removed. HKCU takes priority.
  22. * - Write of entries is HKLM and HKCU. (HKLM may fail, but is ignored).
  23. * - Removed permission modifications from lobby self-registration -- no longer needed.
  24. * 06/19/2001 RichGr DX8.0 added special security rights for "everyone" - remove them if they exist.
  25. *@@END_MSINTERNAL
  26. *
  27. ***************************************************************************/
  28. #include "dnlobbyi.h"
  29. #ifndef DPNBUILD_LIBINTERFACE
  30. // Globals
  31. extern LONG g_lLobbyObjectCount;
  32. #endif // ! DPNBUILD_LIBINTERFACE
  33. DEBUG_ONLY(BOOL g_fLobbyObjectInited = FALSE);
  34. #define DNOSINDIR_INITED 0x00000001
  35. #define DNCOM_INITED 0x00000002
  36. #undef DPF_MODNAME
  37. #define DPF_MODNAME "DNLobbyInit"
  38. BOOL DNLobbyInit(HANDLE hModule)
  39. {
  40. DWORD dwInitFlags = 0;
  41. #ifdef DBG
  42. DNASSERT(!g_fLobbyObjectInited);
  43. #endif // DBG
  44. DEBUG_ONLY(g_fLobbyObjectInited = TRUE);
  45. return TRUE;
  46. }
  47. #undef DPF_MODNAME
  48. #define DPF_MODNAME "DNLobbyDeInit"
  49. void DNLobbyDeInit()
  50. {
  51. #ifdef DBG
  52. DNASSERT(g_fLobbyObjectInited);
  53. #endif // DBG
  54. DPFX(DPFPREP, 5, "Deinitializing Lobby");
  55. DEBUG_ONLY(g_fLobbyObjectInited = FALSE);
  56. }
  57. #ifndef DPNBUILD_NOCOMREGISTER
  58. #undef DPF_MODNAME
  59. #define DPF_MODNAME "DNLobbyRegister"
  60. BOOL DNLobbyRegister(LPCWSTR wszDLLName)
  61. {
  62. if( !CRegistry::Register( L"DirectPlay8Lobby.LobbyClient.1", L"DirectPlay8LobbyClient Object",
  63. wszDLLName, &CLSID_DirectPlay8LobbyClient, L"DirectPlay8Lobby.LobbyClient") )
  64. {
  65. DPFERR( "Could not register lobby client object" );
  66. return FALSE;
  67. }
  68. if( !CRegistry::Register( L"DirectPlay8Lobby.LobbiedApplication.1", L"DirectPlay8LobbiedApplication Object",
  69. wszDLLName, &CLSID_DirectPlay8LobbiedApplication, L"DirectPlay8Lobby.LobbiedApplication") )
  70. {
  71. DPFERR( "Could not register lobby client object" );
  72. return FALSE;
  73. }
  74. CRegistry creg;
  75. if( !creg.Open( HKEY_LOCAL_MACHINE, DPL_REG_LOCAL_APPL_ROOT DPL_REG_LOCAL_APPL_SUB, FALSE, TRUE ) )
  76. {
  77. DPFERR( "Could not create app subkey" );
  78. return FALSE;
  79. }
  80. // Adjust security permissions of the given key
  81. else
  82. {
  83. #ifdef WINNT
  84. // 6/19/01: DX8.0 added special security rights for "everyone" - remove them.
  85. if( !creg.RemoveAllAccessSecurityPermissions() )
  86. {
  87. DPFX(DPFPREP, 0, "Error removing security permissions for app key" );
  88. }
  89. #endif // WINNT
  90. }
  91. return TRUE;
  92. }
  93. #undef DPF_MODNAME
  94. #define DPF_MODNAME "DNLobbyUnRegister"
  95. BOOL DNLobbyUnRegister()
  96. {
  97. BOOL fReturn = TRUE;
  98. if( !CRegistry::UnRegister(&CLSID_DirectPlay8LobbyClient) )
  99. {
  100. DPFX(DPFPREP, 0, "Failed to unregister client object" );
  101. fReturn = FALSE;
  102. }
  103. if( !CRegistry::UnRegister(&CLSID_DirectPlay8LobbiedApplication) )
  104. {
  105. DPFX(DPFPREP, 0, "Failed to unregister app object" );
  106. fReturn = FALSE;
  107. }
  108. CRegistry creg;
  109. if( !creg.Open( HKEY_LOCAL_MACHINE, DPL_REG_LOCAL_APPL_ROOT, FALSE, TRUE ) )
  110. {
  111. DPFERR( "Cannot remove app, does not exist" );
  112. }
  113. else
  114. {
  115. if( !creg.DeleteSubKey( &(DPL_REG_LOCAL_APPL_SUB)[1] ) )
  116. {
  117. DPFERR( "Cannot remove cp sub-key, could have elements" );
  118. }
  119. }
  120. return fReturn;
  121. }
  122. #endif // !DPNBUILD_NOCOMREGISTER
  123. #ifndef DPNBUILD_LIBINTERFACE
  124. #undef DPF_MODNAME
  125. #define DPF_MODNAME "DNLobbyGetRemainingObjectCount"
  126. DWORD DNLobbyGetRemainingObjectCount()
  127. {
  128. return g_lLobbyObjectCount;
  129. }
  130. #endif // ! DPNBUILD_LIBINTERFACE