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.

135 lines
3.9 KiB

  1. /*++
  2. Copyright (C) 2000 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. ldmain.cxx
  6. Abstract:
  7. This file contains the startup code for the
  8. surrogate rpc server used to load 64 bit dlls
  9. in 32 bit apps
  10. Author:
  11. Khaled Sedky (khaleds) 18 January 2000
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #ifndef __LDFUNCS_HPP__
  17. #include "ldfuncs.hpp"
  18. #endif
  19. #ifndef __LDMGR_HPP__
  20. #include "ldmgr.hpp"
  21. #endif
  22. #ifndef __LDINTERFACES_HPP__
  23. #include "ldintrfcs.hpp"
  24. #endif
  25. //
  26. // The global loader pointer used by Threads and RPC functions
  27. //
  28. TLoad64BitDllsMgr *pGLdrObj;
  29. //
  30. // Initialize Debug spewing
  31. //
  32. MODULE_DEBUG_INIT( DBG_ERROR | DBG_WARNING, DBG_ERROR );
  33. BOOL WINAPI
  34. LogOffHandler(
  35. DWORD CtrlType
  36. )
  37. {
  38. BOOL bAction;
  39. if((CtrlType == CTRL_LOGOFF_EVENT) ||
  40. (CtrlType == CTRL_SHUTDOWN_EVENT))
  41. {
  42. //
  43. // Proceed with the proper termination routine
  44. //
  45. bAction = TRUE;
  46. }
  47. else
  48. {
  49. bAction = FALSE;
  50. }
  51. return(bAction);
  52. }
  53. /*++
  54. Function Name:
  55. main
  56. Description:
  57. This function instantiates the main loader object.
  58. Parameters:
  59. None
  60. Return Value
  61. None
  62. --*/
  63. void __cdecl main()
  64. {
  65. HRESULT hRes = S_FALSE;
  66. DWORD RetVal = ERROR_SUCCESS;
  67. TLoad64BitDllsMgr *NewLdrObj = NULL;
  68. //
  69. // Adding our defined HandlerRoutine to deal with
  70. // LOGOFF requests. This is inactive at this time. If required
  71. // remove the comment below.
  72. //
  73. /* BOOL bCtrlHndlr = SetConsoleCtrlHandler(LogOffHandler,TRUE);*/
  74. if((NewLdrObj = new TLoad64BitDllsMgr(&hRes)) &&
  75. (hRes == S_OK))
  76. {
  77. pGLdrObj = NewLdrObj;
  78. TLPCMgr* LPCMgrObj = NULL;
  79. if((hRes = NewLdrObj->QueryInterface(IID_LPCMGR,
  80. reinterpret_cast<VOID **>(&LPCMgrObj))) == S_OK)
  81. {
  82. SPLASSERT(LPCMgrObj);
  83. LPCMgrObj->SetCurrSessionId(NewLdrObj->GetCurrSessionId());
  84. if((RetVal = LPCMgrObj->InitUMPDLPCServer()) != ERROR_SUCCESS)
  85. {
  86. DBGMSG(DBG_WARN, ("InitUMPDLPCServer failed with %u\n",RetVal));
  87. }
  88. else
  89. {
  90. if((RetVal = NewLdrObj->Run()) != ERROR_SUCCESS)
  91. {
  92. DBGMSG(DBG_WARN, ("Failed to run the RPC server with %u\n",RetVal));
  93. }
  94. LPCMgrObj->Release();
  95. NewLdrObj->Release();
  96. }
  97. }
  98. else
  99. {
  100. DBGMSG(DBG_WARN, ("main failed in Instantiating an TLPCMgr object %u\n",hRes));
  101. RetVal = NewLdrObj->GetLastErrorFromHRESULT(hRes);
  102. }
  103. }
  104. else
  105. {
  106. DBGMSG(DBG_WARN, ("SplWOW64 main() failed with %u\n",(hRes == S_OK) ? E_OUTOFMEMORY : hRes));
  107. }
  108. }