Source code of Windows XP (NT5)
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.

292 lines
5.2 KiB

  1. //+------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1993.
  5. //
  6. // File: rawrpc.cxx
  7. //
  8. // Contents: definitions for benchmark test
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 08-Feb-94 Rickhi Created
  15. //
  16. //--------------------------------------------------------------------------
  17. #include <windows.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <rpc.h>
  22. #include <rawrpc.h>
  23. extern "C" const GUID IID_IRawRpc;
  24. int _cdecl main (int argc, char ** argv)
  25. {
  26. // start Rpc
  27. RPC_STATUS rc;
  28. #ifdef USE_MSWMSG
  29. LPTSTR pszProtseq = TEXT("mswmsg");
  30. MSG msg;
  31. #else
  32. LPTSTR pszProtseq = TEXT("ncalrpc");
  33. #endif
  34. LPTSTR pszEndPoint = TEXT("99999.99999");
  35. HANDLE hEvent;
  36. #ifdef UNICODE
  37. rc = RpcServerUseProtseqEp(pszProtseq,
  38. RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
  39. pszEndPoint,
  40. NULL);
  41. #else
  42. rc = RpcServerUseProtseqEp((unsigned char *)pszProtseq,
  43. RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
  44. (unsigned char *)pszEndPoint,
  45. NULL);
  46. #endif
  47. if (rc != RPC_S_OK)
  48. {
  49. return rc;
  50. }
  51. rc = RpcServerRegisterIf(IRawRpc_ServerIfHandle, 0, 0);
  52. if (rc != RPC_S_OK)
  53. {
  54. return rc;
  55. }
  56. I_RpcSsDontSerializeContext();
  57. //
  58. // Signal the client that we're up and running
  59. //
  60. hEvent = CreateEvent(NULL, TRUE, FALSE,
  61. TEXT("OleBenchRawRpcServerStarted"));
  62. // start server listening. this call blocks until we get an
  63. // RpcMgmtStopServerListening call.
  64. rc = RpcServerListen(1, 0xffff, 1);
  65. if (rc != RPC_S_OK)
  66. {
  67. CloseHandle(hEvent);
  68. return rc;
  69. }
  70. if (!SetEvent(hEvent))
  71. {
  72. CloseHandle(hEvent);
  73. return GetLastError();
  74. }
  75. CloseHandle(hEvent);
  76. #ifdef USE_MSWMSG
  77. while (GetMessage(&msg, NULL, 0, 0))
  78. {
  79. TranslateMessage(&msg);
  80. DispatchMessage(&msg);
  81. }
  82. #endif
  83. rc = RpcMgmtWaitServerListen();
  84. if (rc != RPC_S_OK)
  85. {
  86. return rc;
  87. }
  88. // done, exit.
  89. return 0;
  90. }
  91. // Server side of Rpc functions.
  92. SCODE Quit(handle_t hRpc)
  93. {
  94. SCODE rc;
  95. rc = RpcMgmtStopServerListening(NULL);
  96. #ifdef USE_MSWMSG
  97. PostQuitMessage(0);
  98. #endif
  99. return rc;
  100. }
  101. //+-------------------------------------------------------------------------
  102. //
  103. // Method: Void
  104. //
  105. // Synopsis: tests passing no parameters
  106. //
  107. // Arguments:
  108. //
  109. // Returns:
  110. //
  111. // History: 06-Aug-92 Rickhi Created
  112. //
  113. //--------------------------------------------------------------------------
  114. void Void(handle_t hRpc)
  115. {
  116. return;
  117. }
  118. SCODE VoidRC(handle_t hRpc)
  119. {
  120. return RPC_S_OK;
  121. }
  122. SCODE VoidPtrIn(handle_t hRpc, ULONG cb, void *pv)
  123. {
  124. return RPC_S_OK;
  125. }
  126. SCODE VoidPtrOut(handle_t hRpc, ULONG cb, ULONG *pcb, void *pv)
  127. {
  128. memset(pv, 1, cb);
  129. *pcb = cb;
  130. return RPC_S_OK;
  131. }
  132. //+-------------------------------------------------------------------------
  133. //
  134. // Function: Dword
  135. //
  136. // Synopsis: tests passing dwords in and out
  137. //
  138. // Arguments:
  139. //
  140. // Returns: RPC_S_OK
  141. //
  142. // History: 06-Aug-92 Ricksa Created
  143. //
  144. //--------------------------------------------------------------------------
  145. SCODE DwordIn(handle_t hRpc, DWORD dw)
  146. {
  147. return RPC_S_OK;
  148. }
  149. SCODE DwordOut(handle_t hRpc, DWORD *pdw)
  150. {
  151. *pdw = 1;
  152. return RPC_S_OK;
  153. }
  154. SCODE DwordInOut(handle_t hRpc, DWORD *pdw)
  155. {
  156. *pdw = 1;
  157. return RPC_S_OK;
  158. }
  159. //+-------------------------------------------------------------------------
  160. //
  161. // Function: Li
  162. //
  163. // Synopsis: tests passing LARGE INTEGERS in and out
  164. //
  165. // Arguments:
  166. //
  167. // Returns: RPC_S_OK
  168. //
  169. // History: 06-Aug-92 Ricksa Created
  170. //
  171. //--------------------------------------------------------------------------
  172. SCODE LiIn(handle_t hRpc, LARGE_INTEGER li)
  173. {
  174. return RPC_S_OK;
  175. }
  176. SCODE LiOut(handle_t hRpc, LARGE_INTEGER *pli)
  177. {
  178. pli->LowPart = 0;
  179. pli->HighPart = 1;
  180. return RPC_S_OK;
  181. }
  182. SCODE ULiIn(handle_t hRpc, ULARGE_INTEGER uli)
  183. {
  184. return RPC_S_OK;
  185. }
  186. SCODE ULiOut(handle_t hRpc, ULARGE_INTEGER *puli)
  187. {
  188. puli->LowPart = 0;
  189. puli->HighPart = 1;
  190. return RPC_S_OK;
  191. }
  192. //+-------------------------------------------------------------------------
  193. //
  194. // Function: String
  195. //
  196. // Synopsis: tests passing strings in and out
  197. //
  198. // Arguments:
  199. //
  200. // Returns: RPC_S_OK
  201. //
  202. // History: 06-Aug-92 Ricksa Created
  203. //
  204. //--------------------------------------------------------------------------
  205. SCODE StringIn(handle_t hRpc, LPWSTR pwsz)
  206. {
  207. return RPC_S_OK;
  208. }
  209. SCODE StringOut(handle_t hRpc, LPWSTR *ppwsz)
  210. {
  211. // LPOLESTR pwsz = new OLECHAR[80];
  212. // *ppwsz = pwsz;
  213. wcscpy(*ppwsz, L"Hello World This is a Message");
  214. return RPC_S_OK;
  215. }
  216. SCODE StringInOut(handle_t hRpc, LPWSTR pwsz)
  217. {
  218. wcscpy(pwsz, L"Hello World This is a Message");
  219. return RPC_S_OK;
  220. }
  221. //+-------------------------------------------------------------------------
  222. //
  223. // Function: Guid
  224. //
  225. // Synopsis: tests passing GUIDs in and out
  226. //
  227. // Arguments:
  228. //
  229. // Returns: RPC_S_OK
  230. //
  231. // History: 06-Aug-92 Ricksa Created
  232. //
  233. //--------------------------------------------------------------------------
  234. SCODE GuidIn(handle_t hRpc, GUID guid)
  235. {
  236. return RPC_S_OK;
  237. }
  238. SCODE GuidOut(handle_t hRpc, GUID *piid)
  239. {
  240. memcpy(piid, &IID_IRawRpc, sizeof(GUID));
  241. return RPC_S_OK;
  242. }