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.

634 lines
15 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. cimplogn.cxx
  5. Abstract:
  6. The core implementation for the ISensLogon interface.
  7. Author:
  8. Gopal Parupudi <GopalP>
  9. [Notes:]
  10. optional-notes
  11. Revision History:
  12. GopalP 11/17/1997 Start.
  13. --*/
  14. #include <common.hxx>
  15. #include <ole2.h>
  16. #include <oleauto.h>
  17. #include <tchar.h>
  18. #include "sinkcomn.hxx"
  19. #include "cimplogn.hxx"
  20. #include "sensevts.h"
  21. extern ITypeInfo *gpITypeInfoLogon;
  22. extern ITypeInfo *gpITypeInfoLogon2;
  23. //
  24. // Constructors and Destructors
  25. //
  26. CImpISensLogon::CImpISensLogon(
  27. void
  28. ) : m_cRef(0L), m_pfnDestroy(NULL)
  29. {
  30. }
  31. CImpISensLogon::CImpISensLogon(
  32. LPFNDESTROYED pfnDestroy
  33. ) : m_cRef(0L), m_pfnDestroy(pfnDestroy)
  34. {
  35. }
  36. CImpISensLogon::~CImpISensLogon(
  37. void
  38. )
  39. {
  40. // Empty destructor
  41. }
  42. //
  43. // Standard QueryInterface
  44. //
  45. STDMETHODIMP
  46. CImpISensLogon::QueryInterface(
  47. REFIID riid,
  48. LPVOID *ppv
  49. )
  50. {
  51. DebugTraceGuid("CImpISensLogon::QueryInterface()", riid);
  52. HRESULT hr = S_OK;
  53. *ppv = NULL; // To handle failure cases
  54. // IUnknown
  55. if (IsEqualIID(riid, IID_IUnknown))
  56. {
  57. *ppv = (LPUNKNOWN) this;
  58. }
  59. else
  60. // IDispatch
  61. if (IsEqualIID(riid, IID_IDispatch))
  62. {
  63. *ppv = (IDispatch *) this;
  64. }
  65. else
  66. // ISensLogon
  67. if (IsEqualIID(riid, IID_ISensLogon))
  68. {
  69. *ppv = (ISensLogon *) this;
  70. }
  71. else
  72. {
  73. hr = E_NOINTERFACE;
  74. }
  75. if (NULL != *ppv)
  76. {
  77. ((LPUNKNOWN)*ppv)->AddRef();
  78. }
  79. return hr;
  80. }
  81. //
  82. // Standard AddRef and Release
  83. //
  84. STDMETHODIMP_(ULONG)
  85. CImpISensLogon::AddRef(
  86. void
  87. )
  88. {
  89. return InterlockedIncrement((PLONG) &m_cRef);
  90. }
  91. STDMETHODIMP_(ULONG)
  92. CImpISensLogon::Release(
  93. void
  94. )
  95. {
  96. ULONG cRefT;
  97. cRefT = InterlockedDecrement((PLONG) &m_cRef);
  98. if (0 == m_cRef)
  99. {
  100. // Invoke the callback function.
  101. if (NULL != m_pfnDestroy)
  102. {
  103. (*m_pfnDestroy)();
  104. }
  105. delete this;
  106. }
  107. return cRefT;
  108. }
  109. //
  110. // IDispatch member function implementations.
  111. //
  112. STDMETHODIMP
  113. CImpISensLogon::GetTypeInfoCount(
  114. UINT *pCountITypeInfo
  115. )
  116. {
  117. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon::GetTypeInfoCount() called.\n")));
  118. // We implement GetTypeInfo, so return 1.
  119. *pCountITypeInfo = 1;
  120. return NOERROR;
  121. }
  122. STDMETHODIMP
  123. CImpISensLogon::GetTypeInfo(
  124. UINT iTypeInfo,
  125. LCID lcid,
  126. ITypeInfo **ppITypeInfo
  127. )
  128. {
  129. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon::GetTypeInfo() called.\n")));
  130. *ppITypeInfo = NULL;
  131. if (iTypeInfo != 0)
  132. {
  133. return DISP_E_BADINDEX;
  134. }
  135. // Call AddRef and return the pointer.
  136. gpITypeInfoLogon->AddRef();
  137. *ppITypeInfo = gpITypeInfoLogon;
  138. return S_OK;
  139. }
  140. STDMETHODIMP
  141. CImpISensLogon::GetIDsOfNames(
  142. REFIID riid,
  143. LPOLESTR *arrNames,
  144. UINT cNames,
  145. LCID lcid,
  146. DISPID *arrDispIDs)
  147. {
  148. HRESULT hr;
  149. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon::GetIDsOfNames() called.\n")));
  150. if (riid != IID_NULL)
  151. {
  152. return DISP_E_UNKNOWNINTERFACE;
  153. }
  154. hr = gpITypeInfoLogon->GetIDsOfNames(
  155. arrNames,
  156. cNames,
  157. arrDispIDs
  158. );
  159. return hr;
  160. }
  161. STDMETHODIMP
  162. CImpISensLogon::Invoke(
  163. DISPID dispID,
  164. REFIID riid,
  165. LCID lcid,
  166. WORD wFlags,
  167. DISPPARAMS *pDispParams,
  168. VARIANT *pvarResult,
  169. EXCEPINFO *pExecpInfo,
  170. UINT *puArgErr
  171. )
  172. {
  173. HRESULT hr;
  174. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon::Invoke() called.\n")));
  175. if (riid != IID_NULL)
  176. {
  177. return DISP_E_UNKNOWNINTERFACE;
  178. }
  179. hr = gpITypeInfoLogon->Invoke(
  180. (IDispatch*) this,
  181. dispID,
  182. wFlags,
  183. pDispParams,
  184. pvarResult,
  185. pExecpInfo,
  186. puArgErr
  187. );
  188. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon::Invoke() returned 0x%x\n"), hr));
  189. return hr;
  190. }
  191. STDMETHODIMP
  192. CImpISensLogon::Logon(
  193. BSTR bstrUserName
  194. )
  195. {
  196. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  197. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::Logon() called\n\n")));
  198. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  199. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  200. return S_OK;
  201. }
  202. STDMETHODIMP
  203. CImpISensLogon::Logoff(
  204. BSTR bstrUserName
  205. )
  206. {
  207. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  208. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::Logoff() called\n\n")));
  209. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  210. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  211. return S_OK;
  212. }
  213. STDMETHODIMP
  214. CImpISensLogon::StartShell(
  215. BSTR bstrUserName
  216. )
  217. {
  218. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  219. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::StartShell() called\n\n")));
  220. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  221. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  222. return S_OK;
  223. }
  224. STDMETHODIMP
  225. CImpISensLogon::DisplayLock(
  226. BSTR bstrUserName
  227. )
  228. {
  229. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  230. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::DisplayLock() called\n\n")));
  231. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  232. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  233. return S_OK;
  234. }
  235. STDMETHODIMP
  236. CImpISensLogon::DisplayUnlock(
  237. BSTR bstrUserName
  238. )
  239. {
  240. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  241. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::DisplayUnlock() called\n\n")));
  242. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  243. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  244. return S_OK;
  245. }
  246. STDMETHODIMP
  247. CImpISensLogon::StartScreenSaver(
  248. BSTR bstrUserName
  249. )
  250. {
  251. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  252. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::StartScreenSaver() called\n\n")));
  253. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  254. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  255. return S_OK;
  256. }
  257. STDMETHODIMP
  258. CImpISensLogon::StopScreenSaver(
  259. BSTR bstrUserName
  260. )
  261. {
  262. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  263. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon::StopScreenSaver() called\n\n")));
  264. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  265. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  266. return S_OK;
  267. }
  268. //
  269. // ISensLogon2 Implementation
  270. //
  271. //
  272. // Constructors and Destructors
  273. //
  274. CImpISensLogon2::CImpISensLogon2(
  275. void
  276. ) : m_cRef(0L), m_pfnDestroy(NULL)
  277. {
  278. }
  279. CImpISensLogon2::CImpISensLogon2(
  280. LPFNDESTROYED pfnDestroy
  281. ) : m_cRef(0L), m_pfnDestroy(pfnDestroy)
  282. {
  283. }
  284. CImpISensLogon2::~CImpISensLogon2(
  285. void
  286. )
  287. {
  288. // Empty destructor
  289. }
  290. //
  291. // Standard QueryInterface
  292. //
  293. STDMETHODIMP
  294. CImpISensLogon2::QueryInterface(
  295. REFIID riid,
  296. LPVOID *ppv
  297. )
  298. {
  299. DebugTraceGuid("CImpISensLogon2::QueryInterface()", riid);
  300. HRESULT hr = S_OK;
  301. *ppv = NULL; // To handle failure cases
  302. // IUnknown
  303. if (IsEqualIID(riid, IID_IUnknown))
  304. {
  305. *ppv = (LPUNKNOWN) this;
  306. }
  307. else
  308. // IDispatch
  309. if (IsEqualIID(riid, IID_IDispatch))
  310. {
  311. *ppv = (IDispatch *) this;
  312. }
  313. else
  314. // ISensLogon
  315. if (IsEqualIID(riid, IID_ISensLogon2))
  316. {
  317. *ppv = (ISensLogon2 *) this;
  318. }
  319. else
  320. {
  321. hr = E_NOINTERFACE;
  322. }
  323. if (NULL != *ppv)
  324. {
  325. ((LPUNKNOWN)*ppv)->AddRef();
  326. }
  327. return hr;
  328. }
  329. //
  330. // Standard AddRef and Release
  331. //
  332. STDMETHODIMP_(ULONG)
  333. CImpISensLogon2::AddRef(
  334. void
  335. )
  336. {
  337. return InterlockedIncrement((PLONG) &m_cRef);
  338. }
  339. STDMETHODIMP_(ULONG)
  340. CImpISensLogon2::Release(
  341. void
  342. )
  343. {
  344. ULONG cRefT;
  345. cRefT = InterlockedDecrement((PLONG) &m_cRef);
  346. if (0 == m_cRef)
  347. {
  348. // Invoke the callback function.
  349. if (NULL != m_pfnDestroy)
  350. {
  351. (*m_pfnDestroy)();
  352. }
  353. delete this;
  354. }
  355. return cRefT;
  356. }
  357. //
  358. // IDispatch member function implementations.
  359. //
  360. STDMETHODIMP
  361. CImpISensLogon2::GetTypeInfoCount(
  362. UINT *pCountITypeInfo
  363. )
  364. {
  365. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon2::GetTypeInfoCount() called.\n")));
  366. // We implement GetTypeInfo, so return 1.
  367. *pCountITypeInfo = 1;
  368. return NOERROR;
  369. }
  370. STDMETHODIMP
  371. CImpISensLogon2::GetTypeInfo(
  372. UINT iTypeInfo,
  373. LCID lcid,
  374. ITypeInfo **ppITypeInfo
  375. )
  376. {
  377. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon2::GetTypeInfo() called.\n")));
  378. *ppITypeInfo = NULL;
  379. if (iTypeInfo != 0)
  380. {
  381. return DISP_E_BADINDEX;
  382. }
  383. // Call AddRef and return the pointer.
  384. gpITypeInfoLogon2->AddRef();
  385. *ppITypeInfo = gpITypeInfoLogon2;
  386. return S_OK;
  387. }
  388. STDMETHODIMP
  389. CImpISensLogon2::GetIDsOfNames(
  390. REFIID riid,
  391. LPOLESTR *arrNames,
  392. UINT cNames,
  393. LCID lcid,
  394. DISPID *arrDispIDs)
  395. {
  396. HRESULT hr;
  397. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon2::GetIDsOfNames() called.\n")));
  398. if (riid != IID_NULL)
  399. {
  400. return DISP_E_UNKNOWNINTERFACE;
  401. }
  402. hr = gpITypeInfoLogon2->GetIDsOfNames(
  403. arrNames,
  404. cNames,
  405. arrDispIDs
  406. );
  407. return hr;
  408. }
  409. STDMETHODIMP
  410. CImpISensLogon2::Invoke(
  411. DISPID dispID,
  412. REFIID riid,
  413. LCID lcid,
  414. WORD wFlags,
  415. DISPPARAMS *pDispParams,
  416. VARIANT *pvarResult,
  417. EXCEPINFO *pExecpInfo,
  418. UINT *puArgErr
  419. )
  420. {
  421. HRESULT hr;
  422. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon2::Invoke() called.\n")));
  423. if (riid != IID_NULL)
  424. {
  425. return DISP_E_UNKNOWNINTERFACE;
  426. }
  427. hr = gpITypeInfoLogon2->Invoke(
  428. (IDispatch*) this,
  429. dispID,
  430. wFlags,
  431. pDispParams,
  432. pvarResult,
  433. pExecpInfo,
  434. puArgErr
  435. );
  436. SensPrint(SENS_INFO, (SENS_STRING("\t| CImpISensLogon2::Invoke() returned 0x%x\n"), hr));
  437. return hr;
  438. }
  439. STDMETHODIMP
  440. CImpISensLogon2::Logon(
  441. BSTR bstrUserName,
  442. DWORD dwSessionId
  443. )
  444. {
  445. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  446. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon2::Logon() called\n\n")));
  447. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  448. SensPrint(SENS_INFO, (SENS_STRING(" dwSessionId - %d\n"), dwSessionId));
  449. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  450. return S_OK;
  451. }
  452. STDMETHODIMP
  453. CImpISensLogon2::Logoff(
  454. BSTR bstrUserName,
  455. DWORD dwSessionId
  456. )
  457. {
  458. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  459. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon2::Logoff() called\n\n")));
  460. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  461. SensPrint(SENS_INFO, (SENS_STRING(" dwSessionId - %d\n"), dwSessionId));
  462. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  463. return S_OK;
  464. }
  465. STDMETHODIMP
  466. CImpISensLogon2::PostShell(
  467. BSTR bstrUserName,
  468. DWORD dwSessionId
  469. )
  470. {
  471. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  472. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon2::PostShell() called\n\n")));
  473. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  474. SensPrint(SENS_INFO, (SENS_STRING(" dwSessionId - %d\n"), dwSessionId));
  475. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  476. return S_OK;
  477. }
  478. STDMETHODIMP
  479. CImpISensLogon2::SessionDisconnect(
  480. BSTR bstrUserName,
  481. DWORD dwSessionId
  482. )
  483. {
  484. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  485. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon2::SessionDisconnect() called\n\n")));
  486. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  487. SensPrint(SENS_INFO, (SENS_STRING(" dwSessionId - %d\n"), dwSessionId));
  488. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  489. return S_OK;
  490. }
  491. STDMETHODIMP
  492. CImpISensLogon2::SessionReconnect(
  493. BSTR bstrUserName,
  494. DWORD dwSessionId
  495. )
  496. {
  497. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  498. SensPrint(SENS_INFO, (SENS_STRING("CImpISensLogon2::SessionReconnect() called\n\n")));
  499. SensPrintW(SENS_INFO, (SENS_BSTR(" bstrUserName - %s\n"), bstrUserName));
  500. SensPrint(SENS_INFO, (SENS_STRING(" dwSessionId - %d\n"), dwSessionId));
  501. SensPrint(SENS_INFO, (SENS_STRING("---------------------------------------------------------\n")));
  502. return S_OK;
  503. }