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.

365 lines
8.5 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PostCreateServices.h
  7. //
  8. // Description:
  9. // PostCreateServices implementation.
  10. //
  11. // Maintained By:
  12. // David Potter (DavidP) 14-JUN-2001
  13. // Geoffrey Pease (GPease) 15-JUN-2000
  14. //
  15. //////////////////////////////////////////////////////////////////////////////
  16. #include "Pch.h"
  17. #include "GroupHandle.h"
  18. #include "ResourceEntry.h"
  19. #include "IPrivatePostCfgResource.h"
  20. #include "PostCreateServices.h"
  21. DEFINE_THISCLASS("CPostCreateServices")
  22. // ************************************************************************
  23. //
  24. // Constructor / Destructor
  25. //
  26. // ************************************************************************
  27. //////////////////////////////////////////////////////////////////////////////
  28. //
  29. // HRESULT
  30. // CPostCreateServices::S_HrCreateInstance(
  31. // IUnknown ** ppunkOut
  32. // )
  33. //
  34. //////////////////////////////////////////////////////////////////////////////
  35. HRESULT
  36. CPostCreateServices::S_HrCreateInstance(
  37. IUnknown ** ppunkOut
  38. )
  39. {
  40. TraceFunc( "" );
  41. HRESULT hr = S_OK;
  42. CPostCreateServices * ppcs = NULL;
  43. Assert( ppunkOut != NULL );
  44. if ( ppunkOut == NULL )
  45. {
  46. hr = THR( E_POINTER );
  47. goto Cleanup;
  48. }
  49. ppcs = new CPostCreateServices;
  50. if ( ppcs == NULL )
  51. {
  52. hr = THR( E_OUTOFMEMORY );
  53. goto Cleanup;
  54. }
  55. hr = THR( ppcs->HrInit() );
  56. if ( FAILED( hr ) )
  57. {
  58. goto Cleanup;
  59. }
  60. hr = THR( ppcs->TypeSafeQI( IUnknown, ppunkOut ) );
  61. if ( FAILED( hr ) )
  62. {
  63. goto Cleanup;
  64. }
  65. Cleanup:
  66. if ( ppcs != NULL )
  67. {
  68. ppcs->Release();
  69. }
  70. HRETURN( hr );
  71. } //*** CPostCreateServices::S_HrCreateInstance
  72. //////////////////////////////////////////////////////////////////////////////
  73. //
  74. // CPostCreateServices::CPostCreateServices
  75. //
  76. //////////////////////////////////////////////////////////////////////////////
  77. CPostCreateServices::CPostCreateServices( void )
  78. : m_cRef( 1 )
  79. {
  80. TraceFunc( "" );
  81. InterlockedIncrement( &g_cObjects );
  82. TraceFuncExit();
  83. } //*** CPostCreateServices::CPostCreateServices
  84. //////////////////////////////////////////////////////////////////////////////
  85. //
  86. // HRESULT
  87. // CPostCreateServices::HrInit
  88. //
  89. //////////////////////////////////////////////////////////////////////////////
  90. HRESULT
  91. CPostCreateServices::HrInit( void )
  92. {
  93. TraceFunc( "" );
  94. HRESULT hr = S_OK;
  95. // IUnknown stuff
  96. Assert( m_cRef == 1 );
  97. // Resource
  98. Assert( m_presentry == NULL );
  99. HRETURN( hr );
  100. } //*** CPostCreateServices::HrInit
  101. //////////////////////////////////////////////////////////////////////////////
  102. //
  103. // CPostCreateServices::~CPostCreateServices
  104. //
  105. //////////////////////////////////////////////////////////////////////////////
  106. CPostCreateServices::~CPostCreateServices( void )
  107. {
  108. TraceFunc( "" );
  109. InterlockedDecrement( &g_cObjects );
  110. TraceFuncExit();
  111. } //*** CPostCreateServices::~CPostCreateServices
  112. // ************************************************************************
  113. //
  114. // IUnknown
  115. //
  116. // ************************************************************************
  117. //////////////////////////////////////////////////////////////////////////////
  118. //++
  119. //
  120. // CPostCreateServices::QueryInterface
  121. //
  122. // Description:
  123. // Query this object for the passed in interface.
  124. //
  125. // Arguments:
  126. // riidIn
  127. // Id of interface requested.
  128. //
  129. // ppvOut
  130. // Pointer to the requested interface.
  131. //
  132. // Return Value:
  133. // S_OK
  134. // If the interface is available on this object.
  135. //
  136. // E_NOINTERFACE
  137. // If the interface is not available.
  138. //
  139. // E_POINTER
  140. // ppvOut was NULL.
  141. //
  142. // Remarks:
  143. // None.
  144. //
  145. //--
  146. //////////////////////////////////////////////////////////////////////////////
  147. STDMETHODIMP
  148. CPostCreateServices::QueryInterface(
  149. REFIID riidIn
  150. , LPVOID * ppvOut
  151. )
  152. {
  153. TraceQIFunc( riidIn, ppvOut );
  154. HRESULT hr = S_OK;
  155. //
  156. // Validate arguments.
  157. //
  158. Assert( ppvOut != NULL );
  159. if ( ppvOut == NULL )
  160. {
  161. hr = THR( E_POINTER );
  162. goto Cleanup;
  163. }
  164. //
  165. // Handle known interfaces.
  166. //
  167. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  168. {
  169. *ppvOut = static_cast< IClusCfgResourcePostCreate * >( this );
  170. } // if: IUnknown
  171. else if ( IsEqualIID( riidIn, IID_IClusCfgResourcePostCreate ) )
  172. {
  173. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgResourcePostCreate, this, 0 );
  174. } // else if: IClusCfgResourcePostCreate
  175. else if ( IsEqualIID( riidIn, IID_IPrivatePostCfgResource ) )
  176. {
  177. *ppvOut = TraceInterface( __THISCLASS__, IPrivatePostCfgResource, this, 0 );
  178. } // else if: IPrivatePostCfgResource
  179. else
  180. {
  181. *ppvOut = NULL;
  182. hr = E_NOINTERFACE;
  183. }
  184. //
  185. // Add a reference to the interface if successful.
  186. //
  187. if ( SUCCEEDED( hr ) )
  188. {
  189. ((IUnknown *) *ppvOut)->AddRef();
  190. } // if: success
  191. Cleanup:
  192. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  193. } //*** CPostCreateServices::QueryInterface
  194. //////////////////////////////////////////////////////////////////////////////
  195. //
  196. // STDMETHODIMP_(ULONG)
  197. // CPostCreateServices::AddRef
  198. //
  199. //////////////////////////////////////////////////////////////////////////////
  200. STDMETHODIMP_( ULONG )
  201. CPostCreateServices::AddRef( void )
  202. {
  203. TraceFunc( "[IUnknown]" );
  204. InterlockedIncrement( &m_cRef );
  205. CRETURN( m_cRef );
  206. } //*** CPostCreateServices::AddRef
  207. //////////////////////////////////////////////////////////////////////////////
  208. //
  209. // STDMETHODIMP_(ULONG)
  210. // CPostCreateServices::Release
  211. //
  212. //////////////////////////////////////////////////////////////////////////////
  213. STDMETHODIMP_( ULONG )
  214. CPostCreateServices::Release( void )
  215. {
  216. TraceFunc( "[IUnknown]" );
  217. LONG cRef;
  218. cRef = InterlockedDecrement( &m_cRef );
  219. if ( cRef == 0 )
  220. {
  221. TraceDo( delete this );
  222. }
  223. CRETURN( cRef );
  224. } //*** CPostCreateServices::Release
  225. //****************************************************************************
  226. //
  227. // IClusCfgResourcePostCreate
  228. //
  229. //****************************************************************************
  230. //////////////////////////////////////////////////////////////////////////////
  231. //
  232. // STDMETHODIMP
  233. // CPostCreateServices::ChangeName(
  234. // LPCWSTR pcszNameIn
  235. // )
  236. //
  237. //////////////////////////////////////////////////////////////////////////////
  238. STDMETHODIMP
  239. CPostCreateServices::ChangeName(
  240. LPCWSTR pcszNameIn
  241. )
  242. {
  243. TraceFunc1( "[IClusCfgResourcePostCreate] pcszNameIn = '%s'", pcszNameIn );
  244. HRESULT hr = E_NOTIMPL;
  245. HRETURN( hr );
  246. } //*** CPostCreateServices::ChangeName
  247. //////////////////////////////////////////////////////////////////////////////
  248. //
  249. // STDMETHODIMP
  250. // CPostCreateServices::SendResourceControl(
  251. // DWORD dwControlCode,
  252. // LPVOID lpInBuffer,
  253. // DWORD cbInBufferSize,
  254. // LPVOID lpOutBuffer,
  255. // DWORD cbOutBufferSize,
  256. // LPDWORD lpcbBytesReturned
  257. // )
  258. //
  259. //////////////////////////////////////////////////////////////////////////////
  260. STDMETHODIMP
  261. CPostCreateServices::SendResourceControl(
  262. DWORD dwControlCode,
  263. LPVOID lpInBuffer,
  264. DWORD cbInBufferSize,
  265. LPVOID lpOutBuffer,
  266. DWORD cbOutBufferSize,
  267. LPDWORD lpcbBytesReturned
  268. )
  269. {
  270. TraceFunc( "[IClusCfgResourcePostCreate]" );
  271. HRESULT hr = THR( E_NOTIMPL );
  272. HRETURN( hr );
  273. } //*** CPostCreateServices::SendResourceControl
  274. //****************************************************************************
  275. //
  276. // IPrivatePostCfgResource
  277. //
  278. //****************************************************************************
  279. //////////////////////////////////////////////////////////////////////////////
  280. //
  281. // STDMETHODIMP
  282. // CPostCreateServices::SetEntry(
  283. // CResourceEntry * presentryIn
  284. // )
  285. //
  286. //////////////////////////////////////////////////////////////////////////////
  287. STDMETHODIMP
  288. CPostCreateServices::SetEntry(
  289. CResourceEntry * presentryIn
  290. )
  291. {
  292. TraceFunc( "[IPrivatePostCfgResource]" );
  293. HRESULT hr = S_OK;
  294. m_presentry = presentryIn;
  295. HRETURN( hr );
  296. } //*** CPostCreateServices::SetEntry