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.

393 lines
7.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: crpctyp.cxx
  7. //
  8. // Contents: implementations for rpc test
  9. //
  10. // Functions:
  11. // CRpcTypes::CRpcTypes
  12. // CRpcTypes::~CRpcTypes
  13. // CRpcTypes::QueryInterface
  14. //
  15. // History: 06-Aug-92 Ricksa Created
  16. //
  17. //--------------------------------------------------------------------------
  18. #include <pch.cxx>
  19. #pragma hdrstop
  20. #include <crpctyp.hxx> // class definition
  21. const GUID CLSID_RpcTypes =
  22. {0x00000132,0x0001,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  23. //+-------------------------------------------------------------------------
  24. //
  25. // Method: CRpcTypes::CRpcTypes
  26. //
  27. // Synopsis: Creates the application window
  28. //
  29. // Arguments: [pisb] - ISysBind instance
  30. //
  31. // History: 06-Aug-92 Ricksa Created
  32. //
  33. //--------------------------------------------------------------------------
  34. CRpcTypes::CRpcTypes(void)
  35. {
  36. GlobalRefs(TRUE);
  37. ENLIST_TRACKING(CRpcTypes);
  38. }
  39. //+-------------------------------------------------------------------------
  40. //
  41. // Method: CRpcTypes::~CRpcTypes
  42. //
  43. // Synopsis: Cleans up object
  44. //
  45. // History: 06-Aug-92 Ricksa Created
  46. //
  47. //--------------------------------------------------------------------------
  48. CRpcTypes::~CRpcTypes(void)
  49. {
  50. GlobalRefs(FALSE);
  51. }
  52. //+-------------------------------------------------------------------------
  53. //
  54. // Method: CRpcTypes::QueryInterface
  55. //
  56. // Synopsis: Gets called when a WM_COMMAND message received.
  57. //
  58. // Arguments: [ifid] - interface instance requested
  59. // [ppunk] - where to put pointer to interface instance
  60. //
  61. // Returns: S_OK or E_NOINTERFACE
  62. //
  63. // History: 06-Aug-92 Ricksa Created
  64. //
  65. //--------------------------------------------------------------------------
  66. STDMETHODIMP CRpcTypes::QueryInterface(REFIID riid, void **ppunk)
  67. {
  68. SCODE sc = S_OK;
  69. if (IsEqualIID(riid,IID_IUnknown) ||
  70. IsEqualIID(riid,IID_IRpcTypes))
  71. {
  72. // Increase the reference count
  73. *ppunk = (void *)(IRpcTypes *) this;
  74. AddRef();
  75. }
  76. else
  77. {
  78. *ppunk = NULL;
  79. sc = E_NOINTERFACE;
  80. }
  81. return sc;
  82. }
  83. //+-------------------------------------------------------------------------
  84. //
  85. // Method: CRpcTypes::GuidsIn
  86. //
  87. // Synopsis: tests passing GUID parameters
  88. //
  89. // Arguments:
  90. //
  91. // Returns: S_OK or error code with parm #s or'd in
  92. //
  93. // History: 06-Aug-92 Ricksa Created
  94. //
  95. //--------------------------------------------------------------------------
  96. STDMETHODIMP CRpcTypes::GuidsIn(
  97. REFCLSID rclsid,
  98. CLSID clsid,
  99. REFIID riid,
  100. IID iid,
  101. GUID guid)
  102. {
  103. SCODE sc = S_OK;
  104. // compare each parameter with the expected value
  105. if (!IsEqualCLSID(rclsid, CLSID_RpcTypes))
  106. sc |= 1;
  107. if (!IsEqualCLSID(clsid, CLSID_RpcTypes))
  108. sc |= 2;
  109. if (!IsEqualIID(riid, IID_IRpcTypes))
  110. sc |= 4;
  111. if (!IsEqualIID(iid, IID_IRpcTypes))
  112. sc |= 8;
  113. if (!IsEqualIID(guid, IID_IRpcTypes))
  114. sc |= 8;
  115. return sc;
  116. }
  117. STDMETHODIMP CRpcTypes::GuidsOut(
  118. CLSID *pclsid,
  119. IID *piid,
  120. GUID *pguid)
  121. {
  122. // copy in the expected return values
  123. memcpy(pclsid, &CLSID_RpcTypes, sizeof(CLSID));
  124. memcpy(piid, &IID_IRpcTypes, sizeof(IID));
  125. memcpy(pguid, &CLSID_RpcTypes, sizeof(GUID));
  126. return S_OK;
  127. }
  128. //+-------------------------------------------------------------------------
  129. //
  130. // Method: CRpcTypes::DwordIn
  131. //
  132. // Synopsis: tests passing dword and large integer parameters
  133. //
  134. // Arguments:
  135. //
  136. // Returns: S_OK or error code with parm #s or'd in
  137. //
  138. // History: 06-Aug-92 Ricksa Created
  139. //
  140. //--------------------------------------------------------------------------
  141. STDMETHODIMP CRpcTypes::DwordIn(
  142. DWORD dw,
  143. ULONG ul,
  144. LONG lg,
  145. LARGE_INTEGER li,
  146. ULARGE_INTEGER uli)
  147. {
  148. SCODE sc = S_OK;
  149. // compare each parameter with the expected value
  150. if (dw != 1)
  151. sc |= 1;
  152. if (ul != 2)
  153. sc |= 2;
  154. if (lg != 3)
  155. sc |= 4;
  156. if (li.LowPart != 4 ||
  157. li.HighPart != 5)
  158. sc |= 8;
  159. if (uli.LowPart != 6 ||
  160. uli.HighPart != 7)
  161. sc |= 16;
  162. return sc;
  163. }
  164. STDMETHODIMP CRpcTypes::DwordOut(
  165. DWORD *pdw,
  166. ULONG *pul,
  167. LONG *plg,
  168. LARGE_INTEGER *pli,
  169. ULARGE_INTEGER *puli)
  170. {
  171. // copy in the expected return values
  172. *pdw = 1;
  173. *pul = 2;
  174. *plg = 3;
  175. pli->LowPart = 4;
  176. pli->HighPart = 5;
  177. puli->LowPart = 6;
  178. puli->HighPart = 7;
  179. return S_OK;
  180. }
  181. //+-------------------------------------------------------------------------
  182. //
  183. // Method: CRpcTypes::WindowsIn
  184. //
  185. // Synopsis: tests passing windows structure parameters
  186. //
  187. // Arguments:
  188. //
  189. // Returns: S_OK or error code with parm #s or'd in
  190. //
  191. // History: 06-Aug-92 Ricksa Created
  192. //
  193. //--------------------------------------------------------------------------
  194. STDMETHODIMP CRpcTypes::WindowsIn(
  195. POINTL pointl,
  196. SIZEL sizel,
  197. RECTL rectl,
  198. FILETIME filetime,
  199. PALETTEENTRY paletteentry,
  200. LOGPALETTE *plogpalette)
  201. {
  202. SCODE sc = S_OK;
  203. // check the pointl structure
  204. if (pointl.x != 1 || pointl.y != 2)
  205. sc |= 1;
  206. if (sizel.cx != 3 || sizel.cy != 4)
  207. sc |= 2;
  208. if (filetime.dwLowDateTime != 5 || filetime.dwHighDateTime != 6)
  209. sc |= 4;
  210. if (paletteentry.peRed != 7 ||
  211. paletteentry.peGreen != 8 ||
  212. paletteentry.peBlue != 9 ||
  213. paletteentry.peFlags != 10)
  214. sc |= 8;
  215. if (plogpalette->palVersion != 11 ||
  216. plogpalette->palNumEntries != 1)
  217. sc |= 16;
  218. if (plogpalette->palPalEntry[0].peRed != 12)
  219. sc |= 32;
  220. return sc;
  221. }
  222. STDMETHODIMP CRpcTypes::WindowsOut(
  223. POINTL *ppointl,
  224. SIZEL *psizel,
  225. RECTL *prectl,
  226. FILETIME *pfiletime,
  227. PALETTEENTRY *ppaletteentry,
  228. LOGPALETTE **pplogpalette)
  229. {
  230. ppointl->x = 1;
  231. ppointl->y = 2;
  232. psizel->cx = 3;
  233. psizel->cy = 4;
  234. pfiletime->dwLowDateTime = 5;
  235. pfiletime->dwHighDateTime = 6;
  236. ppaletteentry->peRed = 7;
  237. ppaletteentry->peGreen = 8;
  238. ppaletteentry->peBlue = 9;
  239. ppaletteentry->peFlags = 10;
  240. *pplogpalette = new LOGPALETTE;
  241. (*pplogpalette)->palVersion = 11;
  242. (*pplogpalette)->palNumEntries = 1;
  243. (*pplogpalette)->palPalEntry[0].peRed = 12;
  244. return S_OK;
  245. }
  246. //+-------------------------------------------------------------------------
  247. //
  248. // Method: CRpcTypes::OleData
  249. //
  250. // Synopsis: tests passing OLE2 structure parameters
  251. //
  252. // Arguments:
  253. //
  254. // Returns: S_OK or error code with parm #s or'd in
  255. //
  256. // History: 06-Aug-92 Ricksa Created
  257. //
  258. //--------------------------------------------------------------------------
  259. STDMETHODIMP CRpcTypes::OleDataIn(
  260. STATDATA statdata,
  261. STATSTG statstg,
  262. STGMEDIUM stgmedium,
  263. FORMATETC formatetc,
  264. DVTARGETDEVICE *pdvtargetdevice)
  265. {
  266. SCODE sc = S_OK;
  267. return sc;
  268. }
  269. STDMETHODIMP CRpcTypes::OleDataOut(
  270. STATDATA *pstatdata,
  271. STATSTG *pstatstg,
  272. STGMEDIUM *pstgmedium,
  273. FORMATETC *pformatetc,
  274. DVTARGETDEVICE **ppdvtargetdevice)
  275. {
  276. return S_OK;
  277. }
  278. //+-------------------------------------------------------------------------
  279. //
  280. // Method: CRpcTypes::VoidPtr
  281. //
  282. // Synopsis: tests passing arrays of byte parameters
  283. //
  284. // Arguments:
  285. //
  286. // Returns: S_OK or error code with parm #s or'd in
  287. //
  288. // History: 06-Aug-92 Ricksa Created
  289. //
  290. //--------------------------------------------------------------------------
  291. STDMETHODIMP CRpcTypes::VoidPtrIn(
  292. ULONG cb,
  293. void *pv)
  294. {
  295. SCODE sc = S_OK;
  296. BYTE *pb = (BYTE *)pv;
  297. // check the contents of the buffer
  298. for (ULONG i=0; i<cb, i++; pb++)
  299. {
  300. if (*pb != (BYTE)i)
  301. sc = E_FAIL;
  302. }
  303. return sc;
  304. }
  305. STDMETHODIMP CRpcTypes::VoidPtrOut(
  306. void *pv,
  307. ULONG cb,
  308. ULONG *pcb)
  309. {
  310. BYTE *pb = (BYTE *)pv;
  311. *pcb = 0;
  312. // fill the buffer
  313. for (ULONG i=0; i<cb; i++, pb++)
  314. {
  315. *pb = (BYTE)i;
  316. }
  317. *pcb = cb;
  318. return S_OK;
  319. }