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.

347 lines
7.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: crpc.cxx
  7. //
  8. // Contents: implementations for rpc test
  9. //
  10. // Functions:
  11. // CRpcTest::CRpcTest
  12. // CRpcTest::~CRpcTest
  13. // CRpcTest::QueryInterface
  14. //
  15. // History: 06-Aug-92 Ricksa Created
  16. //
  17. //--------------------------------------------------------------------------
  18. #include <pch.cxx>
  19. #pragma hdrstop
  20. #include <crpc.hxx> // class definition
  21. IUnknown *gpPunk = NULL;
  22. //+-------------------------------------------------------------------------
  23. //
  24. // Method: CRpcTest::CRpcTest
  25. //
  26. // Synopsis: Creates the application window
  27. //
  28. // Arguments: [pisb] - ISysBind instance
  29. //
  30. // History: 06-Aug-92 Ricksa Created
  31. //
  32. //--------------------------------------------------------------------------
  33. CRpcTest::CRpcTest(void) : _punkIn(NULL)
  34. {
  35. GlobalRefs(TRUE);
  36. ENLIST_TRACKING(CRpcTest);
  37. }
  38. //+-------------------------------------------------------------------------
  39. //
  40. // Method: CRpcTest::~CRpcTest
  41. //
  42. // Synopsis: Cleans up object
  43. //
  44. // History: 06-Aug-92 Ricksa Created
  45. //
  46. //--------------------------------------------------------------------------
  47. CRpcTest::~CRpcTest(void)
  48. {
  49. GlobalRefs(FALSE);
  50. }
  51. //+-------------------------------------------------------------------------
  52. //
  53. // Method: CRpcTest::QueryInterface
  54. //
  55. // Synopsis: Gets called when a WM_COMMAND message received.
  56. //
  57. // Arguments: [ifid] - interface instance requested
  58. // [ppunk] - where to put pointer to interface instance
  59. //
  60. // Returns: S_OK or ERROR_BAD_COMMAND
  61. //
  62. // History: 06-Aug-92 Ricksa Created
  63. //
  64. //--------------------------------------------------------------------------
  65. STDMETHODIMP CRpcTest::QueryInterface(REFIID riid, void **ppunk)
  66. {
  67. SCODE sc = S_OK;
  68. if (IsEqualIID(riid,IID_IUnknown) ||
  69. IsEqualIID(riid,IID_IRpcTest))
  70. {
  71. // Increase the reference count
  72. *ppunk = (void *)(IRpcTest *) this;
  73. AddRef();
  74. }
  75. else
  76. {
  77. *ppunk = NULL;
  78. sc = E_NOINTERFACE;
  79. }
  80. return sc;
  81. }
  82. //+-------------------------------------------------------------------------
  83. //
  84. // Method: CRpcTest::Void
  85. //
  86. // Synopsis: tests passing no parameters
  87. //
  88. // Arguments:
  89. //
  90. // Returns: S_OK or ERROR_BAD_COMMAND
  91. //
  92. // History: 06-Aug-92 Ricksa Created
  93. //
  94. //--------------------------------------------------------------------------
  95. STDMETHODIMP CRpcTest::Void(void)
  96. {
  97. return S_OK;
  98. }
  99. STDMETHODIMP CRpcTest::VoidRC(void)
  100. {
  101. return S_OK;
  102. }
  103. STDMETHODIMP CRpcTest::VoidPtrIn(ULONG cb, BYTE *pv)
  104. {
  105. return S_OK;
  106. }
  107. STDMETHODIMP CRpcTest::VoidPtrOut(ULONG cb, ULONG *pcb, BYTE *pv)
  108. {
  109. memset(pv, 1, cb);
  110. *pcb = cb;
  111. return S_OK;
  112. }
  113. //+-------------------------------------------------------------------------
  114. //
  115. // Function: CRpcTest::Dword
  116. //
  117. // Synopsis: tests passing dwords in and out
  118. //
  119. // Arguments:
  120. //
  121. // Returns: S_OK
  122. //
  123. // History: 06-Aug-92 Ricksa Created
  124. //
  125. //--------------------------------------------------------------------------
  126. STDMETHODIMP CRpcTest::DwordIn(DWORD dw)
  127. {
  128. return S_OK;
  129. }
  130. STDMETHODIMP CRpcTest::DwordOut(DWORD *pdw)
  131. {
  132. *pdw = 1;
  133. return S_OK;
  134. }
  135. STDMETHODIMP CRpcTest::DwordInOut(DWORD *pdw)
  136. {
  137. *pdw = 1;
  138. return S_OK;
  139. }
  140. //+-------------------------------------------------------------------------
  141. //
  142. // Function: CRpcTest::Li
  143. //
  144. // Synopsis: tests passing LARGE INTEGERS in and out
  145. //
  146. // Arguments:
  147. //
  148. // Returns: S_OK
  149. //
  150. // History: 06-Aug-92 Ricksa Created
  151. //
  152. //--------------------------------------------------------------------------
  153. STDMETHODIMP CRpcTest::LiIn(LARGE_INTEGER li)
  154. {
  155. return S_OK;
  156. }
  157. STDMETHODIMP CRpcTest::LiOut(LARGE_INTEGER *pli)
  158. {
  159. pli->LowPart = 0;
  160. pli->HighPart = 1;
  161. return S_OK;
  162. }
  163. STDMETHODIMP CRpcTest::ULiIn(ULARGE_INTEGER uli)
  164. {
  165. return S_OK;
  166. }
  167. STDMETHODIMP CRpcTest::ULiOut(ULARGE_INTEGER *puli)
  168. {
  169. puli->LowPart = 0;
  170. puli->HighPart = 1;
  171. return S_OK;
  172. }
  173. //+-------------------------------------------------------------------------
  174. //
  175. // Function: CRpcTest::String
  176. //
  177. // Synopsis: tests passing strings in and out
  178. //
  179. // Arguments:
  180. //
  181. // Returns: S_OK
  182. //
  183. // History: 06-Aug-92 Ricksa Created
  184. //
  185. //--------------------------------------------------------------------------
  186. STDMETHODIMP CRpcTest::StringIn(LPOLESTR pwsz)
  187. {
  188. return S_OK;
  189. }
  190. STDMETHODIMP CRpcTest::StringOut(LPOLESTR *ppwsz)
  191. {
  192. // LPOLESTR pwsz = new OLECHAR[80];
  193. // *ppwsz = pwsz;
  194. olestrcpy(*ppwsz, OLESTR("Hello World This is a Message"));
  195. return S_OK;
  196. }
  197. STDMETHODIMP CRpcTest::StringInOut(LPOLESTR pwsz)
  198. {
  199. olestrcpy(pwsz, OLESTR("Hello World This is a Message"));
  200. return S_OK;
  201. }
  202. //+-------------------------------------------------------------------------
  203. //
  204. // Function: CRpcTest::Guid
  205. //
  206. // Synopsis: tests passing GUIDs in and out
  207. //
  208. // Arguments:
  209. //
  210. // Returns: S_OK
  211. //
  212. // History: 06-Aug-92 Ricksa Created
  213. //
  214. //--------------------------------------------------------------------------
  215. STDMETHODIMP CRpcTest::GuidIn(GUID guid)
  216. {
  217. return S_OK;
  218. }
  219. STDMETHODIMP CRpcTest::GuidOut(GUID *piid)
  220. {
  221. memcpy(piid, &IID_IRpcTest, sizeof(GUID));
  222. return S_OK;
  223. }
  224. //+-------------------------------------------------------------------------
  225. //
  226. // Function: CRpcTest::IUnknown
  227. //
  228. // Synopsis: tests passing IUnknown interfaces in and out
  229. //
  230. // Arguments:
  231. //
  232. // Returns: S_OK
  233. //
  234. // History: 06-Aug-92 Ricksa Created
  235. //
  236. //--------------------------------------------------------------------------
  237. STDMETHODIMP CRpcTest::IUnknownIn(IUnknown *punkIn)
  238. {
  239. return S_OK;
  240. }
  241. STDMETHODIMP CRpcTest::IUnknownOut(IUnknown **ppunk)
  242. {
  243. gpPunk->AddRef();
  244. *ppunk = gpPunk;
  245. return S_OK;
  246. }
  247. STDMETHODIMP CRpcTest::IUnknownInKeep(IUnknown *punkIn)
  248. {
  249. if (punkIn)
  250. {
  251. punkIn->AddRef();
  252. if (punkIn != _punkIn)
  253. {
  254. _punkIn->Release();
  255. _punkIn = punkIn;
  256. }
  257. }
  258. return S_OK;
  259. }
  260. STDMETHODIMP CRpcTest::IUnknownInRelease()
  261. {
  262. if (_punkIn)
  263. {
  264. _punkIn->Release();
  265. }
  266. return S_OK;
  267. }
  268. STDMETHODIMP CRpcTest::IUnknownOutKeep(IUnknown **ppunk)
  269. {
  270. *ppunk = (IUnknown *)this;
  271. AddRef();
  272. return S_OK;
  273. }
  274. //+-------------------------------------------------------------------------
  275. //
  276. // Function: CRpcTest::Interface
  277. //
  278. // Synopsis: tests passing whose iid is specified by riid in and out
  279. //
  280. // Arguments:
  281. //
  282. // Returns: S_OK
  283. //
  284. // History: 06-Aug-92 Ricksa Created
  285. //
  286. //--------------------------------------------------------------------------
  287. STDMETHODIMP CRpcTest::InterfaceIn(REFIID riid, IUnknown *punk)
  288. {
  289. return S_OK;
  290. }
  291. STDMETHODIMP CRpcTest::InterfaceOut(REFIID riid, IUnknown **ppunk)
  292. {
  293. this->QueryInterface(riid, (void **)ppunk);
  294. return S_OK;
  295. }