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.

120 lines
3.2 KiB

  1. /*---------------------------------------------------------------------------
  2. File: AgentRpcUtil.cpp
  3. Comments: Functions to establish binding to DCT Agent service.
  4. These functions are used by the dispatcher, and the agent monitor
  5. to bind to the agent service on remote machines.
  6. (c) Copyright 1999, Mission Critical Software, Inc., All Rights Reserved
  7. Proprietary and confidential to Mission Critical Software, Inc.
  8. REVISION LOG ENTRY
  9. Revision By: Christy Boles
  10. Revised on 02/15/99 11:23:57
  11. ---------------------------------------------------------------------------
  12. */
  13. #ifdef USE_STDAFX
  14. # include "stdafx.h"
  15. # include "rpc.h"
  16. #else
  17. # include <windows.h>
  18. #endif
  19. // These global variables can be changed if required
  20. TCHAR const * gsEaDctProtoSeq = (TCHAR const *)TEXT("ncacn_np");
  21. TCHAR const * gsEaDctEndPoint = (TCHAR const *)TEXT("\\pipe\\EaDctRpc");
  22. // Destroy RPC binding for connection with Agent service
  23. DWORD // ret-OS return code
  24. EaxBindDestroy(
  25. handle_t * phBinding ,// i/o-binding handle
  26. TCHAR ** psBinding // i/o-binding string
  27. )
  28. {
  29. if ( *phBinding )
  30. {
  31. RpcBindingFree( phBinding );
  32. *phBinding = NULL;
  33. }
  34. if ( *psBinding )
  35. {
  36. RpcStringFree( psBinding );
  37. *psBinding = NULL;
  38. }
  39. return 0;
  40. }
  41. // Create RPC binding for connection with Agent Service
  42. DWORD // ret-OS return code
  43. EaxBindCreate(
  44. TCHAR const * sComputer ,// in -computer name
  45. handle_t * phBinding ,// out-binding handle
  46. TCHAR ** psBinding ,// out-binding string
  47. BOOL bAuthn // in -flag whether to use authenticated RPC
  48. )
  49. {
  50. DWORD rcOs; // OS return code
  51. do // once or until break
  52. {
  53. EaxBindDestroy( phBinding, psBinding );
  54. rcOs = RpcStringBindingCompose(
  55. NULL,
  56. (TCHAR *) gsEaDctProtoSeq,
  57. (TCHAR *) sComputer,
  58. (TCHAR *) gsEaDctEndPoint,
  59. NULL,
  60. psBinding );
  61. if ( rcOs ) break;
  62. rcOs = RpcBindingFromStringBinding( *psBinding, phBinding );
  63. if ( rcOs || !bAuthn ) break;
  64. rcOs = RpcBindingSetAuthInfo(
  65. *phBinding,
  66. 0,
  67. RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
  68. RPC_C_AUTHN_WINNT,
  69. 0,
  70. 0 );
  71. } while ( FALSE );
  72. if ( rcOs )
  73. {
  74. EaxBindDestroy( phBinding, psBinding );
  75. }
  76. return rcOs;
  77. }
  78. ///////////////////////////////////////////////////////////////////////////////
  79. // midl allocate memory
  80. ///////////////////////////////////////////////////////////////////////////////
  81. void __RPC_FAR * __RPC_USER
  82. midl_user_allocate(
  83. size_t len )
  84. {
  85. return new char[len];
  86. }
  87. ///////////////////////////////////////////////////////////////////////////////
  88. // midl free memory
  89. ///////////////////////////////////////////////////////////////////////////////
  90. void __RPC_USER
  91. midl_user_free(
  92. void __RPC_FAR * ptr )
  93. {
  94. delete [] ptr;
  95. return;
  96. }