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.

9609 lines
253 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1990 - 1999
  6. //
  7. // File: usvr.cxx
  8. //
  9. //--------------------------------------------------------------------------
  10. /* --------------------------------------------------------------------
  11. Microsoft OS/2 LAN Manager
  12. Copyright(c) Microsoft Corp., 1990
  13. -------------------------------------------------------------------- */
  14. /* --------------------------------------------------------------------
  15. File : usvr.cxx
  16. Description :
  17. Server test program for the RPC runtime. This program functions as half
  18. of the build verification test for the RPC runtime. The other half is
  19. the client test program.
  20. This particular program is independent of the particular operating
  21. system other than requiring threads support of some sort (including
  22. mutexes).
  23. RPC server runtime APIs:
  24. RpcCreateServer
  25. RpcDeleteServer
  26. RpcAddAddress
  27. RpcRemoveAddress
  28. RpcAddInterface
  29. RpcRemoveInterface
  30. RpcMonitorAssociation
  31. RpcQueryConfig
  32. RpcGetCurrentCallHandle
  33. RpcGetAssociationContext
  34. RpcQueryCall
  35. RpcQueryBinding
  36. RpcQueryProtocolStack
  37. I_RpcGetBuffer
  38. I_RpcFreeBuffer
  39. I_RpcSendReceive
  40. -------------------------------------------------------------------- */
  41. #include <precomp.hxx>
  42. #include "pipe.h"
  43. #include "astub.h"
  44. #define _PNP_POWER_
  45. #include <winsock2.h>
  46. #include <Charconv.hxx>
  47. #include <direct.h>
  48. extern "C"
  49. {
  50. #include <iphlpapi.h>
  51. }
  52. /*
  53. Transports:
  54. Update this to add a new transport.
  55. */
  56. #define RPC_TRANSPORT_NAMEPIPE 1
  57. #define RPC_LRPC 2
  58. #define RPC_TRANSPORT_TCP 3
  59. #define RPC_TRANSPORT_DNET 4
  60. #define RPC_TRANSPORT_NETBIOS 5
  61. #define RPC_TRANSPORT_SPX 6
  62. #define RPC_TRANSPORT_UDP 7
  63. #define RPC_TRANSPORT_IPX 8
  64. #define RPC_TRANSPORT_DSP 9
  65. #define RPC_TRANSPORT_VNS 10
  66. #define RPC_WMSG 11
  67. #define RPC_TRANSPORT_MSMQ 12
  68. #define MAXLISTENTHREADS 12345
  69. #define MAX_CALL_REQUESTS 500
  70. #define EXTENDED_ERROR_EXCEPTION 77777
  71. #define SIZEOUT_ASYNC_EXCEPTION (0xfffffff)
  72. typedef DWORD
  73. (RPCRTAPI RPC_ENTRY *SET_TEST_HOOK_FN)(
  74. RPC_TEST_HOOK_ID id,
  75. RPC_TEST_HOOK_FN fn
  76. );
  77. //
  78. // Global variables.
  79. //
  80. BOOL fExtendedError = FALSE;
  81. unsigned int MinimumListenThreads = 1;
  82. unsigned int UseEndpointMapperFlag = 0;
  83. unsigned int NoSecurityTests = 0;
  84. unsigned int DatagramFlag = 0;
  85. unsigned int AutoListenFlag = 0;
  86. unsigned int IFSecurity = 0;
  87. int Verbose = 0;
  88. unsigned int WarnFlag = 0; // Flag for warning messages;
  89. unsigned int ErrorFlag = 0; // Flag for error messages;
  90. unsigned int TransportType;
  91. int MaxRpcSize = 1000000;
  92. unsigned long ulSecurityPackage = 10 ;
  93. int FireWallFlag = 0;
  94. char NetBiosProtocol[20] = "ncacn_nb_nb"; // NetBios transport protocol
  95. char *TransportOption = "-namepipe";
  96. int ServerType ;
  97. #define SYNC_WMSG 1
  98. #define ASYNC_WMSG 2
  99. HWND hWnd ;
  100. char szAppName[] = "usvr";
  101. THREAD_IDENTIFIER CurrentTid ;
  102. extern RPC_SERVER_INTERFACE IsabelleInterfaceInformation;
  103. RPC_STATUS Status; // Contains the status of the last RPC API call.
  104. I_RPC_MUTEX PrintMutex = 0; // Mutex used to serialize print operations.
  105. #define CHUNK_SIZE 50
  106. #define NUM_CHUNKS 100
  107. #define BUFF_SIZE 100
  108. typedef int pipe_element_t ;
  109. typedef struct {
  110. void (*Pull) (
  111. PIPE_STATE *state,
  112. pipe_element_t *buffer,
  113. int max_buf,
  114. int *actual_transfer_count
  115. ) ;
  116. void (*Push) (
  117. PIPE_STATE *state,
  118. pipe_element_t *buffer,
  119. int max_buf
  120. ) ;
  121. PIPE_STATE *state ;
  122. } pipe_t ;
  123. int ShutdownCalled ;
  124. unsigned int IsabelleErrors = 0;
  125. unsigned int HelgaErrors = 0;
  126. unsigned int SylviaErrors = 0;
  127. SET_TEST_HOOK_FN SetTestHookFn;
  128. //
  129. // forward declarations
  130. //
  131. extern void
  132. Async (
  133. ) ;
  134. extern void
  135. SendAck (
  136. ) ;
  137. void
  138. DgTransport (
  139. );
  140. void
  141. SecurityErrorWrapper(
  142. int subtest
  143. );
  144. DWORD
  145. GenericServerListen(
  146. char * name,
  147. int endpoint
  148. );
  149. DWORD
  150. GenericServerUnlisten(
  151. char * name
  152. );
  153. //
  154. // function definitions
  155. //
  156. void
  157. ApiError ( // An API error occured; we just print a message.
  158. IN char * Routine, // The routine which called the API.
  159. IN char * API,
  160. IN RPC_STATUS status
  161. )
  162. {
  163. if (ErrorFlag)
  164. {
  165. I_RpcRequestMutex(&PrintMutex);
  166. PrintToConsole(" ApiError in %s (%s = %u)\n",Routine,API,status);
  167. I_RpcClearMutex(PrintMutex);
  168. }
  169. }
  170. void
  171. PauseExecution (
  172. unsigned long milliseconds
  173. )
  174. {
  175. Sleep(milliseconds);
  176. }
  177. void
  178. CompleteReceive(
  179. PRPC_MESSAGE Callee
  180. )
  181. {
  182. DWORD size = 0;
  183. Callee->RpcFlags |= RPC_BUFFER_EXTRA;
  184. Callee->RpcFlags &= ~RPC_BUFFER_PARTIAL;
  185. if ((Callee->RpcFlags & RPC_BUFFER_COMPLETE) == 0)
  186. {
  187. Status = I_RpcReceive(Callee, size) ;
  188. if (Status)
  189. {
  190. ApiError("CompleteReceive", "I_RpcReceive", Status) ;
  191. }
  192. }
  193. ASSERT(Callee->RpcFlags & RPC_BUFFER_COMPLETE);
  194. }
  195. RPC_STATUS
  196. RpcServerUseProtseqEpWrapper (
  197. IN unsigned char PAPI * Protseq,
  198. IN unsigned int MaxCalls,
  199. IN unsigned char PAPI * Endpoint,
  200. IN void PAPI * SecurityDescriptor
  201. )
  202. {
  203. RPC_POLICY Policy ;
  204. if (FireWallFlag)
  205. {
  206. Policy.Length = sizeof(RPC_POLICY) ;
  207. Policy.NICFlags = RPC_C_BIND_TO_ALL_NICS;
  208. Policy.EndpointFlags = RPC_C_DONT_FAIL;
  209. return RpcServerUseProtseqEpExA(Protseq, MaxCalls, Endpoint,
  210. SecurityDescriptor,&Policy) ;
  211. }
  212. else
  213. {
  214. return RpcServerUseProtseqEpA(Protseq, MaxCalls, Endpoint, SecurityDescriptor) ;
  215. }
  216. }
  217. RPC_STATUS
  218. RpcServerUseProtseqWrapper (
  219. IN unsigned char PAPI * Protseq,
  220. IN unsigned int MaxCalls,
  221. IN void PAPI * SecurityDescriptor OPTIONAL
  222. )
  223. {
  224. RPC_POLICY Policy ;
  225. if (FireWallFlag)
  226. {
  227. Policy.Length = sizeof(RPC_POLICY) ;
  228. Policy.NICFlags = RPC_C_BIND_TO_ALL_NICS ;
  229. return RpcServerUseProtseqExA(Protseq, MaxCalls, SecurityDescriptor, &Policy) ;
  230. }
  231. else
  232. {
  233. return RpcServerUseProtseqA(Protseq, MaxCalls, SecurityDescriptor) ;
  234. }
  235. }
  236. RPC_STATUS
  237. RpcServerUseAllProtseqsWrapper (
  238. IN unsigned int MaxCalls,
  239. IN void PAPI * SecurityDescriptor OPTIONAL
  240. )
  241. {
  242. RPC_POLICY Policy ;
  243. if (FireWallFlag)
  244. {
  245. Policy.Length = sizeof(RPC_POLICY) ;
  246. Policy.NICFlags = RPC_C_BIND_TO_ALL_NICS ;
  247. return RpcServerUseAllProtseqsEx(MaxCalls, SecurityDescriptor, &Policy) ;
  248. }
  249. else
  250. {
  251. return RpcServerUseAllProtseqs(MaxCalls, SecurityDescriptor) ;
  252. }
  253. }
  254. RPC_STATUS
  255. RpcServerUseProtseqIfWrapper (
  256. IN unsigned char PAPI * Protseq,
  257. IN unsigned int MaxCalls,
  258. IN RPC_IF_HANDLE IfSpec,
  259. IN void PAPI * SecurityDescriptor
  260. )
  261. {
  262. RPC_POLICY Policy ;
  263. if (FireWallFlag)
  264. {
  265. Policy.Length = sizeof(RPC_POLICY) ;
  266. Policy.NICFlags = RPC_C_BIND_TO_ALL_NICS ;
  267. return RpcServerUseProtseqIfExA(Protseq, MaxCalls, IfSpec,
  268. SecurityDescriptor, &Policy) ;
  269. }
  270. else
  271. {
  272. return RpcServerUseProtseqIfA(Protseq, MaxCalls, IfSpec, SecurityDescriptor) ;
  273. }
  274. }
  275. RPC_STATUS
  276. RpcServerUseAllProtseqsIfWrapper (
  277. IN unsigned int MaxCalls,
  278. IN RPC_IF_HANDLE IfSpec,
  279. IN void PAPI * SecurityDescriptor OPTIONAL
  280. )
  281. {
  282. RPC_POLICY Policy ;
  283. if (FireWallFlag)
  284. {
  285. Policy.Length = sizeof(RPC_POLICY) ;
  286. Policy.NICFlags = RPC_C_BIND_TO_ALL_NICS ;
  287. return RpcServerUseAllProtseqsIfEx(MaxCalls, IfSpec, SecurityDescriptor, &Policy) ;
  288. }
  289. else
  290. {
  291. return RpcServerUseAllProtseqsIf(MaxCalls, IfSpec, SecurityDescriptor) ;
  292. }
  293. }
  294. #if 0
  295. void
  296. GlobalMutexRequest (
  297. void
  298. )
  299. {
  300. I_RpcRequestMutex(&PrintMutex);
  301. }
  302. void
  303. GlobalMutexClear (
  304. void
  305. )
  306. {
  307. I_RpcClearMutex(PrintMutex);
  308. }
  309. #endif
  310. void
  311. OtherError ( // Some other error occured; again, we just print a message.
  312. IN char * Routine, // The routine where the error occured.
  313. IN char * Message
  314. )
  315. {
  316. if (ErrorFlag)
  317. {
  318. I_RpcRequestMutex(&PrintMutex);
  319. PrintToConsole(" Error in %s (%s)\n",Routine,Message);
  320. I_RpcClearMutex(PrintMutex);
  321. }
  322. }
  323. void
  324. Shutdown ( // Awaken the thread waiting on WaitForShutdown.
  325. )
  326. {
  327. Status = RpcMgmtStopServerListening(0);
  328. if (Status)
  329. {
  330. ApiError("Shutdown","RpcMgmtStopServerListening",Status);
  331. }
  332. ShutdownCalled = 1 ;
  333. }
  334. RPC_STATUS
  335. IfCallbackFunction(
  336. IN RPC_IF_HANDLE InterfaceUuid,
  337. IN void *Context
  338. )
  339. {
  340. return (RPC_S_OK) ;
  341. }
  342. RPC_STATUS
  343. stub_RegisterIf (
  344. IN RPC_IF_HANDLE IfSpec,
  345. IN UUID PAPI * MgrTypeUuid OPTIONAL,
  346. IN RPC_MGR_EPV PAPI * MgrEpv OPTIONAL
  347. )
  348. {
  349. unsigned int Flags = 0;
  350. if (AutoListenFlag)
  351. {
  352. Flags |= RPC_IF_AUTOLISTEN ;
  353. ShutdownCalled = 0 ;
  354. }
  355. if (IFSecurity)
  356. {
  357. Flags |= RPC_IF_ALLOW_SECURE_ONLY;
  358. }
  359. return RpcServerRegisterIf2(IfSpec, MgrTypeUuid, MgrEpv,
  360. Flags, 1000, MaxRpcSize, 0);
  361. }
  362. RPC_STATUS
  363. stub_ServerListen (
  364. IN unsigned int MinimumCallThreads,
  365. IN unsigned int MaxCalls,
  366. IN unsigned int DontWait
  367. )
  368. {
  369. if (AutoListenFlag)
  370. {
  371. while (ShutdownCalled == 0)
  372. {
  373. PauseExecution(500) ;
  374. }
  375. return (RPC_S_OK) ;
  376. }
  377. else
  378. {
  379. return RpcServerListen(MinimumCallThreads, MaxCalls, DontWait) ;
  380. }
  381. }
  382. void IsabelleError (
  383. )
  384. {
  385. IsabelleErrors += 1 ;
  386. }
  387. void HelgaError (
  388. )
  389. {
  390. HelgaErrors += 1 ;
  391. }
  392. void SylviaError (
  393. )
  394. {
  395. SylviaErrors += 1 ;
  396. }
  397. #define SIGFRIED 0
  398. #define ELLIOTMINIMIZE 1
  399. #define ELLIOTMAXIMIZE 2
  400. #define ELLIOTNORMAL 3
  401. #define ANDROMIDA 4
  402. #define FREDRICK 7
  403. #define ISABELLENORMAL 10
  404. #define ISABELLEMINIMIZE 11
  405. #define ISABELLEMAXIMIZE 12
  406. #define CHRISTOPHER 13
  407. #define CHRISTOPHERHELGA 14
  408. #define CHRISTOPHERISABELLE 15
  409. #define TYLER 17
  410. #define CHRISTOPHERMUSTFAILONE 18
  411. #define CHRISTOPHERMUSTFAILTWO 19
  412. #define RICHARD 20
  413. #define RICHARDHELPER 21
  414. #define DAVIDFIRST 22
  415. #define DAVIDSECOND 23
  416. #define BARTHOLOMEW 24
  417. #define GRANT 25
  418. #define HERMAN 26
  419. #define IVAN 27
  420. #define JASON 28
  421. #define KENNETH 29
  422. #define TESTYIELD 30
  423. #define SPIPE TESTYIELD
  424. #define SECURITY_ERROR TESTYIELD
  425. /*
  426. Transports:
  427. Update this to add a new transport.
  428. */
  429. char * NamepipeAddresses [] =
  430. {
  431. "\\pipe\\sigfried",
  432. "\\pipe\\elliotmi",
  433. "\\pipe\\elliotma",
  434. "\\pipe\\elliotno",
  435. "\\pipe\\andromno",
  436. 0,
  437. 0,
  438. "\\pipe\\fredrick",
  439. 0,
  440. 0,
  441. "\\pipe\\isabelno",
  442. "\\pipe\\isabelmi",
  443. "\\pipe\\isabelma",
  444. "\\pipe\\christ",
  445. "\\pipe\\zippyhe",
  446. "\\pipe\\zippyis",
  447. 0,
  448. "\\pipe\\tyler",
  449. "\\\blippo",
  450. "\\\\\\chrismft",
  451. "\\pipe\\richard",
  452. "\\pipe\\richardh",
  453. "\\pipe\\david1",
  454. "\\pipe\\david2",
  455. "\\pipe\\bart",
  456. "\\pipe\\grant",
  457. "\\pipe\\herman",
  458. "\\pipe\\ivan",
  459. "\\pipe\\jason",
  460. "\\pipe\\kenneth",
  461. "\\pipe\\testyield"
  462. };
  463. char * DspAddresses [] =
  464. {
  465. "\\pipe\\sigfried",
  466. "\\pipe\\elliotmi",
  467. "\\pipe\\elliotma",
  468. "\\pipe\\elliotno",
  469. "\\pipe\\andromno",
  470. 0,
  471. 0,
  472. "\\pipe\\fredrick",
  473. 0,
  474. 0,
  475. "\\pipe\\isabelno",
  476. "\\pipe\\isabelmi",
  477. "\\pipe\\isabelma",
  478. "\\pipe\\christ",
  479. "\\pipe\\zippyhe",
  480. "\\pipe\\zippyis",
  481. 0,
  482. "\\pipe\\tyler",
  483. "",
  484. "",
  485. "\\pipe\\richard",
  486. "\\pipe\\richardh",
  487. "\\pipe\\david1",
  488. "\\pipe\\david2",
  489. "\\pipe\\bart",
  490. "\\pipe\\grant",
  491. "\\pipe\\herman",
  492. "\\pipe\\ivan",
  493. "\\pipe\\jason",
  494. "\\pipe\\kenneth",
  495. "\\pipe\\testyield"
  496. };
  497. char * NetBiosAddresses [] =
  498. {
  499. "201", // sigfried
  500. "202", // elliotmi
  501. "203", // elliotma
  502. "204", // elliotno
  503. "205", // andromno
  504. 0,
  505. 0,
  506. "206", // fredrick
  507. 0,
  508. 0,
  509. "207", // isabelno
  510. "208", // isabelmi
  511. "209", // isabelma
  512. "210", // christ
  513. "211", // zippyhe
  514. "212", // zippyis
  515. 0,
  516. "214", // tyler
  517. "300", // christ fail 1
  518. "BadName",// christ fail 2
  519. "215", // richard
  520. "216", // richardh
  521. "217", // david1
  522. "218", // david2
  523. "219", // bart
  524. "220", // grant
  525. "221", // herman
  526. "222", // ivan
  527. "223", // jason
  528. "224", // kenneth
  529. "225" //testyield
  530. };
  531. char * TCPAddresses [] =
  532. {
  533. "2025", // SIGFRIED
  534. "2026", // ELLIOTMINIMIZE
  535. "2027", // ELLIOTMAXIMIZE
  536. "2028", // ELLIOTNORMAL
  537. "2029", // ANDROMIDA
  538. 0,
  539. 0,
  540. "2032", // FREDRICK
  541. 0,
  542. 0,
  543. "2035", // ISABELLENORMAL
  544. "2036", // ISABELLEMINIMIZE
  545. "2037", // ISABELLEMAXIMIZE
  546. "2038", // CHRISTOPHER
  547. "2039", // CHRISTOPHERHELGA
  548. "2040", // CHRISTOPHERISABELLE
  549. 0,
  550. "2042", // TYLER
  551. "chrismfo",
  552. "chrismft",
  553. "2043", // RICHARD
  554. "2044", // RICHARDHELPER
  555. "2045", // D1
  556. "2046", // D2
  557. "2047", // BARTHOLOMEW
  558. "2048", // GRANT
  559. "2049", // HERMAN
  560. "2050", // IVAN
  561. "2051", // JASON
  562. "2052", // KENNETH
  563. "2053" // TESTYIELD
  564. };
  565. char * UDPAddresses [] =
  566. {
  567. "2025", // SIGFRIED
  568. "2026", // ELLIOTMINIMIZE
  569. "2027", // ELLIOTMAXIMIZE
  570. "2028", // ELLIOTNORMAL
  571. "2029", // ANDROMIDA
  572. 0,
  573. 0,
  574. "2032", // FREDRICK
  575. 0,
  576. 0,
  577. "2035", // ISABELLENORMAL
  578. "2036", // ISABELLEMINIMIZE
  579. "2037", // ISABELLEMAXIMIZE
  580. "2038", // CHRISTOPHER
  581. "2039", // CHRISTOPHERHELGA
  582. "2040", // CHRISTOPHERISABELLE
  583. 0,
  584. "2042", // TYLER
  585. "chrismfo",
  586. "chrismft",
  587. "2043", // RICHARD
  588. "2044", // RICHARDHELPER
  589. "2045", // D1
  590. "2046", // D2
  591. "2047", // BARTHOLOMEW
  592. "2048", // GRANT
  593. "2049", // HERMAN
  594. "2050", // IVAN
  595. "2051", // JASON
  596. "2052", // KENNETH
  597. "2053" // TESTYIELD
  598. };
  599. char * SPCAddresses [] =
  600. {
  601. "sigfried",
  602. "elliotminimize",
  603. "elliotmaximize",
  604. "elliotnormal",
  605. "andromida",
  606. 0,
  607. 0,
  608. "fredrick",
  609. 0,
  610. 0,
  611. "isabellenormal",
  612. "isabelleminimize",
  613. "isabellemaximize",
  614. "christopher",
  615. "christopherhelga",
  616. "christopherisabelle",
  617. 0,
  618. "tyler",
  619. "\\christophermustfailone",
  620. "christopher\\mustfailtwo",
  621. "richard",
  622. "richardhelper",
  623. "davidfirst",
  624. "davidsecond",
  625. "bartholomew",
  626. "grant",
  627. "herman",
  628. "ivan",
  629. "jason",
  630. "kenneth",
  631. "testyield"
  632. };
  633. char * SPXAddresses [] =
  634. {
  635. "5000", // sigfried
  636. "5001", // elliotmi
  637. "5002", // elliotma
  638. "5003", // elliotno
  639. "5004", // andromno
  640. "5005",
  641. "5006",
  642. "5007", // fredrick
  643. "5008",
  644. "5009",
  645. "5010", // isabelno
  646. "5011", // isabelmi
  647. "5012", // isabelma
  648. "5013", // christ
  649. "5014", // zippyhe
  650. "5015", // zippyis
  651. "5016",
  652. "5017", // tyler
  653. "hello", // christ fail 1
  654. "50195019", // christ fail 2
  655. "5020", // richard
  656. "5021", // richardh
  657. "5022", // david1
  658. "5023", // david2
  659. "5024", // bart
  660. "5025", // grant
  661. "5026", // herman
  662. "5027", // ivan
  663. "5028", // jason
  664. "5029", // kenneth
  665. "5030" // testyield
  666. };
  667. char * IPXAddresses [] =
  668. {
  669. "5000", // sigfried
  670. "5001", // elliotmi
  671. "5002", // elliotma
  672. "5003", // elliotno
  673. "5004", // andromno
  674. "5005",
  675. "5006",
  676. "5007", // fredrick
  677. "5008",
  678. "5009",
  679. "5010", // isabelno
  680. "5011", // isabelmi
  681. "5012", // isabelma
  682. "5013", // christ
  683. "5014", // zippyhe
  684. "5015", // zippyis
  685. "5016",
  686. "5017", // tyler
  687. "hello", // christ fail 1
  688. "50195019", // christ fail 2
  689. "5020", // richard
  690. "5021", // richardh
  691. "5022", // david1
  692. "5023", // david2
  693. "5024", // bart
  694. "5025", // grant
  695. "5026", // herman
  696. "5027", // ivan
  697. "5028", // jason
  698. "5029", // kenneth
  699. "5030" // testyield
  700. };
  701. char * VNSAddresses [] =
  702. {
  703. "250", // sigfried
  704. "251", // elliotmi
  705. "252", // elliotma
  706. "253", // elliotno
  707. "254", // andromno
  708. "255",
  709. "256",
  710. "257", // fredrick
  711. "258",
  712. "259",
  713. "260", // isabelno
  714. "261", // isabelmi
  715. "262", // isabelma
  716. "263", // christ
  717. "264", // zippyhe
  718. "265", // zippyis
  719. "266",
  720. "267", // tyler
  721. "hello", // christ fail 1
  722. "50195019", // christ fail 2
  723. "270", // richard
  724. "271", // richardh
  725. "272", // david1
  726. "273", // david2
  727. "274", // bart
  728. "275", // grant
  729. "276", // herman
  730. "277", // ivan
  731. "278", // jason
  732. "279", // kenneth
  733. "280" // testyield
  734. };
  735. char * MSMQAddresses [] =
  736. {
  737. "SIGFRIED",
  738. "ELLIOTMINIMIZE",
  739. "ELLIOTMAXIMIZE",
  740. "ELLIOTNORMAL",
  741. "ANDROMIDA",
  742. 0,
  743. 0,
  744. "FREDRICK",
  745. 0,
  746. 0,
  747. "ISABELLENORMAL",
  748. "ISABELLEMINIMIZE",
  749. "ISABELLEMAXIMIZE",
  750. "CHRISTOPHER",
  751. "CHRISTOPHERHELGA",
  752. "CHRISTOPHERISABELLE",
  753. 0,
  754. "TYLER",
  755. " \\ \\ \\chrismfo",
  756. "chr\\\\\\\\ $$$$ismft",
  757. "RICHARD",
  758. "RICHARDHELPER",
  759. "D1",
  760. "D2",
  761. "BARTHOLOMEW",
  762. "GRANT",
  763. "HERMAN",
  764. "IVAN",
  765. "JASON",
  766. "KENNETH",
  767. "TESTYIELD"
  768. };
  769. unsigned char *
  770. GetProtocolSequence (
  771. )
  772. /*++
  773. Routine Description:
  774. This routine is used to obtain an rpc protocol sequence.
  775. Return Value:
  776. A pointer to an rpc protocol sequence is returned. This pointer
  777. should not be freed.
  778. Transports:
  779. Update this to add a new transport.
  780. --*/
  781. {
  782. if (TransportType == RPC_TRANSPORT_NAMEPIPE)
  783. return((unsigned char *) "ncacn_np");
  784. if (TransportType == RPC_LRPC)
  785. {
  786. return((unsigned char *) "ncalrpc");
  787. }
  788. if (TransportType == RPC_TRANSPORT_NETBIOS)
  789. return((unsigned char *) NetBiosProtocol);
  790. if (TransportType == RPC_TRANSPORT_SPX)
  791. return((unsigned char *) "ncacn_spx");
  792. if (TransportType == RPC_TRANSPORT_TCP)
  793. return((unsigned char *) "ncacn_ip_tcp");
  794. if (TransportType == RPC_TRANSPORT_UDP)
  795. return((unsigned char *) "ncadg_ip_udp");
  796. if (TransportType == RPC_TRANSPORT_IPX)
  797. return((unsigned char *) "ncadg_ipx");
  798. if (TransportType == RPC_TRANSPORT_DSP)
  799. return((unsigned char *) "ncacn_at_dsp") ;
  800. if (TransportType == RPC_TRANSPORT_VNS)
  801. return((unsigned char *) "ncacn_vns_spp") ;
  802. if (TransportType == RPC_TRANSPORT_MSMQ)
  803. return((unsigned char *) "ncadg_mq") ;
  804. return(0);
  805. }
  806. unsigned char *
  807. GetEndpoint (
  808. IN unsigned int Endpoint
  809. )
  810. /*++
  811. Routine Description:
  812. This routine is used to obtain the endpoint corresponding to a
  813. give endpoint index.
  814. Arguments:
  815. Endpoint - Supplies an index into a table of endpoints.
  816. Return Value:
  817. A pointer to an endpoint from the table of endpoints will be returned.
  818. Transports:
  819. Update this to add a new transport.
  820. --*/
  821. {
  822. if (TransportType == RPC_TRANSPORT_NAMEPIPE)
  823. return((unsigned char *) NamepipeAddresses[Endpoint]);
  824. else if (TransportType == RPC_TRANSPORT_NETBIOS)
  825. return((unsigned char *) NetBiosAddresses[Endpoint]);
  826. else if (TransportType == RPC_TRANSPORT_TCP)
  827. return((unsigned char *) TCPAddresses[Endpoint]);
  828. else if (TransportType == RPC_TRANSPORT_UDP)
  829. return((unsigned char *) UDPAddresses[Endpoint]);
  830. else if ((TransportType == RPC_LRPC) || (TransportType == RPC_WMSG))
  831. return((unsigned char *) SPCAddresses[Endpoint]);
  832. else if (TransportType == RPC_TRANSPORT_SPX)
  833. return((unsigned char *) SPXAddresses[Endpoint]);
  834. else if (TransportType == RPC_TRANSPORT_IPX)
  835. return((unsigned char *) IPXAddresses[Endpoint]);
  836. else if (TransportType == RPC_TRANSPORT_VNS)
  837. return((unsigned char *) VNSAddresses[Endpoint]);
  838. else if (TransportType == RPC_TRANSPORT_DSP)
  839. return ((unsigned char *) DspAddresses[Endpoint]) ;
  840. else if (TransportType == RPC_TRANSPORT_MSMQ)
  841. return ((unsigned char *) MSMQAddresses[Endpoint]) ;
  842. return(0);
  843. }
  844. /* --------------------------------------------------------------------
  845. Helga Interface
  846. -------------------------------------------------------------------- */
  847. unsigned int HelgaCheckManagerEpv = 0;
  848. RPC_MGR_EPV PAPI * HelgaManagerEpv;
  849. unsigned int HelgaCheckObject = 0;
  850. unsigned short HelgaMagicNumber;
  851. int
  852. CheckUuidValue (
  853. IN unsigned short MagicNumber,
  854. OUT UUID PAPI * Uuid
  855. )
  856. /*++
  857. Routine Description:
  858. This routine is used to check that a generated uuid value is correct.
  859. Arguments:
  860. MagicNumber - Supplies a magic number which will be used to
  861. check a generated uuid.
  862. Uuid - Supplies a generated uuid to check.
  863. Return Value:
  864. Zero will be returned if the uuid value is correct; otherwise, non-zero
  865. will be returned.
  866. --*/
  867. {
  868. if ( Uuid->Data1 != ((unsigned long) MagicNumber)
  869. * ((unsigned long) MagicNumber))
  870. return(1);
  871. if ( Uuid->Data2 != MagicNumber )
  872. return(1);
  873. if ( Uuid->Data3 != MagicNumber / 2 )
  874. return(1);
  875. if ( Uuid->Data4[0] != MagicNumber % 256 )
  876. return(1);
  877. if ( Uuid->Data4[1] != MagicNumber % 257 )
  878. return(1);
  879. if ( Uuid->Data4[2] != MagicNumber % 258 )
  880. return(1);
  881. if ( Uuid->Data4[3] != MagicNumber % 259 )
  882. return(1);
  883. if ( Uuid->Data4[4] != MagicNumber % 260 )
  884. return(1);
  885. if ( Uuid->Data4[5] != MagicNumber % 261 )
  886. return(1);
  887. if ( Uuid->Data4[6] != MagicNumber % 262 )
  888. return(1);
  889. if ( Uuid->Data4[7] != MagicNumber % 263 )
  890. return(1);
  891. return(0);
  892. }
  893. void
  894. InitializeBuffer (
  895. IN OUT void PAPI * Buffer,
  896. IN unsigned int BufferLength
  897. )
  898. /*++
  899. Routine Description:
  900. This routine is used to initialize the buffer; the first long in the
  901. buffer is set to be the length of the buffer. The rest of the buffer
  902. is initialized with a pattern which will be checked by the receiver.
  903. Arguments:
  904. Buffer - Supplies the buffer to be initialized.
  905. BufferLength - Supplies the length of the buffer.
  906. --*/
  907. {
  908. unsigned long PAPI * Length;
  909. unsigned char PAPI * BufferScan;
  910. static unsigned char InitialValue = 69;
  911. unsigned char Value;
  912. Length = (unsigned long PAPI *) Buffer;
  913. *Length = BufferLength;
  914. Value = InitialValue;
  915. InitialValue += 1;
  916. for (BufferScan = (unsigned char PAPI *) (Length + 1), BufferLength -= 4;
  917. BufferLength > 0; BufferLength--, BufferScan++, Value++)
  918. *BufferScan = Value;
  919. }
  920. int
  921. CheckBuffer (
  922. IN void PAPI * Buffer,
  923. IN unsigned long BufferLength
  924. )
  925. /*++
  926. Routine Description:
  927. We need to check that the correct bytes were sent. We do not check
  928. the length of the buffer.
  929. Arguments:
  930. Buffer - Supplies the buffer to be checked.
  931. BufferLength - Supplies the length of the buffer to be checked.
  932. Return Value:
  933. A value of zero will be returned if the buffer contains the correct
  934. bytes; otherwise, non-zero will be returned.
  935. --*/
  936. {
  937. unsigned long PAPI * Length;
  938. unsigned char PAPI * BufferScan;
  939. unsigned char Value;
  940. Length = (unsigned long PAPI *) Buffer;
  941. for (BufferScan = (unsigned char PAPI *) (Length + 1),
  942. Value = *BufferScan, BufferLength -= 4;
  943. BufferLength > 0; BufferLength--, BufferScan++, Value++)
  944. {
  945. if (*BufferScan != Value)
  946. {
  947. return(1);
  948. }
  949. }
  950. return(0);
  951. }
  952. int
  953. CheckInitialBuffer (
  954. IN void PAPI * Buffer,
  955. IN unsigned long BufferLength,
  956. OUT unsigned char * pNextValue
  957. )
  958. /*++
  959. Routine Description:
  960. We need to check that the correct bytes were sent. We do not check
  961. the length of the buffer.
  962. Arguments:
  963. Buffer - Supplies the buffer to be checked.
  964. BufferLength - Supplies the length of the buffer to be checked.
  965. Return Value:
  966. A value of zero will be returned if the buffer contains the correct
  967. bytes; otherwise, non-zero will be returned.
  968. --*/
  969. {
  970. unsigned long PAPI * Length;
  971. unsigned char PAPI * BufferScan;
  972. unsigned char Value;
  973. Length = (unsigned long PAPI *) Buffer;
  974. for (BufferScan = (unsigned char PAPI *) (Length + 1),
  975. Value = *BufferScan, BufferLength -= 4;
  976. BufferLength > 0; BufferLength--, BufferScan++, Value++)
  977. {
  978. if (*BufferScan != Value)
  979. {
  980. return(1);
  981. }
  982. }
  983. *pNextValue = Value;
  984. return(0);
  985. }
  986. int
  987. CheckContinuedBuffer (
  988. IN void PAPI * Buffer,
  989. IN unsigned long BufferLength,
  990. IN unsigned char BeginningValue,
  991. OUT unsigned char * pNextValue
  992. )
  993. /*++
  994. Routine Description:
  995. We need to check that the correct bytes were sent. We do not check
  996. the length of the buffer.
  997. Arguments:
  998. Buffer - Supplies the buffer to be checked.
  999. BufferLength - Supplies the length of the buffer to be checked.
  1000. Return Value:
  1001. A value of zero will be returned if the buffer contains the correct
  1002. bytes; otherwise, non-zero will be returned.
  1003. *pValue
  1004. --*/
  1005. {
  1006. unsigned long PAPI * Length;
  1007. unsigned char PAPI * BufferScan;
  1008. unsigned char Value;
  1009. for (BufferScan = (unsigned char PAPI *) Buffer, Value = BeginningValue;
  1010. BufferLength > 0;
  1011. BufferLength--, BufferScan++, Value++)
  1012. {
  1013. if (*BufferScan != Value)
  1014. {
  1015. return(1);
  1016. }
  1017. }
  1018. *pNextValue = Value;
  1019. return(0);
  1020. }
  1021. extern RPC_DISPATCH_TABLE HelgaDispatchTable;
  1022. RPC_PROTSEQ_ENDPOINT HelgaRpcProtseqEndpoint[] =
  1023. {
  1024. {(unsigned char *) "ncacn_np",
  1025. #ifdef WIN32RPC
  1026. (unsigned char *) "\\pipe\\zippyhe"},
  1027. #else // WIN32RPC
  1028. (unsigned char *) "\\device\\namedpipe\\christopherhelga"},
  1029. #endif // WIN32RPC
  1030. {(unsigned char *) "ncacn_ip_tcp", (unsigned char *) "2039"},
  1031. {(unsigned char *) "ncadg_ip_udp", (unsigned char *) "2039"},
  1032. {(unsigned char *) "ncalrpc", (unsigned char *) "christopherhelga"},
  1033. {(unsigned char *) "ncacn_nb_nb", (unsigned char *) "211"},
  1034. {(unsigned char *) "ncacn_spx", (unsigned char *) "5014"},
  1035. {(unsigned char *) "ncadg_ipx", (unsigned char *) "5014"},
  1036. {(unsigned char *) "ncacn_vns_spp", (unsigned char *) "264"},
  1037. {(unsigned char *) "ncacn_at_dsp",(unsigned char *) "\\pipe\\zippyhe"},
  1038. {(unsigned char *) "ncadg_mq",(unsigned char *) "christopherhelga"}
  1039. };
  1040. RPC_SERVER_INTERFACE HelgaInterfaceInformation =
  1041. {
  1042. sizeof(RPC_SERVER_INTERFACE),
  1043. {{1,2,2,{3,3,3,3,3,3,3,3}},
  1044. {1,1}},
  1045. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  1046. {2, 0}},
  1047. &HelgaDispatchTable,
  1048. sizeof(HelgaRpcProtseqEndpoint) / sizeof(RPC_PROTSEQ_ENDPOINT),
  1049. HelgaRpcProtseqEndpoint,
  1050. NULL,
  1051. NULL,
  1052. RPC_INTERFACE_HAS_PIPES
  1053. };
  1054. void __RPC_STUB
  1055. HelgaStub (
  1056. PRPC_MESSAGE Callee
  1057. )
  1058. {
  1059. UUID ObjectUuid;
  1060. CompleteReceive(Callee) ;
  1061. if ( HelgaCheckObject != 0 )
  1062. {
  1063. Status = RpcBindingInqObject(Callee->Handle, &ObjectUuid);
  1064. if (Status)
  1065. {
  1066. ApiError("HelgaStub", "RpcBindingInqObject", Status);
  1067. HelgaError();
  1068. }
  1069. else if ( CheckUuidValue(HelgaMagicNumber, &ObjectUuid) != 0 )
  1070. {
  1071. OtherError("HelgaStub", "CheckUuidValue() != 0");
  1072. HelgaError();
  1073. }
  1074. Status = RpcBindingInqObject(0, &ObjectUuid); // zero handle
  1075. if (Status)
  1076. {
  1077. ApiError("HelgaStub", "RpcBindingInqObject", Status);
  1078. HelgaError();
  1079. }
  1080. else if ( CheckUuidValue(HelgaMagicNumber, &ObjectUuid) != 0 )
  1081. {
  1082. OtherError("HelgaStub", "CheckUuidValue() != 0");
  1083. HelgaError();
  1084. }
  1085. }
  1086. HelgaMagicNumber += 1;
  1087. if ( Callee->ProcNum != 0 )
  1088. {
  1089. OtherError("HelgaStub", "Callee->ProcNum != 0");
  1090. HelgaError();
  1091. }
  1092. if ( memcmp(Callee->RpcInterfaceInformation, &HelgaInterfaceInformation,
  1093. sizeof(HelgaInterfaceInformation)) != 0 )
  1094. {
  1095. OtherError("HelgaStub",
  1096. "Callee->RpcInteraceInformation != &HelgaInterfaceInformation");
  1097. HelgaError();
  1098. }
  1099. if ( HelgaCheckManagerEpv != 0 )
  1100. {
  1101. if ( Callee->ManagerEpv != HelgaManagerEpv )
  1102. {
  1103. OtherError("HelgaStub", "Callee->ManagerEpv != HelgaManagerEpv");
  1104. HelgaError();
  1105. }
  1106. }
  1107. if (Callee->BufferLength != 0)
  1108. {
  1109. OtherError("HelgaStub","*BufferLength != 0");
  1110. HelgaError();
  1111. }
  1112. Callee->BufferLength = 0;
  1113. Status = I_RpcGetBuffer(Callee);
  1114. if (Status)
  1115. {
  1116. ApiError("HelgaStub","I_RpcGetBuffer",Status);
  1117. HelgaError();
  1118. }
  1119. }
  1120. void __RPC_STUB
  1121. HelgaINStub (
  1122. PRPC_MESSAGE Callee
  1123. )
  1124. {
  1125. unsigned long Length;
  1126. UUID ObjectUuid;
  1127. if ( HelgaCheckObject != 0 )
  1128. {
  1129. Status = RpcBindingInqObject(Callee->Handle, &ObjectUuid);
  1130. if (Status)
  1131. {
  1132. ApiError("HelgaINStub", "RpcBindingInqObject", Status);
  1133. HelgaError();
  1134. }
  1135. else if ( CheckUuidValue(HelgaMagicNumber, &ObjectUuid) != 0 )
  1136. {
  1137. OtherError("HelgaINStub", "CheckUuidValue() != 0");
  1138. HelgaError();
  1139. }
  1140. }
  1141. HelgaMagicNumber += 1;
  1142. if ( Callee->ProcNum != 1 )
  1143. {
  1144. OtherError("HelgaINStub", "Callee->ProcNum != 0");
  1145. HelgaError();
  1146. }
  1147. if ( memcmp(Callee->RpcInterfaceInformation, &HelgaInterfaceInformation,
  1148. sizeof(HelgaInterfaceInformation)) != 0 )
  1149. {
  1150. OtherError("HelgaINStub",
  1151. "Callee->RpcInteraceInformation != &HelgaInterfaceInformation");
  1152. HelgaError();
  1153. }
  1154. if ( HelgaCheckManagerEpv != 0 )
  1155. {
  1156. if ( Callee->ManagerEpv != HelgaManagerEpv )
  1157. {
  1158. OtherError("HelgaINStub", "Callee->ManagerEpv != HelgaManagerEpv");
  1159. HelgaError();
  1160. }
  1161. }
  1162. //
  1163. // Check the data we have so far.
  1164. //
  1165. Length = *(unsigned long *) Callee->Buffer;
  1166. if (Length < Callee->BufferLength)
  1167. {
  1168. OtherError("HelgaINStub","*Length < *BufferLength");
  1169. HelgaError();
  1170. }
  1171. if (0 == (Callee->RpcFlags & RPC_BUFFER_COMPLETE))
  1172. {
  1173. CompleteReceive(Callee) ;
  1174. }
  1175. if (Length != Callee->BufferLength)
  1176. {
  1177. OtherError("HelgaINStub","incomplete buffer marked as complete");
  1178. HelgaError();
  1179. }
  1180. unsigned char InitialValue;
  1181. if (CheckInitialBuffer(Callee->Buffer, Callee->BufferLength, &InitialValue) != 0)
  1182. {
  1183. OtherError("HelgaINStub","CheckBuffer Failed");
  1184. HelgaError();
  1185. }
  1186. //
  1187. // The [out] buffer.
  1188. //
  1189. Callee->BufferLength = 0;
  1190. Status = I_RpcGetBuffer(Callee);
  1191. if (Status)
  1192. {
  1193. ApiError("HelgaINStub","I_RpcGetBuffer",Status);
  1194. HelgaError();
  1195. }
  1196. }
  1197. void __RPC_STUB
  1198. HelgaOUTStub (
  1199. PRPC_MESSAGE Callee
  1200. )
  1201. {
  1202. unsigned long * Length;
  1203. unsigned int Size;
  1204. UUID ObjectUuid;
  1205. CompleteReceive(Callee) ;
  1206. if ( HelgaCheckObject != 0 )
  1207. {
  1208. Status = RpcBindingInqObject(Callee->Handle, &ObjectUuid);
  1209. if (Status)
  1210. {
  1211. ApiError("HelgaOUTStub", "RpcBindingInqObject", Status);
  1212. HelgaError();
  1213. }
  1214. else if ( CheckUuidValue(HelgaMagicNumber, &ObjectUuid) != 0 )
  1215. {
  1216. OtherError("HelgaOUTStub", "CheckUuidValue() != 0");
  1217. HelgaError();
  1218. }
  1219. }
  1220. HelgaMagicNumber += 1;
  1221. if ( Callee->ProcNum != 2 )
  1222. {
  1223. OtherError("HelgaOUTStub", "Callee->ProcNum != 0");
  1224. HelgaError();
  1225. }
  1226. if ( memcmp(Callee->RpcInterfaceInformation, &HelgaInterfaceInformation,
  1227. sizeof(HelgaInterfaceInformation)) != 0 )
  1228. {
  1229. OtherError("HelgaOUTStub",
  1230. "Callee->RpcInteraceInformation != &HelgaInterfaceInformation");
  1231. HelgaError();
  1232. }
  1233. if ( HelgaCheckManagerEpv != 0 )
  1234. {
  1235. if ( Callee->ManagerEpv != HelgaManagerEpv )
  1236. {
  1237. OtherError("HelgaOUTStub", "Callee->ManagerEpv != HelgaManagerEpv");
  1238. HelgaError();
  1239. }
  1240. }
  1241. if (Callee->BufferLength != sizeof(unsigned long))
  1242. {
  1243. //
  1244. // secure datagram calls round the stub data length to a multiple
  1245. // of eight.
  1246. //
  1247. if (!DatagramFlag || Callee->BufferLength != 8)
  1248. {
  1249. OtherError("HelgaOUTStub","*BufferLength != sizeof(unsigned int)");
  1250. HelgaError();
  1251. }
  1252. }
  1253. Length = (unsigned long *) Callee->Buffer;
  1254. Size = (unsigned int) *Length;
  1255. Callee->BufferLength = Size;
  1256. Status = I_RpcGetBuffer(Callee);
  1257. if (Status)
  1258. {
  1259. ApiError("HelgaOUTStub","I_RpcGetBuffer",Status);
  1260. HelgaError();
  1261. }
  1262. else
  1263. {
  1264. InitializeBuffer(Callee->Buffer, Size);
  1265. }
  1266. }
  1267. void __RPC_STUB
  1268. HelgaINOUTStub (
  1269. PRPC_MESSAGE Callee
  1270. )
  1271. {
  1272. unsigned long Length;
  1273. UUID ObjectUuid;
  1274. if ( HelgaCheckObject != 0 )
  1275. {
  1276. Status = RpcBindingInqObject(Callee->Handle, &ObjectUuid);
  1277. if (Status)
  1278. {
  1279. ApiError("HelgaINOUTStub", "RpcBindingInqObject", Status);
  1280. HelgaError();
  1281. }
  1282. else if ( CheckUuidValue(HelgaMagicNumber, &ObjectUuid) != 0 )
  1283. {
  1284. OtherError("HelgaINOUTStub", "CheckUuidValue() != 0");
  1285. HelgaError();
  1286. }
  1287. }
  1288. HelgaMagicNumber += 1;
  1289. if ( Callee->ProcNum != 3 )
  1290. {
  1291. OtherError("HelgaINOUTStub", "Callee->ProcNum != 0");
  1292. HelgaError();
  1293. }
  1294. if ( memcmp(Callee->RpcInterfaceInformation, &HelgaInterfaceInformation,
  1295. sizeof(HelgaInterfaceInformation)) != 0 )
  1296. {
  1297. OtherError("HelgaINOUTStub",
  1298. "Callee->RpcInteraceInformation != &HelgaInterfaceInformation");
  1299. HelgaError();
  1300. }
  1301. if ( HelgaCheckManagerEpv != 0 )
  1302. {
  1303. if ( Callee->ManagerEpv != HelgaManagerEpv )
  1304. {
  1305. OtherError("HelgaINOUTStub",
  1306. "Callee->ManagerEpv != HelgaManagerEpv");
  1307. HelgaError();
  1308. }
  1309. }
  1310. //
  1311. // Check the data we have so far.
  1312. //
  1313. Length = *(unsigned long *) Callee->Buffer;
  1314. if (Length < Callee->BufferLength)
  1315. {
  1316. OtherError("HelgaINOUTStub","*Length < *BufferLength");
  1317. HelgaError();
  1318. }
  1319. unsigned char InitialValue;
  1320. if (CheckInitialBuffer(Callee->Buffer, Callee->BufferLength, &InitialValue) != 0)
  1321. {
  1322. OtherError("HelgaINOUTStub","initial CheckBuffer Failed");
  1323. HelgaError();
  1324. }
  1325. if (Length > Callee->BufferLength)
  1326. {
  1327. if (Callee->RpcFlags & RPC_BUFFER_COMPLETE)
  1328. {
  1329. OtherError("HelgaINOUTStub","incomplete buffer marked as complete");
  1330. HelgaError();
  1331. }
  1332. }
  1333. if (0 == (Callee->RpcFlags & RPC_BUFFER_COMPLETE))
  1334. {
  1335. //
  1336. // Get the rest of the data and check it.
  1337. //
  1338. CompleteReceive(Callee) ;
  1339. if (0 != CheckInitialBuffer(Callee->Buffer, Callee->BufferLength, &InitialValue))
  1340. {
  1341. OtherError("HelgaINOUTStub","second CheckBuffer Failed");
  1342. HelgaError();
  1343. }
  1344. }
  1345. Callee->BufferLength = Length;
  1346. Status = I_RpcGetBuffer(Callee);
  1347. if (Status)
  1348. {
  1349. ApiError("HelgaINOUTStub","I_RpcGetBuffer",Status);
  1350. HelgaError();
  1351. }
  1352. else
  1353. {
  1354. InitializeBuffer(Callee->Buffer, Length);
  1355. }
  1356. }
  1357. void Synchro(
  1358. PRPC_MESSAGE Callee
  1359. )
  1360. {
  1361. PrintToConsole("Sychro called\n") ;
  1362. RpcServerYield();
  1363. }
  1364. void SvrLazyFunc(
  1365. PRPC_MESSAGE Callee
  1366. )
  1367. {
  1368. PrintToConsole("About to sleep\n") ;
  1369. PauseExecution(100000) ;
  1370. PrintToConsole("Waking up\n") ;
  1371. Shutdown() ;
  1372. }
  1373. void HelgaLpcSecurity(
  1374. PRPC_MESSAGE Callee
  1375. )
  1376. {
  1377. RPC_STATUS RpcStatus ;
  1378. RPC_CHAR *UserName ;
  1379. PrintToConsole("HelgaLpcSecurity\n") ;
  1380. RpcStatus = RpcBindingInqAuthClient(Callee->Handle, (void **) &UserName,
  1381. NULL, NULL, NULL, NULL) ;
  1382. if ((RpcStatus != RPC_S_OK) && (RpcStatus != RPC_S_BINDING_HAS_NO_AUTH))
  1383. {
  1384. HelgaError() ;
  1385. PrintToConsole("HelgaLpcSecurity: (1) UserName: %S\n", UserName) ;
  1386. }
  1387. UserName = NULL ;
  1388. RpcStatus = RpcBindingInqAuthClient(Callee->Handle, (void **) &UserName,
  1389. NULL, NULL, NULL, NULL) ;
  1390. if ((RpcStatus != RPC_S_OK) && (RpcStatus != RPC_S_BINDING_HAS_NO_AUTH))
  1391. {
  1392. HelgaError() ;
  1393. PrintToConsole("HelgaLpcSecurity: (2) UserName: %S\n", UserName) ;
  1394. }
  1395. }
  1396. void
  1397. HelgaObjectUuids (
  1398. PRPC_MESSAGE Callee
  1399. )
  1400. {
  1401. PrintToConsole("HelgaObjectUuids\n") ;
  1402. char *Ptr = (char *) Callee->Buffer;
  1403. BOOL fObjectUuid = *((BOOL *) Ptr);
  1404. UUID MyObjectUuid;
  1405. Status = RpcBindingInqObject(Callee->Handle, &MyObjectUuid);
  1406. if (Status)
  1407. {
  1408. ApiError("HelgaStub", "RpcBindingInqObject", Status);
  1409. HelgaError();
  1410. RpcRaiseException(Status);
  1411. }
  1412. UUID Uuid;
  1413. Ptr += sizeof(BOOL);
  1414. if (fObjectUuid)
  1415. {
  1416. RpcpMemoryCopy(&Uuid, Ptr, sizeof(UUID));
  1417. }
  1418. else
  1419. {
  1420. RpcpMemorySet(&Uuid, 0, sizeof(UUID));
  1421. }
  1422. if (RpcpMemoryCompare(&Uuid, &MyObjectUuid, sizeof(UUID)))
  1423. {
  1424. HelgaError();
  1425. RpcRaiseException(-1);
  1426. }
  1427. Callee->BufferLength = 0;
  1428. Status = I_RpcGetBuffer(Callee);
  1429. if (Status)
  1430. {
  1431. ApiError("HelgaStub","I_RpcGetBuffer",Status);
  1432. HelgaError();
  1433. RpcRaiseException(Status);
  1434. }
  1435. }
  1436. void
  1437. HelgaConnId (
  1438. PRPC_MESSAGE Callee
  1439. )
  1440. {
  1441. PrintToConsole("HelgaConnId\n") ;
  1442. static void *OldId = 0;
  1443. void *ConnId;
  1444. BOOL fFirstTime;
  1445. Status = I_RpcBindingInqConnId(
  1446. Callee->Handle,
  1447. &ConnId,
  1448. &fFirstTime);
  1449. if (Status)
  1450. {
  1451. HelgaError();
  1452. ApiError("HelgaStub","I_RpcBindingInqConnId",Status);
  1453. RpcRaiseException(Status);
  1454. }
  1455. PrintToConsole("HelgaConnId: ConnId: %p, fFirstTime: %d\n", ConnId, fFirstTime);
  1456. char *Ptr = (char *) Callee->Buffer;
  1457. BOOL fNewConnExpected = *((BOOL *) Ptr);
  1458. if (fNewConnExpected != fFirstTime)
  1459. {
  1460. HelgaError();
  1461. RpcRaiseException(-1);
  1462. }
  1463. if (fFirstTime)
  1464. {
  1465. OldId = ConnId;
  1466. }
  1467. else
  1468. {
  1469. if (ConnId != OldId)
  1470. {
  1471. HelgaError();
  1472. RpcRaiseException(-1);
  1473. }
  1474. }
  1475. Callee->BufferLength = 0;
  1476. Status = I_RpcGetBuffer(Callee);
  1477. if (Status)
  1478. {
  1479. ApiError("HelgaStub","I_RpcGetBuffer",Status);
  1480. HelgaError();
  1481. RpcRaiseException(Status);
  1482. }
  1483. }
  1484. typedef struct _WIRE_CONTEXT
  1485. {
  1486. unsigned long ContextType;
  1487. UUID ContextUuid;
  1488. } WIRE_CONTEXT;
  1489. void UsvrRundown (
  1490. void *Context
  1491. )
  1492. {
  1493. PrintToConsole("UsvrRundown called");
  1494. }
  1495. // partial replica of SCONTEXTItem in scontext.cxx
  1496. typedef struct tagUserContext
  1497. {
  1498. void *R1;
  1499. void *R2;
  1500. void * userContext; /* context for the user */
  1501. } UserContext;
  1502. // the buffer should be of type and size WIRE_CONTEXT
  1503. void OpenContextHandle (
  1504. RPC_MESSAGE *Callee
  1505. )
  1506. {
  1507. void *pGuard;
  1508. RPC_SERVER_INTERFACE *ServerIf;
  1509. RPC_STATUS RpcStatus;
  1510. void *Context;
  1511. WIRE_CONTEXT WireContext;
  1512. ASSERT(Callee->BufferLength == sizeof(WIRE_CONTEXT));
  1513. if (Callee->ProcNum == 21)
  1514. {
  1515. ServerIf = &IsabelleInterfaceInformation;
  1516. }
  1517. else if (Callee->ProcNum == 10)
  1518. {
  1519. ServerIf = &HelgaInterfaceInformation;
  1520. }
  1521. else
  1522. {
  1523. ASSERT(0);
  1524. }
  1525. pGuard = &ServerIf->InterfaceId;
  1526. Context = NDRSContextUnmarshall2(Callee->Handle,
  1527. Callee->Buffer,
  1528. 10,
  1529. pGuard,
  1530. 0);
  1531. ((UserContext *)Context)->userContext = pGuard;
  1532. Callee->BufferLength = 0;
  1533. RpcStatus = I_RpcGetBuffer(Callee);
  1534. if (RpcStatus != RPC_S_OK)
  1535. {
  1536. ApiError("Get Buffer", "I_RpcGetBuffer", Status) ;
  1537. return ;
  1538. }
  1539. NDRSContextMarshall2(Callee->Handle,
  1540. (NDR_SCONTEXT)Context,
  1541. &WireContext,
  1542. UsvrRundown,
  1543. pGuard,
  1544. 0);
  1545. }
  1546. extern void
  1547. Foo_s (
  1548. PRPC_MESSAGE Message
  1549. ) ;
  1550. extern void
  1551. FooPipe_s (
  1552. PRPC_MESSAGE Message
  1553. ) ;
  1554. extern void
  1555. FooBar_s (
  1556. PRPC_MESSAGE Message
  1557. ) ;
  1558. void
  1559. FooCH_s (
  1560. PRPC_MESSAGE Message
  1561. ) ;
  1562. RPC_DISPATCH_FUNCTION HelgaDispatchFunctions[] =
  1563. {
  1564. HelgaStub,
  1565. HelgaINStub,
  1566. HelgaOUTStub,
  1567. HelgaINOUTStub,
  1568. Synchro,
  1569. SvrLazyFunc,
  1570. HelgaLpcSecurity,
  1571. Foo_s,
  1572. HelgaObjectUuids,
  1573. HelgaConnId,
  1574. OpenContextHandle
  1575. };
  1576. RPC_DISPATCH_TABLE HelgaDispatchTable =
  1577. {
  1578. 11, HelgaDispatchFunctions
  1579. };
  1580. /* --------------------------------------------------------------------
  1581. Sylvia Interface
  1582. -------------------------------------------------------------------- */
  1583. extern RPC_DISPATCH_TABLE SylviaDispatchTable;
  1584. RPC_SERVER_INTERFACE SylviaInterfaceInformation =
  1585. {
  1586. sizeof(RPC_SERVER_INTERFACE),
  1587. {{3,2,2,{1,1,1,1,1,1,1,1}},
  1588. {1,1}},
  1589. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  1590. {2, 0}},
  1591. &SylviaDispatchTable,
  1592. 0,
  1593. 0,
  1594. 0,
  1595. 0,
  1596. RPC_INTERFACE_HAS_PIPES
  1597. };
  1598. unsigned int SylviaQueryBinding = 0;
  1599. unsigned int SylviaQueryProtocolStack = 0;
  1600. unsigned int SylviaQueryCall = 0;
  1601. char * SylviaTransportInfo = 0;
  1602. unsigned /*int*/ char // Specifies the new count of calls.
  1603. SylviaCallback (
  1604. unsigned /*long*/ char Depth, // Specifies the depth of recursion desired.
  1605. unsigned /*long*/ char Breadth, // Specifies the breadth desired.
  1606. unsigned /*long*/ char Count // Specifies the count of calls up to this point.
  1607. )
  1608. {
  1609. RPC_MESSAGE Caller;
  1610. unsigned /*long*/ char * plScan, ReturnValue;
  1611. Caller.ProcNum = 0;
  1612. Caller.Handle = I_RpcGetCurrentCallHandle();
  1613. if (Caller.Handle == (RPC_BINDING_HANDLE) 0)
  1614. {
  1615. OtherError("SylviaCallback","Call == (RPC_BINDING_HANDLE) 0");
  1616. SylviaError();
  1617. return(0);
  1618. }
  1619. Caller.BufferLength = sizeof(unsigned /*long*/ char)*4+10240;
  1620. Status = I_RpcGetBuffer(&Caller);
  1621. if (Status)
  1622. {
  1623. ApiError("SylviaCallback","I_RpcGetBuffer",Status);
  1624. SylviaError();
  1625. return(0);
  1626. }
  1627. plScan = (unsigned /*long*/ char *) Caller.Buffer;
  1628. plScan[0] = (unsigned char) Depth;
  1629. plScan[1] = (unsigned char) Breadth;
  1630. plScan[2] = (unsigned char) Count;
  1631. Status = I_RpcSendReceive(&Caller);
  1632. if (Status)
  1633. {
  1634. ApiError("SylviaCallback","I_RpcSendReceive",Status);
  1635. SylviaError();
  1636. return(0);
  1637. }
  1638. plScan = (unsigned /*long*/ char *) Caller.Buffer;
  1639. ReturnValue = *plScan;
  1640. Status = I_RpcFreeBuffer(&Caller);
  1641. if (Status)
  1642. {
  1643. ApiError("SylviaCallback","I_RpcFreeBuffer",Status);
  1644. SylviaError();
  1645. return(0);
  1646. }
  1647. return(ReturnValue);
  1648. }
  1649. unsigned /*long*/ char
  1650. SylviaCallUserCode ( // The user code for SylviaCall.
  1651. unsigned /*long*/ char Depth,
  1652. unsigned /*long*/ char Breadth,
  1653. unsigned /*long*/ char Count
  1654. )
  1655. {
  1656. if (Depth > 0)
  1657. {
  1658. if (Depth == Breadth)
  1659. {
  1660. Count = SylviaCallUserCode(Depth-1,Breadth,Count);
  1661. }
  1662. else
  1663. Count = SylviaCallback(Depth-1,Breadth,Count);
  1664. }
  1665. return(Count+1);
  1666. }
  1667. void __RPC_STUB
  1668. SylviaCall (
  1669. PRPC_MESSAGE Callee
  1670. )
  1671. {
  1672. unsigned /*long*/ char ReturnValue, *plScan;
  1673. if ( Callee->ProcNum != 0 )
  1674. {
  1675. OtherError("SylviaCall", "Callee->ProcNum != 0");
  1676. SylviaError();
  1677. }
  1678. if ( memcmp(Callee->RpcInterfaceInformation, &SylviaInterfaceInformation,
  1679. sizeof(SylviaInterfaceInformation)) != 0 )
  1680. {
  1681. OtherError("SylviaCall",
  1682. "Callee->RpcInteraceInformation != &SylviaInterfaceInformation");
  1683. SylviaError();
  1684. }
  1685. if (Callee->BufferLength != sizeof(unsigned /*long*/ char)*4+10240)
  1686. {
  1687. OtherError("SylviaCall","*BufferLength != sizeof(unsigned char)*4");
  1688. SylviaError();
  1689. }
  1690. plScan = (unsigned /*long*/ char *) Callee->Buffer;
  1691. // if ( SylviaQueryCall
  1692. // && VerifyQueryCall(Callee->Handle,&SylviaProtocolStack))
  1693. // {
  1694. // OtherError("SylviaCallback","VerifyQueryCall");
  1695. // SylviaError();
  1696. // }
  1697. // if ( SylviaQueryBinding
  1698. // && VerifyQueryBinding(Callee->Handle,SylviaServer))
  1699. // {
  1700. // OtherError("SylviaCallback","VerifyQueryBinding");
  1701. // SylviaError();
  1702. // }
  1703. // if ( SylviaQueryProtocolStack
  1704. // && VerifyQueryProtocolStack(Callee->Handle,&SylviaProtocolStack,
  1705. // SylviaTransportInfo))
  1706. // {
  1707. // OtherError("SylviaCallback","VerifyQueryProtocolStack");
  1708. // SylviaError();
  1709. // }
  1710. ReturnValue = (unsigned char) SylviaCallUserCode(plScan[0],plScan[1],plScan[2]);
  1711. // if ( SylviaQueryCall
  1712. // && VerifyQueryCall(Callee->Handle,&SylviaProtocolStack))
  1713. // {
  1714. // OtherError("SylviaCallback","VerifyQueryCall");
  1715. // SylviaError();
  1716. // }
  1717. // if ( SylviaQueryBinding
  1718. // && VerifyQueryBinding(Callee->Handle,SylviaServer))
  1719. // {
  1720. // OtherError("SylviaCallback","VerifyQueryBinding");
  1721. // SylviaError();
  1722. // }
  1723. // if ( SylviaQueryProtocolStack
  1724. // && VerifyQueryProtocolStack(Callee->Handle,&SylviaProtocolStack,
  1725. // SylviaTransportInfo))
  1726. // {
  1727. // OtherError("SylviaCallback","VerifyQueryProtocolStack");
  1728. // SylviaError();
  1729. // }
  1730. Callee->BufferLength = sizeof(unsigned /*long*/ char);
  1731. Status = I_RpcGetBuffer((PRPC_MESSAGE) Callee);
  1732. if (Status)
  1733. {
  1734. ApiError("SylviaCall","I_RpcGetBuffer",Status);
  1735. SylviaError();
  1736. }
  1737. plScan = (unsigned /*long*/ char *) Callee->Buffer;
  1738. *plScan = ReturnValue;
  1739. }
  1740. RPC_DISPATCH_FUNCTION SylviaDispatchFunction[] = {SylviaCall};
  1741. RPC_DISPATCH_TABLE SylviaDispatchTable =
  1742. {
  1743. 1, SylviaDispatchFunction
  1744. };
  1745. /* --------------------------------------------------------------------
  1746. Isabelle Interface
  1747. -------------------------------------------------------------------- */
  1748. extern RPC_DISPATCH_TABLE IsabelleDispatchTable;
  1749. RPC_PROTSEQ_ENDPOINT IsabelleRpcProtseqEndpoint[] =
  1750. {
  1751. {(unsigned char *) "ncacn_np",
  1752. #ifdef WIN32RPC
  1753. (unsigned char *) "\\pipe\\zippyis"},
  1754. #else // WIN32RPC
  1755. (unsigned char *) "\\device\\namedpipe\\christopherisabelle"},
  1756. #endif // WIN32RPC
  1757. {(unsigned char *) "ncacn_ip_tcp",(unsigned char *) "2040"},
  1758. {(unsigned char *) "ncadg_ip_udp",(unsigned char *) "2040"},
  1759. {(unsigned char *) "ncalrpc",(unsigned char *) "christopherisabelle"},
  1760. {(unsigned char *) "ncacn_nb_nb",(unsigned char *) "212"},
  1761. {(unsigned char *) "ncacn_nb_tcp",(unsigned char *) "213"},
  1762. {(unsigned char *) "ncacn_nb_ipx",(unsigned char *) "214"},
  1763. {(unsigned char *) "ncacn_spx",(unsigned char *) "5015"},
  1764. {(unsigned char *) "ncadg_ipx",(unsigned char *) "5015"},
  1765. {(unsigned char *) "ncacn_vns_spp",(unsigned char *) "265"},
  1766. {(unsigned char *) "ncacn_at_dsp", (unsigned char *) "\\pipe\\zippyis"},
  1767. {(unsigned char *) "ncadg_mq", (unsigned char *) "christopherisabelle"}
  1768. };
  1769. RPC_SERVER_INTERFACE IsabelleInterfaceInformation =
  1770. {
  1771. sizeof(RPC_SERVER_INTERFACE),
  1772. {{9,8,8,{7,7,7,7,7,7,7,7}},
  1773. {1,1}},
  1774. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  1775. {2, 0}},
  1776. &IsabelleDispatchTable,
  1777. sizeof(IsabelleRpcProtseqEndpoint) / sizeof(RPC_PROTSEQ_ENDPOINT),
  1778. IsabelleRpcProtseqEndpoint,
  1779. 0,
  1780. 0,
  1781. RPC_INTERFACE_HAS_PIPES
  1782. };
  1783. void __RPC_STUB
  1784. IsabelleShutdown (
  1785. PRPC_MESSAGE Callee
  1786. )
  1787. {
  1788. RPC_BINDING_HANDLE BindingHandle;
  1789. unsigned char PAPI * StringBinding;
  1790. unsigned int ClientLocalFlag = 0;
  1791. RPC_STATUS IsClientLocalStatus;
  1792. CompleteReceive(Callee) ;
  1793. Status = I_RpcBindingIsClientLocal(0, &ClientLocalFlag);
  1794. if ( (IsClientLocalStatus = Status) != RPC_S_CANNOT_SUPPORT )
  1795. {
  1796. if ( Status != RPC_S_OK )
  1797. {
  1798. ApiError("IsabelleShutdown", "I_RpcBindingIsClientLocal", Status);
  1799. IsabelleError();
  1800. }
  1801. }
  1802. if (Callee->BufferLength != 0)
  1803. {
  1804. OtherError("IsabelleShutdown","*BufferLength != 0");
  1805. IsabelleError();
  1806. }
  1807. if (AutoListenFlag == 0)
  1808. {
  1809. Status = RpcMgmtIsServerListening(0);
  1810. if (Status)
  1811. {
  1812. ApiError("IsabelleShutdown", "RpcMgmtIsServerListening", Status);
  1813. IsabelleError();
  1814. }
  1815. }
  1816. Status = RpcBindingServerFromClient(Callee->Handle, &BindingHandle);
  1817. if (Status)
  1818. {
  1819. if ( Status != RPC_S_CANNOT_SUPPORT && (DatagramFlag == 0) )
  1820. {
  1821. ApiError("IsabelleShutdown", "RpcBindingServerFromClient", Status);
  1822. IsabelleError();
  1823. }
  1824. if(IsClientLocalStatus == RPC_S_OK)
  1825. {
  1826. if ( ClientLocalFlag != 0 )
  1827. PrintToConsole("Local Client\n");
  1828. else
  1829. PrintToConsole("Remote Client\n");
  1830. }
  1831. }
  1832. else
  1833. {
  1834. Status = RpcBindingToStringBindingA(BindingHandle, &StringBinding);
  1835. if (Status)
  1836. {
  1837. ApiError("IsabelleShutdown", "RpcBindingToStringBinding", Status);
  1838. IsabelleError();
  1839. }
  1840. else
  1841. {
  1842. if ( ClientLocalFlag != 0 )
  1843. {
  1844. PrintToConsole("Local Client [%s]\n", StringBinding);
  1845. }
  1846. else
  1847. {
  1848. PrintToConsole("Remote Client [%s]\n", StringBinding);
  1849. }
  1850. RpcStringFreeA(&StringBinding);
  1851. RpcBindingFree(&BindingHandle);
  1852. }
  1853. }
  1854. Shutdown();
  1855. Callee->BufferLength = 0;
  1856. Status = I_RpcGetBuffer(Callee);
  1857. if (Status)
  1858. {
  1859. ApiError("IsabelleShutdown","I_RpcGetBuffer",Status);
  1860. IsabelleError();
  1861. }
  1862. }
  1863. void __RPC_STUB
  1864. IsabelleNtSecurity (
  1865. PRPC_MESSAGE CalleeMessage
  1866. )
  1867. /*++
  1868. Routine Description:
  1869. A client will call this routine with some quality of service
  1870. specified. The server will impersonate the client and check
  1871. that the impersonation level is that specified. The request
  1872. buffer will contain the network options passed by the client
  1873. to RpcBindingFromStringBinding.
  1874. Arguments:
  1875. CalleeMessage - Supplies the request message and returns the
  1876. response message for the remote procedure call.
  1877. --*/
  1878. {
  1879. RPC_STATUS Status;
  1880. Status = RpcImpersonateClient(0);
  1881. if (Status != RPC_S_OK)
  1882. {
  1883. ApiError("IsabelleNtSecurity","RpcImpersonateClient",Status);
  1884. IsabelleError();
  1885. }
  1886. else
  1887. {
  1888. Status = RpcRevertToSelf();
  1889. if (Status != RPC_S_OK)
  1890. {
  1891. ApiError("IsabelleNtSecurity","RpcRevertToSelf",Status);
  1892. IsabelleError();
  1893. }
  1894. else
  1895. {
  1896. Status = RpcImpersonateClient(CalleeMessage->Handle);
  1897. if (Status != RPC_S_OK)
  1898. {
  1899. ApiError("IsabelleNtSecurity","RpcImpersonateClient",
  1900. Status);
  1901. IsabelleError();
  1902. }
  1903. else
  1904. {
  1905. Status = RpcRevertToSelf();
  1906. if (Status != RPC_S_OK)
  1907. {
  1908. ApiError("IsabelleNtSecurity","RpcRevertToSelf",Status);
  1909. IsabelleError();
  1910. }
  1911. }
  1912. }
  1913. }
  1914. CalleeMessage->BufferLength = 0;
  1915. Status = I_RpcGetBuffer(CalleeMessage);
  1916. if (Status)
  1917. {
  1918. ApiError("IsabelleNtSecurity","I_RpcGetBuffer",Status);
  1919. IsabelleError();
  1920. }
  1921. }
  1922. int ChristopherIsabelleError;
  1923. void __RPC_STUB
  1924. IsabelleToStringBinding (
  1925. PRPC_MESSAGE Callee
  1926. )
  1927. {
  1928. unsigned char PAPI * StringBinding;
  1929. if (Callee->BufferLength != 0)
  1930. {
  1931. OtherError("IsabelleToStringBinding","*BufferLength != 0");
  1932. IsabelleError();
  1933. }
  1934. Status = RpcBindingToStringBindingA(Callee->Handle, &StringBinding);
  1935. if (Status)
  1936. {
  1937. ApiError("Christopher","RpcBindingToStringBinding",Status);
  1938. PrintToConsole("Christopher : FAIL - RpcBindingToStringBinding\n");
  1939. ChristopherIsabelleError = 1;
  1940. }
  1941. else
  1942. {
  1943. PrintToConsole("Christopher : (RpcBindingToStringBinding)\n ");
  1944. PrintToConsole((char *) StringBinding);
  1945. PrintToConsole("\n");
  1946. Status = RpcStringFreeA(&StringBinding);
  1947. if (Status)
  1948. {
  1949. ApiError("Christopher","RpcStringFree",Status);
  1950. PrintToConsole("Christopher : FAIl - RpcStringFree\n");
  1951. ChristopherIsabelleError = 1;
  1952. }
  1953. else
  1954. {
  1955. if (StringBinding != 0)
  1956. {
  1957. PrintToConsole("Christopher : FAIL - ");
  1958. PrintToConsole("StringBinding != 0\n");
  1959. ChristopherIsabelleError = 1;
  1960. }
  1961. }
  1962. }
  1963. Callee->BufferLength = 0;
  1964. Status = I_RpcGetBuffer(Callee);
  1965. if (Status)
  1966. {
  1967. ApiError("Christopher","I_RpcGetBuffer",Status);
  1968. HelgaError();
  1969. }
  1970. }
  1971. #define RICHARDHELPER_EXIT 1
  1972. #define RICHARDHELPER_EXECUTE 2
  1973. #define RICHARDHELPER_IGNORE 3
  1974. #define RICHARDHELPER_DELAY_EXIT 4
  1975. void
  1976. RichardHelperExit (
  1977. void * Ignore
  1978. )
  1979. {
  1980. PauseExecution(2000L);
  1981. PrintToConsole("Richard : RichardHelper Exiting\n");
  1982. #ifdef WIN32RPC
  1983. ExitProcess(0);
  1984. #endif // WIN32RPC
  1985. }
  1986. void __RPC_STUB
  1987. IsabelleRichardHelper (
  1988. PRPC_MESSAGE Callee
  1989. )
  1990. /*++
  1991. Routine Description:
  1992. This routine is the stub (and actually the manager code as well) for
  1993. the IsabelleRichardHelper routine. The client will call a stub and
  1994. specify a command argument which will be passed in the buffer. We
  1995. need to extract the argument, and then execute the requested command.
  1996. Arguments:
  1997. Callee - Supplies the input arguments and returns the output arguments
  1998. and return value for the stub.
  1999. --*/
  2000. {
  2001. unsigned /*long*/ char Command;
  2002. RPC_STATUS RpcStatus = RPC_S_OK;
  2003. if ( Callee->BufferLength != sizeof(unsigned char)
  2004. && Callee->BufferLength != sizeof(unsigned long) )
  2005. {
  2006. OtherError("IsabelleRichardHelper",
  2007. "*BufferLength != sizeof(unsigned long)");
  2008. IsabelleError();
  2009. Callee->BufferLength = 0;
  2010. Status = I_RpcGetBuffer(Callee);
  2011. if (Status)
  2012. {
  2013. ApiError("IsabelleRichardHelper","I_RpcGetBuffer",Status);
  2014. IsabelleError();
  2015. }
  2016. return;
  2017. }
  2018. Command = *((unsigned char *) Callee->Buffer);
  2019. if (Command == RICHARDHELPER_EXIT)
  2020. {
  2021. PrintToConsole("Richard : RichardHelper Exiting\n");
  2022. #ifdef OS2_12
  2023. DosExit(EXIT_PROCESS, 0);
  2024. #endif // OS2_12
  2025. #ifdef WIN32RPC
  2026. ExitProcess(0);
  2027. #endif // WIN32RPC
  2028. }
  2029. else if (Command == RICHARDHELPER_EXECUTE)
  2030. {
  2031. #ifdef OS2_12
  2032. USHORT Os2Status;
  2033. RESULTCODES ResultCodes;
  2034. char CommandLine[200], *pT;
  2035. pT = CommandLine;
  2036. *pT = 0;
  2037. pT += strlen(strcpy(pT, "usvr")) + 1;
  2038. pT += strlen(strcpy(pT, TransportOption));
  2039. pT += strlen(strcpy(pT, "-error -richardhelper")) + 1;
  2040. *pT = 0;
  2041. Os2Status = DosExecPgm(0,0,EXEC_ASYNC, (unsigned char *)CommandLine, 0,
  2042. &ResultCodes,(unsigned char *)"usvr.exe");
  2043. if (Os2Status != 0)
  2044. {
  2045. OtherError("IsabelleRichardHelper","DosExecPgm Failed");
  2046. IsabelleError();
  2047. }
  2048. #endif // OS2_12
  2049. #ifdef WIN32RPC
  2050. PROCESS_INFORMATION ProcessInformation;
  2051. STARTUPINFOA StartupInfo;
  2052. StartupInfo.cb = sizeof(STARTUPINFOA);
  2053. StartupInfo.lpReserved = 0;
  2054. StartupInfo.lpDesktop = 0;
  2055. StartupInfo.lpTitle = 0;
  2056. StartupInfo.dwX = 0;
  2057. StartupInfo.dwY = 0;
  2058. StartupInfo.dwXSize = 0;
  2059. StartupInfo.dwYSize = 0;
  2060. StartupInfo.dwFlags = 0;
  2061. StartupInfo.wShowWindow = 0;
  2062. StartupInfo.cbReserved2 = 0;
  2063. StartupInfo.lpReserved2 = 0;
  2064. char CommandLine[200];
  2065. PrintToConsole("Spawning richardhelper\n") ;
  2066. strcpy(CommandLine, "usvr ");
  2067. strcat(CommandLine, TransportOption);
  2068. strcat(CommandLine, " -richardhelper");
  2069. if (CreateProcessA(0, CommandLine, 0, 0, FALSE,
  2070. 0, 0, 0, &StartupInfo, &ProcessInformation) == FALSE)
  2071. {
  2072. OtherError("IsabelleRichardHelper","CreateProcessA Failed");
  2073. IsabelleError();
  2074. }
  2075. #endif // WIN32RPC
  2076. }
  2077. else if (Command == RICHARDHELPER_DELAY_EXIT)
  2078. {
  2079. HANDLE HandleToThread ;
  2080. unsigned long ThreadIdentifier;
  2081. HandleToThread = CreateThread(
  2082. 0,
  2083. 0,
  2084. (LPTHREAD_START_ROUTINE) RichardHelperExit,
  2085. 0,
  2086. 0,
  2087. &ThreadIdentifier);
  2088. if (HandleToThread == 0)
  2089. {
  2090. OtherError("IsabelleRichardHelper","Can Not Create Thread");
  2091. IsabelleError();
  2092. }
  2093. }
  2094. else if (Command != RICHARDHELPER_IGNORE)
  2095. {
  2096. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2097. IsabelleError();
  2098. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2099. IsabelleError();
  2100. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2101. IsabelleError();
  2102. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2103. IsabelleError();
  2104. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2105. IsabelleError();
  2106. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2107. IsabelleError();
  2108. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2109. IsabelleError();
  2110. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2111. IsabelleError();
  2112. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2113. IsabelleError();
  2114. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2115. IsabelleError();
  2116. OtherError("IsabelleRichardHelper","Unknown Command Requested");
  2117. IsabelleError();
  2118. }
  2119. Callee->BufferLength = 0;
  2120. Status = I_RpcGetBuffer(Callee);
  2121. if (Status)
  2122. {
  2123. ApiError("IsabelleRichardHelper","I_RpcGetBuffer",Status);
  2124. }
  2125. }
  2126. void __RPC_STUB
  2127. IsabelleRaiseException (
  2128. PRPC_MESSAGE Callee
  2129. )
  2130. /*++
  2131. Routine Description:
  2132. This routine is the stub (and actually the manager code as well) for
  2133. the IsabelleRaiseException routine. The client will call a stub and
  2134. specify an exception to be raised which will be passed in the buffer. We
  2135. need to extract the argument, and then raise the exception.
  2136. Arguments:
  2137. Callee - Supplies the input arguments and returns the output arguments
  2138. and return value for the stub.
  2139. --*/
  2140. {
  2141. unsigned /*long*/ char Exception;
  2142. CompleteReceive(Callee) ;
  2143. if ( Callee->BufferLength != sizeof(unsigned long)
  2144. && Callee->BufferLength != sizeof(unsigned char) )
  2145. {
  2146. OtherError("IsabelleRaiseException",
  2147. "*BufferLength != 1 or 4");
  2148. IsabelleError();
  2149. Callee->BufferLength = 0;
  2150. Status = I_RpcGetBuffer(Callee);
  2151. if (Status)
  2152. {
  2153. ApiError("IsabelleRaiseException","I_RpcGetBuffer",Status);
  2154. IsabelleError();
  2155. }
  2156. return;
  2157. }
  2158. Exception = *((unsigned /*long*/ char *) Callee->Buffer);
  2159. RpcRaiseException((RPC_STATUS) Exception);
  2160. // This should never be reached.
  2161. OtherError("IsabelleRaiseException", "RpcRaiseException Failed");
  2162. IsabelleError();
  2163. Callee->BufferLength = 0;
  2164. Status = I_RpcGetBuffer(Callee);
  2165. if (Status)
  2166. {
  2167. ApiError("IsabelleRaiseException","I_RpcGetBuffer",Status);
  2168. }
  2169. }
  2170. unsigned int IsabelleRundownFlag = 0;
  2171. void PAPI * IsabelleAssociationContext = 0;
  2172. void __RPC_STUB
  2173. IsabelleRundownRoutine (
  2174. IN void PAPI * AssociationContext
  2175. )
  2176. /*++
  2177. Routine Description:
  2178. This routine will get called when the association closes. We just
  2179. need to check that the association context is correct, and then
  2180. note that we got called.
  2181. Arguments:
  2182. AssociationContext - Supplies the association context for the association
  2183. which closed.
  2184. --*/
  2185. {
  2186. if (AssociationContext == IsabelleAssociationContext)
  2187. IsabelleRundownFlag += 1;
  2188. }
  2189. void __RPC_STUB
  2190. IsabelleSetRundown (
  2191. IN PRPC_MESSAGE Callee
  2192. )
  2193. /*++
  2194. Routine Description:
  2195. We want to set an association context in this routine, and a rundown
  2196. routine. The rundown will set a flag when it is called. Later, the
  2197. client, will call another routine to check to set the flag has been
  2198. set.
  2199. Arguments:
  2200. Callee - Supplies the input arguments and returns the output arguments
  2201. and return value for the stub.
  2202. --*/
  2203. {
  2204. CompleteReceive(Callee) ;
  2205. if (Callee->BufferLength != 0)
  2206. {
  2207. OtherError("IsabelleSetException", "*BufferLength != 0");
  2208. IsabelleError();
  2209. }
  2210. IsabelleRundownFlag = 0;
  2211. IsabelleAssociationContext = Callee->Buffer;
  2212. Status = I_RpcMonitorAssociation(Callee->Handle, IsabelleRundownRoutine,
  2213. IsabelleAssociationContext);
  2214. if (Status)
  2215. {
  2216. ApiError("IsabelleSetRundown","I_RpcMonitorAssociation",Status);
  2217. IsabelleError();
  2218. }
  2219. Callee->BufferLength = 0;
  2220. Status = I_RpcGetBuffer(Callee);
  2221. if (Status)
  2222. {
  2223. ApiError("IsabelleSetRundown","I_RpcGetBuffer",Status);
  2224. }
  2225. }
  2226. void __RPC_STUB
  2227. IsabelleCheckRundown (
  2228. PRPC_MESSAGE Callee
  2229. )
  2230. /*++
  2231. Routine Description:
  2232. This routine will be called to check that context rundown did, in
  2233. fact, occur.
  2234. Arguments:
  2235. Callee - Supplies the input arguments and returns the output arguments
  2236. and return value for the stub.
  2237. --*/
  2238. {
  2239. CompleteReceive(Callee) ;
  2240. if (Callee->BufferLength != 0)
  2241. {
  2242. OtherError("IsabelleCheckRundown", "*BufferLength != 0");
  2243. IsabelleError();
  2244. }
  2245. if (0 == DatagramFlag)
  2246. {
  2247. if (IsabelleRundownFlag != 1)
  2248. {
  2249. OtherError("IsabelleCheckRundown", "IsabelleRundownFlag != 1");
  2250. IsabelleError();
  2251. }
  2252. }
  2253. Callee->BufferLength = 0;
  2254. Status = I_RpcGetBuffer(Callee);
  2255. if (Status)
  2256. {
  2257. ApiError("IsabelleCheckRundown","I_RpcGetBuffer",Status);
  2258. }
  2259. }
  2260. void __RPC_STUB
  2261. IsabelleCheckNoRundown (
  2262. PRPC_MESSAGE Callee
  2263. )
  2264. /*++
  2265. Routine Description:
  2266. This routine will be called to check that context rundown did not
  2267. occur.
  2268. Arguments:
  2269. Callee - Supplies the input arguments and returns the output arguments
  2270. and return value for the stub.
  2271. --*/
  2272. {
  2273. CompleteReceive(Callee) ;
  2274. if (Callee->BufferLength != 0)
  2275. {
  2276. OtherError("IsabelleCheckNoRundown", "*BufferLength != 0");
  2277. IsabelleError();
  2278. }
  2279. if (IsabelleRundownFlag == 1)
  2280. {
  2281. OtherError("IsabelleCheckNoRundown", "IsabelleRundownFlag == 1");
  2282. IsabelleError();
  2283. }
  2284. Callee->BufferLength = 0;
  2285. Status = I_RpcGetBuffer(Callee);
  2286. if (Status)
  2287. {
  2288. ApiError("IsabelleCheckNoRundown","I_RpcGetBuffer",Status);
  2289. }
  2290. }
  2291. void __RPC_STUB
  2292. IsabelleCheckContext (
  2293. PRPC_MESSAGE Callee
  2294. )
  2295. /*++
  2296. Routine Description:
  2297. This routine will be called to check the context for an association,
  2298. and then to set a new context.
  2299. Arguments:
  2300. Callee - Supplies the input arguments and returns the output arguments
  2301. and return value for the stub.
  2302. --*/
  2303. {
  2304. void PAPI * Context;
  2305. CompleteReceive(Callee) ;
  2306. if (Callee->BufferLength != 0)
  2307. {
  2308. OtherError("IsabelleCheckContext", "*BufferLength != 0");
  2309. IsabelleError();
  2310. }
  2311. Status = I_RpcGetAssociationContext(Callee->Handle, &Context);
  2312. if (Status)
  2313. {
  2314. ApiError("IsabelleCheckContext", "I_RpcGetAssociationContext",
  2315. Status);
  2316. IsabelleError();
  2317. Callee->BufferLength = 0;
  2318. Status = I_RpcGetBuffer(Callee);
  2319. if (Status)
  2320. {
  2321. ApiError("IsabelleCheckContext","I_RpcGetBuffer",Status);
  2322. IsabelleError();
  2323. }
  2324. return;
  2325. }
  2326. if (Context != IsabelleAssociationContext)
  2327. {
  2328. OtherError("IsabelleCheckContext",
  2329. "Context != IsabelleAssociationContext");
  2330. IsabelleError();
  2331. Callee->BufferLength = 0;
  2332. Status = I_RpcGetBuffer(Callee);
  2333. if (Status)
  2334. {
  2335. ApiError("IsabelleCheckContext","I_RpcGetBuffer",Status);
  2336. IsabelleError();
  2337. }
  2338. return;
  2339. }
  2340. Callee->BufferLength = 0;
  2341. Status = I_RpcGetBuffer(Callee);
  2342. if (Status)
  2343. {
  2344. ApiError("IsabelleCheckContext","I_RpcGetBuffer",Status);
  2345. }
  2346. }
  2347. RPC_BINDING_VECTOR * BartholomewRpcBindingVector;
  2348. unsigned int BartholomewIndex;
  2349. unsigned char *
  2350. UnicodeToAnsiString (
  2351. IN RPC_CHAR * WideCharString,
  2352. OUT RPC_STATUS * RpcStatus
  2353. )
  2354. /*++
  2355. Routine Description:
  2356. This routine will convert a unicode string into an ansi string,
  2357. including allocating memory for the ansi string.
  2358. Arguments:
  2359. WideCharString - Supplies the unicode string to be converted into
  2360. an ansi string.
  2361. RpcStatus - Returns the status of the operation; this will be one
  2362. of the following values.
  2363. RPC_S_OK - The unicode string has successfully been converted
  2364. into an ansi string.
  2365. RPC_S_OUT_OF_MEMORY - Insufficient memory is available to allocate
  2366. the ansi string.
  2367. Return Value:
  2368. A pointer to the ansi string will be returned.
  2369. --*/
  2370. {
  2371. NTSTATUS NtStatus;
  2372. UNICODE_STRING UnicodeString;
  2373. ANSI_STRING AnsiString;
  2374. unsigned char * NewString;
  2375. RtlInitUnicodeString(&UnicodeString,WideCharString);
  2376. NtStatus = RtlUnicodeStringToAnsiString(&AnsiString,&UnicodeString,TRUE);
  2377. if (!NT_SUCCESS(NtStatus))
  2378. {
  2379. *RpcStatus = RPC_S_OUT_OF_MEMORY;
  2380. return(0);
  2381. }
  2382. NewString = new unsigned char[AnsiString.Length + 1];
  2383. if (NewString == 0)
  2384. {
  2385. RtlFreeAnsiString(&AnsiString);
  2386. *RpcStatus = RPC_S_OUT_OF_MEMORY;
  2387. return(0);
  2388. }
  2389. memcpy(NewString,AnsiString.Buffer,AnsiString.Length + 1);
  2390. RtlFreeAnsiString(&AnsiString);
  2391. *RpcStatus = RPC_S_OK;
  2392. return(NewString);
  2393. }
  2394. unsigned char PAPI *
  2395. StringBindingWithDynamicEndpoint (
  2396. IN unsigned char PAPI * StringBinding,
  2397. IN RPC_CHAR PAPI * DynamicEndpoint
  2398. )
  2399. /*++
  2400. Routine Description:
  2401. This routine adds the dynamic endpoint to the string binding. A
  2402. new string binding will be returned, and the supplied string binding
  2403. and dynamic endpoint will be freed.
  2404. Arguments:
  2405. StringBinding - Supplies the string binding to which the dynamic
  2406. endpoint should be added.
  2407. DynamicEndpoint - Supplies the dynamic endpoint.
  2408. Return Value:
  2409. A new string binding will be returned which contains the dynamic
  2410. endpoint if the operation is successful; otherwise, zero will be
  2411. returned.
  2412. --*/
  2413. {
  2414. unsigned char PAPI * ObjectUuid;
  2415. unsigned char PAPI * RpcProtocolSequence;
  2416. unsigned char PAPI * NetworkAddress;
  2417. unsigned char PAPI * Endpoint;
  2418. unsigned char PAPI * NetworkOptions;
  2419. Status = RpcStringBindingParseA(StringBinding, &ObjectUuid,
  2420. &RpcProtocolSequence, &NetworkAddress, &Endpoint,
  2421. &NetworkOptions);
  2422. if (Status)
  2423. {
  2424. ApiError("StringBindingWithDynamicEndpoint",
  2425. "RpcStringBindingParse", Status);
  2426. return(0);
  2427. }
  2428. Status = RpcStringFreeA(&StringBinding);
  2429. if (Status)
  2430. {
  2431. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2432. return(0);
  2433. }
  2434. Status = RpcStringFreeA(&Endpoint);
  2435. if (Status)
  2436. {
  2437. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2438. return(0);
  2439. }
  2440. Endpoint = UnicodeToAnsiString(DynamicEndpoint, &Status);
  2441. if (Status)
  2442. {
  2443. ApiError("StringBindingWithDynamicEndpoint", "UnicodeToAnsiString",
  2444. Status);
  2445. return(0);
  2446. }
  2447. Status = RpcStringFreeW(&DynamicEndpoint);
  2448. if (Status)
  2449. {
  2450. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFreeW",
  2451. Status);
  2452. return(0);
  2453. }
  2454. Status = RpcStringBindingComposeA(ObjectUuid, RpcProtocolSequence,
  2455. NetworkAddress, Endpoint, NetworkOptions, &StringBinding);
  2456. if (Status)
  2457. {
  2458. ApiError("StringBindingWithDynamicEndpoint",
  2459. "RpcStringBindingCompose", Status);
  2460. return(0);
  2461. }
  2462. delete Endpoint;
  2463. Status = RpcStringFreeA(&ObjectUuid);
  2464. if (Status)
  2465. {
  2466. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2467. return(0);
  2468. }
  2469. Status = RpcStringFreeA(&RpcProtocolSequence);
  2470. if (Status)
  2471. {
  2472. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2473. return(0);
  2474. }
  2475. Status = RpcStringFreeA(&NetworkAddress);
  2476. if (Status)
  2477. {
  2478. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2479. return(0);
  2480. }
  2481. Status = RpcStringFreeA(&NetworkOptions);
  2482. if (Status)
  2483. {
  2484. ApiError("StringBindingWithDynamicEndpoint", "RpcStringFree", Status);
  2485. return(0);
  2486. }
  2487. return(StringBinding);
  2488. }
  2489. void __RPC_STUB
  2490. IsabelleGetStringBinding (
  2491. PRPC_MESSAGE Callee
  2492. )
  2493. /*++
  2494. Routine Description:
  2495. This routine will be called to obtain a string binding for one of
  2496. the protocol sequences supported by this server.
  2497. Arguments:
  2498. Callee - Supplies the input arguments and returns the output arguments
  2499. and return value for the stub.
  2500. --*/
  2501. {
  2502. unsigned char * StringBinding;
  2503. WCHAR * DynamicEndpointW;
  2504. RPC_CHAR *DynamicEndpoint;
  2505. unsigned int TransportType ;
  2506. unsigned int CurTransportType;
  2507. CompleteReceive(Callee) ;
  2508. while (BartholomewRpcBindingVector == 0)
  2509. {
  2510. Sleep(100);
  2511. }
  2512. if (Callee->BufferLength != 0)
  2513. {
  2514. OtherError("IsabelleGetStringBinding", "*BufferLength != 0");
  2515. IsabelleError();
  2516. }
  2517. Status = I_RpcBindingInqTransportType(Callee->Handle, &TransportType);
  2518. if (Status)
  2519. {
  2520. ApiError("IsabelleGetStringBinding", "I_RpcBindingInqTransportType", Status);
  2521. IsabelleError();
  2522. return;
  2523. }
  2524. if (TransportType != TRANSPORT_TYPE_LPC)
  2525. {
  2526. while (BartholomewIndex < BartholomewRpcBindingVector->Count)
  2527. {
  2528. Status = I_RpcBindingInqTransportType(
  2529. BartholomewRpcBindingVector->BindingH[BartholomewIndex],
  2530. &CurTransportType);
  2531. if (Status)
  2532. {
  2533. ApiError("IsabelleGetStringBinding",
  2534. "I_RpcBindingInqTransportType", Status);
  2535. IsabelleError();
  2536. return;
  2537. }
  2538. if (CurTransportType == TRANSPORT_TYPE_LPC)
  2539. {
  2540. BartholomewIndex ++;
  2541. continue;
  2542. }
  2543. break;
  2544. }
  2545. }
  2546. if (BartholomewIndex < BartholomewRpcBindingVector->Count)
  2547. {
  2548. Status = RpcBindingToStringBindingA(
  2549. BartholomewRpcBindingVector->BindingH[BartholomewIndex],
  2550. &StringBinding);
  2551. if (Status)
  2552. {
  2553. ApiError("IsabelleGetStringBinding", "RpcBindingToStringBinding",
  2554. Status);
  2555. IsabelleError();
  2556. Callee->BufferLength = 0;
  2557. Status = I_RpcGetBuffer(Callee);
  2558. if (Status)
  2559. {
  2560. ApiError("IsabelleGetStringBinding","I_RpcGetBuffer",Status);
  2561. IsabelleError();
  2562. }
  2563. return;
  2564. }
  2565. Status = I_RpcBindingInqDynamicEndpointW(
  2566. BartholomewRpcBindingVector->BindingH[BartholomewIndex],
  2567. &DynamicEndpointW);
  2568. if (Status)
  2569. {
  2570. ApiError("IsabelleGetStringBinding",
  2571. "I_RpcBindingInqDynamicEndpoint", Status);
  2572. IsabelleError();
  2573. Callee->BufferLength = 0;
  2574. Status = I_RpcGetBuffer(Callee);
  2575. if (Status)
  2576. {
  2577. ApiError("IsabelleGetStringBinding","I_RpcGetBuffer",Status);
  2578. IsabelleError();
  2579. }
  2580. return;
  2581. }
  2582. DynamicEndpoint = DynamicEndpointW;
  2583. if (DynamicEndpoint != 0)
  2584. {
  2585. StringBinding = StringBindingWithDynamicEndpoint(StringBinding,
  2586. DynamicEndpoint);
  2587. if (StringBinding == 0)
  2588. {
  2589. OtherError("IsabelleGetStringBinding",
  2590. "StringBinding == 0");
  2591. IsabelleError();
  2592. Callee->BufferLength = 0;
  2593. Status = I_RpcGetBuffer(Callee);
  2594. if (Status)
  2595. {
  2596. ApiError("IsabelleGetStringBinding","I_RpcGetBuffer",Status);
  2597. IsabelleError();
  2598. }
  2599. return;
  2600. }
  2601. }
  2602. Callee->BufferLength = strlen((char PAPI *) StringBinding) + 1;
  2603. Status = I_RpcGetBuffer(Callee);
  2604. if (Status)
  2605. {
  2606. ApiError("IsabelleGetStringBinding", "I_RpcGetBuffer", Status);
  2607. IsabelleError();
  2608. return;
  2609. }
  2610. memcpy(Callee->Buffer, StringBinding,
  2611. strlen((char PAPI *) StringBinding) + 1);
  2612. Status = RpcStringFreeA(&StringBinding);
  2613. if (Status)
  2614. {
  2615. ApiError("IsabelleGetStringBinding", "RpcStringFree", Status);
  2616. IsabelleError();
  2617. return;
  2618. }
  2619. BartholomewIndex += 1;
  2620. }
  2621. else
  2622. {
  2623. Callee->BufferLength = 0;
  2624. Status = I_RpcGetBuffer(Callee);
  2625. if (Status)
  2626. {
  2627. ApiError("IsabelleGetStringBinding","I_RpcGetBuffer",Status);
  2628. IsabelleError();
  2629. }
  2630. return;
  2631. }
  2632. }
  2633. void IsabelleUnregisterInterfaces(
  2634. PRPC_MESSAGE Callee
  2635. )
  2636. {
  2637. Status = RpcServerUnregisterIf(
  2638. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  2639. if (Status)
  2640. {
  2641. ApiError("IsabelleUnregsterInterface","RpcServerUnregisterIf",Status);
  2642. PrintToConsole("IsabelleUnregsterInterfaces : FAIL - Unable to Unregister Interface ");
  2643. PrintToConsole("(Helga)\n");
  2644. return;
  2645. }
  2646. }
  2647. void IsabelleRegisterInterfaces(
  2648. PRPC_MESSAGE Callee
  2649. )
  2650. {
  2651. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  2652. 0,0);
  2653. if (Status)
  2654. {
  2655. ApiError("Hybrid","stub_RegisterIf",Status);
  2656. PrintToConsole("Hybrid : FAIL - Unable to Register Interface ");
  2657. PrintToConsole("(Helga)\n");
  2658. return;
  2659. }
  2660. Status = stub_RegisterIf(
  2661. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  2662. if (Status)
  2663. {
  2664. ApiError("Hybrid","stub_RegisterIf",Status);
  2665. PrintToConsole("Hybrid : FAIL - Unable to Register Interface ");
  2666. PrintToConsole("(Isabelle)\n");
  2667. return;
  2668. }
  2669. }
  2670. void PipeAlloc(
  2671. PIPE_STATE *state,
  2672. int requested_size,
  2673. pipe_element_t **allocated_buf,
  2674. int *allocated_size)
  2675. {
  2676. if (state->BufferSize < requested_size)
  2677. {
  2678. if (state->AllocatedBuffer)
  2679. {
  2680. I_RpcFree(state->AllocatedBuffer) ;
  2681. }
  2682. state->AllocatedBuffer = I_RpcAllocate(requested_size) ;
  2683. if (state->AllocatedBuffer == 0)
  2684. {
  2685. *allocated_size = 0 ;
  2686. state->BufferSize = 0 ;
  2687. }
  2688. else
  2689. {
  2690. *allocated_size = requested_size ;
  2691. state->BufferSize = requested_size ;
  2692. }
  2693. *allocated_buf = (pipe_element_t *) state->AllocatedBuffer ;
  2694. }
  2695. else
  2696. {
  2697. *allocated_buf = (pipe_element_t *) state->AllocatedBuffer ;
  2698. *allocated_size = state->BufferSize ;
  2699. }
  2700. }
  2701. void PipePull(
  2702. PIPE_STATE *state,
  2703. pipe_element_t *buffer,
  2704. int ecount,
  2705. int *actual_transfer_count
  2706. )
  2707. {
  2708. int num_elements = 0;
  2709. DWORD size = (DWORD) ecount * state->PipeElementSize ;
  2710. RPC_MESSAGE Callee ;
  2711. *actual_transfer_count = 0 ;
  2712. if (state->EndOfPipe)
  2713. {
  2714. return ;
  2715. }
  2716. I_RpcReadPipeElementsFromBuffer(state, (char *) buffer, size, &num_elements) ;
  2717. *actual_transfer_count += num_elements ;
  2718. size -= num_elements * state->PipeElementSize ;
  2719. if (state->EndOfPipe == 0 &&
  2720. num_elements < ecount)
  2721. {
  2722. Callee.RpcFlags = RPC_BUFFER_PARTIAL ;
  2723. Callee.Buffer = state->Buffer ;
  2724. Callee.BufferLength = state->BufferLength ;
  2725. Status = I_RpcReceive(&Callee, size) ;
  2726. if (Status)
  2727. {
  2728. ApiError("PipePull", "I_RpcReceive", Status) ;
  2729. num_elements = 0 ;
  2730. return ;
  2731. }
  2732. state->Buffer = Callee.Buffer ;
  2733. state->BufferLength = Callee.BufferLength ;
  2734. state->CurPointer = (char *) Callee.Buffer ;
  2735. state->BytesRemaining = Callee.BufferLength ;
  2736. buffer = (pipe_element_t *)
  2737. ((char *) buffer + num_elements * state->PipeElementSize) ;
  2738. num_elements = 0 ;
  2739. I_RpcReadPipeElementsFromBuffer(state,
  2740. (char *) buffer, size, &num_elements) ;
  2741. *actual_transfer_count += num_elements ;
  2742. }
  2743. }
  2744. void PipePush(
  2745. PIPE_STATE *state,
  2746. pipe_element_t *buffer,
  2747. int count
  2748. )
  2749. {
  2750. RPC_MESSAGE TempBuf ;
  2751. int size = count * state->PipeElementSize + sizeof(DWORD) ;
  2752. char *temp ;
  2753. RPC_MESSAGE Callee ;
  2754. Callee.Buffer = state->Buffer ;
  2755. Callee.BufferLength = state->BufferLength ;
  2756. Callee.Handle = state->BindingHandle;
  2757. Status = I_RpcReallocPipeBuffer(&Callee, size+state->SendBufferOffset) ;
  2758. if (Status)
  2759. {
  2760. ApiError("PipePush", "I_RpcGetBuffer", Status) ;
  2761. return ;
  2762. }
  2763. temp = (char *) Callee.Buffer+state->SendBufferOffset ;
  2764. *((DWORD *) temp) = count ;
  2765. RpcpMemoryCopy(temp+sizeof(DWORD),
  2766. buffer, count * state->PipeElementSize) ;
  2767. Callee.RpcFlags = RPC_BUFFER_PARTIAL ;
  2768. Status = I_RpcSend(&Callee) ;
  2769. if (Status == RPC_S_SEND_INCOMPLETE)
  2770. {
  2771. state->SendBufferOffset = Callee.BufferLength ;
  2772. }
  2773. else if (Status)
  2774. {
  2775. ApiError("PipePush", "I_RpcSend", Status) ;
  2776. state->SendBufferOffset = 0 ;
  2777. return;
  2778. }
  2779. else
  2780. {
  2781. state->SendBufferOffset = 0 ;
  2782. }
  2783. }
  2784. void IsabelleMgrIN(
  2785. pipe_t *pipe,
  2786. int chunksize,
  2787. int numchunks,
  2788. int checksum,
  2789. int buffsize,
  2790. char *buffer
  2791. )
  2792. {
  2793. static pipe_element_t local_buf[CHUNK_SIZE] ;
  2794. int num_elements ;
  2795. int i, j ;
  2796. int localchecksum = 0;
  2797. PrintToConsole("IsabelleMgrIN: client chunk size: %d\n", chunksize) ;
  2798. PrintToConsole("IsabelleMgrIN: client number of chunks: %d\n", numchunks) ;
  2799. PrintToConsole("IsabelleMgrIN: buffer size: %d\n", buffsize) ;
  2800. PrintToConsole("IsabelleMgrIN: checksum: %d\n", checksum) ;
  2801. do
  2802. {
  2803. pipe->Pull(pipe->state,
  2804. local_buf,
  2805. CHUNK_SIZE,
  2806. &num_elements
  2807. ) ;
  2808. for (i = 0; i <num_elements; i++)
  2809. {
  2810. localchecksum += local_buf[i] ;
  2811. }
  2812. }
  2813. while ( num_elements > 0 );
  2814. if (localchecksum != checksum)
  2815. {
  2816. IsabelleError() ;
  2817. PrintToConsole("IsabelleMgrIN: checksums don't match\n") ;
  2818. }
  2819. }
  2820. void IsabellePipeIN(
  2821. PRPC_MESSAGE Callee
  2822. )
  2823. {
  2824. pipe_t mypipe ;
  2825. PIPE_STATE pipestate ;
  2826. pipe_element_t pipe_element ;
  2827. DWORD size = 3* sizeof(int) ;
  2828. int chunksize, numchunks, checksum, buffsize ;
  2829. char *buffer, *temp ;
  2830. void *savedbuffer ;
  2831. PrintToConsole("IsabellePipeIN called\n") ;
  2832. if (!(Callee->RpcFlags & RPC_BUFFER_COMPLETE) &&
  2833. Callee->BufferLength < size)
  2834. {
  2835. Callee->RpcFlags |= (RPC_BUFFER_PARTIAL | RPC_BUFFER_EXTRA) ;
  2836. size = size - Callee->BufferLength ;
  2837. Status = I_RpcReceive(Callee, size) ;
  2838. if (Status)
  2839. {
  2840. ApiError("PipePull", "I_RpcReceive", Status) ;
  2841. return ;
  2842. }
  2843. }
  2844. temp = (char *) Callee->Buffer ;
  2845. chunksize = *((int *) temp) ;
  2846. temp += sizeof(int) ;
  2847. numchunks = *((int *) temp) ;
  2848. temp += sizeof(int) ;
  2849. checksum = *((int *) temp) ;
  2850. temp += sizeof(int) ;
  2851. buffsize = *((int *) temp) ;
  2852. temp += sizeof(int) ;
  2853. size = 4 * sizeof(int) + buffsize + sizeof(DWORD) ;
  2854. if (!(Callee->RpcFlags & RPC_BUFFER_COMPLETE) &&
  2855. Callee->BufferLength < size)
  2856. {
  2857. Callee->RpcFlags |= (RPC_BUFFER_PARTIAL | RPC_BUFFER_EXTRA) ;
  2858. size = size - Callee->BufferLength ;
  2859. Status = I_RpcReceive(Callee, size) ;
  2860. if (Status)
  2861. {
  2862. ApiError("PipePull", "I_RpcReceive", Status) ;
  2863. return ;
  2864. }
  2865. }
  2866. buffer = (char *) Callee->Buffer + 3 * sizeof(int) ;
  2867. savedbuffer = Callee->Buffer ;
  2868. Callee->Buffer = 0;
  2869. pipestate.Buffer = Callee->Buffer ;
  2870. pipestate.BufferLength = Callee->BufferLength ;
  2871. pipestate.CurrentState = start ;
  2872. pipestate.CurPointer = (char *) buffer+buffsize ;
  2873. pipestate.BytesRemaining = Callee->BufferLength - 3 * sizeof(int) - buffsize ;
  2874. pipestate.EndOfPipe = 0 ;
  2875. pipestate.PipeElementSize = sizeof(pipe_element_t) ;
  2876. pipestate.PartialPipeElement = &pipe_element ;
  2877. pipestate.AllocatedBuffer = 0 ;
  2878. pipestate.BufferSize = 0 ;
  2879. mypipe.Pull = PipePull ;
  2880. mypipe.Push = PipePush ;
  2881. mypipe.state = &pipestate ;
  2882. IsabelleMgrIN(&mypipe, chunksize, numchunks, checksum, buffsize, buffer) ;
  2883. Callee->Buffer = savedbuffer ;
  2884. }
  2885. void IsabelleMgrOUT(
  2886. pipe_t *pipe,
  2887. int *chunksize,
  2888. int *numchunks,
  2889. int *checksum,
  2890. int *buffsize,
  2891. char **buffer
  2892. )
  2893. {
  2894. static pipe_element_t local_buf[CHUNK_SIZE] ;
  2895. static int buf[BUFF_SIZE] ;
  2896. int i ;
  2897. char j = 0;
  2898. int localchecksum = 0;
  2899. PrintToConsole("IsabelleMgrOUT called\n") ;
  2900. for (i = 0; i < CHUNK_SIZE; i++, j++)
  2901. {
  2902. RpcpMemorySet((char *) &(local_buf[i]), j, sizeof(pipe_element_t)) ;
  2903. localchecksum += local_buf[i] ;
  2904. }
  2905. for (i = 0; i < NUM_CHUNKS; i++)
  2906. {
  2907. pipe->Push(pipe->state,
  2908. local_buf,
  2909. CHUNK_SIZE
  2910. ) ;
  2911. }
  2912. pipe->Push(pipe->state, local_buf, 0) ;
  2913. for (i = 0; i < BUFF_SIZE; i++)
  2914. {
  2915. local_buf[i] = i ;
  2916. }
  2917. *chunksize = CHUNK_SIZE ;
  2918. *numchunks = NUM_CHUNKS ;
  2919. *checksum = localchecksum * NUM_CHUNKS;
  2920. *buffsize = BUFF_SIZE ;
  2921. *buffer = (char *) buf ;
  2922. }
  2923. void IsabellePipeOUT(
  2924. PRPC_MESSAGE Callee
  2925. )
  2926. {
  2927. pipe_t mypipe ;
  2928. char *Temp ;
  2929. PIPE_STATE pipestate ;
  2930. pipe_element_t pipe_element ;
  2931. int size ;
  2932. char *buffer ;
  2933. int chunksize, numchunks, buffsize, checksum ;
  2934. RPC_MESSAGE TempBuffer ;
  2935. void *savedbuffer ;
  2936. PrintToConsole("IsabellePipeOUT called\n") ;
  2937. pipestate.Buffer = Callee->Buffer ;
  2938. pipestate.BufferLength = Callee->BufferLength ;
  2939. pipestate.CurrentState = start ;
  2940. pipestate.CurPointer = (char *) Callee->Buffer ;
  2941. pipestate.BytesRemaining = Callee->BufferLength ;
  2942. pipestate.EndOfPipe = 0 ;
  2943. pipestate.PipeElementSize = sizeof(pipe_element_t) ;
  2944. pipestate.PartialPipeElement = &pipe_element ;
  2945. pipestate.AllocatedBuffer = 0 ;
  2946. pipestate.BufferSize = 0 ;
  2947. pipestate.SendBufferOffset = 0 ;
  2948. pipestate.BindingHandle = Callee->Handle;
  2949. Callee->Buffer = 0;
  2950. mypipe.Pull = PipePull ;
  2951. mypipe.Push = PipePush ;
  2952. mypipe.state = &pipestate ;
  2953. IsabelleMgrOUT(&mypipe, &chunksize, &numchunks, &checksum, &buffsize, &buffer) ;
  2954. size = 3 *sizeof(int) + buffsize ;
  2955. Status = I_RpcReallocPipeBuffer(Callee, size+pipestate.SendBufferOffset) ;
  2956. if (Status)
  2957. {
  2958. ApiError("PipePull", "I_RpcReceive", Status) ;
  2959. return ;
  2960. }
  2961. Temp = (char *) Callee->Buffer+pipestate.SendBufferOffset ;
  2962. *((int *) Temp) = chunksize ;
  2963. Temp += sizeof(int) ;
  2964. *((int *) Temp) = numchunks ;
  2965. Temp += sizeof(int) ;
  2966. *((int *) Temp) = checksum ;
  2967. Temp += sizeof(int) ;
  2968. *((int *) Temp) = buffsize ;
  2969. Temp += sizeof(int) ;
  2970. RpcpMemoryCopy(Temp, buffer, buffsize) ;
  2971. }
  2972. void IsabelleMgrINOUT(
  2973. pipe_t *pipe
  2974. )
  2975. {
  2976. int num_elements ;
  2977. int i;
  2978. char j = 0;
  2979. static pipe_element_t local_buf[CHUNK_SIZE] ;
  2980. char *PipeData ;
  2981. int localchecksum = 0;
  2982. int outchecksum = 0;
  2983. do
  2984. {
  2985. pipe->Pull(pipe->state,
  2986. local_buf,
  2987. CHUNK_SIZE,
  2988. &num_elements
  2989. ) ;
  2990. for (i = 0; i <num_elements; i++)
  2991. {
  2992. localchecksum += local_buf[i] ;
  2993. }
  2994. }
  2995. while ( num_elements > 0 );
  2996. PrintToConsole("IsabelleMgrINOUT: checksum (IN) = %d\n", localchecksum) ;
  2997. for (i = 0; i < CHUNK_SIZE; i++, j++)
  2998. {
  2999. RpcpMemorySet((char *) &(local_buf[i]), j, sizeof(pipe_element_t)) ;
  3000. outchecksum += local_buf[i] ;
  3001. }
  3002. PrintToConsole("IsabelleMgrINOUT: checksum (OUT) = %d\n",
  3003. outchecksum * NUM_CHUNKS) ;
  3004. for (i = 0; i <NUM_CHUNKS; i++)
  3005. {
  3006. pipe->Push(pipe->state, local_buf, CHUNK_SIZE) ;
  3007. }
  3008. pipe->Push(pipe->state, local_buf, 0) ;
  3009. }
  3010. void IsabellePipeINOUT(
  3011. PRPC_MESSAGE Callee
  3012. )
  3013. {
  3014. pipe_t mypipe ;
  3015. PIPE_STATE pipestate ;
  3016. pipe_element_t pipe_element ;
  3017. DWORD size = sizeof(pipe_element_t) + sizeof(DWORD) ;
  3018. PrintToConsole("IsabellePipeINOUT called\n") ;
  3019. if (!(Callee->RpcFlags & RPC_BUFFER_COMPLETE) &&
  3020. Callee->BufferLength < size)
  3021. {
  3022. Callee->RpcFlags |= (RPC_BUFFER_PARTIAL | RPC_BUFFER_EXTRA) ;
  3023. size = size - Callee->BufferLength ;
  3024. Status = I_RpcReceive(Callee, size) ;
  3025. if (Status)
  3026. {
  3027. ApiError("PipePull", "I_RpcReceive", Status) ;
  3028. return ;
  3029. }
  3030. }
  3031. pipestate.Buffer = Callee->Buffer ;
  3032. pipestate.BufferLength = Callee->BufferLength ;
  3033. pipestate.CurrentState = start ;
  3034. pipestate.CurPointer = (char *) Callee->Buffer ;
  3035. pipestate.BytesRemaining = Callee->BufferLength ;
  3036. pipestate.EndOfPipe = 0 ;
  3037. pipestate.PipeElementSize = sizeof(pipe_element_t) ;
  3038. pipestate.PartialPipeElement = &pipe_element ;
  3039. pipestate.AllocatedBuffer = 0 ;
  3040. pipestate.BufferSize = 0 ;
  3041. pipestate.SendBufferOffset = 0 ;
  3042. Callee->Buffer = 0;
  3043. mypipe.Pull = PipePull ;
  3044. mypipe.Push = PipePush ;
  3045. mypipe.state = &pipestate ;
  3046. IsabelleMgrINOUT(&mypipe) ;
  3047. }
  3048. void GetServerType(
  3049. PRPC_MESSAGE Callee
  3050. )
  3051. {
  3052. RPC_STATUS RpcStatus;
  3053. OSVERSIONINFO *pOsVer;
  3054. Callee->BufferLength = sizeof(OSVERSIONINFO);
  3055. RpcStatus = I_RpcGetBuffer(Callee);
  3056. if (RpcStatus != RPC_S_OK)
  3057. {
  3058. ApiError("Get Buffer", "I_RpcGetBuffer", Status) ;
  3059. return ;
  3060. }
  3061. pOsVer = (OSVERSIONINFO *)Callee->Buffer;
  3062. pOsVer->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  3063. GetVersionEx(pOsVer);
  3064. }
  3065. void UnregisterHelgaEx(
  3066. PRPC_MESSAGE Callee
  3067. )
  3068. {
  3069. Status = RpcServerUnregisterIfEx(
  3070. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, TRUE);
  3071. if (Status)
  3072. {
  3073. ApiError("UnregisterHelgaEx","RpcServerUnregisterIfEx",Status);
  3074. PrintToConsole("David : FAIL - Unable to Unregister Interface ");
  3075. PrintToConsole("(Helga)\n");
  3076. return;
  3077. }
  3078. }
  3079. RPC_DISPATCH_FUNCTION IsabelleDispatchFunction[] =
  3080. {
  3081. IsabelleShutdown,
  3082. IsabelleNtSecurity,
  3083. IsabelleToStringBinding,
  3084. IsabelleRichardHelper,
  3085. IsabelleRaiseException,
  3086. IsabelleSetRundown,
  3087. IsabelleCheckRundown,
  3088. IsabelleCheckContext,
  3089. IsabelleGetStringBinding,
  3090. IsabelleCheckNoRundown,
  3091. Synchro,
  3092. IsabelleUnregisterInterfaces,
  3093. IsabelleRegisterInterfaces,
  3094. IsabellePipeIN,
  3095. IsabellePipeOUT,
  3096. IsabellePipeINOUT,
  3097. Foo_s,
  3098. FooPipe_s,
  3099. FooBar_s,
  3100. FooCH_s,
  3101. GetServerType,
  3102. OpenContextHandle,
  3103. UnregisterHelgaEx
  3104. };
  3105. RPC_DISPATCH_TABLE IsabelleDispatchTable =
  3106. {
  3107. 23, IsabelleDispatchFunction
  3108. };
  3109. int
  3110. InquireBindings (
  3111. char * TestName
  3112. )
  3113. /*++
  3114. Routine Description:
  3115. This routine is used to test RpcServerInqBindings and
  3116. RpcBindingVectorFree. We call RpcServerInqBindings, and then
  3117. use RpcBindingToStringBinding to get string bindings to print
  3118. to the console.
  3119. Arguments:
  3120. TestName - Supplies the name of the test, Christopher or Bartholomew
  3121. which is invoking this routine. This is necessary so that we
  3122. can print out appropriate messages.
  3123. Return Value:
  3124. Zero will be returned if this test completes successfully; otherwise,
  3125. non-zero will be returned.
  3126. --*/
  3127. {
  3128. RPC_BINDING_VECTOR * RpcBindingVector;
  3129. unsigned int Index;
  3130. unsigned char * StringBinding;
  3131. Status = RpcServerInqBindings(&RpcBindingVector);
  3132. if (Status)
  3133. {
  3134. ApiError(TestName,"RpcServerInqBindings",Status);
  3135. PrintToConsole(TestName);
  3136. PrintToConsole(" : FAIL - RpcServerInqBindings\n");
  3137. return(1);
  3138. }
  3139. PrintToConsole("%s: (RpcServerInqBindings)\n", TestName);
  3140. for (Index = 0; Index < RpcBindingVector->Count; Index++)
  3141. {
  3142. unsigned int Transport;
  3143. char *TransportName;
  3144. Status = RpcBindingToStringBindingA(RpcBindingVector->BindingH[Index],
  3145. &StringBinding);
  3146. if (Status)
  3147. {
  3148. ApiError(TestName,"RpcBindingToStringBinding",Status);
  3149. PrintToConsole(TestName);
  3150. PrintToConsole(" : FAIL - RpcBindingToStringBinding\n");
  3151. return(1);
  3152. }
  3153. Status =
  3154. I_RpcBindingInqTransportType(RpcBindingVector->BindingH[Index],
  3155. &Transport);
  3156. if (Status)
  3157. {
  3158. ApiError(TestName,"I_RpcBindingInqTransportType",Status);
  3159. PrintToConsole(TestName);
  3160. PrintToConsole(" : FAIL - I_RpcBindingInqTransportType\n");
  3161. return(1);
  3162. }
  3163. if (Transport == TRANSPORT_TYPE_CN)
  3164. {
  3165. TransportName = "cn";
  3166. }
  3167. else if (Transport == TRANSPORT_TYPE_DG)
  3168. {
  3169. TransportName = "dg";
  3170. }
  3171. else if (Transport == TRANSPORT_TYPE_LPC)
  3172. {
  3173. TransportName = "lpc";
  3174. }
  3175. else
  3176. {
  3177. PrintToConsole(TestName);
  3178. PrintToConsole(" : FAIL - Unknown transport (I_RpcBindingInqTransportType)\n");
  3179. return(1);
  3180. }
  3181. PrintToConsole(" %s - ( %s )\n",
  3182. (char *) StringBinding,
  3183. TransportName );
  3184. Status = RpcStringFreeA(&StringBinding);
  3185. if (Status)
  3186. {
  3187. ApiError(TestName,"RpcStringFree",Status);
  3188. PrintToConsole(TestName);
  3189. PrintToConsole(" : FAIL - RpcStringFree\n");
  3190. return(1);
  3191. }
  3192. if (StringBinding != 0)
  3193. {
  3194. PrintToConsole(TestName);
  3195. PrintToConsole(" : FAIL - StringBinding != 0\n");
  3196. return(1);
  3197. }
  3198. }
  3199. Status = RpcBindingVectorFree(&RpcBindingVector);
  3200. if (Status)
  3201. {
  3202. ApiError(TestName,"RpcBindingVectorFree",Status);
  3203. PrintToConsole(TestName);
  3204. PrintToConsole(" : FAIL - RpcBindingVectorFree\n");
  3205. return(1);
  3206. }
  3207. if (RpcBindingVector != 0)
  3208. {
  3209. PrintToConsole(TestName);
  3210. PrintToConsole(" : FAIL - RpcBindingVector != 0\n");
  3211. return(1);
  3212. }
  3213. return(0);
  3214. }
  3215. void
  3216. Sigfried (
  3217. )
  3218. /*++
  3219. Routine Description:
  3220. This routine is used to perform a build verification test of the
  3221. rpc runtime. This test checks for basic functionality of the
  3222. runtime. It works with Sebastian in uclnt.exe.
  3223. --*/
  3224. {
  3225. PrintToConsole("Sigfried : Verify Basic Server Functionality\n");
  3226. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3227. 0,0);
  3228. if (Status)
  3229. {
  3230. ApiError("Sigfried","stub_RegisterIf",Status);
  3231. PrintToConsole("Sigfried : FAIL - Unable to Register Interface ");
  3232. PrintToConsole("(Helga)\n");
  3233. return;
  3234. }
  3235. Status = stub_RegisterIf(
  3236. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  3237. if (Status)
  3238. {
  3239. ApiError("Sigfried","stub_RegisterIf",Status);
  3240. PrintToConsole("Sigfried : FAIL - Unable to Register Interface ");
  3241. PrintToConsole("(Isabelle)\n");
  3242. return;
  3243. }
  3244. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3245. GetEndpoint(SIGFRIED), 0);
  3246. if (Status)
  3247. {
  3248. ApiError("Sigfried","RpcServerUseProtseqEpWrapper",Status);
  3249. PrintToConsole("Sigfried : FAIL - Unable to Use Protseq Endpoint\n");
  3250. return;
  3251. }
  3252. // if ( InquireBindings("Sigfried") != 0 )
  3253. // {
  3254. // return;
  3255. // }
  3256. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3257. if (Status)
  3258. {
  3259. ApiError("Sigfried","stub_ServerListen",Status);
  3260. PrintToConsole("Sigfried : FAIL - stub_ServerListen Failed\n");
  3261. return;
  3262. }
  3263. if (HelgaErrors != 0)
  3264. {
  3265. PrintToConsole("Sigfried : FAIL - Error(s) in Helga Interface\n");
  3266. HelgaErrors = 0;
  3267. return;
  3268. }
  3269. if (IsabelleErrors != 0)
  3270. {
  3271. PrintToConsole("Sigfried : FAIL - Error(s) in Isabelle Interface\n");
  3272. IsabelleErrors = 0;
  3273. return;
  3274. }
  3275. Status = RpcServerUnregisterIf(
  3276. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3277. if (Status)
  3278. {
  3279. ApiError("Sigfried","RpcServerUnregisterIf",Status);
  3280. PrintToConsole("Sigfried : FAIL - Unable to Unregister Interface ");
  3281. PrintToConsole("(Isabelle)\n");
  3282. return;
  3283. }
  3284. Status = RpcServerUnregisterIf(
  3285. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3286. if (Status)
  3287. {
  3288. ApiError("Sigfried","RpcServerUnregisterIf",Status);
  3289. PrintToConsole("Sigfried : FAIL - Unable to Unregister Interface ");
  3290. PrintToConsole("(Helga)\n");
  3291. return;
  3292. }
  3293. PrintToConsole("Sigfried : PASS\n");
  3294. }
  3295. void
  3296. Hybrid (
  3297. )
  3298. /*++
  3299. Routine Description:
  3300. This routine is used to perform a build verification test of the
  3301. rpc runtime. This test checks for basic functionality of the
  3302. runtime. It works with Sebastian in uclnt.exe.
  3303. --*/
  3304. {
  3305. PrintToConsole("Hybrid : Verify Basic Server Functionality\n");
  3306. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3307. 0,0);
  3308. if (Status)
  3309. {
  3310. ApiError("Hybrid","stub_RegisterIf",Status);
  3311. PrintToConsole("Hybrid : FAIL - Unable to Register Interface ");
  3312. PrintToConsole("(Helga)\n");
  3313. return;
  3314. }
  3315. Status = stub_RegisterIf(
  3316. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  3317. if (Status)
  3318. {
  3319. ApiError("Hybrid","stub_RegisterIf",Status);
  3320. PrintToConsole("Hybrid : FAIL - Unable to Register Interface ");
  3321. PrintToConsole("(Isabelle)\n");
  3322. return;
  3323. }
  3324. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3325. GetEndpoint(SIGFRIED), 0);
  3326. if (Status)
  3327. {
  3328. ApiError("Hybrid","RpcServerUseProtseqEpWrapper",Status);
  3329. PrintToConsole("Hybrid : FAIL - Unable to Use Protseq Endpoint\n");
  3330. return;
  3331. }
  3332. // if ( InquireBindings("Sigfried") != 0 )
  3333. // {
  3334. // return;
  3335. // }
  3336. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3337. if (Status)
  3338. {
  3339. ApiError("Hybrid","stub_ServerListen",Status);
  3340. PrintToConsole("Hybrid : FAIL - stub_ServerListen Failed\n");
  3341. return;
  3342. }
  3343. if (HelgaErrors != 0)
  3344. {
  3345. PrintToConsole("Hybrid : FAIL - Error(s) in Helga Interface\n");
  3346. HelgaErrors = 0;
  3347. return;
  3348. }
  3349. if (IsabelleErrors != 0)
  3350. {
  3351. PrintToConsole("Hybrid : FAIL - Error(s) in Isabelle Interface\n");
  3352. IsabelleErrors = 0;
  3353. return;
  3354. }
  3355. Status = RpcServerUnregisterIf(
  3356. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3357. if (Status)
  3358. {
  3359. ApiError("Hybrid","RpcServerUnregisterIf",Status);
  3360. PrintToConsole("Hybrid : FAIL - Unable to Unregister Interface ");
  3361. PrintToConsole("(Isabelle)\n");
  3362. return;
  3363. }
  3364. Status = RpcServerUnregisterIf(
  3365. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3366. if (Status)
  3367. {
  3368. ApiError("Hybrid","RpcServerUnregisterIf",Status);
  3369. PrintToConsole("Hybrid : FAIL - Unable to Unregister Interface ");
  3370. PrintToConsole("(Helga)\n");
  3371. return;
  3372. }
  3373. PrintToConsole("Hybrid : PASS\n");
  3374. }
  3375. void
  3376. LpcSecurity (
  3377. )
  3378. /*++
  3379. Routine Description:
  3380. This routine is used to perform a build verification test of the
  3381. rpc runtime. This test checks for basic functionality of the
  3382. runtime. It works with Sebastian in uclnt.exe.
  3383. --*/
  3384. {
  3385. PrintToConsole("LpcSecurity : Verify Basic Server Functionality\n");
  3386. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3387. 0,0);
  3388. if (Status)
  3389. {
  3390. ApiError("LpcSecurity","stub_RegisterIf",Status);
  3391. PrintToConsole("LpcSecurity : FAIL - Unable to Register Interface ");
  3392. PrintToConsole("(Helga)\n");
  3393. return;
  3394. }
  3395. Status = stub_RegisterIf(
  3396. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  3397. if (Status)
  3398. {
  3399. ApiError("LpcSecurity","stub_RegisterIf",Status);
  3400. PrintToConsole("LpcSecurity : FAIL - Unable to Register Interface ");
  3401. PrintToConsole("(Isabelle)\n");
  3402. return;
  3403. }
  3404. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3405. GetEndpoint(SIGFRIED), 0);
  3406. if (Status)
  3407. {
  3408. ApiError("LpcSecurity","RpcServerUseProtseqEpWrapper",Status);
  3409. PrintToConsole("LpcSecurity : FAIL - Unable to Use Protseq Endpoint\n");
  3410. return;
  3411. }
  3412. // if ( InquireBindings("Sigfried") != 0 )
  3413. // {
  3414. // return;
  3415. // }
  3416. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3417. if (Status)
  3418. {
  3419. ApiError("LpcSecurity","stub_ServerListen",Status);
  3420. PrintToConsole("LpcSecurity : FAIL - stub_ServerListen Failed\n");
  3421. return;
  3422. }
  3423. if (HelgaErrors != 0)
  3424. {
  3425. PrintToConsole("LpcSecurity : FAIL - Error(s) in Helga Interface\n");
  3426. HelgaErrors = 0;
  3427. return;
  3428. }
  3429. if (IsabelleErrors != 0)
  3430. {
  3431. PrintToConsole("LpcSecurity : FAIL - Error(s) in Isabelle Interface\n");
  3432. IsabelleErrors = 0;
  3433. return;
  3434. }
  3435. Status = RpcServerUnregisterIf(
  3436. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3437. if (Status)
  3438. {
  3439. ApiError("LpcSecurity","RpcServerUnregisterIf",Status);
  3440. PrintToConsole("LpcSecurity : FAIL - Unable to Unregister Interface ");
  3441. PrintToConsole("(Isabelle)\n");
  3442. return;
  3443. }
  3444. Status = RpcServerUnregisterIf(
  3445. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3446. if (Status)
  3447. {
  3448. ApiError("LpcSecurity","RpcServerUnregisterIf",Status);
  3449. PrintToConsole("LpcSecurity : FAIL - Unable to Unregister Interface ");
  3450. PrintToConsole("(Helga)\n");
  3451. return;
  3452. }
  3453. PrintToConsole("LpcSecurity : PASS\n");
  3454. }
  3455. void
  3456. TestObjectUuids (
  3457. )
  3458. /*++
  3459. Routine Description:
  3460. This routine is used to perform a build verification test of the
  3461. rpc runtime. This test checks for basic functionality of the
  3462. runtime. It works with Sebastian in uclnt.exe.
  3463. --*/
  3464. {
  3465. PrintToConsole("TestObjectUuids : Verify Basic Server Functionality\n");
  3466. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3467. 0,0);
  3468. if (Status)
  3469. {
  3470. ApiError("TestObjectUuids","stub_RegisterIf",Status);
  3471. PrintToConsole("TestObjectUuids : FAIL - Unable to Register Interface ");
  3472. PrintToConsole("(Helga)\n");
  3473. return;
  3474. }
  3475. Status = stub_RegisterIf(
  3476. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  3477. if (Status)
  3478. {
  3479. ApiError("TestObjectUuids","stub_RegisterIf",Status);
  3480. PrintToConsole("TestObjectUuids : FAIL - Unable to Register Interface ");
  3481. PrintToConsole("(Isabelle)\n");
  3482. return;
  3483. }
  3484. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3485. GetEndpoint(SIGFRIED), 0);
  3486. if (Status)
  3487. {
  3488. ApiError("TestObjectUuids","RpcServerUseProtseqEpWrapper",Status);
  3489. PrintToConsole("TestObjectUuids : FAIL - Unable to Use Protseq Endpoint\n");
  3490. return;
  3491. }
  3492. // if ( InquireBindings("Sigfried") != 0 )
  3493. // {
  3494. // return;
  3495. // }
  3496. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3497. if (Status)
  3498. {
  3499. ApiError("TestObjectUuids","stub_ServerListen",Status);
  3500. PrintToConsole("TestObjectUuids : FAIL - stub_ServerListen Failed\n");
  3501. return;
  3502. }
  3503. if (HelgaErrors != 0)
  3504. {
  3505. PrintToConsole("TestObjectUuids : FAIL - Error(s) in Helga Interface\n");
  3506. HelgaErrors = 0;
  3507. return;
  3508. }
  3509. if (IsabelleErrors != 0)
  3510. {
  3511. PrintToConsole("TestObjectUuids : FAIL - Error(s) in Isabelle Interface\n");
  3512. IsabelleErrors = 0;
  3513. return;
  3514. }
  3515. Status = RpcServerUnregisterIf(
  3516. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3517. if (Status)
  3518. {
  3519. ApiError("TestObjectUuids","RpcServerUnregisterIf",Status);
  3520. PrintToConsole("TestObjectUuids : FAIL - Unable to Unregister Interface ");
  3521. PrintToConsole("(Isabelle)\n");
  3522. return;
  3523. }
  3524. Status = RpcServerUnregisterIf(
  3525. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3526. if (Status)
  3527. {
  3528. ApiError("TestObjectUuids","RpcServerUnregisterIf",Status);
  3529. PrintToConsole("TestObjectUuids : FAIL - Unable to Unregister Interface ");
  3530. PrintToConsole("(Helga)\n");
  3531. return;
  3532. }
  3533. PrintToConsole("TestObjectUuids : PASS\n");
  3534. }
  3535. void
  3536. SPipe (
  3537. )
  3538. /*++
  3539. Routine Description:
  3540. This routine is used to perform a build verification test of the
  3541. rpc runtime. This test checks for basic functionality of the
  3542. runtime. It works with Sebastian in uclnt.exe.
  3543. --*/
  3544. {
  3545. PrintToConsole("SPipe : Test Pipes\n");
  3546. Status = RpcServerRegisterIf(
  3547. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,0,0);
  3548. if (Status)
  3549. {
  3550. ApiError("SPipe","RpcServerRegisterIf",Status);
  3551. PrintToConsole("SPipe : FAIL - Unable to Register Interface ");
  3552. PrintToConsole("(Isabelle)\n");
  3553. return;
  3554. }
  3555. Status = RpcServerRegisterIf(
  3556. (RPC_IF_HANDLE) &HelgaInterfaceInformation,0,0);
  3557. if (Status)
  3558. {
  3559. ApiError("SPipe","RpcServerRegisterIf",Status);
  3560. PrintToConsole("SPipe : FAIL - Unable to Register Interface ");
  3561. PrintToConsole("(Isabelle)\n");
  3562. return;
  3563. }
  3564. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3565. GetEndpoint(SPIPE), 0);
  3566. if (Status)
  3567. {
  3568. ApiError("SPipe","RpcServerUseProtseqEpWrapper",Status);
  3569. PrintToConsole("SPipe : FAIL - Unable to Use Protseq Endpoint\n");
  3570. return;
  3571. }
  3572. Status = RpcServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3573. if (Status)
  3574. {
  3575. ApiError("SPipe","RpcServerListen",Status);
  3576. PrintToConsole("SPipe : FAIL - RpcServerListen Failed\n");
  3577. return;
  3578. }
  3579. if (IsabelleErrors != 0)
  3580. {
  3581. PrintToConsole("SPipe : FAIL - Error(s) in Isabelle Interface\n");
  3582. IsabelleErrors = 0;
  3583. return;
  3584. }
  3585. Status = RpcServerUnregisterIf(
  3586. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3587. if (Status)
  3588. {
  3589. ApiError("SPipe","RpcServerUnregisterIf",Status);
  3590. PrintToConsole("SPipe : FAIL - Unable to Unregister Interface ");
  3591. PrintToConsole("(Isabelle)\n");
  3592. return;
  3593. }
  3594. PrintToConsole("SPipe : PASS\n");
  3595. }
  3596. void
  3597. Grant (
  3598. )
  3599. /*++
  3600. Routine Description:
  3601. This routine is used to perform a build verification test of the
  3602. rpc runtime. This test checks for basic functionality of the
  3603. runtime. It works with Graham in uclnt.exe.
  3604. --*/
  3605. {
  3606. PrintToConsole("Grant : Verify Basic Server Functionality\n");
  3607. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3608. 0, (RPC_MGR_EPV PAPI *) 722);
  3609. if (Status)
  3610. {
  3611. ApiError("Grant","stub_RegisterIf",Status);
  3612. PrintToConsole("Grant : FAIL - Unable to Register Interface ");
  3613. PrintToConsole("(Helga)\n");
  3614. return;
  3615. }
  3616. Status = stub_RegisterIf(
  3617. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3618. if (Status)
  3619. {
  3620. ApiError("Grant","stub_RegisterIf",Status);
  3621. PrintToConsole("Grant : FAIL - Unable to Register Interface ");
  3622. PrintToConsole("(Isabelle)\n");
  3623. return;
  3624. }
  3625. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3626. GetEndpoint(GRANT), 0);
  3627. if (Status)
  3628. {
  3629. ApiError("Grant","RpcServerUseProtseqEpWrapper",Status);
  3630. PrintToConsole("Grant : FAIL - Unable to Use Protseq Endpoint\n");
  3631. return;
  3632. }
  3633. HelgaCheckManagerEpv = 1;
  3634. HelgaManagerEpv = (RPC_MGR_EPV PAPI *) 722;
  3635. if (DatagramFlag == 0)
  3636. {
  3637. HelgaCheckObject = 1;
  3638. }
  3639. HelgaMagicNumber = 106;
  3640. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3641. HelgaCheckObject = 0;
  3642. HelgaCheckManagerEpv = 0;
  3643. if (Status)
  3644. {
  3645. ApiError("Grant","stub_ServerListen",Status);
  3646. PrintToConsole("Grant : FAIL - stub_ServerListen Failed\n");
  3647. return;
  3648. }
  3649. if (HelgaErrors != 0)
  3650. {
  3651. PrintToConsole("Grant : FAIL - Error(s) in Helga Interface\n");
  3652. HelgaErrors = 0;
  3653. return;
  3654. }
  3655. if (IsabelleErrors != 0)
  3656. {
  3657. PrintToConsole("Grant : FAIL - Error(s) in Isabelle Interface\n");
  3658. IsabelleErrors = 0;
  3659. return;
  3660. }
  3661. Status = RpcServerUnregisterIf(
  3662. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3663. if (Status)
  3664. {
  3665. ApiError("Grant","RpcServerUnregisterIf",Status);
  3666. PrintToConsole("Grant : FAIL - Unable to Unregister Interface ");
  3667. PrintToConsole("(Isabelle)\n");
  3668. return;
  3669. }
  3670. Status = RpcServerUnregisterIf(
  3671. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3672. if (Status)
  3673. {
  3674. ApiError("Grant","RpcServerUnregisterIf",Status);
  3675. PrintToConsole("Grant : FAIL - Unable to Unregister Interface ");
  3676. PrintToConsole("(Helga)\n");
  3677. return;
  3678. }
  3679. PrintToConsole("Grant : PASS\n");
  3680. }
  3681. void
  3682. Elliot (
  3683. )
  3684. /*++
  3685. Routine Description:
  3686. This routine tests callbacks, multiple address, and multiple
  3687. interfaces. It works with Edward in uclnt.exe. We also test
  3688. client side binding as well. This test is named after a famous
  3689. (at least in his mind) cat.
  3690. --*/
  3691. {
  3692. PrintToConsole("Elliot : Verify Multiple Addresses and Interfaces, ");
  3693. PrintToConsole("and Callbacks\n");
  3694. Status = RpcImpersonateClient(0);
  3695. if ( Status != RPC_S_NO_CALL_ACTIVE )
  3696. {
  3697. ApiError("Elliot", "RpcImpersonateClient", Status);
  3698. PrintToConsole("Elliot : FAIL - RpcImpersonateClient\n");
  3699. return;
  3700. }
  3701. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3702. GetEndpoint(ELLIOTMAXIMIZE), 0);
  3703. if (Status)
  3704. {
  3705. ApiError("Elliot","RpcServerUseProtseqEpWrapper",Status);
  3706. PrintToConsole("Elliot : FAIL - Unable to Use Protseq Endpoint\n");
  3707. return;
  3708. }
  3709. Status = stub_RegisterIf((RPC_IF_HANDLE) &SylviaInterfaceInformation,
  3710. 0, 0);
  3711. if (Status)
  3712. {
  3713. ApiError("Elliot","stub_RegisterIf",Status);
  3714. PrintToConsole("Elliot : FAIL - Unable to Register Interface ");
  3715. PrintToConsole("(Sylvia)\n");
  3716. return;
  3717. }
  3718. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3719. GetEndpoint(ELLIOTMINIMIZE), 0);
  3720. if (Status)
  3721. {
  3722. ApiError("Elliot","RpcServerUseProtseqEpWrapper",Status);
  3723. PrintToConsole("Elliot : FAIL - Unable to Use Protseq Endpoint\n");
  3724. return;
  3725. }
  3726. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3727. GetEndpoint(ELLIOTNORMAL), 0);
  3728. if (Status)
  3729. {
  3730. ApiError("Elliot","RpcServerUseProtseqEpWrapper",Status);
  3731. PrintToConsole("Elliot : FAIL - Unable to Use Protseq Endpoint\n");
  3732. return;
  3733. }
  3734. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3735. 0, 0);
  3736. if (Status)
  3737. {
  3738. ApiError("Elliot","stub_RegisterIf",Status);
  3739. PrintToConsole("Elliot : FAIL - Unable to Register Interface ");
  3740. PrintToConsole("(Helga)\n");
  3741. return;
  3742. }
  3743. Status = stub_RegisterIf(
  3744. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  3745. 0, 0);
  3746. if (Status)
  3747. {
  3748. ApiError("Elliot","stub_RegisterIf",Status);
  3749. PrintToConsole("Elliot : FAIL - Unable to Register Interface ");
  3750. PrintToConsole("(Isabelle)\n");
  3751. return;
  3752. }
  3753. PrintToConsole("Elliot: Start listening\n") ;
  3754. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 1);
  3755. if (Status)
  3756. {
  3757. ApiError("Elliot","stub_ServerListen",Status);
  3758. PrintToConsole("Elliot : FAIL - stub_ServerListen Failed\n");
  3759. return;
  3760. }
  3761. if (AutoListenFlag == 0)
  3762. {
  3763. PrintToConsole("Elliot: RpcMgmtWaitServerListen\n") ;
  3764. Status = RpcMgmtWaitServerListen();
  3765. if (Status)
  3766. {
  3767. ApiError("Elliot","RpcMgmtWaitServerListen",Status);
  3768. PrintToConsole("Elliot : FAIL - RpcMgmtWaitServerListen Failed\n");
  3769. return;
  3770. }
  3771. }
  3772. if (HelgaErrors != 0)
  3773. {
  3774. PrintToConsole("Elliot : FAIL - Error(s) in Helga Interface\n");
  3775. HelgaErrors = 0;
  3776. return;
  3777. }
  3778. if (SylviaErrors != 0)
  3779. {
  3780. PrintToConsole("Elliot : FAIL - Error(s) in Sylvia Interface\n");
  3781. SylviaErrors = 0;
  3782. return;
  3783. }
  3784. if (IsabelleErrors != 0)
  3785. {
  3786. PrintToConsole("Elliot : FAIL - Error(s) in Isabelle Interface\n");
  3787. IsabelleErrors = 0;
  3788. return;
  3789. }
  3790. if (AutoListenFlag)
  3791. {
  3792. // unregister the interfaces individually
  3793. Status = RpcServerUnregisterIf(
  3794. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3795. if (Status)
  3796. {
  3797. ApiError("Elliot","RpcServerUnregisterIf",Status);
  3798. PrintToConsole("Elliot : FAIL - Unable to Unregister Interface ");
  3799. PrintToConsole("(Isabelle)\n");
  3800. return;
  3801. }
  3802. Status = RpcServerUnregisterIf(
  3803. (RPC_IF_HANDLE) &SylviaInterfaceInformation, 0, 0);
  3804. if (Status)
  3805. {
  3806. ApiError("Elliot","RpcServerUnregisterIf",Status);
  3807. PrintToConsole("Elliot : FAIL - Unable to Unregister Interface ");
  3808. PrintToConsole("(Sylvia)\n");
  3809. return;
  3810. }
  3811. Status = RpcServerUnregisterIf(
  3812. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3813. if (Status)
  3814. {
  3815. ApiError("Elliot","RpcServerUnregisterIf",Status);
  3816. PrintToConsole("Elliot : FAIL - Unable to Unregister Interface ");
  3817. PrintToConsole("(Helga)\n");
  3818. return;
  3819. }
  3820. }
  3821. else
  3822. {
  3823. Status = RpcServerUnregisterIf(0, 0, 0);
  3824. if (Status)
  3825. {
  3826. ApiError("Elliot","RpcServerUnregisterIf",Status);
  3827. PrintToConsole("Elliot : FAIL - Unable to Unregister All Interfaces\n");
  3828. return;
  3829. }
  3830. }
  3831. PrintToConsole("Elliot : PASS\n");
  3832. }
  3833. void
  3834. Andromida (
  3835. )
  3836. /*++
  3837. Routine Description:
  3838. This routine is used to perform multithreaded client tests. This
  3839. test works with the Astro test in uclnt.exe.
  3840. --*/
  3841. {
  3842. PrintToConsole("Andromida : Multithreaded Clients\n");
  3843. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3844. GetEndpoint(ANDROMIDA), 0);
  3845. if (Status)
  3846. {
  3847. ApiError("Andromida","RpcServerUseProtseqEpWrapper",Status);
  3848. PrintToConsole("Andromida : FAIL - Unable to Use Protseq Endpoint\n");
  3849. return;
  3850. }
  3851. Status = stub_RegisterIf((RPC_IF_HANDLE) &SylviaInterfaceInformation,
  3852. 0, 0);
  3853. if (Status)
  3854. {
  3855. ApiError("Andromida","stub_RegisterIf",Status);
  3856. PrintToConsole("Andromida : FAIL - Unable to Register Interface ");
  3857. PrintToConsole("(Sylvia)\n");
  3858. return;
  3859. }
  3860. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3861. 0, 0);
  3862. if (Status)
  3863. {
  3864. ApiError("Andromida","stub_RegisterIf",Status);
  3865. PrintToConsole("Andromida : FAIL - Unable to Register Interface ");
  3866. PrintToConsole("(Helga)\n");
  3867. return;
  3868. }
  3869. Status = stub_RegisterIf(
  3870. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  3871. 0, 0);
  3872. if (Status)
  3873. {
  3874. ApiError("Andromida","stub_RegisterIf",Status);
  3875. PrintToConsole("Andromida : FAIL - Unable to Register Interface ");
  3876. PrintToConsole("(Isabelle)\n");
  3877. return;
  3878. }
  3879. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  3880. if (Status)
  3881. {
  3882. ApiError("Andromida","stub_ServerListen",Status);
  3883. PrintToConsole("Andromida : FAIL - stub_ServerListen Failed\n");
  3884. return;
  3885. }
  3886. if (HelgaErrors != 0)
  3887. {
  3888. PrintToConsole("Andromida : FAIL - Error(s) in Helga Interface\n");
  3889. HelgaErrors = 0;
  3890. return;
  3891. }
  3892. if (SylviaErrors != 0)
  3893. {
  3894. PrintToConsole("Andromida : FAIL - Error(s) in Sylvia Interface\n");
  3895. SylviaErrors = 0;
  3896. return;
  3897. }
  3898. if (IsabelleErrors != 0)
  3899. {
  3900. PrintToConsole("Andromida : FAIL - Error(s) in Isabelle Interface\n");
  3901. IsabelleErrors = 0;
  3902. return;
  3903. }
  3904. Status = RpcServerUnregisterIf(
  3905. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  3906. if (Status)
  3907. {
  3908. ApiError("Andromida","RpcServerUnregisterIf",Status);
  3909. PrintToConsole("Andromida : FAIL - Unable to Unregister Interface ");
  3910. PrintToConsole("(Isabelle)\n");
  3911. return;
  3912. }
  3913. Status = RpcServerUnregisterIf(
  3914. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  3915. if (Status)
  3916. {
  3917. ApiError("Andromida","RpcServerUnregisterIf",Status);
  3918. PrintToConsole("Andromida : FAIL - Unable to Unregister Interface ");
  3919. PrintToConsole("(Helga)\n");
  3920. return;
  3921. }
  3922. Status = RpcServerUnregisterIf(
  3923. (RPC_IF_HANDLE) &SylviaInterfaceInformation, 0, 0);
  3924. if (Status)
  3925. {
  3926. ApiError("Andromida","RpcServerUnregisterIf",Status);
  3927. PrintToConsole("Andromida : FAIL - Unable to Unregister Interface ");
  3928. PrintToConsole("(Sylvia)\n");
  3929. return;
  3930. }
  3931. PrintToConsole("Andromida : PASS\n");
  3932. }
  3933. void
  3934. Fredrick (
  3935. )
  3936. /*++
  3937. Routine Description:
  3938. This routine is used to verify all client DCE rpc runtime APIs. It
  3939. works with Fitzgerald in uclnt.exe.
  3940. --*/
  3941. {
  3942. PrintToConsole("Fredrick : Verify All Client APIs\n");
  3943. if (TransportType == RPC_TRANSPORT_TCP)
  3944. {
  3945. struct hostent *he;
  3946. WSADATA data;
  3947. struct in_addr addr;
  3948. u_long AddrAsLong;
  3949. RPC_CHAR Buffer[50];
  3950. RPC_POLICY Policy;
  3951. if ( WSAStartup(2, &data) != NO_ERROR)
  3952. {
  3953. ApiError("Fredrick","WSAStartup",Status);
  3954. PrintToConsole("Fredrick : FAIL - Unable to call WSAStartup\n");
  3955. return;
  3956. }
  3957. // Get Dns hostname
  3958. he = gethostbyname( "" );
  3959. if (he == NULL)
  3960. {
  3961. ApiError("Fredrick","gethostbyname",Status);
  3962. PrintToConsole("Fredrick : FAIL - Unable to call gethostbyname\n");
  3963. return;
  3964. }
  3965. // AddrAsLong = ntohl(*(DWORD *)he->h_addr_list[0]);
  3966. memcpy(&addr, (DWORD *)he->h_addr_list[0], sizeof(addr));
  3967. swprintf(Buffer, L"%d.%d.%d.%d", addr.S_un.S_un_b.s_b1, addr.S_un.S_un_b.s_b2,
  3968. addr.S_un.S_un_b.s_b3, addr.S_un.S_un_b.s_b4);
  3969. Policy.Length = sizeof(RPC_POLICY);
  3970. Policy.EndpointFlags = 0;
  3971. Policy.NICFlags = 0;
  3972. Status = I_RpcServerUseProtseqEp2(Buffer, L"ncacn_ip_tcp", 3, L"2500", NULL, &Policy);
  3973. if (Status)
  3974. {
  3975. ApiError("Fredrick","I_RpcServerUseProtseqEp2",Status);
  3976. PrintToConsole("Fredrick : FAIL - Unable to Use Protseq Endpoint\n");
  3977. return;
  3978. }
  3979. }
  3980. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  3981. GetEndpoint(FREDRICK), 0);
  3982. if (Status)
  3983. {
  3984. ApiError("Fredrick","RpcServerUseProtseqEpWrapper",Status);
  3985. PrintToConsole("Fredrick : FAIL - Unable to Use Protseq Endpoint\n");
  3986. return;
  3987. }
  3988. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  3989. 0, 0);
  3990. if (Status)
  3991. {
  3992. ApiError("Fredrick","stub_RegisterIf",Status);
  3993. PrintToConsole("Fredrick : FAIL - Unable to Register Interface ");
  3994. PrintToConsole("(Helga)\n");
  3995. return;
  3996. }
  3997. Status = stub_RegisterIf(
  3998. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  3999. 0, 0);
  4000. if (Status)
  4001. {
  4002. ApiError("Fredrick","stub_RegisterIf",Status);
  4003. PrintToConsole("Fredrick : FAIL - Unable to Register Interface ");
  4004. PrintToConsole("(Isabelle)\n");
  4005. return;
  4006. }
  4007. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  4008. if (Status)
  4009. {
  4010. ApiError("Fredrick","stub_ServerListen",Status);
  4011. PrintToConsole("Fredrick : FAIL - stub_ServerListen Failed\n");
  4012. return;
  4013. }
  4014. if (HelgaErrors != 0)
  4015. {
  4016. PrintToConsole("Fredrick : FAIL - Error(s) in Helga Interface\n");
  4017. HelgaErrors = 0;
  4018. return;
  4019. }
  4020. if (IsabelleErrors != 0)
  4021. {
  4022. PrintToConsole("Fredrick : FAIL - Error(s) in Isabelle Interface\n");
  4023. IsabelleErrors = 0;
  4024. return;
  4025. }
  4026. PauseExecution(10000L);
  4027. Status = RpcServerUnregisterIf(
  4028. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  4029. if (Status)
  4030. {
  4031. ApiError("Fredrick","RpcServerUnregisterIf",Status);
  4032. PrintToConsole("Fredrick : FAIL - Unable to Unregister Interface ");
  4033. PrintToConsole("(Isabelle)\n");
  4034. return;
  4035. }
  4036. Status = RpcServerUnregisterIf(
  4037. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  4038. if (Status)
  4039. {
  4040. ApiError("Fredrick","RpcServerUnregisterIf",Status);
  4041. PrintToConsole("Fredrick : FAIL - Unable to Unregister Interface ");
  4042. PrintToConsole("(Helga)\n");
  4043. return;
  4044. }
  4045. PrintToConsole("Fredrick : PASS\n");
  4046. }
  4047. void
  4048. GenerateUuidValue (
  4049. IN unsigned short MagicNumber,
  4050. OUT UUID PAPI * Uuid
  4051. )
  4052. /*++
  4053. Routine Description:
  4054. This routine is used to generate a value for a uuid. The magic
  4055. number argument is used in mysterious and wonderful ways to
  4056. generate a uuid (which is not necessarily correct).
  4057. Arguments:
  4058. MagicNumber - Supplies a magic number which will be used to
  4059. generate a uuid.
  4060. Uuid - Returns the generated uuid.
  4061. --*/
  4062. {
  4063. Uuid->Data1 = ((unsigned long) MagicNumber)
  4064. * ((unsigned long) MagicNumber);
  4065. Uuid->Data2 = MagicNumber;
  4066. Uuid->Data3 = MagicNumber / 2;
  4067. Uuid->Data4[0] = MagicNumber % 256;
  4068. Uuid->Data4[1] = MagicNumber % 257;
  4069. Uuid->Data4[2] = MagicNumber % 258;
  4070. Uuid->Data4[3] = MagicNumber % 259;
  4071. Uuid->Data4[4] = MagicNumber % 260;
  4072. Uuid->Data4[5] = MagicNumber % 261;
  4073. Uuid->Data4[6] = MagicNumber % 262;
  4074. Uuid->Data4[7] = MagicNumber % 263;
  4075. }
  4076. int
  4077. ChristopherObjectSetType (
  4078. IN unsigned short ObjectMagicNumber,
  4079. IN unsigned short TypeMagicNumber,
  4080. IN unsigned int MustFailFlag
  4081. )
  4082. /*++
  4083. Routine Description:
  4084. This routine calls the RpcObjectSetType routine. The object uuid
  4085. is generated using the object magic number argument, and the type
  4086. uuid uses the type magic number argument.
  4087. Arguments:
  4088. ObjectMagicNumber - Supplies the magic number to be used to generate
  4089. the object uuid to be passed to RpcObjectSetType.
  4090. TypeMagicNumber - Supplies the magic number to use to generate the
  4091. type uuid.
  4092. MustFailFlag - Supplies a flag indicating whether or not the call
  4093. to RpcObjectSetType must succeed or fail. If this flag is
  4094. zero, then RpcObjectSetType must return RPC_S_OK, otherwise,
  4095. the test fails. If the flag is non-zero, then RpcObjectSetType
  4096. must return RPC_S_ALREADY_REGISTERED.
  4097. Return Value:
  4098. Zero will be returned if the test completes successfully; otherise,
  4099. non-zero will be returned.
  4100. --*/
  4101. {
  4102. UUID ObjectUuid;
  4103. UUID TypeUuid;
  4104. GenerateUuidValue(ObjectMagicNumber,&ObjectUuid);
  4105. GenerateUuidValue(TypeMagicNumber,&TypeUuid);
  4106. Status = RpcObjectSetType(&ObjectUuid,&TypeUuid);
  4107. if (MustFailFlag == 0)
  4108. {
  4109. if (Status)
  4110. {
  4111. ApiError("Christopher","RpcObjectSetType",Status);
  4112. PrintToConsole("Christopher : FAIL - Can not Set Object Type\n");
  4113. return(1);
  4114. }
  4115. }
  4116. else
  4117. {
  4118. if (Status != RPC_S_ALREADY_REGISTERED)
  4119. {
  4120. PrintToConsole("Christopher : FAIL - RpcObjectSetType did not");
  4121. PrintToConsole(" fail as expected\n");
  4122. return(1);
  4123. }
  4124. }
  4125. return(0);
  4126. }
  4127. int
  4128. ChristopherObjectSetNullType (
  4129. IN unsigned short ObjectMagicNumber,
  4130. IN unsigned int UseNullUuidFlag,
  4131. IN unsigned int MustFailFlag
  4132. )
  4133. /*++
  4134. Routine Description:
  4135. This routine calls the RpcObjectSetType routine. The object uuid
  4136. is generated using the object magic number argument, and the type
  4137. uuid is either not specified, or is the null uuid.
  4138. Arguments:
  4139. ObjectMagicNumber - Supplies the magic number to be used to generate
  4140. the object uuid to be passed to RpcObjectSetType.
  4141. UseNullUuidFlag - Supplies a flag indicating whether to specify
  4142. the null uuid for the type uuid or nothing. If this flag is
  4143. non-zero the null uuid will be specified as the type uuid;
  4144. otherwise, the type uuid will not be specified.
  4145. MustFailFlag - Supplies a flag indicating whether or not the call
  4146. to RpcObjectSetType must succeed or fail. If this flag is
  4147. zero, then RpcObjectSetType must return RPC_S_OK, otherwise,
  4148. the test fails. If the flag is non-zero, then RpcObjectSetType
  4149. must return RPC_S_OBJECT_NOT_FOUND.
  4150. Return Value:
  4151. Zero will be returned if the test completes successfully; otherise,
  4152. non-zero will be returned.
  4153. --*/
  4154. {
  4155. UUID ObjectUuid;
  4156. UUID TypeUuid;
  4157. GenerateUuidValue(ObjectMagicNumber,&ObjectUuid);
  4158. memset(&TypeUuid,0,sizeof(UUID));
  4159. if (UseNullUuidFlag == 0)
  4160. Status = RpcObjectSetType(&ObjectUuid,&TypeUuid);
  4161. else
  4162. Status = RpcObjectSetType(&ObjectUuid,0);
  4163. if (MustFailFlag == 0)
  4164. {
  4165. if (Status)
  4166. {
  4167. ApiError("Christopher","RpcObjectSetType",Status);
  4168. PrintToConsole("Christopher : FAIL - Can not Set Object Type\n");
  4169. return(1);
  4170. }
  4171. }
  4172. else
  4173. {
  4174. if (Status != RPC_S_OK)
  4175. {
  4176. PrintToConsole("Christopher : FAIL - RpcObjectSetType did not");
  4177. PrintToConsole(" fail as expected\n");
  4178. return(1);
  4179. }
  4180. }
  4181. return(0);
  4182. }
  4183. int
  4184. ChristopherObjectInqType (
  4185. IN unsigned short ObjectMagicNumber,
  4186. IN unsigned short TypeMagicNumber,
  4187. IN unsigned int MustFailFlag
  4188. )
  4189. /*++
  4190. Routine Description:
  4191. This routine calls the RpcObjectInqType routine. The object uuid
  4192. is generated using the object magic number argument, and the type
  4193. uuid uses the type magic number argument.
  4194. Arguments:
  4195. ObjectMagicNumber - Supplies the magic number to be used to generate
  4196. the object uuid to be passed to RpcObjectInqType.
  4197. TypeMagicNumber - Supplies the magic number to use to generate the
  4198. expected type uuid.
  4199. MustFailFlag - Supplies a flag indicating whether or not the call
  4200. to RpcObjectInqType must fail or succeed. If this flag is
  4201. non-zero, RpcObjectInqType must return RPC_S_OBJECT_NOT_FOUND,
  4202. otherwise the test fails. If the flag is zero, then
  4203. RpcObjectInqType must succeed.
  4204. Return Value:
  4205. Zero will be returned if the test completes successfully; otherise,
  4206. non-zero will be returned.
  4207. --*/
  4208. {
  4209. UUID ObjectUuid;
  4210. UUID TypeUuid;
  4211. UUID ExpectedTypeUuid;
  4212. GenerateUuidValue(ObjectMagicNumber,&ObjectUuid);
  4213. GenerateUuidValue(TypeMagicNumber,&ExpectedTypeUuid);
  4214. Status = RpcObjectInqType(&ObjectUuid,&TypeUuid);
  4215. if (MustFailFlag == 0)
  4216. {
  4217. if (Status)
  4218. {
  4219. ApiError("Christopher","RpcObjectInqType",Status);
  4220. PrintToConsole("Christopher : FAIL - Can not Inquire");
  4221. PrintToConsole(" Object Type\n");
  4222. return(1);
  4223. }
  4224. if (memcmp(&ExpectedTypeUuid,&TypeUuid,sizeof(UUID)) != 0)
  4225. {
  4226. PrintToConsole("Christopher : FAIL - TypeUuid != ");
  4227. PrintToConsole("ExpectedTypeUuid\n");
  4228. return(1);
  4229. }
  4230. }
  4231. else
  4232. {
  4233. if (Status != RPC_S_OBJECT_NOT_FOUND)
  4234. {
  4235. PrintToConsole("Christopher : FAIL - RpcObjectInqType ");
  4236. PrintToConsole("succeeded\n");
  4237. return(1);
  4238. }
  4239. }
  4240. return(0);
  4241. }
  4242. static UUID ChristopherObjectUuid;
  4243. static UUID ChristopherTypeUuid;
  4244. void
  4245. ChristopherRpcObjectInqFn (
  4246. IN UUID PAPI * ObjectUuid,
  4247. OUT UUID PAPI * TypeUuid,
  4248. OUT RPC_STATUS PAPI * Status
  4249. )
  4250. /*++
  4251. Routine Description:
  4252. This routine is the object inquiry function we will pass to the
  4253. runtime. If the object uuid specified is equal to the global
  4254. object uuid, we will return the global type uuid and RPC_S_OK;
  4255. otherwise, we will return RPC_S_OBJECT_NOT_FOUND.
  4256. Arguments:
  4257. ObjectUuid - Supplies the object uuid to compare with the global
  4258. object uuid.
  4259. TypeUuid - Returns the type uuid if the object uuid is found.
  4260. Status - Returns the status of the operations. This will be
  4261. either RPC_S_OK or RPC_S_OBJECT_NOT_FOUND.
  4262. --*/
  4263. {
  4264. if (memcmp(ObjectUuid,&ChristopherObjectUuid,sizeof(UUID)) != 0)
  4265. {
  4266. *Status = RPC_S_OBJECT_NOT_FOUND;
  4267. return;
  4268. }
  4269. memcpy(TypeUuid,&ChristopherTypeUuid,sizeof(UUID));
  4270. *Status = RPC_S_OK;
  4271. return;
  4272. }
  4273. int
  4274. ChristopherTestObject (
  4275. )
  4276. /*++
  4277. Routine Description:
  4278. This routine is used by Christopher to test RpcObjectInqType,
  4279. RpcObjectSetInqFn, and RpcObjectSetType.
  4280. Return Value:
  4281. Zero will be returned if all of the tests complete successfully,
  4282. otherwise, non-zero will be returned.
  4283. --*/
  4284. {
  4285. if (ChristopherObjectSetType(12345,2987,0))
  4286. return(1);
  4287. if (ChristopherObjectInqType(12345,2987,0))
  4288. return(1);
  4289. if (ChristopherObjectInqType(5421,2987,1))
  4290. return(1);
  4291. if (ChristopherObjectSetType(12345,2987,1))
  4292. return(1);
  4293. if (ChristopherObjectSetType(12,2987,0))
  4294. return(1);
  4295. if (ChristopherObjectSetType(123,2987,0))
  4296. return(1);
  4297. if (ChristopherObjectSetType(1234,2987,0))
  4298. return(1);
  4299. if (ChristopherObjectInqType(12,2987,0))
  4300. return(1);
  4301. if (ChristopherObjectInqType(123,2987,0))
  4302. return(1);
  4303. if (ChristopherObjectInqType(1234,2987,0))
  4304. return(1);
  4305. if (ChristopherObjectInqType(12345,2987,0))
  4306. return(1);
  4307. if (ChristopherObjectSetNullType(123,0,0))
  4308. return(1);
  4309. if (ChristopherObjectSetNullType(1234,1,0))
  4310. return(1);
  4311. if (ChristopherObjectInqType(123,2987,1))
  4312. return(1);
  4313. if (ChristopherObjectInqType(1234,2987,1))
  4314. return(1);
  4315. if (ChristopherObjectSetNullType(5421,0,1))
  4316. return(1);
  4317. if (ChristopherObjectSetNullType(421,0,1))
  4318. return(1);
  4319. Status = RpcObjectSetInqFn(&ChristopherRpcObjectInqFn);
  4320. if (Status)
  4321. {
  4322. ApiError("Christopher","RpcObjectSetInqFn",Status);
  4323. PrintToConsole("Christopher : FAIL - RpcObjectSetInqFn ");
  4324. PrintToConsole("(ChristopherRpcObjectInqFn)\n");
  4325. return(1);
  4326. }
  4327. GenerateUuidValue(10666,&ChristopherObjectUuid);
  4328. GenerateUuidValue(8466,&ChristopherTypeUuid);
  4329. if (ChristopherObjectInqType(96,2987,1))
  4330. return(1);
  4331. if (ChristopherObjectInqType(10666,8466,0))
  4332. return(1);
  4333. Status = RpcObjectSetInqFn(0);
  4334. if (Status)
  4335. {
  4336. ApiError("Christopher","RpcObjectSetInqFn",Status);
  4337. PrintToConsole("Christopher : FAIL - RpcObjectSetInqFn (0)\n");
  4338. return(1);
  4339. }
  4340. if (ChristopherObjectInqType(10666,8466,1))
  4341. return(1);
  4342. return(0);
  4343. }
  4344. int
  4345. ChristopherTestInquire (
  4346. )
  4347. /*++
  4348. Routine Description:
  4349. Christopher uses this routine to test RpcServerInqIf and RpcIfInqId.
  4350. Return Value:
  4351. Zero will be returned if all of the test successfully pass. Otherwise,
  4352. non-zero will be returned.
  4353. --*/
  4354. {
  4355. RPC_IF_ID RpcIfId;
  4356. UUID TypeUuid;
  4357. RPC_MGR_EPV PAPI * ManagerEpv;
  4358. Status = RpcIfInqId((RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4359. &RpcIfId);
  4360. if (Status)
  4361. {
  4362. ApiError("Christopher","RpcIfInqId",Status);
  4363. PrintToConsole("Christopher : FAIL - Error in RpcIfInqId\n");
  4364. return(1);
  4365. }
  4366. if ( (RpcIfId.VersMajor != 1)
  4367. || (RpcIfId.VersMinor != 1)
  4368. || (RpcIfId.Uuid.Data1 != 9)
  4369. || (RpcIfId.Uuid.Data2 != 8)
  4370. || (RpcIfId.Uuid.Data3 != 8)
  4371. || (RpcIfId.Uuid.Data4[0] != 7)
  4372. || (RpcIfId.Uuid.Data4[1] != 7)
  4373. || (RpcIfId.Uuid.Data4[2] != 7)
  4374. || (RpcIfId.Uuid.Data4[3] != 7)
  4375. || (RpcIfId.Uuid.Data4[4] != 7)
  4376. || (RpcIfId.Uuid.Data4[5] != 7)
  4377. || (RpcIfId.Uuid.Data4[6] != 7)
  4378. || (RpcIfId.Uuid.Data4[7] != 7))
  4379. {
  4380. PrintToConsole("Christopher : FAIL - Wrong RpcIfId\n");
  4381. return(1);
  4382. }
  4383. TypeUuid.Data1 = 0x12345678;
  4384. TypeUuid.Data2 = 0x9ABC;
  4385. TypeUuid.Data3 = 0xDEF0;
  4386. TypeUuid.Data4[0] = 0x12;
  4387. TypeUuid.Data4[1] = 0x34;
  4388. TypeUuid.Data4[2] = 0x56;
  4389. TypeUuid.Data4[3] = 0x78;
  4390. TypeUuid.Data4[4] = 0x9A;
  4391. TypeUuid.Data4[5] = 0xBC;
  4392. TypeUuid.Data4[6] = 0xDE;
  4393. TypeUuid.Data4[7] = 0xF0;
  4394. Status = stub_RegisterIf(
  4395. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4396. &TypeUuid, (RPC_MGR_EPV PAPI *) 38756);
  4397. if (Status)
  4398. {
  4399. ApiError("Christopher","stub_RegisterIf",Status);
  4400. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4401. PrintToConsole("(Isabelle)\n");
  4402. return(1);
  4403. }
  4404. Status = RpcServerInqIf(
  4405. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4406. &TypeUuid,&ManagerEpv);
  4407. if (Status)
  4408. {
  4409. ApiError("Christopher","RpcServerInqIf",Status);
  4410. PrintToConsole("Christopher : FAIL - RpcServerInqIf\n");
  4411. return(1);
  4412. }
  4413. if (ManagerEpv != (RPC_MGR_EPV PAPI *) 38756)
  4414. {
  4415. PrintToConsole("Christopher : FAIL - ManagerEpv != 38756\n");
  4416. return(1);
  4417. }
  4418. Status = RpcServerUnregisterIf(
  4419. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  4420. if (Status)
  4421. {
  4422. ApiError("Christopher","RpcServerUnregisterIf",Status);
  4423. PrintToConsole("Christopher : FAIL - Unable to Unregister");
  4424. PrintToConsole(" Interface (Isabelle)\n");
  4425. return(1);
  4426. }
  4427. return(0);
  4428. }
  4429. void
  4430. Christopher (
  4431. )
  4432. /*++
  4433. Routine Description:
  4434. We verify all server side APIs in this routine. The idea is to
  4435. emphasize complete coverage, rather than indepth coverage. Actually,
  4436. by all server side APIs, I really mean all server side APIs except
  4437. for security and name service. The following list is the APIs
  4438. which will be tested by this routine.
  4439. RpcBindingInqObject [SCONNECTION]
  4440. RpcBindingToStringBinding [SCONNECTION]
  4441. RpcBindingToStringBinding [SVR_BINDING_HANDLE]
  4442. RpcBindingVectorFree
  4443. RpcIfInqId
  4444. RpcNetworkInqProtseqs
  4445. RpcObjectInqType
  4446. RpcObjectSetInqFn
  4447. RpcObjectSetType
  4448. RpcProtseqVectorFree
  4449. RpcServerInqBindings
  4450. RpcServerInqIf
  4451. RpcServerListen
  4452. stub_RegisterIf
  4453. RpcServerUnregisterIf
  4454. RpcServerUseAllProtseqs
  4455. RpcServerUseAllProtseqsIf
  4456. RpcServerUseProtseq
  4457. RpcServerUseProtseqEpWrapper
  4458. RpcServerUseProtseqIf
  4459. RpcMgmtStopServerListening
  4460. RpcMgmtInqIfIds
  4461. RpcIfIdVectorFree
  4462. --*/
  4463. {
  4464. RPC_PROTSEQ_VECTORA * RpcProtseqVector;
  4465. unsigned int Index;
  4466. UUID TypeUuid;
  4467. UUID ObjectUuid;
  4468. RPC_IF_ID_VECTOR * InterfaceIdVector;
  4469. unsigned char * String;
  4470. PrintToConsole("Christopher : Verify All Server APIs\n");
  4471. Status = RpcNetworkInqProtseqsA(&RpcProtseqVector);
  4472. if (Status)
  4473. {
  4474. ApiError("Christopher","RpcNetworkInqProtseqs",Status);
  4475. PrintToConsole("Christopher : FAIL - RpcNetworkInqProtseqs\n");
  4476. return;
  4477. }
  4478. PrintToConsole("Christopher : (RpcNetworkInqProtseqs)\n");
  4479. for (Index = 0; Index < RpcProtseqVector->Count; Index++)
  4480. {
  4481. PrintToConsole(" ");
  4482. PrintToConsole((char *) RpcProtseqVector->Protseq[Index]);
  4483. PrintToConsole("\n");
  4484. }
  4485. Status = RpcProtseqVectorFreeA(&RpcProtseqVector);
  4486. if (Status)
  4487. {
  4488. ApiError("Christopher","RpcProtseqVectorFree",Status);
  4489. PrintToConsole("Christopher : FAIL - RpcProtseqVectorFree\n");
  4490. return;
  4491. }
  4492. Status = RpcProtseqVectorFreeA(&RpcProtseqVector);
  4493. if (Status)
  4494. {
  4495. ApiError("Christopher","RpcProtseqVectorFree",Status);
  4496. PrintToConsole("Christopher : FAIL - RpcProtseqVectorFree\n");
  4497. return;
  4498. }
  4499. ChristopherIsabelleError = 0;
  4500. // This routine will test RpcServerInqIf and RpcIfInqId for us.
  4501. if (ChristopherTestInquire() != 0)
  4502. return;
  4503. // We test RpcObjectInqType, RpcObjectSetInqFn, and RpcObjectSetType
  4504. // in this routine.
  4505. if (ChristopherTestObject() != 0)
  4506. return;
  4507. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4508. GetEndpoint(CHRISTOPHER), 0);
  4509. if (Status)
  4510. {
  4511. ApiError("Christopher","RpcServerUseProtseqEpWrapper",Status);
  4512. PrintToConsole("Christopher : FAIL - Unable to Use Protseq ");
  4513. PrintToConsole("Endpoint\n");
  4514. return;
  4515. }
  4516. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4517. GetEndpoint(CHRISTOPHER), 0);
  4518. if (Status != RPC_S_DUPLICATE_ENDPOINT)
  4519. {
  4520. ApiError("Christopher","RpcServerUseProtseqEpWrapper",Status);
  4521. PrintToConsole("Christopher : FAIL - Able to Add Duplicate ");
  4522. PrintToConsole("Endpoint\n");
  4523. return;
  4524. }
  4525. Status = stub_RegisterIf(
  4526. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4527. 0, 0);
  4528. if (Status)
  4529. {
  4530. ApiError("Christopher","stub_RegisterIf",Status);
  4531. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4532. PrintToConsole("(Isabelle)\n");
  4533. return;
  4534. }
  4535. // added for synchro support
  4536. Status = stub_RegisterIf(
  4537. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  4538. 0, 0);
  4539. if (Status)
  4540. {
  4541. ApiError("Christopher","stub_RegisterIf",Status);
  4542. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4543. PrintToConsole("(Helga)\n");
  4544. return;
  4545. }
  4546. GenerateUuidValue(288, &ObjectUuid);
  4547. GenerateUuidValue(3010, &TypeUuid);
  4548. Status = RpcObjectSetType(&ObjectUuid, &TypeUuid);
  4549. if (Status)
  4550. {
  4551. ApiError("Christopher","RpcObjectSetType",Status);
  4552. PrintToConsole("Christopher : FAIL - Unable to Set Object Type\n");
  4553. return;
  4554. }
  4555. Status = stub_RegisterIf(
  4556. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  4557. &TypeUuid, (RPC_MGR_EPV PAPI *) 9814);
  4558. if (Status)
  4559. {
  4560. ApiError("Christopher","stub_RegisterIf",Status);
  4561. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4562. PrintToConsole("(Helga)\n");
  4563. return;
  4564. }
  4565. Status = stub_RegisterIf(
  4566. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4567. &TypeUuid, (RPC_MGR_EPV PAPI *) 9814);
  4568. if (Status)
  4569. {
  4570. ApiError("Christopher","stub_RegisterIf",Status);
  4571. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4572. PrintToConsole("(Isabelle)\n");
  4573. return;
  4574. }
  4575. Status = RpcServerUseAllProtseqsIfWrapper(1,
  4576. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0);
  4577. if (Status)
  4578. {
  4579. ApiError("Christopher","RpcServerUseAllProtseqsIfWrapper",Status);
  4580. PrintToConsole("Christopher : FAIL - Unable to Use All Protseqs ");
  4581. PrintToConsole("from Interface\n");
  4582. return;
  4583. }
  4584. Status = RpcServerUseProtseqIfWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4585. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0);
  4586. if (Status)
  4587. {
  4588. ApiError("Christopher","RpcServerUseProtseqIfWrapper",Status);
  4589. PrintToConsole("Christopher : FAIL - Unable to Use Protseq From ");
  4590. PrintToConsole("Interface\n");
  4591. return;
  4592. }
  4593. Status = stub_RegisterIf(
  4594. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  4595. 0, 0);
  4596. if (Status)
  4597. {
  4598. ApiError("Christopher","stub_RegisterIf",Status);
  4599. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4600. PrintToConsole("(Sylvia)\n");
  4601. return;
  4602. }
  4603. Status = stub_RegisterIf(
  4604. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  4605. &TypeUuid, (RPC_MGR_EPV PAPI *) 9814);
  4606. if (Status)
  4607. {
  4608. ApiError("Christopher","stub_RegisterIf",Status);
  4609. PrintToConsole("Christopher : FAIL - Unable to Register Interface ");
  4610. PrintToConsole("(Sylvia)\n");
  4611. return;
  4612. }
  4613. if (AutoListenFlag == 0)
  4614. {
  4615. Status = stub_ServerListen(123, 122, 0);
  4616. if ( Status != RPC_S_MAX_CALLS_TOO_SMALL )
  4617. {
  4618. ApiError("Christopher", "stub_ServerListen", Status);
  4619. PrintToConsole("Christopher : FAIL - stub_ServerListen\n");
  4620. return;
  4621. }
  4622. }
  4623. PrintToConsole("Christopher : Start Listening\n") ;
  4624. HelgaManagerEpv = (RPC_MGR_EPV PAPI *) 9814;
  4625. HelgaCheckManagerEpv = 1;
  4626. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  4627. HelgaCheckManagerEpv = 0;
  4628. if (Status)
  4629. {
  4630. ApiError("Christopher","stub_ServerListen",Status);
  4631. PrintToConsole("Christopher : FAIL - stub_ServerListen Failed\n");
  4632. return;
  4633. }
  4634. if (ChristopherIsabelleError != 0)
  4635. {
  4636. ChristopherIsabelleError = 0;
  4637. return;
  4638. }
  4639. Status = RpcMgmtInqIfIds(0, &InterfaceIdVector);
  4640. if ( Status != RPC_S_OK )
  4641. {
  4642. ApiError("Christopher", "RpcMgmtInqIfIds", Status);
  4643. PrintToConsole("Christopher : FAIL - Unable to Inquire Interface Ids\n");
  4644. return;
  4645. }
  4646. for (Index = 0; Index < InterfaceIdVector->Count; Index++)
  4647. {
  4648. PrintToConsole(" ");
  4649. UuidToStringA(&(InterfaceIdVector->IfId[Index]->Uuid), &String);
  4650. PrintToConsole((char *) String);
  4651. RpcStringFreeA(&String);
  4652. PrintToConsole(" %d.%d\n", InterfaceIdVector->IfId[Index]->VersMajor,
  4653. InterfaceIdVector->IfId[Index]->VersMinor);
  4654. }
  4655. Status = RpcIfIdVectorFree(&InterfaceIdVector);
  4656. if ( ( Status != RPC_S_OK )
  4657. || ( InterfaceIdVector != 0 ) )
  4658. {
  4659. ApiError("Christopher", "RpcIfIdVectorFree", Status);
  4660. PrintToConsole("Christopher : FAIL - Unable to Free IfIdVector\n");
  4661. return;
  4662. }
  4663. if (HelgaErrors != 0)
  4664. {
  4665. PrintToConsole("Christopher : FAIL - Error(s) in Helga");
  4666. PrintToConsole(" Interface\n");
  4667. HelgaErrors = 0;
  4668. return;
  4669. }
  4670. Status = RpcServerUnregisterIf(
  4671. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 1);
  4672. if (Status)
  4673. {
  4674. ApiError("Christopher","RpcServerUnregisterIf",Status);
  4675. PrintToConsole("Christopher : FAIL - Unable to Unregister");
  4676. PrintToConsole(" Interface (Helga)\n");
  4677. return;
  4678. }
  4679. if (IsabelleErrors != 0)
  4680. {
  4681. PrintToConsole("Christopher : FAIL - Error(s) in Isabelle");
  4682. PrintToConsole(" Interface\n");
  4683. IsabelleErrors = 0;
  4684. return;
  4685. }
  4686. Status = RpcServerUnregisterIf(
  4687. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 1);
  4688. if (Status)
  4689. {
  4690. ApiError("Christopher","RpcServerUnregisterIf",Status);
  4691. PrintToConsole("Christopher : FAIL - Unable to Unregister");
  4692. PrintToConsole(" Interface (Isabelle)\n");
  4693. return;
  4694. }
  4695. if (SylviaErrors != 0)
  4696. {
  4697. PrintToConsole("Christopher : FAIL - Error(s) in Sylvia Interface\n");
  4698. SylviaErrors = 0;
  4699. return;
  4700. }
  4701. Status = RpcServerUnregisterIf(
  4702. (RPC_IF_HANDLE) &SylviaInterfaceInformation, 0, 1);
  4703. if (Status)
  4704. {
  4705. ApiError("Christopher","RpcServerUnregisterIf",Status);
  4706. PrintToConsole("Christopher : FAIL - Unable to Unregister");
  4707. PrintToConsole(" Interface (Sylvia)\n");
  4708. return;
  4709. }
  4710. Status = RpcServerUseProtseqWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS, 0);
  4711. if (Status)
  4712. {
  4713. ApiError("Christopher","RpcServerUseProtseq",Status);
  4714. PrintToConsole("Christopher : FAIL - Unable to Use Protseq\n");
  4715. return;
  4716. }
  4717. Status = RpcServerUseAllProtseqsWrapper(1, 0);
  4718. if (Status)
  4719. {
  4720. ApiError("Christopher","RpcServerUseAllProtseqsWrapper",Status);
  4721. PrintToConsole("Christopher : FAIL - Unable to Use All Protseqs\n");
  4722. return;
  4723. }
  4724. if (InquireBindings("Christopher") != 0)
  4725. return;
  4726. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4727. GetEndpoint(CHRISTOPHERMUSTFAILONE), 0);
  4728. if (Status != RPC_S_INVALID_ENDPOINT_FORMAT)
  4729. {
  4730. PrintToConsole("Christopher : FAIL - Status != ");
  4731. PrintToConsole("RPC_S_INVALID_ENDPOINT_FORMAT");
  4732. PrintToConsole(" (ChristopherMustFailOne)\n");
  4733. return;
  4734. }
  4735. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4736. GetEndpoint(CHRISTOPHERMUSTFAILTWO), 0);
  4737. if (Status != RPC_S_INVALID_ENDPOINT_FORMAT)
  4738. {
  4739. PrintToConsole("Christopher : FAIL - Status != ");
  4740. PrintToConsole("RPC_S_INVALID_ENDPOINT_FORMAT");
  4741. PrintToConsole(" (ChristopherMustFailTwo)\n");
  4742. return;
  4743. }
  4744. // SkipInvalidEndpointFormat:
  4745. Status = RpcServerUseProtseqEpWrapper((unsigned char *) "ncacn_bad",
  4746. MAX_CALL_REQUESTS, GetEndpoint(CHRISTOPHERMUSTFAILONE), 0);
  4747. if (Status != RPC_S_PROTSEQ_NOT_SUPPORTED)
  4748. {
  4749. PrintToConsole("Christopher : FAIL - Status != ");
  4750. PrintToConsole("RPC_S_PROTSEQ_NOT_SUPPORTED (ncacn_bad)\n");
  4751. return;
  4752. }
  4753. Status = RpcServerUseProtseqEpWrapper((unsigned char *) "mkm_np",
  4754. MAX_CALL_REQUESTS, GetEndpoint(CHRISTOPHERMUSTFAILONE), 0);
  4755. if (Status != RPC_S_PROTSEQ_NOT_SUPPORTED)
  4756. {
  4757. PrintToConsole("Christopher : FAIL - Status != ");
  4758. PrintToConsole("RPC_S_PROTSEQ_NOT_SUPPORTED (bad_np)\n");
  4759. return;
  4760. }
  4761. PrintToConsole("Christopher : PASS\n");
  4762. }
  4763. void
  4764. David (
  4765. )
  4766. /*++
  4767. Routine Description:
  4768. This routine is used to test association context rundown support;
  4769. it works with Daniel in uclnt.exe.
  4770. --*/
  4771. {
  4772. PrintToConsole("David : Association Context and Rundown\n");
  4773. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4774. GetEndpoint(DAVIDFIRST), 0);
  4775. if (Status)
  4776. {
  4777. ApiError("David","RpcServerUseProtseqEpWrapper",Status);
  4778. PrintToConsole("David : FAIL - Unable to Use Protseq Endpoint\n");
  4779. return;
  4780. }
  4781. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4782. GetEndpoint(DAVIDSECOND), 0);
  4783. if (Status)
  4784. {
  4785. ApiError("David","RpcServerUseProtseqEpWrapper",Status);
  4786. PrintToConsole("David : FAIL - Unable to Use Protseq Endpoint\n");
  4787. return;
  4788. }
  4789. Status = stub_RegisterIf(
  4790. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4791. 0, 0);
  4792. if (Status)
  4793. {
  4794. ApiError("David","stub_RegisterIf",Status);
  4795. PrintToConsole("David : FAIL - Unable to Register Interface ");
  4796. PrintToConsole("(Isabelle)\n");
  4797. return;
  4798. }
  4799. // Synchro support
  4800. Status = stub_RegisterIf((RPC_IF_HANDLE) &HelgaInterfaceInformation,
  4801. 0, 0);
  4802. if (Status)
  4803. {
  4804. ApiError("David","stub_RegisterIf",Status);
  4805. PrintToConsole("David : FAIL - Unable to Register Interface ");
  4806. PrintToConsole("(Helga)\n");
  4807. return;
  4808. }
  4809. PrintToConsole("David: Start Listening\n") ;
  4810. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  4811. if (Status)
  4812. {
  4813. ApiError("David","stub_ServerListen",Status);
  4814. PrintToConsole("David : FAIL - stub_ServerListen Failed\n");
  4815. return;
  4816. }
  4817. if (IsabelleErrors != 0)
  4818. {
  4819. PrintToConsole("David : FAIL - Error(s) in Isabelle Interface\n");
  4820. IsabelleErrors = 0;
  4821. return;
  4822. }
  4823. Status = RpcServerUnregisterIf(
  4824. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  4825. if (Status)
  4826. {
  4827. ApiError("David","RpcServerUnregisterIf",Status);
  4828. PrintToConsole("David : FAIL - Unable to Unregister Interface ");
  4829. PrintToConsole("(Isabelle)\n");
  4830. return;
  4831. }
  4832. // we don't unregister helga, as a method of isabelle should have
  4833. // been called to do that
  4834. PrintToConsole("David : PASS\n");
  4835. }
  4836. void
  4837. Tyler ( // Perform security tests. This particular test works with
  4838. // Thomas which lives in uclnt.cxx.
  4839. )
  4840. /*++
  4841. Routine Description:
  4842. Tyler works with Thomas, which lives in uclnt.exe, to perform build
  4843. verification tests of security.
  4844. --*/
  4845. {
  4846. SECURITY_DESCRIPTOR sd, *psd;
  4847. PrintToConsole("Tyler : Test Security\n");
  4848. if (TransportType == RPC_LRPC)
  4849. {
  4850. // ncalrpc needs a security descriptor.
  4851. psd = &sd;
  4852. InitializeSecurityDescriptor(
  4853. psd,
  4854. SECURITY_DESCRIPTOR_REVISION
  4855. );
  4856. if ( FALSE == SetSecurityDescriptorDacl (
  4857. psd,
  4858. TRUE, // Dacl present
  4859. NULL, // NULL Dacl
  4860. FALSE // Not defaulted
  4861. ) )
  4862. {
  4863. ApiError("Tyler","SetSecurityDescriptorDacl",0);
  4864. return;
  4865. }
  4866. }
  4867. else
  4868. {
  4869. psd = 0;
  4870. }
  4871. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4872. GetEndpoint(TYLER), psd);
  4873. if (Status)
  4874. {
  4875. ApiError("Tyler","RpcServerUseProtseqEpWrapper",Status);
  4876. PrintToConsole("Tyler : FAIL - Unable to Use Protseq Endpoint\n");
  4877. return;
  4878. }
  4879. Status = stub_RegisterIf(
  4880. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4881. 0, 0);
  4882. if (Status)
  4883. {
  4884. ApiError("Tyler","stub_RegisterIf",Status);
  4885. PrintToConsole("Tyler : FAIL - Unable to Register Interface ");
  4886. PrintToConsole("(Isabelle)\n");
  4887. return;
  4888. }
  4889. Status = stub_RegisterIf(
  4890. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  4891. 0, 0);
  4892. if (Status)
  4893. {
  4894. ApiError("Tyler","stub_RegisterIf",Status);
  4895. PrintToConsole("Tyler : FAIL - Unable to Register Interface ");
  4896. PrintToConsole("(Helga)\n");
  4897. return;
  4898. }
  4899. Status = RpcServerRegisterAuthInfoA((unsigned char PAPI *)
  4900. "ServerPrincipal", ulSecurityPackage, 0, 0); //hack
  4901. if (Status)
  4902. {
  4903. ApiError("Tyler", "RpcServerRegisterAuthInfo", Status);
  4904. PrintToConsole("Tyler : FAIL - Unable to Register AuthInfo\n");
  4905. return;
  4906. }
  4907. PrintToConsole("Tyler : Listening\n") ;
  4908. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  4909. if (Status)
  4910. {
  4911. ApiError("Tyler","stub_ServerListen",Status);
  4912. PrintToConsole("Tyler : FAIL - stub_ServerListen Failed\n");
  4913. return;
  4914. }
  4915. if (IsabelleErrors != 0)
  4916. {
  4917. PrintToConsole("Tyler : FAIL - Error(s) in Isabelle Interface\n");
  4918. IsabelleErrors = 0;
  4919. return;
  4920. }
  4921. if (HelgaErrors != 0)
  4922. {
  4923. PrintToConsole("Tyler : FAIL - Error(s) in Helga Interface\n");
  4924. HelgaErrors = 0;
  4925. return;
  4926. }
  4927. Status = RpcServerUnregisterIf(
  4928. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  4929. if (Status)
  4930. {
  4931. ApiError("Tyler","RpcServerUnregisterIf",Status);
  4932. PrintToConsole("Tyler : FAIL - Unable to Unregister Interface ");
  4933. PrintToConsole("(Isabelle)\n");
  4934. return;
  4935. }
  4936. Status = RpcServerUnregisterIf(
  4937. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  4938. if (Status)
  4939. {
  4940. ApiError("Tyler","RpcServerUnregisterIf",Status);
  4941. PrintToConsole("Tyler : FAIL - Unable to Unregister Interface ");
  4942. PrintToConsole("(Helga)\n");
  4943. return;
  4944. }
  4945. PrintToConsole("Tyler : PASS\n");
  4946. }
  4947. void
  4948. Terry ( // Perform security tests. This particular test works with
  4949. // Tim which lives in uclnt.cxx.
  4950. )
  4951. /*++
  4952. Routine Description:
  4953. Terry works with Tim, which lives in uclnt.exe, to perform build
  4954. verification tests of NT security.
  4955. --*/
  4956. {
  4957. PrintToConsole("Terry : Test Security\n");
  4958. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  4959. GetEndpoint(TYLER), 0);
  4960. if (Status)
  4961. {
  4962. ApiError("Terry","RpcServerUseProtseqEpWrapper",Status);
  4963. PrintToConsole("Terry : FAIL - Unable to Use Protseq Endpoint\n");
  4964. return;
  4965. }
  4966. Status = stub_RegisterIf(
  4967. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  4968. 0, 0);
  4969. if (Status)
  4970. {
  4971. ApiError("Terry","stub_RegisterIf",Status);
  4972. PrintToConsole("Terry : FAIL - Unable to Register Interface ");
  4973. PrintToConsole("(Isabelle)\n");
  4974. return;
  4975. }
  4976. Status = stub_RegisterIf(
  4977. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  4978. 0, 0);
  4979. if (Status)
  4980. {
  4981. ApiError("Terry","stub_RegisterIf",Status);
  4982. PrintToConsole("Terry : FAIL - Unable to Register Interface ");
  4983. PrintToConsole("(Helga)\n");
  4984. return;
  4985. }
  4986. Status = RpcServerRegisterAuthInfoA((unsigned char PAPI *)
  4987. "ServerPrincipal", ulSecurityPackage, 0, 0);
  4988. if (Status)
  4989. {
  4990. ApiError("Terry", "RpcServerRegisterAuthInfo", Status);
  4991. PrintToConsole("Terry : FAIL - Unable to Register AuthInfo\n");
  4992. return;
  4993. }
  4994. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  4995. if (Status)
  4996. {
  4997. ApiError("Terry","stub_ServerListen",Status);
  4998. PrintToConsole("Terry : FAIL - stub_ServerListen Failed\n");
  4999. return;
  5000. }
  5001. if (IsabelleErrors != 0)
  5002. {
  5003. PrintToConsole("Terry : FAIL - Error(s) in Isabelle Interface\n");
  5004. IsabelleErrors = 0;
  5005. return;
  5006. }
  5007. if (HelgaErrors != 0)
  5008. {
  5009. PrintToConsole("Terry : FAIL - Error(s) in Helga Interface\n");
  5010. HelgaErrors = 0;
  5011. return;
  5012. }
  5013. Status = RpcServerUnregisterIf(
  5014. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5015. if (Status)
  5016. {
  5017. ApiError("Terry","RpcServerUnregisterIf",Status);
  5018. PrintToConsole("Terry : FAIL - Unable to Unregister Interface ");
  5019. PrintToConsole("(Isabelle)\n");
  5020. return;
  5021. }
  5022. Status = RpcServerUnregisterIf(
  5023. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5024. if (Status)
  5025. {
  5026. ApiError("Terry","RpcServerUnregisterIf",Status);
  5027. PrintToConsole("Terry : FAIL - Unable to Unregister Interface ");
  5028. PrintToConsole("(Helga)\n");
  5029. return;
  5030. }
  5031. PrintToConsole("Terry : PASS\n");
  5032. }
  5033. void
  5034. RichardHelper (
  5035. )
  5036. /*++
  5037. Routine Description:
  5038. This routine will be used as a helper by Richard. The description
  5039. of Richard will explain how it is used.
  5040. --*/
  5041. {
  5042. PrintToConsole("Richard : RichardHelper Executed\n");
  5043. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5044. GetEndpoint(RICHARDHELPER), 0);
  5045. if (Status)
  5046. {
  5047. ApiError("RichardHelper", "RpcServerUseProtseqEpWrapper", Status);
  5048. PrintToConsole("RichardHelper : FAIL - Unable to Use Protseq ");
  5049. PrintToConsole("Endpoint\n");
  5050. return;
  5051. }
  5052. Status = stub_RegisterIf(
  5053. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5054. 0, 0);
  5055. if (Status)
  5056. {
  5057. ApiError("RichardHelper","stub_RegisterIf",Status);
  5058. PrintToConsole("RichardHelper : FAIL - Unable to Register Interface ");
  5059. PrintToConsole("(Isabelle)\n");
  5060. return;
  5061. }
  5062. Status = stub_RegisterIf(
  5063. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5064. 0, 0);
  5065. if (Status)
  5066. {
  5067. ApiError("RichardHelper","stub_RegisterIf",Status);
  5068. PrintToConsole("RichardHelper : FAIL - Unable to Register Interface ");
  5069. PrintToConsole("(Helga)\n");
  5070. return;
  5071. }
  5072. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5073. if (Status)
  5074. {
  5075. ApiError("RichardHelper","stub_ServerListen",Status);
  5076. PrintToConsole("RichardHelper : FAIL - stub_ServerListen Failed\n");
  5077. return;
  5078. }
  5079. if (IsabelleErrors != 0)
  5080. {
  5081. PrintToConsole("RichardHelper : FAIL - Error(s) in Isabelle");
  5082. PrintToConsole(" Interface\n");
  5083. IsabelleErrors = 0;
  5084. return;
  5085. }
  5086. Status = RpcServerUnregisterIf(
  5087. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5088. if (Status)
  5089. {
  5090. ApiError("RichardHelper","RpcServerUnregisterIf",Status);
  5091. PrintToConsole("RichardHelper : FAIL - Unable to Unregister ");
  5092. PrintToConsole("Interface (Isabelle)\n");
  5093. return;
  5094. }
  5095. Status = RpcServerUnregisterIf(
  5096. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5097. if (Status)
  5098. {
  5099. ApiError("RichardHelper","RpcServerUnregisterIf",Status);
  5100. PrintToConsole("RichardHelper : FAIL - Unable to Unregister ");
  5101. PrintToConsole("Interface (Helga)\n");
  5102. return;
  5103. }
  5104. }
  5105. void
  5106. Richard (
  5107. )
  5108. /*++
  5109. Description:
  5110. Richard works with Robert (in uclnt.cxx) to test call and callback
  5111. failures. In particular, we want to test that a call failing does
  5112. not invalidate the binding handle. We will do this using the
  5113. RichardHelper routine.
  5114. --*/
  5115. {
  5116. PrintToConsole("Richard : Test Call and Callback Failures\n");
  5117. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5118. GetEndpoint(RICHARD), 0);
  5119. if (Status)
  5120. {
  5121. ApiError("Richard","RpcServerUseProtseqEpWrapper",Status);
  5122. PrintToConsole("Richard : FAIL - Unable to Use Protseq Endpoint\n");
  5123. return;
  5124. }
  5125. Status = stub_RegisterIf(
  5126. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5127. 0, 0);
  5128. if (Status)
  5129. {
  5130. ApiError("Richard","stub_RegisterIf",Status);
  5131. PrintToConsole("Richard : FAIL - Unable to Register Interface ");
  5132. PrintToConsole("(Isabelle)\n");
  5133. return;
  5134. }
  5135. Status = stub_RegisterIf(
  5136. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5137. 0, 0);
  5138. if (Status)
  5139. {
  5140. ApiError("Richard","stub_RegisterIf",Status);
  5141. PrintToConsole("Richard : FAIL - Unable to Register Interface ");
  5142. PrintToConsole("(Helga)\n");
  5143. return;
  5144. }
  5145. PrintToConsole("Richard : Listening\n") ;
  5146. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5147. if (Status)
  5148. {
  5149. ApiError("Richard","stub_ServerListen",Status);
  5150. PrintToConsole("Richard : FAIL - stub_ServerListen Failed\n");
  5151. return;
  5152. }
  5153. if (IsabelleErrors != 0)
  5154. {
  5155. PrintToConsole("Richard : FAIL - Error(s) in Isabelle Interface\n");
  5156. IsabelleErrors = 0;
  5157. return;
  5158. }
  5159. Status = RpcServerUnregisterIf(
  5160. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5161. if (Status)
  5162. {
  5163. ApiError("Richard","RpcServerUnregisterIf",Status);
  5164. PrintToConsole("Richard : FAIL - Unable to Unregister Interface ");
  5165. PrintToConsole("(Isabelle)\n");
  5166. return;
  5167. }
  5168. Status = RpcServerUnregisterIf(
  5169. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5170. if (Status)
  5171. {
  5172. ApiError("Richard","RpcServerUnregisterIf",Status);
  5173. PrintToConsole("Richard : FAIL - Unable to Unregister Interface ");
  5174. PrintToConsole("(Helga)\n");
  5175. return;
  5176. }
  5177. PrintToConsole("Richard : PASS\n");
  5178. }
  5179. void
  5180. Kenneth (
  5181. )
  5182. /*++
  5183. Description:
  5184. Kenneth works with Keith (in uclnt.cxx) to auto reconnect.
  5185. --*/
  5186. {
  5187. PrintToConsole("Kenneth : Test Auto Reconnect\n");
  5188. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5189. GetEndpoint(KENNETH), 0);
  5190. if (Status)
  5191. {
  5192. ApiError("Kenneth","RpcServerUseProtseqEpWrapper",Status);
  5193. PrintToConsole("Kenneth : FAIL - Unable to Use Protseq Endpoint\n");
  5194. return;
  5195. }
  5196. Status = stub_RegisterIf(
  5197. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5198. 0, 0);
  5199. if (Status)
  5200. {
  5201. ApiError("Kenneth","stub_RegisterIf",Status);
  5202. PrintToConsole("Kenneth : FAIL - Unable to Register Interface ");
  5203. PrintToConsole("(Isabelle)\n");
  5204. return;
  5205. }
  5206. // Synchro support
  5207. Status = stub_RegisterIf(
  5208. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5209. 0, 0);
  5210. if (Status)
  5211. {
  5212. ApiError("Kenneth","stub_RegisterIf",Status);
  5213. PrintToConsole("Kenneth : FAIL - Unable to Register Interface ");
  5214. PrintToConsole("(Helga)\n");
  5215. return;
  5216. }
  5217. PrintToConsole("Kenneth : Listening\n") ;
  5218. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5219. if (Status)
  5220. {
  5221. ApiError("Kenneth","stub_ServerListen",Status);
  5222. PrintToConsole("Kenneth : FAIL - stub_ServerListen Failed\n");
  5223. return;
  5224. }
  5225. if (IsabelleErrors != 0)
  5226. {
  5227. PrintToConsole("Kenneth : FAIL - Error(s) in Isabelle Interface\n");
  5228. IsabelleErrors = 0;
  5229. return;
  5230. }
  5231. Status = RpcServerUnregisterIf(
  5232. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5233. if (Status)
  5234. {
  5235. ApiError("Kenneth","RpcServerUnregisterIf",Status);
  5236. PrintToConsole("Kenneth : FAIL - Unable to Unregister Interface ");
  5237. PrintToConsole("(Isabelle)\n");
  5238. return;
  5239. }
  5240. // synchro support
  5241. Status = RpcServerUnregisterIf(
  5242. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5243. if (Status)
  5244. {
  5245. ApiError("Kenneth","RpcServerUnregisterIf",Status);
  5246. PrintToConsole("Kenneth : FAIL - Unable to Unregister Interface ");
  5247. PrintToConsole("(Helga)\n");
  5248. return;
  5249. }
  5250. PrintToConsole("Kenneth : PASS\n");
  5251. }
  5252. void
  5253. BartholomewHelper (
  5254. )
  5255. /*++
  5256. Routine Description:
  5257. Bartholomew will use this routine to help with testing resolving
  5258. endpoints. We just need to use some protocol sequences and then
  5259. register with the endpoint mapper before returning (and exiting).
  5260. --*/
  5261. {
  5262. PrintToConsole("Bartholomew : BartholomewHelper Executed\n");
  5263. Status = RpcServerUseAllProtseqsWrapper(1, 0);
  5264. if (Status)
  5265. {
  5266. ApiError("BartholomewHelper","RpcServerUseAllProtseqsWrapper",Status);
  5267. PrintToConsole("BartholomewHelper : FAIL - Unable to Use All Protseqs\n");
  5268. return;
  5269. }
  5270. Status = RpcServerInqBindings(&BartholomewRpcBindingVector);
  5271. if (Status)
  5272. {
  5273. ApiError("BartholomewHelper", "RpcServerInqBindings", Status);
  5274. PrintToConsole("BartholomewHelper : FAIL - RpcServerInqBindings\n");
  5275. return;
  5276. }
  5277. Status = RpcEpRegisterA((RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5278. BartholomewRpcBindingVector, 0,
  5279. (unsigned char PAPI *) "usvr.exe");
  5280. if (Status)
  5281. {
  5282. ApiError("BartholomewHelper", "RpcEpRegister", Status);
  5283. PrintToConsole("BartholomewHelper : FAIL - RpcEpRegister Failed\n");
  5284. return;
  5285. }
  5286. Status = RpcEpRegisterNoReplaceA(
  5287. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  5288. BartholomewRpcBindingVector, 0,
  5289. (unsigned char PAPI *) "usvr.exe");
  5290. if (Status)
  5291. {
  5292. ApiError("BartholomewHelper", "RpcEpRegisterNoReplace", Status);
  5293. PrintToConsole("BartholomewHelper : FAIL - RpcEpRegister Failed\n");
  5294. return;
  5295. }
  5296. PrintToConsole("Bartholomew : BartholomewHelper Exiting\n");
  5297. }
  5298. void
  5299. Bartholomew (
  5300. )
  5301. /*++
  5302. Routine Description:
  5303. This routine works with Benjamin in uclnt.exe to test that dynamic
  5304. endpoints work. What we actually do is inquire all bindings supported
  5305. by this server, and then have the client bind to each of them, and
  5306. make a call.
  5307. --*/
  5308. {
  5309. PrintToConsole("Bartholomew : Test Dynamic Endpoints\n");
  5310. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5311. GetEndpoint(BARTHOLOMEW), 0);
  5312. if (Status)
  5313. {
  5314. ApiError("Bartholomew", "RpcServerUseProtseqEpWrapper", Status);
  5315. PrintToConsole("Bartholomew : FAIL - Unable to Use Protseq ");
  5316. PrintToConsole("Endpoint\n");
  5317. return;
  5318. }
  5319. Status = stub_RegisterIf(
  5320. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5321. 0, 0);
  5322. if (Status)
  5323. {
  5324. ApiError("Bartholomew","stub_RegisterIf",Status);
  5325. PrintToConsole("Bartholomew : FAIL - Unable to Register Interface ");
  5326. PrintToConsole("(Isabelle)\n");
  5327. return;
  5328. }
  5329. // Synchro support
  5330. Status = stub_RegisterIf(
  5331. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5332. 0, 0);
  5333. if (Status)
  5334. {
  5335. ApiError("Bartholomew","stub_RegisterIf",Status);
  5336. PrintToConsole("Bartholomew : FAIL - Unable to Register Interface ");
  5337. PrintToConsole("(Helga)\n");
  5338. return;
  5339. }
  5340. Status = stub_RegisterIf(
  5341. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  5342. 0, 0);
  5343. if (Status)
  5344. {
  5345. ApiError("Bartholomew","stub_RegisterIf",Status);
  5346. PrintToConsole("Bartholomew : FAIL - Unable to Register Interface ");
  5347. PrintToConsole("(Sylvia)\n");
  5348. return;
  5349. }
  5350. Status = RpcServerUseProtseqWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS, 0);
  5351. if (Status)
  5352. {
  5353. ApiError("Bartholomew","RpcServerUseProtseq",Status);
  5354. PrintToConsole("Bartholomew : FAIL - Unable to Use Protseq\n");
  5355. return;
  5356. }
  5357. Status = RpcServerUseAllProtseqsWrapper(1, 0);
  5358. if (Status)
  5359. {
  5360. ApiError("Bartholomew","RpcServerUseAllProtseqsWrapper",Status);
  5361. PrintToConsole("Bartholomew : FAIL - Unable to Use All Protseqs\n");
  5362. return;
  5363. }
  5364. if ( InquireBindings("Bartholomew") != 0 )
  5365. {
  5366. return;
  5367. }
  5368. Status = RpcServerInqBindings(&BartholomewRpcBindingVector);
  5369. if (Status)
  5370. {
  5371. ApiError("Bartholomew", "RpcServerInqBindings", Status);
  5372. PrintToConsole("Bartholomew : FAIL - RpcServerInqBindings\n");
  5373. return;
  5374. }
  5375. BartholomewIndex = 0;
  5376. if ( UseEndpointMapperFlag != 0 )
  5377. {
  5378. Status = RpcEpRegisterA((RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5379. BartholomewRpcBindingVector, 0,
  5380. (unsigned char PAPI *) "usvr.exe");
  5381. if (Status)
  5382. {
  5383. ApiError("Bartholomew", "RpcEpRegister", Status);
  5384. PrintToConsole("Bartholomew : FAIL - RpcEpRegister Failed\n");
  5385. return;
  5386. }
  5387. Status = RpcEpRegisterNoReplaceA(
  5388. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  5389. BartholomewRpcBindingVector, 0,
  5390. (unsigned char PAPI *) "usvr.exe");
  5391. if (Status)
  5392. {
  5393. ApiError("Bartholomew", "RpcEpRegisterNoReplace", Status);
  5394. PrintToConsole("Bartholomew : FAIL - RpcEpRegister Failed\n");
  5395. return;
  5396. }
  5397. #ifdef WIN32RPC
  5398. PROCESS_INFORMATION ProcessInformation;
  5399. STARTUPINFOA StartupInfo;
  5400. StartupInfo.cb = sizeof(STARTUPINFOA);
  5401. StartupInfo.lpReserved = 0;
  5402. StartupInfo.lpDesktop = 0;
  5403. StartupInfo.lpTitle = 0;
  5404. StartupInfo.dwX = 0;
  5405. StartupInfo.dwY = 0;
  5406. StartupInfo.dwXSize = 0;
  5407. StartupInfo.dwYSize = 0;
  5408. StartupInfo.dwFlags = 0;
  5409. StartupInfo.wShowWindow = 0;
  5410. StartupInfo.cbReserved2 = 0;
  5411. StartupInfo.lpReserved2 = 0;
  5412. char CommandLine[200];
  5413. strcpy(CommandLine, "usvr ");
  5414. strcat(CommandLine, TransportOption);
  5415. strcat(CommandLine, " -bartholomewhelper");
  5416. if (CreateProcessA(0, CommandLine, 0, 0, FALSE,
  5417. 0, 0, 0, &StartupInfo, &ProcessInformation) == FALSE)
  5418. {
  5419. OtherError("Bartholomew","CreateProcessA Failed");
  5420. PrintToConsole("Bartholomew : FAIL - CreateProcess Failed\n");
  5421. return;
  5422. }
  5423. #endif // WIN32RPC
  5424. PauseExecution(2000L);
  5425. }
  5426. PrintToConsole("Bartholomew : Listening\n") ;
  5427. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5428. if (Status)
  5429. {
  5430. ApiError("Bartholomew","stub_ServerListen",Status);
  5431. PrintToConsole("Bartholomew : FAIL - stub_ServerListen Failed\n");
  5432. return;
  5433. }
  5434. Status = RpcBindingVectorFree(&BartholomewRpcBindingVector);
  5435. if (Status)
  5436. {
  5437. ApiError("Bartholomew", "RpcBindingVectorFree", Status);
  5438. PrintToConsole("Bartholomew : FAIL - RpcBindingVectorFree\n");
  5439. return;
  5440. }
  5441. if (BartholomewRpcBindingVector != 0)
  5442. {
  5443. PrintToConsole("Bartholomew : FAIL - ");
  5444. PrintToConsole("BartholomewRpcBindingVector != 0\n");
  5445. return;
  5446. }
  5447. // Synchro support
  5448. Status = RpcServerUnregisterIf(
  5449. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5450. if (Status)
  5451. {
  5452. ApiError("Bartholomew","RpcServerUnregisterIf",Status);
  5453. PrintToConsole("Bartholomew : FAIL - Unable to Unregister ");
  5454. PrintToConsole("Interface (Helga)\n");
  5455. return;
  5456. }
  5457. if (IsabelleErrors != 0)
  5458. {
  5459. PrintToConsole("Bartholomew : FAIL - Error(s) in Isabelle");
  5460. PrintToConsole(" Interface\n");
  5461. IsabelleErrors = 0;
  5462. return;
  5463. }
  5464. Status = RpcServerUnregisterIf(
  5465. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5466. if (Status)
  5467. {
  5468. ApiError("Bartholomew","RpcServerUnregisterIf",Status);
  5469. PrintToConsole("Bartholomew : FAIL - Unable to Unregister ");
  5470. PrintToConsole("Interface (Isabelle)\n");
  5471. return;
  5472. }
  5473. if (SylviaErrors != 0)
  5474. {
  5475. PrintToConsole("Bartholomew : FAIL - Error(s) in Sylvia");
  5476. PrintToConsole(" Interface\n");
  5477. HelgaErrors = 0;
  5478. return;
  5479. }
  5480. Status = RpcServerUnregisterIf(
  5481. (RPC_IF_HANDLE) &SylviaInterfaceInformation, 0, 0);
  5482. if (Status)
  5483. {
  5484. ApiError("Bartholomew","RpcServerUnregisterIf",Status);
  5485. PrintToConsole("Bartholomew : FAIL - Unable to Unregister ");
  5486. PrintToConsole("Interface (Sylvia)\n");
  5487. return;
  5488. }
  5489. PrintToConsole("Bartholomew : PASS\n");
  5490. }
  5491. void
  5492. TestYield (
  5493. )
  5494. /*++
  5495. Routine Description:
  5496. This routine works with Harold in uclnt.exe to test that idle
  5497. connections get cleaned up properly, and that context is maintained.
  5498. --*/
  5499. {
  5500. PrintToConsole("TestYeild : Test Yielding\n");
  5501. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5502. GetEndpoint(TESTYIELD), 0);
  5503. if (Status)
  5504. {
  5505. ApiError("TestYield","RpcServerUseProtseqEpWrapper",Status);
  5506. PrintToConsole("TestYield: FAIL - Unable to Use Protseq Endpoint\n");
  5507. return;
  5508. }
  5509. // Synchro support
  5510. Status = stub_RegisterIf(
  5511. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5512. 0, 0);
  5513. if (Status)
  5514. {
  5515. ApiError("TestYield","stub_RegisterIf",Status);
  5516. PrintToConsole("TestYield: FAIL - Unable to Register Interface ");
  5517. PrintToConsole("(Helga)\n");
  5518. return;
  5519. }
  5520. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5521. if (Status)
  5522. {
  5523. ApiError("TestYield","stub_ServerListen",Status);
  5524. PrintToConsole("TestYield: FAIL - stub_ServerListen Failed\n");
  5525. return;
  5526. }
  5527. Status = RpcServerUnregisterIf(
  5528. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5529. if (Status)
  5530. {
  5531. ApiError("Herman","RpcServerUnregisterIf",Status);
  5532. PrintToConsole("Herman : FAIL - Unable to Unregister Interface ");
  5533. PrintToConsole("(Helga)\n");
  5534. return;
  5535. }
  5536. PrintToConsole("TestYield: PASS\n");
  5537. }
  5538. void
  5539. Herman (
  5540. )
  5541. /*++
  5542. Routine Description:
  5543. This routine works with Harold in uclnt.exe to test that idle
  5544. connections get cleaned up properly, and that context is maintained.
  5545. --*/
  5546. {
  5547. PrintToConsole("Herman : Test Idle Connection Cleanup and Context\n");
  5548. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5549. GetEndpoint(HERMAN), 0);
  5550. if (Status)
  5551. {
  5552. ApiError("Herman","RpcServerUseProtseqEpWrapper",Status);
  5553. PrintToConsole("Herman : FAIL - Unable to Use Protseq Endpoint\n");
  5554. return;
  5555. }
  5556. // Synchro support
  5557. Status = stub_RegisterIf(
  5558. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5559. 0, 0);
  5560. if (Status)
  5561. {
  5562. ApiError("Herman","stub_RegisterIf",Status);
  5563. PrintToConsole("Herman : FAIL - Unable to Register Interface ");
  5564. PrintToConsole("(Helga)\n");
  5565. return;
  5566. }
  5567. Status = stub_RegisterIf(
  5568. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5569. 0, 0);
  5570. if (Status)
  5571. {
  5572. ApiError("Herman","stub_RegisterIf",Status);
  5573. PrintToConsole("Herman : FAIL - Unable to Register Interface ");
  5574. PrintToConsole("(Isabelle)\n");
  5575. return;
  5576. }
  5577. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5578. if (Status)
  5579. {
  5580. ApiError("Herman","stub_ServerListen",Status);
  5581. PrintToConsole("Herman : FAIL - stub_ServerListen Failed\n");
  5582. return;
  5583. }
  5584. if (IsabelleErrors != 0)
  5585. {
  5586. PrintToConsole("Herman : FAIL - Error(s) in Isabelle Interface\n");
  5587. IsabelleErrors = 0;
  5588. return;
  5589. }
  5590. Status = RpcServerUnregisterIf(
  5591. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5592. if (Status)
  5593. {
  5594. ApiError("Herman","RpcServerUnregisterIf",Status);
  5595. PrintToConsole("Herman : FAIL - Unable to Unregister Interface ");
  5596. PrintToConsole("(Isabelle)\n");
  5597. return;
  5598. }
  5599. Status = RpcServerUnregisterIf(
  5600. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5601. if (Status)
  5602. {
  5603. ApiError("Herman","RpcServerUnregisterIf",Status);
  5604. PrintToConsole("Herman : FAIL - Unable to Unregister Interface ");
  5605. PrintToConsole("(Helga)\n");
  5606. return;
  5607. }
  5608. PrintToConsole("Herman : PASS\n");
  5609. }
  5610. void
  5611. Ivan (
  5612. )
  5613. /*++
  5614. Routine Description:
  5615. This routine stress tests the runtime. It works with Isaac in uclnt.exe.
  5616. --*/
  5617. {
  5618. PrintToConsole("Ivan : Stress Test\n");
  5619. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5620. GetEndpoint(IVAN), 0);
  5621. if (Status)
  5622. {
  5623. ApiError("Ivan","RpcServerUseProtseqEpWrapper",Status);
  5624. PrintToConsole("Ivan : FAIL - Unable to Use Protseq Endpoint\n");
  5625. return;
  5626. }
  5627. Status = stub_RegisterIf(
  5628. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5629. 0, 0);
  5630. if (Status)
  5631. {
  5632. ApiError("Ivan","stub_RegisterIf",Status);
  5633. PrintToConsole("Ivan : FAIL - Unable to Register Interface ");
  5634. PrintToConsole("(Isabelle)\n");
  5635. return;
  5636. }
  5637. Status = stub_RegisterIf(
  5638. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5639. 0, 0);
  5640. if (Status)
  5641. {
  5642. ApiError("Ivan","stub_RegisterIf",Status);
  5643. PrintToConsole("Ivan : FAIL - Unable to Register Interface ");
  5644. PrintToConsole("(Helga)\n");
  5645. return;
  5646. }
  5647. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5648. if (Status)
  5649. {
  5650. ApiError("Ivan","stub_ServerListen",Status);
  5651. PrintToConsole("Ivan : FAIL - stub_ServerListen Failed\n");
  5652. return;
  5653. }
  5654. if (IsabelleErrors != 0)
  5655. {
  5656. PrintToConsole("Ivan : FAIL - Error(s) in Isabelle Interface\n");
  5657. IsabelleErrors = 0;
  5658. return;
  5659. }
  5660. Status = RpcServerUnregisterIf(
  5661. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5662. if (Status)
  5663. {
  5664. ApiError("Ivan","RpcServerUnregisterIf",Status);
  5665. PrintToConsole("Ivan : FAIL - Unable to Unregister Interface ");
  5666. PrintToConsole("(Isabelle)\n");
  5667. return;
  5668. }
  5669. if (HelgaErrors != 0)
  5670. {
  5671. PrintToConsole("Ivan : FAIL - Error(s) in Helga Interface\n");
  5672. HelgaErrors = 0;
  5673. return;
  5674. }
  5675. Status = RpcServerUnregisterIf(
  5676. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5677. if (Status)
  5678. {
  5679. ApiError("Ivan","RpcServerUnregisterIf",Status);
  5680. PrintToConsole("Ivan : FAIL - Unable to Unregister Interface ");
  5681. PrintToConsole("(Helga)\n");
  5682. return;
  5683. }
  5684. PrintToConsole("Ivan : PASS\n");
  5685. }
  5686. void
  5687. Jason (
  5688. )
  5689. /*++
  5690. Routine Description:
  5691. This routine helps perform performance tests of the runtime. It works
  5692. with James in uclnt.exe.
  5693. --*/
  5694. {
  5695. PrintToConsole("Jason : Timing Tests With %d Listen Threads\n",
  5696. MinimumListenThreads);
  5697. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  5698. GetEndpoint(JASON), 0);
  5699. if (Status)
  5700. {
  5701. ApiError("Jason","RpcServerUseProtseqEpWrapper",Status);
  5702. PrintToConsole("Jason : FAIL - Unable to Use Protseq Endpoint\n");
  5703. return;
  5704. }
  5705. Status = stub_RegisterIf(
  5706. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5707. 0, 0);
  5708. if (Status)
  5709. {
  5710. ApiError("Jason","stub_RegisterIf",Status);
  5711. PrintToConsole("Jason : FAIL - Unable to Register Interface ");
  5712. PrintToConsole("(Isabelle)\n");
  5713. return;
  5714. }
  5715. Status = stub_RegisterIf(
  5716. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  5717. 0, 0);
  5718. if (Status)
  5719. {
  5720. ApiError("Jason","stub_RegisterIf",Status);
  5721. PrintToConsole("Jason : FAIL - Unable to Register Interface ");
  5722. PrintToConsole("(Helga)\n");
  5723. return;
  5724. }
  5725. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  5726. if (Status)
  5727. {
  5728. ApiError("Jason","stub_ServerListen",Status);
  5729. PrintToConsole("Jason : FAIL - stub_ServerListen Failed\n");
  5730. return;
  5731. }
  5732. if (IsabelleErrors != 0)
  5733. {
  5734. PrintToConsole("Jason : FAIL - Error(s) in Isabelle Interface\n");
  5735. IsabelleErrors = 0;
  5736. return;
  5737. }
  5738. Status = RpcServerUnregisterIf(
  5739. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  5740. if (Status)
  5741. {
  5742. ApiError("Jason","RpcServerUnregisterIf",Status);
  5743. PrintToConsole("Jason : FAIL - Unable to Unregister Interface ");
  5744. PrintToConsole("(Isabelle)\n");
  5745. return;
  5746. }
  5747. if (HelgaErrors != 0)
  5748. {
  5749. PrintToConsole("Jason : FAIL - Error(s) in Helga Interface\n");
  5750. HelgaErrors = 0;
  5751. return;
  5752. }
  5753. Status = RpcServerUnregisterIf(
  5754. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  5755. if (Status)
  5756. {
  5757. ApiError("Jason","RpcServerUnregisterIf",Status);
  5758. PrintToConsole("Jason : FAIL - Unable to Unregister Interface ");
  5759. PrintToConsole("(Helga)\n");
  5760. return;
  5761. }
  5762. PrintToConsole("Jason : PASS\n");
  5763. }
  5764. void
  5765. WaitForAddressListChange (
  5766. IN void *Ignore
  5767. )
  5768. {
  5769. OVERLAPPED ol;
  5770. SOCKET sock;
  5771. HANDLE hEvent;
  5772. SOCKADDR_IN sockaddr;
  5773. DWORD byteRet;
  5774. hEvent = CreateEvent(0, FALSE, FALSE, 0);
  5775. if (hEvent == 0)
  5776. {
  5777. ApiError("WaitForAddressListChange", "CreateEventW", 0);
  5778. return ;
  5779. }
  5780. sock = WSASocket(AF_INET,
  5781. SOCK_STREAM,
  5782. IPPROTO_TCP,
  5783. 0,
  5784. 0,
  5785. WSA_FLAG_OVERLAPPED);
  5786. if (sock == INVALID_SOCKET)
  5787. {
  5788. ApiError("WaitForAddressListChange", "WSASocketW", GetLastError());
  5789. return;
  5790. }
  5791. sockaddr.sin_addr.s_addr = INADDR_ANY;
  5792. sockaddr.sin_family = AF_INET;
  5793. sockaddr.sin_port = 0;
  5794. if (bind(sock,(struct sockaddr *) &sockaddr, sizeof(SOCKADDR_IN)))
  5795. {
  5796. closesocket(sock);
  5797. return;
  5798. }
  5799. if(listen(sock, 10) == SOCKET_ERROR)
  5800. {
  5801. closesocket(sock);
  5802. return;
  5803. }
  5804. while (1)
  5805. {
  5806. ol.hEvent = hEvent;
  5807. ol.Offset = 0;
  5808. ol.OffsetHigh = 0;
  5809. if (WSAIoctl(sock,
  5810. SIO_ADDRESS_LIST_CHANGE,
  5811. 0, 0, 0, 0, &byteRet, &ol, 0) == SOCKET_ERROR)
  5812. {
  5813. if (WSAGetLastError() != ERROR_IO_PENDING)
  5814. {
  5815. ApiError("WaitForAddressListChange", "DeviceIoControl",
  5816. GetLastError());
  5817. return;
  5818. }
  5819. //
  5820. // Wait for the IO to complete
  5821. //
  5822. WaitForSingleObject(hEvent,INFINITE);
  5823. }
  5824. //
  5825. // figure out the new address list
  5826. //
  5827. //
  5828. // First find out how big a buffer do we need.
  5829. //
  5830. byteRet = 0;
  5831. if (WSAIoctl(sock,
  5832. SIO_ADDRESS_LIST_QUERY,
  5833. 0, 0, 0, 0, &byteRet, NULL, NULL) == 0)
  5834. {
  5835. I_RpcRequestMutex(&PrintMutex);
  5836. PrintToConsole("The Address list has changed, it is now empty\n");
  5837. I_RpcClearMutex(PrintMutex);
  5838. continue;
  5839. }
  5840. else
  5841. {
  5842. if (WSAGetLastError() != WSAEFAULT || byteRet == 0 )
  5843. {
  5844. ApiError("WaitForAddressListChange", "SIO_ADDRESS_LIST_QUERY",
  5845. WSAGetLastError());
  5846. return;
  5847. }
  5848. }
  5849. LPSOCKET_ADDRESS_LIST interfaceList =
  5850. (LPSOCKET_ADDRESS_LIST) I_RpcAllocate(byteRet);
  5851. if( interfaceList == NULL )
  5852. {
  5853. ApiError("WaitForAddressListChange", "I_RpcAllocate", 0);
  5854. return;
  5855. }
  5856. if (WSAIoctl(sock,
  5857. SIO_ADDRESS_LIST_QUERY,
  5858. 0, 0, interfaceList, byteRet,&byteRet,NULL, NULL) != ERROR_SUCCESS)
  5859. {
  5860. ApiError("WaitForAddressListChange", "SIO_ADDRESS_LIST_QUERY",
  5861. WSAGetLastError());
  5862. return;
  5863. }
  5864. I_RpcRequestMutex(&PrintMutex);
  5865. PrintToConsole("The Address list has changed:\n");
  5866. int i;
  5867. for (i = 0; i < interfaceList->iAddressCount; i++)
  5868. {
  5869. PrintToConsole("AF: %d, Address: ",
  5870. interfaceList->Address[i].lpSockaddr->sa_family);
  5871. int j;
  5872. for (j = 0; j<14; j++)
  5873. {
  5874. PrintToConsole("%u ",
  5875. (unsigned char) interfaceList->Address[i].lpSockaddr->sa_data[j]);
  5876. }
  5877. PrintToConsole("\n");
  5878. }
  5879. PrintToConsole("\n");
  5880. I_RpcClearMutex(PrintMutex);
  5881. }
  5882. }
  5883. static unsigned long DefaultThreadStackSize = 0;
  5884. int
  5885. TestPNP (
  5886. )
  5887. {
  5888. unsigned long ThreadIdentifier;
  5889. HANDLE NotificationHandle = 0;
  5890. WSAOVERLAPPED Overlapped;
  5891. unsigned long bytes;
  5892. HANDLE hEvent;
  5893. WSADATA data;
  5894. int retval ;
  5895. if (WSAStartup(2, &data) != NO_ERROR)
  5896. {
  5897. return -1;
  5898. }
  5899. //
  5900. // Create another thread to go off and wait on address list
  5901. // changes
  5902. //
  5903. if (CreateThread(0,
  5904. DefaultThreadStackSize,
  5905. (LPTHREAD_START_ROUTINE) WaitForAddressListChange,
  5906. 0,
  5907. 0,
  5908. &ThreadIdentifier) == 0)
  5909. {
  5910. ApiError("TestPNP", "CreateThread", GetLastError());
  5911. return -1;
  5912. }
  5913. hEvent = CreateEvent(0, FALSE, FALSE, 0);
  5914. if (hEvent == 0)
  5915. {
  5916. ApiError("TestPNP", "CreateEventW", 0);
  5917. return -1;
  5918. }
  5919. retval = WSAProviderConfigChange(
  5920. &NotificationHandle,
  5921. &Overlapped,
  5922. 0
  5923. );
  5924. if (retval != 0 || NotificationHandle == 0)
  5925. {
  5926. ApiError("TestPNP", "WSAProviderConfigChange", retval);
  5927. return -1;
  5928. }
  5929. while (1)
  5930. {
  5931. Overlapped.hEvent = hEvent;
  5932. Overlapped.Offset = 0;
  5933. Overlapped.OffsetHigh = 0;
  5934. retval = WSAProviderConfigChange(
  5935. &NotificationHandle,
  5936. &Overlapped,
  5937. 0
  5938. );
  5939. if (retval != 0)
  5940. {
  5941. if (GetLastError() == WSA_IO_PENDING)
  5942. {
  5943. WaitForSingleObject(hEvent,INFINITE);
  5944. }
  5945. else
  5946. {
  5947. ApiError("TestPNP", "WSAProviderConfigChange", retval);
  5948. return -1;
  5949. }
  5950. }
  5951. WSAPROTOCOL_INFO *lpProtocolBuffer;
  5952. DWORD dwBufferLength = 1;
  5953. int ProtocolCount;
  5954. while (1)
  5955. {
  5956. lpProtocolBuffer = (WSAPROTOCOL_INFO *) I_RpcAllocate(dwBufferLength);
  5957. if (lpProtocolBuffer == 0)
  5958. {
  5959. ApiError("TestPNP", "I_RpcAllocate", 0);
  5960. return -1;
  5961. }
  5962. ProtocolCount = WSAEnumProtocols(
  5963. 0,
  5964. lpProtocolBuffer,
  5965. &dwBufferLength
  5966. );
  5967. if (ProtocolCount != SOCKET_ERROR)
  5968. {
  5969. break;
  5970. }
  5971. I_RpcFree(lpProtocolBuffer);
  5972. if (GetLastError() != WSAENOBUFS)
  5973. {
  5974. return -1;
  5975. }
  5976. }
  5977. int i;
  5978. //
  5979. // take the print mutex for the entire output, so we don't
  5980. // garble it with the other thread
  5981. //
  5982. I_RpcRequestMutex(&PrintMutex);
  5983. PrintToConsole("LoadedProtocols:\n");
  5984. for (i = 0; i < ProtocolCount; i++)
  5985. {
  5986. PrintToConsole("SocketType: %d, Protocol:%d, Address Family: %d\n",
  5987. lpProtocolBuffer[i].iSocketType,
  5988. lpProtocolBuffer[i].iProtocol,
  5989. lpProtocolBuffer[i].iAddressFamily);
  5990. }
  5991. PrintToConsole("\n");
  5992. I_RpcClearMutex(PrintMutex);
  5993. }
  5994. }
  5995. void
  5996. RpcYield()
  5997. {
  5998. RpcServerYield();
  5999. }
  6000. void FireWall (
  6001. )
  6002. {
  6003. PMIB_IFTABLE pMib;
  6004. DWORD Size = 20*sizeof(MIB_IFROW)+sizeof(DWORD);
  6005. UINT i, j;
  6006. for (i = 0; i < 2; i++)
  6007. {
  6008. pMib = (PMIB_IFTABLE) I_RpcAllocate(Size);
  6009. if (pMib == 0)
  6010. {
  6011. return;
  6012. }
  6013. RpcpMemorySet(pMib, 0, Size);
  6014. Status = GetIfTable(pMib, &Size, 0);
  6015. if (Status == 0)
  6016. {
  6017. break;
  6018. }
  6019. }
  6020. if (Status != RPC_S_OK)
  6021. {
  6022. return;
  6023. }
  6024. for (i = 1; i < pMib->dwNumEntries+1; i++)
  6025. {
  6026. for (j = 0; j < pMib->dwNumEntries; j++)
  6027. {
  6028. if (pMib->table[j].dwIndex == i)
  6029. {
  6030. PrintToConsole("IF[%d]: Ethernet: %s\n", i,
  6031. (char *) pMib->table[j].bDescr);
  6032. break;
  6033. }
  6034. }
  6035. }
  6036. }
  6037. extern void
  6038. Async (
  6039. ) ;
  6040. int __cdecl
  6041. main (
  6042. int argc,
  6043. char * argv[]
  6044. )
  6045. /*
  6046. Transports:
  6047. Update this to add a new transport.
  6048. */
  6049. {
  6050. int argscan, testflag = 0;
  6051. RPC_STATS_VECTOR * Statistics;
  6052. char *option ;
  6053. TransportType = RPC_TRANSPORT_NAMEPIPE;
  6054. for (argscan = 1; argscan < argc; argscan++)
  6055. {
  6056. if (strcmp(argv[argscan], "-p") == 0)
  6057. {
  6058. ulSecurityPackage = (unsigned long) atol(argv[argscan+1]);
  6059. argscan++;
  6060. }
  6061. else if (strcmp(argv[argscan],"-warn") == 0)
  6062. WarnFlag = 1;
  6063. else if (strcmp(argv[argscan],"-error") == 0)
  6064. ErrorFlag = 1;
  6065. else if (strcmp(argv[argscan],"-v") == 0)
  6066. Verbose = 1;
  6067. else if (strcmp(argv[argscan],"-verbose") == 0)
  6068. Verbose = 1;
  6069. else if (strcmp(argv[argscan],"-rpcss") == 0)
  6070. {
  6071. UseEndpointMapperFlag = 1;
  6072. }
  6073. else if (strcmp(argv[argscan],"-nosecuritytests") == 0)
  6074. {
  6075. NoSecurityTests = 1;
  6076. }
  6077. else if (strcmp(argv[argscan],"-sigfried") == 0)
  6078. {
  6079. testflag = 1;
  6080. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6081. Sigfried();
  6082. }
  6083. else if (strcmp(argv[argscan],"-hybrid") == 0)
  6084. {
  6085. testflag = 1;
  6086. PrintToConsole("RPC Runtime Hybrid Server Test\n");
  6087. Hybrid();
  6088. }
  6089. else if (strcmp(argv[argscan],"-lpcsecurity") == 0)
  6090. {
  6091. testflag = 1;
  6092. PrintToConsole("RPC Runtime Lpc Security Test\n");
  6093. LpcSecurity();
  6094. }
  6095. else if (strcmp(argv[argscan],"-objuuid") == 0)
  6096. {
  6097. testflag = 1;
  6098. PrintToConsole("RPC Obj Uuid test\n");
  6099. TestObjectUuids();
  6100. }
  6101. else if (strcmp(argv[argscan],"-connid") == 0)
  6102. {
  6103. testflag = 1;
  6104. PrintToConsole("RPC Conn Id test\n");
  6105. TestObjectUuids();
  6106. }
  6107. else if (strcmp(argv[argscan],"-async") == 0)
  6108. {
  6109. testflag = 1;
  6110. PrintToConsole("RPC Runtime Async RPC Tests\n");
  6111. Async();
  6112. }
  6113. else if (strcmp(argv[argscan],"-ee") == 0)
  6114. {
  6115. PrintToConsole("enabling extended errors\n");
  6116. fExtendedError = TRUE;
  6117. }
  6118. else if (strcmp(argv[argscan],"-dgtransport") == 0)
  6119. {
  6120. testflag = 1;
  6121. PrintToConsole("datagram transport tests \n");
  6122. DgTransport();
  6123. }
  6124. else if (strcmp(argv[argscan],"-sendack") == 0)
  6125. {
  6126. testflag = 1;
  6127. PrintToConsole("RPC Runtime datagram delayed-ack Tests\n");
  6128. SendAck();
  6129. }
  6130. else if (strcmp(argv[argscan],"-securityerror") == 0)
  6131. {
  6132. int testnum;
  6133. testflag = 1;
  6134. PrintToConsole("security provider error tests \n");
  6135. argscan++ ;
  6136. if (argscan == argc)
  6137. {
  6138. PrintToConsole("-securityerror: you must specify a test #, or zero for all, or '?' for help\n");
  6139. return 1;
  6140. }
  6141. if (strcmp(argv[argscan], "?") == 0)
  6142. {
  6143. testnum = 100 ;
  6144. }
  6145. else
  6146. {
  6147. testnum = atoi(argv[argscan]) ;
  6148. }
  6149. SecurityErrorWrapper(testnum);
  6150. }
  6151. else if (strcmp(argv[argscan],"-grant") == 0)
  6152. {
  6153. testflag = 1;
  6154. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6155. Grant();
  6156. }
  6157. else if (strcmp(argv[argscan],"-elliot") == 0)
  6158. {
  6159. testflag = 1;
  6160. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6161. Elliot();
  6162. }
  6163. else if (strcmp(argv[argscan],"-andromida") == 0)
  6164. {
  6165. testflag = 1;
  6166. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6167. Andromida();
  6168. }
  6169. else if (strcmp(argv[argscan],"-fredrick") == 0)
  6170. {
  6171. testflag = 1;
  6172. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6173. Fredrick();
  6174. }
  6175. else if (strcmp(argv[argscan],"-christopher") == 0)
  6176. {
  6177. testflag = 1;
  6178. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6179. Christopher();
  6180. }
  6181. else if (strcmp(argv[argscan],"-david") == 0)
  6182. {
  6183. testflag = 1;
  6184. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6185. David();
  6186. }
  6187. else if (strcmp(argv[argscan],"-tyler") == 0)
  6188. {
  6189. testflag = 1;
  6190. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6191. Tyler();
  6192. }
  6193. else if (strcmp(argv[argscan],"-terry") == 0)
  6194. {
  6195. testflag = 1;
  6196. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6197. Terry();
  6198. }
  6199. else if (strcmp(argv[argscan],"-richardhelper") == 0)
  6200. {
  6201. testflag = 1;
  6202. RichardHelper();
  6203. return(0);
  6204. }
  6205. else if (strcmp(argv[argscan],"-bartholomewhelper") == 0)
  6206. {
  6207. testflag = 1;
  6208. BartholomewHelper();
  6209. return(0);
  6210. }
  6211. else if (strcmp(argv[argscan],"-richard") == 0)
  6212. {
  6213. testflag = 1;
  6214. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6215. Richard();
  6216. }
  6217. else if (strcmp(argv[argscan],"-bartholomew") == 0)
  6218. {
  6219. testflag = 1;
  6220. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6221. Bartholomew();
  6222. }
  6223. else if (strcmp(argv[argscan],"-herman") == 0)
  6224. {
  6225. testflag = 1;
  6226. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6227. Herman();
  6228. }
  6229. else if (strcmp(argv[argscan],"-ivan") == 0)
  6230. {
  6231. testflag = 1;
  6232. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6233. Ivan();
  6234. }
  6235. else if (strcmp(argv[argscan],"-jason") == 0)
  6236. {
  6237. testflag = 1;
  6238. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6239. Jason();
  6240. }
  6241. else if (strcmp(argv[argscan],"-kenneth") == 0)
  6242. {
  6243. testflag = 1;
  6244. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6245. Kenneth();
  6246. }
  6247. else if (strcmp(argv[argscan],"-pipe") == 0)
  6248. {
  6249. testflag = 1;
  6250. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6251. SPipe();
  6252. }
  6253. else if (strcmp(argv[argscan],"-testyield") == 0)
  6254. {
  6255. testflag = 1;
  6256. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6257. TestYield();
  6258. }
  6259. else if (strcmp(argv[argscan],"-yield") == 0)
  6260. {
  6261. testflag = 1;
  6262. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6263. RpcYield();
  6264. }
  6265. else if (strcmp(argv[argscan],"-pnp") == 0)
  6266. {
  6267. testflag = 1;
  6268. PrintToConsole("Test PNP stuff\n");
  6269. TestPNP();
  6270. }
  6271. else if (strcmp(argv[argscan],"-namepipe") == 0)
  6272. {
  6273. TransportType = RPC_TRANSPORT_NAMEPIPE;
  6274. TransportOption = argv[argscan];
  6275. }
  6276. else if (strcmp(argv[argscan],"-lrpc") == 0)
  6277. {
  6278. TransportType = RPC_LRPC;
  6279. TransportOption = argv[argscan];
  6280. }
  6281. else if (strcmp(argv[argscan],"-tcp") == 0)
  6282. {
  6283. TransportType = RPC_TRANSPORT_TCP;
  6284. TransportOption = argv[argscan];
  6285. }
  6286. else if (strcmp(argv[argscan],"-udp") == 0)
  6287. {
  6288. DatagramFlag = 1;
  6289. TransportType = RPC_TRANSPORT_UDP;
  6290. TransportOption = argv[argscan];
  6291. }
  6292. else if (strcmp(argv[argscan],"-dnet") == 0)
  6293. {
  6294. TransportType = RPC_TRANSPORT_DNET;
  6295. TransportOption = argv[argscan];
  6296. }
  6297. else if (strcmp(argv[argscan],"-spx") == 0)
  6298. {
  6299. TransportType = RPC_TRANSPORT_SPX;
  6300. TransportOption = argv[argscan];
  6301. }
  6302. else if (strcmp(argv[argscan],"-ipx") == 0)
  6303. {
  6304. DatagramFlag = 1;
  6305. TransportType = RPC_TRANSPORT_IPX;
  6306. TransportOption = argv[argscan];
  6307. }
  6308. else if (strcmp(argv[argscan],"-vns") == 0)
  6309. {
  6310. TransportType = RPC_TRANSPORT_VNS;
  6311. TransportOption = argv[argscan];
  6312. }
  6313. else if (strcmp(argv[argscan], "-dsp") == 0)
  6314. {
  6315. TransportType = RPC_TRANSPORT_DSP ;
  6316. TransportOption = argv[argscan] ;
  6317. }
  6318. else if (strcmp(argv[argscan], "-msmq") == 0)
  6319. {
  6320. DatagramFlag = 1;
  6321. TransportType = RPC_TRANSPORT_MSMQ ;
  6322. TransportOption = argv[argscan] ;
  6323. }
  6324. else if (strcmp(argv[argscan], "-autolisten") == 0)
  6325. {
  6326. AutoListenFlag = 1 ;
  6327. }
  6328. else if (strcmp(argv[argscan], "-ifsecurity") == 0)
  6329. {
  6330. IFSecurity = 1;
  6331. }
  6332. else if (strcmp(argv[argscan], "-firewall") == 0)
  6333. {
  6334. testflag = 1;
  6335. FireWallFlag = 1 ;
  6336. FireWall();
  6337. }
  6338. else if (strcmp(argv[argscan],"-protocol") == 0)
  6339. {
  6340. strcpy(NetBiosProtocol+sizeof("ncacn_nb_")-1, argv[argscan+1]);
  6341. argscan++;
  6342. }
  6343. else if (strcmp(argv[argscan],"-netbios") == 0)
  6344. {
  6345. TransportType = RPC_TRANSPORT_NETBIOS;
  6346. TransportOption = argv[argscan];
  6347. }
  6348. else if (strncmp(argv[argscan], "-listen:", strlen("-listen:"))
  6349. == 0 )
  6350. {
  6351. MinimumListenThreads = atoi(argv[argscan] + strlen("-listen:"));
  6352. if ( MinimumListenThreads == 0 )
  6353. {
  6354. MinimumListenThreads = 1;
  6355. }
  6356. }
  6357. else if (strncmp(argv[argscan], "-rpcsize:", strlen("-rpcsize:"))
  6358. == 0 )
  6359. {
  6360. MaxRpcSize = atoi(argv[argscan] + strlen("-rpcsize:"));
  6361. }
  6362. else if (argv[argscan][0] == '-')
  6363. {
  6364. PrintToConsole("unknown option '%s'\n", argv[argscan]);
  6365. return 1;
  6366. }
  6367. else
  6368. {
  6369. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6370. PrintToConsole("Usage : usvr\n");
  6371. PrintToConsole(" -warn : turn on warning messages\n");
  6372. PrintToConsole(" -error : turn on error messages\n");
  6373. PrintToConsole(" -sigfried\n");
  6374. PrintToConsole(" -grant\n");
  6375. PrintToConsole(" -elliot\n");
  6376. PrintToConsole(" -andromida\n");
  6377. PrintToConsole(" -fredrick\n");
  6378. PrintToConsole(" -christopher\n");
  6379. PrintToConsole(" -david\n");
  6380. PrintToConsole(" -tyler\n");
  6381. PrintToConsole(" -terry\n");
  6382. PrintToConsole(" -richard\n");
  6383. PrintToConsole(" -bartholomew\n");
  6384. PrintToConsole(" -herman\n");
  6385. PrintToConsole(" -ivan\n");
  6386. PrintToConsole(" -jason\n");
  6387. PrintToConsole(" -kenneth\n");
  6388. PrintToConsole(" -namepipe\n");
  6389. PrintToConsole(" -lrpc\n");
  6390. PrintToConsole(" -tcp\n");
  6391. PrintToConsole(" -udp\n");
  6392. PrintToConsole(" -dnet\n");
  6393. PrintToConsole(" -netbios\n");
  6394. PrintToConsole(" -spx\n");
  6395. PrintToConsole(" -dsp\n") ;
  6396. PrintToConsole(" -vns\n") ;
  6397. PrintToConsole(" -msmq\n") ;
  6398. PrintToConsole(" -listen:<listen threads>\n");
  6399. PrintToConsole(" -rpcss\n");
  6400. PrintToConsole(" -p <security provider #>\n");
  6401. PrintToConsole(" -nosecuritytests") ;
  6402. return(1);
  6403. }
  6404. }
  6405. if (!testflag)
  6406. {
  6407. PrintToConsole("RPC Runtime Server Build Verification Test\n");
  6408. PrintToConsole("Sigfried\n") ;
  6409. Sigfried();
  6410. PrintToConsole("Grant\n") ;
  6411. Grant();
  6412. PrintToConsole("Elliot\n") ;
  6413. Elliot();
  6414. PrintToConsole("Andromida\n") ;
  6415. Andromida();
  6416. PrintToConsole("Fredrick\n") ;
  6417. Fredrick();
  6418. PrintToConsole("Christopher\n") ;
  6419. Christopher();
  6420. PrintToConsole("David\n") ;
  6421. David();
  6422. if ( NoSecurityTests == 0)
  6423. {
  6424. PrintToConsole("Tyler\n") ;
  6425. Tyler();
  6426. }
  6427. if ( TransportType != RPC_LRPC )
  6428. {
  6429. PrintToConsole("Richard\n") ;
  6430. Richard();
  6431. }
  6432. PrintToConsole("Kenneth\n") ;
  6433. Kenneth();
  6434. PrintToConsole("Bartholomew\n") ;
  6435. Bartholomew();
  6436. PrintToConsole("Async\n") ;
  6437. Async();
  6438. }
  6439. Status = RpcMgmtInqStats(0,&Statistics);
  6440. if (Status)
  6441. {
  6442. ApiError("main", "RpcMgmtInqStats", Status);
  6443. return(0);
  6444. }
  6445. PrintToConsole("\nCalls (and Callbacks) Received : %lu",
  6446. Statistics->Stats[RPC_C_STATS_CALLS_IN]);
  6447. PrintToConsole("\nCallbacks Sent : %lu",
  6448. Statistics->Stats[RPC_C_STATS_CALLS_OUT]);
  6449. PrintToConsole("\nPackets Received : %lu\nPackets Sent : %lu\n",
  6450. Statistics->Stats[RPC_C_STATS_PKTS_IN],
  6451. Statistics->Stats[RPC_C_STATS_PKTS_OUT]);
  6452. Status = RpcMgmtStatsVectorFree(&Statistics);
  6453. if (Status)
  6454. ApiError("main", "RpcMgmtStatsVectorFree", Status);
  6455. return(0); // To keep the compiler happy.
  6456. }
  6457. //
  6458. // BVT for Async RPC
  6459. //
  6460. //
  6461. // Server side code
  6462. //
  6463. //
  6464. // the following routines outline the server side code for a simple async function.
  6465. //
  6466. #define TRACE(_x) { \
  6467. if (Verbose) \
  6468. {\
  6469. PrintToConsole _x;\
  6470. }\
  6471. }
  6472. #if 0
  6473. //
  6474. // Begin, Approximate idl file
  6475. //
  6476. interface FooInterface {
  6477. int Foo (handle_t hBinding, [in] int sizein, [in] int *bufferin,
  6478. [in, out] int *sizeout, [out] int **bufferout) ;
  6479. }
  6480. // End, idl file
  6481. //
  6482. // Begin, Corresponding ACF file
  6483. //
  6484. interface FooInterface {
  6485. [async] Foo () ;
  6486. }
  6487. // End, acf file
  6488. //
  6489. // look at asyncstub.h for the generated header
  6490. // file for function Foo
  6491. //
  6492. #endif
  6493. ////////////////////////////////////////////////////////////
  6494. // Begin, stubs for Foo //
  6495. ////////////////////////////////////////////////////////////
  6496. RPC_STATUS RPC_ENTRY
  6497. MyRpcAbortAsyncCall (
  6498. IN PRPC_ASYNC_STATE pAsync,
  6499. IN unsigned long ExceptionCode
  6500. )
  6501. /*++
  6502. Routine Description:
  6503. Arguments:
  6504. pAsync - the async handle being registered
  6505. Return Value:
  6506. RPC_S_OK - the call succeeded.
  6507. RPC_S_INVALID_HANDLE - the handle was bad.
  6508. --*/
  6509. {
  6510. return I_RpcAsyncAbortCall(pAsync, ExceptionCode);
  6511. }
  6512. typedef struct {
  6513. RPC_ASYNC_STUB_STATE StubState ;
  6514. RPC_ASYNC_STATE AsyncState ;
  6515. void *state ;
  6516. int sizeout ;
  6517. int *bufferout ;
  6518. } FOO_ASYNC_SERVER_STATE;
  6519. RPC_STATUS
  6520. FooComplete (
  6521. IN PRPC_ASYNC_STATE pAsync,
  6522. IN void *Reply
  6523. )
  6524. /*++
  6525. Routine Description:
  6526. This is a generated stub. It is the completion routine for the function
  6527. Foo. When the server app is done with processing a particular call to
  6528. Foo, It calls Foo_complete to complete the call.
  6529. Arguments:
  6530. pAsync - The async handle. This handle is always the first parameter of every
  6531. Foo_complete routine.
  6532. --*/
  6533. {
  6534. int *Ptr ;
  6535. RPC_MESSAGE Message ;
  6536. RPC_STATUS RpcStatus ;
  6537. FOO_ASYNC_SERVER_STATE *StubInfo =
  6538. (FOO_ASYNC_SERVER_STATE *) pAsync->StubInfo ;
  6539. TRACE(("FooComplete called: %d\n", *((int *) Reply))) ;
  6540. Message.ProcNum = RPC_FLAGS_VALID_BIT ;
  6541. Message.RpcFlags = RPC_BUFFER_ASYNC;
  6542. Message.BufferLength = 8 + StubInfo->sizeout ;
  6543. Message.Handle = StubInfo->StubState.CallHandle ;
  6544. RpcStatus = I_RpcGetBuffer(&Message) ;
  6545. if (RpcStatus)
  6546. {
  6547. return RpcStatus ;
  6548. }
  6549. Ptr = (int *) Message.Buffer ;
  6550. *Ptr++ = *((int *) Reply) ;
  6551. *Ptr++ = StubInfo->sizeout ;
  6552. RpcpMemoryCopy(Ptr, StubInfo->bufferout, StubInfo->sizeout) ;
  6553. I_RpcFree(StubInfo->bufferout) ;
  6554. // send the async reply
  6555. Message.RpcFlags = RPC_BUFFER_ASYNC;
  6556. RpcStatus = I_RpcSend(&Message) ;
  6557. if (RpcStatus)
  6558. {
  6559. return RpcStatus ;
  6560. }
  6561. I_RpcFree(pAsync->StubInfo) ;
  6562. return RPC_S_OK ;
  6563. }
  6564. void
  6565. Foo_s (
  6566. PRPC_MESSAGE Message
  6567. )
  6568. /*++
  6569. Routine Description:
  6570. Generated stub for Foo.
  6571. --*/
  6572. {
  6573. int sizein ;
  6574. int *bufferin ;
  6575. int *Ptr ;
  6576. FOO_ASYNC_SERVER_STATE *StubInfo;
  6577. RPC_STATUS RpcStatus ;
  6578. if ((Message->RpcFlags & RPC_BUFFER_COMPLETE) == 0)
  6579. {
  6580. Message->RpcFlags = RPC_BUFFER_EXTRA;
  6581. RpcStatus = I_RpcReceive (Message, 0) ;
  6582. if (RpcStatus)
  6583. {
  6584. RpcRaiseException(RpcStatus) ;
  6585. }
  6586. }
  6587. StubInfo = (FOO_ASYNC_SERVER_STATE *)
  6588. I_RpcAllocate(sizeof(FOO_ASYNC_SERVER_STATE)) ;
  6589. if (StubInfo == 0)
  6590. {
  6591. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  6592. }
  6593. StubInfo->AsyncState.Size = sizeof(RPC_ASYNC_STATE) ;
  6594. StubInfo->AsyncState.StubInfo = (void *) StubInfo ;
  6595. StubInfo->AsyncState.Flags = 0;
  6596. StubInfo->AsyncState.NotificationType = RpcNotificationTypeNone;
  6597. StubInfo->StubState.CallHandle = Message->Handle ;
  6598. StubInfo->StubState.Flags = 0;
  6599. StubInfo->StubState.CompletionRoutine = FooComplete ;
  6600. RpcStatus = I_RpcAsyncSetHandle(
  6601. Message,
  6602. (PRPC_ASYNC_STATE) &(StubInfo->AsyncState)) ;
  6603. if (RpcStatus)
  6604. {
  6605. RpcRaiseException(RpcStatus) ;
  6606. }
  6607. // unmarshall the received data
  6608. Ptr = (int *) Message->Buffer ;
  6609. sizein = *Ptr++ ;
  6610. bufferin = Ptr ;
  6611. Ptr += (sizein+3)/sizeof(int) ;
  6612. StubInfo->sizeout = *Ptr ;
  6613. Foo ((PRPC_ASYNC_STATE) &(StubInfo->AsyncState),
  6614. Message->Handle,
  6615. sizein,
  6616. bufferin,
  6617. &(StubInfo->sizeout),
  6618. &(StubInfo->bufferout)) ;
  6619. }
  6620. ////////////////////////////////////////////////////////////
  6621. // End, stubs for Foo //
  6622. ////////////////////////////////////////////////////////////
  6623. ///////////////////////////////////////////////////////////
  6624. // Begin, Application //
  6625. //////////////////////////////////////////////////////////
  6626. typedef struct {
  6627. PRPC_ASYNC_STATE pAsync ;
  6628. RPC_BINDING_HANDLE hBinding ;
  6629. int *sizeout ;
  6630. int **bufferout ;
  6631. } CALL_COOKIE ;
  6632. void
  6633. ThreadProc(
  6634. CALL_COOKIE *Cookie
  6635. )
  6636. /*++
  6637. Routine Description:
  6638. The thread that calls Foo_complete. Foo_complete is being called
  6639. in a separate thread to show that it infact can be.
  6640. Arguments:
  6641. pAsync - the async handle on which Foo_complete needs to be called.
  6642. --*/
  6643. {
  6644. int retval = 1;
  6645. UUID ObjectUuid;
  6646. TRACE(("Foo: Sending back async reply\n"));
  6647. Status = RpcBindingInqObject(Cookie->hBinding, &ObjectUuid);
  6648. if (Status)
  6649. {
  6650. goto Cleanup;
  6651. }
  6652. if (CheckUuidValue(UUID_ASYNC_EXCEPTION, &ObjectUuid) == 0)
  6653. {
  6654. MyRpcAbortAsyncCall(Cookie->pAsync, ASYNC_EXCEPT) ;
  6655. return ;
  6656. }
  6657. *(Cookie->bufferout) = (int *) I_RpcAllocate(*(Cookie->sizeout)) ;
  6658. if (*(Cookie->bufferout) == 0)
  6659. {
  6660. goto Cleanup;
  6661. }
  6662. if (CheckUuidValue(UUID_SLEEP_1000, &ObjectUuid) == 0)
  6663. {
  6664. Sleep(1000);
  6665. }
  6666. if (CheckUuidValue(UUID_SLEEP_2000, &ObjectUuid) == 0)
  6667. {
  6668. Sleep(2000);
  6669. }
  6670. else if (CheckUuidValue(UUID_TEST_CANCEL, &ObjectUuid) == 0)
  6671. {
  6672. if (RpcServerTestCancel(RpcAsyncGetCallHandle(Cookie->pAsync)) == RPC_S_OK)
  6673. {
  6674. PrintToConsole("Async: Call was cancelled\n");
  6675. MyRpcAbortAsyncCall(Cookie->pAsync, ASYNC_EXCEPT) ;
  6676. return;
  6677. }
  6678. }
  6679. else if (CheckUuidValue(UUID_EXTENDED_ERROR, &ObjectUuid) == 0)
  6680. {
  6681. RPC_EXTENDED_ERROR_INFO ErrorInfo;
  6682. ErrorInfo.Version = RPC_EEINFO_VERSION;
  6683. ErrorInfo.ComputerName = NULL;
  6684. ErrorInfo.Flags = 0;
  6685. ErrorInfo.NumberOfParameters = 1;
  6686. ErrorInfo.DetectionLocation = 0;
  6687. ErrorInfo.GeneratingComponent = 0;
  6688. ErrorInfo.ProcessID = 0;
  6689. ErrorInfo.Status = EXTENDED_ERROR_EXCEPTION;
  6690. ErrorInfo.Parameters[0].ParameterType = eeptAnsiString;
  6691. ErrorInfo.Parameters[0].u.AnsiString = "first element of three generated by usvr in ThreadProc()";
  6692. RpcErrorAddRecord(&ErrorInfo);
  6693. ErrorInfo.Parameters[0].u.AnsiString = "second element of three generated by usvr in ThreadProc()";
  6694. RpcErrorAddRecord(&ErrorInfo);
  6695. ErrorInfo.Parameters[0].u.AnsiString = "third element of three generated by usvr in ThreadProc()";
  6696. RpcErrorAddRecord(&ErrorInfo);
  6697. MyRpcAbortAsyncCall(Cookie->pAsync, EXTENDED_ERROR_EXCEPTION);
  6698. return;
  6699. }
  6700. Status = MyRpcCompleteAsyncCall(Cookie->pAsync, &retval) ;
  6701. if (Status != RPC_S_OK)
  6702. {
  6703. PrintToConsole("Async: RpcCompleteAsyncCall return: %d\n",
  6704. Status);
  6705. }
  6706. Sleep(100);
  6707. return;
  6708. Cleanup:
  6709. PrintToConsole("ThreadProc: an unknown error occurred; returning out-of-memory\n");
  6710. MyRpcAbortAsyncCall(Cookie->pAsync, RPC_S_OUT_OF_MEMORY) ;
  6711. IsabelleError() ;
  6712. }
  6713. int Count = 0;
  6714. void
  6715. Foo (
  6716. IN PRPC_ASYNC_STATE pAsync,
  6717. IN RPC_BINDING_HANDLE hBinding,
  6718. IN int sizein,
  6719. IN int *bufferin,
  6720. IN OUT int *sizeout,
  6721. OUT int **bufferout
  6722. )
  6723. /*++
  6724. Routine Description:
  6725. This is a actual manager routine. It can spawn off an async operation
  6726. (a thread in this case) to do the rest of the work, and send back the
  6727. reply when it is done.
  6728. Arguments:
  6729. pAsync - Async handle. This is always the first parameter of every async
  6730. handle.
  6731. --*/
  6732. {
  6733. unsigned long ThreadIdentifier;
  6734. HANDLE HandleToThread ;
  6735. CALL_COOKIE *CallCookie ;
  6736. UUID ObjectUuid;
  6737. Status = RpcBindingInqObject(hBinding, &ObjectUuid);
  6738. if (Status)
  6739. {
  6740. PrintToConsole("Foo: can't inq object uuid, error = %d\n", Status);
  6741. RpcRaiseException(Status);
  6742. }
  6743. if (CheckUuidValue(UUID_SYNC_EXCEPTION, &ObjectUuid) == 0)
  6744. {
  6745. RpcRaiseException(SYNC_EXCEPT) ;
  6746. }
  6747. Count++ ;
  6748. TRACE(("Foo: Count %d\n", Count)) ;
  6749. if ((Count % 7) == 0)
  6750. {
  6751. Sleep(100) ;
  6752. }
  6753. CallCookie = new CALL_COOKIE ;
  6754. if (CallCookie == 0)
  6755. {
  6756. RpcRaiseException(APP_ERROR) ;
  6757. }
  6758. CallCookie->pAsync = pAsync ;
  6759. CallCookie->sizeout = sizeout ;
  6760. CallCookie->bufferout = bufferout ;
  6761. CallCookie->hBinding = hBinding;
  6762. if (*sizeout > 100000)
  6763. {
  6764. DebugBreak();
  6765. }
  6766. if (RpcServerTestCancel(RpcAsyncGetCallHandle(pAsync)) == RPC_S_OK)
  6767. {
  6768. PrintToConsole("Async: Call was cancelled\n");
  6769. }
  6770. if ((Count % 3) == 0)
  6771. {
  6772. ThreadProc(CallCookie);
  6773. }
  6774. else
  6775. {
  6776. HandleToThread = CreateThread(
  6777. 0,
  6778. DefaultThreadStackSize,
  6779. (LPTHREAD_START_ROUTINE) ThreadProc,
  6780. CallCookie,
  6781. 0,
  6782. &ThreadIdentifier);
  6783. if (HandleToThread == 0)
  6784. {
  6785. PrintToConsole("Foo: Error, could not create thread\n") ;
  6786. return ;
  6787. }
  6788. CloseHandle(HandleToThread);
  6789. }
  6790. // return to the server stub.
  6791. }
  6792. ///////////////////////////////////////////////////////////
  6793. // End, Application //
  6794. //////////////////////////////////////////////////////////
  6795. //
  6796. // the following function outline the server side code for a simple async
  6797. // function using pipes.
  6798. //
  6799. ////////////////////////////////////////////////////////////
  6800. // Begin, stubs for FooPipe //
  6801. ////////////////////////////////////////////////////////////
  6802. typedef struct {
  6803. RPC_ASYNC_STUB_STATE StubState ;
  6804. RPC_ASYNC_STATE AsyncState ;
  6805. void *state ;
  6806. async_intpipe inpipe ;
  6807. async_intpipe outpipe ;
  6808. int checksum_out ;
  6809. } FOOPIPE_ASYNC_SERVER_STATE;
  6810. #define ASYNC_CHUNK_SIZE 1000
  6811. #define ASYNC_NUM_CHUNKS 20
  6812. RPC_STATUS
  6813. PipeSendFunction (
  6814. PRPC_ASYNC_STATE pAsync,
  6815. void *context,
  6816. int *buffer,
  6817. int num_elements
  6818. )
  6819. /*++
  6820. Routine Description:
  6821. this function is always implemented by the stubs. This routine is called by
  6822. the application, to send pipe data.
  6823. Arguments:
  6824. pAsync - Async Handle. The async handle is always the first parameter of every
  6825. async routine.
  6826. --*/
  6827. {
  6828. unsigned int Flags = 0;
  6829. RPC_STATUS RpcStatus ;
  6830. RPC_MESSAGE Message ;
  6831. FOOPIPE_ASYNC_SERVER_STATE *StubInfo =
  6832. (FOOPIPE_ASYNC_SERVER_STATE *) pAsync->StubInfo ;
  6833. int calculated_length = num_elements * sizeof(int) + sizeof(int) ;
  6834. char *ptr ;
  6835. Message.ProcNum = RPC_FLAGS_VALID_BIT ;
  6836. Message.Handle = StubInfo->StubState.CallHandle ;
  6837. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  6838. {
  6839. calculated_length += StubInfo->StubState.BufferLength ;
  6840. }
  6841. if (StubInfo->StubState.Buffer == 0)
  6842. {
  6843. Message.RpcFlags = RPC_BUFFER_ASYNC | RPC_BUFFER_PARTIAL ;
  6844. Message.BufferLength = calculated_length ;
  6845. RpcStatus = I_RpcGetBuffer(&Message) ;
  6846. if (RpcStatus != RPC_S_OK)
  6847. {
  6848. return RpcStatus;
  6849. }
  6850. }
  6851. else
  6852. {
  6853. Message.RpcFlags = RPC_BUFFER_ASYNC ;
  6854. Message.Buffer = StubInfo->StubState.Buffer ;
  6855. Message.BufferLength = StubInfo->StubState.BufferLength;
  6856. RpcStatus = I_RpcReallocPipeBuffer(&Message, calculated_length) ;
  6857. if (RpcStatus != RPC_S_OK)
  6858. {
  6859. return RpcStatus;
  6860. }
  6861. }
  6862. ptr = (char *) Message.Buffer ;
  6863. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  6864. {
  6865. ptr += StubInfo->StubState.BufferLength ;
  6866. }
  6867. *((int *) ptr) = num_elements ;
  6868. RpcpMemoryCopy(ptr+sizeof(int), buffer, num_elements *sizeof(int)) ;
  6869. Message.RpcFlags = RPC_BUFFER_PARTIAL | RPC_BUFFER_ASYNC;
  6870. RpcStatus = I_RpcSend(&Message) ;
  6871. if (RpcStatus == RPC_S_OK)
  6872. {
  6873. StubInfo->StubState.State = SEND_COMPLETE ;
  6874. }
  6875. else if (RpcStatus == RPC_S_SEND_INCOMPLETE)
  6876. {
  6877. StubInfo->StubState.State = SEND_INCOMPLETE ;
  6878. }
  6879. else
  6880. {
  6881. return RpcStatus;
  6882. }
  6883. StubInfo->StubState.Buffer = Message.Buffer ;
  6884. StubInfo->StubState.BufferLength = Message.BufferLength ;
  6885. return RPC_S_OK;
  6886. }
  6887. RPC_STATUS
  6888. PipeReceiveFunction (
  6889. PRPC_ASYNC_STATE pAsync,
  6890. int *buffer,
  6891. int requested_count,
  6892. int *actual_count
  6893. )
  6894. /*++
  6895. Function Name:PipeReceiveFunction
  6896. Parameters:
  6897. Description:
  6898. Returns:
  6899. --*/
  6900. {
  6901. int num_elements = 0;
  6902. RPC_MESSAGE Callee ;
  6903. FOOPIPE_ASYNC_SERVER_STATE *StubInfo =
  6904. (FOOPIPE_ASYNC_SERVER_STATE *) pAsync->StubInfo ;
  6905. PIPE_STATE *state = &(StubInfo->StubState.PipeState);
  6906. DWORD size = (DWORD) requested_count * state->PipeElementSize ;
  6907. *actual_count = 0 ;
  6908. if (state->EndOfPipe)
  6909. {
  6910. return RPC_S_OK;
  6911. }
  6912. I_RpcReadPipeElementsFromBuffer(
  6913. state,
  6914. (char *) buffer,
  6915. size,
  6916. &num_elements) ;
  6917. *actual_count += num_elements ;
  6918. size -= num_elements * state->PipeElementSize ;
  6919. if (state->EndOfPipe == 0 &&
  6920. num_elements < requested_count)
  6921. {
  6922. Callee.ProcNum = RPC_FLAGS_VALID_BIT ;
  6923. Callee.Handle = StubInfo->StubState.CallHandle ;
  6924. Callee.RpcFlags = RPC_BUFFER_PARTIAL | RPC_BUFFER_ASYNC ;
  6925. if (num_elements)
  6926. {
  6927. Callee.RpcFlags |= RPC_BUFFER_NONOTIFY;
  6928. }
  6929. Callee.Buffer = 0 ;
  6930. Callee.BufferLength = 0 ;
  6931. Status = I_RpcReceive(&Callee, size) ;
  6932. if (Status)
  6933. {
  6934. ApiError("PipePull", "I_RpcReceive", Status) ;
  6935. if (Status == RPC_S_ASYNC_CALL_PENDING)
  6936. {
  6937. if (num_elements)
  6938. {
  6939. Status = RPC_S_OK;
  6940. }
  6941. }
  6942. else
  6943. {
  6944. num_elements = 0 ;
  6945. }
  6946. return Status;
  6947. }
  6948. state->Buffer = Callee.Buffer ;
  6949. state->BufferLength = Callee.BufferLength ;
  6950. state->CurPointer = (char *) Callee.Buffer ;
  6951. state->BytesRemaining = Callee.BufferLength ;
  6952. buffer = (pipe_element_t *)
  6953. ((char *) buffer + num_elements * state->PipeElementSize) ;
  6954. num_elements = 0 ;
  6955. I_RpcReadPipeElementsFromBuffer(
  6956. state,
  6957. (char *) buffer,
  6958. size,
  6959. &num_elements) ;
  6960. *actual_count += num_elements ;
  6961. }
  6962. return RPC_S_OK;
  6963. }
  6964. RPC_STATUS
  6965. FooPipeComplete (
  6966. IN PRPC_ASYNC_STATE pAsync,
  6967. IN void *Reply
  6968. )
  6969. /*++
  6970. Routine Description:
  6971. Stub for the completion routine of FooPipe.
  6972. Arguments:
  6973. pAsync - async handle
  6974. --*/
  6975. {
  6976. RPC_MESSAGE Message ;
  6977. RPC_STATUS RpcStatus ;
  6978. char *ptr ;
  6979. int calculated_length = 8 ;
  6980. FOOPIPE_ASYNC_SERVER_STATE *StubInfo =
  6981. (FOOPIPE_ASYNC_SERVER_STATE *) pAsync->StubInfo ;
  6982. TRACE(("FooPipeComplete called: %d\n", *((int *) Reply))) ;
  6983. Message.ProcNum = RPC_FLAGS_VALID_BIT ;
  6984. Message.Handle = StubInfo->StubState.CallHandle ;
  6985. Message.Buffer = StubInfo->StubState.Buffer ;
  6986. Message.BufferLength = StubInfo->StubState.BufferLength ;
  6987. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  6988. {
  6989. calculated_length += StubInfo->StubState.BufferLength ;
  6990. }
  6991. // if we had [out] pipes, I_RpcGetBuffer must have
  6992. // been called
  6993. Message.RpcFlags = RPC_BUFFER_ASYNC ;
  6994. RpcStatus = I_RpcReallocPipeBuffer(&Message, calculated_length) ;
  6995. if (RpcStatus != RPC_S_OK)
  6996. {
  6997. return RpcStatus ;
  6998. }
  6999. ptr = (char *) Message.Buffer ;
  7000. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  7001. {
  7002. ptr += StubInfo->StubState.BufferLength ;
  7003. }
  7004. *((int *) ptr) = *((int *) Reply);
  7005. *(((int *) ptr)+1) = StubInfo->checksum_out ;
  7006. // send the async reply
  7007. Message.RpcFlags = RPC_BUFFER_ASYNC;
  7008. RpcStatus = I_RpcSend(&Message) ;
  7009. if (RpcStatus)
  7010. {
  7011. return RpcStatus ;
  7012. }
  7013. I_RpcFree(StubInfo) ;
  7014. return RPC_S_OK ;
  7015. }
  7016. int tempint ;
  7017. void
  7018. FooPipe_s (
  7019. PRPC_MESSAGE Message
  7020. )
  7021. /*++
  7022. Routine Description:
  7023. server stub for the FooPipe function.
  7024. --*/
  7025. {
  7026. int checksum_in;
  7027. FOOPIPE_ASYNC_SERVER_STATE *StubInfo ;
  7028. RPC_STATUS RpcStatus ;
  7029. unsigned long non_pipe_size = sizeof(int) ;
  7030. if (Message->BufferLength < non_pipe_size)
  7031. {
  7032. Message->RpcFlags = RPC_BUFFER_PARTIAL
  7033. | RPC_BUFFER_EXTRA;
  7034. RpcStatus = I_RpcReceive(
  7035. Message,
  7036. non_pipe_size - Message->BufferLength) ;
  7037. if (RpcStatus)
  7038. {
  7039. RpcRaiseException(RpcStatus) ;
  7040. }
  7041. }
  7042. //
  7043. // allocate a handle on the heap, initialize it
  7044. // and register it with the RPC runtime.
  7045. //
  7046. StubInfo = (FOOPIPE_ASYNC_SERVER_STATE *)
  7047. I_RpcAllocate(sizeof(FOOPIPE_ASYNC_SERVER_STATE)) ;
  7048. StubInfo->AsyncState.Size = sizeof(RPC_ASYNC_STATE) ;
  7049. StubInfo->AsyncState.Flags = 0;
  7050. StubInfo->AsyncState.StubInfo = (void *) StubInfo ;
  7051. StubInfo->AsyncState.NotificationType = RpcNotificationTypeNone;
  7052. StubInfo->StubState.Length = sizeof(FOOPIPE_ASYNC_SERVER_STATE) ;
  7053. StubInfo->StubState.CallHandle = Message->Handle ;
  7054. StubInfo->StubState.PipeState.Buffer = 0;
  7055. StubInfo->StubState.PipeState.CurrentState = start;
  7056. StubInfo->StubState.PipeState.EndOfPipe = 0;
  7057. StubInfo->StubState.PipeState.PipeElementSize = sizeof(int);
  7058. StubInfo->StubState.PipeState.PartialPipeElement = &tempint;
  7059. StubInfo->StubState.PipeState.PreviousBuffer = 0;
  7060. StubInfo->StubState.Buffer = 0;
  7061. if (Message->BufferLength > non_pipe_size)
  7062. {
  7063. StubInfo->StubState.PipeState.CurPointer = (char *) Message->Buffer + sizeof(int);
  7064. StubInfo->StubState.PipeState.BytesRemaining =
  7065. Message->BufferLength - non_pipe_size;
  7066. }
  7067. else
  7068. {
  7069. StubInfo->StubState.PipeState.CurPointer = 0;
  7070. StubInfo->StubState.PipeState.BytesRemaining = 0;
  7071. }
  7072. RpcStatus = I_RpcAsyncSetHandle(
  7073. Message,
  7074. (PRPC_ASYNC_STATE) &(StubInfo->AsyncState)) ;
  7075. if (RpcStatus != RPC_S_OK)
  7076. {
  7077. RpcRaiseException(RpcStatus) ;
  7078. }
  7079. // unmarshall the received data
  7080. checksum_in = *((int *) Message->Buffer) ;
  7081. StubInfo->StubState.CompletionRoutine = FooPipeComplete ;
  7082. StubInfo->inpipe.PipeReceive = PipeReceiveFunction;
  7083. StubInfo->outpipe.PipeSend = PipeSendFunction ;
  7084. FooPipe ((PRPC_ASYNC_STATE) &(StubInfo->AsyncState),
  7085. Message->Handle,
  7086. checksum_in,
  7087. &(StubInfo->inpipe),
  7088. &(StubInfo->outpipe),
  7089. &(StubInfo->checksum_out)) ;
  7090. }
  7091. ////////////////////////////////////////////////////////////
  7092. // End, stubs for FooPipe //
  7093. ////////////////////////////////////////////////////////////
  7094. ///////////////////////////////////////////////////////////
  7095. // Begin, Application //
  7096. //////////////////////////////////////////////////////////
  7097. typedef struct {
  7098. PRPC_ASYNC_STATE pAsync ;
  7099. int checksum_in ;
  7100. async_intpipe *inpipe ;
  7101. async_intpipe *outpipe ;
  7102. int *checksum_out ;
  7103. int i ;
  7104. int PipeChecksum ;
  7105. int ExpectedValue;
  7106. int PipeBuffer[ASYNC_CHUNK_SIZE] ;
  7107. } PIPE_CALL_COOKIE ;
  7108. int PipeCount = 0;
  7109. void
  7110. FooPipeAPCRoutine (
  7111. IN PRPC_ASYNC_STATE pAsync,
  7112. IN void *Context,
  7113. IN RPC_ASYNC_EVENT Event
  7114. )
  7115. /*++
  7116. Routine Description:
  7117. description
  7118. Arguments:
  7119. --*/
  7120. {
  7121. RPC_STATUS Status;
  7122. PIPE_CALL_COOKIE *Cookie = (PIPE_CALL_COOKIE *) pAsync->UserInfo ;
  7123. switch (Event)
  7124. {
  7125. case RpcSendComplete:
  7126. if (Cookie->i <ASYNC_NUM_CHUNKS)
  7127. {
  7128. Cookie->i++ ;
  7129. Status = Cookie->outpipe->PipeSend(
  7130. pAsync,
  7131. 0,
  7132. (int *) Cookie->PipeBuffer,
  7133. ASYNC_CHUNK_SIZE) ;
  7134. }
  7135. else
  7136. {
  7137. ASSERT(Cookie->i == ASYNC_NUM_CHUNKS);
  7138. Cookie->i++ ;
  7139. pAsync->Flags = 0;
  7140. Status = Cookie->outpipe->PipeSend(
  7141. pAsync,
  7142. 0, 0, 0) ;
  7143. }
  7144. if (Status != RPC_S_OK)
  7145. {
  7146. PrintToConsole("PipeSend failed\n");
  7147. }
  7148. break;
  7149. case RpcCallComplete:
  7150. #if DBG
  7151. PrintToConsole("usvr: call complete APC !!\n");
  7152. #endif
  7153. break;
  7154. }
  7155. }
  7156. void
  7157. ThreadProcPipes(
  7158. IN PIPE_CALL_COOKIE *Cookie
  7159. )
  7160. /*++
  7161. Routine Description:
  7162. The thread that calls FooPipe_complete. FooPipe_complete is being called
  7163. in a separate thread to show that it infact can be.
  7164. Arguments:
  7165. pAsync - the async handle on which Foo_complete needs to be called.
  7166. --*/
  7167. {
  7168. int *ptr ;
  7169. int i ;
  7170. int retval ;
  7171. int Checksum = 0;
  7172. RPC_STATUS Status ;
  7173. int num_elements;
  7174. BOOL fDone = 0;
  7175. RpcTryExcept
  7176. {
  7177. TRACE(("FooPipe: sending pipe data\n")) ;
  7178. while (!fDone)
  7179. {
  7180. Status = Cookie->inpipe->PipeReceive(
  7181. Cookie->pAsync,
  7182. (int *) Cookie->PipeBuffer,
  7183. ASYNC_CHUNK_SIZE,
  7184. &num_elements);
  7185. switch (Status)
  7186. {
  7187. case RPC_S_ASYNC_CALL_PENDING:
  7188. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  7189. {
  7190. RpcRaiseException(APP_ERROR) ;
  7191. }
  7192. break;
  7193. case RPC_S_OK:
  7194. if (num_elements == 0)
  7195. {
  7196. fDone = 1;
  7197. }
  7198. else
  7199. {
  7200. for (i = 0; i <num_elements; i++)
  7201. {
  7202. if (Cookie->PipeBuffer[i] != Cookie->ExpectedValue)
  7203. {
  7204. printf("pipe recv fn: elt %d contains %lx, expected %lx\n",
  7205. i, Cookie->PipeBuffer[i], Cookie->ExpectedValue);
  7206. DebugBreak();
  7207. }
  7208. Cookie->ExpectedValue =
  7209. (Cookie->PipeBuffer[i]+1) % ASYNC_CHUNK_SIZE;
  7210. Cookie->PipeChecksum += Cookie->PipeBuffer[i] ;
  7211. }
  7212. }
  7213. break;
  7214. default:
  7215. fDone = 1;
  7216. break;
  7217. }
  7218. //
  7219. // This code is for testing flow control
  7220. //
  7221. PipeCount++;
  7222. if ((PipeCount % 3) == 0)
  7223. {
  7224. Sleep(100);
  7225. }
  7226. }
  7227. if (Status != RPC_S_OK)
  7228. {
  7229. RpcRaiseException(Status);
  7230. }
  7231. TRACE(("FooPipe: sending pipe data\n")) ;
  7232. ptr = (int *) Cookie->PipeBuffer ;
  7233. for (i = 0; i <ASYNC_CHUNK_SIZE; i++)
  7234. {
  7235. *ptr++ = i;
  7236. Checksum += i ;
  7237. }
  7238. TRACE(("FooPipe: [out] Block checksum: %d\n", Checksum)) ;
  7239. Checksum *= ASYNC_NUM_CHUNKS ;
  7240. TRACE(("FooPipe: [out] Total checksum: %d\n", Checksum)) ;
  7241. Cookie->i = 1;
  7242. Status = Cookie->outpipe->PipeSend(
  7243. Cookie->pAsync,
  7244. 0,
  7245. Cookie->PipeBuffer,
  7246. ASYNC_CHUNK_SIZE) ;
  7247. if (Status != RPC_S_OK)
  7248. {
  7249. RpcRaiseException(Status);
  7250. }
  7251. while (Cookie->i < ASYNC_NUM_CHUNKS+1)
  7252. {
  7253. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  7254. {
  7255. RpcRaiseException(APP_ERROR) ;
  7256. }
  7257. }
  7258. TRACE(("FooPipe: sending non pipe reply\n")) ;
  7259. *(Cookie->checksum_out) = Checksum ;
  7260. if (Cookie->checksum_in != Cookie->PipeChecksum)
  7261. {
  7262. PrintToConsole("FooPipe: Checksum Error, expected: %d, checksum: %d\n",
  7263. Cookie->checksum_in, Cookie->PipeChecksum) ;
  7264. IsabelleError() ;
  7265. retval = 0;
  7266. }
  7267. else
  7268. {
  7269. retval = 1;
  7270. }
  7271. Status = MyRpcCompleteAsyncCall(Cookie->pAsync, &retval) ;
  7272. }
  7273. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  7274. {
  7275. IsabelleError() ;
  7276. MyRpcCompleteAsyncCall(Cookie->pAsync, &retval) ;
  7277. PrintToConsole("FooPipe: Exception : 0x%lX\n", GetExceptionCode()) ;
  7278. }
  7279. RpcEndExcept
  7280. Sleep(100);
  7281. }
  7282. void
  7283. FooPipe (
  7284. IN PRPC_ASYNC_STATE pAsync,
  7285. IN RPC_BINDING_HANDLE hBinding,
  7286. IN int checksum_in,
  7287. IN async_intpipe *inpipe,
  7288. OUT async_intpipe *outpipe,
  7289. OUT int *checksum_out
  7290. )
  7291. /*++
  7292. Routine Description:
  7293. The manager routine that implements FooPipe. It sets up the receive
  7294. and alloc function pointer for each of the pipes on which data is to
  7295. be received, and call RpcRegisterAsycnHandle on the async handle.
  7296. It then spawns off an async operation (creates a thread in this case),
  7297. to process the async call.
  7298. Arguments:
  7299. pAsync - Async Handle. The async handle is always the first parameter of every
  7300. async routine.
  7301. --*/
  7302. {
  7303. unsigned long ThreadIdentifier;
  7304. HANDLE HandleToThread ;
  7305. RPC_STATUS RpcStatus ;
  7306. PIPE_CALL_COOKIE *PipeCallCookie ;
  7307. PipeCallCookie = new PIPE_CALL_COOKIE ;
  7308. if (PipeCallCookie == 0)
  7309. {
  7310. RpcRaiseException(APP_ERROR) ;
  7311. }
  7312. PipeCallCookie->pAsync = pAsync ;
  7313. PipeCallCookie->inpipe = inpipe ;
  7314. PipeCallCookie->outpipe = outpipe ;
  7315. PipeCallCookie->checksum_in = checksum_in ;
  7316. PipeCallCookie->checksum_out = checksum_out ;
  7317. PipeCallCookie->PipeChecksum = 0;
  7318. PipeCallCookie->ExpectedValue = 0;
  7319. HandleToThread = CreateThread(0,
  7320. DefaultThreadStackSize,
  7321. (LPTHREAD_START_ROUTINE) ThreadProcPipes,
  7322. PipeCallCookie,
  7323. 0,
  7324. &ThreadIdentifier);
  7325. if (HandleToThread == 0)
  7326. {
  7327. PrintToConsole("FooPipe: Can't create thread\n") ;
  7328. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  7329. }
  7330. pAsync->Flags = RPC_C_NOTIFY_ON_SEND_COMPLETE ;
  7331. pAsync->UserInfo = (void *) PipeCallCookie ;
  7332. pAsync->NotificationType = RpcNotificationTypeApc ;
  7333. pAsync->u.APC.NotificationRoutine = FooPipeAPCRoutine ;
  7334. pAsync->u.APC.hThread = HandleToThread ;
  7335. RpcStatus = RpcAsyncRegisterInfo(pAsync) ;
  7336. if (RpcStatus != RPC_S_OK)
  7337. {
  7338. RpcRaiseException(RpcStatus) ;
  7339. }
  7340. }
  7341. ///////////////////
  7342. // misc stuff ///
  7343. ///////////////////
  7344. int
  7345. FooBar (
  7346. IN RPC_BINDING_HANDLE hBinding,
  7347. IN int sizein,
  7348. IN int *bufferin,
  7349. IN OUT int *sizeout,
  7350. OUT int **bufferout
  7351. )
  7352. {
  7353. UUID ObjectUuid;
  7354. Status = RpcBindingInqObject(hBinding, &ObjectUuid);
  7355. if (Status)
  7356. {
  7357. PrintToConsole("FooBar: can't inq object uuid, error = %d\n", Status);
  7358. RpcRaiseException(Status);
  7359. }
  7360. if (CheckUuidValue(UUID_SYNC_EXCEPTION, &ObjectUuid) == 0)
  7361. {
  7362. RpcRaiseException(SYNC_EXCEPT) ;
  7363. }
  7364. *bufferout = (int *) I_RpcAllocate(*sizeout) ;
  7365. if (*bufferout == 0)
  7366. {
  7367. RpcRaiseException(APP_ERROR) ;
  7368. }
  7369. return 1;
  7370. }
  7371. void
  7372. FooBar_s (
  7373. PRPC_MESSAGE Message
  7374. )
  7375. /*++
  7376. Routine Description:
  7377. Generated stub for FooBar.
  7378. --*/
  7379. {
  7380. int *bufferin ;
  7381. int *bufferout ;
  7382. int sizein, sizeout ;
  7383. int *Ptr ;
  7384. int retval ;
  7385. RPC_STATUS RpcStatus ;
  7386. if ((Message->RpcFlags & RPC_BUFFER_COMPLETE) == 0)
  7387. {
  7388. Message->RpcFlags = RPC_BUFFER_EXTRA;
  7389. RpcStatus = I_RpcReceive (Message, 0) ;
  7390. if (RpcStatus)
  7391. {
  7392. RpcRaiseException(RpcStatus) ;
  7393. }
  7394. }
  7395. // unmarshall the received data
  7396. Ptr = (int *) Message->Buffer ;
  7397. sizein = *Ptr++ ;
  7398. bufferin = Ptr ;
  7399. Ptr += (sizein+3)/sizeof(int) ;
  7400. sizeout = *Ptr ;
  7401. retval = FooBar (Message->Handle, sizein, bufferin, &sizeout, &bufferout) ;
  7402. Message->BufferLength = sizeout+8;
  7403. RpcStatus = I_RpcGetBuffer(Message) ;
  7404. if (RpcStatus != RPC_S_OK)
  7405. {
  7406. RpcRaiseException(RpcStatus) ;
  7407. }
  7408. Ptr = (int *) Message->Buffer ;
  7409. *Ptr++ = retval ;
  7410. *Ptr++ = sizeout ;
  7411. RpcpMemoryCopy(Ptr, bufferout, sizeout) ;
  7412. I_RpcFree(bufferout) ;
  7413. }
  7414. ////////////////////////////////////////////////////////////
  7415. // Begin, stubs for FooCH //
  7416. ////////////////////////////////////////////////////////////
  7417. void
  7418. FooCH (
  7419. IN PRPC_ASYNC_STATE pAsync,
  7420. IN RPC_BINDING_HANDLE hBinding,
  7421. IN int sizein,
  7422. IN int *bufferin,
  7423. IN OUT int *sizeout,
  7424. OUT int **bufferout
  7425. ) ;
  7426. typedef struct {
  7427. RPC_ASYNC_STUB_STATE StubState ;
  7428. RPC_ASYNC_STATE AsyncState ;
  7429. void *state ;
  7430. int sizeout ;
  7431. int *bufferout ;
  7432. } FOOCH_ASYNC_SERVER_STATE;
  7433. RPC_STATUS
  7434. FooCHComplete (
  7435. IN PRPC_ASYNC_STATE pAsync,
  7436. IN void *Reply
  7437. )
  7438. /*++
  7439. Routine Description:
  7440. This is a generated stub. It is the completion routine for the function
  7441. FooCH. When the server app is done with processing a particular call to
  7442. FooCH, It calls FooCH_complete to complete the call.
  7443. Arguments:
  7444. pAsync - The async handle. This handle is always the first parameter of every
  7445. FooCH_complete routine.
  7446. --*/
  7447. {
  7448. int *Ptr ;
  7449. RPC_MESSAGE Message ;
  7450. RPC_STATUS RpcStatus ;
  7451. FOOCH_ASYNC_SERVER_STATE *StubInfo =
  7452. (FOOCH_ASYNC_SERVER_STATE *) pAsync->StubInfo ;
  7453. TRACE(("FooCHComplete called: %d\n", *((int *) Reply))) ;
  7454. Message.ProcNum = RPC_FLAGS_VALID_BIT ;
  7455. Message.RpcFlags = RPC_BUFFER_ASYNC;
  7456. Message.BufferLength = 8 + StubInfo->sizeout ;
  7457. Message.Handle = StubInfo->StubState.CallHandle ;
  7458. RpcStatus = I_RpcGetBuffer(&Message) ;
  7459. if (RpcStatus)
  7460. {
  7461. return RpcStatus ;
  7462. }
  7463. Ptr = (int *) Message.Buffer ;
  7464. *Ptr++ = *((int *) Reply) ;
  7465. *Ptr++ = StubInfo->sizeout ;
  7466. RpcpMemoryCopy(Ptr, StubInfo->bufferout, StubInfo->sizeout) ;
  7467. I_RpcFree(StubInfo->bufferout) ;
  7468. // send the async reply
  7469. Message.RpcFlags = RPC_BUFFER_ASYNC;
  7470. RpcStatus = I_RpcSend(&Message) ;
  7471. if (RpcStatus)
  7472. {
  7473. return RpcStatus ;
  7474. }
  7475. I_RpcFree(pAsync->StubInfo) ;
  7476. return RPC_S_OK ;
  7477. }
  7478. void
  7479. FooCH_s (
  7480. PRPC_MESSAGE Message
  7481. )
  7482. /*++
  7483. Routine Description:
  7484. Generated stub for FooCH.
  7485. --*/
  7486. {
  7487. int sizein ;
  7488. int *bufferin ;
  7489. int *Ptr ;
  7490. FOOCH_ASYNC_SERVER_STATE *StubInfo;
  7491. RPC_STATUS RpcStatus ;
  7492. NDR_SCONTEXT Context ;
  7493. if ((Message->RpcFlags & RPC_BUFFER_COMPLETE) == 0)
  7494. {
  7495. Message->RpcFlags = RPC_BUFFER_EXTRA;
  7496. RpcStatus = I_RpcReceive (Message, 0) ;
  7497. if (RpcStatus)
  7498. {
  7499. RpcRaiseException(RpcStatus) ;
  7500. }
  7501. }
  7502. // allocate a handle and tell the runtime about it
  7503. StubInfo = (FOOCH_ASYNC_SERVER_STATE *)
  7504. I_RpcAllocate(sizeof(FOOCH_ASYNC_SERVER_STATE)) ;
  7505. if (StubInfo == 0)
  7506. {
  7507. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  7508. }
  7509. StubInfo->AsyncState.Size = sizeof(RPC_ASYNC_STATE) ;
  7510. StubInfo->AsyncState.StubInfo = (void *) StubInfo ;
  7511. StubInfo->AsyncState.Flags = 0;
  7512. StubInfo->AsyncState.NotificationType = RpcNotificationTypeNone;
  7513. StubInfo->StubState.CompletionRoutine = FooCHComplete ;
  7514. StubInfo->StubState.CallHandle = Message->Handle ;
  7515. StubInfo->StubState.Flags = 0;
  7516. RpcStatus = I_RpcAsyncSetHandle(
  7517. Message,
  7518. (PRPC_ASYNC_STATE) &(StubInfo->AsyncState)) ;
  7519. if (RpcStatus != RPC_S_OK)
  7520. {
  7521. RpcRaiseException(RpcStatus) ;
  7522. }
  7523. // unmarshall the received data
  7524. Ptr = (int *) Message->Buffer ;
  7525. Context = NDRSContextUnmarshallEx (
  7526. Message->Handle,
  7527. 0,
  7528. Message->DataRepresentation );
  7529. if (Context == 0)
  7530. {
  7531. RpcRaiseException(RPC_X_SS_CONTEXT_MISMATCH) ;
  7532. }
  7533. Ptr += 20/sizeof(int) ;
  7534. sizein = *Ptr++ ;
  7535. bufferin = Ptr ;
  7536. Ptr += (sizein+3)/sizeof(int) ;
  7537. StubInfo->sizeout = *Ptr ;
  7538. {
  7539. RPC_STATUS Status = 0;
  7540. UUID ObjectUuid;
  7541. Status = RpcBindingInqObject(Message->Handle, &ObjectUuid);
  7542. if (Status)
  7543. {
  7544. PrintToConsole("FooBar: can't inq object uuid, error = %d\n", Status);
  7545. RpcRaiseException(Status);
  7546. }
  7547. if (CheckUuidValue(UUID_SYNC_EXCEPTION, &ObjectUuid) == 0)
  7548. {
  7549. RpcRaiseException(SYNC_EXCEPT) ;
  7550. }
  7551. if (CheckUuidValue(UUID_ASYNC_EXCEPTION, &ObjectUuid) == 0)
  7552. {
  7553. StubInfo->sizeout = SIZEOUT_ASYNC_EXCEPTION;
  7554. }
  7555. }
  7556. FooCH ((PRPC_ASYNC_STATE) &(StubInfo->AsyncState),
  7557. (void PAPI *) *NDRSContextValue(Context),
  7558. sizein,
  7559. bufferin,
  7560. &(StubInfo->sizeout),
  7561. &(StubInfo->bufferout)) ;
  7562. }
  7563. ////////////////////////////////////////////////////////////
  7564. // End, stubs for FooCH //
  7565. ////////////////////////////////////////////////////////////
  7566. ///////////////////////////////////////////////////////////
  7567. // Begin, Application //
  7568. //////////////////////////////////////////////////////////
  7569. typedef struct {
  7570. PRPC_ASYNC_STATE pAsync ;
  7571. int *sizeout ;
  7572. int **bufferout ;
  7573. BOOL fException;
  7574. } FOOCH_CALL_COOKIE ;
  7575. void
  7576. FooCHThreadProc(
  7577. FOOCH_CALL_COOKIE *Cookie
  7578. )
  7579. /*++
  7580. Routine Description:
  7581. The thread that calls FooCH_complete. FooCH_complete is being called
  7582. in a separate thread to show that it infact can be.
  7583. Arguments:
  7584. pAsync - the async handle on which FooCH_complete needs to be called.
  7585. --*/
  7586. {
  7587. int retval = 1;
  7588. TRACE(("FOOCH: Sending back aync reply\n")) ;
  7589. if (Cookie->fException)
  7590. {
  7591. MyRpcAbortAsyncCall(Cookie->pAsync, ASYNC_EXCEPT) ;
  7592. return ;
  7593. }
  7594. *(Cookie->bufferout) = (int *) I_RpcAllocate(*(Cookie->sizeout)) ;
  7595. if (*(Cookie->bufferout) == 0)
  7596. {
  7597. MyRpcAbortAsyncCall(Cookie->pAsync, RPC_S_OUT_OF_MEMORY) ;
  7598. IsabelleError() ;
  7599. return ;
  7600. }
  7601. Status = MyRpcCompleteAsyncCall(Cookie->pAsync, &retval) ;
  7602. if (Status != RPC_S_OK)
  7603. {
  7604. IsabelleError() ;
  7605. }
  7606. }
  7607. void
  7608. FooCH (
  7609. IN PRPC_ASYNC_STATE pAsync,
  7610. IN void PAPI *ContextHandle,
  7611. IN int sizein,
  7612. IN int *bufferin,
  7613. IN OUT int *sizeout,
  7614. OUT int **bufferout
  7615. )
  7616. /*++
  7617. Routine Description:
  7618. This is a actual manager routine. It can spawn off an async operation
  7619. (a thread in this case) to do the rest of the work, and send back the
  7620. reply when it is done.
  7621. Arguments:
  7622. pAsync - Async handle. This is always the first parameter of every async
  7623. handle.
  7624. --*/
  7625. {
  7626. unsigned long ThreadIdentifier;
  7627. HANDLE HandleToThread ;
  7628. FOOCH_CALL_COOKIE *CallCookie ;
  7629. CallCookie = new FOOCH_CALL_COOKIE ;
  7630. if (CallCookie == 0)
  7631. {
  7632. RpcRaiseException(APP_ERROR) ;
  7633. }
  7634. CallCookie->pAsync = pAsync ;
  7635. CallCookie->sizeout = sizeout ;
  7636. CallCookie->bufferout = bufferout ;
  7637. CallCookie->fException = FALSE;
  7638. if (*sizeout == SIZEOUT_ASYNC_EXCEPTION)
  7639. {
  7640. CallCookie->fException = TRUE;
  7641. }
  7642. HandleToThread = CreateThread(
  7643. 0,
  7644. DefaultThreadStackSize,
  7645. (LPTHREAD_START_ROUTINE) FooCHThreadProc,
  7646. CallCookie,
  7647. 0,
  7648. &ThreadIdentifier);
  7649. if (HandleToThread == 0)
  7650. {
  7651. PrintToConsole("FooCH: Error, could not create thread\n") ;
  7652. return ;
  7653. }
  7654. // return to the server stub.
  7655. }
  7656. ///////////////////////////////////////////////////////////
  7657. // End, Application //
  7658. //////////////////////////////////////////////////////////
  7659. void
  7660. Async (
  7661. )
  7662. /*++
  7663. Routine Description:
  7664. Register the interfaces and start listening
  7665. --*/
  7666. {
  7667. PrintToConsole("Async : Test Async RPC\n");
  7668. Status = stub_RegisterIf(
  7669. (RPC_IF_HANDLE) &SylviaInterfaceInformation,
  7670. 0, 0);
  7671. if (Status)
  7672. {
  7673. ApiError("Async","stub_RegisterIf",Status);
  7674. PrintToConsole("Async : FAIL - Unable to Register Interface ");
  7675. PrintToConsole("(Sylvia)\n");
  7676. return;
  7677. }
  7678. //
  7679. // synchronous listen blocks inside GenericServerListen
  7680. //
  7681. Status = GenericServerListen( "Async", BARTHOLOMEW );
  7682. if (Status)
  7683. {
  7684. return;
  7685. }
  7686. Status = GenericServerUnlisten( "Async" );
  7687. if (Status)
  7688. {
  7689. return;
  7690. }
  7691. Status = RpcServerUnregisterIf(
  7692. (RPC_IF_HANDLE) &SylviaInterfaceInformation, 0, 0);
  7693. if (Status)
  7694. {
  7695. ApiError("Async","RpcServerUnregisterIf",Status);
  7696. PrintToConsole("Async : FAIL - Unable to Unregister ");
  7697. PrintToConsole("Interface (Sylvia)\n");
  7698. return;
  7699. }
  7700. PrintToConsole("Async : PASS\n");
  7701. }
  7702. void
  7703. SendAck (
  7704. )
  7705. /*++
  7706. Routine Description:
  7707. Register the interfaces and start listening
  7708. --*/
  7709. {
  7710. PrintToConsole("SendAck : Test datagram delayed ACK\n");
  7711. Status = GenericServerListen( "SendAck", BARTHOLOMEW );
  7712. if (Status)
  7713. {
  7714. return;
  7715. }
  7716. Status = GenericServerUnlisten( "SendAck" );
  7717. if (Status)
  7718. {
  7719. return;
  7720. }
  7721. }
  7722. void
  7723. DgTransport (
  7724. )
  7725. /*++
  7726. Routine Description:
  7727. Register the interfaces and start listening
  7728. --*/
  7729. {
  7730. PrintToConsole("DgTransport : Test datagram transport\n");
  7731. Status = GenericServerListen( "DgTransport", BARTHOLOMEW );
  7732. if (Status)
  7733. {
  7734. return;
  7735. }
  7736. Status = GenericServerUnlisten( "DgTransport" );
  7737. if (Status)
  7738. {
  7739. return;
  7740. }
  7741. }
  7742. PVOID LastConnectionCreated = 0;
  7743. PVOID MySecurityContext = 0;
  7744. DWORD ChosenErrorCode = 0;
  7745. void
  7746. ShutdownHookFn(
  7747. DWORD id,
  7748. PVOID subject,
  7749. PVOID object
  7750. )
  7751. {
  7752. switch (id)
  7753. {
  7754. case TH_RPC_LOG_EVENT:
  7755. {
  7756. RPC_EVENT * event = (RPC_EVENT *) subject;
  7757. // TRACE((" hook: %c %c %p %p\n", event->Subject, event->Verb, event->SubjectPointer, event->ObjectPointer));
  7758. //
  7759. // Record sconnection creation.
  7760. //
  7761. if (event->Subject == SU_SCONN &&
  7762. event->Verb == EV_CREATE)
  7763. {
  7764. TRACE((" hook: created connection %p\n", event->SubjectPointer));
  7765. LastConnectionCreated = event->SubjectPointer;
  7766. }
  7767. break;
  7768. }
  7769. case TH_RPC_SECURITY_SERVER_CONTEXT_CREATED:
  7770. {
  7771. if (object == LastConnectionCreated)
  7772. {
  7773. TRACE((" hook: connection %p created security context %p\n", LastConnectionCreated, subject));
  7774. MySecurityContext = subject;
  7775. }
  7776. break;
  7777. }
  7778. default:
  7779. {
  7780. break;
  7781. }
  7782. }
  7783. }
  7784. void
  7785. SecurityContextHook(
  7786. DWORD id,
  7787. PVOID subject,
  7788. PVOID object
  7789. )
  7790. {
  7791. if (subject == MySecurityContext)
  7792. {
  7793. TRACE((" hook executed: context %p, hook ID %x, error code is 0x%x\n", subject, id, ChosenErrorCode));
  7794. DWORD * pStatus = (DWORD *) object;
  7795. *pStatus = ChosenErrorCode;
  7796. }
  7797. else
  7798. {
  7799. TRACE((" hook: ignoring notification, my cxt = %p, context %p, hook ID %x, error code is 0x%x\n",
  7800. MySecurityContext, subject, id, ChosenErrorCode));
  7801. }
  7802. }
  7803. void
  7804. TestSecurityError (
  7805. RPC_TEST_HOOK_ID id,
  7806. DWORD error
  7807. );
  7808. void
  7809. SecurityErrorWrapper(
  7810. int subtest
  7811. )
  7812. {
  7813. //
  7814. // Set up the test hook.
  7815. //
  7816. {
  7817. HMODULE hRpc = GetModuleHandle(L"RPCRT4.DLL");
  7818. if (!hRpc)
  7819. {
  7820. ApiError("","GetModuleHandle",GetLastError());
  7821. return;
  7822. }
  7823. SetTestHookFn = (SET_TEST_HOOK_FN) GetProcAddress( hRpc, "I_RpcSetTestHook" );
  7824. if (!SetTestHookFn)
  7825. {
  7826. ApiError("", "GetProcAddress: I_RpcSetTestHook", GetLastError());
  7827. }
  7828. }
  7829. switch (subtest)
  7830. {
  7831. default:
  7832. {
  7833. PrintToConsole("unknown security-error case!\n");
  7834. // no break here
  7835. }
  7836. case 100:
  7837. {
  7838. //
  7839. // wants a list
  7840. //
  7841. PrintToConsole("cases:\n"
  7842. "\n"
  7843. " 1 - AcceptFirstTime returns SEC_E_SHUTDOWN_IN_PROGRESS\n"
  7844. " 2 - AcceptThirdLeg returns SEC_E_SHUTDOWN_IN_PROGRESS\n"
  7845. );
  7846. return;
  7847. }
  7848. case 0:
  7849. {
  7850. PrintToConsole("running all sub tests\n");
  7851. }
  7852. case 1:
  7853. {
  7854. PrintToConsole("subtest 1: AcceptFirstTime returns SEC_E_SHUTDOWN_IN_PROGRESS\n");
  7855. TestSecurityError( TH_SECURITY_FN_ACCEPT1, SEC_E_SHUTDOWN_IN_PROGRESS );
  7856. if (subtest)
  7857. {
  7858. break;
  7859. }
  7860. }
  7861. case 2:
  7862. {
  7863. PrintToConsole("subtest 1: AcceptThirdLeg returns SEC_E_SHUTDOWN_IN_PROGRESS\n");
  7864. TestSecurityError( TH_SECURITY_FN_ACCEPT3, SEC_E_SHUTDOWN_IN_PROGRESS );
  7865. if (subtest)
  7866. {
  7867. break;
  7868. }
  7869. }
  7870. }
  7871. }
  7872. void
  7873. TestSecurityError (
  7874. RPC_TEST_HOOK_ID id,
  7875. DWORD error
  7876. )
  7877. /*++
  7878. Routine Description:
  7879. Register the interfaces and start listening
  7880. --*/
  7881. {
  7882. //
  7883. // Set test hooks.
  7884. //
  7885. (*SetTestHookFn)( TH_RPC_LOG_EVENT, ShutdownHookFn );
  7886. (*SetTestHookFn)( TH_RPC_SECURITY_SERVER_CONTEXT_CREATED, ShutdownHookFn );
  7887. ChosenErrorCode = error;
  7888. (*SetTestHookFn)( id, SecurityContextHook );
  7889. //
  7890. // Wait for the client to make the call.
  7891. //
  7892. Status = GenericServerListen( "SecurityShutdown", SECURITY_ERROR );
  7893. if (Status)
  7894. {
  7895. return;
  7896. }
  7897. //
  7898. // Remove test hooks.
  7899. //
  7900. (*SetTestHookFn)( TH_RPC_LOG_EVENT, 0 );
  7901. (*SetTestHookFn)( TH_RPC_SECURITY_SERVER_CONTEXT_CREATED, 0 );
  7902. (*SetTestHookFn)( id, 0 );
  7903. //
  7904. // Clean up.
  7905. //
  7906. Status = GenericServerUnlisten( "SecurityShutdown" );
  7907. if (Status)
  7908. {
  7909. return;
  7910. }
  7911. }
  7912. DWORD
  7913. GenericServerUnlisten(
  7914. char * name
  7915. )
  7916. {
  7917. // Synchro support
  7918. Status = RpcServerUnregisterIf(
  7919. (RPC_IF_HANDLE) &HelgaInterfaceInformation, 0, 0);
  7920. if (Status)
  7921. {
  7922. ApiError(name,"RpcServerUnregisterIf",Status);
  7923. PrintToConsole("%s : FAIL - Unable to Unregister ", name);
  7924. PrintToConsole("Interface (Helga)\n");
  7925. return Status;
  7926. }
  7927. if (IsabelleErrors != 0)
  7928. {
  7929. PrintToConsole("%s : FAIL - Error(s) in Isabelle", name);
  7930. PrintToConsole(" Interface\n");
  7931. IsabelleErrors = 0;
  7932. return Status;
  7933. }
  7934. Status = RpcServerUnregisterIf(
  7935. (RPC_IF_HANDLE) &IsabelleInterfaceInformation, 0, 0);
  7936. if (Status)
  7937. {
  7938. ApiError(name,"RpcServerUnregisterIf",Status);
  7939. PrintToConsole("%s : FAIL - Unable to Unregister ", name);
  7940. PrintToConsole("Interface (Isabelle)\n");
  7941. return Status;
  7942. }
  7943. if (SylviaErrors != 0)
  7944. {
  7945. PrintToConsole("%s : FAIL - Error(s) in Sylvia", name);
  7946. PrintToConsole(" Interface\n");
  7947. HelgaErrors = 0;
  7948. return Status;
  7949. }
  7950. return 0;
  7951. }
  7952. DWORD
  7953. GenericServerListen(
  7954. char * name,
  7955. int endpoint
  7956. )
  7957. {
  7958. Status = RpcServerUseProtseqEpWrapper(GetProtocolSequence(), MAX_CALL_REQUESTS,
  7959. GetEndpoint(endpoint), 0);
  7960. if (Status)
  7961. {
  7962. ApiError(name, "RpcServerUseProtseqEpWrapper", Status);
  7963. PrintToConsole("%s : FAIL - Unable to Use Protseq endpoint \n", name);
  7964. return Status;
  7965. }
  7966. Status = stub_RegisterIf(
  7967. (RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  7968. 0, 0);
  7969. if (Status)
  7970. {
  7971. ApiError(name,"stub_RegisterIf",Status);
  7972. PrintToConsole("%s : FAIL - Unable to Register Interface ", name);
  7973. PrintToConsole("(Isabelle)\n");
  7974. return Status;
  7975. }
  7976. // Synchro support
  7977. Status = stub_RegisterIf(
  7978. (RPC_IF_HANDLE) &HelgaInterfaceInformation,
  7979. 0, 0);
  7980. if (Status)
  7981. {
  7982. ApiError(name,"stub_RegisterIf",Status);
  7983. PrintToConsole("%s : FAIL - Unable to Register Interface ", name);
  7984. PrintToConsole("(Helga)\n");
  7985. return Status;
  7986. }
  7987. if (!NoSecurityTests)
  7988. {
  7989. Status = RpcServerRegisterAuthInfoA((unsigned char PAPI *) "ServerPrincipal", 10, 0, 0);
  7990. if (Status)
  7991. {
  7992. ApiError(name, "RpcServerRegisterAuthInfo", Status);
  7993. PrintToConsole("%s : FAIL - Unable to Register AuthInfo\n", name);
  7994. return Status;
  7995. }
  7996. }
  7997. Status = stub_ServerListen(MinimumListenThreads, MAXLISTENTHREADS, 0);
  7998. if (Status)
  7999. {
  8000. ApiError(name,"stub_ServerListen",Status);
  8001. PrintToConsole("%s : FAIL - stub_ServerListen Failed\n", name);
  8002. return Status;
  8003. }
  8004. return 0;
  8005. }