Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14834 lines
366 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1991 - 2000
  3. Module Name:
  4. uclnt.cxx
  5. Abstract:
  6. This module is half of the build verification for the RPC runtime;
  7. the other half can be found in the file usvr.cxx. These two
  8. executables (uclnt.exe and usvr.exe) work together to test all
  9. runtime APIs.
  10. Author:
  11. Michael Montague (mikemon) 01-Jan-1990
  12. Revision History:
  13. --*/
  14. #include <precomp.hxx>
  15. #include <osfpcket.hxx>
  16. #include <ntsecapi.h>
  17. #include <lm.h>
  18. #include "pipe.h"
  19. #include "astub.h"
  20. #define UCLNT
  21. #define swaplong(Value)
  22. #define swapshort(Value)
  23. #define EXPORT
  24. #include <sysinc.h>
  25. #include <rpc.h>
  26. #include <rpcdcep.h>
  27. #include <rpcndr.h>
  28. BOOL IsWMSG = FALSE ;
  29. extern RPC_CLIENT_INTERFACE HelgaInterfaceInformation ;
  30. /*
  31. Transports:
  32. Update this to add a new transport.
  33. */
  34. #define RPC_TRANSPORT_NAMEPIPE 1
  35. #define RPC_LRPC 2
  36. #define RPC_TRANSPORT_TCP 3
  37. #define RPC_TRANSPORT_DNET 4
  38. #define RPC_TRANSPORT_NETBIOS 5
  39. #define RPC_TRANSPORT_SPX 6
  40. #define RPC_TRANSPORT_UDP 7
  41. #define RPC_TRANSPORT_IPX 8
  42. #define RPC_TRANSPORT_DSP 9
  43. #define RPC_TRANSPORT_VNS 10
  44. #define RPC_WMSG 11
  45. #define RPC_TRANSPORT_MSMQ 12
  46. //
  47. // constants
  48. //
  49. #define RETRYCOUNT 10
  50. #define RETRYDELAY 500L
  51. #define LONG_TESTDELAY 10000L
  52. #define EXTENDED_ERROR_EXCEPTION 77777
  53. //
  54. // global variables
  55. //
  56. long TestDelay = 3000L;
  57. int NumberOfTestsRun = 0;
  58. static unsigned long DefaultThreadStackSize = 0;
  59. BOOL fNonCausal = 0;
  60. unsigned long HelgaMaxSize = 0xffffffff;
  61. unsigned int NoCallBacksFlag = 0;
  62. unsigned int UseEndpointMapperFlag = 0;
  63. unsigned int MaybeTests = 0;
  64. unsigned int IdempotentTests = 0;
  65. unsigned int BroadcastTests = 0;
  66. unsigned int NoSecurityTests = 0;
  67. unsigned int HackForOldStubs = 0;
  68. unsigned int DatagramTests = 0;
  69. unsigned int fUniqueBinding = 0;
  70. int Subtest = 0;
  71. int Verbose = 0;
  72. int IFSecurityFlag = 0;
  73. int AutoListenFlag = 1;
  74. char *SecurityUser = NULL;
  75. char *SecurityDomain = NULL;
  76. char *SecurityPassword = NULL;
  77. char *gPrincName = NULL;
  78. unsigned long ulSecurityPackage = 10 ;
  79. unsigned long TransportType;
  80. unsigned int WarnFlag = 0; // Flag for warning messages.
  81. unsigned int ErrorFlag = 1; // Flag for error messages.
  82. char NetBiosProtocol[20] = "ncacn_nb_nb"; // NetBios transport protocol
  83. char * Server ;
  84. RPC_STATUS Status; // Contains the status of the last RPC API call.
  85. /* volatile */ int fShutdown; // Flag indicating that shutdown should occur.
  86. #define CHUNK_SIZE 50
  87. #define NUM_CHUNKS 100
  88. #define BUFF_SIZE 100
  89. // if you change the type of the pipe element
  90. // make sure you change the pull and push routines
  91. // to correctly initialize the pipe element
  92. typedef int pipe_element_t ;
  93. typedef struct {
  94. void (PAPI *Pull) (
  95. char PAPI *state,
  96. pipe_element_t PAPI *buffer,
  97. int max_buf,
  98. int PAPI *size_to_send
  99. ) ;
  100. void (PAPI *Push) (
  101. char PAPI *state,
  102. pipe_element_t PAPI *input_buffer,
  103. int ecount
  104. ) ;
  105. void (PAPI *Alloc) (
  106. char PAPI *state,
  107. int requested_size,
  108. pipe_element_t PAPI * PAPI *allocate_buf,
  109. int PAPI *allocated_size
  110. ) ;
  111. char PAPI *state ;
  112. } pipe_t ;
  113. static CRITICAL_SECTION TestMutex;
  114. //
  115. // forward declarations
  116. //
  117. void
  118. DgTransport (
  119. int testnum
  120. );
  121. void
  122. SecurityErrorWrapper(
  123. int subtest
  124. );
  125. DWORD
  126. DumpEeInfo(
  127. int indentlevel
  128. );
  129. DWORD
  130. HelgaSendReceiveFailure (
  131. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  132. // remote procedure call.
  133. int ProcNum
  134. );
  135. int
  136. FooSync (
  137. RPC_BINDING_HANDLE hBinding,
  138. /* [in] */ int sizein,
  139. /* [in] */ int *bufferin,
  140. /* [in, out] */ int *sizeout,
  141. /* [out] */ int **bufferout
  142. );
  143. //
  144. // function definitions
  145. //
  146. void
  147. TestMutexRequest (
  148. void
  149. )
  150. {
  151. EnterCriticalSection(&TestMutex);
  152. }
  153. void
  154. TestMutexClear (
  155. void
  156. )
  157. {
  158. LeaveCriticalSection(&TestMutex);
  159. }
  160. void
  161. ApiError ( // An API error occured; we just print a message.
  162. IN char * Routine, // The routine which called the API.
  163. IN char * API,
  164. IN RPC_STATUS status
  165. )
  166. {
  167. if (ErrorFlag)
  168. {
  169. TestMutexRequest();
  170. PrintToConsole(" ApiError in %s (%s = %u)\n",Routine,API,status);
  171. TestMutexClear();
  172. }
  173. // _asm {int 3} ;
  174. }
  175. void
  176. PauseExecution (
  177. unsigned long milliseconds
  178. )
  179. {
  180. Sleep(milliseconds);
  181. }
  182. void
  183. OtherError ( // Some other error occured; again, we just print a message.
  184. IN char * Routine, // The routine where the error occured.
  185. IN char * Message
  186. )
  187. {
  188. if (ErrorFlag)
  189. {
  190. TestMutexRequest();
  191. PrintToConsole(" Error in %s (%s)\n",Routine,Message);
  192. TestMutexClear();
  193. }
  194. }
  195. unsigned int IsabelleErrors = 0;
  196. unsigned int HelgaErrors = 0;
  197. unsigned int SylviaErrors = 0;
  198. void IsabelleError (
  199. )
  200. {
  201. IsabelleErrors += 1 ;
  202. }
  203. void HelgaError (
  204. )
  205. {
  206. HelgaErrors += 1 ;
  207. }
  208. void SylviaError (
  209. )
  210. {
  211. SylviaErrors += 1 ;
  212. }
  213. #define SIGFRIED 0
  214. #define ELLIOTMINIMIZE 1
  215. #define ELLIOTMAXIMIZE 2
  216. #define ELLIOTNORMAL 3
  217. #define ANDROMIDA 4
  218. #define FREDRICK 7
  219. #define ISABELLENORMAL 10
  220. #define ISABELLEMINIMIZE 11
  221. #define ISABELLEMAXIMIZE 12
  222. #define CHRISTOPHER 13
  223. #define CHRISTOPHERHELGA 14
  224. #define CHRISTOPHERISABELLE 15
  225. #define TYLER 17
  226. #define RICHARD 18
  227. #define RICHARDHELPER 19
  228. #define NOENDPOINT 20
  229. #define DAVIDFIRST 21
  230. #define DAVIDSECOND 22
  231. #define BARTHOLOMEW 23
  232. #define GRANT 24
  233. #define HERMAN 25
  234. #define IVAN 26
  235. #define JASON 27
  236. #define KENNETH 28
  237. #define TESTYIELD 29
  238. #define SPIPE TESTYIELD
  239. #define SECURITY_ERROR TESTYIELD
  240. /*
  241. Transports:
  242. Update this to add a new transport.
  243. */
  244. char * NamepipeAddresses [] =
  245. {
  246. "\\pipe\\sigfried",
  247. "\\pipe\\elliotmi",
  248. "\\pipe\\elliotma",
  249. "\\pipe\\elliotno",
  250. "\\pipe\\andromno",
  251. 0,
  252. 0,
  253. "\\pipe\\fredrick",
  254. 0,
  255. 0,
  256. "\\pipe\\isabelno",
  257. "\\pipe\\isabelmi",
  258. "\\pipe\\isabelma",
  259. "\\pipe\\christ",
  260. "\\pipe\\zippyhe",
  261. "\\pipe\\zippyis",
  262. 0,
  263. "\\pipe\\tyler",
  264. "\\pipe\\richard",
  265. "\\pipe\\richardh",
  266. 0,
  267. "\\pipe\\david1",
  268. "\\pipe\\david2",
  269. "\\pipe\\bart",
  270. "\\pipe\\grant",
  271. "\\pipe\\herman",
  272. "\\pipe\\ivan",
  273. "\\pipe\\jason",
  274. "\\pipe\\kenneth",
  275. "\\pipe\\testyield"
  276. };
  277. char * DspAddresses [] =
  278. {
  279. "\\pipe\\sigfried",
  280. "\\pipe\\elliotmi",
  281. "\\pipe\\elliotma",
  282. "\\pipe\\elliotno",
  283. "\\pipe\\andromno",
  284. 0,
  285. 0,
  286. "\\pipe\\fredrick",
  287. 0,
  288. 0,
  289. "\\pipe\\isabelno",
  290. "\\pipe\\isabelmi",
  291. "\\pipe\\isabelma",
  292. "\\pipe\\christ",
  293. "\\pipe\\zippyhe",
  294. "\\pipe\\zippyis",
  295. 0,
  296. "\\pipe\\tyler",
  297. "\\pipe\\richard",
  298. "\\pipe\\richardh",
  299. 0,
  300. "\\pipe\\david1",
  301. "\\pipe\\david2",
  302. "\\pipe\\bart",
  303. "\\pipe\\grant",
  304. "\\pipe\\herman",
  305. "\\pipe\\ivan",
  306. "\\pipe\\jason",
  307. "\\pipe\\kenneth",
  308. "\\pipe\\testyield"
  309. };
  310. char * TCPDefaultServer =
  311. "serverhost";
  312. char * UDPDefaultServer =
  313. "serverhost";
  314. char * NetBiosAddresses [] =
  315. {
  316. "201", // sigfried
  317. "202", // elliotmi
  318. "203", // elliotma
  319. "204", // elliotno
  320. "205", // andromno
  321. 0,
  322. 0,
  323. "206", // fredrick
  324. 0,
  325. 0,
  326. "207", // isabelno
  327. "208", // isabelmi
  328. "209", // isabelma
  329. "210", // christ
  330. "211", // zippyhe
  331. "212", // zippyis
  332. 0,
  333. "214", // tyler
  334. "215", // richard
  335. "216", // richardh
  336. 0,
  337. "217", // david1
  338. "218", // david2
  339. "219", // bart
  340. "220", // grant
  341. "221", // herman
  342. "222", // ivan
  343. "223", // jason
  344. "224", // kenneth
  345. "225" // testyield
  346. };
  347. char * TCPAddresses [] =
  348. {
  349. "2025", // SIGFRIED
  350. "2026", // ELLIOTMINIMIZE
  351. "2027", // ELLIOTMAXIMIZE
  352. "2028", // ELLIOTNORMAL
  353. "2029", // ANDROMIDA
  354. 0,
  355. 0,
  356. "2032", // FREDRICK
  357. 0,
  358. 0,
  359. "2035", // ISABELLENORMAL
  360. "2036", // ISABELLEMINIMIZE
  361. "2037", // ISABELLEMAXIMIZE
  362. "2038", // CHRISTOPHER
  363. "2039", // CHRISTOPHERHELGA
  364. "2040", // CHRISTOPHERISABELLE
  365. 0,
  366. "2042", // TYLER
  367. "2043", // RICHARD
  368. "2044", // RICHARDHELPER
  369. 0,
  370. "2045", //D1
  371. "2046", //D2
  372. "2047", // Bartholomew
  373. "2048", // Grant
  374. "2049", // Herman
  375. "2050", // Ivan
  376. "2051", // Jason
  377. "2052", // Kenneth
  378. "2053" // TestYield
  379. };
  380. char * UDPAddresses [] =
  381. {
  382. "2025", // SIGFRIED
  383. "2026", // ELLIOTMINIMIZE
  384. "2027", // ELLIOTMAXIMIZE
  385. "2028", // ELLIOTNORMAL
  386. "2029", // ANDROMIDA
  387. 0,
  388. 0,
  389. "2032", // FREDRICK
  390. 0,
  391. 0,
  392. "2035", // ISABELLENORMAL
  393. "2036", // ISABELLEMINIMIZE
  394. "2037", // ISABELLEMAXIMIZE
  395. "2038", // CHRISTOPHER
  396. "2039", // CHRISTOPHERHELGA
  397. "2040", // CHRISTOPHERISABELLE
  398. 0,
  399. "2042", // TYLER
  400. "2043", // RICHARD
  401. "2044", // RICHARDHELPER
  402. 0,
  403. "2045", //D1
  404. "2046", //D2
  405. "2047", // Bartholomew
  406. "2048", // Grant
  407. "2049", // Herman
  408. "2050", // Ivan
  409. "2051", // Jason
  410. "2052", // Kenneth
  411. "2053" // TestYield
  412. };
  413. char * SPCAddresses [] =
  414. {
  415. "sigfried",
  416. "elliotminimize",
  417. "elliotmaximize",
  418. "elliotnormal",
  419. "andromida",
  420. 0,
  421. 0,
  422. "fredrick",
  423. 0,
  424. 0,
  425. "isabellenormal",
  426. "isabelleminimize",
  427. "isabellemaximize",
  428. "christopher",
  429. "christopherhelga",
  430. "christopherisabelle",
  431. 0,
  432. "tyler",
  433. "richard",
  434. "richardhelper",
  435. 0,
  436. "davidfirst",
  437. "davidsecond",
  438. "bartholomew",
  439. "grant",
  440. "herman",
  441. "ivan",
  442. "jason",
  443. "kenneth",
  444. "testyield"
  445. };
  446. char * SPXAddresses [] =
  447. {
  448. "5000", // sigfried
  449. "5001", // elliotmi
  450. "5002", // elliotma
  451. "5003", // elliotno
  452. "5004", // andromno
  453. "5005",
  454. "5006",
  455. "5007", // fredrick
  456. "5008",
  457. "5009",
  458. "5010", // isabelno
  459. "5011", // isabelmi
  460. "5012", // isabelma
  461. "5013", // christ
  462. "5014", // zippyhe
  463. "5015", // zippyis
  464. "5016",
  465. "5017", // tyler
  466. "5020", // richard
  467. "5021", // richardh
  468. 0,
  469. "5022", // david1
  470. "5023", // david2
  471. "5024", // bart
  472. "5025", // grant
  473. "5026", // herman
  474. "5027", // ivan
  475. "5028", // jason
  476. "5029", // kenneth
  477. "5030" // testyield
  478. };
  479. char * IPXAddresses [] =
  480. {
  481. "5000", // sigfried
  482. "5001", // elliotmi
  483. "5002", // elliotma
  484. "5003", // elliotno
  485. "5004", // andromno
  486. "5005",
  487. "5006",
  488. "5007", // fredrick
  489. "5008",
  490. "5009",
  491. "5010", // isabelno
  492. "5011", // isabelmi
  493. "5012", // isabelma
  494. "5013", // christ
  495. "5014", // zippyhe
  496. "5015", // zippyis
  497. "5016",
  498. "5017", // tyler
  499. "5020", // richard
  500. "5021", // richardh
  501. 0,
  502. "5022", // david1
  503. "5023", // david2
  504. "5024", // bart
  505. "5025", // grant
  506. "5026", // herman
  507. "5027", // ivan
  508. "5028", // jason
  509. "5029", // kenneth
  510. "5030" // testyield
  511. };
  512. char * VNSAddresses [] =
  513. {
  514. "250", // sigfried
  515. "251", // elliotmi
  516. "252", // elliotma
  517. "253", // elliotno
  518. "254", // andromno
  519. "255",
  520. "256",
  521. "257", // fredrick
  522. "258",
  523. "259",
  524. "260", // isabelno
  525. "261", // isabelmi
  526. "262", // isabelma
  527. "263", // christ
  528. "264", // zippyhe
  529. "265", // zippyis
  530. "266",
  531. "267", // tyler
  532. "270", // richard
  533. "271", // richardh
  534. 0,
  535. "272", // david1
  536. "273", // david2
  537. "274", // bart
  538. "275", // grant
  539. "276", // herman
  540. "277", // ivan
  541. "278", // jason
  542. "279", // kenneth
  543. "280" // testyield
  544. };
  545. char * MSMQAddresses [] =
  546. {
  547. "SIGFRIED",
  548. "ELLIOTMINIMIZE",
  549. "ELLIOTMAXIMIZE",
  550. "ELLIOTNORMAL",
  551. "ANDROMIDA",
  552. 0,
  553. 0,
  554. "FREDRICK",
  555. 0,
  556. 0,
  557. "ISABELLENORMAL",
  558. "ISABELLEMINIMIZE",
  559. "ISABELLEMAXIMIZE",
  560. "CHRISTOPHER",
  561. "CHRISTOPHERHELGA",
  562. "CHRISTOPHERISABELLE",
  563. 0,
  564. "TYLER",
  565. "RICHARD",
  566. "RICHARDHELPER",
  567. 0,
  568. "D1",
  569. "D2",
  570. "Bartholomew",
  571. "Grant",
  572. "Herman",
  573. "Ivan",
  574. "Jason",
  575. "Kenneth",
  576. "TestYield"
  577. };
  578. unsigned char PAPI *
  579. GetStringBinding (
  580. IN unsigned int Address,
  581. IN char PAPI * ObjectUuid, OPTIONAL
  582. IN unsigned char PAPI * NetworkOptions OPTIONAL
  583. )
  584. /*++
  585. Routine Description:
  586. A string binding for the desired address is constructed.
  587. Arguments:
  588. Address - Supplies an index into a table of endpoints.
  589. ObjectUuid - Optionally supplies the string representation of a UUID
  590. to be specified as the object uuid in the string binding.
  591. NetworkOptions - Optionally supplies the network options for this
  592. string binding.
  593. Return Value:
  594. The constructed string binding will be returned.
  595. Transports:
  596. Update this to add a new transport.
  597. --*/
  598. {
  599. unsigned char PAPI * StringBinding;
  600. if (TransportType == RPC_TRANSPORT_NAMEPIPE)
  601. {
  602. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  603. (unsigned char PAPI *) "ncacn_np",
  604. #ifdef WIN32RPC
  605. (unsigned char PAPI *) ((Server)? Server: "\\\\."),
  606. #else
  607. (unsigned char PAPI *) Server,
  608. #endif
  609. (unsigned char PAPI *) NamepipeAddresses[Address],
  610. NetworkOptions, &StringBinding);
  611. }
  612. if (TransportType == RPC_TRANSPORT_NETBIOS)
  613. {
  614. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  615. (unsigned char PAPI *) NetBiosProtocol,
  616. (unsigned char PAPI *) Server,
  617. (unsigned char PAPI *) NetBiosAddresses[Address],
  618. NetworkOptions, &StringBinding);
  619. }
  620. if (TransportType == RPC_LRPC)
  621. {
  622. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  623. (unsigned char PAPI *) "ncalrpc", NULL,
  624. (unsigned char PAPI *) SPCAddresses[Address], NetworkOptions,
  625. &StringBinding);
  626. }
  627. if (TransportType == RPC_TRANSPORT_TCP)
  628. {
  629. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  630. (unsigned char PAPI *) "ncacn_ip_tcp",
  631. (unsigned char PAPI *) Server,
  632. (unsigned char PAPI *) TCPAddresses[Address],
  633. NetworkOptions,
  634. &StringBinding);
  635. }
  636. if (TransportType == RPC_TRANSPORT_UDP)
  637. {
  638. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  639. (unsigned char PAPI *) "ncadg_ip_udp",
  640. (unsigned char PAPI *) Server,
  641. (unsigned char PAPI *) UDPAddresses[Address],
  642. NetworkOptions,
  643. &StringBinding);
  644. }
  645. if (TransportType == RPC_TRANSPORT_SPX)
  646. {
  647. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  648. (unsigned char PAPI *) "ncacn_spx",
  649. (unsigned char PAPI *) Server,
  650. (unsigned char PAPI *) SPXAddresses[Address],
  651. NetworkOptions, &StringBinding);
  652. }
  653. if (TransportType == RPC_TRANSPORT_IPX)
  654. {
  655. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  656. (unsigned char PAPI *) "ncadg_ipx",
  657. (unsigned char PAPI *) Server,
  658. (unsigned char PAPI *) IPXAddresses[Address],
  659. NetworkOptions, &StringBinding);
  660. }
  661. if (TransportType == RPC_TRANSPORT_DSP)
  662. {
  663. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  664. (unsigned char PAPI *) "ncacn_at_dsp",
  665. (unsigned char PAPI *) Server,
  666. (unsigned char PAPI *) DspAddresses[Address],
  667. NetworkOptions, &StringBinding);
  668. }
  669. if (TransportType == RPC_TRANSPORT_VNS)
  670. {
  671. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  672. (unsigned char PAPI *) "ncacn_vns_spp",
  673. (unsigned char PAPI *) Server,
  674. (unsigned char PAPI *) VNSAddresses[Address],
  675. NetworkOptions, &StringBinding);
  676. }
  677. if (TransportType == RPC_TRANSPORT_MSMQ)
  678. {
  679. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjectUuid,
  680. (unsigned char PAPI *) "ncadg_mq",
  681. (unsigned char PAPI *) Server,
  682. (unsigned char PAPI *) MSMQAddresses[Address],
  683. NetworkOptions, &StringBinding);
  684. }
  685. if (Status)
  686. {
  687. ApiError("GetStringBinding","RpcStringBindingCompose",Status);
  688. PrintToConsole("GetStringBinding failed in ");
  689. PrintToConsole("RpcStringBindingCompose\n");
  690. return(0);
  691. }
  692. return(StringBinding);
  693. }
  694. RPC_STATUS
  695. GetBinding (
  696. IN unsigned int Address,
  697. OUT RPC_BINDING_HANDLE PAPI * Binding
  698. )
  699. /*++
  700. Routine Description:
  701. A binding for the desired address is constructed. This is a wrapper
  702. around GetStringBinding and RpcBindingFromStringBinding.
  703. Arguments:
  704. Address - Supplies an index into a table of endpoints.
  705. Binding - A pointer to the location to store the returned binding
  706. handle.
  707. Return Value:
  708. The status code from RpcBindingFromStringBinding is returned.
  709. --*/
  710. {
  711. unsigned char PAPI * StringBinding;
  712. RPC_STATUS FreeStatus;
  713. StringBinding = GetStringBinding(Address, 0, 0);
  714. Status = RpcBindingFromStringBindingA(StringBinding, Binding);
  715. if (Status)
  716. ApiError("GetBinding","RpcBindingFromStringBinding",Status);
  717. if (IFSecurityFlag)
  718. {
  719. Status = RpcBindingSetAuthInfo(
  720. *Binding, NULL,
  721. RPC_C_AUTHN_LEVEL_CONNECT,
  722. 10,
  723. NULL,
  724. NULL);
  725. if (Status != RPC_S_OK)
  726. {
  727. ApiError("GetBinding","RpcBindingSetAuthInfo",Status);
  728. return Status;
  729. }
  730. }
  731. if (StringBinding)
  732. {
  733. FreeStatus = RpcStringFreeA(&StringBinding);
  734. if (FreeStatus)
  735. {
  736. ApiError("GetBinding","RpcStringFree",FreeStatus);
  737. PrintToConsole("GetBinding failed in ");
  738. PrintToConsole("RpcStringFree\n");
  739. }
  740. }
  741. if (fUniqueBinding)
  742. {
  743. Status = RpcBindingSetOption( *Binding, RPC_C_OPT_UNIQUE_BINDING, TRUE );
  744. if (Status != RPC_S_OK)
  745. {
  746. ApiError("GetBinding","RpcBindingSetOption",Status);
  747. return Status;
  748. }
  749. }
  750. return(Status);
  751. }
  752. RPC_STATUS
  753. UclntSendReceive (
  754. IN OUT PRPC_MESSAGE RpcMessage
  755. )
  756. /*++
  757. Routine Description:
  758. This routine takes care of retrying to send the remote procedure
  759. call.
  760. Arguments:
  761. RpcMessage - Supplies and returns the message for I_RpcSendReceive.
  762. Return Value:
  763. The result of I_RpcSendReceive will be returned.
  764. --*/
  765. {
  766. Status = I_RpcSendReceive(RpcMessage);
  767. return(Status);
  768. }
  769. RPC_STATUS
  770. UclntGetBuffer (
  771. IN OUT PRPC_MESSAGE RpcMessage
  772. )
  773. /*++
  774. Routine Description:
  775. This routine takes care of retrying to getting a buffer.
  776. Arguments:
  777. RpcMessage - Supplies and returns the message for I_RpcGetBuffer.
  778. Return Value:
  779. The result of I_RpcGetBuffer will be returned.
  780. --*/
  781. {
  782. unsigned int RetryCount;
  783. RPC_BINDING_HANDLE Handle = RpcMessage->Handle;
  784. for (RetryCount = 0; RetryCount < RETRYCOUNT; RetryCount++)
  785. {
  786. RpcMessage->Handle = Handle;
  787. Status = I_RpcGetBuffer(RpcMessage);
  788. if ( (Status != RPC_S_SERVER_TOO_BUSY)
  789. && (Status != RPC_S_CALL_FAILED_DNE))
  790. break;
  791. PauseExecution(RETRYDELAY);
  792. }
  793. return(Status);
  794. }
  795. /* --------------------------------------------------------------------
  796. Isabelle Interface
  797. -------------------------------------------------------------------- */
  798. RPC_PROTSEQ_ENDPOINT IsabelleRpcProtseqEndpoint[] =
  799. {
  800. {(unsigned char *) "ncacn_np",
  801. #ifdef WIN32RPC
  802. (unsigned char *) "\\pipe\\zippyis"},
  803. #else // WIN32RPC
  804. (unsigned char *) "\\device\\namedpipe\\christopherisabelle"},
  805. #endif // WIN32RPC
  806. {(unsigned char *) "ncacn_ip_tcp",(unsigned char *) "2040"}
  807. ,{(unsigned char *) "ncadg_ip_udp",(unsigned char *) "2040"}
  808. ,{(unsigned char *) "ncalrpc",(unsigned char *) "christopherisabelle"}
  809. ,{(unsigned char *) "ncacn_nb_nb",(unsigned char *) "212"}
  810. ,{(unsigned char *) "ncacn_spx",(unsigned char *) "5015"}
  811. ,{(unsigned char *) "ncadg_ipx",(unsigned char *) "5015"}
  812. ,{(unsigned char *) "ncacn_vns_spp", (unsigned char *) "265"}
  813. ,{(unsigned char *) "ncacn_at_dsp", (unsigned char *) "\\pipe\\zippyis"}
  814. ,{(unsigned char *) "ncadg_mq", (unsigned char *) "christopherisabelle"}
  815. };
  816. RPC_CLIENT_INTERFACE IsabelleInterfaceInformation =
  817. {
  818. sizeof(RPC_CLIENT_INTERFACE),
  819. {{9,8,8,{7,7,7,7,7,7,7,7}},
  820. {1,1}},
  821. {{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},
  822. {2,0}}, /* {4,5}}, */
  823. 0,
  824. sizeof(IsabelleRpcProtseqEndpoint) / sizeof(RPC_PROTSEQ_ENDPOINT),
  825. IsabelleRpcProtseqEndpoint,
  826. 0,
  827. NULL,
  828. RPC_INTERFACE_HAS_PIPES
  829. };
  830. void
  831. IsabelleShutdown (
  832. RPC_BINDING_HANDLE Binding // Specifies the binding to use in making the
  833. // remote procedure call.
  834. )
  835. {
  836. RPC_MESSAGE Caller;
  837. Caller.Handle = Binding;
  838. Caller.BufferLength = 0;
  839. Caller.ProcNum = 0 | HackForOldStubs ;
  840. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  841. Caller.RpcFlags = 0;
  842. if (IdempotentTests != 0)
  843. {
  844. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  845. }
  846. if (MaybeTests != 0)
  847. {
  848. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  849. }
  850. if (BroadcastTests != 0)
  851. {
  852. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  853. }
  854. Status = UclntGetBuffer(&Caller);
  855. if (Status)
  856. {
  857. ApiError("IsabelleShutdown", "I_RpcGetBuffer", Status);
  858. IsabelleError();
  859. return;
  860. }
  861. Status = UclntSendReceive(&Caller);
  862. if (Status)
  863. {
  864. ApiError("IsabelleShutdown","I_RpcSendReceive",Status);
  865. IsabelleError();
  866. return;
  867. }
  868. else
  869. {
  870. if (Caller.BufferLength != 0)
  871. {
  872. OtherError("IsabelleShutdown","BufferLength != 0");
  873. IsabelleError();
  874. return;
  875. }
  876. Status = I_RpcFreeBuffer(&Caller);
  877. if (Status)
  878. {
  879. ApiError("IsabelleShutdown","I_RpcFreeBuffer",Status);
  880. IsabelleError();
  881. return;
  882. }
  883. }
  884. }
  885. void
  886. IsabelleNtSecurity (
  887. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  888. // remote procedure call.
  889. unsigned int BufferLength,
  890. void PAPI * Buffer
  891. )
  892. {
  893. RPC_MESSAGE Caller;
  894. Caller.Handle = Binding;
  895. Caller.BufferLength = BufferLength;
  896. Caller.ProcNum = 1 | HackForOldStubs ;
  897. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  898. Caller.RpcFlags = 0;
  899. if (IdempotentTests != 0)
  900. {
  901. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  902. }
  903. if (MaybeTests != 0)
  904. {
  905. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  906. }
  907. if (BroadcastTests != 0)
  908. {
  909. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  910. }
  911. Status = UclntGetBuffer(&Caller);
  912. if (Status)
  913. {
  914. ApiError("IsabelleNtSecurity","I_RpcGetBuffer",Status);
  915. IsabelleError();
  916. return;
  917. }
  918. RpcpMemoryCopy(Caller.Buffer,Buffer,BufferLength);
  919. Status = UclntSendReceive(&Caller);
  920. if (Status)
  921. {
  922. ApiError("IsabelleNtSecurity","I_RpcSendReceive",Status);
  923. IsabelleError();
  924. return;
  925. }
  926. else
  927. {
  928. if (Caller.BufferLength != 0)
  929. {
  930. OtherError("IsabelleNtSecurity","BufferLength != 0");
  931. IsabelleError();
  932. return;
  933. }
  934. Status = I_RpcFreeBuffer(&Caller);
  935. if (Status)
  936. {
  937. ApiError("IsabelleNtSecurity","I_RpcFreeBuffer",Status);
  938. IsabelleError();
  939. return;
  940. }
  941. }
  942. }
  943. void
  944. IsabelleToStringBinding (
  945. RPC_BINDING_HANDLE Binding // Specifies the binding to use in making the
  946. // remote procedure call.
  947. )
  948. {
  949. RPC_MESSAGE Caller;
  950. Caller.Handle = Binding;
  951. Caller.BufferLength = 0;
  952. Caller.ProcNum = 2 | HackForOldStubs ;
  953. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  954. Caller.RpcFlags = 0;
  955. if (IdempotentTests != 0)
  956. {
  957. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  958. }
  959. if (MaybeTests != 0)
  960. {
  961. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  962. }
  963. if (BroadcastTests != 0)
  964. {
  965. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  966. }
  967. Status = UclntGetBuffer(&Caller);
  968. if (Status)
  969. {
  970. ApiError("IsabelleToStringBinding", "I_RpcGetBuffer", Status);
  971. IsabelleError();
  972. return;
  973. }
  974. Status = UclntSendReceive(&Caller);
  975. if (Status)
  976. {
  977. ApiError("IsabelleToStringBinding","I_RpcSendReceive",Status);
  978. IsabelleError();
  979. return;
  980. }
  981. else
  982. {
  983. if (Caller.BufferLength != 0)
  984. {
  985. OtherError("IsabelleToStringBinding","BufferLength != 0");
  986. IsabelleError();
  987. return;
  988. }
  989. Status = I_RpcFreeBuffer(&Caller);
  990. if (Status)
  991. {
  992. ApiError("IsabelleToStringBinding","I_RpcFreeBuffer",Status);
  993. IsabelleError();
  994. return;
  995. }
  996. }
  997. }
  998. #define RICHARDHELPER_EXIT 1
  999. #define RICHARDHELPER_EXECUTE 2
  1000. #define RICHARDHELPER_IGNORE 3
  1001. #define RICHARDHELPER_DELAY_EXIT 4
  1002. RPC_STATUS
  1003. IsabelleRichardHelper (
  1004. IN RPC_BINDING_HANDLE Binding,
  1005. IN unsigned /*long*/ char Command
  1006. )
  1007. /*++
  1008. Routine Description:
  1009. This routine is the caller stub for the IsabelleRichardHelper routine
  1010. on the server side. We marshall the command, and use the supplied
  1011. binding handle to direct the call.
  1012. Arguments:
  1013. Binding - Supplies a binding to direct the call.
  1014. Command - Supplies a command for IsabelleRichardHelper to execute
  1015. on the server side. Command must be one of the following
  1016. values.
  1017. RICHARDHELPER_EXIT - This value will cause the server to exit.
  1018. RICHARDHELPER_EXECUTE - The server will execute usvr.exe with
  1019. this the -richardhelper flag.
  1020. RICHARDHELPER_IGNORE - The server will do nothing except return.
  1021. Return Value:
  1022. The status of the operation will be returned. This will be the
  1023. status codes returned from RpcGetBuffer and/or RpcSendReceive.
  1024. --*/
  1025. {
  1026. RPC_MESSAGE Caller;
  1027. unsigned /*long*/ char PAPI * plScan;
  1028. Caller.Handle = Binding;
  1029. Caller.BufferLength = sizeof(unsigned /*long*/ char);
  1030. Caller.ProcNum = 3 | HackForOldStubs ;
  1031. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1032. Caller.RpcFlags = 0;
  1033. if (IdempotentTests != 0)
  1034. {
  1035. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1036. }
  1037. if (MaybeTests != 0)
  1038. {
  1039. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1040. }
  1041. if (BroadcastTests != 0)
  1042. {
  1043. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1044. }
  1045. Status = UclntGetBuffer(&Caller);
  1046. if (Status != RPC_S_OK)
  1047. return(Status);
  1048. plScan = (unsigned /*long*/ char PAPI *) Caller.Buffer;
  1049. *plScan = Command;
  1050. Status = UclntSendReceive(&Caller);
  1051. if (Status != RPC_S_OK)
  1052. return(Status);
  1053. return(I_RpcFreeBuffer(&Caller));
  1054. }
  1055. RPC_STATUS
  1056. IsabelleRaiseException (
  1057. IN RPC_BINDING_HANDLE Binding,
  1058. IN unsigned /*long*/ char Exception
  1059. )
  1060. /*++
  1061. Routine Description:
  1062. This routine is the caller stub for the IsabelleRaiseException routine
  1063. on the server side. We marshall the exception code, and use the supplied
  1064. binding handle to direct the call.
  1065. Arguments:
  1066. Binding - Supplies a binding to direct the call.
  1067. Exception - Supplies the exception to be raised by IsabelleRaiseException.
  1068. Return Value:
  1069. The exception raised will be returned.
  1070. --*/
  1071. {
  1072. RPC_MESSAGE Caller;
  1073. unsigned /*long*/ char PAPI * plScan;
  1074. Caller.Handle = Binding;
  1075. Caller.BufferLength = sizeof(unsigned /*long*/ char);
  1076. Caller.ProcNum = 4 | HackForOldStubs ;
  1077. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1078. Caller.RpcFlags = 0;
  1079. if (IdempotentTests != 0)
  1080. {
  1081. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1082. }
  1083. if (MaybeTests != 0)
  1084. {
  1085. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1086. }
  1087. if (BroadcastTests != 0)
  1088. {
  1089. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1090. }
  1091. Status = UclntGetBuffer(&Caller);
  1092. if (Status != RPC_S_OK)
  1093. return(Status);
  1094. plScan = (unsigned /*long*/ char PAPI *) Caller.Buffer;
  1095. *plScan = Exception;
  1096. Status = UclntSendReceive(&Caller);
  1097. return(Status);
  1098. }
  1099. void
  1100. IsabelleSetRundown (
  1101. RPC_BINDING_HANDLE Binding
  1102. )
  1103. /*++
  1104. Routine Description:
  1105. This is the caller stub which will request that the server set
  1106. a rundown routine for the association over which the call came.
  1107. Arguments:
  1108. Binding - Supplies a binding handle to be used to direct the
  1109. remote procedure call.
  1110. --*/
  1111. {
  1112. RPC_MESSAGE Caller;
  1113. Caller.Handle = Binding;
  1114. Caller.BufferLength = 0;
  1115. Caller.ProcNum = 5 | HackForOldStubs ;
  1116. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1117. Caller.RpcFlags = 0;
  1118. if (IdempotentTests != 0)
  1119. {
  1120. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1121. }
  1122. if (MaybeTests != 0)
  1123. {
  1124. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1125. }
  1126. if (BroadcastTests != 0)
  1127. {
  1128. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1129. }
  1130. Status = UclntGetBuffer(&Caller);
  1131. if (Status)
  1132. {
  1133. ApiError("IsabelleSetRundown", "I_RpcGetBuffer", Status);
  1134. IsabelleError();
  1135. return;
  1136. }
  1137. Status = UclntSendReceive(&Caller);
  1138. if (Status)
  1139. {
  1140. ApiError("IsabelleSetRundown","I_RpcSendReceive",Status);
  1141. IsabelleError();
  1142. return;
  1143. }
  1144. else
  1145. {
  1146. if (Caller.BufferLength != 0)
  1147. {
  1148. OtherError("IsabelleSetRundown","BufferLength != 0");
  1149. IsabelleError();
  1150. return;
  1151. }
  1152. Status = I_RpcFreeBuffer(&Caller);
  1153. if (Status)
  1154. {
  1155. ApiError("IsabelleSetRundown","I_RpcFreeBuffer",Status);
  1156. IsabelleError();
  1157. return;
  1158. }
  1159. }
  1160. }
  1161. void
  1162. IsabelleCheckRundown (
  1163. RPC_BINDING_HANDLE Binding
  1164. )
  1165. /*++
  1166. Routine Description:
  1167. This is the caller stub which will request that the server check
  1168. that the rundown routine actually got called.
  1169. Arguments:
  1170. Binding - Supplies a binding handle to be used to direct the
  1171. remote procedure call.
  1172. --*/
  1173. {
  1174. RPC_MESSAGE Caller;
  1175. Caller.Handle = Binding;
  1176. Caller.BufferLength = 0;
  1177. Caller.ProcNum = 6| HackForOldStubs ;
  1178. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1179. Caller.RpcFlags = 0;
  1180. if (IdempotentTests != 0)
  1181. {
  1182. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1183. }
  1184. if (MaybeTests != 0)
  1185. {
  1186. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1187. }
  1188. if (BroadcastTests != 0)
  1189. {
  1190. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1191. }
  1192. Status = UclntGetBuffer(&Caller);
  1193. if (Status)
  1194. {
  1195. ApiError("IsabelleCheckRundown", "I_RpcGetBuffer", Status);
  1196. IsabelleError();
  1197. return;
  1198. }
  1199. Status = UclntSendReceive(&Caller);
  1200. if (Status)
  1201. {
  1202. ApiError("IsabelleCheckRundown","I_RpcSendReceive",Status);
  1203. IsabelleError();
  1204. return;
  1205. }
  1206. else
  1207. {
  1208. if (Caller.BufferLength != 0)
  1209. {
  1210. OtherError("IsabelleCheckRundown","BufferLength != 0");
  1211. IsabelleError();
  1212. return;
  1213. }
  1214. Status = I_RpcFreeBuffer(&Caller);
  1215. if (Status)
  1216. {
  1217. ApiError("IsabelleCheckRundown","I_RpcFreeBuffer",Status);
  1218. IsabelleError();
  1219. return;
  1220. }
  1221. }
  1222. }
  1223. void
  1224. IsabelleMustFail (
  1225. RPC_BINDING_HANDLE Binding
  1226. )
  1227. /*++
  1228. Routine Description:
  1229. Arguments:
  1230. Binding - Supplies a binding handle to be used to direct the
  1231. remote procedure call.
  1232. --*/
  1233. {
  1234. RPC_MESSAGE Caller;
  1235. Caller.Handle = Binding;
  1236. Caller.BufferLength = 0;
  1237. Caller.ProcNum = 6| HackForOldStubs ;
  1238. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1239. Caller.RpcFlags = 0;
  1240. if (IdempotentTests != 0)
  1241. {
  1242. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1243. }
  1244. if (MaybeTests != 0)
  1245. {
  1246. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1247. }
  1248. if (BroadcastTests != 0)
  1249. {
  1250. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1251. }
  1252. Status = UclntGetBuffer(&Caller);
  1253. if (Status)
  1254. {
  1255. return;
  1256. }
  1257. Status = UclntSendReceive(&Caller);
  1258. if (Status)
  1259. {
  1260. return;
  1261. }
  1262. PrintToConsole("IsabelleMustFail: This call is supposed to fail\n") ;
  1263. IsabelleError();
  1264. }
  1265. void
  1266. IsabelleCheckContext (
  1267. RPC_BINDING_HANDLE Binding
  1268. )
  1269. /*++
  1270. Routine Description:
  1271. This is the caller stub which will request that the server check
  1272. the association context for this association (the one the call comes
  1273. in other), and then to set a new association context.
  1274. Arguments:
  1275. Binding - Supplies a binding handle to be used to direct the
  1276. remote procedure call.
  1277. --*/
  1278. {
  1279. RPC_MESSAGE Caller;
  1280. Caller.Handle = Binding;
  1281. Caller.BufferLength = 0;
  1282. Caller.ProcNum = 7 | HackForOldStubs ;
  1283. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1284. Caller.RpcFlags = 0;
  1285. if (IdempotentTests != 0)
  1286. {
  1287. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1288. }
  1289. if (MaybeTests != 0)
  1290. {
  1291. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1292. }
  1293. if (BroadcastTests != 0)
  1294. {
  1295. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1296. }
  1297. Status = UclntGetBuffer(&Caller);
  1298. if (Status)
  1299. {
  1300. ApiError("IsabelleCheckContext", "I_RpcGetBuffer", Status);
  1301. IsabelleError();
  1302. return;
  1303. }
  1304. Status = UclntSendReceive(&Caller);
  1305. if (Status)
  1306. {
  1307. ApiError("IsabelleCheckContext","I_RpcSendReceive",Status);
  1308. IsabelleError();
  1309. return;
  1310. }
  1311. else
  1312. {
  1313. if (Caller.BufferLength != 0)
  1314. {
  1315. OtherError("IsabelleCheckContext","BufferLength != 0");
  1316. IsabelleError();
  1317. return;
  1318. }
  1319. Status = I_RpcFreeBuffer(&Caller);
  1320. if (Status)
  1321. {
  1322. ApiError("IsabelleCheckContext","I_RpcFreeBuffer",Status);
  1323. IsabelleError();
  1324. return;
  1325. }
  1326. }
  1327. }
  1328. unsigned char *
  1329. IsabelleGetStringBinding (
  1330. RPC_BINDING_HANDLE Binding
  1331. )
  1332. /*++
  1333. Routine Description:
  1334. This is the caller stub which will request that the server return
  1335. the next string binding from the list of bindings supported by the
  1336. server.
  1337. Arguments:
  1338. Binding - Supplies a binding handle to be used to direct the
  1339. remote procedure call.
  1340. Return Value:
  1341. A copy of the string binding will be returned. This can be freed
  1342. using the delete operator. If there are no more string bindings,
  1343. or an error occurs, zero will be returned.
  1344. --*/
  1345. {
  1346. RPC_MESSAGE Caller;
  1347. unsigned char * StringBinding;
  1348. Caller.Handle = Binding;
  1349. Caller.BufferLength = 0;
  1350. Caller.ProcNum = 8 | HackForOldStubs ;
  1351. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1352. Caller.RpcFlags = 0;
  1353. if (IdempotentTests != 0)
  1354. {
  1355. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1356. }
  1357. if (MaybeTests != 0)
  1358. {
  1359. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1360. }
  1361. if (BroadcastTests != 0)
  1362. {
  1363. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1364. }
  1365. Status = UclntGetBuffer(&Caller);
  1366. if (Status)
  1367. {
  1368. ApiError("IsabelleGetStringBinding", "I_RpcGetBuffer", Status);
  1369. IsabelleError();
  1370. return(0);
  1371. }
  1372. Status = UclntSendReceive(&Caller);
  1373. if (Status)
  1374. {
  1375. ApiError("IsabelleGetStringBinding","I_RpcSendReceive",Status);
  1376. IsabelleError();
  1377. return(0);
  1378. }
  1379. if (Caller.BufferLength != 0)
  1380. {
  1381. StringBinding = new unsigned char[Caller.BufferLength];
  1382. RpcpMemoryCopy(StringBinding,Caller.Buffer,Caller.BufferLength);
  1383. }
  1384. else
  1385. StringBinding = 0;
  1386. Status = I_RpcFreeBuffer(&Caller);
  1387. if (Status)
  1388. {
  1389. ApiError("IsabelleGetStringBinding","I_RpcFreeBuffer",Status);
  1390. IsabelleError();
  1391. return(0);
  1392. }
  1393. return(StringBinding);
  1394. }
  1395. void
  1396. IsabelleCheckNoRundown (
  1397. RPC_BINDING_HANDLE Binding
  1398. )
  1399. /*++
  1400. Routine Description:
  1401. This is the caller stub which will request that the server check
  1402. that the rundown routine did not get called.
  1403. Arguments:
  1404. Binding - Supplies a binding handle to be used to direct the
  1405. remote procedure call.
  1406. --*/
  1407. {
  1408. RPC_MESSAGE Caller;
  1409. Caller.Handle = Binding;
  1410. Caller.BufferLength = 0;
  1411. Caller.ProcNum = 9| HackForOldStubs ;
  1412. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1413. Caller.RpcFlags = 0;
  1414. if (IdempotentTests != 0)
  1415. {
  1416. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1417. }
  1418. if (MaybeTests != 0)
  1419. {
  1420. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1421. }
  1422. if (BroadcastTests != 0)
  1423. {
  1424. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1425. }
  1426. Status = UclntGetBuffer(&Caller);
  1427. if (Status)
  1428. {
  1429. ApiError("IsabelleCheckNoRundown", "I_RpcGetBuffer", Status);
  1430. IsabelleError();
  1431. return;
  1432. }
  1433. Status = UclntSendReceive(&Caller);
  1434. if (Status)
  1435. {
  1436. ApiError("IsabelleCheckNoRundown","I_RpcSendReceive",Status);
  1437. IsabelleError();
  1438. return;
  1439. }
  1440. else
  1441. {
  1442. if (Caller.BufferLength != 0)
  1443. {
  1444. OtherError("IsabelleCheckNoRundown","BufferLength != 0");
  1445. IsabelleError();
  1446. return;
  1447. }
  1448. Status = I_RpcFreeBuffer(&Caller);
  1449. if (Status)
  1450. {
  1451. ApiError("IsabelleCheckNoRundown","I_RpcFreeBuffer",Status);
  1452. IsabelleError();
  1453. return;
  1454. }
  1455. }
  1456. }
  1457. void
  1458. IsabelleUnregisterInterfaces (
  1459. RPC_BINDING_HANDLE Binding
  1460. )
  1461. /*++
  1462. Routine Description:
  1463. Arguments:
  1464. Binding - Supplies a binding handle to be used to direct the
  1465. remote procedure call.
  1466. --*/
  1467. {
  1468. RPC_MESSAGE Caller;
  1469. Caller.Handle = Binding;
  1470. Caller.BufferLength = 0;
  1471. Caller.ProcNum = 11| HackForOldStubs ;
  1472. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1473. Caller.RpcFlags = 0;
  1474. if (IdempotentTests != 0)
  1475. {
  1476. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1477. }
  1478. if (MaybeTests != 0)
  1479. {
  1480. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1481. }
  1482. if (BroadcastTests != 0)
  1483. {
  1484. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1485. }
  1486. Status = UclntGetBuffer(&Caller);
  1487. if (Status)
  1488. {
  1489. ApiError("IsabelleUnregisterInterfaces", "I_RpcGetBuffer", Status);
  1490. IsabelleError();
  1491. return;
  1492. }
  1493. Status = UclntSendReceive(&Caller);
  1494. if (Status)
  1495. {
  1496. ApiError("IsabelleUnregisterInterfaces","I_RpcSendReceive",Status);
  1497. IsabelleError();
  1498. return;
  1499. }
  1500. Status = I_RpcFreeBuffer(&Caller);
  1501. if (Status)
  1502. {
  1503. ApiError("IsabelleUnregisterInterfaces","I_RpcFreeBuffer",Status);
  1504. IsabelleError();
  1505. return;
  1506. }
  1507. }
  1508. void
  1509. IsabelleRegisterInterfaces (
  1510. RPC_BINDING_HANDLE Binding
  1511. )
  1512. /*++
  1513. Routine Description:
  1514. Arguments:
  1515. Binding - Supplies a binding handle to be used to direct the
  1516. remote procedure call.
  1517. --*/
  1518. {
  1519. RPC_MESSAGE Caller;
  1520. Caller.Handle = Binding;
  1521. Caller.BufferLength = 0;
  1522. Caller.ProcNum = 12| HackForOldStubs ;
  1523. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1524. Caller.RpcFlags = 0;
  1525. if (IdempotentTests != 0)
  1526. {
  1527. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  1528. }
  1529. if (MaybeTests != 0)
  1530. {
  1531. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  1532. }
  1533. if (BroadcastTests != 0)
  1534. {
  1535. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  1536. }
  1537. Status = UclntGetBuffer(&Caller);
  1538. if (Status)
  1539. {
  1540. ApiError("IsabelleRegisterInterfaces", "I_RpcGetBuffer", Status);
  1541. IsabelleError();
  1542. return;
  1543. }
  1544. Status = UclntSendReceive(&Caller);
  1545. if (Status)
  1546. {
  1547. ApiError("IsabelleRegisterInterfaces","I_RpcSendReceive",Status);
  1548. IsabelleError();
  1549. return;
  1550. }
  1551. Status = I_RpcFreeBuffer(&Caller);
  1552. if (Status)
  1553. {
  1554. ApiError("IsabelleRegisterInterfaces","I_RpcFreeBuffer",Status);
  1555. IsabelleError();
  1556. return;
  1557. }
  1558. }
  1559. void PipeAlloc(
  1560. char PAPI *state,
  1561. int requested_size,
  1562. pipe_element_t PAPI * PAPI *allocated_buf,
  1563. int PAPI * allocated_size)
  1564. {
  1565. static int size = 0;
  1566. static void PAPI *buffer = NULL;
  1567. if (size < requested_size)
  1568. {
  1569. if (buffer)
  1570. {
  1571. I_RpcFree(buffer) ;
  1572. }
  1573. buffer = I_RpcAllocate(requested_size) ;
  1574. if (buffer == 0)
  1575. {
  1576. *allocated_size = 0 ;
  1577. size = 0 ;
  1578. }
  1579. else
  1580. {
  1581. *allocated_size = requested_size ;
  1582. size = requested_size ;
  1583. }
  1584. *allocated_buf = (pipe_element_t PAPI *) buffer ;
  1585. }
  1586. else
  1587. {
  1588. *allocated_buf = (pipe_element_t PAPI *) buffer ;
  1589. *allocated_size = size ;
  1590. }
  1591. }
  1592. void PipePull(
  1593. char PAPI *state,
  1594. pipe_element_t PAPI *buffer,
  1595. int num_buf_elem,
  1596. int PAPI *size_to_send
  1597. )
  1598. {
  1599. int i ;
  1600. char j = 0;
  1601. if (*((int PAPI *)state) <= 0)
  1602. {
  1603. *size_to_send = 0 ;
  1604. return ;
  1605. }
  1606. // fill pipe elements
  1607. for (i = 0; i<num_buf_elem; i++, j++)
  1608. {
  1609. buffer[i] = i ;
  1610. }
  1611. *size_to_send = num_buf_elem ;
  1612. --*((int PAPI *) state) ;
  1613. }
  1614. int localchecksum ;
  1615. void PipePush(
  1616. char PAPI *state,
  1617. pipe_element_t PAPI *input_buffer,
  1618. int ecount
  1619. )
  1620. {
  1621. char PAPI *temp = (char PAPI *) input_buffer ;
  1622. int i, j ;
  1623. for (i = 0; i < ecount; i++)
  1624. {
  1625. localchecksum += input_buffer[i] ;
  1626. }
  1627. }
  1628. void
  1629. IsabellePipeIN (
  1630. RPC_BINDING_HANDLE Binding,
  1631. pipe_t PAPI *pipe,
  1632. int chunksize,
  1633. int numchunks,
  1634. long checksum,
  1635. int buffsize,
  1636. char PAPI *buffer
  1637. )
  1638. {
  1639. RPC_MESSAGE Caller, TempBuf;
  1640. pipe_element_t PAPI *buf ;
  1641. int num_buf_bytes ;
  1642. int count ;
  1643. int num_buf_elem ;
  1644. DWORD size = 0 ;
  1645. char PAPI *Temp ;
  1646. int BufferOffset = 0 ;
  1647. int LengthToSend ;
  1648. Caller.Handle = Binding;
  1649. Caller.BufferLength = 3 * sizeof(int) + buffsize;
  1650. Caller.ProcNum = 13 | HackForOldStubs | RPC_FLAGS_VALID_BIT;
  1651. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1652. Caller.RpcFlags = RPC_BUFFER_PARTIAL ;
  1653. Status = UclntGetBuffer(&Caller);
  1654. if (Status)
  1655. {
  1656. ApiError("IsabellePipeIN", "I_RpcGetBuffer", Status);
  1657. IsabelleError();
  1658. return;
  1659. }
  1660. // marshal the fixed parameters
  1661. Temp = (char PAPI *) Caller.Buffer ;
  1662. *((int PAPI *) Temp) = chunksize ;
  1663. Temp += sizeof(int) ;
  1664. *((int PAPI *) Temp) = numchunks ;
  1665. Temp += sizeof(int) ;
  1666. *((long PAPI *) Temp) = checksum ;
  1667. Temp += sizeof(long) ;
  1668. *((int PAPI *) Temp) = buffsize ;
  1669. Temp += sizeof(int) ;
  1670. RpcpMemoryCopy(Temp, buffer, buffsize) ;
  1671. // send the marshalled parameters
  1672. Status = I_RpcSend(&Caller);
  1673. if (Status == RPC_S_SEND_INCOMPLETE)
  1674. {
  1675. BufferOffset = Caller.BufferLength ;
  1676. }
  1677. else if (Status)
  1678. {
  1679. ApiError("IsabellePipeIN","I_RpcSend",Status);
  1680. IsabelleError();
  1681. return;
  1682. }
  1683. do
  1684. {
  1685. pipe->Alloc(pipe->state,
  1686. chunksize * sizeof(pipe_element_t) + sizeof(DWORD),
  1687. &buf,
  1688. &num_buf_bytes
  1689. ) ;
  1690. num_buf_elem = (num_buf_bytes -sizeof(DWORD)) / sizeof(pipe_element_t) ;
  1691. pipe->Pull(pipe->state,
  1692. (pipe_element_t PAPI *) ((char PAPI *) buf+sizeof(DWORD)),
  1693. num_buf_elem,
  1694. &count
  1695. ) ;
  1696. *((DWORD PAPI *) buf) = count ;
  1697. LengthToSend = (count * sizeof(pipe_element_t)) + sizeof(DWORD) ;
  1698. Status = I_RpcReallocPipeBuffer(&Caller, LengthToSend+BufferOffset) ;
  1699. if (Status)
  1700. {
  1701. ApiError("IsabellePipeIN","I_RpcReallocPipeBuffer",Status);
  1702. IsabelleError();
  1703. return;
  1704. }
  1705. if (count == 0)
  1706. {
  1707. Caller.RpcFlags = 0 ;
  1708. }
  1709. RpcpMemoryCopy((char PAPI *) Caller.Buffer+BufferOffset, buf, LengthToSend) ;
  1710. Status = I_RpcSend(&Caller) ;
  1711. if (Status == RPC_S_SEND_INCOMPLETE)
  1712. {
  1713. BufferOffset = Caller.BufferLength ;
  1714. }
  1715. else if (Status)
  1716. {
  1717. ApiError("IsabellePipeIN","I_RpcSend",Status);
  1718. IsabelleError();
  1719. return;
  1720. }
  1721. else
  1722. {
  1723. BufferOffset = 0 ;
  1724. }
  1725. }
  1726. while (count > 0) ;
  1727. size = 0 ;
  1728. Caller.RpcFlags = 0 ;
  1729. Status = I_RpcReceive(&Caller, size) ;
  1730. if (Status == RPC_S_OK)
  1731. {
  1732. if (Caller.BufferLength != 0)
  1733. {
  1734. OtherError("IsabellePipeIN","BufferLength != 0");
  1735. IsabelleError();
  1736. return;
  1737. }
  1738. Status = I_RpcFreeBuffer(&Caller);
  1739. if (Status)
  1740. {
  1741. ApiError("IsabellePipeIN","I_RpcFreeBuffer",Status);
  1742. IsabelleError();
  1743. return;
  1744. }
  1745. }
  1746. }
  1747. void LocalPipePull(
  1748. PIPE_STATE PAPI *state,
  1749. void PAPI *buffer,
  1750. int max_buf,
  1751. int PAPI *actual_transfer_count
  1752. )
  1753. {
  1754. unsigned num_elements = 0 ;
  1755. DWORD size = (DWORD) max_buf;
  1756. int bytescopied ;
  1757. RPC_MESSAGE Caller ;
  1758. *actual_transfer_count = 0 ;
  1759. if (state->EndOfPipe)
  1760. {
  1761. return ;
  1762. }
  1763. I_RpcReadPipeElementsFromBuffer(state, (char PAPI *) buffer, max_buf, (int *) &num_elements) ;
  1764. *actual_transfer_count += num_elements ;
  1765. bytescopied = num_elements * sizeof(pipe_element_t) ;
  1766. if (state->EndOfPipe == 0 &&
  1767. num_elements < (max_buf / sizeof(pipe_element_t)))
  1768. {
  1769. Caller.RpcFlags = RPC_BUFFER_PARTIAL ;
  1770. Caller.Buffer = state->Buffer ;
  1771. Caller.BufferLength = state->BufferLength ;
  1772. Status = I_RpcReceive(&Caller, size) ;
  1773. if (Status)
  1774. {
  1775. ApiError("PipePull", "I_RpcReceive", Status) ;
  1776. return ;
  1777. }
  1778. num_elements = 0 ;
  1779. state->Buffer = Caller.Buffer ;
  1780. state->BufferLength = Caller.BufferLength ;
  1781. state->CurPointer = (char PAPI *) Caller.Buffer ;
  1782. state->BytesRemaining = Caller.BufferLength ;
  1783. I_RpcReadPipeElementsFromBuffer(
  1784. (PIPE_STATE PAPI *) state,
  1785. (char PAPI *) buffer+bytescopied,
  1786. max_buf - bytescopied, (int *) &num_elements) ;
  1787. *actual_transfer_count += num_elements ;
  1788. }
  1789. }
  1790. void
  1791. IsabellePipeOUT (
  1792. RPC_BINDING_HANDLE Binding,
  1793. pipe_t PAPI *pipe,
  1794. int chunksize
  1795. )
  1796. {
  1797. RPC_MESSAGE Caller;
  1798. int num_elements ;
  1799. int count ;
  1800. DWORD size = chunksize * sizeof(pipe_element_t) + sizeof(DWORD) *2;
  1801. int max_buf ;
  1802. PIPE_STATE localstate ;
  1803. pipe_element_t PAPI *buf ;
  1804. pipe_element_t pipe_element ;
  1805. int rchunksize, rnumchunks, rbuffsize, rchecksum ;
  1806. char PAPI *temp, PAPI *cur ;
  1807. Caller.Handle = Binding;
  1808. Caller.BufferLength = 0;
  1809. Caller.ProcNum = 14 | HackForOldStubs | RPC_FLAGS_VALID_BIT;
  1810. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1811. Caller.RpcFlags = RPC_BUFFER_PARTIAL ;
  1812. Status = I_RpcGetBuffer(&Caller) ;
  1813. if (Status)
  1814. {
  1815. ApiError("IsabellePipeOUT","I_RpcSendReceive",Status);
  1816. IsabelleError();
  1817. return;
  1818. }
  1819. Caller.RpcFlags = 0;
  1820. Status = I_RpcSend(&Caller) ;
  1821. if (Status)
  1822. {
  1823. ApiError("IsabellePipeOUT","I_RpcSendReceive",Status);
  1824. IsabelleError();
  1825. return;
  1826. }
  1827. Caller.RpcFlags |= RPC_BUFFER_PARTIAL ;
  1828. Status = I_RpcReceive(&Caller, size) ;
  1829. if (Status)
  1830. {
  1831. ApiError("IsabellePipeOUT", "I_RpcReceive", Status) ;
  1832. IsabelleError() ;
  1833. return ;
  1834. }
  1835. localstate.Buffer = Caller.Buffer ;
  1836. localstate.BufferLength = Caller.BufferLength ;
  1837. localstate.CurrentState = start ;
  1838. localstate.CurPointer = (char PAPI *) Caller.Buffer ;
  1839. localstate.BytesRemaining = Caller.BufferLength ;
  1840. localstate.EndOfPipe = 0 ;
  1841. localstate.PipeElementSize = sizeof(pipe_element_t) ;
  1842. localstate.PartialPipeElement = &pipe_element ;
  1843. localchecksum = 0;
  1844. do
  1845. {
  1846. pipe->Alloc(pipe->state,
  1847. size,
  1848. &buf,
  1849. &max_buf
  1850. ) ;
  1851. LocalPipePull(&localstate, buf, max_buf, &num_elements) ;
  1852. pipe->Push(pipe->state,
  1853. buf,
  1854. num_elements) ;
  1855. }
  1856. while (num_elements > 0);
  1857. if (!(Caller.RpcFlags & RPC_BUFFER_COMPLETE))
  1858. {
  1859. Caller.RpcFlags = 0 ;
  1860. Status = I_RpcReceive(&Caller, size) ;
  1861. if (Status)
  1862. {
  1863. ApiError("IsabellePipeOUT", "I_RpcReceive", Status) ;
  1864. IsabelleError() ;
  1865. return ;
  1866. }
  1867. }
  1868. if (localstate.BytesRemaining > 0)
  1869. {
  1870. // this might be quite inefficient... need to improve
  1871. // Also, CurPointer may be a pointer in Caller.Buffer
  1872. // need to keep track of this in the state.
  1873. temp = (char PAPI *) I_RpcAllocate(Caller.BufferLength + localstate.BytesRemaining) ;
  1874. RpcpMemoryCopy(temp, localstate.CurPointer, localstate.BytesRemaining) ;
  1875. RpcpMemoryCopy(temp+localstate.BytesRemaining,
  1876. Caller.Buffer, Caller.BufferLength) ;
  1877. cur = temp ;
  1878. }
  1879. else
  1880. {
  1881. temp = 0;
  1882. cur = (char PAPI *) Caller.Buffer ;
  1883. }
  1884. rchunksize = *((int PAPI *) cur) ;
  1885. cur += sizeof(int) ;
  1886. rnumchunks = *((int PAPI *) cur) ;
  1887. cur += sizeof(int) ;
  1888. rchecksum = *((int PAPI *) cur) ;
  1889. cur += sizeof(int) ;
  1890. rbuffsize = *((int PAPI *) cur) ;
  1891. cur += sizeof(int) ;
  1892. PrintToConsole("IsabellePipeOUT: chunksize = %d\n", rchunksize) ;
  1893. PrintToConsole("IsabellePipeOUT: numchunks = %d\n", rnumchunks) ;
  1894. PrintToConsole("IsabellePipeOUT: buffsize = %d\n", rbuffsize) ;
  1895. PrintToConsole("IsabellePipeOUT: checksum = %d\n", rchecksum) ;
  1896. if (temp)
  1897. {
  1898. I_RpcFree(temp) ;
  1899. }
  1900. Status = I_RpcFreeBuffer(&Caller) ;
  1901. if (Status)
  1902. {
  1903. ApiError("IsabellePipeOUT","I_RpcSendReceive",Status);
  1904. IsabelleError() ;
  1905. return;
  1906. }
  1907. if (rchecksum != localchecksum)
  1908. {
  1909. IsabelleError() ;
  1910. }
  1911. }
  1912. void
  1913. IsabellePipeINOUT (
  1914. RPC_BINDING_HANDLE Binding,
  1915. pipe_t PAPI *pipe,
  1916. int chunksize,
  1917. int checksum
  1918. )
  1919. {
  1920. RPC_MESSAGE Caller, TempBuf;
  1921. pipe_element_t PAPI *buf ;
  1922. int num_buf_bytes ;
  1923. int count ;
  1924. int num_buf_elem ;
  1925. DWORD size = chunksize * sizeof(pipe_element_t) + sizeof(DWORD) * 2;
  1926. PIPE_STATE localstate ;
  1927. int max_buf ;
  1928. int num_elements ;
  1929. pipe_element_t pipe_element ;
  1930. int BufferOffset = 0 ;
  1931. int LengthToSend ;
  1932. Caller.Handle = Binding;
  1933. Caller.BufferLength = 0;
  1934. Caller.ProcNum = 15 | HackForOldStubs | RPC_FLAGS_VALID_BIT;
  1935. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  1936. Caller.RpcFlags = RPC_BUFFER_PARTIAL ;
  1937. Status = UclntGetBuffer(&Caller) ;
  1938. if (Status)
  1939. {
  1940. ApiError("IsabellePipeINOUT","I_RpcSendReceive",Status);
  1941. IsabelleError();
  1942. return;
  1943. }
  1944. // send the marshalled parameters
  1945. Status = I_RpcSend(&Caller);
  1946. if (Status == RPC_S_SEND_INCOMPLETE)
  1947. {
  1948. BufferOffset = Caller.BufferLength ;
  1949. }
  1950. else if (Status)
  1951. {
  1952. ApiError("IsabellePipeINOUT","I_RpcSendReceive",Status);
  1953. IsabelleError();
  1954. return;
  1955. }
  1956. do
  1957. {
  1958. pipe->Alloc(pipe->state,
  1959. size,
  1960. &buf,
  1961. &num_buf_bytes
  1962. ) ;
  1963. num_buf_elem = (num_buf_bytes -sizeof(DWORD)) / sizeof(pipe_element_t) ;
  1964. pipe->Pull(pipe->state,
  1965. (pipe_element_t PAPI *) ((char PAPI *) buf+sizeof(DWORD)),
  1966. num_buf_elem,
  1967. &count
  1968. ) ;
  1969. *((DWORD PAPI *) buf) = count ;
  1970. LengthToSend = (count * sizeof(pipe_element_t)) + sizeof(DWORD) ;
  1971. Status = I_RpcReallocPipeBuffer(&Caller, LengthToSend+BufferOffset) ;
  1972. if (Status)
  1973. {
  1974. ApiError("IsabellePipeINOUT","I_RpcGetBuffer",Status);
  1975. IsabelleError();
  1976. return;
  1977. }
  1978. if (count == 0)
  1979. {
  1980. Caller.RpcFlags = 0 ;
  1981. }
  1982. RpcpMemoryCopy((char PAPI *) Caller.Buffer+BufferOffset, buf, LengthToSend) ;
  1983. Status = I_RpcSend(&Caller) ;
  1984. if (Status == RPC_S_SEND_INCOMPLETE)
  1985. {
  1986. BufferOffset = Caller.BufferLength ;
  1987. }
  1988. else if (Status)
  1989. {
  1990. ApiError("IsabellePipeINOUT","I_RpcSend",Status);
  1991. IsabelleError();
  1992. return;
  1993. }
  1994. else
  1995. {
  1996. BufferOffset = 0 ;
  1997. }
  1998. }
  1999. while (count > 0) ;
  2000. Caller.RpcFlags |= RPC_BUFFER_PARTIAL ;
  2001. Status = I_RpcReceive(&Caller, size) ;
  2002. if (Status)
  2003. {
  2004. ApiError("IsabellePipeINOUT", "I_RpcReceive", Status) ;
  2005. IsabelleError() ;
  2006. return ;
  2007. }
  2008. PrintToConsole("IsabellePipeINOUT: checksum (IN) = %d\n",
  2009. checksum) ;
  2010. localstate.Buffer = Caller.Buffer ;
  2011. localstate.CurrentState = start ;
  2012. localstate.CurPointer = (char PAPI *) Caller.Buffer ;
  2013. localstate.BytesRemaining = Caller.BufferLength ;
  2014. localstate.EndOfPipe = 0 ;
  2015. localstate.PipeElementSize = sizeof(pipe_element_t) ;
  2016. localstate.PartialPipeElement = &pipe_element ;
  2017. localchecksum = 0;
  2018. do
  2019. {
  2020. pipe->Alloc(pipe->state,
  2021. size,
  2022. &buf,
  2023. &max_buf
  2024. ) ;
  2025. LocalPipePull(&localstate, buf, max_buf, &num_elements) ;
  2026. pipe->Push(pipe->state,
  2027. buf,
  2028. num_elements
  2029. ) ;
  2030. }
  2031. while (num_elements > 0);
  2032. if (!(Caller.RpcFlags & RPC_BUFFER_COMPLETE))
  2033. {
  2034. Status = I_RpcReceive(&Caller, size) ;
  2035. if (Status)
  2036. {
  2037. ApiError("IsabellePipeINOUT", "I_RpcReceive", Status) ;
  2038. IsabelleError() ;
  2039. return ;
  2040. }
  2041. }
  2042. Status = I_RpcFreeBuffer(&Caller) ;
  2043. if (Status)
  2044. {
  2045. ApiError("IsabellePipeINOUT","I_RpcSendReceive",Status);
  2046. IsabelleError();
  2047. return;
  2048. }
  2049. PrintToConsole("IsabellePipeINOUT: checksum (OUT) = %d\n", localchecksum) ;
  2050. }
  2051. BOOL IsServerNTSystem(RPC_BINDING_HANDLE Binding)
  2052. {
  2053. OSVERSIONINFO *pOsVer;
  2054. BOOL fResult;
  2055. RPC_MESSAGE Caller;
  2056. Caller.Handle = Binding;
  2057. Caller.BufferLength = 0;
  2058. Caller.ProcNum = 20| HackForOldStubs ;
  2059. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  2060. Caller.RpcFlags = 0;
  2061. if (IdempotentTests != 0)
  2062. {
  2063. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2064. }
  2065. if (MaybeTests != 0)
  2066. {
  2067. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2068. }
  2069. if (BroadcastTests != 0)
  2070. {
  2071. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2072. }
  2073. Status = UclntGetBuffer(&Caller);
  2074. if (Status)
  2075. {
  2076. ApiError("IsServerNTSystem", "I_RpcGetBuffer", Status);
  2077. IsabelleError();
  2078. return TRUE;
  2079. }
  2080. Status = UclntSendReceive(&Caller);
  2081. if (Status)
  2082. {
  2083. ApiError("IsServerNTSystem","I_RpcSendReceive",Status);
  2084. IsabelleError();
  2085. return TRUE;
  2086. }
  2087. pOsVer = (OSVERSIONINFO *)Caller.Buffer;
  2088. if (pOsVer->dwPlatformId == VER_PLATFORM_WIN32_NT)
  2089. fResult = TRUE;
  2090. else
  2091. fResult = FALSE;
  2092. Status = I_RpcFreeBuffer(&Caller);
  2093. if (Status)
  2094. {
  2095. ApiError("IsServerNTSystem","I_RpcFreeBuffer",Status);
  2096. IsabelleError();
  2097. }
  2098. return fResult;
  2099. }
  2100. typedef struct _WIRE_CONTEXT
  2101. {
  2102. unsigned long ContextType;
  2103. UUID ContextUuid;
  2104. } WIRE_CONTEXT;
  2105. typedef struct _CCONTEXT {
  2106. RPC_BINDING_HANDLE hRPC; // binding handle assoicated with context
  2107. unsigned long MagicValue;
  2108. WIRE_CONTEXT NDR;
  2109. } CCONTEXT, *PCCONTEXT;
  2110. const ULONG CONTEXT_MAGIC_VALUE = 0xFEDCBA98;
  2111. void
  2112. UnregisterHelgaEx (
  2113. RPC_BINDING_HANDLE Binding
  2114. )
  2115. {
  2116. RPC_MESSAGE Caller;
  2117. Caller.Handle = Binding;
  2118. Caller.BufferLength = 0;
  2119. Caller.ProcNum = 22| HackForOldStubs ;
  2120. Caller.RpcInterfaceInformation = &IsabelleInterfaceInformation;
  2121. Caller.RpcFlags = 0;
  2122. if (IdempotentTests != 0)
  2123. {
  2124. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2125. }
  2126. if (MaybeTests != 0)
  2127. {
  2128. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2129. }
  2130. if (BroadcastTests != 0)
  2131. {
  2132. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2133. }
  2134. Status = UclntGetBuffer(&Caller);
  2135. if (Status)
  2136. {
  2137. ApiError("UnregisterHelgaEx", "I_RpcGetBuffer", Status);
  2138. IsabelleError();
  2139. return;
  2140. }
  2141. Status = UclntSendReceive(&Caller);
  2142. if (Status)
  2143. {
  2144. ApiError("UnregisterHelgaEx","I_RpcSendReceive",Status);
  2145. IsabelleError();
  2146. return;
  2147. }
  2148. Status = I_RpcFreeBuffer(&Caller);
  2149. if (Status)
  2150. {
  2151. ApiError("UnregisterHelgaEx","I_RpcFreeBuffer",Status);
  2152. IsabelleError();
  2153. }
  2154. }
  2155. void OpenContextHandle(
  2156. IN RPC_BINDING_HANDLE Binding,
  2157. IN RPC_CLIENT_INTERFACE *If,
  2158. OUT CCONTEXT *ContextHandle
  2159. )
  2160. {
  2161. RPC_MESSAGE Caller;
  2162. Caller.Handle = Binding;
  2163. Caller.BufferLength = sizeof(WIRE_CONTEXT);
  2164. if (If == &IsabelleInterfaceInformation)
  2165. Caller.ProcNum = 21| HackForOldStubs ;
  2166. else if (If == &HelgaInterfaceInformation)
  2167. Caller.ProcNum = 10| HackForOldStubs ;
  2168. else
  2169. {
  2170. ASSERT(0);
  2171. }
  2172. Caller.RpcInterfaceInformation = If;
  2173. Caller.RpcFlags = 0;
  2174. if (IdempotentTests != 0)
  2175. {
  2176. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2177. }
  2178. if (MaybeTests != 0)
  2179. {
  2180. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2181. }
  2182. if (BroadcastTests != 0)
  2183. {
  2184. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2185. }
  2186. Status = UclntGetBuffer(&Caller);
  2187. if (Status)
  2188. {
  2189. ApiError("OpenContextHandle", "I_RpcGetBuffer", Status);
  2190. IsabelleError();
  2191. return;
  2192. }
  2193. memset(Caller.Buffer, 0, sizeof(WIRE_CONTEXT));
  2194. Status = UclntSendReceive(&Caller);
  2195. if (Status)
  2196. {
  2197. ApiError("OpenContextHandle","I_RpcSendReceive",Status);
  2198. IsabelleError();
  2199. return;
  2200. }
  2201. if (ContextHandle)
  2202. {
  2203. Status = RpcBindingCopy(Binding, &ContextHandle->hRPC);
  2204. if (Status)
  2205. {
  2206. ApiError("OpenContextHandle","RpcBindingCopy", Status);
  2207. IsabelleError();
  2208. }
  2209. ContextHandle->MagicValue = CONTEXT_MAGIC_VALUE;
  2210. memcpy(&ContextHandle->NDR, Caller.Buffer, sizeof(WIRE_CONTEXT));
  2211. }
  2212. Status = I_RpcFreeBuffer(&Caller);
  2213. if (Status)
  2214. {
  2215. ApiError("OpenContextHandle","I_RpcFreeBuffer",Status);
  2216. IsabelleError();
  2217. }
  2218. }
  2219. /* -----------------------------------------------------------------
  2220. Synchronize Routine
  2221. --------------------------------------------------------------------*/
  2222. void Synchro(
  2223. unsigned int Address // Specifies the binding to use in making the call
  2224. )
  2225. {
  2226. RPC_BINDING_HANDLE Binding ;
  2227. int fPrint = 0;
  2228. RPC_MESSAGE Caller;
  2229. if (AutoListenFlag)
  2230. {
  2231. Caller.BufferLength = 0;
  2232. Caller.ProcNum = 4 | HackForOldStubs ;
  2233. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation ;
  2234. Caller.RpcFlags = 0;
  2235. }
  2236. Status = GetBinding(Address, &Binding);
  2237. if (Status)
  2238. {
  2239. ApiError("Synchro","GetBinding",Status);
  2240. PrintToConsole("Synchro : FAIL - Unable to Bind\n");
  2241. return;
  2242. }
  2243. #ifdef __RPC_WIN32__
  2244. if (AutoListenFlag)
  2245. {
  2246. Caller.Handle = Binding;
  2247. while(1)
  2248. {
  2249. while(UclntGetBuffer(&Caller))
  2250. {
  2251. Caller.Handle = Binding;
  2252. PrintToConsole(".");
  2253. fPrint = 1;
  2254. PauseExecution(100);
  2255. }
  2256. if( UclntSendReceive(&Caller) == 0)
  2257. {
  2258. PrintToConsole("\n");
  2259. break ;
  2260. }
  2261. PauseExecution(100) ;
  2262. PrintToConsole(".");
  2263. fPrint = 1;
  2264. Caller.Handle = Binding ;
  2265. }
  2266. // SendReceive okay, free buffer now.
  2267. Status = I_RpcFreeBuffer(&Caller);
  2268. if (Status)
  2269. ApiError("Synchro","I_RpcFreeBuffer",Status);
  2270. }
  2271. else
  2272. {
  2273. while(RpcMgmtIsServerListening(Binding) != RPC_S_OK)
  2274. {
  2275. PrintToConsole(".");
  2276. fPrint = 1;
  2277. PauseExecution(100) ;
  2278. }
  2279. }
  2280. #else
  2281. Caller.Handle = Binding;
  2282. while(1)
  2283. {
  2284. while(UclntGetBuffer(&Caller))
  2285. {
  2286. Caller.Handle = Binding;
  2287. PrintToConsole(".");
  2288. fPrint = 1;
  2289. PauseExecution(100);
  2290. }
  2291. if( UclntSendReceive(&Caller) == 0)
  2292. {
  2293. PrintToConsole("\n");
  2294. break ;
  2295. }
  2296. PauseExecution(100) ;
  2297. PrintToConsole(".");
  2298. fPrint = 1;
  2299. }
  2300. // SendReceive okay, free buffer now.
  2301. Status = I_RpcFreeBuffer(&Caller);
  2302. if (Status)
  2303. ApiError("Synchro","I_RpcFreeBuffer",Status);
  2304. #endif
  2305. Status = RpcBindingFree(&Binding);
  2306. if (Status)
  2307. {
  2308. ApiError("Synchro","RpcBindingFree",Status);
  2309. PrintToConsole("Synchro : FAIL - Unable to Free Binding");
  2310. return;
  2311. }
  2312. if (fPrint)
  2313. {
  2314. PrintToConsole("\n");
  2315. }
  2316. }
  2317. /* --------------------------------------------------------------------
  2318. Helga Interface
  2319. -------------------------------------------------------------------- */
  2320. void
  2321. InitializeBuffer (
  2322. IN OUT void PAPI * Buffer,
  2323. IN unsigned int BufferLength
  2324. )
  2325. /*++
  2326. Routine Description:
  2327. This routine is used to initialize the buffer; the first long in the
  2328. buffer is set to be the length of the buffer. The rest of the buffer
  2329. is initialized with a pattern which will be checked by the receiver.
  2330. Arguments:
  2331. Buffer - Supplies the buffer to be initialized.
  2332. BufferLength - Supplies the length of the buffer.
  2333. --*/
  2334. {
  2335. unsigned long PAPI * Length;
  2336. unsigned char PAPI * BufferScan;
  2337. static unsigned char InitialValue = 96;
  2338. unsigned char Value;
  2339. Length = (unsigned long PAPI *) Buffer;
  2340. *Length = BufferLength;
  2341. swaplong(*Length) ;
  2342. Value = InitialValue;
  2343. InitialValue += 1;
  2344. for (BufferScan = (unsigned char PAPI *) (Length + 1), BufferLength -= 4;
  2345. BufferLength > 0; BufferLength--, BufferScan++, Value++)
  2346. *BufferScan = Value;
  2347. }
  2348. int
  2349. CheckBuffer (
  2350. IN void PAPI * Buffer,
  2351. IN unsigned long BufferLength
  2352. )
  2353. /*++
  2354. Routine Description:
  2355. We need to check that the correct bytes were sent. We do not check
  2356. the length of the buffer.
  2357. Arguments:
  2358. Buffer - Supplies the buffer to be checked.
  2359. BufferLength - Supplies the length of the buffer to be checked.
  2360. Return Value:
  2361. A value of zero will be returned if the buffer contains the correct
  2362. bytes; otherwise, non-zero will be returned.
  2363. --*/
  2364. {
  2365. unsigned long PAPI * Length;
  2366. unsigned char PAPI * BufferScan;
  2367. unsigned char Value = 0;
  2368. Length = (unsigned long PAPI *) Buffer;
  2369. swaplong(*Length) ;
  2370. for (BufferScan = (unsigned char PAPI *) (Length + 1),
  2371. Value = *BufferScan, BufferLength -= 4;
  2372. BufferLength > 0; BufferLength--, BufferScan++, Value++)
  2373. if (*BufferScan != Value)
  2374. return(1);
  2375. return(0);
  2376. }
  2377. RPC_PROTSEQ_ENDPOINT HelgaRpcProtseqEndpoint[] =
  2378. {
  2379. {(unsigned char *) "ncacn_np",
  2380. #ifdef WIN32RPC
  2381. (unsigned char *) "\\pipe\\zippyhe"},
  2382. #else // WIN32RPC
  2383. (unsigned char *) "\\device\\namedpipe\\christopherhelga"},
  2384. #endif // WIN32RPC
  2385. {(unsigned char *) "ncacn_ip_tcp", (unsigned char *) "2039"}
  2386. ,{(unsigned char *) "ncadg_ip_udp", (unsigned char *) "2039"}
  2387. ,{(unsigned char *) "ncalrpc",(unsigned char *) "christopherhelga"}
  2388. ,{(unsigned char *) "ncacn_nb_nb",(unsigned char *) "211"}
  2389. ,{(unsigned char *) "ncacn_spx", (unsigned char *) "5014"}
  2390. ,{(unsigned char *) "ncadg_ipx", (unsigned char *) "5014"}
  2391. ,{(unsigned char *) "ncacn_vns_spp", (unsigned char *) "264"}
  2392. ,{(unsigned char *) "ncacn_at_dsp", (unsigned char *) "\\pipe\\zippyhe"}
  2393. ,{(unsigned char *) "ncadg_mq", (unsigned char *) "christopherhelga"}
  2394. };
  2395. RPC_CLIENT_INTERFACE HelgaInterfaceInformation =
  2396. {
  2397. sizeof(RPC_CLIENT_INTERFACE),
  2398. {{1,2,2,{3,3,3,3,3,3,3,3}},
  2399. {1,1}},
  2400. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  2401. {2, 0}},
  2402. 0,
  2403. sizeof(HelgaRpcProtseqEndpoint) / sizeof(RPC_PROTSEQ_ENDPOINT),
  2404. HelgaRpcProtseqEndpoint,
  2405. 0,
  2406. NULL,
  2407. RPC_INTERFACE_HAS_PIPES
  2408. };
  2409. // Send a 0 length packet and expect a 0 length one in reply
  2410. void
  2411. Helga (
  2412. RPC_BINDING_HANDLE Binding // Specifies the binding to use in making the
  2413. // remote procedure call.
  2414. )
  2415. {
  2416. RPC_MESSAGE Caller;
  2417. Caller.Handle = Binding;
  2418. Caller.BufferLength = 0;
  2419. Caller.ProcNum = 0 | HackForOldStubs ;
  2420. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2421. Caller.RpcFlags = 0;
  2422. if (IdempotentTests != 0)
  2423. {
  2424. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2425. }
  2426. if (MaybeTests != 0)
  2427. {
  2428. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2429. }
  2430. if (BroadcastTests != 0)
  2431. {
  2432. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2433. }
  2434. Status = UclntGetBuffer(&Caller);
  2435. if (Status)
  2436. {
  2437. ApiError("Helga","I_RpcGetBuffer",Status);
  2438. HelgaError();
  2439. return;
  2440. }
  2441. Status = UclntSendReceive(&Caller);
  2442. if (Status)
  2443. {
  2444. ApiError("Helga","I_RpcSendReceive",Status);
  2445. HelgaError();
  2446. return;
  2447. }
  2448. else
  2449. {
  2450. if (Caller.BufferLength != 0)
  2451. {
  2452. OtherError("Helga","BufferLength != 0");
  2453. HelgaError();
  2454. return;
  2455. }
  2456. Status = I_RpcFreeBuffer(&Caller);
  2457. if (Status)
  2458. {
  2459. ApiError("Helga","I_RpcFreeBuffer",Status);
  2460. HelgaError();
  2461. return;
  2462. }
  2463. }
  2464. }
  2465. // Send a 0 length packet and expect a 0 length one in reply
  2466. DWORD
  2467. HelgaSendReceiveFailure (
  2468. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  2469. // remote procedure call.
  2470. int ProcNum
  2471. )
  2472. {
  2473. RPC_MESSAGE Caller;
  2474. Caller.Handle = Binding;
  2475. Caller.BufferLength = 0;
  2476. Caller.ProcNum = ProcNum | HackForOldStubs ;
  2477. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2478. Caller.RpcFlags = 0;
  2479. if (IdempotentTests != 0)
  2480. {
  2481. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2482. }
  2483. if (MaybeTests != 0)
  2484. {
  2485. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2486. }
  2487. if (BroadcastTests != 0)
  2488. {
  2489. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2490. }
  2491. Status = UclntGetBuffer(&Caller);
  2492. if (Status)
  2493. {
  2494. ApiError("Helga","I_RpcGetBuffer",Status);
  2495. HelgaError();
  2496. return -1;
  2497. }
  2498. Status = UclntSendReceive(&Caller);
  2499. if (!Status)
  2500. {
  2501. ApiError("HelgaSendReceiveFailure","I_RpcSendReceive",Status);
  2502. HelgaError();
  2503. I_RpcFreeBuffer(&Caller);
  2504. return -1;
  2505. }
  2506. return Status;
  2507. }
  2508. void
  2509. HelgaSyncLpcSecurity (
  2510. RPC_BINDING_HANDLE Binding
  2511. )
  2512. {
  2513. RPC_MESSAGE Caller;
  2514. Caller.Handle = Binding;
  2515. Caller.BufferLength = 0;
  2516. Caller.ProcNum = 6 | HackForOldStubs ;
  2517. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2518. Caller.RpcFlags = 0;
  2519. if (IdempotentTests != 0)
  2520. {
  2521. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2522. }
  2523. if (MaybeTests != 0)
  2524. {
  2525. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2526. }
  2527. if (BroadcastTests != 0)
  2528. {
  2529. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2530. }
  2531. Status = UclntGetBuffer(&Caller);
  2532. if (Status)
  2533. {
  2534. ApiError("HelgaLpcSecurity","I_RpcGetBuffer",Status);
  2535. HelgaError();
  2536. return;
  2537. }
  2538. Status = UclntSendReceive(&Caller);
  2539. if (Status)
  2540. {
  2541. ApiError("HelgaLpcSecurity","I_RpcSendReceive",Status);
  2542. HelgaError();
  2543. return;
  2544. }
  2545. if (Caller.BufferLength != 0)
  2546. {
  2547. OtherError("HelgaLpcSecurity","BufferLength != 0");
  2548. HelgaError();
  2549. return;
  2550. }
  2551. Status = I_RpcFreeBuffer(&Caller);
  2552. if (Status)
  2553. {
  2554. ApiError("HelgaLpcSecurity","I_RpcFreeBuffer",Status);
  2555. HelgaError();
  2556. return;
  2557. }
  2558. }
  2559. void
  2560. HelgaAsyncLpcSecurity (
  2561. RPC_BINDING_HANDLE Binding
  2562. )
  2563. {
  2564. RPC_MESSAGE Caller;
  2565. RPC_ASYNC_STATE Async;
  2566. Caller.Handle = Binding;
  2567. Caller.BufferLength = 0;
  2568. Caller.ProcNum = 6 | HackForOldStubs | RPC_FLAGS_VALID_BIT;
  2569. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2570. Caller.RpcFlags = RPC_BUFFER_ASYNC;
  2571. if (IdempotentTests != 0)
  2572. {
  2573. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2574. }
  2575. if (MaybeTests != 0)
  2576. {
  2577. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2578. }
  2579. if (BroadcastTests != 0)
  2580. {
  2581. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2582. }
  2583. Status = UclntGetBuffer(&Caller);
  2584. if (Status)
  2585. {
  2586. ApiError("HelgaLpcSecurity","I_RpcGetBuffer",Status);
  2587. HelgaError();
  2588. return;
  2589. }
  2590. Async.u.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  2591. if (Async.u.hEvent == 0)
  2592. {
  2593. HelgaError();
  2594. return;
  2595. }
  2596. Async.NotificationType = RpcNotificationTypeEvent ;
  2597. Status = I_RpcAsyncSetHandle(&Caller, (PRPC_ASYNC_STATE) &Async);
  2598. if (Status)
  2599. {
  2600. HelgaError();
  2601. return;
  2602. }
  2603. Caller.RpcFlags = RPC_BUFFER_ASYNC;
  2604. Status = I_RpcSend(&Caller);
  2605. if (Status)
  2606. {
  2607. ApiError("HelgaLpcSecurity","I_RpcSend",Status);
  2608. HelgaError();
  2609. return;
  2610. }
  2611. if (Caller.BufferLength != 0)
  2612. {
  2613. OtherError("HelgaLpcSecurity","BufferLength != 0");
  2614. HelgaError();
  2615. return;
  2616. }
  2617. WaitForSingleObject(Async.u.hEvent, INFINITE);
  2618. Caller.RpcFlags = RPC_BUFFER_ASYNC;
  2619. Status = I_RpcReceive(&Caller, 0);
  2620. if (Status)
  2621. {
  2622. HelgaError();
  2623. return;
  2624. }
  2625. Status = I_RpcFreeBuffer(&Caller);
  2626. if (Status)
  2627. {
  2628. ApiError("HelgaLpcSecurity","I_RpcFreeBuffer",Status);
  2629. HelgaError();
  2630. return;
  2631. }
  2632. }
  2633. void
  2634. HelgaLpcSecurity (
  2635. RPC_BINDING_HANDLE Binding,
  2636. BOOL fAsync
  2637. )
  2638. {
  2639. if (fAsync)
  2640. {
  2641. HelgaAsyncLpcSecurity(Binding);
  2642. }
  2643. else
  2644. {
  2645. HelgaSyncLpcSecurity(Binding);
  2646. }
  2647. }
  2648. void
  2649. HelgaMustFail (
  2650. RPC_BINDING_HANDLE Binding // Specifies the binding to use in making the
  2651. // remote procedure call.
  2652. )
  2653. {
  2654. RPC_MESSAGE Caller;
  2655. Caller.Handle = Binding;
  2656. Caller.BufferLength = 0;
  2657. Caller.ProcNum = 0 | HackForOldStubs ;
  2658. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2659. Caller.RpcFlags = 0;
  2660. if (IdempotentTests != 0)
  2661. {
  2662. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2663. }
  2664. if (MaybeTests != 0)
  2665. {
  2666. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2667. }
  2668. if (BroadcastTests != 0)
  2669. {
  2670. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2671. }
  2672. Status = UclntGetBuffer(&Caller);
  2673. if (Status)
  2674. {
  2675. PrintToConsole("HelgaMustFail: I_RpcGetBuffer: %d\n", Status) ;
  2676. return;
  2677. }
  2678. Status = UclntSendReceive(&Caller);
  2679. if (Status)
  2680. {
  2681. PrintToConsole("HelgaMustFail: I_RpcSendReceive: %d\n", Status) ;
  2682. return;
  2683. }
  2684. PrintToConsole("HelgaMustFail: This call is supposed to fail\n") ;
  2685. HelgaError();
  2686. }
  2687. void
  2688. HelgaUsingContextHandle (
  2689. void PAPI * ContextHandle
  2690. )
  2691. {
  2692. RPC_MESSAGE Caller;
  2693. Caller.Handle = NDRCContextBinding(ContextHandle);
  2694. Caller.BufferLength = 0;
  2695. Caller.ProcNum = 0| HackForOldStubs ;
  2696. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2697. Caller.RpcFlags = 0;
  2698. if (IdempotentTests != 0)
  2699. {
  2700. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2701. }
  2702. if (MaybeTests != 0)
  2703. {
  2704. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2705. }
  2706. if (BroadcastTests != 0)
  2707. {
  2708. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2709. }
  2710. Status = UclntGetBuffer(&Caller);
  2711. if (Status)
  2712. {
  2713. ApiError("Helga","I_RpcGetBuffer",Status);
  2714. HelgaError();
  2715. return;
  2716. }
  2717. Status = UclntSendReceive(&Caller);
  2718. if (Status)
  2719. {
  2720. ApiError("Helga","I_RpcSendReceive",Status);
  2721. HelgaError();
  2722. return;
  2723. }
  2724. else
  2725. {
  2726. if (Caller.BufferLength != 0)
  2727. {
  2728. OtherError("Helga","BufferLength != 0");
  2729. HelgaError();
  2730. return;
  2731. }
  2732. Status = I_RpcFreeBuffer(&Caller);
  2733. if (Status)
  2734. {
  2735. ApiError("Helga","I_RpcFreeBuffer",Status);
  2736. HelgaError();
  2737. return;
  2738. }
  2739. }
  2740. }
  2741. // Send a packet of a requested size, the expected reply is 0 length
  2742. // The first long of the packet is the expected size on the server size
  2743. void
  2744. HelgaIN (
  2745. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  2746. // remote procedure call.
  2747. unsigned long BufferLength // Specifies the length of the buffer.
  2748. )
  2749. {
  2750. RPC_MESSAGE Caller;
  2751. Caller.Handle = Binding;
  2752. Caller.BufferLength = BufferLength;
  2753. Caller.ProcNum = 1 | HackForOldStubs ;
  2754. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2755. Caller.RpcFlags = 0;
  2756. if (IdempotentTests != 0)
  2757. {
  2758. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2759. }
  2760. if (MaybeTests != 0)
  2761. {
  2762. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2763. }
  2764. if (BroadcastTests != 0)
  2765. {
  2766. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2767. }
  2768. Status = UclntGetBuffer(&Caller);
  2769. if (Status)
  2770. {
  2771. ApiError("HelgaIN","I_RpcGetBuffer",Status);
  2772. HelgaError();
  2773. return;
  2774. }
  2775. InitializeBuffer(Caller.Buffer, BufferLength);
  2776. Status = UclntSendReceive(&Caller);
  2777. if (Status)
  2778. {
  2779. ApiError("HelgaIN","I_RpcSendReceive",Status);
  2780. HelgaError();
  2781. return;
  2782. }
  2783. else
  2784. {
  2785. if (Caller.BufferLength != 0)
  2786. {
  2787. OtherError("HelgaIN","BufferLength != 0");
  2788. HelgaError();
  2789. return;
  2790. }
  2791. Status = I_RpcFreeBuffer(&Caller);
  2792. if (Status)
  2793. {
  2794. ApiError("HelgaIN","I_RpcFreeBuffer",Status);
  2795. HelgaError();
  2796. return;
  2797. }
  2798. }
  2799. }
  2800. // Send a packet which contains a single long, which is the size
  2801. // of the packet the server will send in reply
  2802. void
  2803. HelgaOUT (
  2804. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  2805. // remote procedure call.
  2806. unsigned long BufferLength // Specifies the length of the buffer.
  2807. )
  2808. {
  2809. RPC_MESSAGE Caller;
  2810. unsigned long PAPI * Length;
  2811. Caller.Handle = Binding;
  2812. Caller.BufferLength = sizeof(unsigned long);
  2813. Caller.ProcNum = 2 | HackForOldStubs ;
  2814. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2815. Caller.RpcFlags = 0;
  2816. if (IdempotentTests != 0)
  2817. {
  2818. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2819. }
  2820. if (MaybeTests != 0)
  2821. {
  2822. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2823. }
  2824. if (BroadcastTests != 0)
  2825. {
  2826. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2827. }
  2828. Status = UclntGetBuffer(&Caller);
  2829. if (Status)
  2830. {
  2831. ApiError("HelgaOUT","I_RpcGetBuffer",Status);
  2832. HelgaError();
  2833. return;
  2834. }
  2835. Length = (unsigned long PAPI *) Caller.Buffer;
  2836. *Length = BufferLength;
  2837. swaplong(*Length) ;
  2838. Status = UclntSendReceive(&Caller);
  2839. if (Status)
  2840. {
  2841. ApiError("HelgaOUT","I_RpcSendReceive",Status);
  2842. HelgaError();
  2843. return;
  2844. }
  2845. else
  2846. {
  2847. Length = (unsigned long PAPI *) Caller.Buffer;
  2848. swaplong(*Length) ;
  2849. if (Caller.BufferLength != *Length)
  2850. {
  2851. OtherError("HelgaOUT","BufferLength != *Length");
  2852. HelgaError();
  2853. return;
  2854. }
  2855. if (CheckBuffer(Caller.Buffer, Caller.BufferLength) != 0)
  2856. {
  2857. OtherError("HelgaOUT","CheckBuffer Failed");
  2858. HelgaError();
  2859. return;
  2860. }
  2861. Status = I_RpcFreeBuffer(&Caller);
  2862. if (Status)
  2863. {
  2864. ApiError("HelgaOUT","I_RpcFreeBuffer",Status);
  2865. HelgaError();
  2866. return;
  2867. }
  2868. }
  2869. }
  2870. // Send a packet, which the first long is the size of the packet, whoes
  2871. // reply should be a packet of the same size
  2872. void
  2873. HelgaINOUT (
  2874. RPC_BINDING_HANDLE Binding, // Specifies the binding to use in making the
  2875. // remote procedure call.
  2876. unsigned long BufferLength // Specifies the length of the buffer.
  2877. )
  2878. {
  2879. RPC_MESSAGE Caller;
  2880. unsigned long PAPI * Length;
  2881. Caller.Handle = Binding;
  2882. Caller.BufferLength = BufferLength;
  2883. Caller.ProcNum = 3 | HackForOldStubs ;
  2884. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  2885. Caller.RpcFlags = 0;
  2886. if (IdempotentTests != 0)
  2887. {
  2888. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  2889. }
  2890. if (MaybeTests != 0)
  2891. {
  2892. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  2893. }
  2894. if (BroadcastTests != 0)
  2895. {
  2896. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  2897. }
  2898. Status = UclntGetBuffer(&Caller);
  2899. if (Status)
  2900. {
  2901. ApiError("HelgaINOUT","I_RpcGetBuffer",Status);
  2902. HelgaError();
  2903. return;
  2904. }
  2905. InitializeBuffer(Caller.Buffer, BufferLength);
  2906. Status = UclntSendReceive(&Caller);
  2907. if (Status)
  2908. {
  2909. ApiError("HelgaINOUT","I_RpcSendReceive",Status);
  2910. HelgaError();
  2911. return;
  2912. }
  2913. else
  2914. {
  2915. Length = (unsigned long PAPI *) Caller.Buffer;
  2916. swaplong(*Length) ;
  2917. if (Caller.BufferLength != *Length)
  2918. {
  2919. OtherError("HelgaINOUT","BufferLength != *Length");
  2920. HelgaError();
  2921. return;
  2922. }
  2923. if (CheckBuffer(Caller.Buffer, Caller.BufferLength) != 0)
  2924. {
  2925. OtherError("HelgaINOUT","CheckBuffer Failed");
  2926. HelgaError();
  2927. return;
  2928. }
  2929. Status = I_RpcFreeBuffer(&Caller);
  2930. if (Status)
  2931. {
  2932. ApiError("HelgaINOUT","I_RpcFreeBuffer",Status);
  2933. HelgaError();
  2934. return;
  2935. }
  2936. }
  2937. }
  2938. unsigned long
  2939. HelgaSizes[] =
  2940. {
  2941. 128, 256, 512, 1024, 1024*2, 1024*4, 1024*8,
  2942. 10000, 15000, 20000, 60000, 30000, 40000, 100000, 1024*82,
  2943. 0
  2944. };
  2945. #if 0
  2946. unsigned long
  2947. HelgaSizes[] =
  2948. {
  2949. 128, 128,
  2950. 0
  2951. };
  2952. #endif
  2953. void
  2954. TestHelgaInterface (
  2955. RPC_BINDING_HANDLE HelgaBinding,
  2956. unsigned long SizeUpperBound
  2957. )
  2958. /*++
  2959. Routine Description:
  2960. The various tests uses this routine to test the Helga interface in
  2961. different scenarios. We run each of the routines for a variety of
  2962. input and output buffer sizes. This is controlled by the array,
  2963. HelgaSizes.
  2964. Arguments:
  2965. HelgaBinding - Supplies the binding handle to use when calling each
  2966. of the Helga caller stubs.
  2967. --*/
  2968. {
  2969. int Count;
  2970. Helga(HelgaBinding);
  2971. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  2972. {
  2973. if (HelgaSizes[Count] <= SizeUpperBound)
  2974. {
  2975. HelgaIN(HelgaBinding,HelgaSizes[Count]);
  2976. }
  2977. }
  2978. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  2979. {
  2980. if (HelgaSizes[Count] <= SizeUpperBound)
  2981. {
  2982. HelgaOUT(HelgaBinding,HelgaSizes[Count]);
  2983. }
  2984. }
  2985. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  2986. {
  2987. if (HelgaSizes[Count] <= SizeUpperBound)
  2988. {
  2989. HelgaINOUT(HelgaBinding,HelgaSizes[Count]);
  2990. }
  2991. }
  2992. }
  2993. RPC_CLIENT_INTERFACE HelgaInterfaceWrongTransferSyntax =
  2994. {
  2995. sizeof(RPC_CLIENT_INTERFACE),
  2996. {{1,2,2,{3,3,3,3,3,3,3,3}},
  2997. {1,1}},
  2998. {{0xb4537da9, 0x3d03, 0x4f6b, {0xb5, 0x94, 0x52, 0xb2, 0x87, 0x4e, 0xe9, 0xd0}},
  2999. {1, 0}},
  3000. 0,
  3001. 0,
  3002. 0,
  3003. 0,
  3004. 0,
  3005. RPC_INTERFACE_HAS_PIPES
  3006. };
  3007. RPC_CLIENT_INTERFACE HelgaInterfaceWrongGuid =
  3008. {
  3009. sizeof(RPC_CLIENT_INTERFACE),
  3010. {{1,2,4,{3,3,3,3,3,3,3,3}},
  3011. {1,1}},
  3012. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  3013. {2,0}},
  3014. 0,
  3015. 0,
  3016. 0,
  3017. 0,
  3018. 0,
  3019. RPC_INTERFACE_HAS_PIPES
  3020. };
  3021. int
  3022. HelgaWrongInterfaceGuid (
  3023. RPC_BINDING_HANDLE Binding
  3024. )
  3025. /*++
  3026. Routine Description:
  3027. This routine makes a remote procedure call using the wrong interface
  3028. GUID (not supported by the server). The call must fail, otherwise,
  3029. there is a bug in the runtime. (Otherwise there are no bugs in the
  3030. runtime -- I wish.)
  3031. Arguments:
  3032. Binding - Supplies the binding handle to use in trying to make the
  3033. remote procedure call.
  3034. Return Value:
  3035. Zero will be returned in the call fails as expected. Otherwise,
  3036. non-zero will be returned.
  3037. --*/
  3038. {
  3039. RPC_MESSAGE Caller;
  3040. Caller.Handle = Binding;
  3041. Caller.BufferLength = 0;
  3042. Caller.ProcNum = 0 | HackForOldStubs ;
  3043. Caller.RpcInterfaceInformation = &HelgaInterfaceWrongGuid;
  3044. Caller.RpcFlags = 0;
  3045. if (IdempotentTests != 0)
  3046. {
  3047. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  3048. }
  3049. if (MaybeTests != 0)
  3050. {
  3051. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  3052. }
  3053. if (BroadcastTests != 0)
  3054. {
  3055. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  3056. }
  3057. Status = UclntGetBuffer(&Caller);
  3058. if (Status == RPC_S_UNKNOWN_IF)
  3059. return(0);
  3060. Status = UclntSendReceive(&Caller);
  3061. if (Status == RPC_S_UNKNOWN_IF)
  3062. return(0);
  3063. return(1);
  3064. }
  3065. int
  3066. HelgaWrongTransferSyntax (
  3067. RPC_BINDING_HANDLE Binding
  3068. )
  3069. /*++
  3070. Routine Description:
  3071. This routine makes a remote procedure call using the wrong transfer
  3072. syntax (not supported by the server). The call must fail, otherwise,
  3073. there is a bug in the runtime. (Otherwise there are no bugs in the
  3074. runtime -- I wish.)
  3075. Arguments:
  3076. Binding - Supplies the binding handle to use in trying to make the
  3077. remote procedure call.
  3078. Return Value:
  3079. Zero will be returned in the call fails as expected. Otherwise,
  3080. non-zero will be returned.
  3081. --*/
  3082. {
  3083. RPC_MESSAGE Caller;
  3084. Caller.Handle = Binding;
  3085. Caller.BufferLength = 0;
  3086. Caller.ProcNum = 0 | HackForOldStubs ;
  3087. Caller.RpcInterfaceInformation = &HelgaInterfaceWrongTransferSyntax;
  3088. Caller.RpcFlags = 0;
  3089. if (IdempotentTests != 0)
  3090. {
  3091. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  3092. }
  3093. if (MaybeTests != 0)
  3094. {
  3095. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  3096. }
  3097. if (BroadcastTests != 0)
  3098. {
  3099. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  3100. }
  3101. Status = UclntGetBuffer(&Caller);
  3102. if (Status == RPC_S_UNSUPPORTED_TRANS_SYN)
  3103. return(0);
  3104. Status = UclntSendReceive(&Caller);
  3105. if (Status == RPC_S_UNSUPPORTED_TRANS_SYN)
  3106. return(0);
  3107. return(1);
  3108. }
  3109. /* --------------------------------------------------------------------
  3110. Sylvia Interface
  3111. -------------------------------------------------------------------- */
  3112. extern RPC_DISPATCH_TABLE SylviaDispatchTable;
  3113. RPC_CLIENT_INTERFACE SylviaInterfaceInformation =
  3114. {
  3115. sizeof(RPC_CLIENT_INTERFACE),
  3116. {{3,2,2,{1,1,1,1,1,1,1,1}},
  3117. {1,1}},
  3118. {{0x8A885D04, 0x1CEB, 0x11C9, {0x9F, 0xE8, 0x08, 0x00, 0x2B, 0x10, 0x48, 0x60}},
  3119. {2, 0}},
  3120. &SylviaDispatchTable,
  3121. 0,
  3122. 0,
  3123. 0,
  3124. 0,
  3125. RPC_INTERFACE_HAS_PIPES
  3126. };
  3127. unsigned int
  3128. LocalSylviaCall (
  3129. unsigned /*long*/ char Depth,
  3130. unsigned /*long*/ char Breadth,
  3131. unsigned /*long*/ char Count
  3132. )
  3133. {
  3134. if (Depth > 0)
  3135. {
  3136. if (Depth == Breadth)
  3137. {
  3138. Count = (unsigned char) LocalSylviaCall(Depth-1,Breadth,Count);
  3139. }
  3140. else
  3141. Count = (unsigned char) LocalSylviaCall(Depth-1,Breadth,Count);
  3142. }
  3143. return(Count+1);
  3144. }
  3145. unsigned /*long*/ char // Specifies the new count of calls.
  3146. SylviaCall (
  3147. RPC_BINDING_HANDLE Binding,
  3148. unsigned /*long*/ char Depth, // Specifies the depth of recursion desired.
  3149. unsigned /*long*/ char Breadth, // Specifies the breadth desired.
  3150. unsigned /*long*/ char Count // Specifies the count of calls up to this point.
  3151. )
  3152. {
  3153. RPC_MESSAGE Caller;
  3154. unsigned /*long*/ char PAPI * plScan, ReturnValue ;
  3155. if ( NoCallBacksFlag != 0 )
  3156. {
  3157. return((unsigned char) LocalSylviaCall(Depth, Breadth, Count));
  3158. }
  3159. Caller.Handle = Binding;
  3160. Caller.BufferLength = sizeof(unsigned /*long*/ char) *4+10240;
  3161. Caller.ProcNum = 0 | HackForOldStubs ;
  3162. Caller.RpcInterfaceInformation = &SylviaInterfaceInformation;
  3163. Caller.RpcFlags = 0;
  3164. if (IdempotentTests != 0)
  3165. {
  3166. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  3167. }
  3168. if (MaybeTests != 0)
  3169. {
  3170. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  3171. }
  3172. if (BroadcastTests != 0)
  3173. {
  3174. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  3175. }
  3176. Status = UclntGetBuffer(&Caller);
  3177. if (Status)
  3178. {
  3179. ApiError("SylviaCall","I_RpcGetBuffer",Status);
  3180. SylviaError();
  3181. return(0);
  3182. }
  3183. plScan = (unsigned /*long*/ char PAPI *) Caller.Buffer;
  3184. plScan[0] = (unsigned char) Depth;
  3185. plScan[1] = (unsigned char) Breadth;
  3186. plScan[2] = (unsigned char) Count;
  3187. Status = UclntSendReceive(&Caller);
  3188. if (Status)
  3189. {
  3190. ApiError("SylviaCall","I_RpcSendReceive",Status);
  3191. SylviaError();
  3192. return(0);
  3193. }
  3194. plScan = (unsigned /*long*/ char PAPI *) Caller.Buffer;
  3195. ReturnValue = *plScan;
  3196. Status = I_RpcFreeBuffer(&Caller);
  3197. if (Status)
  3198. {
  3199. ApiError("SylviaCall","I_RpcFreeBuffer",Status);
  3200. SylviaError();
  3201. return(0);
  3202. }
  3203. return(ReturnValue);
  3204. }
  3205. RPC_BINDING_HANDLE SylviaBinding;
  3206. unsigned int
  3207. SylviaCallbackUserCode (
  3208. unsigned /*long*/ char Depth,
  3209. unsigned /*long*/ char Breadth,
  3210. unsigned /*long*/ char Count
  3211. ); // Prototype to keep the compiler happy because we recursively call
  3212. // this routine.
  3213. unsigned int
  3214. SylviaCallbackUserCode ( // The user code for SylviaCallback.
  3215. unsigned /*long*/ char Depth,
  3216. unsigned /*long*/ char Breadth,
  3217. unsigned /*long*/ char Count
  3218. )
  3219. {
  3220. if (Depth > 0)
  3221. {
  3222. if (Depth == Breadth)
  3223. {
  3224. Count = (unsigned char) SylviaCallbackUserCode(Depth-1,Breadth,Count);
  3225. }
  3226. else
  3227. Count = SylviaCall(SylviaBinding,Depth-1,Breadth,Count);
  3228. }
  3229. return(Count+1);
  3230. }
  3231. void __RPC_STUB
  3232. SylviaCallback (
  3233. PRPC_MESSAGE Callee
  3234. )
  3235. {
  3236. unsigned /*long*/ char ReturnValue, PAPI *plScan;
  3237. if ( Callee->ProcNum != 0 )
  3238. {
  3239. OtherError("SylviaCallback", "Callee->ProcNum != 0");
  3240. SylviaError();
  3241. }
  3242. if ( RpcpMemoryCompare(Callee->RpcInterfaceInformation,
  3243. &SylviaInterfaceInformation,
  3244. sizeof(SylviaInterfaceInformation)) != 0 )
  3245. {
  3246. OtherError("SylviaCallback",
  3247. "Callee->RpcInteraceInformation != &SylviaInterfaceInformation");
  3248. SylviaError();
  3249. }
  3250. if (Callee->BufferLength != sizeof(unsigned /*long*/ char)*4+10240)
  3251. {
  3252. OtherError("SylviaCallback",
  3253. "Callee->BufferLength != sizeof(unsigned int)*4");
  3254. SylviaError();
  3255. }
  3256. plScan = (unsigned /*long*/ char PAPI *) Callee->Buffer;
  3257. ReturnValue = (unsigned char) SylviaCallbackUserCode(plScan[0],plScan[1],plScan[2]);
  3258. Callee->BufferLength = sizeof(unsigned char /*long*/);
  3259. Status = I_RpcGetBuffer(Callee);
  3260. if (Status)
  3261. {
  3262. ApiError("SylviaCallback","I_RpcGetBuffer",Status);
  3263. SylviaError();
  3264. }
  3265. plScan = (unsigned /*long*/ char PAPI *) Callee->Buffer;
  3266. *plScan = ReturnValue;
  3267. }
  3268. RPC_DISPATCH_FUNCTION SylviaDispatchFunction[] = {SylviaCallback};
  3269. RPC_DISPATCH_TABLE SylviaDispatchTable =
  3270. {
  3271. 1, SylviaDispatchFunction
  3272. };
  3273. void
  3274. GenerateUuidValue (
  3275. IN unsigned short MagicNumber,
  3276. OUT UUID PAPI * Uuid
  3277. )
  3278. /*++
  3279. Routine Description:
  3280. This routine is used to generate a value for a uuid. The magic
  3281. number argument is used in mysterious and wonderful ways to
  3282. generate a uuid (which is not necessarily correct).
  3283. Arguments:
  3284. MagicNumber - Supplies a magic number which will be used to
  3285. generate a uuid.
  3286. Uuid - Returns the generated uuid.
  3287. --*/
  3288. {
  3289. Uuid->Data1= (unsigned long) MagicNumber * (unsigned long) MagicNumber ;
  3290. //swaplong(Uuid->Data1) ;
  3291. Uuid->Data2 = MagicNumber;
  3292. Uuid->Data3 = MagicNumber / 2;
  3293. //swapshort(Uuid->Data2) ;
  3294. //swapshort(Uuid->Data3) ;
  3295. Uuid->Data4[0] = MagicNumber % 256;
  3296. Uuid->Data4[1] = MagicNumber % 257;
  3297. Uuid->Data4[2] = MagicNumber % 258;
  3298. Uuid->Data4[3] = MagicNumber % 259;
  3299. Uuid->Data4[4] = MagicNumber % 260;
  3300. Uuid->Data4[5] = MagicNumber % 261;
  3301. Uuid->Data4[6] = MagicNumber % 262;
  3302. Uuid->Data4[7] = MagicNumber % 263;
  3303. }
  3304. int
  3305. CheckUuidValue (
  3306. IN unsigned short MagicNumber,
  3307. OUT UUID PAPI * Uuid
  3308. )
  3309. /*++
  3310. Routine Description:
  3311. This routine is used to check that a generated uuid value is correct.
  3312. Arguments:
  3313. MagicNumber - Supplies a magic number which will be used to
  3314. check a generated uuid.
  3315. Uuid - Supplies a generated uuid to check.
  3316. Return Value:
  3317. Zero will be returned if the uuid value is correct; otherwise, non-zero
  3318. will be returned.
  3319. --*/
  3320. {
  3321. // swaplong(Uuid->Data1) ;
  3322. if ( Uuid->Data1 != ((unsigned long) MagicNumber)
  3323. * ((unsigned long) MagicNumber))
  3324. return(1);
  3325. // swapshort(Uuid->Data2) ;
  3326. if ( Uuid->Data2 != MagicNumber )
  3327. return(1);
  3328. // swapshort(Uuid->Data3) ;
  3329. if ( Uuid->Data3 != MagicNumber / 2 )
  3330. return(1);
  3331. if ( Uuid->Data4[0] != MagicNumber % 256 )
  3332. return(1);
  3333. if ( Uuid->Data4[1] != MagicNumber % 257 )
  3334. return(1);
  3335. if ( Uuid->Data4[2] != MagicNumber % 258 )
  3336. return(1);
  3337. if ( Uuid->Data4[3] != MagicNumber % 259 )
  3338. return(1);
  3339. if ( Uuid->Data4[4] != MagicNumber % 260 )
  3340. return(1);
  3341. if ( Uuid->Data4[5] != MagicNumber % 261 )
  3342. return(1);
  3343. if ( Uuid->Data4[6] != MagicNumber % 262 )
  3344. return(1);
  3345. if ( Uuid->Data4[7] != MagicNumber % 263 )
  3346. return(1);
  3347. return(0);
  3348. }
  3349. static unsigned int TryFinallyCount;
  3350. static unsigned int TryFinallyFailed;
  3351. void
  3352. TheodoreTryFinally (
  3353. unsigned int count,
  3354. unsigned int raise
  3355. )
  3356. {
  3357. if (count == 0)
  3358. {
  3359. if (raise)
  3360. RpcRaiseException(437);
  3361. return;
  3362. }
  3363. RpcTryFinally
  3364. {
  3365. TryFinallyCount += 1;
  3366. TheodoreTryFinally(count-1,raise);
  3367. }
  3368. RpcFinally
  3369. {
  3370. TryFinallyCount -= 1;
  3371. if ( (RpcAbnormalTermination() && !raise)
  3372. || (!RpcAbnormalTermination() && raise))
  3373. TryFinallyFailed += 1;
  3374. }
  3375. RpcEndFinally
  3376. }
  3377. void
  3378. Theodore ( // This test checks the exception handling support provided
  3379. // by the RPC runtime. No remote procedure calls occur.
  3380. )
  3381. {
  3382. unsigned int TryFinallyPass = 0;
  3383. if ( NumberOfTestsRun++ )
  3384. {
  3385. PauseExecution(TestDelay);
  3386. }
  3387. PrintToConsole("Theodore : Verify exception handling support\n");
  3388. TryFinallyCount = 0;
  3389. TryFinallyFailed = 0;
  3390. RpcTryExcept
  3391. {
  3392. RpcTryExcept
  3393. {
  3394. TheodoreTryFinally(20,1);
  3395. }
  3396. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  3397. {
  3398. if ( (RpcExceptionCode() == 437)
  3399. && (TryFinallyCount == 0))
  3400. TryFinallyPass = 1;
  3401. }
  3402. RpcEndExcept
  3403. }
  3404. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  3405. {
  3406. PrintToConsole("Theodore : FAIL in RpcTryExcept (%u)\n",TryFinallyCount);
  3407. return;
  3408. }
  3409. RpcEndExcept
  3410. if (!TryFinallyPass)
  3411. {
  3412. PrintToConsole("Theodore : FAIL in RpcTryFinally\n");
  3413. return;
  3414. }
  3415. if (TryFinallyFailed)
  3416. {
  3417. PrintToConsole("Theodore : FAIL in RpcTryFinally\n");
  3418. return;
  3419. }
  3420. TryFinallyCount = 0;
  3421. TryFinallyFailed = 0;
  3422. RpcTryExcept
  3423. {
  3424. TheodoreTryFinally(20,0);
  3425. }
  3426. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  3427. {
  3428. PrintToConsole("Theodore : FAIL in RpcTryExcept\n");
  3429. return;
  3430. }
  3431. RpcEndExcept
  3432. if (TryFinallyFailed)
  3433. {
  3434. PrintToConsole("Theodore : FAIL in RpcTryFinally\n");
  3435. return;
  3436. }
  3437. PrintToConsole("Theodore : PASS\n");
  3438. }
  3439. void
  3440. Sebastian (
  3441. )
  3442. /*++
  3443. Routine Description:
  3444. We perform a build verification test in the routine. This test
  3445. checks for basic functionality of the runtime. It works with
  3446. Sigfried in usvr.exe. This particular test is dedicated to a cat.
  3447. --*/
  3448. {
  3449. RPC_BINDING_HANDLE HelgaBinding;
  3450. RPC_BINDING_HANDLE IsabelleBinding;
  3451. int HelgaCount;
  3452. Synchro(SIGFRIED) ;
  3453. if ( NumberOfTestsRun++ )
  3454. {
  3455. PauseExecution(TestDelay);
  3456. }
  3457. PrintToConsole("Sebastian : Verify Basic Client Functionality\n");
  3458. Status = GetBinding(SIGFRIED, &HelgaBinding);
  3459. if (Status)
  3460. {
  3461. ApiError("Sebastian","GetBinding",Status);
  3462. PrintToConsole("Sebastian : FAIL - Unable to Bind (Sigfried)\n");
  3463. return;
  3464. }
  3465. Status = GetBinding(SIGFRIED, &IsabelleBinding);
  3466. if (Status)
  3467. {
  3468. ApiError("Sebastian","GetBinding",Status);
  3469. PrintToConsole("Sebastian : FAIL - Unable to Bind (Sigfried)\n");
  3470. return;
  3471. }
  3472. for (HelgaCount = 0; HelgaCount < 100; HelgaCount++)
  3473. {
  3474. Status = RpcBindingFree(&HelgaBinding);
  3475. if (Status)
  3476. {
  3477. ApiError("Sebastian","RpcBindingFree",Status);
  3478. PrintToConsole("Sebastian : FAIL - Unable to Free Binding");
  3479. PrintToConsole(" (HelgaBinding)\n");
  3480. return;
  3481. }
  3482. Status = GetBinding(SIGFRIED, &HelgaBinding);
  3483. if (Status)
  3484. {
  3485. ApiError("Sebastian","GetBinding",Status);
  3486. PrintToConsole("Sebastian : FAIL - Unable to Bind (Sigfried)\n");
  3487. return;
  3488. }
  3489. Helga(HelgaBinding);
  3490. }
  3491. TestHelgaInterface(HelgaBinding, HelgaMaxSize);
  3492. IsabelleShutdown(IsabelleBinding);
  3493. if (HelgaErrors != 0)
  3494. {
  3495. PrintToConsole("Sebastian : FAIL - Error(s) in Helga Interface\n");
  3496. HelgaErrors = 0;
  3497. return;
  3498. }
  3499. Status = RpcBindingFree(&HelgaBinding);
  3500. if (Status)
  3501. {
  3502. ApiError("Sebastian","RpcBindingFree",Status);
  3503. PrintToConsole("Sebastian : FAIL - Unable to Free Binding");
  3504. PrintToConsole(" (HelgaBinding)\n");
  3505. return;
  3506. }
  3507. if (IsabelleErrors != 0)
  3508. {
  3509. PrintToConsole("Sebastian : FAIL - Error(s) in Isabelle Interface\n");
  3510. IsabelleErrors = 0;
  3511. return;
  3512. }
  3513. Status = RpcBindingFree(&IsabelleBinding);
  3514. if (Status)
  3515. {
  3516. ApiError("Sebastian","RpcBindingFree",Status);
  3517. PrintToConsole("Sebastian : FAIL - Unable to Free Binding");
  3518. PrintToConsole(" (IsabelleBinding)\n");
  3519. return;
  3520. }
  3521. PrintToConsole("Sebastian : PASS\n");
  3522. }
  3523. void
  3524. Pipe (
  3525. )
  3526. /*++
  3527. Routine Description:
  3528. We perform a build verification test in the routine. This test
  3529. checks for basic functionality of the runtime. It works with
  3530. Sigfried in usvr.exe. This particular test is dedicated to a cat.
  3531. --*/
  3532. {
  3533. RPC_BINDING_HANDLE IsabelleBinding;
  3534. pipe_t pipe ;
  3535. int state ;
  3536. int local_buf[BUFF_SIZE] ;
  3537. int i ;
  3538. long checksum ;
  3539. Synchro(SPIPE) ;
  3540. if ( NumberOfTestsRun++ )
  3541. {
  3542. PauseExecution(TestDelay);
  3543. }
  3544. PrintToConsole("PIPE : Verify Basic Client Functionality\n");
  3545. Status = GetBinding(SPIPE, &IsabelleBinding);
  3546. if (Status)
  3547. {
  3548. ApiError("PIPE","GetBinding",Status);
  3549. PrintToConsole("PIPE : FAIL - Unable to Bind (Sigfried)\n");
  3550. return;
  3551. }
  3552. pipe.Alloc = PipeAlloc ;
  3553. pipe.Pull = PipePull ;
  3554. pipe.Push = PipePush ;
  3555. pipe.state = (char PAPI *) &state ;
  3556. for (i = 0; i < BUFF_SIZE; i++)
  3557. {
  3558. local_buf[i] = i ;
  3559. }
  3560. state = NUM_CHUNKS ;
  3561. checksum = (long) (CHUNK_SIZE-1) * (long) CHUNK_SIZE /2 *
  3562. (long) NUM_CHUNKS ;
  3563. IsabellePipeIN(IsabelleBinding, &pipe,
  3564. CHUNK_SIZE, NUM_CHUNKS, checksum,
  3565. BUFF_SIZE * sizeof(int), (char PAPI *) local_buf) ;
  3566. if (IsabelleErrors != 0)
  3567. {
  3568. PrintToConsole("PIPE : FAIL - Error(s) in Isabelle Interface\n");
  3569. IsabelleErrors = 0;
  3570. return;
  3571. }
  3572. IsabellePipeOUT(IsabelleBinding, &pipe, CHUNK_SIZE) ;
  3573. if (IsabelleErrors != 0)
  3574. {
  3575. PrintToConsole("PIPE : FAIL - Error(s) in Isabelle Interface\n");
  3576. IsabelleErrors = 0;
  3577. return;
  3578. }
  3579. state = NUM_CHUNKS ;
  3580. IsabellePipeINOUT(IsabelleBinding, &pipe, CHUNK_SIZE, checksum) ;
  3581. if (IsabelleErrors != 0)
  3582. {
  3583. PrintToConsole("PIPE : FAIL - Error(s) in Isabelle Interface\n");
  3584. IsabelleErrors = 0;
  3585. return;
  3586. }
  3587. IsabelleShutdown(IsabelleBinding);
  3588. if (IsabelleErrors != 0)
  3589. {
  3590. PrintToConsole("PIPE : FAIL - Error(s) in Isabelle Interface\n");
  3591. IsabelleErrors = 0;
  3592. return;
  3593. }
  3594. Status = RpcBindingFree(&IsabelleBinding);
  3595. if (Status)
  3596. {
  3597. ApiError("PIPE","RpcBindingFree",Status);
  3598. PrintToConsole("PIPE : FAIL - Unable to Free Binding");
  3599. PrintToConsole(" (IsabelleBinding)\n");
  3600. return;
  3601. }
  3602. PrintToConsole("PIPE : PASS\n");
  3603. }
  3604. void
  3605. LpcSecurityHelper (
  3606. BOOL fAsync,
  3607. BOOL fDynamic
  3608. )
  3609. {
  3610. RPC_SECURITY_QOS QOS;
  3611. RPC_BINDING_HANDLE HelgaBinding;
  3612. Status = GetBinding(SIGFRIED, &HelgaBinding);
  3613. if (Status)
  3614. {
  3615. ApiError("LpcSecurity","GetBinding",Status);
  3616. PrintToConsole("LpcSecurity : FAIL - Unable to Bind (Sigfried)\n");
  3617. return;
  3618. }
  3619. QOS.Version = RPC_C_SECURITY_QOS_VERSION;
  3620. QOS.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
  3621. QOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
  3622. if (fDynamic)
  3623. {
  3624. QOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
  3625. }
  3626. else
  3627. {
  3628. QOS.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC;
  3629. }
  3630. Status = RpcBindingSetAuthInfoEx(
  3631. HelgaBinding,
  3632. RPC_STRING_LITERAL("ServerPrincipal"),
  3633. RPC_C_AUTHN_LEVEL_CONNECT,
  3634. 10,
  3635. NULL,
  3636. 0,
  3637. &QOS);
  3638. if (Status != RPC_S_OK)
  3639. {
  3640. ApiError("LpcSecurity","RpcBindingSetAuthInfoEx",Status);
  3641. goto Cleanup;
  3642. }
  3643. //
  3644. // Logon as local administrator and call again
  3645. //
  3646. HANDLE hToken;
  3647. if (LogonUser(
  3648. RPC_T("Administrator"),
  3649. NULL,
  3650. RPC_T(""),
  3651. LOGON32_LOGON_BATCH,
  3652. LOGON32_PROVIDER_DEFAULT,
  3653. &hToken) == 0)
  3654. {
  3655. ApiError("LpcSecurity","LogonUser",GetLastError());
  3656. goto Cleanup;
  3657. }
  3658. if (ImpersonateLoggedOnUser(hToken) == 0)
  3659. {
  3660. ApiError("LpcSecurity","LogonUser",GetLastError());
  3661. goto Cleanup;
  3662. }
  3663. if (fDynamic)
  3664. {
  3665. PrintToConsole("LpcSecurity: Expected: Administrator\n");
  3666. }
  3667. else
  3668. {
  3669. PrintToConsole("LpcSecurity: Expected: REDMOND\\mazharm\n");
  3670. }
  3671. HelgaLpcSecurity(HelgaBinding, fAsync) ;
  3672. RevertToSelf();
  3673. PrintToConsole("LpcSecurity: Expected: REDMOND\\mazharm\n");
  3674. HelgaLpcSecurity(HelgaBinding, fAsync) ;
  3675. CloseHandle(hToken);
  3676. Cleanup:
  3677. Status = RpcBindingFree(&HelgaBinding);
  3678. if (Status)
  3679. {
  3680. ApiError("LpcSecurity","RpcBindingFree",Status);
  3681. PrintToConsole("LpcSecurity : FAIL - Unable to Free Binding");
  3682. PrintToConsole(" (HelgaBinding)\n");
  3683. return;
  3684. }
  3685. }
  3686. void
  3687. LpcSecurityTwoHandles (
  3688. BOOL fAsync
  3689. )
  3690. {
  3691. RPC_SECURITY_QOS QOS;
  3692. RPC_BINDING_HANDLE HelgaBinding;
  3693. RPC_BINDING_HANDLE HelgaBinding1;
  3694. Status = GetBinding(SIGFRIED, &HelgaBinding);
  3695. if (Status)
  3696. {
  3697. ApiError("LpcSecurity","GetBinding",Status);
  3698. PrintToConsole("LpcSecurity : FAIL - Unable to Bind (Sigfried)\n");
  3699. return;
  3700. }
  3701. Status = GetBinding(SIGFRIED, &HelgaBinding1);
  3702. if (Status)
  3703. {
  3704. ApiError("LpcSecurity","GetBinding",Status);
  3705. PrintToConsole("LpcSecurity : FAIL - Unable to Bind (Sigfried)\n");
  3706. return;
  3707. }
  3708. QOS.Version = RPC_C_SECURITY_QOS_VERSION;
  3709. QOS.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
  3710. QOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
  3711. QOS.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC;
  3712. Status = RpcBindingSetAuthInfoExA(
  3713. HelgaBinding,
  3714. (unsigned char *) "ServerPrincipal",
  3715. RPC_C_AUTHN_LEVEL_CONNECT,
  3716. 10,
  3717. NULL,
  3718. 0,
  3719. &QOS);
  3720. if (Status != RPC_S_OK)
  3721. {
  3722. ApiError("LpcSecurity","RpcBindingSetAuthInfoEx",Status);
  3723. goto Cleanup;
  3724. }
  3725. //
  3726. // Logon as local administrator and call again
  3727. //
  3728. HANDLE hToken;
  3729. if (LogonUserA(
  3730. "Administrator",
  3731. NULL,
  3732. "",
  3733. LOGON32_LOGON_BATCH,
  3734. LOGON32_PROVIDER_DEFAULT,
  3735. &hToken) == 0)
  3736. {
  3737. ApiError("LpcSecurity","LogonUser",GetLastError());
  3738. goto Cleanup;
  3739. }
  3740. if (ImpersonateLoggedOnUser(hToken) == 0)
  3741. {
  3742. ApiError("LpcSecurity","LogonUser",GetLastError());
  3743. goto Cleanup;
  3744. }
  3745. QOS.Version = RPC_C_SECURITY_QOS_VERSION;
  3746. QOS.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
  3747. QOS.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT;
  3748. QOS.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC;
  3749. Status = RpcBindingSetAuthInfoExA(
  3750. HelgaBinding1,
  3751. (unsigned char *) "ServerPrincipal",
  3752. RPC_C_AUTHN_LEVEL_CONNECT,
  3753. 10,
  3754. NULL,
  3755. 0,
  3756. &QOS);
  3757. if (Status != RPC_S_OK)
  3758. {
  3759. ApiError("LpcSecurity","RpcBindingSetAuthInfoEx",Status);
  3760. goto Cleanup;
  3761. }
  3762. PrintToConsole("LpcSecurity: Expected: REDMOND\\mazharm\n");
  3763. HelgaLpcSecurity(HelgaBinding, fAsync);
  3764. PrintToConsole("LpcSecurity: Expected: Administrator\n");
  3765. HelgaLpcSecurity(HelgaBinding1, fAsync);
  3766. RevertToSelf();
  3767. PrintToConsole("LpcSecurity: Expected: REDMOND\\mazharm\n");
  3768. HelgaLpcSecurity(HelgaBinding, fAsync) ;
  3769. PrintToConsole("LpcSecurity: Expected: Administrator\n");
  3770. HelgaLpcSecurity(HelgaBinding1, fAsync);
  3771. CloseHandle(hToken);
  3772. Cleanup:
  3773. Status = RpcBindingFree(&HelgaBinding);
  3774. if (Status)
  3775. {
  3776. ApiError("LpcSecurity","RpcBindingFree",Status);
  3777. PrintToConsole("LpcSecurity : FAIL - Unable to Free Binding");
  3778. PrintToConsole(" (HelgaBinding)\n");
  3779. return;
  3780. }
  3781. Status = RpcBindingFree(&HelgaBinding1);
  3782. if (Status)
  3783. {
  3784. ApiError("LpcSecurity","RpcBindingFree",Status);
  3785. PrintToConsole("LpcSecurity : FAIL - Unable to Free Binding");
  3786. PrintToConsole(" (HelgaBinding)\n");
  3787. return;
  3788. }
  3789. }
  3790. void
  3791. LpcSecurity (
  3792. )
  3793. /*++
  3794. Routine Description:
  3795. We perform a build verification test in the routine. This test
  3796. checks for basic functionality of the runtime. It works with
  3797. Sigfried in usvr.exe. This particular test is dedicated to a cat.
  3798. --*/
  3799. {
  3800. RPC_BINDING_HANDLE IsabelleBinding;
  3801. int HelgaCount;
  3802. Synchro(SIGFRIED) ;
  3803. if ( NumberOfTestsRun++ )
  3804. {
  3805. PauseExecution(TestDelay);
  3806. }
  3807. PrintToConsole("LpcSecurity : Verify Basic Client Functionality\n");
  3808. Status = GetBinding(SIGFRIED, &IsabelleBinding);
  3809. if (Status)
  3810. {
  3811. ApiError("LpcSecurity","GetBinding",Status);
  3812. PrintToConsole("LpcSecurity : FAIL - Unable to Bind (Sigfried)\n");
  3813. return;
  3814. }
  3815. #if 0
  3816. //
  3817. // Sync call with static
  3818. //
  3819. PrintToConsole("LpcSecurity: Sync call with static tracking\n");
  3820. LpcSecurityHelper(0, 0);
  3821. #endif
  3822. //
  3823. // Sync call with dynamic binding
  3824. //
  3825. PrintToConsole("LpcSecurity: Sync call with dynamic tracking\n");
  3826. LpcSecurityHelper(0, 1);
  3827. #if 0
  3828. //
  3829. // Async call with static binding
  3830. //
  3831. PrintToConsole("LpcSecurity: Async call with static tracking \n");
  3832. LpcSecurityHelper(1, 0);
  3833. #endif
  3834. //
  3835. // Async call with dynamic binding
  3836. //
  3837. PrintToConsole("LpcSecurity: Async call with dynamic tracking \n");
  3838. LpcSecurityHelper(1, 1);
  3839. #if 0
  3840. //
  3841. // Async call with static,using two handles
  3842. //
  3843. LpcSecurityTwoHandles(1);
  3844. //
  3845. // Sync call with static using two handle
  3846. //
  3847. LpcSecurityTwoHandles(0);
  3848. #endif
  3849. IsabelleShutdown(IsabelleBinding);
  3850. if (HelgaErrors != 0)
  3851. {
  3852. PrintToConsole("LpcSecurity : FAIL - Error(s) in Helga Interface\n");
  3853. HelgaErrors = 0;
  3854. return;
  3855. }
  3856. if (IsabelleErrors != 0)
  3857. {
  3858. PrintToConsole("LpcSecurity : FAIL - Error(s) in Isabelle Interface\n");
  3859. IsabelleErrors = 0;
  3860. return;
  3861. }
  3862. Status = RpcBindingFree(&IsabelleBinding);
  3863. if (Status)
  3864. {
  3865. ApiError("LpcSecurity","RpcBindingFree",Status);
  3866. PrintToConsole("LpcSecurity : FAIL - Unable to Free Binding");
  3867. PrintToConsole(" (IsabelleBinding)\n");
  3868. return;
  3869. }
  3870. PrintToConsole("LpcSecurity : PASS\n");
  3871. }
  3872. RPC_STATUS
  3873. UclntGetBufferWithObject (
  3874. IN OUT PRPC_MESSAGE RpcMessage,
  3875. IN UUID *ObjectUuid
  3876. )
  3877. /*++
  3878. Routine Description:
  3879. This routine takes care of retrying to getting a buffer.
  3880. Arguments:
  3881. RpcMessage - Supplies and returns the message for I_RpcGetBuffer.
  3882. Return Value:
  3883. The result of I_RpcGetBuffer will be returned.
  3884. --*/
  3885. {
  3886. unsigned int RetryCount;
  3887. for (RetryCount = 0; RetryCount < RETRYCOUNT; RetryCount++)
  3888. {
  3889. Status = I_RpcGetBufferWithObject(RpcMessage, ObjectUuid);
  3890. if ( (Status != RPC_S_SERVER_TOO_BUSY)
  3891. && (Status != RPC_S_CALL_FAILED_DNE))
  3892. break;
  3893. PauseExecution(RETRYDELAY);
  3894. }
  3895. return(Status);
  3896. }
  3897. void
  3898. HelgaObjectUuids (
  3899. RPC_BINDING_HANDLE HelgaBinding,
  3900. UUID *ObjectUuid
  3901. )
  3902. {
  3903. RPC_MESSAGE Caller;
  3904. Caller.Handle = HelgaBinding;
  3905. Caller.BufferLength = sizeof(BOOL)+sizeof(UUID);
  3906. Caller.ProcNum = 8 | HackForOldStubs ;
  3907. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  3908. Caller.RpcFlags = 0;
  3909. if (IdempotentTests != 0)
  3910. {
  3911. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  3912. }
  3913. if (MaybeTests != 0)
  3914. {
  3915. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  3916. }
  3917. if (BroadcastTests != 0)
  3918. {
  3919. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  3920. }
  3921. if (ObjectUuid)
  3922. {
  3923. Status = UclntGetBufferWithObject(&Caller, ObjectUuid);
  3924. }
  3925. else
  3926. {
  3927. Status = UclntGetBuffer(&Caller);
  3928. }
  3929. if (Status)
  3930. {
  3931. ApiError("Helga","I_RpcGetBuffer",Status);
  3932. HelgaError();
  3933. return;
  3934. }
  3935. char *Ptr = (char *) Caller.Buffer;
  3936. if (ObjectUuid)
  3937. {
  3938. *((LONG *) Ptr) = 1;
  3939. Ptr += sizeof(BOOL);
  3940. RpcpMemoryCopy(Ptr, ObjectUuid, sizeof(UUID));
  3941. }
  3942. else
  3943. {
  3944. *((LONG *) Ptr) = 0;
  3945. }
  3946. Status = UclntSendReceive(&Caller);
  3947. if (Status)
  3948. {
  3949. ApiError("Helga","I_RpcSendReceive",Status);
  3950. HelgaError();
  3951. return;
  3952. }
  3953. if (Caller.BufferLength != 0)
  3954. {
  3955. OtherError("Helga","BufferLength != 0");
  3956. HelgaError();
  3957. return;
  3958. }
  3959. Status = I_RpcFreeBuffer(&Caller);
  3960. if (Status)
  3961. {
  3962. ApiError("Helga","I_RpcFreeBuffer",Status);
  3963. HelgaError();
  3964. return;
  3965. }
  3966. }
  3967. void
  3968. TestObjectUuids (
  3969. )
  3970. /*++
  3971. Routine Description:
  3972. We perform a build verification test in the routine. This test
  3973. checks for basic functionality of the runtime. It works with
  3974. Sigfried in usvr.exe. This particular test is dedicated to a cat.
  3975. --*/
  3976. {
  3977. RPC_BINDING_HANDLE HelgaBinding;
  3978. RPC_BINDING_HANDLE IsabelleBinding;
  3979. int HelgaCount;
  3980. Synchro(SIGFRIED) ;
  3981. if ( NumberOfTestsRun++ )
  3982. {
  3983. PauseExecution(TestDelay);
  3984. }
  3985. PrintToConsole("TestObjectUuids : Verify Basic Client Functionality\n");
  3986. Status = GetBinding(SIGFRIED, &HelgaBinding);
  3987. if (Status)
  3988. {
  3989. ApiError("TestObjectUuids","GetBinding",Status);
  3990. PrintToConsole("TestObjectUuids : FAIL - Unable to Bind (Sigfried)\n");
  3991. return;
  3992. }
  3993. Status = GetBinding(SIGFRIED, &IsabelleBinding);
  3994. if (Status)
  3995. {
  3996. ApiError("TestObjectUuids","GetBinding",Status);
  3997. PrintToConsole("TestObjectUuids : FAIL - Unable to Bind (Sigfried)\n");
  3998. return;
  3999. }
  4000. HelgaObjectUuids(HelgaBinding, 0);
  4001. UUID MyUuid;
  4002. RpcpMemorySet(&MyUuid, 'M', sizeof(UUID));
  4003. HelgaObjectUuids(HelgaBinding, &MyUuid);
  4004. HelgaObjectUuids(HelgaBinding, 0);
  4005. IsabelleShutdown(IsabelleBinding);
  4006. if (HelgaErrors != 0)
  4007. {
  4008. PrintToConsole("TestObjectUuids : FAIL - Error(s) in Helga Interface\n");
  4009. HelgaErrors = 0;
  4010. return;
  4011. }
  4012. Status = RpcBindingFree(&HelgaBinding);
  4013. if (Status)
  4014. {
  4015. ApiError("TestObjectUuids","RpcBindingFree",Status);
  4016. PrintToConsole("TestObjectUuids : FAIL - Unable to Free Binding");
  4017. PrintToConsole(" (HelgaBinding)\n");
  4018. return;
  4019. }
  4020. if (IsabelleErrors != 0)
  4021. {
  4022. PrintToConsole("TestObjectUuids : FAIL - Error(s) in Isabelle Interface\n");
  4023. IsabelleErrors = 0;
  4024. return;
  4025. }
  4026. Status = RpcBindingFree(&IsabelleBinding);
  4027. if (Status)
  4028. {
  4029. ApiError("TestObjectUuids","RpcBindingFree",Status);
  4030. PrintToConsole("TestObjectUuids : FAIL - Unable to Free Binding");
  4031. PrintToConsole(" (IsabelleBinding)\n");
  4032. return;
  4033. }
  4034. PrintToConsole("TestObjectUuids : PASS\n");
  4035. }
  4036. void
  4037. HelgaConnId (
  4038. RPC_BINDING_HANDLE HelgaBinding,
  4039. BOOL fNewConnExpected
  4040. )
  4041. {
  4042. RPC_MESSAGE Caller;
  4043. Caller.Handle = HelgaBinding;
  4044. Caller.BufferLength = sizeof(BOOL)+sizeof(UUID);
  4045. Caller.ProcNum = 9 | HackForOldStubs ;
  4046. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation;
  4047. Caller.RpcFlags = 0;
  4048. if (IdempotentTests != 0)
  4049. {
  4050. Caller.RpcFlags |= RPC_NCA_FLAGS_IDEMPOTENT;
  4051. }
  4052. if (MaybeTests != 0)
  4053. {
  4054. Caller.RpcFlags |= RPC_NCA_FLAGS_MAYBE;
  4055. }
  4056. if (BroadcastTests != 0)
  4057. {
  4058. Caller.RpcFlags |= RPC_NCA_FLAGS_BROADCAST;
  4059. }
  4060. Status = UclntGetBuffer(&Caller);
  4061. if (Status)
  4062. {
  4063. ApiError("Helga","I_RpcGetBuffer",Status);
  4064. HelgaError();
  4065. return;
  4066. }
  4067. char *Ptr = (char *) Caller.Buffer;
  4068. *((BOOL *) Ptr) = fNewConnExpected;
  4069. Status = UclntSendReceive(&Caller);
  4070. if (Status)
  4071. {
  4072. ApiError("Helga","I_RpcSendReceive",Status);
  4073. HelgaError();
  4074. return;
  4075. }
  4076. if (Caller.BufferLength != 0)
  4077. {
  4078. OtherError("Helga","BufferLength != 0");
  4079. HelgaError();
  4080. return;
  4081. }
  4082. Status = I_RpcFreeBuffer(&Caller);
  4083. if (Status)
  4084. {
  4085. ApiError("Helga","I_RpcFreeBuffer",Status);
  4086. HelgaError();
  4087. return;
  4088. }
  4089. }
  4090. void
  4091. TestConnId (
  4092. )
  4093. /*++
  4094. Routine Description:
  4095. We perform a build verification test in the routine. This test
  4096. checks for basic functionality of the runtime. It works with
  4097. Sigfried in usvr.exe. This particular test is dedicated to a cat.
  4098. --*/
  4099. {
  4100. RPC_BINDING_HANDLE HelgaBinding;
  4101. RPC_BINDING_HANDLE IsabelleBinding;
  4102. int HelgaCount;
  4103. Synchro(SIGFRIED) ;
  4104. if ( NumberOfTestsRun++ )
  4105. {
  4106. PauseExecution(TestDelay);
  4107. }
  4108. PrintToConsole("TestConnId : Verify Basic Client Functionality\n");
  4109. Status = GetBinding(SIGFRIED, &HelgaBinding);
  4110. if (Status)
  4111. {
  4112. ApiError("TestConnId","GetBinding",Status);
  4113. PrintToConsole("TestConnId : FAIL - Unable to Bind (Sigfried)\n");
  4114. return;
  4115. }
  4116. Status = GetBinding(SIGFRIED, &IsabelleBinding);
  4117. if (Status)
  4118. {
  4119. ApiError("TestConnId","GetBinding",Status);
  4120. PrintToConsole("TestConnId : FAIL - Unable to Bind (Sigfried)\n");
  4121. return;
  4122. }
  4123. HelgaConnId(HelgaBinding, 1);
  4124. HelgaConnId(HelgaBinding, 0);
  4125. RpcBindingFree(&HelgaBinding);
  4126. Status = GetBinding(SIGFRIED, &HelgaBinding);
  4127. if (Status)
  4128. {
  4129. ApiError("TestConnId","GetBinding",Status);
  4130. PrintToConsole("TestConnId : FAIL - Unable to Bind (Sigfried)\n");
  4131. return;
  4132. }
  4133. HelgaConnId(HelgaBinding, 1);
  4134. HelgaConnId(HelgaBinding, 0);
  4135. IsabelleShutdown(IsabelleBinding);
  4136. if (HelgaErrors != 0)
  4137. {
  4138. PrintToConsole("TestConnId : FAIL - Error(s) in Helga Interface\n");
  4139. HelgaErrors = 0;
  4140. return;
  4141. }
  4142. Status = RpcBindingFree(&HelgaBinding);
  4143. if (Status)
  4144. {
  4145. ApiError("TestConnId","RpcBindingFree",Status);
  4146. PrintToConsole("TestConnId : FAIL - Unable to Free Binding");
  4147. PrintToConsole(" (HelgaBinding)\n");
  4148. return;
  4149. }
  4150. if (IsabelleErrors != 0)
  4151. {
  4152. PrintToConsole("TestConnId : FAIL - Error(s) in Isabelle Interface\n");
  4153. IsabelleErrors = 0;
  4154. return;
  4155. }
  4156. Status = RpcBindingFree(&IsabelleBinding);
  4157. if (Status)
  4158. {
  4159. ApiError("TestConnId","RpcBindingFree",Status);
  4160. PrintToConsole("TestConnId : FAIL - Unable to Free Binding");
  4161. PrintToConsole(" (IsabelleBinding)\n");
  4162. return;
  4163. }
  4164. PrintToConsole("TestConnId : PASS\n");
  4165. }
  4166. void
  4167. Hybrid (
  4168. )
  4169. /*++
  4170. Routine Description:
  4171. We perform a build verification test in the routine. This test
  4172. checks for basic functionality of the runtime. It works with
  4173. Hybrid in usvr.exe. This particular test is dedicated to a cat.
  4174. --*/
  4175. {
  4176. RPC_BINDING_HANDLE HelgaBinding;
  4177. RPC_BINDING_HANDLE IsabelleBinding;
  4178. int HelgaCount;
  4179. Synchro(SIGFRIED) ;
  4180. if ( NumberOfTestsRun++ )
  4181. {
  4182. PauseExecution(TestDelay);
  4183. }
  4184. PrintToConsole("Hybrid : Verify Basic Client Functionality\n");
  4185. Status = GetBinding(SIGFRIED, &HelgaBinding);
  4186. if (Status)
  4187. {
  4188. ApiError("Hybrid","GetBinding",Status);
  4189. PrintToConsole("Hybrid : FAIL - Unable to Bind (Sigfried)\n");
  4190. return;
  4191. }
  4192. Status = GetBinding(SIGFRIED, &IsabelleBinding);
  4193. if (Status)
  4194. {
  4195. ApiError("Hybrid","GetBinding",Status);
  4196. PrintToConsole("Hybrid : FAIL - Unable to Bind (Sigfried)\n");
  4197. return;
  4198. }
  4199. for (HelgaCount = 0; HelgaCount < 30; HelgaCount++)
  4200. {
  4201. Helga(HelgaBinding);
  4202. IsabelleUnregisterInterfaces(IsabelleBinding) ;
  4203. HelgaMustFail(HelgaBinding) ;
  4204. IsabelleRegisterInterfaces(IsabelleBinding) ;
  4205. }
  4206. for (HelgaCount = 0; HelgaCount < 5; HelgaCount++)
  4207. {
  4208. TestHelgaInterface(HelgaBinding, HelgaMaxSize);
  4209. IsabelleUnregisterInterfaces(IsabelleBinding) ;
  4210. HelgaMustFail(HelgaBinding) ;
  4211. IsabelleRegisterInterfaces(IsabelleBinding) ;
  4212. }
  4213. IsabelleShutdown(IsabelleBinding);
  4214. if (HelgaErrors != 0)
  4215. {
  4216. PrintToConsole("Hybrid : FAIL - Error(s) in Helga Interface\n");
  4217. HelgaErrors = 0;
  4218. return;
  4219. }
  4220. Status = RpcBindingFree(&HelgaBinding);
  4221. if (Status)
  4222. {
  4223. ApiError("Hybrid","RpcBindingFree",Status);
  4224. PrintToConsole("Hybrid : FAIL - Unable to Free Binding");
  4225. PrintToConsole(" (HelgaBinding)\n");
  4226. return;
  4227. }
  4228. if (IsabelleErrors != 0)
  4229. {
  4230. PrintToConsole("Hybrid : FAIL - Error(s) in Isabelle Interface\n");
  4231. IsabelleErrors = 0;
  4232. return;
  4233. }
  4234. Status = RpcBindingFree(&IsabelleBinding);
  4235. if (Status)
  4236. {
  4237. ApiError("Hybrid","RpcBindingFree",Status);
  4238. PrintToConsole("Hybrid : FAIL - Unable to Free Binding");
  4239. PrintToConsole(" (IsabelleBinding)\n");
  4240. return;
  4241. }
  4242. PrintToConsole("Hybrid : PASS\n");
  4243. }
  4244. void
  4245. Graham (
  4246. )
  4247. /*++
  4248. Routine Description:
  4249. We perform a build verification test in the routine. This test
  4250. checks for basic functionality of the runtime. It works with
  4251. Grant in usvr.exe. This particular test is dedicated to a cat.
  4252. --*/
  4253. {
  4254. RPC_BINDING_HANDLE HelgaBinding;
  4255. RPC_BINDING_HANDLE IsabelleBinding;
  4256. UUID ObjectUuid;
  4257. unsigned short MagicValue;
  4258. unsigned int Count;
  4259. Synchro(GRANT) ;
  4260. if ( NumberOfTestsRun++ )
  4261. {
  4262. PauseExecution(TestDelay);
  4263. }
  4264. PrintToConsole("Graham : Verify Basic Client Functionality\n");
  4265. Status = GetBinding(GRANT, &HelgaBinding);
  4266. if (Status)
  4267. {
  4268. ApiError("Graham","GetBinding",Status);
  4269. PrintToConsole("Graham : FAIL - Unable to Bind (Grant)\n");
  4270. return;
  4271. }
  4272. Status = GetBinding(GRANT, &IsabelleBinding);
  4273. if (Status)
  4274. {
  4275. ApiError("Graham","GetBinding",Status);
  4276. PrintToConsole("Graham : FAIL - Unable to Bind (Grant)\n");
  4277. return;
  4278. }
  4279. MagicValue = 106;
  4280. GenerateUuidValue(MagicValue, &ObjectUuid);
  4281. Status = RpcBindingSetObject(HelgaBinding, &ObjectUuid);
  4282. if (Status)
  4283. {
  4284. ApiError("Graham", "RpcBindingSetObject", Status);
  4285. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  4286. return;
  4287. }
  4288. MagicValue += 1;
  4289. Helga(HelgaBinding);
  4290. GenerateUuidValue(MagicValue, &ObjectUuid);
  4291. Status = RpcBindingSetObject(HelgaBinding, &ObjectUuid);
  4292. if (Status)
  4293. {
  4294. ApiError("Graham", "RpcBindingSetObject", Status);
  4295. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  4296. return;
  4297. }
  4298. MagicValue += 1;
  4299. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  4300. {
  4301. if (HelgaSizes[Count] > HelgaMaxSize)
  4302. continue;
  4303. HelgaIN(HelgaBinding,HelgaSizes[Count]);
  4304. GenerateUuidValue(MagicValue, &ObjectUuid);
  4305. Status = RpcBindingSetObject(HelgaBinding, &ObjectUuid);
  4306. if (Status)
  4307. {
  4308. ApiError("Graham", "RpcBindingSetObject", Status);
  4309. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  4310. return;
  4311. }
  4312. MagicValue += 1;
  4313. }
  4314. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  4315. {
  4316. if (HelgaSizes[Count] > HelgaMaxSize)
  4317. continue;
  4318. HelgaOUT(HelgaBinding,HelgaSizes[Count]);
  4319. GenerateUuidValue(MagicValue, &ObjectUuid);
  4320. Status = RpcBindingSetObject(HelgaBinding, &ObjectUuid);
  4321. if (Status)
  4322. {
  4323. ApiError("Graham", "RpcBindingSetObject", Status);
  4324. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  4325. return;
  4326. }
  4327. MagicValue += 1;
  4328. }
  4329. for (Count = 0; HelgaSizes[Count] != 0; Count++)
  4330. {
  4331. if (HelgaSizes[Count] > HelgaMaxSize)
  4332. continue;
  4333. HelgaINOUT(HelgaBinding,HelgaSizes[Count]);
  4334. GenerateUuidValue(MagicValue, &ObjectUuid);
  4335. Status = RpcBindingSetObject(HelgaBinding, &ObjectUuid);
  4336. if (Status)
  4337. {
  4338. ApiError("Graham", "RpcBindingSetObject", Status);
  4339. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  4340. return;
  4341. }
  4342. MagicValue += 1;
  4343. }
  4344. IsabelleShutdown(IsabelleBinding);
  4345. if (HelgaErrors != 0)
  4346. {
  4347. PrintToConsole("Graham : FAIL - Error(s) in Helga Interface\n");
  4348. HelgaErrors = 0;
  4349. return;
  4350. }
  4351. Status = RpcBindingFree(&HelgaBinding);
  4352. if (Status)
  4353. {
  4354. ApiError("Graham","RpcBindingFree",Status);
  4355. PrintToConsole("Graham : FAIL - Unable to Free Binding");
  4356. PrintToConsole(" (HelgaBinding)\n");
  4357. return;
  4358. }
  4359. if (IsabelleErrors != 0)
  4360. {
  4361. PrintToConsole("Graham : FAIL - Error(s) in Isabelle Interface\n");
  4362. IsabelleErrors = 0;
  4363. return;
  4364. }
  4365. Status = RpcBindingFree(&IsabelleBinding);
  4366. if (Status)
  4367. {
  4368. ApiError("Graham","RpcBindingFree",Status);
  4369. PrintToConsole("Graham : FAIL - Unable to Free Binding");
  4370. PrintToConsole(" (IsabelleBinding)\n");
  4371. return;
  4372. }
  4373. PrintToConsole("Graham : PASS\n");
  4374. }
  4375. void
  4376. Edward (
  4377. )
  4378. /*++
  4379. Routine Description:
  4380. This routine verifies server support of multiple addresses and
  4381. interfaces, as well as callbacks. In addition, we test binding
  4382. here as well. This test works with Elliot in usvr.exe.
  4383. --*/
  4384. {
  4385. RPC_BINDING_HANDLE IsabelleBinding;
  4386. RPC_BINDING_HANDLE SylviaMinimize;
  4387. RPC_BINDING_HANDLE SylviaMaximize;
  4388. RPC_BINDING_HANDLE HelgaMinimize;
  4389. RPC_BINDING_HANDLE HelgaMaximize;
  4390. RPC_BINDING_HANDLE EdwardMinimize;
  4391. RPC_BINDING_HANDLE EdwardNormal;
  4392. RPC_BINDING_HANDLE EdwardMaximize;
  4393. Synchro(ELLIOTMINIMIZE) ;
  4394. if ( NumberOfTestsRun++ )
  4395. {
  4396. PauseExecution(TestDelay);
  4397. }
  4398. PrintToConsole("Edward : Verify Callbacks, Multiple Addresses");
  4399. PrintToConsole(", and Multiple Interfaces\n");
  4400. Status = GetBinding(ELLIOTMINIMIZE, &SylviaMinimize);
  4401. if (Status)
  4402. {
  4403. ApiError("Edward","GetBinding",Status);
  4404. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Minimize)\n");
  4405. return;
  4406. }
  4407. Status = GetBinding(ELLIOTMAXIMIZE, &SylviaMaximize);
  4408. if (Status)
  4409. {
  4410. ApiError("Edward","GetBinding",Status);
  4411. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Maximize)\n");
  4412. return;
  4413. }
  4414. Status = GetBinding(ELLIOTMINIMIZE, &HelgaMinimize);
  4415. if (Status)
  4416. {
  4417. ApiError("Edward","GetBinding",Status);
  4418. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Minimize)\n");
  4419. return;
  4420. }
  4421. Status = GetBinding(ELLIOTMAXIMIZE, &HelgaMaximize);
  4422. if (Status)
  4423. {
  4424. ApiError("Edward","GetBinding",Status);
  4425. PrintToConsole("Edward : FAIL - Unable to Bind (ElliotMaximize)\n");
  4426. return;
  4427. }
  4428. Status = GetBinding(ELLIOTMAXIMIZE, &IsabelleBinding);
  4429. if (Status)
  4430. {
  4431. ApiError("Edward","GetBinding",Status);
  4432. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Maximize)\n");
  4433. return;
  4434. }
  4435. // First, we will test callbacks.
  4436. SylviaBinding = SylviaMinimize;
  4437. if (SylviaCall(SylviaBinding,5,0,0) != LocalSylviaCall(5,0,0))
  4438. {
  4439. PrintToConsole("Edward : FAIL - Incorrect result");
  4440. PrintToConsole(" from SylviaCall(5,0,0)\n");
  4441. return;
  4442. }
  4443. if (SylviaCall(SylviaBinding,10,5,0) != LocalSylviaCall(10,5,0))
  4444. {
  4445. PrintToConsole("Edward : FAIL - Incorrect result");
  4446. PrintToConsole(" from SylviaCall(10,5,0)\n");
  4447. return;
  4448. }
  4449. // And then we will test callbacks again using the maximize address.
  4450. SylviaBinding = SylviaMaximize;
  4451. if (SylviaCall(SylviaBinding,5,0,0) != LocalSylviaCall(5,0,0))
  4452. {
  4453. PrintToConsole("Edward : FAIL - Incorrect result from");
  4454. PrintToConsole(" SylviaCall(5,0,0)\n");
  4455. return;
  4456. }
  4457. if (SylviaCall(SylviaBinding,10,5,0) != LocalSylviaCall(10,5,0))
  4458. {
  4459. PrintToConsole("Edward : FAIL - Incorrect result");
  4460. PrintToConsole(" from SylviaCall(10,5,0)\n");
  4461. return;
  4462. }
  4463. // Ok, now we will insure that the Helga interface works.
  4464. Helga(HelgaMinimize);
  4465. HelgaIN(HelgaMinimize,1024*4);
  4466. HelgaOUT(HelgaMinimize,1024*8);
  4467. HelgaINOUT(HelgaMinimize,1024*16);
  4468. Helga(HelgaMaximize);
  4469. HelgaIN(HelgaMaximize,1024*4);
  4470. HelgaOUT(HelgaMaximize,1024*8);
  4471. HelgaINOUT(HelgaMaximize,1024*16);
  4472. if (HelgaErrors != 0)
  4473. {
  4474. PrintToConsole("Edward : FAIL - Error(s) in Helga Interface\n");
  4475. HelgaErrors = 0;
  4476. return;
  4477. }
  4478. // Now we want to unbind both Sylvia binding handles, and then try
  4479. // the Helga interface again.
  4480. if (SylviaErrors != 0)
  4481. {
  4482. PrintToConsole("Edward : FAIL - Error(s) in Sylvia Interface\n");
  4483. SylviaErrors = 0;
  4484. return;
  4485. }
  4486. Status = RpcBindingFree(&SylviaMinimize);
  4487. if (Status)
  4488. {
  4489. ApiError("Edward","RpcBindingFree",Status);
  4490. PrintToConsole("Edward : FAIL - Unable to Free Binding ");
  4491. PrintToConsole("(SylviaMinimize)\n");
  4492. return;
  4493. }
  4494. Status = RpcBindingFree(&SylviaMaximize);
  4495. if (Status)
  4496. {
  4497. ApiError("Edward","RpcBindingFree",Status);
  4498. PrintToConsole("Edward : FAIL - Unable to Free Binding");
  4499. PrintToConsole(" (SylviaMaximize)\n");
  4500. return;
  4501. }
  4502. // Ok, now we will insure that the Helga interface still works.
  4503. Helga(HelgaMinimize);
  4504. HelgaIN(HelgaMinimize,1024*2);
  4505. HelgaOUT(HelgaMinimize,1024*4);
  4506. HelgaINOUT(HelgaMinimize,1024*8);
  4507. Helga(HelgaMaximize);
  4508. HelgaIN(HelgaMaximize,1024*2);
  4509. HelgaOUT(HelgaMaximize,1024*4);
  4510. HelgaINOUT(HelgaMaximize,1024*8);
  4511. if (HelgaErrors != 0)
  4512. {
  4513. PrintToConsole("Edward : FAIL - Error(s) in Helga Interface\n");
  4514. HelgaErrors = 0;
  4515. return;
  4516. }
  4517. // Now we need to test the binding stuff.
  4518. Status = GetBinding(ELLIOTMINIMIZE, &EdwardMinimize);
  4519. if (Status)
  4520. {
  4521. ApiError("Edward","GetBinding",Status);
  4522. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Minimize)\n");
  4523. return;
  4524. }
  4525. Status = GetBinding(ELLIOTNORMAL, &EdwardNormal);
  4526. if (Status)
  4527. {
  4528. ApiError("Edward","GetBinding",Status);
  4529. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Normal)\n");
  4530. return;
  4531. }
  4532. Status = GetBinding(ELLIOTMAXIMIZE, &EdwardMaximize);
  4533. if (Status)
  4534. {
  4535. ApiError("Edward","GetBinding",Status);
  4536. PrintToConsole("Edward : FAIL - Unable to Bind (Elliot Maximize)\n");
  4537. return;
  4538. }
  4539. if (HelgaWrongInterfaceGuid(EdwardMinimize))
  4540. {
  4541. PrintToConsole("Edward : FAIL - HelgaWrongInterfaceGuid Succeeded\n");
  4542. return;
  4543. }
  4544. if (HelgaWrongInterfaceGuid(EdwardNormal))
  4545. {
  4546. PrintToConsole("Edward : FAIL - HelgaWrongInterfaceGuid Succeeded\n");
  4547. return;
  4548. }
  4549. if (HelgaWrongInterfaceGuid(EdwardMaximize))
  4550. {
  4551. PrintToConsole("Edward : FAIL - HelgaWrongInterfaceGuid Succeeded\n");
  4552. return;
  4553. }
  4554. //Skip over the WrongTransfer Syntax tests for Datagram
  4555. //Datagram doesnt req. any checks on Transfer syntaxes
  4556. if (DatagramTests == 0)
  4557. {
  4558. if (HelgaWrongTransferSyntax(EdwardMinimize))
  4559. {
  4560. PrintToConsole("Edward : FAIL - HelgaWrongTransferSyntax");
  4561. PrintToConsole(" Succeeded\n");
  4562. return;
  4563. }
  4564. if (HelgaWrongTransferSyntax(EdwardNormal))
  4565. {
  4566. PrintToConsole("Edward : FAIL - HelgaWrongTransferSyntax");
  4567. PrintToConsole(" Succeeded\n");
  4568. return;
  4569. }
  4570. if (HelgaWrongTransferSyntax(EdwardMaximize))
  4571. {
  4572. PrintToConsole("Edward : FAIL - HelgaWrongTransferSyntax");
  4573. PrintToConsole(" Succeeded\n");
  4574. return;
  4575. }
  4576. }
  4577. Status = RpcBindingFree(&EdwardMinimize);
  4578. if (Status)
  4579. {
  4580. PrintToConsole("Edward : FAIL - Unable to Free Binding ");
  4581. PrintToConsole("(EdwardMinimize)\n");
  4582. return;
  4583. }
  4584. Status = RpcBindingFree(&EdwardNormal);
  4585. if (Status)
  4586. {
  4587. PrintToConsole("Edward : FAIL - Unable to Free Binding ");
  4588. PrintToConsole("(EdwardNormal)\n");
  4589. return;
  4590. }
  4591. Status = RpcBindingFree(&EdwardMaximize);
  4592. if (Status)
  4593. {
  4594. PrintToConsole("Edward : FAIL - Unable to Free Binding ");
  4595. PrintToConsole("(EdwardMaximize)\n");
  4596. return;
  4597. }
  4598. // Finally, we will tell the server to shutdown, and then we will
  4599. // unbind the Helga bindings.
  4600. IsabelleShutdown(IsabelleBinding);
  4601. if (IsabelleErrors != 0)
  4602. {
  4603. PrintToConsole("Edward : FAIL - Error(s) in Isabelle Interface\n");
  4604. IsabelleErrors = 0;
  4605. return;
  4606. }
  4607. Status = RpcBindingFree(&IsabelleBinding);
  4608. if (Status)
  4609. {
  4610. PrintToConsole("Edward : FAIL - Unable to Free Binding");
  4611. PrintToConsole(" (IsabelleBinding)\n");
  4612. return;
  4613. }
  4614. Status = RpcBindingFree(&HelgaMaximize);
  4615. if (Status)
  4616. {
  4617. PrintToConsole("Edward : FAIL - Unable to Free Binding ");
  4618. PrintToConsole("(HelgaMaximize)\n");
  4619. return;
  4620. }
  4621. Status = RpcBindingFree(&HelgaMinimize);
  4622. if (Status)
  4623. {
  4624. PrintToConsole("Edward : FAIL - Unable to Free Binding");
  4625. PrintToConsole(" (HelgaMinimize)\n");
  4626. return;
  4627. }
  4628. PrintToConsole("Edward : PASS\n");
  4629. }
  4630. #ifdef NOVELL_NP
  4631. unsigned int AstroThreads = 1;
  4632. #else // NOVELL_NP
  4633. unsigned int AstroThreads = 2;
  4634. #endif // NOVELL
  4635. #ifndef NOTHREADS
  4636. unsigned int AstroThreadCount;
  4637. /* volatile */ int fAstroResume;
  4638. void
  4639. AstroSylvia (
  4640. IN void * Ignore
  4641. )
  4642. /*++
  4643. Routine Description:
  4644. This routine will be called by each thread created by the Astro
  4645. test to make calls against the Sylvia interface.
  4646. Arguments:
  4647. Ignore - Supplies an argument which we do not use. The thread class
  4648. takes a single argument, which we ignore.
  4649. --*/
  4650. {
  4651. UNUSED(Ignore);
  4652. if (SylviaCall(SylviaBinding,5,0,0) != LocalSylviaCall(5,0,0))
  4653. {
  4654. PrintToConsole("AstroSylvia : FAIL - Incorrect result from");
  4655. PrintToConsole(" SylviaCall(5,0,0)\n");
  4656. return;
  4657. }
  4658. if (SylviaCall(SylviaBinding,10,5,0) != LocalSylviaCall(10,5,0))
  4659. {
  4660. PrintToConsole("AstroSylvia : FAIL - Incorrect result from");
  4661. PrintToConsole(" SylviaCall(10,5,0)\n");
  4662. return;
  4663. }
  4664. TestMutexRequest();
  4665. AstroThreadCount -= 1;
  4666. if (AstroThreadCount == 0)
  4667. {
  4668. TestMutexClear();
  4669. fAstroResume = 1;
  4670. }
  4671. else
  4672. TestMutexClear();
  4673. }
  4674. MUTEX2 Mutex2(&Status);
  4675. void
  4676. AstroMutex (
  4677. RPC_BINDING_HANDLE Dontcare
  4678. )
  4679. {
  4680. int i;
  4681. while (1)
  4682. {
  4683. for (i = 0; i < 10; i++)
  4684. {
  4685. Mutex2.Request();
  4686. PrintToConsole("Thread %d in the mutex\n", GetCurrentThreadId());
  4687. Mutex2.Clear();
  4688. PauseExecution(30*i);
  4689. }
  4690. }
  4691. }
  4692. void
  4693. AstroHelga (
  4694. RPC_BINDING_HANDLE HelgaBinding
  4695. )
  4696. /*++
  4697. Routine Description:
  4698. This routine will be used by the Astro test to perform a test against
  4699. the Helga interface. More that one thread will execute this routine
  4700. at a time.
  4701. Arguments:
  4702. HelgaBinding - Supplies the binding handle to use in make calls using
  4703. the Helga interface.
  4704. --*/
  4705. {
  4706. TestHelgaInterface(HelgaBinding,
  4707. ( HelgaMaxSize < 8*1024L ? HelgaMaxSize : 8*1024L ));
  4708. TestMutexRequest();
  4709. AstroThreadCount -= 1;
  4710. if (AstroThreadCount == 0)
  4711. {
  4712. TestMutexClear();
  4713. fAstroResume = 1;
  4714. }
  4715. else
  4716. TestMutexClear();
  4717. }
  4718. void
  4719. AstroHelgaAndUnbind ( // Perform the a test using the Helga interface. When
  4720. // done, unbind the binding handle.
  4721. RPC_BINDING_HANDLE HelgaBinding // Binding to use to the Helga interface.
  4722. )
  4723. /*++
  4724. Routine Description:
  4725. This routine is the same as AstroHelga, except that we free the binding
  4726. handle when we are done using it.
  4727. Arguments:
  4728. HelgaBinding - Supplies the binding handle to use in making calls
  4729. using the Helga interface. When we are done with it, we free
  4730. it.
  4731. --*/
  4732. {
  4733. TestHelgaInterface(HelgaBinding,
  4734. ( HelgaMaxSize < 8*1024L ? HelgaMaxSize : 8*1024L ));
  4735. Status = RpcBindingFree(&HelgaBinding);
  4736. if (Status)
  4737. {
  4738. ApiError("Astro","RpcBindingFree",Status);
  4739. PrintToConsole("Astro : FAIL - Unable to Free Binding ");
  4740. PrintToConsole("(HelgaBinding)\n");
  4741. return;
  4742. }
  4743. TestMutexRequest();
  4744. AstroThreadCount -= 1;
  4745. if (AstroThreadCount == 0)
  4746. {
  4747. TestMutexClear();
  4748. fAstroResume = 1;
  4749. }
  4750. else
  4751. TestMutexClear();
  4752. }
  4753. typedef enum _ASTRO_BIND_OPTION
  4754. {
  4755. AstroBindOnce,
  4756. AstroBindThread,
  4757. AstroBindSylvia,
  4758. AstroDontBind
  4759. } ASTRO_BIND_OPTION;
  4760. int
  4761. PerformMultiThreadAstroTest (
  4762. ASTRO_BIND_OPTION AstroBindOption,
  4763. void (*AstroTestRoutine)(RPC_BINDING_HANDLE),
  4764. unsigned int Address
  4765. )
  4766. /*++
  4767. Routine Description:
  4768. This routine takes care of performing all of the multi-threaded Astro
  4769. tests. We create the binding handles as well as creating the threads
  4770. to perform each test. We also wait around for all of the threads to
  4771. complete.
  4772. Arguments:
  4773. AstroBindOption - Supplies information indicating how the binding
  4774. for this particular test should be done.
  4775. AstroTestRoutine - Supplies the test routine to be executed by each
  4776. thread performing the test.
  4777. Address - Supplies the address index to be passed to GetStringBinding
  4778. used to get a string binding. The string binding is passed to
  4779. RpcBindingFromStringBinding.
  4780. Return Value:
  4781. A return value of zero indicates that the test succeeded. Otherwise,
  4782. the test failed.
  4783. --*/
  4784. {
  4785. RPC_STATUS RpcStatus;
  4786. RPC_BINDING_HANDLE BindingHandle;
  4787. unsigned int ThreadCount;
  4788. if (AstroBindOption == AstroBindOnce)
  4789. {
  4790. Status = GetBinding(Address, &BindingHandle);
  4791. if (Status)
  4792. {
  4793. ApiError("Astro","GetBinding",Status);
  4794. PrintToConsole("Astro : FAIL - Unable to Bind\n");
  4795. return(1);
  4796. }
  4797. }
  4798. else if (AstroBindOption == AstroBindSylvia)
  4799. {
  4800. Status = GetBinding(Address, &BindingHandle);
  4801. SylviaBinding = BindingHandle;
  4802. if (Status)
  4803. {
  4804. ApiError("Astro","GetBinding",Status);
  4805. PrintToConsole("Astro : FAIL - Unable to Bind\n");
  4806. return(1);
  4807. }
  4808. }
  4809. AstroThreadCount = AstroThreads;
  4810. fAstroResume = 0;
  4811. for (ThreadCount = 0; ThreadCount < AstroThreads; ThreadCount++)
  4812. {
  4813. if (AstroBindOption == AstroBindThread)
  4814. {
  4815. Status = GetBinding(Address, &BindingHandle);
  4816. if (Status)
  4817. {
  4818. ApiError("Astro","GetBinding",Status);
  4819. PrintToConsole("Astro : FAIL - Unable to Bind\n");
  4820. return(1);
  4821. }
  4822. }
  4823. RpcStatus = RPC_S_OK;
  4824. HANDLE HandleToThread;
  4825. unsigned long ThreadId;
  4826. HandleToThread = CreateThread(
  4827. 0,
  4828. DefaultThreadStackSize,
  4829. (LPTHREAD_START_ROUTINE) AstroTestRoutine,
  4830. BindingHandle,
  4831. 0,
  4832. &ThreadId);
  4833. if (HandleToThread == 0)
  4834. {
  4835. OtherError("Astro", "CreateThread failed");
  4836. PrintToConsole("Astro : FAIL - Unable to create thread\n");
  4837. return(1);
  4838. }
  4839. }
  4840. while (!fAstroResume)
  4841. PauseExecution(200L);
  4842. if (AstroThreadCount != 0)
  4843. {
  4844. PrintToConsole("Astro : FAIL - AstroThreadCount != 0\n");
  4845. return(1);
  4846. }
  4847. if (HelgaErrors != 0)
  4848. {
  4849. PrintToConsole("Astro : FAIL - Error(s) in Helga Interface\n");
  4850. return(1);
  4851. }
  4852. if ( (AstroBindOption == AstroBindOnce)
  4853. || (AstroBindOption == AstroBindSylvia))
  4854. {
  4855. Status = RpcBindingFree(&BindingHandle);
  4856. if (Status)
  4857. {
  4858. ApiError("Astro","RpcBindingFree",Status);
  4859. PrintToConsole("Astro : FAIL - Unable to Free Binding ");
  4860. PrintToConsole("(BindingHandle)\n");
  4861. return(1);
  4862. }
  4863. }
  4864. return(0);
  4865. }
  4866. #endif
  4867. void
  4868. Astro (
  4869. )
  4870. /*++
  4871. Routine Description:
  4872. This routine tests the runtime by having more than one thread
  4873. simultaneously perform remote procedure calls. This test works with
  4874. the Andromida test in usvr.exe.
  4875. --*/
  4876. {
  4877. RPC_BINDING_HANDLE IsabelleBinding;
  4878. RPC_STATUS RpcStatus = RPC_S_OK;
  4879. Synchro(ANDROMIDA) ;
  4880. if ( NumberOfTestsRun++ )
  4881. {
  4882. PauseExecution(TestDelay);
  4883. }
  4884. PrintToConsole("Astro : Multithreaded Clients (%d)\n", AstroThreads);
  4885. Status = GetBinding(ANDROMIDA, &IsabelleBinding);
  4886. if (Status)
  4887. {
  4888. ApiError("Astro","GetBinding",Status);
  4889. PrintToConsole("Astro : FAIL - Unable to Bind (Andromida)\n");
  4890. return;
  4891. }
  4892. #ifndef NOTHREADS
  4893. if (PerformMultiThreadAstroTest(AstroBindOnce,AstroHelga,
  4894. ANDROMIDA))
  4895. return;
  4896. if (PerformMultiThreadAstroTest(AstroBindThread, AstroHelgaAndUnbind,
  4897. ANDROMIDA))
  4898. return;
  4899. if ( PerformMultiThreadAstroTest(AstroBindSylvia, AstroSylvia,
  4900. ANDROMIDA) != 0 )
  4901. {
  4902. return;
  4903. }
  4904. #endif
  4905. IsabelleShutdown(IsabelleBinding);
  4906. if (IsabelleErrors != 0)
  4907. {
  4908. PrintToConsole("Astro : FAIL - Error(s) in Isabelle Interface\n");
  4909. IsabelleErrors = 0;
  4910. return;
  4911. }
  4912. Status = RpcBindingFree(&IsabelleBinding);
  4913. if (Status)
  4914. {
  4915. ApiError("Astro","RpcBindingFree",Status);
  4916. PrintToConsole("Astro : FAIL - Unable to Free Binding");
  4917. PrintToConsole(" (IsabelleBinding)\n");
  4918. return;
  4919. }
  4920. PrintToConsole("Astro : PASS\n");
  4921. }
  4922. int
  4923. FitzgeraldCompose (
  4924. IN char PAPI * ObjUuid OPTIONAL,
  4925. IN char PAPI * Protseq,
  4926. IN char PAPI * NetworkAddr,
  4927. IN char PAPI * Endpoint OPTIONAL,
  4928. IN char PAPI * NetworkOptions OPTIONAL,
  4929. IN char PAPI * ExpectedStringBinding
  4930. )
  4931. /*++
  4932. Routine Description:
  4933. This routine is used by Fitzgerald to test the RpcStringBindingCompose
  4934. API.
  4935. Arguments:
  4936. ObjUuid - Optionally supplies the object UUID field to pass to
  4937. RpcStringBindingCompose.
  4938. Protseq - Supplies the RPC protocol sequence field to pass to
  4939. RpcStringBindingCompose.
  4940. NetworkAddr - Supplies the network address field to pass to
  4941. RpcStringBindingCompose.
  4942. Endpoint - Optionally supplies the endpoint field to pass to
  4943. RpcStringBindingCompose.
  4944. NetworkOptions - Optionally supplies the network options field to
  4945. pass to RpcStringBindingCompose.
  4946. ExpectedStringBinding - Supplies the expected string binding which
  4947. should be obtained from RpcStringBindingCompose.
  4948. Return Value:
  4949. 0 - The test passed successfully.
  4950. 1 - The test failed.
  4951. --*/
  4952. {
  4953. unsigned char PAPI * StringBinding;
  4954. RPC_STATUS Status;
  4955. Status = RpcStringBindingComposeA((unsigned char PAPI *) ObjUuid,
  4956. (unsigned char PAPI *) Protseq,
  4957. (unsigned char PAPI *) NetworkAddr,
  4958. (unsigned char PAPI *) Endpoint,
  4959. (unsigned char PAPI *) NetworkOptions,&StringBinding);
  4960. if (Status)
  4961. {
  4962. ApiError("FitzgeraldCompose","RpcStringBindingCompose",Status);
  4963. PrintToConsole("Fitzgerald : FAIL - Error in");
  4964. PrintToConsole(" RpcStringBindingCompose\n");
  4965. return(1);
  4966. }
  4967. if (strcmp((char PAPI *) StringBinding,
  4968. (char PAPI *) ExpectedStringBinding) != 0)
  4969. {
  4970. PrintToConsole("Fitzgerald : FAIL - StringBinding");
  4971. PrintToConsole(" != ExpectedStringBinding\n");
  4972. return(1);
  4973. }
  4974. Status = RpcStringFreeA(&StringBinding);
  4975. if (Status)
  4976. {
  4977. ApiError("FitzgeraldCompose","RpcStringFree",Status);
  4978. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  4979. return(1);
  4980. }
  4981. return(0);
  4982. }
  4983. int
  4984. FitzgeraldParse (
  4985. IN char PAPI * StringBinding,
  4986. IN char PAPI * ExpectedObjUuid OPTIONAL,
  4987. IN char PAPI * ExpectedProtseq OPTIONAL,
  4988. IN char PAPI * ExpectedNetworkAddr OPTIONAL,
  4989. IN char PAPI * ExpectedEndpoint OPTIONAL,
  4990. IN char PAPI * ExpectedOptions OPTIONAL
  4991. )
  4992. /*++
  4993. Routine Description:
  4994. This routine is used by Fitzgerald to test the RpcStringBindingParse
  4995. API.
  4996. Arguments:
  4997. StringBinding - Supplies the string binding to be parsed.
  4998. ExpectedObjUuid - Supplies a string containing the expected object
  4999. UUID field.
  5000. ExpectedProtseq - Supplies the expected RPC protocol sequence field.
  5001. ExpectedNetworkAddr - Supplies the expected network address field.
  5002. ExpectedEndpoint - Supplies the expected endpoint field.
  5003. ExpectedOptions - Supplies the expected options field.
  5004. Return Value:
  5005. 0 - The test passed successfully.
  5006. 1 - The test failed.
  5007. --*/
  5008. {
  5009. unsigned char PAPI * ObjUuid = 0;
  5010. unsigned char PAPI * Protseq = 0;
  5011. unsigned char PAPI * NetworkAddr = 0;
  5012. unsigned char PAPI * Endpoint = 0;
  5013. unsigned char PAPI * Options = 0;
  5014. RPC_STATUS Status;
  5015. Status = RpcStringBindingParseA((unsigned char PAPI *) StringBinding,
  5016. (ARGUMENT_PRESENT(ExpectedObjUuid) ? (unsigned char PAPI * PAPI *) &ObjUuid : 0),
  5017. (ARGUMENT_PRESENT(ExpectedProtseq) ? (unsigned char PAPI * PAPI *) &Protseq : 0),
  5018. (ARGUMENT_PRESENT(ExpectedNetworkAddr) ? (unsigned char PAPI * PAPI *) &NetworkAddr : 0),
  5019. (ARGUMENT_PRESENT(ExpectedEndpoint) ? (unsigned char PAPI * PAPI *) &Endpoint : 0),
  5020. (ARGUMENT_PRESENT(ExpectedOptions) ? (unsigned char PAPI * PAPI *) &Options : 0));
  5021. if (Status)
  5022. {
  5023. ApiError("FitzgeraldParse","RpcStringBindingParse",Status);
  5024. PrintToConsole("Fitzgerald : FAIL - Error in");
  5025. PrintToConsole(" RpcStringBindingParse\n");
  5026. return(1);
  5027. }
  5028. if (strcmp(ExpectedObjUuid,(char PAPI *) ObjUuid) != 0)
  5029. {
  5030. PrintToConsole("Fitzgerald : FAIL - ExpectedObjUuid != ObjUuid");
  5031. return(1);
  5032. }
  5033. if (strcmp(ExpectedProtseq,(char PAPI *) Protseq) != 0)
  5034. {
  5035. PrintToConsole("Fitzgerald : FAIL - ExpectedProtseq != Protseq");
  5036. return(1);
  5037. }
  5038. if (strcmp(ExpectedNetworkAddr,(char PAPI *) NetworkAddr) != 0)
  5039. {
  5040. PrintToConsole("Fitzgerald : FAIL - ExpectedNetworkAddr");
  5041. PrintToConsole(" != NetworkAddr");
  5042. return(1);
  5043. }
  5044. if (strcmp(ExpectedEndpoint,(char PAPI *) Endpoint) != 0)
  5045. {
  5046. PrintToConsole("Fitzgerald : FAIL - ExpectedEndpoint != Endpoint");
  5047. return(1);
  5048. }
  5049. if (strcmp(ExpectedOptions,(char PAPI *) Options) != 0)
  5050. {
  5051. PrintToConsole("Fitzgerald : FAIL - ExpectedOptions != Options");
  5052. return(1);
  5053. }
  5054. Status = RpcStringFreeA(&ObjUuid);
  5055. if (Status)
  5056. {
  5057. ApiError("FitzgeraldParse","RpcStringFree",Status);
  5058. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5059. return(1);
  5060. }
  5061. Status = RpcStringFreeA(&Protseq);
  5062. if (Status)
  5063. {
  5064. ApiError("FitzgeraldParse","RpcStringFree",Status);
  5065. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5066. return(1);
  5067. }
  5068. Status = RpcStringFreeA(&NetworkAddr);
  5069. if (Status)
  5070. {
  5071. ApiError("FitzgeraldParse","RpcStringFree",Status);
  5072. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5073. return(1);
  5074. }
  5075. Status = RpcStringFreeA(&Endpoint);
  5076. if (Status)
  5077. {
  5078. ApiError("FitzgeraldParse","RpcStringFree",Status);
  5079. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5080. return(1);
  5081. }
  5082. Status = RpcStringFreeA(&Options);
  5083. if (Status)
  5084. {
  5085. ApiError("FitzgeraldParse","RpcStringFree",Status);
  5086. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5087. return(1);
  5088. }
  5089. return(0);
  5090. }
  5091. int
  5092. FitzgeraldComposeAndParse (
  5093. void
  5094. )
  5095. /*++
  5096. Routine Description:
  5097. This routine tests that the string binding (RpcStringBindingCompose and
  5098. RpcStringBindingParse) and string (RpcStringFree) APIs are working
  5099. correctly. This is a build verification test; hence it focuses on
  5100. testing that all functionality is there, testing error cases are
  5101. not quite as important.
  5102. Return Value:
  5103. Zero will be returned if all of the tests pass, otherwise, non-zero
  5104. will be returned.
  5105. --*/
  5106. {
  5107. unsigned char PAPI * StringBinding;
  5108. if (FitzgeraldCompose(0,"ncacn_np","\\\\server","\\pipe\\endpoint",0,
  5109. "ncacn_np:\\\\\\\\server[\\\\pipe\\\\endpoint]"))
  5110. return(1);
  5111. if (FitzgeraldCompose(0,"ncacn_np","\\\\server",0,0,
  5112. "ncacn_np:\\\\\\\\server"))
  5113. return(1);
  5114. Status = RpcStringBindingComposeA(
  5115. (unsigned char PAPI *) "12345678-9012-B456-8001-08002B033D7AA",
  5116. (unsigned char PAPI *) "ncacn_np",
  5117. (unsigned char PAPI *) "\\\\server", 0,0, &StringBinding);
  5118. if ( Status != RPC_S_INVALID_STRING_UUID )
  5119. {
  5120. ApiError("FitzgeraldComposeAndParse", "RpcStringBindingCompose",
  5121. Status);
  5122. PrintToConsole("Fitzgerald : FAIL - Error ");
  5123. PrintToConsole("in RpcStringBindingCompose\n");
  5124. return(1);
  5125. }
  5126. if (FitzgeraldCompose("12345678-9012-B456-8001-08002B033D7A",
  5127. "ncacn_np","\\\\server","\\pipe\\endpoint",0,
  5128. "12345678-9012-b456-8001-08002b033d7a@ncacn_np:\\\\\\\\server[\\\\pipe\\\\endpoint]"))
  5129. return(1);
  5130. if (FitzgeraldCompose(0,"ncacn_np","\\\\server","\\pipe\\endpoint",
  5131. "security=identify",
  5132. "ncacn_np:\\\\\\\\server[\\\\pipe\\\\endpoint,security=identify]"))
  5133. return(1);
  5134. if (FitzgeraldCompose(0,"ncacn_np","\\\\server",0,"option=value",
  5135. "ncacn_np:\\\\\\\\server[,option=value]"))
  5136. return(1);
  5137. if (FitzgeraldParse("12345678-9012-b456-8001-08002b033d7a@ncacn_np:\\\\\\\\server[\\\\pipe\\\\endpoint,security=identify]",
  5138. "12345678-9012-b456-8001-08002b033d7a",
  5139. "ncacn_np","\\\\server","\\pipe\\endpoint",
  5140. "security=identify"))
  5141. return(1);
  5142. if (FitzgeraldParse("ncacn_np:\\\\\\\\server",
  5143. "","ncacn_np","\\\\server","",""))
  5144. return(1);
  5145. if (FitzgeraldParse("ncacn_np:\\\\\\\\server[\\\\pipe\\\\endpoint]",
  5146. "","ncacn_np","\\\\server","\\pipe\\endpoint",""))
  5147. return(1);
  5148. return(0);
  5149. }
  5150. int
  5151. FitzgeraldBindingCopy (
  5152. )
  5153. /*++
  5154. Routine Description:
  5155. Fitzgerald uses this routine to test the RpcBindingCopy API (we also
  5156. use RpcBindingFromStringBinding and RpcBindingFree).
  5157. Return Value:
  5158. Zero will be returned if all of the tests pass, otherwise, non-zero
  5159. will be returned.
  5160. --*/
  5161. {
  5162. RPC_BINDING_HANDLE BindingHandle;
  5163. RPC_BINDING_HANDLE CopiedBeforeRpc;
  5164. RPC_BINDING_HANDLE CopiedAfterRpc;
  5165. Status = GetBinding(FREDRICK, &BindingHandle);
  5166. if (Status)
  5167. {
  5168. ApiError("Fitzgerald","GetBinding",Status);
  5169. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5170. PrintToConsole(" (Fredrick)");
  5171. return(1);
  5172. }
  5173. Status = RpcBindingCopy(BindingHandle,&CopiedBeforeRpc);
  5174. if (Status)
  5175. {
  5176. ApiError("Fitzgerald","RpcBindingCopy",Status);
  5177. PrintToConsole("Fitzgerald : FAIL - Unable to Copy Binding");
  5178. PrintToConsole(" (BindingHandle)\n");
  5179. return(1);
  5180. }
  5181. Helga(BindingHandle);
  5182. if (HelgaErrors != 0)
  5183. {
  5184. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5185. HelgaErrors = 0;
  5186. return(1);
  5187. }
  5188. Helga(CopiedBeforeRpc);
  5189. if (HelgaErrors != 0)
  5190. {
  5191. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5192. HelgaErrors = 0;
  5193. return(1);
  5194. }
  5195. Status = RpcBindingCopy(CopiedBeforeRpc,&CopiedAfterRpc);
  5196. if (Status)
  5197. {
  5198. ApiError("Fitzgerald","RpcBindingCopy",Status);
  5199. PrintToConsole("Fitzgerald : FAIL - Unable to Copy Binding");
  5200. PrintToConsole(" (CopiedBeforeRpc)\n");
  5201. return(1);
  5202. }
  5203. Status = RpcBindingFree(&BindingHandle);
  5204. if (Status)
  5205. {
  5206. ApiError("Fitzgerald","RpcBindingFree",Status);
  5207. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5208. PrintToConsole(" (BindingHandle)\n");
  5209. return(1);
  5210. }
  5211. Helga(CopiedBeforeRpc);
  5212. if (HelgaErrors != 0)
  5213. {
  5214. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5215. HelgaErrors = 0;
  5216. return(1);
  5217. }
  5218. Helga(CopiedAfterRpc);
  5219. if (HelgaErrors != 0)
  5220. {
  5221. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5222. HelgaErrors = 0;
  5223. return(1);
  5224. }
  5225. Status = RpcBindingFree(&CopiedBeforeRpc);
  5226. if (Status)
  5227. {
  5228. ApiError("Fitzgerald","RpcBindingFree",Status);
  5229. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5230. PrintToConsole(" (CopiedBeforeRpc)\n");
  5231. return(1);
  5232. }
  5233. Helga(CopiedAfterRpc);
  5234. if (HelgaErrors != 0)
  5235. {
  5236. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5237. HelgaErrors = 0;
  5238. return(1);
  5239. }
  5240. Status = RpcBindingFree(&CopiedAfterRpc);
  5241. if (Status)
  5242. {
  5243. ApiError("Fitzgerald","RpcBindingFree",Status);
  5244. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5245. PrintToConsole(" (CopiedAfterRpc)\n");
  5246. return(1);
  5247. }
  5248. return(0);
  5249. }
  5250. int
  5251. FitzgeraldToStringBinding (
  5252. IN unsigned char PAPI * UseThisStringBinding,
  5253. IN unsigned char PAPI * ExpectedStringBinding,
  5254. IN UUID PAPI * ObjectUuid OPTIONAL
  5255. )
  5256. /*++
  5257. Routine Description:
  5258. This routine tests the RpcBindingToStringBinding API.
  5259. Arguments:
  5260. UseThisStringBinding - Supplies the string binding to used in
  5261. making the binding handle.
  5262. ExpectedStringBinding - Supplies the expected string binding to be
  5263. obtained from RpcBindingToStringBinding.
  5264. ObjectUuid - Optionally supplies an object uuid which should be
  5265. set in the binding handle.
  5266. Return Value:
  5267. Zero will be returned if the test passes, otherwise, non-zero
  5268. will be returned.
  5269. --*/
  5270. {
  5271. RPC_BINDING_HANDLE BindingHandle;
  5272. unsigned char PAPI * StringBinding;
  5273. Status = RpcBindingFromStringBindingA(UseThisStringBinding,&BindingHandle);
  5274. if (Status)
  5275. {
  5276. ApiError("Fitzgerald","RpcBindingFromStringBinding",Status);
  5277. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5278. PrintToConsole(" (Fredrick)\n");
  5279. return(1);
  5280. }
  5281. if (ARGUMENT_PRESENT(ObjectUuid))
  5282. {
  5283. Status = RpcBindingSetObject(BindingHandle,ObjectUuid);
  5284. if (Status)
  5285. {
  5286. ApiError("Fitzgerald","RpcBindingSetObject",Status);
  5287. PrintToConsole("Fitzgerald : FAIL - Error in ");
  5288. PrintToConsole("RpcBindingSetObject\n");
  5289. return(1);
  5290. }
  5291. }
  5292. Status = RpcBindingToStringBindingA(BindingHandle,&StringBinding);
  5293. if (Status)
  5294. {
  5295. ApiError("Fitzgerald","RpcBindingToStringBinding",Status);
  5296. PrintToConsole("Fitzgerald : FAIL - Unable to Create String Binding");
  5297. PrintToConsole(" (BindingHandle)\n");
  5298. return(1);
  5299. }
  5300. if (strcmp((char *) ExpectedStringBinding,(char *) StringBinding) != 0)
  5301. {
  5302. PrintToConsole("Fitzgerald : FAIL - ExpectedStringBinding");
  5303. PrintToConsole(" != StringBinding\n");
  5304. return(1);
  5305. }
  5306. Status = RpcStringFreeA(&StringBinding);
  5307. if (Status)
  5308. {
  5309. ApiError("Fitzgerald","RpcStringFree",Status);
  5310. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5311. return(1);
  5312. }
  5313. Helga(BindingHandle);
  5314. Status = RpcBindingToStringBindingA(BindingHandle,&StringBinding);
  5315. if (Status)
  5316. {
  5317. ApiError("Fitzgerald","RpcBindingToStringBinding",Status);
  5318. PrintToConsole("Fitzgerald : FAIL - Unable to Create String Binding");
  5319. PrintToConsole(" (BindingHandle)\n");
  5320. return(1);
  5321. }
  5322. if (strcmp((char *) ExpectedStringBinding,(char *) StringBinding) != 0)
  5323. {
  5324. PrintToConsole("Fitzgerald : FAIL - ExpectedStringBinding");
  5325. PrintToConsole(" != StringBinding\n");
  5326. return(1);
  5327. }
  5328. Status = RpcStringFreeA(&StringBinding);
  5329. if (Status)
  5330. {
  5331. ApiError("Fitzgerald","RpcStringFree",Status);
  5332. PrintToConsole("Fitzgerald : FAIL - Error in RpcStringFree\n");
  5333. return(1);
  5334. }
  5335. Status = RpcBindingFree(&BindingHandle);
  5336. if (Status)
  5337. {
  5338. ApiError("Fitzgerald","RpcBindingCopy",Status);
  5339. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5340. PrintToConsole(" (BindingHandle)\n");
  5341. return(1);
  5342. }
  5343. return(0);
  5344. }
  5345. int
  5346. FitzgeraldInqSetObjectUuid (
  5347. IN unsigned int SetObjectBeforeRpcFlag,
  5348. IN unsigned int InqObjectBeforeRpcFlag,
  5349. IN UUID PAPI * ObjectUuid,
  5350. IN unsigned char PAPI * StringBinding
  5351. )
  5352. /*++
  5353. Routine Description:
  5354. This routine tests the RpcBindingInqObject and RpcBindingSetObject
  5355. APIs.
  5356. Arguments:
  5357. SetObjectBeforeRpcFlag - Supplies a flag that specifies when the
  5358. object uuid in the binding handle should be set: one means
  5359. the object uuid should be set before making a remote procedure
  5360. call, and zero means afterward.
  5361. InqObjectBeforeRpcFlag - Supplies a flag which is the same as the
  5362. SetObjectBeforeRpcFlag, but it applies to inquiring the object
  5363. uuid.
  5364. ObjectUuid - Supplies the uuid to set in the binding handle.
  5365. StringBinding - Supplies the string binding to use.
  5366. Return Value:
  5367. Zero will be returned if all of the tests pass, otherwise, non-zero
  5368. will be returned.
  5369. --*/
  5370. {
  5371. UUID InqObjectUuid;
  5372. RPC_BINDING_HANDLE BindingHandle;
  5373. Status = RpcBindingFromStringBindingA(StringBinding,&BindingHandle);
  5374. if (Status)
  5375. {
  5376. ApiError("Fitzgerald","RpcBindingFromStringBinding",Status);
  5377. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5378. PrintToConsole(" (Fredrick)\n");
  5379. return(1);
  5380. }
  5381. if (SetObjectBeforeRpcFlag == 1)
  5382. {
  5383. Status = RpcBindingSetObject(BindingHandle,ObjectUuid);
  5384. if (Status)
  5385. {
  5386. ApiError("Fitzgerald","RpcBindingSetObject",Status);
  5387. PrintToConsole("Fitzgerald : FAIL - Error in ");
  5388. PrintToConsole("RpcBindingSetObject\n");
  5389. return(1);
  5390. }
  5391. }
  5392. if (InqObjectBeforeRpcFlag == 1)
  5393. {
  5394. Status = RpcBindingInqObject(BindingHandle,&InqObjectUuid);
  5395. if (Status)
  5396. {
  5397. ApiError("Fitzgerald","RpcBindingInqObject",Status);
  5398. PrintToConsole("Fitzgerald : FAIL - Error in ");
  5399. PrintToConsole("RpcBindingInqObject\n");
  5400. return(1);
  5401. }
  5402. if ( (InqObjectUuid.Data1 != ObjectUuid->Data1)
  5403. || (InqObjectUuid.Data2 != ObjectUuid->Data2)
  5404. || (InqObjectUuid.Data3 != ObjectUuid->Data3)
  5405. || (InqObjectUuid.Data4[0] != ObjectUuid->Data4[0])
  5406. || (InqObjectUuid.Data4[1] != ObjectUuid->Data4[1])
  5407. || (InqObjectUuid.Data4[2] != ObjectUuid->Data4[2])
  5408. || (InqObjectUuid.Data4[3] != ObjectUuid->Data4[3])
  5409. || (InqObjectUuid.Data4[4] != ObjectUuid->Data4[4])
  5410. || (InqObjectUuid.Data4[5] != ObjectUuid->Data4[5])
  5411. || (InqObjectUuid.Data4[6] != ObjectUuid->Data4[6])
  5412. || (InqObjectUuid.Data4[7] != ObjectUuid->Data4[7]))
  5413. {
  5414. PrintToConsole("Fitzgerald : FAIL - InqObjectUuid !=");
  5415. PrintToConsole(" SetObjectUuid\n");
  5416. return(1);
  5417. }
  5418. }
  5419. Helga(BindingHandle);
  5420. if (SetObjectBeforeRpcFlag == 0)
  5421. {
  5422. Status = RpcBindingSetObject(BindingHandle,ObjectUuid);
  5423. if (Status)
  5424. {
  5425. ApiError("Fitzgerald","RpcBindingSetObject",Status);
  5426. PrintToConsole("Fitzgerald : FAIL - Error in ");
  5427. PrintToConsole("RpcBindingSetObject\n");
  5428. return(1);
  5429. }
  5430. }
  5431. if (InqObjectBeforeRpcFlag == 0)
  5432. {
  5433. Status = RpcBindingInqObject(BindingHandle,&InqObjectUuid);
  5434. if (Status)
  5435. {
  5436. ApiError("Fitzgerald","RpcBindingInqObject",Status);
  5437. PrintToConsole("Fitzgerald : FAIL - Error in ");
  5438. PrintToConsole("RpcBindingInqObject\n");
  5439. return(1);
  5440. }
  5441. if ( (InqObjectUuid.Data1 != ObjectUuid->Data1)
  5442. || (InqObjectUuid.Data2 != ObjectUuid->Data2)
  5443. || (InqObjectUuid.Data3 != ObjectUuid->Data3)
  5444. || (InqObjectUuid.Data4[0] != ObjectUuid->Data4[0])
  5445. || (InqObjectUuid.Data4[1] != ObjectUuid->Data4[1])
  5446. || (InqObjectUuid.Data4[2] != ObjectUuid->Data4[2])
  5447. || (InqObjectUuid.Data4[3] != ObjectUuid->Data4[3])
  5448. || (InqObjectUuid.Data4[4] != ObjectUuid->Data4[4])
  5449. || (InqObjectUuid.Data4[5] != ObjectUuid->Data4[5])
  5450. || (InqObjectUuid.Data4[6] != ObjectUuid->Data4[6])
  5451. || (InqObjectUuid.Data4[7] != ObjectUuid->Data4[7]))
  5452. {
  5453. PrintToConsole("Fitzgerald : FAIL - InqObjectUuid !=");
  5454. PrintToConsole(" SetObjectUuid\n");
  5455. return(1);
  5456. }
  5457. }
  5458. Status = RpcBindingFree(&BindingHandle);
  5459. if (Status)
  5460. {
  5461. ApiError("Fitzgerald","RpcBindingCopy",Status);
  5462. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5463. PrintToConsole(" (BindingHandle)\n");
  5464. return(1);
  5465. }
  5466. return(0);
  5467. }
  5468. int
  5469. FitzgeraldStringBindingAndObject (
  5470. )
  5471. /*++
  5472. Routine Description:
  5473. Fitzgerald uses this routine to test the RpcBindingToStringBinding,
  5474. RpcBindingInqObject, and RpcBindingSetObject APIs. We need to test
  5475. them together because we need to check that the object uuid gets
  5476. placed into the string binding.
  5477. Return Value:
  5478. Zero will be returned if all of the tests pass, otherwise, non-zero
  5479. will be returned.
  5480. --*/
  5481. {
  5482. UUID ObjectUuid;
  5483. unsigned char PAPI * StringBinding1;
  5484. unsigned char PAPI * StringBinding2;
  5485. if (FitzgeraldToStringBinding(GetStringBinding(FREDRICK,0,0),
  5486. GetStringBinding(FREDRICK,0,0), 0))
  5487. return(1);
  5488. if (FitzgeraldToStringBinding(GetStringBinding(FREDRICK,
  5489. "12345678-9012-B456-8001-08002B033D7A",0),
  5490. GetStringBinding(FREDRICK,
  5491. "12345678-9012-B456-8001-08002B033D7A",0), 0))
  5492. return(1);
  5493. ObjectUuid.Data1 = 0x12345678;
  5494. ObjectUuid.Data2 = 0x9012;
  5495. ObjectUuid.Data3 = 0xB456;
  5496. ObjectUuid.Data4[0] = 0x80;
  5497. ObjectUuid.Data4[1] = 0x01;
  5498. ObjectUuid.Data4[2] = 0x08;
  5499. ObjectUuid.Data4[3] = 0x00;
  5500. ObjectUuid.Data4[4] = 0x2B;
  5501. ObjectUuid.Data4[5] = 0x03;
  5502. ObjectUuid.Data4[6] = 0x3D;
  5503. ObjectUuid.Data4[7] = 0x7A;
  5504. StringBinding1 = GetStringBinding(FREDRICK, 0, 0) ;
  5505. StringBinding2 = GetStringBinding(FREDRICK,
  5506. "12345678-9012-B456-8001-08002B033D7A",0) ;
  5507. if (FitzgeraldToStringBinding(StringBinding1, StringBinding2, &ObjectUuid))
  5508. return(1);
  5509. #if 0
  5510. if (FitzgeraldToStringBinding(GetStringBinding(FREDRICK,0,0),
  5511. GetStringBinding(FREDRICK,
  5512. "12345678-9012-B456-8001-08002B033D7A",0), &ObjectUuid))
  5513. return(1);
  5514. #endif
  5515. if (FitzgeraldInqSetObjectUuid(1,1,&ObjectUuid,
  5516. GetStringBinding(FREDRICK,0,0)))
  5517. return(1);
  5518. if (FitzgeraldInqSetObjectUuid(1,0,&ObjectUuid,
  5519. GetStringBinding(FREDRICK,0,0)))
  5520. return(1);
  5521. if (FitzgeraldInqSetObjectUuid(0,0,&ObjectUuid,
  5522. GetStringBinding(FREDRICK,0,0)))
  5523. return(1);
  5524. if (FitzgeraldInqSetObjectUuid(2,1,&ObjectUuid,
  5525. GetStringBinding(FREDRICK,
  5526. "12345678-9012-B456-8001-08002B033D7A",0)))
  5527. return(1);
  5528. if (FitzgeraldInqSetObjectUuid(2,0,&ObjectUuid,
  5529. GetStringBinding(FREDRICK,
  5530. "12345678-9012-B456-8001-08002B033D7A",0)))
  5531. return(1);
  5532. return(0);
  5533. }
  5534. int
  5535. FitzgeraldComTimeout (
  5536. IN unsigned int SetBeforeRpc,
  5537. IN unsigned int SetBeforeRpcTimeout,
  5538. IN unsigned int InqBeforeRpc,
  5539. IN unsigned int InqBeforeRpcTimeout,
  5540. IN unsigned int SetAfterRpc,
  5541. IN unsigned int SetAfterRpcTimeout,
  5542. IN unsigned int InqAfterRpc,
  5543. IN unsigned int InqAfterRpcTimeout
  5544. )
  5545. /*++
  5546. Routine Description:
  5547. Fitzgerald uses this routine to test the communications timeout
  5548. management routines, RpcMgmtInqComTimeout and RpcMgmtSetComTimeout.
  5549. Arguments:
  5550. SetBeforeRpc - Supplies a flag which, if it is non-zero, indicates that
  5551. the communications timeout should be set before making a remote
  5552. procedure call.
  5553. SetBeforeRpcTimeout - Supplies the timeout value to be set before
  5554. making a remote procedure call.
  5555. InqBeforeRpc - Supplies a flag which, if it is non-zero, indicates that
  5556. the communications timeout should be inquired before making a
  5557. remote procedure call.
  5558. InqBeforeRpcTimeout - Supplies the expected timeout value to be
  5559. inquired before making a remote procedure call.
  5560. SetAfterRpc - Supplies a flag which, if it is non-zero, indicates that
  5561. the communications timeout should be set after making a remote
  5562. procedure call.
  5563. SetAfterRpcTimeout - Supplies the timeout value to be set after
  5564. making a remote procedure call.
  5565. InqAfterRpc - Supplies a flag which, if it is non-zero, indicates that
  5566. the communications timeout should be inquired after making a
  5567. remote procedure call.
  5568. InqAfterRpcTimeout - Supplies the expected timeout value to be
  5569. inquired after making a remote procedure call.
  5570. Return Value:
  5571. Zero will be returned if all of the tests pass, otherwise, non-zero
  5572. will be returned.
  5573. --*/
  5574. {
  5575. RPC_BINDING_HANDLE BindingHandle;
  5576. unsigned int Timeout;
  5577. Status = GetBinding(FREDRICK, &BindingHandle);
  5578. if (Status)
  5579. {
  5580. ApiError("Fitzgerald","GetBinding",Status);
  5581. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5582. PrintToConsole(" (Fredrick)");
  5583. return(1);
  5584. }
  5585. if (SetBeforeRpc != 0)
  5586. {
  5587. Status = RpcMgmtSetComTimeout(BindingHandle,SetBeforeRpcTimeout);
  5588. if (Status)
  5589. {
  5590. ApiError("Fitzgerald","RpcMgmtSetComTimeout",Status);
  5591. PrintToConsole("Fitzgerald : FAIL - Error in");
  5592. PrintToConsole(" RpcMgmtSetComTimeout\n");
  5593. return(1);
  5594. }
  5595. }
  5596. if (InqBeforeRpc != 0)
  5597. {
  5598. Status = RpcMgmtInqComTimeout(BindingHandle,&Timeout);
  5599. if (Status)
  5600. {
  5601. ApiError("Fitzgerald","RpcMgmtInqComTimeout",Status);
  5602. PrintToConsole("Fitzgerald : FAIL - Error in");
  5603. PrintToConsole(" RpcMgmtInqComTimeout\n");
  5604. return(1);
  5605. }
  5606. if (Timeout != InqBeforeRpcTimeout)
  5607. {
  5608. PrintToConsole("Fitzgerald : FAIL - Timeout != ");
  5609. PrintToConsole("InqBeforeRpcTimeout\n");
  5610. return(1);
  5611. }
  5612. }
  5613. Helga(BindingHandle);
  5614. if (HelgaErrors != 0)
  5615. {
  5616. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5617. HelgaErrors = 0;
  5618. return(1);
  5619. }
  5620. if (SetAfterRpc != 0)
  5621. {
  5622. Status = RpcMgmtSetComTimeout(BindingHandle,SetAfterRpcTimeout);
  5623. if (Status)
  5624. {
  5625. ApiError("Fitzgerald","RpcMgmtSetComTimeout",Status);
  5626. PrintToConsole("Fitzgerald : FAIL - Error in");
  5627. PrintToConsole(" RpcMgmtSetComTimeout\n");
  5628. return(1);
  5629. }
  5630. }
  5631. if (InqAfterRpc != 0)
  5632. {
  5633. Status = RpcMgmtInqComTimeout(BindingHandle,&Timeout);
  5634. if (Status)
  5635. {
  5636. ApiError("Fitzgerald","RpcMgmtInqComTimeout",Status);
  5637. PrintToConsole("Fitzgerald : FAIL - Error in");
  5638. PrintToConsole(" RpcMgmtInqComTimeout\n");
  5639. return(1);
  5640. }
  5641. if (Timeout != InqAfterRpcTimeout)
  5642. {
  5643. PrintToConsole("Fitzgerald : FAIL - Timeout != ");
  5644. PrintToConsole("InqAfterRpcTimeout\n");
  5645. return(1);
  5646. }
  5647. }
  5648. Status = RpcBindingFree(&BindingHandle);
  5649. if (Status)
  5650. {
  5651. ApiError("Fitzgerald","RpcBindingFree",Status);
  5652. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5653. PrintToConsole(" (BindingHandle)\n");
  5654. return(1);
  5655. }
  5656. return(0);
  5657. }
  5658. int
  5659. FitzgeraldTestFault (
  5660. void
  5661. )
  5662. /*++
  5663. Routine Description:
  5664. This routine will test that faults get propogated correctly from the
  5665. server back to the client.
  5666. Return Value:
  5667. Zero will be returned if all of the tests pass, otherwise, non-zero
  5668. will be returned.
  5669. --*/
  5670. {
  5671. RPC_BINDING_HANDLE ExceptionBinding;
  5672. Status = GetBinding(FREDRICK, &ExceptionBinding);
  5673. if (Status)
  5674. {
  5675. ApiError("Fitzgerald","GetBinding",Status);
  5676. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5677. PrintToConsole(" (Fredrick)");
  5678. return(1);
  5679. }
  5680. Helga(ExceptionBinding);
  5681. if (IsabelleRaiseException(ExceptionBinding, (unsigned char) ulSecurityPackage) != (unsigned char) ulSecurityPackage)
  5682. {
  5683. PrintToConsole("Fitzgerald : FAIL - Exception Not Raised\n");
  5684. return(1);
  5685. }
  5686. Helga(ExceptionBinding);
  5687. if (HelgaErrors != 0)
  5688. {
  5689. PrintToConsole("Fitzgerald : FAIL - Error(s) in Helga Interface\n");
  5690. HelgaErrors = 0;
  5691. return(1);
  5692. }
  5693. if (IsabelleErrors != 0)
  5694. {
  5695. PrintToConsole("Fitzgerald : FAIL - Error(s) in Isabelle");
  5696. PrintToConsole(" Interface\n");
  5697. IsabelleErrors = 0;
  5698. return(1);
  5699. }
  5700. Status = RpcBindingFree(&ExceptionBinding);
  5701. if (Status)
  5702. {
  5703. ApiError("Fitzgerald","RpcBindingFree",Status);
  5704. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5705. PrintToConsole(" (ExceptionBinding)\n");
  5706. return(1);
  5707. }
  5708. return(0);
  5709. }
  5710. int
  5711. FitzgeraldContextHandle (
  5712. )
  5713. {
  5714. void PAPI * ContextHandle = 0;
  5715. RPC_BINDING_HANDLE BindingHandle;
  5716. unsigned long ContextUuid[5];
  5717. Status = GetBinding(FREDRICK, &BindingHandle);
  5718. if (Status)
  5719. {
  5720. ApiError("Fitzgerald","GetBinding",Status);
  5721. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5722. PrintToConsole(" (Fredrick)");
  5723. return(1);
  5724. }
  5725. Helga(BindingHandle);
  5726. ContextUuid[0] = 0;
  5727. ContextUuid[1] = 1;
  5728. ContextUuid[2] = 2;
  5729. ContextUuid[3] = 3;
  5730. ContextUuid[4] = 4;
  5731. NDRCContextUnmarshall(&ContextHandle, BindingHandle, ContextUuid,
  5732. 0x00L | 0x10L | 0x0000L);
  5733. Status = RpcBindingFree(&BindingHandle);
  5734. if (Status)
  5735. {
  5736. ApiError("Fitzgerald","RpcBindingFree",Status);
  5737. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5738. PrintToConsole(" (BindingHandle)\n");
  5739. return(1);
  5740. }
  5741. HelgaUsingContextHandle(ContextHandle);
  5742. RpcSsDestroyClientContext(&ContextHandle);
  5743. if ( ContextHandle != 0 )
  5744. {
  5745. PrintToConsole("Fitzgerald : FAIL - ContextHandle != 0\n");
  5746. return(1);
  5747. }
  5748. return(0);
  5749. }
  5750. void
  5751. Fitzgerald (
  5752. )
  5753. /*++
  5754. Routine Description:
  5755. We verify all client side APIs in this routine. The idea is to
  5756. emphasize complete coverage, rather than indepth coverage. Actually,
  5757. when I say all client side APIs, I really mean all client side APIs
  5758. except for security and name service. The following list is the
  5759. APIs which will be tested by this routine.
  5760. RpcBindingCopy
  5761. RpcBindingFree
  5762. RpcBindingFromStringBinding
  5763. RpcBindingInqObject
  5764. RpcBindingSetObject
  5765. RpcBindingToStringBinding
  5766. RpcStringBindingCompose
  5767. RpcStringBindingParse
  5768. RpcIfInqId
  5769. RpcNetworkIsProtseqValid
  5770. RpcMgmtInqComTimeout
  5771. RpcMgmtSetComTimeout
  5772. RpcStringFree
  5773. UuidToString
  5774. UuidFromString
  5775. --*/
  5776. {
  5777. RPC_BINDING_HANDLE IsabelleBinding;
  5778. RPC_IF_ID RpcIfId;
  5779. UUID Uuid;
  5780. unsigned char PAPI * String;
  5781. if ( NumberOfTestsRun++ )
  5782. {
  5783. PauseExecution(TestDelay);
  5784. }
  5785. Synchro(FREDRICK) ;
  5786. PrintToConsole("Fitzgerald : Verify All Client APIs\n");
  5787. if ( FitzgeraldContextHandle() != 0 )
  5788. {
  5789. return;
  5790. }
  5791. // Test that the routines to convert UUIDs to and from strings work
  5792. // correctly.
  5793. GenerateUuidValue(3768,&Uuid);
  5794. Status = UuidToStringA(&Uuid, &String);
  5795. if (Status)
  5796. {
  5797. ApiError("Fitzgerald", "UuidToString", Status);
  5798. PrintToConsole("Fitzgerald : FAIL - UuidToString\n");
  5799. return;
  5800. }
  5801. Status = UuidFromStringA(String, &Uuid);
  5802. if (Status)
  5803. {
  5804. ApiError("Fitzgerald", "UuidFromString", Status);
  5805. PrintToConsole("Fitzgerald : FAIL - UuidFromString\n");
  5806. return;
  5807. }
  5808. Status = RpcStringFreeA(&String);
  5809. if (Status)
  5810. {
  5811. ApiError("Fitzgerald", "RpcStringFree", Status);
  5812. PrintToConsole("Fitzgerald : FAIL - RpcStringFree\n");
  5813. return;
  5814. }
  5815. if ( CheckUuidValue(3768,&Uuid) != 0 )
  5816. {
  5817. OtherError("Fitzgerald", "CheckUuidValue() != 0");
  5818. PrintToConsole("Fitzgerald : FAIL - CheckUuidValue() != 0\n");
  5819. return;
  5820. }
  5821. Status = UuidFromString(0, &Uuid);
  5822. if (Status)
  5823. {
  5824. ApiError("Fitzgerald", "UuidFromString", Status);
  5825. PrintToConsole("Fitzgerald : FAIL - UuidFromString\n");
  5826. return;
  5827. }
  5828. if ( ( Uuid.Data1 != 0 )
  5829. || ( Uuid.Data2 != 0 )
  5830. || ( Uuid.Data3 != 0 )
  5831. || ( Uuid.Data4[0] != 0 )
  5832. || ( Uuid.Data4[1] != 0 )
  5833. || ( Uuid.Data4[2] != 0 )
  5834. || ( Uuid.Data4[3] != 0 )
  5835. || ( Uuid.Data4[4] != 0 )
  5836. || ( Uuid.Data4[5] != 0 )
  5837. || ( Uuid.Data4[6] != 0 )
  5838. || ( Uuid.Data4[7] != 0 ) )
  5839. {
  5840. OtherError("Fitzgerald", "Uuid != NIL UUID");
  5841. PrintToConsole("Fitzgerald : FAIL - Uuid != NIL UUID\n");
  5842. return;
  5843. }
  5844. // Test that a null protocol sequence causes RPC_S_INVALID_RPC_PROTSEQ
  5845. // to be returned rather than RPC_S_PROTSEQ_NOT_SUPPORTED.
  5846. Status = RpcBindingFromStringBindingA(
  5847. (unsigned char PAPI *) ":[\\\\pipe\\\\endpoint]",
  5848. &IsabelleBinding);
  5849. if (Status != RPC_S_INVALID_RPC_PROTSEQ)
  5850. {
  5851. ApiError("Fitzgerald","RpcBindingFromStringBinding",Status);
  5852. PrintToConsole("Fitzgerald : FAIL - RpcBindingFromStringBinding");
  5853. PrintToConsole(" did not fail with RPC_S_INVALID_RPC_PROTSEQ\n");
  5854. return;
  5855. }
  5856. Status = GetBinding(FREDRICK, &IsabelleBinding);
  5857. if (Status)
  5858. {
  5859. ApiError("Fitzgerald","GetBinding",Status);
  5860. PrintToConsole("Fitzgerald : FAIL - Unable to Bind");
  5861. PrintToConsole(" (Fredrick)");
  5862. return;
  5863. }
  5864. Status = RpcNsBindingInqEntryNameA(IsabelleBinding, RPC_C_NS_SYNTAX_DCE,
  5865. &String);
  5866. if ( Status != RPC_S_NO_ENTRY_NAME )
  5867. {
  5868. ApiError("Fitzgerald","RpcNsBindingInqEntryName",Status);
  5869. PrintToConsole("Fitzgerald : FAIL - RpcNsBindingInqEntryName");
  5870. PrintToConsole(" Did Not Fail");
  5871. return;
  5872. }
  5873. // This routine will test RpcStringBindingCompose,
  5874. // RpcStringBindingParse, RpcStringFree for us.
  5875. if (FitzgeraldComposeAndParse())
  5876. return;
  5877. // We test RpcBindingCopy here.
  5878. if (FitzgeraldBindingCopy())
  5879. return;
  5880. // This particular routine gets to test RpcBindingToStringBinding,
  5881. // RpcBindingInqObject, and RpcBindingSetObject.
  5882. if (FitzgeraldStringBindingAndObject())
  5883. return;
  5884. if (FitzgeraldComTimeout(0,0,1,RPC_C_BINDING_DEFAULT_TIMEOUT,
  5885. 0,0,1,RPC_C_BINDING_DEFAULT_TIMEOUT))
  5886. return;
  5887. if (FitzgeraldComTimeout(1,RPC_C_BINDING_MAX_TIMEOUT,
  5888. 1,RPC_C_BINDING_MAX_TIMEOUT,0,0,1,RPC_C_BINDING_MAX_TIMEOUT))
  5889. return;
  5890. if (FitzgeraldComTimeout(0,0,0,0,1,RPC_C_BINDING_MAX_TIMEOUT,
  5891. 1,RPC_C_BINDING_MAX_TIMEOUT))
  5892. return;
  5893. // We need to test faults. This is done by this routine.
  5894. if (FitzgeraldTestFault())
  5895. return;
  5896. Status = RpcBindingSetObject(IsabelleBinding, 0);
  5897. if (Status)
  5898. {
  5899. ApiError("Fitzgerald", "RpcBindingSetObject", Status);
  5900. PrintToConsole("Fitzgerald : FAIL - Unable to Set Object\n");
  5901. return;
  5902. }
  5903. IsabelleShutdown(IsabelleBinding);
  5904. if (IsabelleErrors != 0)
  5905. {
  5906. PrintToConsole("Fitzgerald : FAIL - Error(s) in Isabelle");
  5907. PrintToConsole(" Interface\n");
  5908. IsabelleErrors = 0;
  5909. return;
  5910. }
  5911. Status = RpcBindingFree(&IsabelleBinding);
  5912. if (Status)
  5913. {
  5914. ApiError("Fitzgerald","RpcBindingFree",Status);
  5915. PrintToConsole("Fitzgerald : FAIL - Unable to Free Binding");
  5916. PrintToConsole(" (IsabelleBinding)\n");
  5917. return;
  5918. }
  5919. Status = RpcIfInqId((RPC_IF_HANDLE) &IsabelleInterfaceInformation,
  5920. &RpcIfId);
  5921. if (Status)
  5922. {
  5923. ApiError("Fitzgerald","RpcIfInqId",Status);
  5924. PrintToConsole("Fitzgerald : FAIL - Error in RpcIfInqId\n");
  5925. return;
  5926. }
  5927. if ( (RpcIfId.VersMajor != 1)
  5928. || (RpcIfId.VersMinor != 1)
  5929. || (RpcIfId.Uuid.Data1 != 9)
  5930. || (RpcIfId.Uuid.Data2 != 8)
  5931. || (RpcIfId.Uuid.Data3 != 8)
  5932. || (RpcIfId.Uuid.Data4[0] != 7)
  5933. || (RpcIfId.Uuid.Data4[1] != 7)
  5934. || (RpcIfId.Uuid.Data4[2] != 7)
  5935. || (RpcIfId.Uuid.Data4[3] != 7)
  5936. || (RpcIfId.Uuid.Data4[4] != 7)
  5937. || (RpcIfId.Uuid.Data4[5] != 7)
  5938. || (RpcIfId.Uuid.Data4[6] != 7)
  5939. || (RpcIfId.Uuid.Data4[7] != 7))
  5940. {
  5941. PrintToConsole("Fitzgerald : FAIL - Wrong RpcIfId\n");
  5942. return;
  5943. }
  5944. Status = RpcNetworkIsProtseqValidA((unsigned char *) "ncacn_np");
  5945. if (Status)
  5946. {
  5947. ApiError("Fitzgerald","RpcNetworkIsProtseqValid",Status);
  5948. PrintToConsole("Fitzgerald : FAIL - RpcNetworkIsProtseqValid");
  5949. PrintToConsole(" Failed\n");
  5950. return;
  5951. }
  5952. Status = RpcNetworkIsProtseqValidA((unsigned char *) "nope_np");
  5953. if (Status != RPC_S_INVALID_RPC_PROTSEQ)
  5954. {
  5955. PrintToConsole("Fitzgerald : FAIL - RpcNetworkIsProtseqValid");
  5956. PrintToConsole(" != RPC_S_INVALID_RPC_PROTSEQ\n");
  5957. return;
  5958. }
  5959. Status = RpcNetworkIsProtseqValidA((unsigned char *) "ncacn_fail");
  5960. if (Status != RPC_S_PROTSEQ_NOT_SUPPORTED)
  5961. {
  5962. PrintToConsole("Fitzgerald : FAIL - RpcNetworkIsProtseqValid");
  5963. PrintToConsole(" != RPC_S_PROTSEQ_NOT_SUPPORTED\n");
  5964. return;
  5965. }
  5966. PrintToConsole("Fitzgerald : PASS\n");
  5967. }
  5968. void
  5969. Charles (
  5970. )
  5971. /*++
  5972. Routine Description:
  5973. This routine works with Christopher in usvr.exe to test all
  5974. server APIs (all except security and name service APIs).
  5975. --*/
  5976. {
  5977. RPC_BINDING_HANDLE ChristopherBinding;
  5978. RPC_BINDING_HANDLE ChristopherHelgaBinding;
  5979. RPC_BINDING_HANDLE ChristopherIsabelleBinding;
  5980. RPC_BINDING_HANDLE ChristopherHelgaNoEndpoint;
  5981. UUID ObjectUuid;
  5982. if ( NumberOfTestsRun++ )
  5983. {
  5984. PauseExecution(30000);
  5985. }
  5986. Synchro(CHRISTOPHER) ;
  5987. PrintToConsole("Charles : Verify All Server APIs\n");
  5988. Status = GetBinding(CHRISTOPHER, &ChristopherBinding);
  5989. if (Status)
  5990. {
  5991. ApiError("Charles","GetBinding",Status);
  5992. PrintToConsole("Charles : FAIL - Unable to Bind ");
  5993. PrintToConsole("(Christopher)\n");
  5994. return;
  5995. }
  5996. GenerateUuidValue(288, &ObjectUuid);
  5997. Status = RpcBindingSetObject(ChristopherBinding, &ObjectUuid);
  5998. if (Status)
  5999. {
  6000. ApiError("Charles", "RpcBindingSetObject", Status);
  6001. PrintToConsole("Charles : FAIL - Unable to Set Object\n");
  6002. return;
  6003. }
  6004. Status = GetBinding(CHRISTOPHERHELGA, &ChristopherHelgaBinding);
  6005. if (Status)
  6006. {
  6007. ApiError("Charles","GetBinding",Status);
  6008. PrintToConsole("Charles : FAIL - Unable to Bind ");
  6009. PrintToConsole("(ChristopherHelga)\n");
  6010. return;
  6011. }
  6012. GenerateUuidValue(288, &ObjectUuid);
  6013. Status = RpcBindingSetObject(ChristopherHelgaBinding, &ObjectUuid);
  6014. if (Status)
  6015. {
  6016. ApiError("Charles", "RpcBindingSetObject", Status);
  6017. PrintToConsole("Charles : FAIL - Unable to Set Object\n");
  6018. return;
  6019. }
  6020. Status = GetBinding(CHRISTOPHERISABELLE, &ChristopherIsabelleBinding);
  6021. if (Status)
  6022. {
  6023. ApiError("Charles","GetBinding",Status);
  6024. PrintToConsole("Charles : FAIL - Unable to Bind ");
  6025. PrintToConsole("(ChristopherIsabelle)\n");
  6026. return;
  6027. }
  6028. GenerateUuidValue(288, &ObjectUuid);
  6029. Status = RpcBindingSetObject(ChristopherIsabelleBinding, &ObjectUuid);
  6030. if (Status)
  6031. {
  6032. ApiError("Charles", "RpcBindingSetObject", Status);
  6033. PrintToConsole("Charles : FAIL - Unable to Set Object\n");
  6034. return;
  6035. }
  6036. Status = GetBinding(NOENDPOINT, &ChristopherHelgaNoEndpoint);
  6037. if (Status)
  6038. {
  6039. ApiError("Charles","GetBinding",Status);
  6040. PrintToConsole("Charles : FAIL - Unable to Bind ");
  6041. PrintToConsole("(ChristopherHelgaNoEndpoint)\n");
  6042. return;
  6043. }
  6044. GenerateUuidValue(288, &ObjectUuid);
  6045. Status = RpcBindingSetObject(ChristopherHelgaNoEndpoint, &ObjectUuid);
  6046. if (Status)
  6047. {
  6048. ApiError("Charles", "RpcBindingSetObject", Status);
  6049. PrintToConsole("Charles : FAIL - Unable to Set Object\n");
  6050. return;
  6051. }
  6052. SylviaBinding = ChristopherBinding;
  6053. if (SylviaCall(ChristopherBinding,10,5,0) != LocalSylviaCall(10,5,0))
  6054. {
  6055. PrintToConsole("Charles : FAIL - Incorrect result from");
  6056. PrintToConsole(" SylviaCall(10,5,0)\n");
  6057. return;
  6058. }
  6059. SylviaBinding = ChristopherHelgaBinding;
  6060. if (SylviaCall(ChristopherHelgaBinding,10,5,0)
  6061. != LocalSylviaCall(10,5,0))
  6062. {
  6063. PrintToConsole("Charles : FAIL - Incorrect result from");
  6064. PrintToConsole(" SylviaCall(10,5,0)\n");
  6065. return;
  6066. }
  6067. SylviaBinding = ChristopherIsabelleBinding;
  6068. if (SylviaCall(ChristopherIsabelleBinding,10,5,0)
  6069. != LocalSylviaCall(10,5,0))
  6070. {
  6071. PrintToConsole("Charles : FAIL - Incorrect result from");
  6072. PrintToConsole(" SylviaCall(10,5,0)\n");
  6073. return;
  6074. }
  6075. IsabelleToStringBinding(ChristopherBinding);
  6076. IsabelleToStringBinding(ChristopherIsabelleBinding);
  6077. IsabelleToStringBinding(ChristopherHelgaBinding);
  6078. TestHelgaInterface(ChristopherHelgaNoEndpoint, HelgaMaxSize);
  6079. Status = RpcBindingReset(ChristopherHelgaNoEndpoint);
  6080. if (Status)
  6081. {
  6082. ApiError("Charles", "RpcBindingReset", Status);
  6083. PrintToConsole("Charles : FAIL - Unable to Reset");
  6084. PrintToConsole(" (ChristopherHelgaNoEndpoint)\n");
  6085. return;
  6086. }
  6087. Helga(ChristopherHelgaNoEndpoint);
  6088. Status = RpcBindingReset(ChristopherHelgaNoEndpoint);
  6089. if (Status)
  6090. {
  6091. ApiError("Charles", "RpcBindingReset", Status);
  6092. PrintToConsole("Charles : FAIL - Unable to Reset");
  6093. PrintToConsole(" (ChristopherHelgaNoEndpoint)\n");
  6094. return;
  6095. }
  6096. Helga(ChristopherHelgaNoEndpoint);
  6097. Status = RpcBindingReset(ChristopherHelgaNoEndpoint);
  6098. if (Status)
  6099. {
  6100. ApiError("Charles", "RpcBindingReset", Status);
  6101. PrintToConsole("Charles : FAIL - Unable to Reset");
  6102. PrintToConsole(" (ChristopherHelgaNoEndpoint)\n");
  6103. return;
  6104. }
  6105. IsabelleShutdown(ChristopherBinding);
  6106. // We need an extra delay in here because Christopher performs some
  6107. // other tests after RpcServerListen returns.
  6108. PauseExecution(LONG_TESTDELAY);
  6109. if (HelgaErrors != 0)
  6110. {
  6111. PrintToConsole("Charles : FAIL - Error(s) in Helga Interface\n");
  6112. HelgaErrors = 0;
  6113. return;
  6114. }
  6115. if (IsabelleErrors != 0)
  6116. {
  6117. PrintToConsole("Charles : FAIL - Error(s) in Isabelle Interface\n");
  6118. IsabelleErrors = 0;
  6119. return;
  6120. }
  6121. if (SylviaErrors != 0)
  6122. {
  6123. PrintToConsole("Charles : FAIL - Error(s) in Sylvia Interface\n");
  6124. SylviaErrors = 0;
  6125. return;
  6126. }
  6127. Status = RpcBindingFree(&ChristopherHelgaBinding);
  6128. if (Status)
  6129. {
  6130. ApiError("Charles","RpcBindingFree",Status);
  6131. PrintToConsole("Charles : FAIL - Unable to Free Binding");
  6132. PrintToConsole(" (ChristopherHelgaBinding)\n");
  6133. return;
  6134. }
  6135. Status = RpcBindingFree(&ChristopherBinding);
  6136. if (Status)
  6137. {
  6138. ApiError("Charles","RpcBindingFree",Status);
  6139. PrintToConsole("Charles : FAIL - Unable to Free Binding");
  6140. PrintToConsole(" (ChristopherBinding)\n");
  6141. return;
  6142. }
  6143. Status = RpcBindingFree(&ChristopherHelgaNoEndpoint);
  6144. if (Status)
  6145. {
  6146. ApiError("Charles","RpcBindingFree",Status);
  6147. PrintToConsole("Charles : FAIL - Unable to Free Binding");
  6148. PrintToConsole(" (ChristopherHelgaNoEndpoint)\n");
  6149. return;
  6150. }
  6151. Status = RpcBindingFree(&ChristopherIsabelleBinding);
  6152. if (Status)
  6153. {
  6154. ApiError("Charles","RpcBindingFree",Status);
  6155. PrintToConsole("Charles : FAIL - Unable to Free Binding");
  6156. PrintToConsole(" (ChristopherIsabelleBinding)\n");
  6157. return;
  6158. }
  6159. PrintToConsole("Charles : PASS\n");
  6160. }
  6161. int
  6162. ThomasNtSecurity
  6163. (
  6164. IN char * NetworkOptions
  6165. )
  6166. /*++
  6167. Routine Description:
  6168. Thomas uses this routine to test NT security and RPC.
  6169. Arguments:
  6170. NetworkOptions - Supplies the network options to be used for the
  6171. binding.
  6172. Return Value:
  6173. Zero will be returned if the test completes successfully, otherwise,
  6174. non-zero will be returned.
  6175. --*/
  6176. {
  6177. RPC_BINDING_HANDLE ThomasNormalBinding;
  6178. Status = RpcBindingFromStringBindingA(
  6179. GetStringBinding(TYLER,0,(unsigned char *) NetworkOptions),
  6180. &ThomasNormalBinding);
  6181. if (Status)
  6182. {
  6183. ApiError("Thomas","RpcBindingFromStringBinding",Status);
  6184. PrintToConsole("Thomas : FAIL - Unable to Bind (Tyler)\n");
  6185. return(1);
  6186. }
  6187. IsabelleNtSecurity(ThomasNormalBinding,
  6188. strlen((char *) NetworkOptions) + 1, NetworkOptions);
  6189. if (IsabelleErrors != 0)
  6190. {
  6191. PrintToConsole("Thomas : FAIL - Error(s) in Isabelle Interface\n");
  6192. IsabelleErrors = 0;
  6193. return(1);
  6194. }
  6195. Status = RpcBindingFree(&ThomasNormalBinding);
  6196. if (Status)
  6197. {
  6198. ApiError("Thomas","RpcBindingFree",Status);
  6199. PrintToConsole("Thomas : FAIL - Unable to Free Binding");
  6200. PrintToConsole(" (ThomasNormalBinding)\n");
  6201. return(1);
  6202. }
  6203. return(0);
  6204. }
  6205. int
  6206. ThomasTestNtSecurity (
  6207. )
  6208. /*++
  6209. Routine Description:
  6210. This helper routine tests NT security (such as over named pipes and
  6211. lpc).
  6212. Return Value:
  6213. A non-zero return value indicates that the test failed.
  6214. --*/
  6215. {
  6216. if (ThomasNtSecurity("") != 0)
  6217. return(1);
  6218. if (ThomasNtSecurity("Security=Identification Dynamic True") != 0)
  6219. return(1);
  6220. if (ThomasNtSecurity("Security=Identification Static True") != 0)
  6221. return(1);
  6222. if (ThomasNtSecurity("Security=Identification Dynamic False") != 0)
  6223. return(1);
  6224. if (ThomasNtSecurity("Security=Identification Static False") != 0)
  6225. return(1);
  6226. if (ThomasNtSecurity("Security=Anonymous Dynamic True") != 0)
  6227. return(1);
  6228. if (ThomasNtSecurity("Security=Anonymous Static True") != 0)
  6229. return(1);
  6230. if (ThomasNtSecurity("Security=Anonymous Dynamic False") != 0)
  6231. return(1);
  6232. if (ThomasNtSecurity("Security=Anonymous Static False") != 0)
  6233. return(1);
  6234. if (ThomasNtSecurity("Security=Impersonation Dynamic True") != 0)
  6235. return(1);
  6236. if (ThomasNtSecurity("Security=Impersonation Static True") != 0)
  6237. return(1);
  6238. if (ThomasNtSecurity("Security=Impersonation Dynamic False") != 0)
  6239. return(1);
  6240. if (ThomasNtSecurity("Security=Impersonation Static False") != 0)
  6241. return(1);
  6242. return(0);
  6243. }
  6244. int
  6245. ThomasInqSetAuthInfo (
  6246. IN unsigned char PAPI * ServerPrincName,
  6247. IN unsigned long AuthnLevel,
  6248. IN unsigned long AuthnSvc,
  6249. IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity,
  6250. IN unsigned long AuthzSvc,
  6251. IN RPC_STATUS ExpectedResult,
  6252. IN unsigned long ExpectedAuthnLevel
  6253. )
  6254. /*++
  6255. Routine Description:
  6256. We test RpcBindingSetAuthInfo and RpcBindingInqAuthInfo in this
  6257. routine.
  6258. Arguments:
  6259. ServerPrincName - Supplies the server principal name to use.
  6260. AuthnLevel - Supplies the authentication level to use.
  6261. AuthnSvc - Supplies the authentication service to use.
  6262. AuthIdentity - Supplies the security context to use.
  6263. AuthzSvc - Supplies the authorization service to use.
  6264. ExpectedResult - Supplies the result expected from RpcBindingSetAuthInfo.
  6265. ExpectedAuthnLevel - Supplies the expected authentication level to
  6266. be obtained from RpcBindingSetAuthInfo.
  6267. Return Value:
  6268. A non-zero result indicates that the test failed.
  6269. --*/
  6270. {
  6271. RPC_BINDING_HANDLE BindingHandle;
  6272. unsigned long AuthenticationLevel;
  6273. unsigned long AuthenticationService;
  6274. unsigned long AuthorizationService;
  6275. unsigned char IgnoreString[4];
  6276. Status = GetBinding(TYLER, &BindingHandle);
  6277. if (Status)
  6278. {
  6279. ApiError("Thomas", "GetBinding", Status);
  6280. PrintToConsole("Thomas : FAIL - Unable to Bind (Tyler)\n");
  6281. return(1);
  6282. }
  6283. if (gPrincName)
  6284. {
  6285. ServerPrincName = (unsigned char *)gPrincName;
  6286. }
  6287. Status = RpcBindingSetAuthInfoA(BindingHandle, ServerPrincName, AuthnLevel,
  6288. AuthnSvc, AuthIdentity, AuthzSvc);
  6289. if ( Status != ExpectedResult )
  6290. {
  6291. ApiError("Thomas", "RpcBindingSetAuthInfo", Status);
  6292. PrintToConsole("Thomas : FAIL - RpcBindingSetAuthInfo, Unexpected");
  6293. PrintToConsole(" Result\n");
  6294. return(1);
  6295. }
  6296. if (Status)
  6297. {
  6298. return(0);
  6299. }
  6300. Status = RpcBindingInqAuthInfo(BindingHandle, 0, &AuthenticationLevel,
  6301. &AuthenticationService, 0, &AuthorizationService);
  6302. if (Status)
  6303. {
  6304. ApiError("Thomas", "RpcBindingInqAuthInfo", Status);
  6305. PrintToConsole("Thomas : FAIL - RpcBindingInqAuthInfo\n");
  6306. return(1);
  6307. }
  6308. if ( AuthenticationLevel != ExpectedAuthnLevel )
  6309. {
  6310. PrintToConsole("Thomas : WARNING - ");
  6311. PrintToConsole("AuthenticationLevel != ExpectedAuthnLevel\n");
  6312. }
  6313. if ( AuthenticationService != AuthnSvc )
  6314. {
  6315. OtherError("Thomas", "AuthenticationService != AuthnSvc");
  6316. PrintToConsole("Thomas : FAIL - RpcBindingInqAuthInfo\n");
  6317. return(1);
  6318. }
  6319. if ( AuthorizationService != AuthzSvc )
  6320. {
  6321. OtherError("Thomas", "AuthorizationService != AuthzSvc");
  6322. PrintToConsole("Thomas : FAIL - RpcBindingInqAuthInfo\n");
  6323. return(1);
  6324. }
  6325. TestHelgaInterface(BindingHandle, HelgaMaxSize);
  6326. IsabelleNtSecurity(BindingHandle, 1, IgnoreString);
  6327. Status = RpcBindingFree(&BindingHandle);
  6328. if (Status)
  6329. {
  6330. ApiError("Thomas","RpcBindingFree",Status);
  6331. PrintToConsole("Thomas : FAIL - Unable to Free Binding");
  6332. PrintToConsole(" (BindingHandle)\n");
  6333. return(1);
  6334. }
  6335. return(0);
  6336. }
  6337. int
  6338. ThomasTestRpcSecurity (BOOL fServerIsNTSystem
  6339. )
  6340. /*++
  6341. Routine Description:
  6342. This routine exercises rpc protocol level security support in the
  6343. runtime.
  6344. Return Value:
  6345. A non-zero return value indicates that the test failed.
  6346. --*/
  6347. {
  6348. RPC_AUTH_IDENTITY_HANDLE AuthId = NULL;
  6349. OSVERSIONINFO versionInfo;
  6350. if(ulSecurityPackage == 123)
  6351. AuthId = 0 ;
  6352. // if platform is Win98 and transport is MSMQ, no point of doing security tests
  6353. // Falcon will try to upgrade connection level authentication to packet, which in turn
  6354. // will be rejected by the security system. The only possible connection is not authenticated
  6355. if (TransportType == RPC_TRANSPORT_MSMQ)
  6356. {
  6357. memset(&versionInfo, 0, sizeof(versionInfo));
  6358. versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
  6359. GetVersionEx(&versionInfo);
  6360. if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
  6361. return 0;
  6362. }
  6363. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6364. RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage, AuthId , 0, RPC_S_OK,
  6365. RPC_C_AUTHN_LEVEL_CONNECT) != 0 )
  6366. {
  6367. return(1);
  6368. }
  6369. if(ulSecurityPackage == 123)
  6370. {
  6371. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage,
  6372. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6373. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_CONNECT) != 0 )
  6374. {
  6375. return(1);
  6376. }
  6377. }
  6378. if (!fServerIsNTSystem)
  6379. return 0;
  6380. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6381. RPC_C_AUTHN_LEVEL_CALL, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6382. RPC_C_AUTHN_LEVEL_PKT) != 0 )
  6383. {
  6384. return(1);
  6385. }
  6386. if(ulSecurityPackage == 123)
  6387. {
  6388. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_CALL, ulSecurityPackage,
  6389. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6390. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT) != 0 )
  6391. {
  6392. return(1);
  6393. }
  6394. }
  6395. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6396. RPC_C_AUTHN_LEVEL_PKT, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6397. RPC_C_AUTHN_LEVEL_PKT) != 0 )
  6398. {
  6399. return(1);
  6400. }
  6401. if(ulSecurityPackage == 123)
  6402. {
  6403. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT, ulSecurityPackage,
  6404. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6405. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT) != 0 )
  6406. {
  6407. return(1);
  6408. }
  6409. }
  6410. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6411. RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6412. RPC_C_AUTHN_LEVEL_PKT_INTEGRITY) != 0 )
  6413. {
  6414. return(1);
  6415. }
  6416. if(ulSecurityPackage == 123)
  6417. {
  6418. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, ulSecurityPackage,
  6419. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6420. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_INTEGRITY) != 0 )
  6421. {
  6422. return(1);
  6423. }
  6424. }
  6425. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6426. RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ulSecurityPackage, AuthId , 0, RPC_S_OK,
  6427. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6428. {
  6429. return(1);
  6430. }
  6431. if(ulSecurityPackage == 123)
  6432. {
  6433. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ulSecurityPackage,
  6434. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6435. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6436. {
  6437. return(1);
  6438. }
  6439. }
  6440. return(0);
  6441. }
  6442. #ifdef WIN32RPC
  6443. int
  6444. ThomasTestLRpcSecurity (
  6445. )
  6446. /*++
  6447. Routine Description:
  6448. This routine exercises rpc protocol level security support in the
  6449. runtime.
  6450. Return Value:
  6451. A non-zero return value indicates that the test failed.
  6452. --*/
  6453. {
  6454. SEC_WINNT_AUTH_IDENTITY ntssp;
  6455. RPC_AUTH_IDENTITY_HANDLE AuthId = &ntssp;
  6456. ntssp.User = (RPC_CHAR *) SecurityUser;
  6457. if (ntssp.User)
  6458. {
  6459. ntssp.UserLength = lstrlen((const RPC_SCHAR *) SecurityUser);
  6460. }
  6461. else
  6462. {
  6463. ntssp.UserLength = 0;
  6464. }
  6465. ntssp.Domain = (RPC_CHAR *) SecurityDomain;
  6466. if (ntssp.Domain)
  6467. {
  6468. ntssp.DomainLength = lstrlen((const RPC_SCHAR *) SecurityDomain);
  6469. }
  6470. else
  6471. {
  6472. ntssp.DomainLength = 0;
  6473. }
  6474. ntssp.Password = (RPC_CHAR *) SecurityPassword;
  6475. if (ntssp.Password)
  6476. {
  6477. ntssp.PasswordLength = lstrlen((const RPC_SCHAR *) SecurityPassword);
  6478. }
  6479. else
  6480. {
  6481. ntssp.PasswordLength = 0;
  6482. }
  6483. ntssp.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
  6484. // LRPC can only use 10
  6485. ulSecurityPackage = 10 ;
  6486. unsigned long size = 256;
  6487. char UserName[256];
  6488. char Tmp[256];
  6489. //
  6490. // hack
  6491. //
  6492. strcpy(UserName, "redmond\\");
  6493. if (GetUserNameA(Tmp, &size) == 0)
  6494. {
  6495. return (1);
  6496. }
  6497. strcat(UserName, Tmp);
  6498. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) UserName,
  6499. RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage, AuthId , 0, RPC_S_OK,
  6500. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6501. {
  6502. return(1);
  6503. }
  6504. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage,
  6505. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6506. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6507. {
  6508. return(1);
  6509. }
  6510. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) UserName,
  6511. RPC_C_AUTHN_LEVEL_CALL, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6512. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6513. {
  6514. return(1);
  6515. }
  6516. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_CALL, ulSecurityPackage,
  6517. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6518. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6519. {
  6520. return(1);
  6521. }
  6522. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) UserName,
  6523. RPC_C_AUTHN_LEVEL_PKT, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6524. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6525. {
  6526. return(1);
  6527. }
  6528. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT, ulSecurityPackage,
  6529. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6530. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6531. {
  6532. return(1);
  6533. }
  6534. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) UserName,
  6535. RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6536. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6537. {
  6538. return(1);
  6539. }
  6540. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT_INTEGRITY, ulSecurityPackage,
  6541. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6542. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6543. {
  6544. return(1);
  6545. }
  6546. if ( ThomasInqSetAuthInfo((unsigned char PAPI *) UserName,
  6547. RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ulSecurityPackage, AuthId , 0, RPC_S_OK,
  6548. RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6549. {
  6550. return(1);
  6551. }
  6552. if ( ThomasInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, ulSecurityPackage,
  6553. (RPC_AUTH_IDENTITY_HANDLE) RPC_CONST_STRING("ClientPrincipal"),
  6554. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_PKT_PRIVACY) != 0 )
  6555. {
  6556. return(1);
  6557. }
  6558. return(0);
  6559. }
  6560. #endif
  6561. void
  6562. Thomas (
  6563. )
  6564. /*++
  6565. Routine Description:
  6566. This routine is used to test security, both at the transport level,
  6567. and at the RPC level. We work with Tyler in usvr.exe.
  6568. --*/
  6569. {
  6570. RPC_BINDING_HANDLE IsabelleBinding;
  6571. BOOL fServerIsNTSystem;
  6572. Synchro(TYLER) ;
  6573. if ( NumberOfTestsRun++ )
  6574. {
  6575. PauseExecution(TestDelay);
  6576. }
  6577. PrintToConsole("Thomas : Test Security\n");
  6578. Status = GetBinding(TYLER, &IsabelleBinding);
  6579. if (Status)
  6580. {
  6581. ApiError("Thomas","GetBinding",Status);
  6582. PrintToConsole("Thomas : FAIL - Unable to Bind (Tyler)\n");
  6583. return;
  6584. }
  6585. fServerIsNTSystem = IsServerNTSystem(IsabelleBinding);
  6586. // change here to test rpc security for LRPC also
  6587. if(TransportType != RPC_LRPC)
  6588. {
  6589. if ( ThomasTestRpcSecurity(fServerIsNTSystem) != 0 )
  6590. {
  6591. return;
  6592. }
  6593. }
  6594. if ( TransportType == RPC_TRANSPORT_NAMEPIPE || TransportType == RPC_LRPC )
  6595. {
  6596. if ( ThomasTestNtSecurity() != 0 )
  6597. {
  6598. return;
  6599. }
  6600. }
  6601. IsabelleShutdown(IsabelleBinding);
  6602. if (IsabelleErrors != 0)
  6603. {
  6604. PrintToConsole("Thomas : FAIL - Error(s) in Isabelle Interface\n");
  6605. IsabelleErrors = 0;
  6606. return;
  6607. }
  6608. Status = RpcBindingFree(&IsabelleBinding);
  6609. if (Status)
  6610. {
  6611. ApiError("Thomas","RpcBindingFree",Status);
  6612. PrintToConsole("Thomas : FAIL - Unable to Free Binding");
  6613. PrintToConsole(" (IsabelleBinding)\n");
  6614. return;
  6615. }
  6616. PrintToConsole("Thomas : PASS\n");
  6617. }
  6618. int
  6619. TimInqSetAuthInfo (
  6620. IN unsigned char PAPI * ServerPrincName,
  6621. IN unsigned long AuthnLevel,
  6622. IN unsigned long AuthnSvc,
  6623. IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity,
  6624. IN unsigned long AuthzSvc,
  6625. IN RPC_STATUS ExpectedResult,
  6626. IN unsigned long ExpectedAuthnLevel
  6627. )
  6628. /*++
  6629. Routine Description:
  6630. We test RpcBindingSetAuthInfo and RpcBindingInqAuthInfo in this
  6631. routine.
  6632. Arguments:
  6633. ServerPrincName - Supplies the server principal name to use.
  6634. AuthnLevel - Supplies the authentication level to use.
  6635. AuthnSvc - Supplies the authentication service to use.
  6636. AuthIdentity - Supplies the security context to use.
  6637. AuthzSvc - Supplies the authorization service to use.
  6638. ExpectedResult - Supplies the result expected from RpcBindingSetAuthInfo.
  6639. ExpectedAuthnLevel - Supplies the expected authentication level to
  6640. be obtained from RpcBindingSetAuthInfo.
  6641. Return Value:
  6642. A non-zero result indicates that the test failed.
  6643. --*/
  6644. {
  6645. RPC_BINDING_HANDLE BindingHandle;
  6646. unsigned long AuthenticationLevel;
  6647. unsigned long AuthenticationService;
  6648. unsigned long AuthorizationService;
  6649. unsigned char IgnoreString[4];
  6650. Status = GetBinding(TYLER, &BindingHandle);
  6651. if (Status)
  6652. {
  6653. ApiError("Tim", "GetBinding", Status);
  6654. PrintToConsole("Tim : FAIL - Unable to Bind (Tyler)\n");
  6655. return(1);
  6656. }
  6657. Status = RpcBindingSetAuthInfoA(BindingHandle, ServerPrincName, AuthnLevel,
  6658. AuthnSvc, AuthIdentity, AuthzSvc);
  6659. if ( Status != ExpectedResult )
  6660. {
  6661. ApiError("Tim", "RpcBindingSetAuthInfo", Status);
  6662. PrintToConsole("Tim : FAIL - RpcBindingSetAuthInfo, Unexpected");
  6663. PrintToConsole(" Result\n");
  6664. return(1);
  6665. }
  6666. if (Status)
  6667. {
  6668. return(0);
  6669. }
  6670. Status = RpcBindingInqAuthInfo(BindingHandle, 0, &AuthenticationLevel,
  6671. &AuthenticationService, 0, &AuthorizationService);
  6672. if (Status)
  6673. {
  6674. ApiError("Tim", "RpcBindingInqAuthInfo", Status);
  6675. PrintToConsole("Tim : FAIL - RpcBindingInqAuthInfo\n");
  6676. return(1);
  6677. }
  6678. if ( AuthenticationLevel != ExpectedAuthnLevel )
  6679. {
  6680. PrintToConsole("Tim : WARNING - ");
  6681. PrintToConsole("AuthenticationLevel != ExpectedAuthnLevel\n");
  6682. }
  6683. if ( AuthenticationService != AuthnSvc )
  6684. {
  6685. OtherError("Tim", "AuthenticationService != AuthnSvc");
  6686. PrintToConsole("Tim : FAIL - RpcBindingInqAuthInfo\n");
  6687. return(1);
  6688. }
  6689. if ( AuthorizationService != AuthzSvc )
  6690. {
  6691. OtherError("Tim", "AuthorizationService != AuthzSvc");
  6692. PrintToConsole("Tim : FAIL - RpcBindingInqAuthInfo\n");
  6693. return(1);
  6694. }
  6695. TestHelgaInterface(BindingHandle, HelgaMaxSize);
  6696. IsabelleNtSecurity(BindingHandle, 1, IgnoreString);
  6697. Status = RpcBindingFree(&BindingHandle);
  6698. if (Status)
  6699. {
  6700. ApiError("Tim","RpcBindingFree",Status);
  6701. PrintToConsole("Tim : FAIL - Unable to Free Binding");
  6702. PrintToConsole(" (BindingHandle)\n");
  6703. return(1);
  6704. }
  6705. return(0);
  6706. }
  6707. int
  6708. TimTestRpcSecurity (
  6709. )
  6710. /*++
  6711. Routine Description:
  6712. This routine exercises rpc protocol level security support in the
  6713. runtime.
  6714. Return Value:
  6715. A non-zero return value indicates that the test failed.
  6716. --*/
  6717. {
  6718. RPC_AUTH_IDENTITY_HANDLE AuthId = NULL;
  6719. // RPC_C_AUTHN_WINNT to ulSecurityPackage in the intrest of generality
  6720. if ( TimInqSetAuthInfo((unsigned char PAPI *) "ServerPrincipal",
  6721. RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage, AuthId, 0, RPC_S_OK,
  6722. RPC_C_AUTHN_LEVEL_CONNECT) != 0 )
  6723. {
  6724. return(1);
  6725. }
  6726. // RPC_C_AUTHN_WINNT to ulSecurityPackage in the intrest of generality
  6727. if ( TimInqSetAuthInfo(0, RPC_C_AUTHN_LEVEL_CONNECT, ulSecurityPackage,
  6728. AuthId,
  6729. 0, RPC_S_OK, RPC_C_AUTHN_LEVEL_CONNECT) != 0 )
  6730. {
  6731. return(1);
  6732. }
  6733. return(0);
  6734. }
  6735. void
  6736. Tim (
  6737. )
  6738. /*++
  6739. Routine Description:
  6740. This routine is used to test security, both at the transport level,
  6741. and at the RPC level. We work with Terry in usvr.exe.
  6742. --*/
  6743. {
  6744. RPC_BINDING_HANDLE IsabelleBinding;
  6745. Synchro(TYLER) ;
  6746. if ( NumberOfTestsRun++ )
  6747. {
  6748. PauseExecution(TestDelay);
  6749. }
  6750. PrintToConsole("Tim : Test Security\n");
  6751. Status = GetBinding(TYLER, &IsabelleBinding);
  6752. if (Status)
  6753. {
  6754. ApiError("Tim","GetBinding",Status);
  6755. PrintToConsole("Tim : FAIL - Unable to Bind (Tyler)\n");
  6756. return;
  6757. }
  6758. if ( TransportType != RPC_LRPC )
  6759. {
  6760. if ( TimTestRpcSecurity() != 0 )
  6761. {
  6762. return;
  6763. }
  6764. }
  6765. IsabelleShutdown(IsabelleBinding);
  6766. if (IsabelleErrors != 0)
  6767. {
  6768. PrintToConsole("Tim : FAIL - Error(s) in Isabelle Interface\n");
  6769. IsabelleErrors = 0;
  6770. return;
  6771. }
  6772. Status = RpcBindingFree(&IsabelleBinding);
  6773. if (Status)
  6774. {
  6775. ApiError("Tim","RpcBindingFree",Status);
  6776. PrintToConsole("Tim : FAIL - Unable to Free Binding");
  6777. PrintToConsole(" (IsabelleBinding)\n");
  6778. return;
  6779. }
  6780. PrintToConsole("Tim : PASS\n");
  6781. }
  6782. void
  6783. Robert (
  6784. )
  6785. /*++
  6786. Routine Description:
  6787. Robert works with Richard (in usvr.cxx) to test call and callback
  6788. failures.
  6789. --*/
  6790. {
  6791. RPC_BINDING_HANDLE RichardBinding;
  6792. RPC_BINDING_HANDLE RichardHelperBinding;
  6793. unsigned int RetryCount;
  6794. Synchro(RICHARD) ;
  6795. if ( NumberOfTestsRun++ )
  6796. {
  6797. PauseExecution(TestDelay);
  6798. }
  6799. PrintToConsole("Robert : Test Call and Callback Failures\n");
  6800. Status = GetBinding(RICHARD, &RichardBinding);
  6801. if (Status)
  6802. {
  6803. ApiError("Robert","GetBinding",Status);
  6804. PrintToConsole("Robert : FAIL - Unable to Bind (Richard)\n");
  6805. return;
  6806. }
  6807. Status = GetBinding(RICHARDHELPER, &RichardHelperBinding);
  6808. if (Status)
  6809. {
  6810. ApiError("Robert","GetBinding",Status);
  6811. PrintToConsole("Robert : FAIL - Unable to Bind (RichardHelper)\n");
  6812. return;
  6813. }
  6814. Status = IsabelleRichardHelper(RichardBinding,RICHARDHELPER_EXECUTE);
  6815. if (Status != RPC_S_OK)
  6816. {
  6817. ApiError("Robert","IsabelleRichardHelper",Status);
  6818. PrintToConsole("Robert : FAIL - ");
  6819. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXECUTE)\n");
  6820. return;
  6821. }
  6822. // PauseExecution(30000L);
  6823. Synchro(RICHARDHELPER) ;
  6824. for (RetryCount = 0; RetryCount < RETRYCOUNT; RetryCount++)
  6825. {
  6826. Status = IsabelleRichardHelper(RichardHelperBinding,
  6827. RICHARDHELPER_IGNORE);
  6828. if (Status == RPC_S_OK)
  6829. break;
  6830. PauseExecution(RETRYDELAY);
  6831. }
  6832. if (Status != RPC_S_OK)
  6833. {
  6834. ApiError("Robert","IsabelleRichardHelper",Status);
  6835. PrintToConsole("Robert : FAIL - ");
  6836. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_IGNORE)\n");
  6837. return;
  6838. }
  6839. Status = IsabelleRichardHelper(RichardHelperBinding, RICHARDHELPER_EXIT);
  6840. if (Status == RPC_S_OK)
  6841. {
  6842. PrintToConsole("Robert : FAIL - ");
  6843. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXIT) ");
  6844. PrintToConsole("Succeeded\n");
  6845. return;
  6846. }
  6847. if (Status != RPC_S_CALL_FAILED)
  6848. {
  6849. PrintToConsole("Robert : WARN - ");
  6850. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXIT) != ");
  6851. PrintToConsole("RPC_S_CALL_FAILED\n");
  6852. }
  6853. PauseExecution(TestDelay);
  6854. Status = IsabelleRichardHelper(RichardHelperBinding,RICHARDHELPER_IGNORE);
  6855. if (Status == RPC_S_OK)
  6856. {
  6857. PrintToConsole("Robert : FAIL - ");
  6858. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_IGNORE) ");
  6859. PrintToConsole("Succeeded\n");
  6860. return;
  6861. }
  6862. PrintToConsole("Robert : Spawning RichardHelper again\n") ;
  6863. Status = IsabelleRichardHelper(RichardBinding,RICHARDHELPER_EXECUTE);
  6864. if (Status != RPC_S_OK)
  6865. {
  6866. ApiError("Robert","IsabelleRichardHelper",Status);
  6867. PrintToConsole("Robert : FAIL - ");
  6868. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXECUTE)\n");
  6869. return;
  6870. }
  6871. // PauseExecution(30000L);
  6872. Synchro(RICHARDHELPER) ;
  6873. for (RetryCount = 0; RetryCount < RETRYCOUNT; RetryCount++)
  6874. {
  6875. Status = IsabelleRichardHelper(RichardHelperBinding,
  6876. RICHARDHELPER_IGNORE);
  6877. if (Status == RPC_S_OK)
  6878. break;
  6879. PauseExecution(RETRYDELAY);
  6880. }
  6881. if (Status != RPC_S_OK)
  6882. {
  6883. ApiError("Robert","IsabelleRichardHelper",Status);
  6884. PrintToConsole("Robert : FAIL - ");
  6885. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_IGNORE)\n");
  6886. return;
  6887. }
  6888. IsabelleShutdown(RichardHelperBinding);
  6889. IsabelleShutdown(RichardBinding);
  6890. if (IsabelleErrors != 0)
  6891. {
  6892. PrintToConsole("Robert : FAIL - Error(s) in Isabelle Interface\n");
  6893. IsabelleErrors = 0;
  6894. return;
  6895. }
  6896. Status = RpcBindingFree(&RichardBinding);
  6897. if (Status)
  6898. {
  6899. ApiError("Robert","RpcBindingFree",Status);
  6900. PrintToConsole("Robert : FAIL - Unable to Free Binding");
  6901. PrintToConsole(" (RichardBinding)\n");
  6902. return;
  6903. }
  6904. Status = RpcBindingFree(&RichardHelperBinding);
  6905. if (Status)
  6906. {
  6907. ApiError("Robert","RpcBindingFree",Status);
  6908. PrintToConsole("Robert : FAIL - Unable to Free Binding");
  6909. PrintToConsole(" (RichardHelperBinding)\n");
  6910. return;
  6911. }
  6912. PrintToConsole("Robert : PASS\n");
  6913. }
  6914. void
  6915. Keith (
  6916. )
  6917. /*++
  6918. Routine Description:
  6919. Keith works with Kenneth (in usvr.cxx) to test auto-reconnect.
  6920. --*/
  6921. {
  6922. RPC_BINDING_HANDLE KennethBinding;
  6923. RPC_BINDING_HANDLE KennethHelperBinding;
  6924. Synchro(KENNETH) ;
  6925. if ( NumberOfTestsRun++ )
  6926. {
  6927. PauseExecution(TestDelay);
  6928. }
  6929. PrintToConsole("Keith : Test Auto Reconnect\n");
  6930. Status = GetBinding(KENNETH, &KennethBinding);
  6931. if (Status)
  6932. {
  6933. ApiError("Keith","GetBinding",Status);
  6934. PrintToConsole("Keith : FAIL - Unable to Bind (Kenneth)\n");
  6935. return;
  6936. }
  6937. Status = GetBinding(RICHARDHELPER, &KennethHelperBinding);
  6938. if (Status)
  6939. {
  6940. ApiError("Keith","GetBinding",Status);
  6941. PrintToConsole("Keith : FAIL - Unable to Bind (KennethHelper)\n");
  6942. return;
  6943. }
  6944. Status = IsabelleRichardHelper(KennethBinding, RICHARDHELPER_EXECUTE);
  6945. if (Status != RPC_S_OK)
  6946. {
  6947. ApiError("Keith","IsabelleRichardHelper",Status);
  6948. PrintToConsole("Keith : FAIL - ");
  6949. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXECUTE)\n");
  6950. return;
  6951. }
  6952. PauseExecution(20000L);
  6953. Status = IsabelleRichardHelper(KennethHelperBinding, RICHARDHELPER_IGNORE);
  6954. if (Status != RPC_S_OK)
  6955. {
  6956. ApiError("Keith","IsabelleRichardHelper",Status);
  6957. PrintToConsole("Keith : FAIL - ");
  6958. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_IGNORE)\n");
  6959. return;
  6960. }
  6961. Status = IsabelleRichardHelper(KennethHelperBinding,
  6962. RICHARDHELPER_DELAY_EXIT);
  6963. if (Status != RPC_S_OK)
  6964. {
  6965. PrintToConsole("Keith : FAIL - ");
  6966. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_DELAY_EXIT) ");
  6967. PrintToConsole("Failed\n");
  6968. return;
  6969. }
  6970. PauseExecution(30000L);
  6971. Status = IsabelleRichardHelper(KennethBinding, RICHARDHELPER_EXECUTE);
  6972. if (Status != RPC_S_OK)
  6973. {
  6974. ApiError("Keith","IsabelleRichardHelper",Status);
  6975. PrintToConsole("Keith : FAIL - ");
  6976. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_EXECUTE)\n");
  6977. return;
  6978. }
  6979. PauseExecution(40000L);
  6980. Status = IsabelleRichardHelper(KennethHelperBinding, RICHARDHELPER_IGNORE);
  6981. if (Status != RPC_S_OK)
  6982. {
  6983. ApiError("Keith","IsabelleRichardHelper",Status);
  6984. PrintToConsole("Keith : FAIL - ");
  6985. PrintToConsole("IsabelleRichardHelper(RICHARDHELPER_IGNORE)\n");
  6986. return;
  6987. }
  6988. IsabelleShutdown(KennethHelperBinding);
  6989. IsabelleShutdown(KennethBinding);
  6990. if (IsabelleErrors != 0)
  6991. {
  6992. PrintToConsole("Keith : FAIL - Error(s) in Isabelle Interface\n");
  6993. IsabelleErrors = 0;
  6994. return;
  6995. }
  6996. Status = RpcBindingFree(&KennethBinding);
  6997. if (Status)
  6998. {
  6999. ApiError("Keith","RpcBindingFree",Status);
  7000. PrintToConsole("Keith : FAIL - Unable to Free Binding");
  7001. PrintToConsole(" (KennethBinding)\n");
  7002. return;
  7003. }
  7004. Status = RpcBindingFree(&KennethHelperBinding);
  7005. if (Status)
  7006. {
  7007. ApiError("Keith","RpcBindingFree",Status);
  7008. PrintToConsole("Keith : FAIL - Unable to Free Binding");
  7009. PrintToConsole(" (KennethHelperBinding)\n");
  7010. return;
  7011. }
  7012. PrintToConsole("Keith : PASS\n");
  7013. }
  7014. void
  7015. Daniel (
  7016. )
  7017. /*++
  7018. Routine Description:
  7019. This routine is used to test association context rundown support;
  7020. it works with David in usvr.exe.
  7021. --*/
  7022. {
  7023. RPC_BINDING_HANDLE DanielFirst;;
  7024. RPC_BINDING_HANDLE DanielSecond;
  7025. CCONTEXT *ContextHandle, *ContextHandle2;
  7026. Synchro(DAVIDFIRST) ;
  7027. if ( NumberOfTestsRun++ )
  7028. {
  7029. PauseExecution(TestDelay);
  7030. }
  7031. PrintToConsole("Daniel : Association Context and Rundown\n");
  7032. Status = GetBinding(DAVIDFIRST, &DanielFirst);
  7033. if (Status)
  7034. {
  7035. ApiError("Daniel","GetBinding",Status);
  7036. PrintToConsole("Daniel : FAIL - Unable to Bind (DavidFirst)\n");
  7037. return;
  7038. }
  7039. Status = GetBinding(DAVIDSECOND, &DanielSecond);
  7040. if (Status)
  7041. {
  7042. ApiError("Daniel","GetBinding",Status);
  7043. PrintToConsole("Daniel : FAIL - Unable to Bind (DavidSecond)\n");
  7044. return;
  7045. }
  7046. IsabelleSetRundown(DanielSecond);
  7047. IsabelleCheckContext(DanielSecond);
  7048. #ifdef DEBUGRPC
  7049. PrintToDebugger("\n\n\n\nUCLNT: Calling RpcBindingFree\n");
  7050. #endif
  7051. Status = RpcBindingFree(&DanielSecond);
  7052. if (Status)
  7053. {
  7054. ApiError("Daniel","RpcBindingFree",Status);
  7055. PrintToConsole("Daniel : FAIL - Unable to Free Binding");
  7056. PrintToConsole(" (DanielSecond)\n");
  7057. return;
  7058. }
  7059. PauseExecution(3000L);
  7060. IsabelleCheckRundown(DanielFirst);
  7061. ContextHandle = (CCONTEXT *)I_RpcAllocate(sizeof(CCONTEXT));
  7062. if (!ContextHandle)
  7063. {
  7064. ApiError("Daniel","I_RpcAllocate",Status);
  7065. PrintToConsole("Daniel : FAIL - Unable to I_RpcAllocate");
  7066. PrintToConsole(" (DanielSecond)\n");
  7067. return;
  7068. }
  7069. OpenContextHandle(DanielFirst, &IsabelleInterfaceInformation, NULL);
  7070. OpenContextHandle(DanielFirst, &IsabelleInterfaceInformation, ContextHandle);
  7071. Status = RpcBindingCopy(ContextHandle, (RPC_BINDING_HANDLE *)&ContextHandle2);
  7072. if (Status)
  7073. {
  7074. ApiError("Daniel","RpcBindingCopy",Status);
  7075. PrintToConsole("Daniel : FAIL - Unable to copy context handle");
  7076. PrintToConsole(" (DanielSecond)\n");
  7077. return;
  7078. }
  7079. Status = RpcBindingSetOption(ContextHandle2, RPC_C_OPT_DONT_LINGER, TRUE);
  7080. if (Status)
  7081. {
  7082. ApiError("Daniel","RpcBindingSetOption",Status);
  7083. PrintToConsole("Daniel : FAIL - Unable to set context handle options");
  7084. PrintToConsole(" (DanielSecond)\n");
  7085. return;
  7086. }
  7087. RpcSsDestroyClientContext((void **)&ContextHandle);
  7088. RpcSsDestroyClientContext((void **)&ContextHandle2);
  7089. OpenContextHandle(DanielFirst, &HelgaInterfaceInformation, NULL);
  7090. OpenContextHandle(DanielFirst, &HelgaInterfaceInformation, NULL);
  7091. UnregisterHelgaEx(DanielFirst);
  7092. IsabelleShutdown(DanielFirst);
  7093. if (IsabelleErrors != 0)
  7094. {
  7095. PrintToConsole("Daniel : FAIL - Error(s) in Isabelle Interface\n");
  7096. IsabelleErrors = 0;
  7097. return;
  7098. }
  7099. Status = RpcBindingFree(&DanielFirst);
  7100. if (Status)
  7101. {
  7102. ApiError("Daniel","RpcBindingFree",Status);
  7103. PrintToConsole("Daniel : FAIL - Unable to Free Binding");
  7104. PrintToConsole(" (DanielFirst)\n");
  7105. return;
  7106. }
  7107. PrintToConsole("Daniel : PASS\n");
  7108. }
  7109. int
  7110. BenjaminTestBinding (
  7111. IN unsigned char PAPI * StringBinding
  7112. )
  7113. /*++
  7114. Routine Description:
  7115. This helper routine will take and convert the string binding into
  7116. a binding, use the binding to make a remote procedure call, and
  7117. then free the binding.
  7118. Arguments:
  7119. StringBinding - Supplies the string binding to use to convert into
  7120. a binding.
  7121. Return Value:
  7122. If the test passes, zero will be returned; otherwise, non-zero will
  7123. be returned.
  7124. --*/
  7125. {
  7126. RPC_BINDING_HANDLE Binding;
  7127. unsigned char PAPI * ObjUuid;
  7128. unsigned char PAPI * Protseq;
  7129. unsigned char PAPI * NetworkAddr;
  7130. unsigned char PAPI * NetworkOptions;
  7131. int OldCallbacksFlag = 0;
  7132. unsigned int TransportType;
  7133. if ( UseEndpointMapperFlag != 0 )
  7134. {
  7135. Status = RpcStringBindingParseA(StringBinding, &ObjUuid, &Protseq,
  7136. &NetworkAddr, 0, &NetworkOptions);
  7137. if (Status)
  7138. {
  7139. ApiError("Benjamin", "RpcStringBindingParse", Status);
  7140. PrintToConsole("Benjamin : RpcStringBindingParse Failed\n");
  7141. return(1);
  7142. }
  7143. Status = RpcStringBindingComposeA(ObjUuid, Protseq, NetworkAddr, 0,
  7144. NetworkOptions, &StringBinding);
  7145. if (Status)
  7146. {
  7147. ApiError("Benjamin", "RpcStringBindingCompose", Status);
  7148. PrintToConsole("Benjamin : RpcStringBindingCompose Failed\n");
  7149. return(1);
  7150. }
  7151. Status = RpcStringFreeA(&Protseq);
  7152. if (!Status)
  7153. RpcStringFreeA(&NetworkOptions);
  7154. if (!Status)
  7155. RpcStringFreeA(&ObjUuid);
  7156. if (Status)
  7157. {
  7158. ApiError("Benjamin", "RpcStringFree", Status);
  7159. PrintToConsole("Benjamin : RpcStringFree Failed\n");
  7160. return(1);
  7161. }
  7162. }
  7163. PrintToConsole("Benjamin : ");
  7164. PrintToConsole("%s - ", StringBinding);
  7165. Status = RpcBindingFromStringBindingA(StringBinding, &Binding);
  7166. if (Status)
  7167. {
  7168. if (Status == RPC_S_PROTSEQ_NOT_SUPPORTED)
  7169. {
  7170. return(0);
  7171. }
  7172. ApiError("Benjamin", "RpcBindingFromStringBinding", Status);
  7173. PrintToConsole("Benjamin : FAIL - Unable to Binding");
  7174. PrintToConsole(" (StringBinding)\n");
  7175. return(1);
  7176. }
  7177. SylviaBinding = Binding;
  7178. Status = I_RpcBindingInqTransportType(SylviaBinding, &TransportType);
  7179. if (Status)
  7180. {
  7181. ApiError("Benjamin", "I_RpcBindingInqTransportType", Status);
  7182. PrintToConsole("Benjamin : I_RpcBindingInqTransportType Failed\n");
  7183. return(1);
  7184. }
  7185. switch(TransportType)
  7186. {
  7187. case TRANSPORT_TYPE_CN:
  7188. PrintToConsole("( cn )\n");
  7189. break;
  7190. case TRANSPORT_TYPE_DG:
  7191. PrintToConsole(" ( dg )\n");
  7192. break;
  7193. case TRANSPORT_TYPE_LPC:
  7194. PrintToConsole("( lpc )\n");
  7195. break;
  7196. default:
  7197. {
  7198. PrintToConsole("Benjamin : FAIL - Incorrect result");
  7199. PrintToConsole("Benjamin : I_RpcBindingInqTransportType Failed\n");
  7200. return(1);
  7201. }
  7202. }
  7203. //This is a temporary workaround till dg implements callbacks
  7204. //What we want to do is if the transport type is datagram, set the no
  7205. //callback flag even if user didnt specify. Then unset it again!
  7206. if (TransportType == TRANSPORT_TYPE_DG)
  7207. {
  7208. OldCallbacksFlag = NoCallBacksFlag;
  7209. NoCallBacksFlag = 1;
  7210. }
  7211. if ( SylviaCall(SylviaBinding, 5, 0, 0) != LocalSylviaCall(5, 0, 0) )
  7212. {
  7213. PrintToConsole("Benjamin : FAIL - Incorrect result");
  7214. PrintToConsole(" from SylviaCall(5,0,0)\n");
  7215. return(1);
  7216. }
  7217. if (SylviaErrors != 0)
  7218. {
  7219. PrintToConsole("Benjamin : FAIL - Error(s) in Sylvia");
  7220. PrintToConsole(" Interface\n");
  7221. HelgaErrors = 0;
  7222. return(1);
  7223. }
  7224. if (TransportType == TRANSPORT_TYPE_DG)
  7225. {
  7226. NoCallBacksFlag = OldCallbacksFlag;
  7227. }
  7228. Status = RpcBindingFree(&Binding);
  7229. if (Status)
  7230. {
  7231. ApiError("Benjamin", "RpcBindingFree", Status);
  7232. PrintToConsole("Benjamin : FAIL - Unable to Free Binding");
  7233. PrintToConsole(" (Binding)\n");
  7234. return(1);
  7235. }
  7236. return(0);
  7237. }
  7238. void
  7239. Benjamin (
  7240. )
  7241. /*++
  7242. Routine Description:
  7243. This routine works with Bartholomew in usvr.exe to test that
  7244. dynamic endpoints work. What we actually do is inquire all bindings
  7245. supported by the server, and then this client binds to each of
  7246. them, and makes a call.
  7247. --*/
  7248. {
  7249. RPC_BINDING_HANDLE Bartholomew;
  7250. unsigned char * StringBinding;
  7251. Synchro(BARTHOLOMEW) ;
  7252. if ( NumberOfTestsRun++ )
  7253. {
  7254. PauseExecution(4*LONG_TESTDELAY);
  7255. }
  7256. PrintToConsole("Benjamin : Test Dynamic Endpoints\n");
  7257. Status = GetBinding(BARTHOLOMEW, &Bartholomew);
  7258. if (Status)
  7259. {
  7260. ApiError("Benjamin", "GetBinding", Status);
  7261. PrintToConsole("Benjamin : FAIL - Unable to Bind (Bartholomew)\n");
  7262. return;
  7263. }
  7264. while ((StringBinding = IsabelleGetStringBinding(Bartholomew)) != 0)
  7265. {
  7266. if (0 != strstr("http", (char *) StringBinding))
  7267. {
  7268. delete StringBinding;
  7269. continue;
  7270. }
  7271. if (BenjaminTestBinding(StringBinding) != 0)
  7272. return;
  7273. delete StringBinding;
  7274. }
  7275. IsabelleShutdown(Bartholomew);
  7276. if (IsabelleErrors != 0)
  7277. {
  7278. PrintToConsole("Benjamin : FAIL - Error(s) in Isabelle");
  7279. PrintToConsole(" Interface\n");
  7280. IsabelleErrors = 0;
  7281. return;
  7282. }
  7283. Status = RpcBindingFree(&Bartholomew);
  7284. if (Status)
  7285. {
  7286. ApiError("Benjamin", "RpcBindingFree", Status);
  7287. PrintToConsole("Benjamin : FAIL - Unable to Free Binding");
  7288. PrintToConsole(" (Bartholomew)\n");
  7289. return;
  7290. }
  7291. PrintToConsole("Benjamin : PASS\n");
  7292. }
  7293. void
  7294. Harold (
  7295. )
  7296. /*++
  7297. Routine Description:
  7298. This routine works with Herman in usvr.exe to test that idle
  7299. connections get cleaned up properly, and that context is maintained.
  7300. --*/
  7301. {
  7302. RPC_BINDING_HANDLE Binding, ContextBinding;
  7303. int seconds;
  7304. PrintToConsole("Harold : Test Idle Connection Cleanup and Context\n");
  7305. Synchro(HERMAN) ;
  7306. if ( NumberOfTestsRun++ )
  7307. {
  7308. PauseExecution(TestDelay);
  7309. }
  7310. Status = RpcMgmtEnableIdleCleanup();
  7311. if (Status)
  7312. {
  7313. ApiError("Harold","RpcMgmtEnableIdleCleanup",Status);
  7314. PrintToConsole("Harold : FAIL - RpcMgmtEnableIdleCleanup\n");
  7315. return;
  7316. }
  7317. Status = GetBinding(HERMAN, &Binding);
  7318. if (Status)
  7319. {
  7320. ApiError("Harold","GetBinding",Status);
  7321. PrintToConsole("Harold : FAIL - Unable to Bind (Herman)\n");
  7322. return;
  7323. }
  7324. IsabelleSetRundown(Binding);
  7325. IsabelleCheckContext(Binding);
  7326. // We want to wait for eight minutes. This will give enough time for
  7327. // the cleanup code to get run to cleanup the idle connection.
  7328. PrintToConsole("Harold : Waiting");
  7329. for (seconds = 0; seconds < 30; seconds++)
  7330. {
  7331. PauseExecution(1000L);
  7332. PrintToConsole(".");
  7333. }
  7334. PrintToConsole("\n");
  7335. IsabelleCheckRundown(Binding);
  7336. if (IsabelleErrors != 0)
  7337. {
  7338. PrintToConsole("Harold : FAIL - Error(s) in Isabelle Interface\n");
  7339. IsabelleErrors = 0;
  7340. return;
  7341. }
  7342. Status = I_RpcBindingCopy(Binding, &ContextBinding);
  7343. if (Status)
  7344. {
  7345. ApiError("Harold", "I_RpcBindingCopy", Status);
  7346. PrintToConsole("Harold : FAIL - I_RpcBindingCopy Failed\n");
  7347. return;
  7348. }
  7349. Status = RpcBindingFree(&Binding);
  7350. if (Status)
  7351. {
  7352. ApiError("Harold","RpcBindingFree",Status);
  7353. PrintToConsole("Harold : FAIL - Unable to Free Binding");
  7354. PrintToConsole(" (Binding)\n");
  7355. return;
  7356. }
  7357. IsabelleSetRundown(ContextBinding);
  7358. IsabelleCheckContext(ContextBinding);
  7359. // We want to wait for eight minutes. This will give enough time for
  7360. // the cleanup code to get run to cleanup the idle connection, but this
  7361. // time the connection should not be cleaned up because we have got
  7362. // context open.
  7363. PrintToConsole("Harold : Waiting");
  7364. for (seconds = 0; seconds < 30; seconds++)
  7365. {
  7366. PauseExecution(1000L);
  7367. PrintToConsole(".");
  7368. }
  7369. PrintToConsole("\n");
  7370. IsabelleCheckNoRundown(ContextBinding);
  7371. if (IsabelleErrors != 0)
  7372. {
  7373. PrintToConsole("Harold : FAIL - Error(s) in Isabelle Interface\n");
  7374. IsabelleErrors = 0;
  7375. return;
  7376. }
  7377. IsabelleShutdown(ContextBinding);
  7378. Status = RpcBindingFree(&ContextBinding);
  7379. if (Status)
  7380. {
  7381. ApiError("Harold","RpcBindingFree",Status);
  7382. PrintToConsole("Harold : FAIL - Unable to Free Binding");
  7383. PrintToConsole(" (ContextBinding)\n");
  7384. return;
  7385. }
  7386. PrintToConsole("Harold : PASS\n");
  7387. }
  7388. unsigned int JamesSize = 128;
  7389. unsigned int JamesCount = 100;
  7390. void
  7391. James (
  7392. )
  7393. /*++
  7394. Routine Description:
  7395. This routine works with Jason in usvr.exe to perform timing tests
  7396. of the runtime.
  7397. --*/
  7398. {
  7399. RPC_BINDING_HANDLE Binding;
  7400. unsigned int Count;
  7401. unsigned long StartingTime, EndingTime;
  7402. unsigned char PAPI * StringBinding;
  7403. UUID ObjectUuid;
  7404. PrintToConsole("James : Timing Test (%d) %d times\n", JamesSize,
  7405. JamesCount);
  7406. Synchro(JASON) ;
  7407. if ( NumberOfTestsRun++ )
  7408. {
  7409. PauseExecution(TestDelay);
  7410. }
  7411. //
  7412. // Bind, NullCall, Free
  7413. //
  7414. StringBinding = GetStringBinding(JASON,0,0);
  7415. StartingTime = GetCurrentTime();
  7416. for (Count = 0; Count < JamesCount; Count++)
  7417. {
  7418. Status = RpcBindingFromStringBindingA(StringBinding,&Binding);
  7419. if (Status)
  7420. {
  7421. ApiError("James","RpcBindingFromStringBinding",Status);
  7422. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7423. return;
  7424. }
  7425. if (fUniqueBinding)
  7426. {
  7427. Status = RpcBindingSetOption( Binding, RPC_C_OPT_UNIQUE_BINDING, TRUE );
  7428. if (Status != RPC_S_OK)
  7429. {
  7430. ApiError("James","RpcBindingSetOption",Status);
  7431. return;
  7432. }
  7433. }
  7434. Helga(Binding);
  7435. if (HelgaErrors != 0)
  7436. {
  7437. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7438. HelgaErrors = 0;
  7439. return;
  7440. }
  7441. Status = RpcBindingFree(&Binding);
  7442. if (Status)
  7443. {
  7444. ApiError("James","RpcBindingFree",Status);
  7445. PrintToConsole("James : FAIL - Unable to Free Binding");
  7446. PrintToConsole(" (Binding)\n");
  7447. return;
  7448. }
  7449. }
  7450. EndingTime = GetCurrentTime();
  7451. PrintToConsole(" Bind, NullCall, Free : %d.%d ms [%d in %d milliseconds]\n",
  7452. (EndingTime - StartingTime) / JamesCount,
  7453. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7454. JamesCount, (EndingTime - StartingTime));
  7455. //
  7456. // NullCall
  7457. //
  7458. Status = GetBinding(JASON, &Binding);
  7459. if (Status)
  7460. {
  7461. ApiError("James","GetBinding",Status);
  7462. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7463. return;
  7464. }
  7465. Helga(Binding);
  7466. StartingTime = GetCurrentTime();
  7467. for (Count = 0; Count < JamesCount; Count++)
  7468. {
  7469. Helga(Binding);
  7470. }
  7471. EndingTime = GetCurrentTime();
  7472. if (HelgaErrors != 0)
  7473. {
  7474. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7475. HelgaErrors = 0;
  7476. return;
  7477. }
  7478. Status = RpcBindingFree(&Binding);
  7479. if (Status)
  7480. {
  7481. ApiError("James","RpcBindingFree",Status);
  7482. PrintToConsole("James : FAIL - Unable to Free Binding");
  7483. PrintToConsole(" (Binding)\n");
  7484. return;
  7485. }
  7486. PrintToConsole(" NullCall : %d.%d ms [%d in %d milliseconds]\n",
  7487. (EndingTime - StartingTime) / JamesCount,
  7488. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7489. JamesCount, (EndingTime - StartingTime));
  7490. //
  7491. // InCall
  7492. //
  7493. Status = GetBinding(JASON, &Binding);
  7494. if (Status)
  7495. {
  7496. ApiError("James","GetBinding",Status);
  7497. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7498. return;
  7499. }
  7500. Helga(Binding);
  7501. StartingTime = GetCurrentTime();
  7502. for (Count = 0; Count < JamesCount; Count++)
  7503. {
  7504. HelgaIN(Binding,JamesSize);
  7505. }
  7506. EndingTime = GetCurrentTime();
  7507. if (HelgaErrors != 0)
  7508. {
  7509. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7510. HelgaErrors = 0;
  7511. return;
  7512. }
  7513. Status = RpcBindingFree(&Binding);
  7514. if (Status)
  7515. {
  7516. ApiError("James","RpcBindingFree",Status);
  7517. PrintToConsole("James : FAIL - Unable to Free Binding");
  7518. PrintToConsole(" (Binding)\n");
  7519. return;
  7520. }
  7521. PrintToConsole(" InCall(%d) : %d.%d ms [%d in %d milliseconds]\n",
  7522. JamesSize, (EndingTime - StartingTime) / JamesCount,
  7523. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7524. JamesCount, (EndingTime - StartingTime));
  7525. //
  7526. // InCall w/Binding Object UUID
  7527. //
  7528. Status = GetBinding(JASON, &Binding);
  7529. if (Status)
  7530. {
  7531. ApiError("James","GetBinding",Status);
  7532. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7533. return;
  7534. }
  7535. GenerateUuidValue(8179, &ObjectUuid);
  7536. Status = RpcBindingSetObject(Binding, &ObjectUuid);
  7537. if (Status)
  7538. {
  7539. ApiError("Graham", "RpcBindingSetObject", Status);
  7540. PrintToConsole("Graham : FAIL - Unable to Set Object\n");
  7541. return;
  7542. }
  7543. Helga(Binding);
  7544. StartingTime = GetCurrentTime();
  7545. for (Count = 0; Count < JamesCount; Count++)
  7546. {
  7547. HelgaIN(Binding,JamesSize);
  7548. }
  7549. EndingTime = GetCurrentTime();
  7550. if (HelgaErrors != 0)
  7551. {
  7552. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7553. HelgaErrors = 0;
  7554. return;
  7555. }
  7556. Status = RpcBindingFree(&Binding);
  7557. if (Status)
  7558. {
  7559. ApiError("James","RpcBindingFree",Status);
  7560. PrintToConsole("James : FAIL - Unable to Free Binding");
  7561. PrintToConsole(" (Binding)\n");
  7562. return;
  7563. }
  7564. PrintToConsole(" InCall/WUUID(%d) : %d.%d ms [%d in %d milliseconds]\n",
  7565. JamesSize, (EndingTime - StartingTime) / JamesCount,
  7566. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7567. JamesCount, (EndingTime - StartingTime));
  7568. //
  7569. // OUTCall
  7570. //
  7571. Status = GetBinding(JASON, &Binding);
  7572. if (Status)
  7573. {
  7574. ApiError("James","GetBinding",Status);
  7575. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7576. return;
  7577. }
  7578. Helga(Binding);
  7579. StartingTime = GetCurrentTime();
  7580. for (Count = 0; Count < JamesCount; Count++)
  7581. {
  7582. HelgaOUT(Binding,JamesSize);
  7583. }
  7584. EndingTime = GetCurrentTime();
  7585. if (HelgaErrors != 0)
  7586. {
  7587. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7588. HelgaErrors = 0;
  7589. return;
  7590. }
  7591. Status = RpcBindingFree(&Binding);
  7592. if (Status)
  7593. {
  7594. ApiError("James","RpcBindingFree",Status);
  7595. PrintToConsole("James : FAIL - Unable to Free Binding");
  7596. PrintToConsole(" (Binding)\n");
  7597. return;
  7598. }
  7599. PrintToConsole(" OutCall(%d) : %d.%d ms [%d in %d milliseconds]\n",
  7600. JamesSize, (EndingTime - StartingTime) / JamesCount,
  7601. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7602. JamesCount, (EndingTime - StartingTime));
  7603. //
  7604. // InOutCall
  7605. //
  7606. Status = GetBinding(JASON, &Binding);
  7607. if (Status)
  7608. {
  7609. ApiError("James","GetBinding",Status);
  7610. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7611. return;
  7612. }
  7613. Helga(Binding);
  7614. StartingTime = GetCurrentTime();
  7615. for (Count = 0; Count < JamesCount; Count++)
  7616. {
  7617. HelgaINOUT(Binding,JamesSize);
  7618. }
  7619. EndingTime = GetCurrentTime();
  7620. if (HelgaErrors != 0)
  7621. {
  7622. PrintToConsole("James : FAIL - Error(s) in Helga Interface\n");
  7623. HelgaErrors = 0;
  7624. return;
  7625. }
  7626. Status = RpcBindingFree(&Binding);
  7627. if (Status)
  7628. {
  7629. ApiError("James","RpcBindingFree",Status);
  7630. PrintToConsole("James : FAIL - Unable to Free Binding");
  7631. PrintToConsole(" (Binding)\n");
  7632. return;
  7633. }
  7634. PrintToConsole(" InOutCall(%d) : %d.%d ms [%d in %d milliseconds]\n",
  7635. JamesSize, (EndingTime - StartingTime) / JamesCount,
  7636. ((1000 * (EndingTime - StartingTime) / JamesCount) % 1000),
  7637. JamesCount, (EndingTime - StartingTime));
  7638. Status = GetBinding(JASON, &Binding);
  7639. if (Status)
  7640. {
  7641. ApiError("James","GetBinding",Status);
  7642. PrintToConsole("James : FAIL - Unable to Bind (Jason)\n");
  7643. return;
  7644. }
  7645. IsabelleShutdown(Binding);
  7646. if (IsabelleErrors != 0)
  7647. {
  7648. PrintToConsole("James : FAIL - Error(s) in Isabelle Interface\n");
  7649. IsabelleErrors = 0;
  7650. return;
  7651. }
  7652. Status = RpcBindingFree(&Binding);
  7653. if (Status)
  7654. {
  7655. ApiError("James","RpcBindingFree",Status);
  7656. PrintToConsole("James : FAIL - Unable to Free Binding");
  7657. PrintToConsole(" (Binding)\n");
  7658. return;
  7659. }
  7660. PrintToConsole("James : PASS\n");
  7661. }
  7662. int
  7663. IsaacStressTest (
  7664. IN unsigned int Iteration,
  7665. IN unsigned int InitialSize,
  7666. IN unsigned int MaximumSize,
  7667. IN unsigned int Increment
  7668. )
  7669. /*++
  7670. Routine Description:
  7671. This routine performs one iteration of the stress test. We bind with
  7672. the server, perform one or more remote procedure calls, and then
  7673. unbind.
  7674. Arguments:
  7675. Iteration - Supplies an indication of which iteration of the test is
  7676. being performed. We will use that information to print out the
  7677. buffer sizes the first time.
  7678. InitialSize - Supplies the initial buffer size to use.
  7679. MaximumSize - Supplies the maximum buffer size to use; when this size
  7680. is reach, the test will return.
  7681. Increment - Supplies the amount to increment the buffer size each
  7682. time.
  7683. Return Value:
  7684. Zero will be returned if the test completes successfully; otherwise,
  7685. non-zero will be returned.
  7686. --*/
  7687. {
  7688. RPC_BINDING_HANDLE Binding;
  7689. Status = GetBinding(IVAN, &Binding);
  7690. if (Status)
  7691. {
  7692. ApiError("Isaac","GetBinding",Status);
  7693. PrintToConsole("Isaac : FAIL - Unable to Bind (Ivan)\n");
  7694. return(1);
  7695. }
  7696. for (; InitialSize < MaximumSize; InitialSize += Increment)
  7697. {
  7698. if (Iteration == 0)
  7699. {
  7700. PrintToConsole("%d ",InitialSize);
  7701. }
  7702. Helga(Binding);
  7703. HelgaIN(Binding, InitialSize);
  7704. HelgaOUT(Binding, InitialSize);
  7705. HelgaINOUT(Binding, InitialSize);
  7706. }
  7707. if (Iteration == 0)
  7708. {
  7709. PrintToConsole("\n");
  7710. }
  7711. if (HelgaErrors != 0)
  7712. {
  7713. PrintToConsole("Isaac : FAIL - Error(s) in Helga Interface\n");
  7714. HelgaErrors = 0;
  7715. return(1);
  7716. }
  7717. Status = RpcBindingFree(&Binding);
  7718. if (Status)
  7719. {
  7720. ApiError("Isaac","RpcBindingFree",Status);
  7721. PrintToConsole("Isaac : FAIL - Unable to Free Binding");
  7722. PrintToConsole(" (Binding)\n");
  7723. return(1);
  7724. }
  7725. return(0);
  7726. }
  7727. unsigned int IsaacIterations = 100;
  7728. unsigned int IsaacInitialSize = 128;
  7729. unsigned int IsaacMaximumSize = 4096;
  7730. unsigned int IsaacIncrement = 512;
  7731. void
  7732. Isaac (
  7733. )
  7734. /*++
  7735. Routine Description:
  7736. This routine works to Ivan in usvr.exe to stress test the runtime.
  7737. --*/
  7738. {
  7739. RPC_BINDING_HANDLE Binding;
  7740. unsigned int Count;
  7741. PrintToConsole("Isaac : Stress Test (%d to %d by %d) %d times\n",
  7742. IsaacInitialSize, IsaacMaximumSize, IsaacIncrement,
  7743. IsaacIterations);
  7744. Synchro(IVAN) ;
  7745. if ( NumberOfTestsRun++ )
  7746. {
  7747. PauseExecution(TestDelay);
  7748. }
  7749. for (Count = 0; Count < IsaacIterations ; Count++)
  7750. {
  7751. if ( IsaacStressTest(Count, IsaacInitialSize, IsaacMaximumSize,
  7752. IsaacIncrement) != 0 )
  7753. {
  7754. return;
  7755. }
  7756. PrintToConsole(".");
  7757. }
  7758. PrintToConsole("\n");
  7759. // this piece of code was below the loop
  7760. Status = GetBinding(IVAN, &Binding);
  7761. if (Status)
  7762. {
  7763. ApiError("Isaac","GetBinding",Status);
  7764. PrintToConsole("Isaac : FAIL - Unable to Bind (Ivan)\n");
  7765. return;
  7766. }
  7767. IsabelleShutdown(Binding);
  7768. if (IsabelleErrors != 0)
  7769. {
  7770. PrintToConsole("Isaac : FAIL - Error(s) in Isabelle Interface\n");
  7771. IsabelleErrors = 0;
  7772. return;
  7773. }
  7774. Status = RpcBindingFree(&Binding);
  7775. if (Status)
  7776. {
  7777. ApiError("Isaac","RpcBindingFree",Status);
  7778. PrintToConsole("Isaac : FAIL - Unable to Free Binding");
  7779. PrintToConsole(" (Binding)\n");
  7780. return;
  7781. }
  7782. PrintToConsole("Isaac : PASS\n");
  7783. }
  7784. void
  7785. ExtendedError (
  7786. )
  7787. {
  7788. RPC_BINDING_HANDLE Binding ;
  7789. RPC_SECURITY_QOS QOS;
  7790. UUID ObjectUuid;
  7791. Status = GetBinding(TYLER, &Binding);
  7792. if (Status)
  7793. {
  7794. ApiError("ExtendedError", "GetBinding", Status);
  7795. PrintToConsole("ExtendedError : FAIL - Unable to Bind (Tyler)\n");
  7796. return;
  7797. }
  7798. QOS.Version = RPC_C_SECURITY_QOS_VERSION;
  7799. QOS.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE;
  7800. QOS.Capabilities = RPC_C_QOS_CAPABILITIES_MUTUAL_AUTH;
  7801. QOS.IdentityTracking = RPC_C_QOS_IDENTITY_DYNAMIC;
  7802. Status = RpcBindingSetAuthInfoEx(
  7803. Binding,
  7804. (RPC_CHAR *) L"ServerPrincipal",
  7805. RPC_C_AUTHN_LEVEL_CONNECT,
  7806. 10,
  7807. NULL,
  7808. 0,
  7809. &QOS);
  7810. if (Status != RPC_S_OK)
  7811. {
  7812. ApiError("ExtendedError","RpcBindingSetAuthInfoEx",Status);
  7813. return;
  7814. }
  7815. Helga(Binding);
  7816. if (HelgaErrors)
  7817. {
  7818. PrintToConsole("RPC extended error: %d",
  7819. I_RpcGetExtendedError());
  7820. }
  7821. else
  7822. {
  7823. PrintToConsole("RPC call passed\n");
  7824. }
  7825. RpcBindingFree( &Binding );
  7826. //
  7827. // check propagation of extended-error packets
  7828. //
  7829. Status = GetBinding(TYLER, &Binding);
  7830. if (Status)
  7831. {
  7832. ApiError("Async", "GetBinding", Status);
  7833. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  7834. return;
  7835. }
  7836. //
  7837. // see usvr.cxx: activates the extended error info in "ThreadProc"
  7838. //
  7839. GenerateUuidValue(UUID_EXTENDED_ERROR, &ObjectUuid);
  7840. Status = RpcBindingSetObject(Binding, &ObjectUuid);
  7841. if (Status)
  7842. {
  7843. ApiError("Async", "BindingSetObject", Status);
  7844. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  7845. return;
  7846. }
  7847. int i;
  7848. //
  7849. // make a few calls on the helga interface
  7850. // this should cause an alter context
  7851. //
  7852. for (i=0; i<3; i++)
  7853. {
  7854. __try
  7855. {
  7856. int inbuf[1];
  7857. int sizeout = 0;
  7858. int * bufferout;
  7859. //
  7860. // FooSync will force an exception on the server if the in-size is zero.
  7861. //
  7862. FooSync( Binding, sizeof(int), inbuf, &sizeout, &bufferout);
  7863. }
  7864. __except(1)
  7865. {
  7866. Status = GetExceptionCode();
  7867. }
  7868. if (Status != EXTENDED_ERROR_EXCEPTION)
  7869. {
  7870. PrintToConsole("eeinfo: call returned status %d instead of %d\n", Status, EXTENDED_ERROR_EXCEPTION);
  7871. }
  7872. DumpEeInfo(1);
  7873. }
  7874. }
  7875. void TestYield(void)
  7876. {
  7877. RPC_BINDING_HANDLE Binding ;
  7878. RPC_MESSAGE Caller;
  7879. Synchro(TESTYIELD) ;
  7880. Caller.BufferLength = 0;
  7881. Caller.ProcNum = 5 | HackForOldStubs ;
  7882. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation ;
  7883. Caller.RpcFlags = 0;
  7884. Status = GetBinding(TESTYIELD, &Binding);
  7885. if (Status)
  7886. {
  7887. ApiError("TestYield","GetBinding",Status);
  7888. PrintToConsole("TestYield: FAIL - Unable to Bind\n");
  7889. return;
  7890. }
  7891. // new code end
  7892. Caller.Handle = Binding;
  7893. while(UclntGetBuffer(&Caller))
  7894. {
  7895. Caller.Handle = Binding ;
  7896. PauseExecution(1000) ;
  7897. }
  7898. if(UclntSendReceive(&Caller) != 0)
  7899. {
  7900. ApiError("TestYield","GetBinding",Status);
  7901. PrintToConsole("TestYield: FAIL - Unable to Bind\n");
  7902. return;
  7903. }
  7904. Status = I_RpcFreeBuffer(&Caller);
  7905. if (Status)
  7906. ApiError("TestYield","I_RpcFreeBuffer",Status);
  7907. Status = RpcBindingFree(&Binding);
  7908. if (Status)
  7909. {
  7910. ApiError("TestYield","RpcBindingFree",Status);
  7911. PrintToConsole("TestYield: FAIL - Unable to Free Binding");
  7912. return;
  7913. }
  7914. }
  7915. char *GetNextCard (
  7916. char **Ptr
  7917. )
  7918. {
  7919. char *Card = *Ptr ;
  7920. if (*Card == 0)
  7921. {
  7922. return NULL ;
  7923. }
  7924. while (**Ptr) (*Ptr)++ ;
  7925. (*Ptr)++ ;
  7926. ASSERT(*Card == '\\') ;
  7927. Card++ ;
  7928. while (*Card != '\\') Card++ ;
  7929. Card++ ;
  7930. return Card ;
  7931. }
  7932. char *GetNextIPAddress(
  7933. char **Ptr
  7934. )
  7935. {
  7936. char *Address = *Ptr ;
  7937. if (*Address == 0)
  7938. {
  7939. return NULL ;
  7940. }
  7941. while (**Ptr) (*Ptr)++ ;
  7942. (*Ptr)++ ;
  7943. return Address ;
  7944. }
  7945. void PrintAddresses(
  7946. char *Card
  7947. )
  7948. {
  7949. char szBuf[512] ;
  7950. HKEY hKey;
  7951. RPC_STATUS Status;
  7952. char Buffer[512] ;
  7953. DWORD Size = 512;
  7954. char *address ;
  7955. char *temp1 ;
  7956. DWORD Type;
  7957. // Create the key string
  7958. sprintf(szBuf,
  7959. "System\\CurrentControlSet\\Services\\%s\\Parameters\\Tcpip",
  7960. Card) ;
  7961. Status =
  7962. RegOpenKeyExA(
  7963. HKEY_LOCAL_MACHINE,
  7964. szBuf,
  7965. 0,
  7966. KEY_READ,
  7967. &hKey);
  7968. if ( Status != ERROR_SUCCESS
  7969. && Status != ERROR_FILE_NOT_FOUND )
  7970. {
  7971. ASSERT(0);
  7972. return;
  7973. }
  7974. // Get DHCP Address
  7975. if (Status == ERROR_SUCCESS)
  7976. {
  7977. Status =
  7978. RegQueryValueExA(
  7979. hKey,
  7980. "DhcpIPAddress",
  7981. 0,
  7982. &Type,
  7983. (unsigned char *) Buffer,
  7984. &Size);
  7985. }
  7986. if ( Status != ERROR_SUCCESS
  7987. && Status != ERROR_FILE_NOT_FOUND )
  7988. {
  7989. ASSERT(0);
  7990. return ;
  7991. }
  7992. PrintToConsole("\tDHCP: %s\n", Buffer) ;
  7993. Status =
  7994. RegQueryValueExA(
  7995. hKey,
  7996. "IPAddress",
  7997. 0,
  7998. &Type,
  7999. (unsigned char *) Buffer,
  8000. &Size);
  8001. if ( Status != ERROR_SUCCESS
  8002. && Status != ERROR_FILE_NOT_FOUND )
  8003. {
  8004. ASSERT(0);
  8005. return ;
  8006. }
  8007. int i ;
  8008. for (i =0, temp1 = Buffer; address = GetNextIPAddress(&temp1); i++)
  8009. {
  8010. PrintToConsole("\tStatic IP Address [%d]: %s\n", i, address) ;
  8011. }
  8012. }
  8013. void RegLookup()
  8014. {
  8015. char *temp ;
  8016. char *Card ;
  8017. char Buffer[512] ;
  8018. RPC_STATUS Status;
  8019. HKEY hKey;
  8020. DWORD Size = 512;
  8021. DWORD Type;
  8022. PrintToConsole("RegLookup\n") ;
  8023. NumberOfTestsRun++ ;
  8024. Status =
  8025. RegOpenKeyExA(
  8026. HKEY_LOCAL_MACHINE,
  8027. "System\\CurrentControlSet\\Services\\Rpc\\Linkage",
  8028. 0,
  8029. KEY_READ,
  8030. &hKey);
  8031. if ( Status != ERROR_SUCCESS
  8032. && Status != ERROR_FILE_NOT_FOUND )
  8033. {
  8034. ASSERT(0);
  8035. return;
  8036. }
  8037. if (Status == ERROR_SUCCESS)
  8038. {
  8039. Status =
  8040. RegQueryValueExA(
  8041. hKey,
  8042. "Bind",
  8043. 0,
  8044. &Type,
  8045. (unsigned char *) Buffer,
  8046. &Size);
  8047. }
  8048. if ( Status != ERROR_SUCCESS
  8049. && Status != ERROR_FILE_NOT_FOUND )
  8050. {
  8051. ASSERT(0);
  8052. return ;
  8053. }
  8054. char *temp1;
  8055. char *address;
  8056. PrintToConsole("Cards:") ;
  8057. for (temp = Buffer; Card = GetNextCard(&temp);)
  8058. {
  8059. PrintToConsole("%s:\n", Card) ;
  8060. PrintAddresses(Card) ;
  8061. }
  8062. }
  8063. void
  8064. Except()
  8065. {
  8066. int i ;
  8067. for (i =0; i <100; i++)
  8068. {
  8069. RpcTryExcept
  8070. {
  8071. RpcRaiseException(10) ;
  8072. }
  8073. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  8074. {
  8075. PrintToConsole("exception raised!") ;
  8076. }
  8077. RpcEndExcept
  8078. }
  8079. }
  8080. char *osf_ptype[] =
  8081. {
  8082. "rpc_request",
  8083. "bad packet",
  8084. "rpc_response",
  8085. "rpc_fault",
  8086. "bad packet",
  8087. "bad packet",
  8088. "bad packet",
  8089. "bad packet",
  8090. "bad packet",
  8091. "bad packet",
  8092. "bad packet",
  8093. "rpc_bind",
  8094. "rpc_bind_ack",
  8095. "rpc_bind_nak",
  8096. "rpc_alter_context",
  8097. "rpc_alter_context_resp",
  8098. "rpc_auth_3",
  8099. "rpc_shutdown",
  8100. "rpc_cancel",
  8101. "rpc_orphaned"
  8102. };
  8103. void
  8104. PrintUuid(UUID *Uuid)
  8105. {
  8106. unsigned long PAPI * Vector;
  8107. Vector = (unsigned long PAPI *) Uuid;
  8108. if ( (Vector[0] == 0)
  8109. && (Vector[1] == 0)
  8110. && (Vector[2] == 0)
  8111. && (Vector[3] == 0))
  8112. {
  8113. PrintToConsole("(Null Uuid)");
  8114. }
  8115. else
  8116. {
  8117. PrintToConsole("%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  8118. Uuid->Data1, Uuid->Data2, Uuid->Data3, Uuid->Data4[0], Uuid->Data4[1],
  8119. Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],
  8120. Uuid->Data4[6], Uuid->Data4[7] );
  8121. }
  8122. return;
  8123. }
  8124. void do_copacket (
  8125. rpcconn_common *Packet
  8126. )
  8127. {
  8128. sec_trailer *SecurityTrailer;
  8129. //
  8130. // Dump the common header first
  8131. //
  8132. PrintToConsole("\n");
  8133. PrintToConsole ("rpc_vers\t\t- 0x%x\n", Packet->rpc_vers);
  8134. PrintToConsole ("rpc_vers_minor\t\t- 0x%x\n", Packet->rpc_vers_minor);
  8135. PrintToConsole ("PTYPE\t\t\t- 0x%x, %s\n",
  8136. Packet->PTYPE, osf_ptype[Packet->PTYPE]);
  8137. PrintToConsole ("pfc_flags\t\t- 0x%x\n", Packet->pfc_flags);
  8138. PrintToConsole ("drep\t\t\t- 0x%x\n", (DWORD) *((DWORD *) &(Packet->drep)));
  8139. PrintToConsole ("frag_length\t\t- 0x%x\n", Packet->frag_length);
  8140. PrintToConsole ("auth_length\t\t- 0x%x\n", Packet->auth_length);
  8141. PrintToConsole ("call_id\t\t\t- 0x%x\n", Packet->call_id);
  8142. //
  8143. //
  8144. // Dump the packet specific stuff
  8145. //
  8146. switch (Packet->PTYPE)
  8147. {
  8148. case rpc_request:
  8149. PrintToConsole ("alloc_hint\t\t- 0x%x\n", ((rpcconn_request *) Packet)->alloc_hint);
  8150. PrintToConsole ("p_cont_id\t\t- 0x%x\n", ((rpcconn_request *) Packet)->p_cont_id);
  8151. PrintToConsole ("opnum\t\t\t- 0x%x\n", ((rpcconn_request *) Packet)->opnum);
  8152. if (Packet->pfc_flags & PFC_OBJECT_UUID)
  8153. {
  8154. PrintToConsole("UUID\t\t -\n");
  8155. PrintUuid((UUID *) (((char *)Packet)+sizeof(rpcconn_common)));
  8156. PrintToConsole("\n");
  8157. PrintToConsole ("Stub Data\t\t- 0x%p\n",
  8158. (char *) Packet+sizeof(rpcconn_request)+sizeof(UUID));
  8159. }
  8160. else
  8161. {
  8162. PrintToConsole ("Stub Data\t\t- 0x%p\n", (char *) Packet+sizeof(rpcconn_request));
  8163. }
  8164. break;
  8165. case rpc_response:
  8166. PrintToConsole ("alloc_hint\t\t- 0x%x\n", ((rpcconn_response *) Packet)->alloc_hint);
  8167. PrintToConsole ("p_cont_id\t\t- 0x%x\n", ((rpcconn_response *) Packet)->p_cont_id);
  8168. PrintToConsole ("alert_count\t\t- 0x%x\n", ((rpcconn_response *) Packet)->alert_count);
  8169. PrintToConsole ("reserved\t\t- 0x%x\n", ((rpcconn_response *) Packet)->reserved);
  8170. PrintToConsole ("Stub Data\t\t- 0x%p\n", (char *) Packet+sizeof(rpcconn_response));
  8171. break;
  8172. case rpc_fault:
  8173. PrintToConsole ("alloc_hint\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->alloc_hint);
  8174. PrintToConsole ("p_cont_id\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->p_cont_id);
  8175. PrintToConsole ("alert_count\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->alert_count);
  8176. PrintToConsole ("reserved\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->reserved);
  8177. PrintToConsole ("status\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->status);
  8178. PrintToConsole ("reserved2\t\t- 0x%x\n", ((rpcconn_fault *) Packet)->reserved2);
  8179. break;
  8180. case rpc_bind:
  8181. case rpc_alter_context:
  8182. PrintToConsole ("max_xmit_frag\t\t- 0x%x\n", ((rpcconn_bind *) Packet)->max_xmit_frag);
  8183. PrintToConsole ("max_recv_frag\t\t- 0x%x\n", ((rpcconn_bind *) Packet)->max_recv_frag);
  8184. PrintToConsole ("assoc_group_id\t\t- 0x%x\n", ((rpcconn_bind *) Packet)->assoc_group_id);
  8185. break;
  8186. case rpc_bind_ack:
  8187. PrintToConsole ("max_xmit_frag\t\t- 0x%x\n", ((rpcconn_bind_ack *) Packet)->max_xmit_frag);
  8188. PrintToConsole ("max_recv_frag\t\t- 0x%x\n", ((rpcconn_bind_ack *) Packet)->max_recv_frag);
  8189. PrintToConsole ("assoc_group_id\t\t- 0x%x\n", ((rpcconn_bind_ack *) Packet)->assoc_group_id);
  8190. PrintToConsole ("sec_addr_length\t\t- 0x%x\n", ((rpcconn_bind_ack *) Packet)->sec_addr_length);
  8191. break;
  8192. case rpc_bind_nak:
  8193. PrintToConsole ("provider_reject_reason\t\t- 0x%x\n", ((rpcconn_bind_nak *) Packet)->provider_reject_reason);
  8194. PrintToConsole ("versions\t\t- 0x%x\n", ((rpcconn_bind_nak *) Packet)->versions);
  8195. break;
  8196. case rpc_alter_context_resp:
  8197. PrintToConsole ("max_xmit_frag\t\t- 0x%x\n", ((rpcconn_alter_context_resp *) Packet)->max_xmit_frag);
  8198. PrintToConsole ("max_recv_frag\t\t- 0x%x\n", ((rpcconn_alter_context_resp *) Packet)->max_recv_frag);
  8199. PrintToConsole ("assoc_group_id\t\t- 0x%x\n", ((rpcconn_alter_context_resp *) Packet)->assoc_group_id);
  8200. PrintToConsole ("sec_addr_length\t\t- 0x%x\n", ((rpcconn_alter_context_resp *) Packet)->sec_addr_length);
  8201. PrintToConsole ("pad\t\t- 0x%x\n", ((rpcconn_alter_context_resp *) Packet)->pad);
  8202. break;
  8203. case rpc_auth_3:
  8204. case rpc_shutdown:
  8205. case rpc_cancel:
  8206. case rpc_orphaned:
  8207. break;
  8208. default:
  8209. PrintToConsole ("Bad Packet\n");
  8210. break;
  8211. }
  8212. //
  8213. // Dump the security trailer
  8214. //
  8215. if (Packet->auth_length)
  8216. {
  8217. SecurityTrailer = (sec_trailer *) ((char *) Packet+Packet->frag_length
  8218. -Packet->auth_length - sizeof(sec_trailer));
  8219. PrintToConsole("Security trailer: 0x%p\n", SecurityTrailer);
  8220. PrintToConsole ("auth_type\t\t- 0x%x\n", SecurityTrailer->auth_type);
  8221. PrintToConsole ("auth_level\t\t- 0x%x\n", SecurityTrailer->auth_level);
  8222. PrintToConsole ("auth_pad_length\t\t- 0x%x\n", SecurityTrailer->auth_pad_length);
  8223. PrintToConsole ("auth_reserved\t\t- 0x%x\n", SecurityTrailer->auth_reserved);
  8224. PrintToConsole ("auth_context_id\t\t- 0x%x\n", SecurityTrailer->auth_context_id);
  8225. PrintToConsole ("trailer\t\t-0x%p\n", SecurityTrailer+1);
  8226. }
  8227. }
  8228. void
  8229. RpcPduFilter (
  8230. IN void *Buffer,
  8231. IN unsigned int BufferLength,
  8232. IN BOOL fDatagram
  8233. )
  8234. {
  8235. if (fDatagram == 0)
  8236. {
  8237. do_copacket((rpcconn_common *) Buffer);
  8238. }
  8239. else
  8240. {
  8241. PrintToConsole("UCNT: Datagram PDU\n");
  8242. }
  8243. }
  8244. void
  8245. SetPDUFilter (
  8246. )
  8247. {
  8248. HMODULE hLibrary;
  8249. RPC_SETFILTER_FUNC pSetFilterFunc;
  8250. hLibrary = LoadLibraryA("rpcrt4.dll");
  8251. if (hLibrary == 0)
  8252. {
  8253. PrintToConsole("UCLNT: Cannot set PDU filter\n");
  8254. return;
  8255. }
  8256. pSetFilterFunc = (RPC_SETFILTER_FUNC) GetProcAddress(
  8257. hLibrary, "I_RpcltDebugSetPDUFilter");
  8258. if (pSetFilterFunc == 0)
  8259. {
  8260. PrintToConsole("UCLNT: Cannot set PDU filter\n");
  8261. return;
  8262. }
  8263. (*pSetFilterFunc) (RpcPduFilter);
  8264. }
  8265. extern void
  8266. Async (
  8267. int testnum
  8268. ) ;
  8269. extern void
  8270. SendAck (
  8271. int testnum
  8272. ) ;
  8273. extern void
  8274. AsyncAll (
  8275. void
  8276. ) ;
  8277. int __cdecl
  8278. main (
  8279. int argc,
  8280. char * argv[]
  8281. )
  8282. /*
  8283. Transports:
  8284. Update this to add a new transport.
  8285. */
  8286. {
  8287. int argscan;
  8288. RPC_STATUS RpcStatus = RPC_S_OK;
  8289. char *option ;
  8290. int testnum = 0;
  8291. DWORD dwTickCount;
  8292. dwTickCount = GetTickCount();
  8293. InitializeCriticalSection(&TestMutex);
  8294. // Normally, this routine will be called by the DLL initialization
  8295. // routine. However, we are linking in our own copy of the threads
  8296. // package, so we need to call this to initialize it.
  8297. RpcMgmtSetCancelTimeout(20) ;
  8298. ASSERT( RpcStatus == RPC_S_OK );
  8299. PrintToConsole("RPC Runtime Client Build Verification Test\n");
  8300. TransportType = RPC_TRANSPORT_NAMEPIPE;
  8301. for (argscan = 1; argscan < argc; argscan++)
  8302. {
  8303. if (strcmp(argv[argscan], "-p") == 0)
  8304. {
  8305. ulSecurityPackage = (unsigned long) atol(argv[argscan+1]);
  8306. argscan++;
  8307. }
  8308. else if (strcmp(argv[argscan],"-princ") == 0)
  8309. {
  8310. gPrincName = argv[argscan + 1];
  8311. argscan ++;
  8312. }
  8313. else if (strcmp(argv[argscan],"-warn") == 0)
  8314. {
  8315. WarnFlag = 1;
  8316. }
  8317. else if (strcmp(argv[argscan],"-noncausal") == 0)
  8318. {
  8319. fNonCausal = 1;
  8320. }
  8321. else if (strcmp(argv[argscan],"-unique") == 0)
  8322. {
  8323. fUniqueBinding = 1;
  8324. }
  8325. else if (strcmp(argv[argscan],"-v") == 0)
  8326. {
  8327. Verbose = 1;
  8328. }
  8329. else if (strcmp(argv[argscan],"-verbose") == 0)
  8330. {
  8331. Verbose = 1;
  8332. }
  8333. else if (strcmp(argv[argscan],"-error") == 0)
  8334. {
  8335. ErrorFlag = 1;
  8336. }
  8337. else if (strcmp(argv[argscan],"-rpcss") == 0)
  8338. {
  8339. UseEndpointMapperFlag = 1;
  8340. }
  8341. else if (strcmp(argv[argscan],"-nosecuritytests") == 0)
  8342. {
  8343. NoSecurityTests = 1;
  8344. }
  8345. else if (strcmp(argv[argscan],"-nocallbacks") == 0)
  8346. {
  8347. NoCallBacksFlag = 1;
  8348. }
  8349. else if (strcmp(argv[argscan],"-small") == 0)
  8350. {
  8351. HelgaMaxSize = 1024;
  8352. }
  8353. else if (strcmp(argv[argscan],"-medium") == 0)
  8354. {
  8355. HelgaMaxSize = 8*1024;
  8356. }
  8357. else if (strcmp(argv[argscan],"-exceptfail") == 0)
  8358. {
  8359. RpcRaiseException(437);
  8360. }
  8361. else if (strcmp(argv[argscan],"-idempotent") == 0)
  8362. {
  8363. HackForOldStubs = RPC_FLAGS_VALID_BIT;
  8364. }
  8365. else if (strcmp(argv[argscan],"-theodore") == 0)
  8366. {
  8367. Theodore();
  8368. }
  8369. else if (strcmp(argv[argscan],"-sebastian") == 0)
  8370. {
  8371. Sebastian();
  8372. }
  8373. else if (strcmp(argv[argscan],"-hybrid") == 0)
  8374. {
  8375. Hybrid();
  8376. }
  8377. else if (strcmp(argv[argscan],"-lpcsecurity") == 0)
  8378. {
  8379. LpcSecurity();
  8380. }
  8381. else if (strcmp(argv[argscan],"-objuuid") == 0)
  8382. {
  8383. TestObjectUuids();
  8384. }
  8385. else if (strcmp(argv[argscan],"-connid") == 0)
  8386. {
  8387. TestConnId();
  8388. }
  8389. else if (strcmp(argv[argscan],"-graham") == 0)
  8390. {
  8391. Graham();
  8392. }
  8393. else if (strcmp(argv[argscan],"-edward") == 0)
  8394. {
  8395. Edward();
  8396. }
  8397. else if (strcmp(argv[argscan],"-astro") == 0)
  8398. {
  8399. Astro();
  8400. }
  8401. else if (strcmp(argv[argscan],"-fitzgerald") == 0)
  8402. {
  8403. Fitzgerald();
  8404. }
  8405. else if (strcmp(argv[argscan],"-charles") == 0)
  8406. {
  8407. Charles();
  8408. }
  8409. else if (strcmp(argv[argscan],"-daniel") == 0)
  8410. {
  8411. Daniel();
  8412. }
  8413. else if (strcmp(argv[argscan],"-thomas") == 0)
  8414. {
  8415. Thomas();
  8416. }
  8417. else if (strcmp(argv[argscan],"-tim") == 0)
  8418. {
  8419. Tim();
  8420. }
  8421. else if (strcmp(argv[argscan],"-robert") == 0)
  8422. {
  8423. Robert();
  8424. }
  8425. else if (strcmp(argv[argscan],"-benjamin") == 0)
  8426. {
  8427. Benjamin();
  8428. }
  8429. else if (strcmp(argv[argscan],"-harold") == 0)
  8430. {
  8431. Harold();
  8432. }
  8433. else if (strcmp(argv[argscan],"-isaac") == 0)
  8434. {
  8435. Isaac();
  8436. }
  8437. else if (strcmp(argv[argscan],"-james") == 0)
  8438. {
  8439. James();
  8440. }
  8441. else if (strcmp(argv[argscan],"-keith") == 0)
  8442. {
  8443. Keith();
  8444. }
  8445. else if (strcmp(argv[argscan],"-exerror") == 0)
  8446. {
  8447. ExtendedError();
  8448. }
  8449. else if (strcmp(argv[argscan],"-eeinfo") == 0)
  8450. {
  8451. ExtendedErrorInfo();
  8452. }
  8453. else if (strcmp(argv[argscan],"-async") == 0)
  8454. {
  8455. Async(testnum);
  8456. }
  8457. else if (strcmp(argv[argscan],"-mutextest") == 0)
  8458. {
  8459. PerformMultiThreadAstroTest(AstroDontBind, AstroMutex, 0);
  8460. }
  8461. else if (strcmp(argv[argscan],"-asynctest") == 0)
  8462. {
  8463. argscan++ ;
  8464. if (strcmp(argv[argscan], "?") == 0)
  8465. {
  8466. testnum = 100 ;
  8467. }
  8468. else
  8469. {
  8470. testnum = atoi(argv[argscan]) ;
  8471. }
  8472. }
  8473. else if (strcmp(argv[argscan],"-sendack") == 0)
  8474. {
  8475. argscan++ ;
  8476. if (argscan == argc)
  8477. {
  8478. PrintToConsole("-sendack: you must specify a test #, or zero for all, or '?' for help\n");
  8479. return 1;
  8480. }
  8481. if (strcmp(argv[argscan], "?") == 0)
  8482. {
  8483. testnum = 100 ;
  8484. }
  8485. else
  8486. {
  8487. testnum = atoi(argv[argscan]) ;
  8488. }
  8489. SendAck( testnum );
  8490. }
  8491. else if (strcmp(argv[argscan],"-dgtransport") == 0)
  8492. {
  8493. argscan++ ;
  8494. if (argscan == argc)
  8495. {
  8496. PrintToConsole("-dgtransport: you must specify a test #, or zero for all, or '?' for help\n");
  8497. return 1;
  8498. }
  8499. if (strcmp(argv[argscan], "?") == 0)
  8500. {
  8501. testnum = 100 ;
  8502. }
  8503. else
  8504. {
  8505. testnum = atoi(argv[argscan]) ;
  8506. }
  8507. DgTransport( testnum );
  8508. }
  8509. else if (strcmp(argv[argscan],"-securityerror") == 0)
  8510. {
  8511. PrintToConsole("security provider error tests \n");
  8512. argscan++ ;
  8513. if (argscan == argc)
  8514. {
  8515. PrintToConsole("-securityerror: you must specify a test #, or zero for all, or '?' for help\n");
  8516. return 1;
  8517. }
  8518. if (strcmp(argv[argscan], "?") == 0)
  8519. {
  8520. testnum = 100 ;
  8521. }
  8522. else
  8523. {
  8524. testnum = atoi(argv[argscan]) ;
  8525. }
  8526. SecurityErrorWrapper(testnum);
  8527. }
  8528. else if (strcmp(argv[argscan],"-reg") == 0)
  8529. {
  8530. RegLookup() ;
  8531. }
  8532. else if (strcmp(argv[argscan],"-pipe") == 0)
  8533. {
  8534. Pipe() ;
  8535. }
  8536. else if (strcmp(argv[argscan],"-except") == 0)
  8537. {
  8538. Except();
  8539. }
  8540. else if (strcmp(argv[argscan],"-namepipe") == 0)
  8541. {
  8542. TransportType = RPC_TRANSPORT_NAMEPIPE;
  8543. }
  8544. else if (strcmp(argv[argscan],"-lrpc") == 0)
  8545. {
  8546. TransportType = RPC_LRPC;
  8547. }
  8548. else if (strcmp(argv[argscan],"-tcp") == 0)
  8549. {
  8550. TransportType = RPC_TRANSPORT_TCP;
  8551. }
  8552. else if (strcmp(argv[argscan],"-udp") == 0)
  8553. {
  8554. DatagramTests = 1;
  8555. NoCallBacksFlag = 1;
  8556. TransportType = RPC_TRANSPORT_UDP;
  8557. }
  8558. else if (strcmp(argv[argscan],"-dnet") == 0)
  8559. {
  8560. TransportType = RPC_TRANSPORT_DNET;
  8561. }
  8562. else if (strcmp(argv[argscan],"-netbios") == 0)
  8563. {
  8564. TestDelay = LONG_TESTDELAY;
  8565. TransportType = RPC_TRANSPORT_NETBIOS;
  8566. }
  8567. else if (strcmp(argv[argscan],"-spx") == 0)
  8568. {
  8569. TransportType = RPC_TRANSPORT_SPX;
  8570. }
  8571. else if (strcmp(argv[argscan], "-dsp") == 0)
  8572. {
  8573. TransportType = RPC_TRANSPORT_DSP ;
  8574. }
  8575. else if (strcmp(argv[argscan], "-autolisten") == 0)
  8576. {
  8577. AutoListenFlag = 1 ;
  8578. }
  8579. else if (strcmp(argv[argscan], "-ifsecurity") == 0)
  8580. {
  8581. IFSecurityFlag = 1 ;
  8582. }
  8583. else if (strcmp(argv[argscan],"-ipx") == 0)
  8584. {
  8585. DatagramTests = 1;
  8586. NoCallBacksFlag = 1;
  8587. TransportType = RPC_TRANSPORT_IPX;
  8588. }
  8589. else if (strcmp(argv[argscan],"-vns") == 0)
  8590. {
  8591. TransportType = RPC_TRANSPORT_VNS;
  8592. }
  8593. else if (strcmp(argv[argscan],"-msmq") == 0)
  8594. {
  8595. DatagramTests = 1;
  8596. NoCallBacksFlag = 1;
  8597. TransportType = RPC_TRANSPORT_MSMQ;
  8598. }
  8599. else if (strcmp(argv[argscan],"-pdufilter") == 0)
  8600. {
  8601. SetPDUFilter();
  8602. }
  8603. else if (strcmp(argv[argscan],"-protocol") == 0)
  8604. {
  8605. strcpy(NetBiosProtocol+sizeof("ncacn_nb_")-1, argv[argscan+1]);
  8606. argscan++;
  8607. }
  8608. else if (strncmp(argv[argscan],"-server:",strlen("-server:")) == 0)
  8609. {
  8610. Server = argv[argscan] + strlen("-server:");
  8611. }
  8612. else if (strncmp(argv[argscan],"-su:",
  8613. strlen("-su:")) == 0)
  8614. {
  8615. SecurityUser = (char *)(argv[argscan] + strlen("-su:"));
  8616. }
  8617. else if (strncmp(argv[argscan],"-sd:",
  8618. strlen("-sd:")) == 0)
  8619. {
  8620. SecurityDomain = (char *) (argv[argscan] + strlen("-sd:"));
  8621. }
  8622. else if (strncmp(argv[argscan],"-sp:",
  8623. strlen("-sp:")) == 0)
  8624. {
  8625. SecurityPassword = (char *) (argv[argscan] + strlen("-sp:"));
  8626. }
  8627. else if (strncmp(argv[argscan],"-threads:",strlen("-threads:")) == 0)
  8628. {
  8629. AstroThreads = atoi(argv[argscan] + strlen("-threads:"));
  8630. if (AstroThreads == 0)
  8631. {
  8632. AstroThreads = 1;
  8633. }
  8634. }
  8635. else if (strncmp(argv[argscan],"-iterations:",strlen("-iterations:"))
  8636. == 0)
  8637. {
  8638. IsaacIterations = atoi(argv[argscan] + strlen("-iterations:"));
  8639. if (IsaacIterations == 0)
  8640. {
  8641. IsaacIterations = 100;
  8642. }
  8643. }
  8644. else if (strncmp(argv[argscan],"-initial:",strlen("-initial:"))
  8645. == 0)
  8646. {
  8647. IsaacInitialSize = atoi(argv[argscan] + strlen("-initial:"));
  8648. if (IsaacInitialSize < 4)
  8649. {
  8650. IsaacInitialSize = 128;
  8651. }
  8652. }
  8653. else if (strncmp(argv[argscan],"-maximum:",strlen("-maximum:"))
  8654. == 0)
  8655. {
  8656. IsaacMaximumSize = atoi(argv[argscan] + strlen("-maximum:"));
  8657. if (IsaacMaximumSize < IsaacInitialSize)
  8658. {
  8659. IsaacMaximumSize = 4096;
  8660. }
  8661. }
  8662. else if (strncmp(argv[argscan],"-increment:",strlen("-increment:"))
  8663. == 0)
  8664. {
  8665. IsaacIncrement = atoi(argv[argscan] + strlen("-increment:"));
  8666. if (IsaacIncrement == 0)
  8667. {
  8668. IsaacIncrement = 512;
  8669. }
  8670. }
  8671. else if (strncmp(argv[argscan],"-size:",strlen("-size:"))
  8672. == 0)
  8673. {
  8674. JamesSize = atoi(argv[argscan] + strlen("-size:"));
  8675. if (JamesSize <4)
  8676. {
  8677. JamesSize = 4;
  8678. }
  8679. }
  8680. else if (strncmp(argv[argscan],"-count:",strlen("-count:"))
  8681. == 0)
  8682. {
  8683. JamesCount = atoi(argv[argscan] + strlen("-count:"));
  8684. if (JamesCount == 0)
  8685. {
  8686. JamesCount = 100;
  8687. }
  8688. }
  8689. else if ( (strcmp(argv[argscan],"-usage") == 0)
  8690. || (strcmp(argv[argscan],"-?") == 0))
  8691. {
  8692. PrintToConsole("Usage : uclnt\n");
  8693. PrintToConsole(" -warn : turn on warning messages\n");
  8694. PrintToConsole(" -error : turn on error messages\n");
  8695. PrintToConsole(" -nocallbacks\n");
  8696. PrintToConsole(" -nosecuritytests\n");
  8697. PrintToConsole(" -theodore\n");
  8698. PrintToConsole(" -exceptfail\n");
  8699. PrintToConsole(" -sebastian\n");
  8700. PrintToConsole(" -graham\n");
  8701. PrintToConsole(" -edward\n");
  8702. PrintToConsole(" -astro\n");
  8703. PrintToConsole(" -fitzgerald\n");
  8704. PrintToConsole(" -charles\n");
  8705. PrintToConsole(" -daniel\n");
  8706. PrintToConsole(" -thomas\n");
  8707. PrintToConsole(" -tim\n");
  8708. PrintToConsole(" -robert\n");
  8709. PrintToConsole(" -benjamin\n");
  8710. PrintToConsole(" -harold\n");
  8711. PrintToConsole(" -isaac\n");
  8712. PrintToConsole(" -james\n");
  8713. PrintToConsole(" -keith\n");
  8714. PrintToConsole(" -hybrid\n");
  8715. PrintToConsole(" -connid\n");
  8716. PrintToConsole(" -pipe\n") ;
  8717. PrintToConsole(" -namepipe\n");
  8718. PrintToConsole(" -lrpc\n");
  8719. PrintToConsole(" -tcp\n");
  8720. PrintToConsole(" -udp [-idempotent -maybe -broadcast]\n");
  8721. PrintToConsole(" -dnet\n");
  8722. PrintToConsole(" -netbios\n");
  8723. PrintToConsole(" -server:<server>\n");
  8724. PrintToConsole(" -spx\n");
  8725. PrintToConsole(" -ipx\n");
  8726. PrintToConsole(" -dsp\n") ;
  8727. PrintToConsole(" -msmq\n") ;
  8728. PrintToConsole(" -threads:<astro threads>\n");
  8729. PrintToConsole(" -iterations:<isaac iterations>\n");
  8730. PrintToConsole(" -initial:<isaac initial size>\n");
  8731. PrintToConsole(" -maximum:<isaac maximum size>\n");
  8732. PrintToConsole(" -increment:<isaac increment>\n");
  8733. PrintToConsole(" -size:<james size>\n");
  8734. PrintToConsole(" -count:<james count>\n");
  8735. PrintToConsole(" -rpcss\n");
  8736. PrintToConsole(" -p <security provider #>\n");
  8737. PrintToConsole(" -su:<tim user>\n");
  8738. PrintToConsole(" -sd:<tim domain>\n");
  8739. PrintToConsole(" -sp:<tim password>\n");
  8740. PrintToConsole(" -unique (enables RPC_C_OPT_UNIQUE_BINDING)\n");
  8741. PrintToConsole(" -noncausal (enables RPC_C_OPT_BINDING_NONCAUSAL)\n");
  8742. return(1);
  8743. }
  8744. else if (argv[argscan][0] == '-')
  8745. {
  8746. PrintToConsole("unknown option '%s'\n", argv[argscan]);
  8747. return 1;
  8748. }
  8749. else
  8750. Server = argv[argscan];
  8751. }
  8752. if ( NumberOfTestsRun == 0 )
  8753. {
  8754. Theodore();
  8755. Sebastian();
  8756. Graham();
  8757. Edward();
  8758. Astro();
  8759. Fitzgerald();
  8760. Charles();
  8761. Daniel();
  8762. if ( NoSecurityTests == 0)
  8763. {
  8764. Thomas();
  8765. }
  8766. if ( TransportType != RPC_LRPC )
  8767. {
  8768. Robert();
  8769. }
  8770. Keith();
  8771. Benjamin();
  8772. Async(0);
  8773. }
  8774. return(0); // To keep the compiler happy.
  8775. }
  8776. //
  8777. // BVT for Async RPC
  8778. //
  8779. //
  8780. // Client side code
  8781. //
  8782. //
  8783. // the following routines outline the client side code for a simple async
  8784. // function
  8785. //
  8786. #define TRACE(_x) { \
  8787. if (Verbose) \
  8788. {\
  8789. PrintToConsole _x;\
  8790. }\
  8791. }
  8792. int OutstandingCalls ;
  8793. int FooProcnum = 16 ;
  8794. int FooPipeProcnum = 17 ;
  8795. void * FooInterface = &IsabelleInterfaceInformation;
  8796. #if 0
  8797. //
  8798. // Begin, Approximate idl file
  8799. //
  8800. interface FooInterface {
  8801. int Foo (handle_t hBinding, [in] int sizein, [in] int *bufferin,
  8802. [in, out] int *sizeout, [out] int **bufferout) ;
  8803. }
  8804. // End, idl file
  8805. //
  8806. // Begin, Corresponding ACF file
  8807. //
  8808. interface FooInterface {
  8809. [async] Foo () ;
  8810. }
  8811. // End, acf file
  8812. //
  8813. // look at asyncstub.h for the generated header
  8814. // file for function Foo
  8815. //
  8816. #endif
  8817. ////////////////////////////////////////////////////////////
  8818. // Begin, stubs for Foo //
  8819. ////////////////////////////////////////////////////////////
  8820. HANDLE SyncEvent ;
  8821. typedef struct {
  8822. RPC_ASYNC_STUB_STATE StubState ;
  8823. void *state ;
  8824. int *sizeout ;
  8825. int **bufferout ;
  8826. } FOO_ASYNC_CLIENT_STATE;
  8827. RPC_STATUS
  8828. FooComplete(
  8829. IN PRPC_ASYNC_STATE pAsync,
  8830. OUT void *Reply
  8831. )
  8832. /*++
  8833. Routine Description:
  8834. The completion routine corresponding to the function Foo. This routine
  8835. is called to get the out parameters from an async function.
  8836. Arguments:
  8837. pAsync - Async Handle. The async handle is always the first parameter of every
  8838. async routine.
  8839. --*/
  8840. {
  8841. RPC_STATUS Status ;
  8842. RPC_MESSAGE Message ;
  8843. int *ptr ;
  8844. FOO_ASYNC_CLIENT_STATE *StubInfo =
  8845. (FOO_ASYNC_CLIENT_STATE *) pAsync->StubInfo ;
  8846. Message.RpcInterfaceInformation = FooInterface ;
  8847. Message.RpcFlags = RPC_BUFFER_ASYNC;
  8848. Message.Handle = StubInfo->StubState.CallHandle ;
  8849. Message.Buffer = StubInfo->StubState.Buffer ;
  8850. Message.BufferLength = StubInfo->StubState.BufferLength ;
  8851. Status = I_RpcReceive(&Message, 0) ;
  8852. if (Status)
  8853. {
  8854. return Status ;
  8855. }
  8856. ptr = (int *) Message.Buffer ;
  8857. *((int *) Reply) = *ptr++ ;
  8858. *(StubInfo->sizeout) = *ptr++ ;
  8859. *(StubInfo->bufferout) = (int *) I_RpcAllocate(*(StubInfo->sizeout)) ;
  8860. if (*(StubInfo->bufferout) == 0)
  8861. {
  8862. return RPC_S_OUT_OF_MEMORY ;
  8863. }
  8864. RpcpMemoryCopy(*(StubInfo->bufferout), ptr, *(StubInfo->sizeout)) ;
  8865. I_RpcFreeBuffer(&Message) ;
  8866. I_RpcFree(StubInfo) ;
  8867. return RPC_S_OK ;
  8868. }
  8869. void
  8870. Foo (
  8871. PRPC_ASYNC_STATE pAsync,
  8872. RPC_BINDING_HANDLE hBinding,
  8873. /* [in] */ int sizein,
  8874. /* [in] */ int *bufferin,
  8875. /* [in, out] */ int *sizeout,
  8876. /* [out] */ int **bufferout
  8877. )
  8878. /*++
  8879. Routine Description:
  8880. Client stub for function Foo.
  8881. Arguments:
  8882. pAsync - Async Handle. The async handle is always the first parameter of every
  8883. async routine.
  8884. --*/
  8885. {
  8886. RPC_STATUS RpcStatus ;
  8887. RPC_MESSAGE Message ;
  8888. FOO_ASYNC_CLIENT_STATE *StubInfo ;
  8889. int *Ptr ;
  8890. StubInfo = (FOO_ASYNC_CLIENT_STATE *) I_RpcAllocate (
  8891. sizeof(FOO_ASYNC_CLIENT_STATE)) ;
  8892. if (StubInfo == 0)
  8893. {
  8894. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  8895. }
  8896. pAsync->StubInfo = (void *) StubInfo ;
  8897. StubInfo->StubState.CallHandle = hBinding ;
  8898. Message.Handle = hBinding ;
  8899. Message.BufferLength = 8+sizein+(sizein%4) ;
  8900. Message.ProcNum = FooProcnum | HackForOldStubs | RPC_FLAGS_VALID_BIT ;
  8901. Message.RpcInterfaceInformation = FooInterface ;
  8902. Message.RpcFlags = RPC_BUFFER_ASYNC ;
  8903. RpcStatus = I_RpcGetBuffer(&Message) ;
  8904. if (RpcStatus)
  8905. {
  8906. RpcRaiseException(RpcStatus) ;
  8907. }
  8908. // marshal ;-)
  8909. Ptr = (int *) Message.Buffer ;
  8910. *Ptr++ = sizein ;
  8911. RpcpMemoryCopy(Ptr, bufferin, sizein) ;
  8912. Ptr += (sizein+3)/sizeof(int) ;
  8913. *Ptr = *sizeout ;
  8914. StubInfo->StubState.Flags = 0;
  8915. StubInfo->sizeout = sizeout ;
  8916. StubInfo->bufferout = bufferout ;
  8917. RpcStatus = I_RpcAsyncSetHandle(&Message, (PRPC_ASYNC_STATE) pAsync) ;
  8918. if (RpcStatus)
  8919. {
  8920. RpcRaiseException(RpcStatus) ;
  8921. }
  8922. StubInfo->StubState.CompletionRoutine = FooComplete ;
  8923. Message.RpcFlags = RPC_BUFFER_ASYNC;
  8924. RpcStatus = I_RpcSend(&Message) ;
  8925. if (RpcStatus)
  8926. {
  8927. RpcRaiseException(RpcStatus) ;
  8928. }
  8929. StubInfo->StubState.CallHandle = Message.Handle ;
  8930. StubInfo->StubState.Buffer = Message.Buffer ;
  8931. StubInfo->StubState.BufferLength = Message.BufferLength ;
  8932. // return to the app
  8933. }
  8934. int
  8935. FooSync (
  8936. RPC_BINDING_HANDLE hBinding,
  8937. /* [in] */ int sizein,
  8938. /* [in] */ int *bufferin,
  8939. /* [in, out] */ int *sizeout,
  8940. /* [out] */ int **bufferout
  8941. )
  8942. /*++
  8943. Routine Description:
  8944. Client stub for function Foo.
  8945. Arguments:
  8946. pAsync - Async Handle. The async handle is always the first parameter of every
  8947. async routine.
  8948. --*/
  8949. {
  8950. RPC_STATUS RpcStatus ;
  8951. RPC_MESSAGE Message ;
  8952. int *Ptr ;
  8953. int retval ;
  8954. Message.Handle = hBinding ;
  8955. Message.BufferLength = 8+sizein+(sizein%4) ;
  8956. Message.ProcNum = FooProcnum | HackForOldStubs | RPC_FLAGS_VALID_BIT ;
  8957. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  8958. Message.RpcFlags = 0;
  8959. RpcStatus = I_RpcGetBuffer(&Message) ;
  8960. if (RpcStatus)
  8961. {
  8962. RpcRaiseException(RpcStatus) ;
  8963. }
  8964. Ptr = (int *) Message.Buffer ;
  8965. *Ptr++ = sizein ;
  8966. RpcpMemoryCopy(Ptr, bufferin, sizein) ;
  8967. Ptr += (sizein+3)/sizeof(int) ;
  8968. *Ptr = *sizeout ;
  8969. Message.RpcFlags = 0;
  8970. RpcStatus = I_RpcSendReceive(&Message) ;
  8971. if (RpcStatus)
  8972. {
  8973. RpcRaiseException(RpcStatus) ;
  8974. }
  8975. *bufferout = (int *) I_RpcAllocate(*sizeout) ;
  8976. if (*bufferout == 0)
  8977. {
  8978. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  8979. }
  8980. Ptr = (int *) Message.Buffer ;
  8981. retval = *Ptr++ ;
  8982. *sizeout = *Ptr++;
  8983. RpcpMemoryCopy(*bufferout, Ptr, *sizeout) ;
  8984. I_RpcFreeBuffer(&Message) ;
  8985. return retval ;
  8986. }
  8987. ////////////////////////////////////////////////////////////
  8988. // End, stubs for Foo //
  8989. ////////////////////////////////////////////////////////////
  8990. ///////////////////////////////////////////////////////////
  8991. // Begin, Application //
  8992. //////////////////////////////////////////////////////////
  8993. typedef struct {
  8994. RPC_ASYNC_STATE Async ;
  8995. int SizeOut ;
  8996. int *BufferOut ;
  8997. BOOL CallFinished ;
  8998. } CALL_COOKIE ;
  8999. void
  9000. ThreadProc(
  9001. IN CALL_COOKIE *Cookie
  9002. )
  9003. /*++
  9004. Routine Description:
  9005. completion routine is called in another thread. To prove that it can be.
  9006. Arguments:
  9007. pAsync - Async Handle. The async handle is always the first parameter of every
  9008. async routine.
  9009. --*/
  9010. {
  9011. int retval ;
  9012. TRACE(("Foo: waiting for aync reply\n")) ;
  9013. RpcTryExcept
  9014. {
  9015. WaitForSingleObject(Cookie->Async.u.hEvent, INFINITE) ;
  9016. Status = MyRpcCompleteAsyncCall(&Cookie->Async, &retval) ;
  9017. if (Status != RPC_S_OK)
  9018. {
  9019. RpcRaiseException(Status) ;
  9020. }
  9021. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  9022. if (retval != 1)
  9023. {
  9024. RpcRaiseException(APP_ERROR) ;
  9025. }
  9026. I_RpcFree(Cookie->BufferOut) ;
  9027. }
  9028. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9029. {
  9030. PrintToConsole("Foo: Exception 0x%lX\n", GetExceptionCode()) ;
  9031. IsabelleError() ;
  9032. }
  9033. RpcEndExcept
  9034. SetEvent(SyncEvent) ;
  9035. }
  9036. void
  9037. WaitForReply (
  9038. IN BOOL *pfCallFinished
  9039. )
  9040. {
  9041. do
  9042. {
  9043. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  9044. {
  9045. RpcRaiseException(APP_ERROR);
  9046. }
  9047. } while (*pfCallFinished == 0);
  9048. }
  9049. void
  9050. FooAPCRoutine (
  9051. IN PRPC_ASYNC_STATE pAsync,
  9052. IN void *Context,
  9053. IN RPC_ASYNC_EVENT Event
  9054. )
  9055. /*++
  9056. Routine Description:
  9057. description
  9058. Arguments:
  9059. arg1 - description
  9060. --*/
  9061. {
  9062. CALL_COOKIE *Cookie = (CALL_COOKIE *) pAsync->UserInfo ;
  9063. switch (Event)
  9064. {
  9065. case RpcCallComplete:
  9066. Cookie->CallFinished = 1;
  9067. OutstandingCalls--;
  9068. break;
  9069. }
  9070. }
  9071. void
  9072. CallFoo (
  9073. RPC_BINDING_HANDLE Binding,
  9074. CALL_COOKIE *Cookie,
  9075. RPC_NOTIFICATION_TYPES NotificationType,
  9076. int SizeIn,
  9077. int SizeOut
  9078. )
  9079. /*++
  9080. Routine Description:
  9081. description
  9082. Arguments:
  9083. arg1 - description
  9084. --*/
  9085. {
  9086. int *BufferIn ;
  9087. BufferIn = (int *) new char[SizeIn] ;
  9088. if (BufferIn == 0)
  9089. {
  9090. RpcRaiseException(APP_ERROR) ;
  9091. }
  9092. Cookie->SizeOut = SizeOut ;
  9093. Cookie->Async.Size = sizeof(RPC_ASYNC_STATE) ;
  9094. Cookie->Async.Flags = 0;
  9095. Cookie->Async.Lock = 0;
  9096. Cookie->Async.NotificationType = NotificationType ;
  9097. switch (NotificationType)
  9098. {
  9099. case RpcNotificationTypeNone:
  9100. break;
  9101. case RpcNotificationTypeEvent:
  9102. Cookie->Async.u.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  9103. if (Cookie->Async.u.hEvent == 0)
  9104. {
  9105. RpcRaiseException(APP_ERROR) ;
  9106. }
  9107. Cookie->Async.NotificationType = RpcNotificationTypeEvent ;
  9108. break;
  9109. case RpcNotificationTypeApc:
  9110. Cookie->Async.NotificationType = RpcNotificationTypeApc ;
  9111. Cookie->Async.u.APC.NotificationRoutine = FooAPCRoutine ;
  9112. Cookie->Async.u.APC.hThread = 0;
  9113. Cookie->CallFinished = 0;
  9114. break;
  9115. default:
  9116. PrintToConsole("Async: bad notification type\n") ;
  9117. break;
  9118. }
  9119. Cookie->Async.UserInfo = (void *) Cookie ;
  9120. // call the async function
  9121. // the buffers supplied for the [out] and the [in, out] params
  9122. // should be valid until the logical RPC call has completed.
  9123. Foo(&Cookie->Async,
  9124. Binding,
  9125. SizeIn,
  9126. BufferIn,
  9127. &Cookie->SizeOut,
  9128. &Cookie->BufferOut) ;
  9129. delete BufferIn ;
  9130. }
  9131. void
  9132. AsyncUsingEvent(
  9133. IN RPC_BINDING_HANDLE Binding,
  9134. int SizeIn,
  9135. int SizeOut
  9136. )
  9137. /*++
  9138. Routine Description:
  9139. The code that calls the async function.
  9140. Arguments:
  9141. Binding - the binding handle.
  9142. --*/
  9143. {
  9144. RPC_STATUS Status ;
  9145. int userstate = 10;
  9146. unsigned long ThreadIdentifier;
  9147. HANDLE HandleToThread ;
  9148. CALL_COOKIE *Cookie = 0;
  9149. RpcTryExcept
  9150. {
  9151. Cookie =new CALL_COOKIE ;
  9152. if (Cookie == 0)
  9153. {
  9154. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  9155. }
  9156. CallFoo (Binding, Cookie, RpcNotificationTypeEvent, SizeIn, SizeOut) ;
  9157. HandleToThread = CreateThread(
  9158. 0,
  9159. DefaultThreadStackSize,
  9160. (LPTHREAD_START_ROUTINE) ThreadProc,
  9161. Cookie,
  9162. 0,
  9163. &ThreadIdentifier);
  9164. if (HandleToThread == 0)
  9165. {
  9166. PrintToConsole("Foo: Error, couldn't create thread\n") ;
  9167. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  9168. }
  9169. // wait for the other guy to finish
  9170. TRACE(("Foo: Waiting...\n")) ;
  9171. WaitForSingleObject(SyncEvent, INFINITE) ;
  9172. }
  9173. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9174. {
  9175. PrintToConsole("Foo: Exception 0x%lX\n", GetExceptionCode()) ;
  9176. IsabelleError() ;
  9177. }
  9178. RpcEndExcept
  9179. if (Cookie && Cookie->Async.u.hEvent)
  9180. {
  9181. CloseHandle(Cookie->Async.u.hEvent) ;
  9182. }
  9183. }
  9184. void
  9185. AsyncUsingAPC(
  9186. RPC_BINDING_HANDLE Binding,
  9187. int SizeIn,
  9188. int SizeOut
  9189. )
  9190. /*++
  9191. Routine Description:
  9192. The code that calls the async function.
  9193. Arguments:
  9194. Binding - the binding handle.
  9195. --*/
  9196. {
  9197. RPC_STATUS Status ;
  9198. CALL_COOKIE Cookie ;
  9199. int retval ;
  9200. RpcTryExcept
  9201. {
  9202. CallFoo(Binding, &Cookie, RpcNotificationTypeApc, SizeIn, SizeOut) ;
  9203. WaitForReply(&(Cookie.CallFinished));
  9204. Status = MyRpcCompleteAsyncCall(&Cookie.Async, &retval) ;
  9205. if (Status != RPC_S_OK)
  9206. {
  9207. RpcRaiseException(Status) ;
  9208. }
  9209. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  9210. if (retval != 1)
  9211. {
  9212. RpcRaiseException(APP_ERROR) ;
  9213. }
  9214. I_RpcFree(Cookie.BufferOut) ;
  9215. }
  9216. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9217. {
  9218. PrintToConsole("Foo: Exception 0x%lX\n", GetExceptionCode()) ;
  9219. Status = GetExceptionCode() ;
  9220. if (Status == SYNC_EXCEPT
  9221. || Status == ASYNC_EXCEPT)
  9222. {
  9223. RpcRaiseException(Status) ;
  9224. }
  9225. else
  9226. {
  9227. IsabelleError() ;
  9228. }
  9229. }
  9230. RpcEndExcept
  9231. }
  9232. void
  9233. AsyncUsingPolling(
  9234. RPC_BINDING_HANDLE Binding,
  9235. int SizeIn,
  9236. int SizeOut
  9237. )
  9238. /*++
  9239. Routine Description:
  9240. The code that calls the async function.
  9241. Arguments:
  9242. Binding - the binding handle.
  9243. --*/
  9244. {
  9245. RPC_STATUS Status ;
  9246. CALL_COOKIE Cookie ;
  9247. int retval ;
  9248. RpcTryExcept
  9249. {
  9250. CallFoo(Binding, &Cookie, RpcNotificationTypeNone, SizeIn, SizeOut) ;
  9251. while ((Status = RpcAsyncGetCallStatus(&Cookie.Async))
  9252. == RPC_S_ASYNC_CALL_PENDING)
  9253. {
  9254. Sleep(1) ;
  9255. }
  9256. if (Status != RPC_S_OK)
  9257. {
  9258. RpcRaiseException(Status) ;
  9259. }
  9260. Status = MyRpcCompleteAsyncCall(&Cookie.Async, &retval) ;
  9261. if (Status != RPC_S_OK)
  9262. {
  9263. RpcRaiseException(Status) ;
  9264. }
  9265. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  9266. if (retval != 1)
  9267. {
  9268. RpcRaiseException(APP_ERROR) ;
  9269. }
  9270. I_RpcFree(Cookie.BufferOut) ;
  9271. }
  9272. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9273. {
  9274. PrintToConsole("Foo: Exception 0x%lX\n", GetExceptionCode()) ;
  9275. Status = GetExceptionCode() ;
  9276. if (Status == SYNC_EXCEPT
  9277. || Status == ASYNC_EXCEPT)
  9278. {
  9279. RpcRaiseException(Status) ;
  9280. }
  9281. else
  9282. {
  9283. IsabelleError() ;
  9284. }
  9285. }
  9286. RpcEndExcept
  9287. }
  9288. ///////////////////////////////////////////////////////////
  9289. // End, Application //
  9290. //////////////////////////////////////////////////////////
  9291. //
  9292. // The following routines outline the client side code for a simple async function
  9293. // using pipes.
  9294. //
  9295. #if 0
  9296. //
  9297. // Begin, Approximate idl file
  9298. //
  9299. interface FooInterface {
  9300. typedef pipe int aysnc_intpipe ;
  9301. int FooPipe (handle_t hBinding, [in] int checksum_in, [in] async_intpipe *inpipe,
  9302. [out] async_intpipe *outpipe, [out] int *checksum_out) ;
  9303. } ;
  9304. // End, idl file
  9305. //
  9306. // Begin, corresponding acf file
  9307. //
  9308. interface FooInterface {
  9309. [async] Foo () ;
  9310. } ;
  9311. //
  9312. // End, acf file
  9313. //
  9314. //
  9315. // look at asyncstub.h for generated header
  9316. // file for function FooPipe
  9317. //
  9318. #endif
  9319. ////////////////////////////////////////////////////////////
  9320. // Begin, stubs for FooPipe //
  9321. ////////////////////////////////////////////////////////////
  9322. // declare the async handle
  9323. typedef struct {
  9324. RPC_ASYNC_STUB_STATE StubState ;
  9325. void *state ;
  9326. async_intpipe outpipe ;
  9327. int *checksum_out;
  9328. } FOOPIPE_ASYNC_CLIENT_STATE, *FOOPIPE_ASYNC_CLIENT_HANDLE ;
  9329. #define ASYNC_CHUNK_SIZE 1000
  9330. #define ASYNC_NUM_CHUNKS 20
  9331. RPC_STATUS
  9332. PipeReceiveFunction (
  9333. IN PRPC_ASYNC_STATE pAsync,
  9334. IN int *buffer,
  9335. IN int requested_count,
  9336. IN int *actual_count
  9337. )
  9338. /*++
  9339. Function Name:PipeReceiveFunction
  9340. Parameters:
  9341. Description:
  9342. Returns:
  9343. --*/
  9344. {
  9345. int num_elements = 0;
  9346. RPC_MESSAGE Callee ;
  9347. FOOPIPE_ASYNC_CLIENT_STATE *StubInfo =
  9348. (FOOPIPE_ASYNC_CLIENT_STATE *) pAsync->StubInfo ;
  9349. PIPE_STATE *state = &(StubInfo->StubState.PipeState);
  9350. DWORD size = (DWORD) requested_count * state->PipeElementSize ;
  9351. *actual_count = 0 ;
  9352. if (state->EndOfPipe)
  9353. {
  9354. return RPC_S_OK;
  9355. }
  9356. I_RpcReadPipeElementsFromBuffer(
  9357. state,
  9358. (char *) buffer,
  9359. size,
  9360. &num_elements) ;
  9361. *actual_count += num_elements ;
  9362. size -= num_elements * state->PipeElementSize ;
  9363. if (state->EndOfPipe == 0 &&
  9364. num_elements < requested_count)
  9365. {
  9366. Callee.ProcNum = RPC_FLAGS_VALID_BIT ;
  9367. Callee.Handle = StubInfo->StubState.CallHandle ;
  9368. Callee.RpcFlags = RPC_BUFFER_PARTIAL | RPC_BUFFER_ASYNC ;
  9369. if (num_elements)
  9370. {
  9371. Callee.RpcFlags |= RPC_BUFFER_NONOTIFY;
  9372. }
  9373. Callee.Buffer = 0 ;
  9374. Callee.BufferLength = 0 ;
  9375. Status = I_RpcReceive(&Callee, size) ;
  9376. if (Status)
  9377. {
  9378. if (num_elements && Status == RPC_S_ASYNC_CALL_PENDING)
  9379. {
  9380. num_elements = 0 ;
  9381. return RPC_S_OK;
  9382. }
  9383. if (Status != RPC_S_ASYNC_CALL_PENDING)
  9384. {
  9385. ApiError("PipePull", "I_RpcReceive", Status) ;
  9386. }
  9387. num_elements = 0 ;
  9388. return Status;
  9389. }
  9390. state->Buffer = Callee.Buffer ;
  9391. state->BufferLength = Callee.BufferLength ;
  9392. state->CurPointer = (char *) Callee.Buffer ;
  9393. state->BytesRemaining = Callee.BufferLength ;
  9394. buffer = (pipe_element_t *)
  9395. ((char *) buffer + num_elements * state->PipeElementSize) ;
  9396. num_elements = 0 ;
  9397. I_RpcReadPipeElementsFromBuffer(
  9398. state,
  9399. (char *) buffer,
  9400. size,
  9401. &num_elements) ;
  9402. *actual_count += num_elements ;
  9403. }
  9404. return RPC_S_OK;
  9405. }
  9406. RPC_STATUS
  9407. PipeSendFunction (
  9408. IN PRPC_ASYNC_STATE pAsync,
  9409. IN void *context,
  9410. IN int *buffer,
  9411. IN int num_elements
  9412. )
  9413. /*++
  9414. Routine Description:
  9415. this function is always implemented by the stubs. This routine is called by
  9416. the application, to send pipe data.
  9417. Arguments:
  9418. pAsync - Async Handle. The async handle is always the first parameter of every
  9419. async routine.
  9420. --*/
  9421. {
  9422. unsigned int Flags = 0;
  9423. RPC_STATUS RpcStatus ;
  9424. RPC_MESSAGE Message ;
  9425. FOOPIPE_ASYNC_CLIENT_STATE *StubInfo =
  9426. (FOOPIPE_ASYNC_CLIENT_STATE *) pAsync->StubInfo ;
  9427. int calculated_length = num_elements * sizeof(int) + sizeof(int);
  9428. char *ptr ;
  9429. Message.ProcNum = FooPipeProcnum | HackForOldStubs;
  9430. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  9431. Message.Handle = StubInfo->StubState.CallHandle ;
  9432. Message.Buffer = StubInfo->StubState.Buffer ;
  9433. Message.BufferLength = StubInfo->StubState.BufferLength;
  9434. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  9435. {
  9436. calculated_length += StubInfo->StubState.BufferLength ;
  9437. }
  9438. Message.RpcFlags = RPC_BUFFER_ASYNC ;
  9439. RpcStatus = I_RpcReallocPipeBuffer (&Message, calculated_length) ;
  9440. if (RpcStatus != RPC_S_OK)
  9441. {
  9442. return RpcStatus;
  9443. }
  9444. ptr = (char *) Message.Buffer ;
  9445. if (StubInfo->StubState.State == SEND_INCOMPLETE)
  9446. {
  9447. ptr += StubInfo->StubState.BufferLength ;
  9448. }
  9449. *((int *) ptr) = num_elements ;
  9450. RpcpMemoryCopy(ptr+sizeof(int), buffer, num_elements *sizeof(int)) ;
  9451. if (num_elements) // || !lastpipe
  9452. {
  9453. Message.RpcFlags = RPC_BUFFER_PARTIAL ;
  9454. }
  9455. else
  9456. {
  9457. // we are making a simplifying assumption
  9458. // that there is a single [in] pipe.
  9459. Message.RpcFlags = 0;
  9460. }
  9461. Message.RpcFlags |= RPC_BUFFER_ASYNC;
  9462. RpcStatus = I_RpcSend(&Message) ;
  9463. if (RpcStatus == RPC_S_OK)
  9464. {
  9465. StubInfo->StubState.State = SEND_COMPLETE ;
  9466. }
  9467. else if (RpcStatus == RPC_S_SEND_INCOMPLETE)
  9468. {
  9469. StubInfo->StubState.State = SEND_INCOMPLETE ;
  9470. }
  9471. else
  9472. {
  9473. return RpcStatus;
  9474. }
  9475. StubInfo->StubState.Buffer = Message.Buffer ;
  9476. StubInfo->StubState.BufferLength = Message.BufferLength ;
  9477. return RPC_S_OK;
  9478. }
  9479. RPC_STATUS
  9480. FooPipeComplete(
  9481. IN PRPC_ASYNC_STATE pAsync,
  9482. IN void *Reply
  9483. )
  9484. /*++
  9485. Routine Description:
  9486. Stub for the completion routine of FooPipe
  9487. Arguments:
  9488. pAsync - Async Handle. The async handle is always the first parameter of every
  9489. async routine.
  9490. --*/
  9491. {
  9492. RPC_STATUS Status ;
  9493. RPC_MESSAGE Message ;
  9494. void *ptr ;
  9495. int retval;
  9496. UINT_PTR offset ;
  9497. FOOPIPE_ASYNC_CLIENT_STATE *StubInfo =
  9498. (FOOPIPE_ASYNC_CLIENT_STATE *) pAsync->StubInfo ;
  9499. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  9500. Message.Handle = StubInfo->StubState.CallHandle ;
  9501. Message.Buffer = StubInfo->StubState.PipeState.Buffer;
  9502. Message.BufferLength = 0;
  9503. if (StubInfo->StubState.PipeState.BytesRemaining < 8)
  9504. {
  9505. Message.RpcFlags = RPC_BUFFER_ASYNC|RPC_BUFFER_EXTRA;
  9506. Status = I_RpcReceive(&Message, 8) ;
  9507. if (Status)
  9508. {
  9509. return Status ;
  9510. }
  9511. // just being paranoid here. I didn't want an overflow.
  9512. offset = StubInfo->StubState.PipeState.CurPointer
  9513. - (char *) StubInfo->StubState.PipeState.Buffer ;
  9514. ptr = (char *) Message.Buffer + offset ;
  9515. }
  9516. else
  9517. {
  9518. ptr = StubInfo->StubState.PipeState.CurPointer ;
  9519. if (!ptr)
  9520. {
  9521. return RPC_S_OUT_OF_MEMORY ;
  9522. }
  9523. }
  9524. *((int *) Reply) = *((int *) ptr) ;
  9525. *(StubInfo->checksum_out) = *(((int *) ptr)+1) ;
  9526. I_RpcFreeBuffer(&Message) ;
  9527. I_RpcFree(StubInfo) ;
  9528. return RPC_S_OK ;
  9529. }
  9530. int tempint ;
  9531. void
  9532. FooPipe (
  9533. PRPC_ASYNC_STATE pAsync,
  9534. RPC_BINDING_HANDLE hBinding,
  9535. /* [in] */ int checksum_in,
  9536. /* [in] */ async_intpipe *inpipe,
  9537. /* [out] */ async_intpipe *outpipe,
  9538. /* [out] */ int *checksum_out
  9539. )
  9540. /*++
  9541. Routine Description:
  9542. The stub routine for FooPipe function.
  9543. Arguments:
  9544. pAsync - Async Handle. The async handle is always the first parameter of every
  9545. async routine.
  9546. --*/
  9547. {
  9548. RPC_STATUS RpcStatus ;
  9549. RPC_MESSAGE Message ;
  9550. FOOPIPE_ASYNC_CLIENT_STATE *StubInfo ;
  9551. StubInfo = (FOOPIPE_ASYNC_CLIENT_STATE *) I_RpcAllocate (
  9552. sizeof(FOOPIPE_ASYNC_CLIENT_STATE)) ;
  9553. if (StubInfo == 0)
  9554. {
  9555. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  9556. }
  9557. pAsync->StubInfo = (void *) StubInfo ;
  9558. StubInfo->StubState.CallHandle = hBinding ;
  9559. Message.Handle = hBinding ;
  9560. Message.BufferLength = 4 ;
  9561. Message.ProcNum = FooPipeProcnum | HackForOldStubs | RPC_FLAGS_VALID_BIT ;
  9562. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  9563. Message.RpcFlags = RPC_BUFFER_ASYNC | RPC_BUFFER_PARTIAL ;
  9564. RpcStatus = I_RpcGetBuffer(&Message) ;
  9565. if (RpcStatus)
  9566. {
  9567. RpcRaiseException(RpcStatus) ;
  9568. }
  9569. // initialize the async handle and register it with the
  9570. // RPC runtime.
  9571. StubInfo->StubState.PipeState.Buffer = 0;
  9572. StubInfo->StubState.PipeState.CurrentState = start;
  9573. StubInfo->StubState.PipeState.CurPointer = 0;
  9574. StubInfo->StubState.PipeState.BytesRemaining = 0;
  9575. StubInfo->StubState.PipeState.EndOfPipe = 0;
  9576. StubInfo->StubState.PipeState.PipeElementSize = sizeof(int);
  9577. StubInfo->StubState.PipeState.PartialPipeElement = &tempint;
  9578. StubInfo->StubState.PipeState.PreviousBuffer = 0;
  9579. RpcStatus = I_RpcAsyncSetHandle(&Message, pAsync) ;
  9580. if (RpcStatus)
  9581. {
  9582. RpcRaiseException(RpcStatus) ;
  9583. }
  9584. *((int *) Message.Buffer) = checksum_in ;
  9585. inpipe->PipeSend = PipeSendFunction ;
  9586. outpipe->PipeReceive = PipeReceiveFunction;
  9587. StubInfo->StubState.CompletionRoutine = FooPipeComplete ;
  9588. StubInfo->checksum_out = checksum_out ;
  9589. Message.RpcFlags = RPC_BUFFER_PARTIAL| RPC_BUFFER_ASYNC;
  9590. RpcStatus = I_RpcSend(&Message) ;
  9591. if (RpcStatus == RPC_S_OK)
  9592. {
  9593. StubInfo->StubState.State = SEND_COMPLETE ;
  9594. }
  9595. else if (RpcStatus == RPC_S_SEND_INCOMPLETE)
  9596. {
  9597. StubInfo->StubState.State = SEND_INCOMPLETE ;
  9598. }
  9599. else
  9600. {
  9601. RpcRaiseException(RpcStatus) ;
  9602. }
  9603. StubInfo->StubState.CallHandle = Message.Handle ;
  9604. StubInfo->StubState.Buffer = Message.Buffer ;
  9605. StubInfo->StubState.BufferLength = Message.BufferLength ;
  9606. }
  9607. ////////////////////////////////////////////////////////////
  9608. // End, stubs for FooPipe //
  9609. ////////////////////////////////////////////////////////////
  9610. ////////////////////////////////////////////////////////////
  9611. // Begin, Application //
  9612. ////////////////////////////////////////////////////////////
  9613. typedef struct {
  9614. RPC_ASYNC_STATE Async ;
  9615. async_intpipe inpipe ;
  9616. async_intpipe outpipe ;
  9617. BOOL CallFinished ;
  9618. BOOL PipeDataSent;
  9619. int checksum_out;
  9620. int PipeChecksum ;
  9621. int PipeBuffer[ASYNC_CHUNK_SIZE] ;
  9622. int ExpectedValue;
  9623. int i ;
  9624. } PIPE_CALL_COOKIE ;
  9625. int PipeCount = 0;
  9626. void
  9627. FooPipeAPCRoutine (
  9628. IN PRPC_ASYNC_STATE pAsync,
  9629. IN void *Context,
  9630. IN RPC_ASYNC_EVENT Event
  9631. )
  9632. /*++
  9633. Routine Description:
  9634. description
  9635. Arguments:
  9636. arg1 - description
  9637. --*/
  9638. {
  9639. PIPE_CALL_COOKIE *Cookie = (PIPE_CALL_COOKIE *) pAsync->UserInfo ;
  9640. switch (Event)
  9641. {
  9642. case RpcSendComplete:
  9643. if (Cookie->i % 7)
  9644. {
  9645. Sleep(10);
  9646. }
  9647. if (Cookie->i <ASYNC_NUM_CHUNKS)
  9648. {
  9649. Cookie->i++ ;
  9650. Status = Cookie->inpipe.PipeSend(
  9651. pAsync,
  9652. 0,
  9653. (int *) Cookie->PipeBuffer,
  9654. ASYNC_CHUNK_SIZE) ;
  9655. }
  9656. else
  9657. {
  9658. ASSERT(Cookie->PipeDataSent == 0);
  9659. pAsync->Flags = 0;
  9660. Status = Cookie->inpipe.PipeSend(
  9661. pAsync,
  9662. 0, 0, 0) ;
  9663. Cookie->PipeDataSent = 1;
  9664. }
  9665. if (Status != RPC_S_OK)
  9666. {
  9667. PrintToConsole("FooPipeAPCRoutine: PipeSend failed\n");
  9668. IsabelleError();
  9669. }
  9670. break;
  9671. case RpcCallComplete:
  9672. Cookie->CallFinished = 1;
  9673. OutstandingCalls-- ;
  9674. break;
  9675. }
  9676. }
  9677. void
  9678. CallFooPipe (
  9679. RPC_BINDING_HANDLE Binding,
  9680. PIPE_CALL_COOKIE *Cookie,
  9681. RPC_NOTIFICATION_TYPES NotificationType
  9682. )
  9683. /*++
  9684. Routine Description:
  9685. description
  9686. Arguments:
  9687. arg1 - description
  9688. --*/
  9689. {
  9690. int Checksum = 0;
  9691. int n ;
  9692. int *ptr ;
  9693. Cookie->Async.Size = sizeof(RPC_ASYNC_STATE) ;
  9694. Cookie->Async.UserInfo = (void *) Cookie ;
  9695. Cookie->outpipe.state = 0;
  9696. Cookie->inpipe.state = 0;
  9697. Cookie->PipeChecksum = 0;
  9698. Cookie->CallFinished = 0;
  9699. Cookie->i = 0;
  9700. Cookie->PipeDataSent = 0;
  9701. Cookie->Async.Flags = 0;
  9702. Cookie->Async.Lock = 0;
  9703. Cookie->ExpectedValue = 0;
  9704. switch (NotificationType)
  9705. {
  9706. case RpcNotificationTypeNone:
  9707. break;
  9708. case RpcNotificationTypeEvent:
  9709. Cookie->Async.NotificationType = RpcNotificationTypeEvent ;
  9710. Cookie->Async.u.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  9711. if (Cookie->Async.u.hEvent == 0)
  9712. {
  9713. RpcRaiseException(APP_ERROR) ;
  9714. }
  9715. break;
  9716. case RpcNotificationTypeApc:
  9717. Cookie->Async.Flags = RPC_C_NOTIFY_ON_SEND_COMPLETE;
  9718. Cookie->Async.NotificationType = RpcNotificationTypeApc ;
  9719. Cookie->Async.u.APC.NotificationRoutine = FooPipeAPCRoutine ;
  9720. Cookie->Async.u.APC.hThread = 0 ;
  9721. break;
  9722. default:
  9723. PrintToConsole("Async: bad notification type\n") ;
  9724. break;
  9725. }
  9726. ptr = Cookie->PipeBuffer ;
  9727. for (n = 0; n <ASYNC_CHUNK_SIZE; n++)
  9728. {
  9729. *ptr++ = n;
  9730. Checksum += n ;
  9731. }
  9732. TRACE(("FooPipe: [in] Block checksum: %d\n", Checksum)) ;
  9733. Checksum *= ASYNC_NUM_CHUNKS ;
  9734. TRACE(("FooPipe: [in] Total checksum: %d\n", Checksum)) ;
  9735. FooPipe(&(Cookie->Async),
  9736. Binding,
  9737. Checksum,
  9738. &(Cookie->inpipe),
  9739. &(Cookie->outpipe),
  9740. &(Cookie->checksum_out)) ;
  9741. }
  9742. void
  9743. AsyncPipesUsingAPC(
  9744. RPC_BINDING_HANDLE Binding
  9745. )
  9746. /*++
  9747. Routine Description:
  9748. Call the async function.
  9749. Arguments:
  9750. Binding - Binding handle.
  9751. --*/
  9752. {
  9753. RPC_STATUS Status ;
  9754. PIPE_CALL_COOKIE *Cookie;
  9755. int retval ;
  9756. BOOL fDone = 0;
  9757. int num_elements;
  9758. int i;
  9759. RpcTryExcept
  9760. {
  9761. Cookie = new PIPE_CALL_COOKIE ;
  9762. if (Cookie == 0)
  9763. {
  9764. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  9765. }
  9766. CallFooPipe (Binding, Cookie, RpcNotificationTypeApc) ;
  9767. while (Cookie->PipeDataSent == 0)
  9768. {
  9769. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  9770. {
  9771. RpcRaiseException(APP_ERROR) ;
  9772. }
  9773. }
  9774. while (!fDone)
  9775. {
  9776. Status = Cookie->outpipe.PipeReceive(
  9777. &(Cookie->Async),
  9778. (int *) Cookie->PipeBuffer,
  9779. ASYNC_CHUNK_SIZE,
  9780. &num_elements);
  9781. switch (Status)
  9782. {
  9783. case RPC_S_ASYNC_CALL_PENDING:
  9784. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  9785. {
  9786. RpcRaiseException(APP_ERROR) ;
  9787. }
  9788. break;
  9789. case RPC_S_OK:
  9790. if (num_elements == 0)
  9791. {
  9792. fDone = 1;
  9793. }
  9794. else
  9795. {
  9796. for (i = 0; i <num_elements; i++)
  9797. {
  9798. Cookie->PipeChecksum += Cookie->PipeBuffer[i] ;
  9799. if (Cookie->PipeBuffer[i] != Cookie->ExpectedValue)
  9800. {
  9801. printf("pipe recv fn: elt %d contains %lx, expected %lx\n",
  9802. i, Cookie->PipeBuffer[i], Cookie->ExpectedValue);
  9803. DebugBreak();
  9804. }
  9805. Cookie->ExpectedValue =
  9806. (Cookie->PipeBuffer[i]+1) % ASYNC_CHUNK_SIZE;
  9807. }
  9808. }
  9809. break;
  9810. default:
  9811. fDone = 1;
  9812. break;
  9813. }
  9814. //
  9815. // This code is for testing flow control
  9816. //
  9817. PipeCount++;
  9818. if (PipeCount % 3)
  9819. {
  9820. Sleep(100);
  9821. }
  9822. }
  9823. if (Status != RPC_S_OK)
  9824. {
  9825. RpcRaiseException(Status);
  9826. }
  9827. while (Cookie->CallFinished == 0)
  9828. {
  9829. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  9830. {
  9831. RpcRaiseException(APP_ERROR) ;
  9832. }
  9833. }
  9834. Status = MyRpcCompleteAsyncCall(&Cookie->Async, &retval) ;
  9835. if (Status != RPC_S_OK)
  9836. {
  9837. RpcRaiseException(Status) ;
  9838. }
  9839. if (retval != 1)
  9840. {
  9841. RpcRaiseException(APP_ERROR) ;
  9842. }
  9843. if (Cookie->PipeChecksum != Cookie->checksum_out)
  9844. {
  9845. PrintToConsole("FooPipe: Checksum Error, expected: %d, checksum: %d\n",
  9846. Cookie->checksum_out, Cookie->PipeChecksum) ;
  9847. RpcRaiseException(APP_ERROR) ;
  9848. }
  9849. }
  9850. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9851. {
  9852. PrintToConsole("FooPipe: Exception 0x%lX\n", GetExceptionCode()) ;
  9853. IsabelleError() ;
  9854. }
  9855. RpcEndExcept
  9856. if (Cookie)
  9857. {
  9858. delete Cookie ;
  9859. }
  9860. }
  9861. void
  9862. MultipleOutstandingCalls (
  9863. IN RPC_BINDING_HANDLE Binding,
  9864. IN int NumCalls
  9865. )
  9866. /*++
  9867. Routine Description:
  9868. tests multiple outstanding calls and causal ordering
  9869. Arguments:
  9870. Binding - Binding on which to make the calls
  9871. NumCalls - Number of outstanding calls
  9872. --*/
  9873. {
  9874. RPC_STATUS Status ;
  9875. PIPE_CALL_COOKIE *PipeCookies;
  9876. CALL_COOKIE *Cookies ;
  9877. int retval ;
  9878. int i ;
  9879. int SizeIn, SizeOut ;
  9880. RpcTryExcept
  9881. {
  9882. Cookies = new CALL_COOKIE[NumCalls] ;
  9883. if (Cookies == 0)
  9884. {
  9885. RpcRaiseException(APP_ERROR) ;
  9886. }
  9887. PipeCookies = new PIPE_CALL_COOKIE[NumCalls] ;
  9888. if (PipeCookies == 0)
  9889. {
  9890. RpcRaiseException(APP_ERROR) ;
  9891. }
  9892. OutstandingCalls = 0;
  9893. SizeIn = 10;
  9894. SizeOut = 10 ;
  9895. for (i = 0; i < NumCalls; i++)
  9896. {
  9897. CallFoo(Binding, &Cookies[i], RpcNotificationTypeApc, SizeIn, SizeOut) ;
  9898. SizeIn += 100 ;
  9899. SizeOut+= 100 ;
  9900. OutstandingCalls++ ;
  9901. }
  9902. while (OutstandingCalls)
  9903. {
  9904. if (SleepEx(INFINITE, TRUE) != WAIT_IO_COMPLETION)
  9905. {
  9906. RpcRaiseException(APP_ERROR) ;
  9907. }
  9908. }
  9909. for (i = 0; i < NumCalls; i++)
  9910. {
  9911. Status = MyRpcCompleteAsyncCall(&Cookies[i].Async, &retval) ;
  9912. if (Status != RPC_S_OK)
  9913. {
  9914. PrintToConsole("Call %d on handle %p returned %d\n",
  9915. i, &Cookies[i].Async, Status);
  9916. continue;
  9917. }
  9918. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  9919. if (retval != 1)
  9920. {
  9921. RpcRaiseException(APP_ERROR) ;
  9922. }
  9923. I_RpcFree(Cookies[i].BufferOut) ;
  9924. }
  9925. }
  9926. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9927. {
  9928. PrintToConsole("MultipeOutstandingCalls: Exception 0x%lX\n", GetExceptionCode()) ;
  9929. IsabelleError() ;
  9930. }
  9931. RpcEndExcept
  9932. if (Cookies)
  9933. {
  9934. delete Cookies ;
  9935. }
  9936. if (PipeCookies)
  9937. {
  9938. delete PipeCookies ;
  9939. }
  9940. }
  9941. void
  9942. SyncAsyncInterop (
  9943. IN RPC_BINDING_HANDLE Binding,
  9944. IN int SizeIn,
  9945. IN int SizeOut
  9946. )
  9947. /*++
  9948. Routine Description:
  9949. description
  9950. Arguments:
  9951. arg1 - description
  9952. --*/
  9953. {
  9954. int retval ;
  9955. int *bufferout ;
  9956. int *bufferin ;
  9957. RpcTryExcept
  9958. {
  9959. bufferin = (int *) I_RpcAllocate(SizeIn) ;
  9960. if (bufferin == 0)
  9961. {
  9962. RpcRaiseException(APP_ERROR) ;
  9963. }
  9964. // sync client, async server
  9965. retval = FooSync (Binding, SizeIn, bufferin, &SizeOut, &bufferout) ;
  9966. if (retval != 1)
  9967. {
  9968. RpcRaiseException(APP_ERROR) ;
  9969. }
  9970. I_RpcFree(bufferout) ;
  9971. // ugly hack alert
  9972. FooProcnum = 18 ;
  9973. // async client, sync server (calling FooBar)
  9974. AsyncUsingAPC(Binding, SizeIn, SizeOut) ;
  9975. FooProcnum = 16 ;
  9976. // sync client, async server using pipes
  9977. // async client, sync server using pipes
  9978. }
  9979. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  9980. {
  9981. PrintToConsole("SyncAsyncInterop: Exception 0x%lX\n", GetExceptionCode()) ;
  9982. IsabelleError() ;
  9983. }
  9984. RpcEndExcept
  9985. }
  9986. void
  9987. InitLsaString(
  9988. PLSA_UNICODE_STRING LsaString,
  9989. LPWSTR String
  9990. )
  9991. {
  9992. DWORD StringLength;
  9993. if (String == NULL) {
  9994. LsaString->Buffer = NULL;
  9995. LsaString->Length = 0;
  9996. LsaString->MaximumLength = 0;
  9997. return;
  9998. }
  9999. StringLength = lstrlenW(String);
  10000. LsaString->Buffer = String;
  10001. LsaString->Length = (USHORT) StringLength * sizeof(WCHAR);
  10002. LsaString->MaximumLength=(USHORT)(StringLength+1) * sizeof(WCHAR);
  10003. }
  10004. NTSTATUS
  10005. SetPrivilegeOnAccount(
  10006. LSA_HANDLE PolicyHandle, // open policy handle
  10007. PSID AccountSid, // SID to grant privilege to
  10008. LPWSTR PrivilegeName, // privilege to grant (Unicode)
  10009. BOOL bEnable // enable or disable
  10010. )
  10011. {
  10012. LSA_UNICODE_STRING PrivilegeString;
  10013. //
  10014. // Create a LSA_UNICODE_STRING for the privilege name.
  10015. //
  10016. InitLsaString(&PrivilegeString, PrivilegeName);
  10017. //
  10018. // grant or revoke the privilege, accordingly
  10019. //
  10020. if(bEnable) {
  10021. return LsaAddAccountRights(
  10022. PolicyHandle, // open policy handle
  10023. AccountSid, // target SID
  10024. &PrivilegeString, // privileges
  10025. 1 // privilege count
  10026. );
  10027. } else {
  10028. return LsaRemoveAccountRights(
  10029. PolicyHandle, // open policy handle
  10030. AccountSid, // target SID
  10031. FALSE, // do not disable all rights
  10032. &PrivilegeString, // privileges
  10033. 1 // privilege count
  10034. );
  10035. }
  10036. }
  10037. DWORD
  10038. AddServicePrivToAccount(
  10039. LPWSTR MachineName,
  10040. LPWSTR pAccount
  10041. )
  10042. /*++
  10043. Routine Description:
  10044. Enables the appropriate privileges for the cluster account and
  10045. sets up the cluster service to run in the specified account.
  10046. Arguments:
  10047. None
  10048. Return Value:
  10049. ERROR_SUCCESS if successful
  10050. Win32 error code otherwise
  10051. --*/
  10052. {
  10053. LSA_HANDLE PolicyHandle;
  10054. LSA_OBJECT_ATTRIBUTES ObjectAttributes;
  10055. LSA_UNICODE_STRING ServerString;
  10056. PLSA_UNICODE_STRING Server = NULL;
  10057. NTSTATUS Status;
  10058. WCHAR domain[MAX_PATH];
  10059. PSID pSid;
  10060. SID_NAME_USE sidType;
  10061. DWORD nBytes;
  10062. DWORD maxDomain;
  10063. if (MachineName != NULL) {
  10064. InitLsaString(&ServerString, MachineName);
  10065. Server = &ServerString;
  10066. }
  10067. PrintToConsole("Machine: %ls, Account: %ls.\n",MachineName,pAccount);
  10068. nBytes=0;
  10069. maxDomain=MAX_PATH*sizeof(WCHAR);
  10070. if (LookupAccountName(MachineName,pAccount,NULL,&nBytes,
  10071. domain,&maxDomain,&sidType))
  10072. {
  10073. PrintToConsole("AddServicePrivToAccount: LookupAccountName(NULL) failed.\n");
  10074. return ERROR_INVALID_PARAMETER;
  10075. }
  10076. pSid=LocalAlloc(LPTR,nBytes);
  10077. if (NULL == pSid)
  10078. {
  10079. PrintToConsole("AddServicePrivToAccount: LocalAlloc failed.\n");
  10080. return GetLastError();
  10081. }
  10082. if (!LookupAccountName(MachineName,pAccount,pSid,&nBytes,
  10083. domain,&maxDomain,&sidType))
  10084. {
  10085. PrintToConsole(
  10086. "AddServicePrivToAccount: LookupAccountName(%ls) failed.\n",
  10087. pAccount);
  10088. return GetLastError();
  10089. }
  10090. //
  10091. // Always initialize the object attributes to all zeroes.
  10092. //
  10093. ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
  10094. //
  10095. // Attempt to open the local policy.
  10096. //
  10097. Status = LsaOpenPolicy(Server,
  10098. &ObjectAttributes,
  10099. POLICY_CREATE_ACCOUNT | POLICY_LOOKUP_NAMES,
  10100. &PolicyHandle);
  10101. if (MachineName != NULL) {
  10102. if (!NT_SUCCESS(Status)) {
  10103. //
  10104. // We could not contact the PDC to configure the service account.
  10105. // Put up a nice informative popup and let the user run setup
  10106. // again when the PDC is back.
  10107. //
  10108. PrintToConsole("AddServicePrivToAccount: LsaOpenPolicy failed.\n");
  10109. return(Status);
  10110. }
  10111. } else {
  10112. if (!NT_SUCCESS(Status)) {
  10113. PrintToConsole(
  10114. "AddServicePrivToAccount: LsaOpenPolicy failed 2.\n");
  10115. return(Status);
  10116. }
  10117. }
  10118. //
  10119. // Add the SeTcbPriviledge
  10120. //
  10121. Status = SetPrivilegeOnAccount(PolicyHandle,
  10122. pSid,
  10123. SE_TCB_NAME,
  10124. TRUE);
  10125. if (!NT_SUCCESS(Status)) {
  10126. PrintToConsole(
  10127. "AddServicePrivToAccount: SetPrivilegeOnAccount(tcb).\n");
  10128. goto AddServicePrivToAccount_Bail;
  10129. }
  10130. //
  10131. // Add the SeServiceLogonRight
  10132. //
  10133. Status = SetPrivilegeOnAccount(PolicyHandle,
  10134. pSid,
  10135. SE_SERVICE_LOGON_NAME,
  10136. TRUE);
  10137. if (!NT_SUCCESS(Status)) {
  10138. PrintToConsole(
  10139. "AddServicePrivToAccount: SetPrivilegeOnAccount(logon).\n");
  10140. goto AddServicePrivToAccount_Bail;
  10141. }
  10142. //
  10143. // Add the SeBackupPrivilege
  10144. //
  10145. Status = SetPrivilegeOnAccount(PolicyHandle,
  10146. pSid,
  10147. SE_BACKUP_NAME,
  10148. TRUE);
  10149. if (!NT_SUCCESS(Status)) {
  10150. PrintToConsole(
  10151. "AddServicePrivToAccount: SetPrivilegeOnAccount(backup).\n");
  10152. goto AddServicePrivToAccount_Bail;
  10153. }
  10154. //
  10155. // Add the SeRestorePrivilege
  10156. //
  10157. Status = SetPrivilegeOnAccount(PolicyHandle,
  10158. pSid,
  10159. SE_RESTORE_NAME,
  10160. TRUE);
  10161. if (!NT_SUCCESS(Status)) {
  10162. PrintToConsole(
  10163. "AddServicePrivToAccount: SetPrivilegeOnAccount(restore).\n");
  10164. goto AddServicePrivToAccount_Bail;
  10165. }
  10166. //
  10167. // Add the lock memory privilege
  10168. //
  10169. Status = SetPrivilegeOnAccount(PolicyHandle,
  10170. pSid,
  10171. SE_LOCK_MEMORY_NAME,
  10172. TRUE);
  10173. if (!NT_SUCCESS(Status)) {
  10174. PrintToConsole(
  10175. "AddServicePrivToAccount: SetPrivilegeOnAccount(memory).\n");
  10176. goto AddServicePrivToAccount_Bail;
  10177. }
  10178. //
  10179. // Add the increase quota privilege
  10180. //
  10181. Status = SetPrivilegeOnAccount(PolicyHandle,
  10182. pSid,
  10183. SE_INCREASE_QUOTA_NAME,
  10184. TRUE);
  10185. if (!NT_SUCCESS(Status)) {
  10186. PrintToConsole(
  10187. "AddServicePrivToAccount: SetPrivilegeOnAccount(quota).\n");
  10188. goto AddServicePrivToAccount_Bail;
  10189. }
  10190. //
  10191. // Add the load driver privilege
  10192. //
  10193. Status = SetPrivilegeOnAccount(PolicyHandle,
  10194. pSid,
  10195. SE_LOAD_DRIVER_NAME,
  10196. TRUE);
  10197. if (!NT_SUCCESS(Status)) {
  10198. PrintToConsole(
  10199. "AddServicePrivToAccount: SetPrivilegeOnAccount(driver).\n");
  10200. goto AddServicePrivToAccount_Bail;
  10201. }
  10202. //
  10203. // Add the increase base priority privilege
  10204. //
  10205. Status = SetPrivilegeOnAccount(PolicyHandle,
  10206. pSid,
  10207. SE_INC_BASE_PRIORITY_NAME,
  10208. TRUE);
  10209. if (!NT_SUCCESS(Status)) {
  10210. PrintToConsole(
  10211. "AddServicePrivToAccount: SetPrivilegeOnAccount(priority)\n");
  10212. goto AddServicePrivToAccount_Bail;
  10213. }
  10214. Status=ERROR_SUCCESS;
  10215. AddServicePrivToAccount_Bail:
  10216. //
  10217. // Close the policy handle.
  10218. //
  10219. LsaClose(PolicyHandle);
  10220. return(Status);
  10221. }
  10222. void
  10223. AsyncSecurity (
  10224. IN RPC_BINDING_HANDLE Binding
  10225. )
  10226. /*++
  10227. Routine Description:
  10228. description
  10229. Arguments:
  10230. arg1 - description
  10231. --*/
  10232. {
  10233. HANDLE hToken;
  10234. WCHAR FullName[512];
  10235. wsprintf((PWSTR) &FullName[0], L"%hs\\%hs", SecurityDomain, SecurityUser);
  10236. AddServicePrivToAccount(L"", &FullName[0]);
  10237. while (1)
  10238. {
  10239. if (LogonUserA(SecurityUser, SecurityDomain, SecurityPassword,
  10240. LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hToken) == 0)
  10241. {
  10242. PrintToConsole("LogonUser failed: %d\n", GetLastError());
  10243. break;
  10244. }
  10245. ImpersonateLoggedOnUser(hToken);
  10246. // set auth info to various levels
  10247. // and impersonate on the server
  10248. Status = RpcBindingSetAuthInfo(Binding, NULL, RPC_C_AUTHN_DEFAULT,
  10249. RPC_C_AUTHN_WINNT, NULL, NULL);
  10250. AsyncUsingAPC(Binding, 20, 20);
  10251. CloseHandle(hToken);
  10252. }
  10253. }
  10254. void
  10255. AsyncSecurityThreads()
  10256. {
  10257. int i;
  10258. unsigned long ThreadIdentifier;
  10259. HANDLE HandleToThread ;
  10260. RPC_BINDING_HANDLE Binding;
  10261. UUID ObjectUuid;
  10262. GenerateUuidValue(UUID_TEST_CANCEL, &ObjectUuid);
  10263. for (i = 0; i<3; i++)
  10264. {
  10265. Status = GetBinding(BARTHOLOMEW, &Binding);
  10266. if (Status)
  10267. {
  10268. ApiError("Async", "GetBinding", Status);
  10269. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  10270. return;
  10271. }
  10272. Status = RpcBindingSetObject(Binding, &ObjectUuid);
  10273. if (Status)
  10274. {
  10275. ApiError("Async", "RpcBindingSetObject", Status);
  10276. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10277. return;
  10278. }
  10279. HandleToThread = CreateThread(
  10280. 0,
  10281. DefaultThreadStackSize,
  10282. (LPTHREAD_START_ROUTINE) AsyncSecurity,
  10283. Binding,
  10284. 0,
  10285. &ThreadIdentifier);
  10286. if (HandleToThread == 0)
  10287. {
  10288. PrintToConsole("AsyncSecurity: Error, couldn't create thread\n") ;
  10289. IsabelleError();
  10290. return;
  10291. }
  10292. CloseHandle(HandleToThread);
  10293. }
  10294. Status = GetBinding(BARTHOLOMEW, &Binding);
  10295. if (Status)
  10296. {
  10297. ApiError("Async", "GetBinding", Status);
  10298. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  10299. return;
  10300. }
  10301. Status = RpcBindingSetObject(Binding, &ObjectUuid);
  10302. if (Status)
  10303. {
  10304. ApiError("Async", "RpcBindingSetObject", Status);
  10305. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10306. return;
  10307. }
  10308. AsyncSecurity(Binding);
  10309. }
  10310. void
  10311. AsyncExceptions (
  10312. IN RPC_BINDING_HANDLE Binding
  10313. )
  10314. /*++
  10315. Routine Description:
  10316. description
  10317. Arguments:
  10318. arg1 - description
  10319. --*/
  10320. {
  10321. BOOL ExceptionOccured ;
  10322. int ExceptionCode ;
  10323. UUID SavedUuid;
  10324. UUID ExceptionUuid;
  10325. //
  10326. // object UUID is used to control server-side exceptions: save the original one.
  10327. //
  10328. Status = RpcBindingInqObject(Binding, &SavedUuid);
  10329. if (Status)
  10330. {
  10331. ApiError("Async", "RpcBindingInqObject", Status);
  10332. PrintToConsole("Async : FAIL - Unable to save original object UUID\n");
  10333. return;
  10334. }
  10335. // test sync exceptions (async server)
  10336. RpcTryExcept
  10337. {
  10338. ExceptionOccured = 0;
  10339. ExceptionCode = 0;
  10340. GenerateUuidValue(UUID_SYNC_EXCEPTION, &ExceptionUuid);
  10341. Status = RpcBindingSetObject(Binding, &ExceptionUuid);
  10342. if (Status)
  10343. {
  10344. ApiError("Async", "RpcBindingSetObject", Status);
  10345. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10346. return;
  10347. }
  10348. AsyncUsingAPC(Binding, 0, 10) ;
  10349. }
  10350. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  10351. {
  10352. ExceptionOccured = 1;
  10353. ExceptionCode = GetExceptionCode() ;
  10354. }
  10355. RpcEndExcept
  10356. if (ExceptionOccured == 0
  10357. || ExceptionCode != SYNC_EXCEPT)
  10358. {
  10359. PrintToConsole("Async: wrong exception value 0x%x\n", ExceptionCode );
  10360. IsabelleError() ;
  10361. Status = RpcBindingSetObject(Binding, &SavedUuid);
  10362. if (Status)
  10363. {
  10364. ApiError("Async", "RpcBindingSetObject", Status);
  10365. PrintToConsole("Async : FAIL - Unable to restore original object UUID\n");
  10366. }
  10367. return ;
  10368. }
  10369. // test sync exceptions (sync server)
  10370. RpcTryExcept
  10371. {
  10372. ExceptionOccured = 0;
  10373. ExceptionCode = 0;
  10374. // ugly hack alert
  10375. FooProcnum = 18 ;
  10376. GenerateUuidValue(UUID_SYNC_EXCEPTION, &ExceptionUuid);
  10377. Status = RpcBindingSetObject(Binding, &ExceptionUuid);
  10378. if (Status)
  10379. {
  10380. ApiError("Async", "RpcBindingSetObject", Status);
  10381. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10382. return;
  10383. }
  10384. // async client, sync server (calling FooBar)
  10385. AsyncUsingAPC(Binding, 0, 10) ;
  10386. }
  10387. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  10388. {
  10389. ExceptionOccured = 1;
  10390. ExceptionCode = GetExceptionCode() ;
  10391. }
  10392. RpcEndExcept
  10393. FooProcnum = 16 ;
  10394. if (ExceptionOccured == 0
  10395. || ExceptionCode != SYNC_EXCEPT)
  10396. {
  10397. PrintToConsole("Async: wrong exception value 0x%x\n", ExceptionCode );
  10398. IsabelleError() ;
  10399. Status = RpcBindingSetObject(Binding, &SavedUuid);
  10400. if (Status)
  10401. {
  10402. ApiError("Async", "RpcBindingSetObject", Status);
  10403. PrintToConsole("Async : FAIL - Unable to restore original object UUID\n");
  10404. }
  10405. return ;
  10406. }
  10407. // test async exceptions
  10408. RpcTryExcept
  10409. {
  10410. ExceptionOccured = 0;
  10411. ExceptionCode = 0;
  10412. GenerateUuidValue(UUID_ASYNC_EXCEPTION, &ExceptionUuid);
  10413. Status = RpcBindingSetObject(Binding, &ExceptionUuid);
  10414. if (Status)
  10415. {
  10416. ApiError("Async", "RpcBindingSetObject", Status);
  10417. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10418. return;
  10419. }
  10420. AsyncUsingAPC(Binding, 10, 0) ;
  10421. }
  10422. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  10423. {
  10424. ExceptionOccured = 1;
  10425. ExceptionCode = GetExceptionCode() ;
  10426. }
  10427. RpcEndExcept
  10428. if (ExceptionOccured == 0
  10429. || ExceptionCode != ASYNC_EXCEPT)
  10430. {
  10431. PrintToConsole("Async: wrong exception value 0x%x\n", ExceptionCode );
  10432. IsabelleError() ;
  10433. }
  10434. Status = RpcBindingSetObject(Binding, &SavedUuid);
  10435. if (Status)
  10436. {
  10437. ApiError("Async", "RpcBindingSetObject", Status);
  10438. PrintToConsole("Async : FAIL - Unable to restore original object UUID\n");
  10439. }
  10440. }
  10441. ////////////////////////////////////////////////////////////
  10442. // Begin, stubs for FooCH //
  10443. ////////////////////////////////////////////////////////////
  10444. typedef struct {
  10445. RPC_ASYNC_STUB_STATE StubState ;
  10446. void *state ;
  10447. int *sizeout ;
  10448. int **bufferout ;
  10449. } FOOCH_ASYNC_CLIENT_STATE;
  10450. RPC_STATUS
  10451. FooCHComplete(
  10452. IN PRPC_ASYNC_STATE pAsync,
  10453. OUT void *Reply
  10454. )
  10455. /*++
  10456. Routine Description:
  10457. The completion routine corresponding to the function Foo. This routine
  10458. is called to get the out parameters from an async function.
  10459. Arguments:
  10460. pAsync - Async Handle. The async handle is always the first parameter of every
  10461. async routine.
  10462. --*/
  10463. {
  10464. RPC_STATUS Status ;
  10465. RPC_MESSAGE Message ;
  10466. int *ptr ;
  10467. FOOCH_ASYNC_CLIENT_STATE *StubInfo =
  10468. (FOOCH_ASYNC_CLIENT_STATE *) pAsync->StubInfo ;
  10469. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  10470. Message.RpcFlags = RPC_BUFFER_ASYNC;
  10471. Message.Handle = StubInfo->StubState.CallHandle ;
  10472. Message.Buffer = StubInfo->StubState.Buffer ;
  10473. Message.BufferLength = StubInfo->StubState.BufferLength ;
  10474. Status = I_RpcReceive(&Message, 0) ;
  10475. if (Status)
  10476. {
  10477. return Status ;
  10478. }
  10479. ptr = (int *) Message.Buffer ;
  10480. *((int *) Reply) = *ptr++ ;
  10481. *(StubInfo->sizeout) = *ptr++ ;
  10482. *(StubInfo->bufferout) = (int *) I_RpcAllocate(*(StubInfo->sizeout)) ;
  10483. if (*(StubInfo->bufferout) == 0)
  10484. {
  10485. return RPC_S_OUT_OF_MEMORY ;
  10486. }
  10487. RpcpMemoryCopy(*(StubInfo->bufferout), ptr, *(StubInfo->sizeout)) ;
  10488. I_RpcFreeBuffer(&Message) ;
  10489. I_RpcFree(StubInfo) ;
  10490. return RPC_S_OK ;
  10491. }
  10492. void
  10493. FooCH (
  10494. PRPC_ASYNC_STATE pAsync,
  10495. /* [in] */ void PAPI *ContextHandle,
  10496. /* [in] */ int sizein,
  10497. /* [in] */ int *bufferin,
  10498. /* [in, out] */ int *sizeout,
  10499. /* [out] */ int **bufferout
  10500. )
  10501. /*++
  10502. Routine Description:
  10503. Client stub for function FooCH.
  10504. Arguments:
  10505. pAsync - Async Handle. The async handle is always the first parameter of every
  10506. async routine.
  10507. --*/
  10508. {
  10509. RPC_STATUS RpcStatus ;
  10510. RPC_MESSAGE Message ;
  10511. FOOCH_ASYNC_CLIENT_STATE *StubInfo ;
  10512. int *Ptr ;
  10513. StubInfo = (FOOCH_ASYNC_CLIENT_STATE *) I_RpcAllocate (
  10514. sizeof(FOOCH_ASYNC_CLIENT_STATE)) ;
  10515. if (StubInfo == 0)
  10516. {
  10517. RpcRaiseException(RPC_S_OUT_OF_MEMORY) ;
  10518. }
  10519. pAsync->StubInfo = (void *) StubInfo ;
  10520. StubInfo->StubState.CallHandle = NDRCContextBinding(ContextHandle) ;
  10521. Message.Handle = StubInfo->StubState.CallHandle;
  10522. Message.BufferLength = 20+8+sizein+(sizein%4) ;
  10523. Message.ProcNum = 19 | HackForOldStubs | RPC_FLAGS_VALID_BIT ;
  10524. Message.RpcInterfaceInformation = &IsabelleInterfaceInformation ;
  10525. Message.RpcFlags = RPC_BUFFER_ASYNC ;
  10526. RpcStatus = I_RpcGetBuffer(&Message) ;
  10527. if (RpcStatus)
  10528. {
  10529. RpcRaiseException(RpcStatus) ;
  10530. }
  10531. // marshal ;-)
  10532. Ptr = (int *) Message.Buffer ;
  10533. NDRCContextMarshall(ContextHandle, Ptr) ;
  10534. Ptr += 20 / sizeof(int) ;
  10535. *Ptr++ = sizein ;
  10536. RpcpMemoryCopy(Ptr, bufferin, sizein) ;
  10537. Ptr += (sizein+3)/sizeof(int) ;
  10538. *Ptr = *sizeout ;
  10539. StubInfo->StubState.Flags = 0;
  10540. StubInfo->sizeout = sizeout ;
  10541. StubInfo->bufferout = bufferout ;
  10542. RpcStatus = I_RpcAsyncSetHandle(&Message, (PRPC_ASYNC_STATE) pAsync) ;
  10543. if (RpcStatus)
  10544. {
  10545. RpcRaiseException(RpcStatus) ;
  10546. }
  10547. StubInfo->StubState.CompletionRoutine = FooCHComplete ;
  10548. Message.RpcFlags = RPC_BUFFER_ASYNC;
  10549. RpcStatus = I_RpcSend(&Message) ;
  10550. if (RpcStatus)
  10551. {
  10552. RpcRaiseException(RpcStatus) ;
  10553. }
  10554. StubInfo->StubState.CallHandle = Message.Handle ;
  10555. StubInfo->StubState.Buffer = Message.Buffer ;
  10556. StubInfo->StubState.BufferLength = Message.BufferLength ;
  10557. // return to the app
  10558. }
  10559. typedef struct {
  10560. RPC_ASYNC_STATE Async ;
  10561. int SizeOut ;
  10562. int *BufferOut ;
  10563. BOOL CallFinished ;
  10564. void PAPI *ContextHandle ;
  10565. } FOOCH_CALL_COOKIE ;
  10566. void
  10567. FooCHAPCRoutine (
  10568. IN PRPC_ASYNC_STATE pAsync,
  10569. IN void *Context,
  10570. IN RPC_ASYNC_EVENT Event
  10571. )
  10572. /*++
  10573. Routine Description:
  10574. description
  10575. Arguments:
  10576. arg1 - description
  10577. --*/
  10578. {
  10579. FOOCH_CALL_COOKIE *Cookie = (FOOCH_CALL_COOKIE *) pAsync->UserInfo ;
  10580. switch (Event)
  10581. {
  10582. case RpcCallComplete:
  10583. Cookie->CallFinished = 1;
  10584. OutstandingCalls--;
  10585. break;
  10586. }
  10587. }
  10588. void
  10589. CallFooCH (
  10590. RPC_BINDING_HANDLE BindingHandle,
  10591. FOOCH_CALL_COOKIE *Cookie,
  10592. RPC_NOTIFICATION_TYPES NotificationType,
  10593. int SizeIn,
  10594. int SizeOut
  10595. )
  10596. /*++
  10597. Routine Description:
  10598. description
  10599. Arguments:
  10600. arg1 - description
  10601. --*/
  10602. {
  10603. int *BufferIn ;
  10604. unsigned long ContextUuid[5];
  10605. Cookie->ContextHandle = 0;
  10606. ContextUuid[0] = 0;
  10607. ContextUuid[1] = 1;
  10608. ContextUuid[2] = 2;
  10609. ContextUuid[3] = 3;
  10610. ContextUuid[4] = 4;
  10611. NDRCContextUnmarshall(&(Cookie->ContextHandle),
  10612. BindingHandle,
  10613. ContextUuid,
  10614. 0x00L | 0x10L | 0x0000L);
  10615. BufferIn = (int *) new char[SizeIn] ;
  10616. if (BufferIn == 0)
  10617. {
  10618. RpcRaiseException(APP_ERROR) ;
  10619. }
  10620. Cookie->SizeOut = SizeOut ;
  10621. Cookie->Async.Size = sizeof(RPC_ASYNC_STATE) ;
  10622. Cookie->Async.Flags = 0;
  10623. Cookie->Async.Lock = 0;
  10624. Cookie->Async.NotificationType = NotificationType ;
  10625. switch (NotificationType)
  10626. {
  10627. case RpcNotificationTypeNone:
  10628. break;
  10629. case RpcNotificationTypeEvent:
  10630. Cookie->Async.u.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  10631. if (Cookie->Async.u.hEvent == 0)
  10632. {
  10633. RpcRaiseException(APP_ERROR) ;
  10634. }
  10635. Cookie->Async.NotificationType = RpcNotificationTypeEvent ;
  10636. break;
  10637. case RpcNotificationTypeApc:
  10638. Cookie->Async.NotificationType = RpcNotificationTypeApc ;
  10639. Cookie->Async.u.APC.NotificationRoutine = FooCHAPCRoutine ;
  10640. Cookie->Async.u.APC.hThread = 0;
  10641. Cookie->CallFinished = 0;
  10642. break;
  10643. default:
  10644. PrintToConsole("Async: bad notification type\n") ;
  10645. break;
  10646. }
  10647. Cookie->Async.UserInfo = (void *) Cookie ;
  10648. // call the async function
  10649. // the buffers supplied for the [out] and the [in, out] params
  10650. // should be valid until the logical RPC call has completed.
  10651. FooCH(&Cookie->Async,
  10652. Cookie->ContextHandle,
  10653. SizeIn,
  10654. BufferIn,
  10655. &Cookie->SizeOut,
  10656. &Cookie->BufferOut) ;
  10657. delete BufferIn ;
  10658. }
  10659. void
  10660. ContextHandles(
  10661. RPC_BINDING_HANDLE Binding,
  10662. int SizeIn,
  10663. int SizeOut
  10664. )
  10665. /*++
  10666. Routine Description:
  10667. The code that calls the async function.
  10668. Arguments:
  10669. Binding - the binding handle.
  10670. --*/
  10671. {
  10672. RPC_STATUS Status ;
  10673. FOOCH_CALL_COOKIE Cookie ;
  10674. int retval ;
  10675. RpcTryExcept
  10676. {
  10677. CallFooCH(Binding, &Cookie, RpcNotificationTypeApc, SizeIn, SizeOut) ;
  10678. WaitForReply(&(Cookie.CallFinished));
  10679. Status = MyRpcCompleteAsyncCall(&Cookie.Async, &retval) ;
  10680. if (Status != RPC_S_OK)
  10681. {
  10682. RpcRaiseException(Status) ;
  10683. }
  10684. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  10685. if (retval != 1)
  10686. {
  10687. RpcRaiseException(APP_ERROR) ;
  10688. }
  10689. RpcSsDestroyClientContext(&(Cookie.ContextHandle));
  10690. if ( Cookie.ContextHandle != 0 )
  10691. {
  10692. PrintToConsole("Async : ContextHandle != 0\n");
  10693. RpcRaiseException(APP_ERROR) ;
  10694. }
  10695. I_RpcFree(Cookie.BufferOut) ;
  10696. }
  10697. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  10698. {
  10699. PrintToConsole("FooCH: Exception 0x%lX\n", GetExceptionCode()) ;
  10700. Status = GetExceptionCode() ;
  10701. if (Status == SYNC_EXCEPT
  10702. || Status == ASYNC_EXCEPT)
  10703. {
  10704. RpcRaiseException(Status) ;
  10705. }
  10706. else
  10707. {
  10708. IsabelleError() ;
  10709. }
  10710. }
  10711. RpcEndExcept
  10712. }
  10713. int AsyncSizes[] =
  10714. {
  10715. 20, 100, 256, 1024, 10000, 100000
  10716. } ;
  10717. #define CHECK_ERRORS \
  10718. if (IsabelleErrors != 0)\
  10719. {\
  10720. PrintToConsole("Async : FAIL - Error(s) in Isabelle");\
  10721. PrintToConsole(" Interface\n");\
  10722. IsabelleShutdown(Async);\
  10723. IsabelleErrors = 0;\
  10724. return;\
  10725. }
  10726. void
  10727. PingServer (
  10728. RPC_BINDING_HANDLE Binding
  10729. )
  10730. {
  10731. RPC_MESSAGE Caller;
  10732. Caller.Handle = Binding;
  10733. Caller.BufferLength = 0;
  10734. Caller.ProcNum = 4 | HackForOldStubs ;
  10735. Caller.RpcInterfaceInformation = &HelgaInterfaceInformation ;
  10736. Caller.RpcFlags = 0;
  10737. if (UclntGetBuffer(&Caller) != RPC_S_OK)
  10738. {
  10739. IsabelleError();
  10740. return ;
  10741. }
  10742. if (UclntSendReceive(&Caller) != RPC_S_OK)
  10743. {
  10744. IsabelleError();
  10745. return;
  10746. }
  10747. if (I_RpcFreeBuffer(&Caller) != RPC_S_OK)
  10748. {
  10749. IsabelleError();
  10750. }
  10751. }
  10752. long PendingCalls;
  10753. void
  10754. AsyncPingProc(
  10755. IN PRPC_MESSAGE Message
  10756. )
  10757. {
  10758. if (UclntSendReceive(Message) != RPC_S_OK)
  10759. {
  10760. IsabelleError();
  10761. InterlockedDecrement(&PendingCalls);
  10762. return;
  10763. }
  10764. InterlockedDecrement(&PendingCalls);
  10765. }
  10766. void
  10767. AsyncPingServer (
  10768. RPC_BINDING_HANDLE Binding
  10769. )
  10770. {
  10771. RPC_MESSAGE Caller[20];
  10772. unsigned long ThreadIdentifier;
  10773. HANDLE HandleToThread ;
  10774. int i;
  10775. for (i = 0; i <20; i++)
  10776. {
  10777. Caller[i].Handle = Binding;
  10778. Caller[i].BufferLength = 0;
  10779. Caller[i].ProcNum = 4 | HackForOldStubs ;
  10780. Caller[i].RpcInterfaceInformation = &HelgaInterfaceInformation ;
  10781. Caller[i].RpcFlags = 0;
  10782. if (UclntGetBuffer(&Caller[i]) != RPC_S_OK)
  10783. {
  10784. IsabelleError();
  10785. return ;
  10786. }
  10787. }
  10788. PendingCalls = 20;
  10789. for (i = 0; i<20; i++)
  10790. {
  10791. HandleToThread = CreateThread(
  10792. 0,
  10793. DefaultThreadStackSize,
  10794. (LPTHREAD_START_ROUTINE) AsyncPingProc,
  10795. &Caller[i],
  10796. 0,
  10797. &ThreadIdentifier);
  10798. if (HandleToThread == 0)
  10799. {
  10800. PrintToConsole("AsyncPingServer: Error, couldn't create thread\n") ;
  10801. IsabelleError();
  10802. return;
  10803. }
  10804. }
  10805. while (PendingCalls)
  10806. {
  10807. Sleep(1000);
  10808. }
  10809. for (i = 0; i < 20; i++)
  10810. {
  10811. if (I_RpcFreeBuffer(&Caller[i]) != RPC_S_OK)
  10812. {
  10813. IsabelleError();
  10814. }
  10815. }
  10816. }
  10817. void
  10818. AsyncCancels (
  10819. IN RPC_BINDING_HANDLE Binding
  10820. )
  10821. {
  10822. RPC_STATUS Status ;
  10823. CALL_COOKIE Cookie ;
  10824. int retval ;
  10825. RpcTryExcept
  10826. {
  10827. //
  10828. // Test non abortive cancels
  10829. //
  10830. CallFoo(Binding, &Cookie, RpcNotificationTypeApc, 20, 20) ;
  10831. Sleep(10);
  10832. //
  10833. // non abortive cancel
  10834. //
  10835. Status = RpcAsyncCancelCall(&Cookie.Async, 0);
  10836. if (Status != RPC_S_OK)
  10837. {
  10838. RpcRaiseException(Status);
  10839. }
  10840. WaitForReply(&(Cookie.CallFinished));
  10841. Status = MyRpcCompleteAsyncCall(&Cookie.Async, &retval) ;
  10842. if (Status != RPC_S_OK)
  10843. {
  10844. RpcRaiseException(Status) ;
  10845. }
  10846. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  10847. //
  10848. // Test abortive cancels
  10849. //
  10850. CallFoo(Binding, &Cookie, RpcNotificationTypeApc, 20, 20) ;
  10851. Sleep(10);
  10852. //
  10853. // Abortive cancel
  10854. //
  10855. Status = RpcAsyncCancelCall(&Cookie.Async, 1);
  10856. if (Status != RPC_S_OK)
  10857. {
  10858. RpcRaiseException(Status);
  10859. }
  10860. WaitForReply(&(Cookie.CallFinished));
  10861. Status = MyRpcCompleteAsyncCall(&Cookie.Async, &retval) ;
  10862. if (Status != RPC_S_CALL_CANCELLED)
  10863. {
  10864. RpcRaiseException(Status) ;
  10865. }
  10866. TRACE(("Async: MyRpcCompleteAsyncCall returned %d\n", retval)) ;
  10867. }
  10868. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  10869. {
  10870. PrintToConsole("Foo: Exception 0x%lX\n", GetExceptionCode()) ;
  10871. Status = GetExceptionCode() ;
  10872. if (Status == SYNC_EXCEPT
  10873. || Status == ASYNC_EXCEPT)
  10874. {
  10875. RpcRaiseException(Status) ;
  10876. }
  10877. else
  10878. {
  10879. IsabelleError() ;
  10880. }
  10881. }
  10882. RpcEndExcept
  10883. }
  10884. #define LAST 15
  10885. extern void
  10886. AsyncAll (
  10887. void
  10888. )
  10889. /*++
  10890. Routine Description:
  10891. Loop through all Async tests.
  10892. --*/
  10893. {
  10894. int i;
  10895. for( i = 0; i < LAST; i ++)
  10896. {
  10897. Async(i);
  10898. }
  10899. }
  10900. void
  10901. Async (
  10902. int testnum
  10903. )
  10904. /*++
  10905. Routine Description:
  10906. Invoke the tests.
  10907. --*/
  10908. {
  10909. int i ;
  10910. UUID ObjectUuid;
  10911. UUID CancelUuid;
  10912. RPC_BINDING_HANDLE Async;
  10913. RPC_BINDING_HANDLE AsyncBind;
  10914. if (testnum > LAST)
  10915. {
  10916. PrintToConsole("Async tests:\n") ;
  10917. PrintToConsole("0: Run all the tests\n") ;
  10918. PrintToConsole("1: Async using APCs, events and polling\n") ;
  10919. PrintToConsole("2: Async pipes using events\n") ;
  10920. PrintToConsole("3: Async pipes using APC, and flow control\n") ;
  10921. PrintToConsole("4: Async with security\n") ;
  10922. PrintToConsole("5: Sync and async exceptions\n") ;
  10923. PrintToConsole("6: Multiple outstanding calls and causal ordering\n") ;
  10924. PrintToConsole("7: Context handles\n") ;
  10925. PrintToConsole("8: Sync/Async interop\n") ;
  10926. PrintToConsole("9: Async ping server") ;
  10927. PrintToConsole("10: Alter context during async calls\n") ;
  10928. PrintToConsole("11: Async cancels\n") ;
  10929. PrintToConsole("12: Multiple outstanding non causal calls\n") ;
  10930. PrintToConsole("13: Rebinds on secure calls with uuids\n") ;
  10931. NumberOfTestsRun++ ;
  10932. return ;
  10933. }
  10934. Synchro(BARTHOLOMEW) ;
  10935. if ( NumberOfTestsRun++ )
  10936. {
  10937. PauseExecution(TestDelay);
  10938. }
  10939. PrintToConsole("Async : Test Async RPC\n");
  10940. Status = GetBinding(BARTHOLOMEW, &Async);
  10941. if (Status)
  10942. {
  10943. ApiError("Async", "GetBinding", Status);
  10944. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  10945. return;
  10946. }
  10947. #if 0
  10948. PingServer(Async);
  10949. CHECK_ERRORS;
  10950. #endif
  10951. SyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  10952. if (SyncEvent == 0)
  10953. {
  10954. ApiError("Async", "CreateEvent", Status);
  10955. return;
  10956. }
  10957. GenerateUuidValue(UUID_TEST_CANCEL, &ObjectUuid);
  10958. Status = RpcBindingSetObject(Async, &ObjectUuid);
  10959. if (Status)
  10960. {
  10961. ApiError("Async", "RpcBindingSetObject", Status);
  10962. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  10963. return;
  10964. }
  10965. if (fNonCausal)
  10966. {
  10967. Status = RpcBindingSetOption(Async,
  10968. RPC_C_OPT_BINDING_NONCAUSAL,
  10969. 1);
  10970. if (Status)
  10971. {
  10972. ApiError("Async", "RpcBindingSetOption", Status);
  10973. PrintToConsole("Async : FAIL - Unable to Set Option\n");
  10974. return;
  10975. }
  10976. }
  10977. switch (testnum)
  10978. {
  10979. case 0:
  10980. case 1:
  10981. PrintToConsole("Async: Testing async using APCs, events and polling\n") ;
  10982. for (i = 0; i < sizeof(AsyncSizes)/sizeof(int); i++)
  10983. {
  10984. AsyncUsingAPC(Async, AsyncSizes[i], AsyncSizes[i]) ;
  10985. CHECK_ERRORS;
  10986. AsyncUsingEvent(Async, AsyncSizes[i], AsyncSizes[i]) ;
  10987. CHECK_ERRORS;
  10988. AsyncUsingPolling(Async, AsyncSizes[i], AsyncSizes[i]) ;
  10989. CHECK_ERRORS;
  10990. }
  10991. if (testnum != 0)
  10992. {
  10993. break;
  10994. }
  10995. case 2:
  10996. PrintToConsole("Async: Testing async pipes using events\n") ;
  10997. CHECK_ERRORS;
  10998. if (testnum != 0)
  10999. {
  11000. break;
  11001. }
  11002. case 3:
  11003. PrintToConsole("Async: Testing async async pipes using APC, and flow control\n") ;
  11004. AsyncPipesUsingAPC(Async) ;
  11005. CHECK_ERRORS;
  11006. if (testnum != 0)
  11007. {
  11008. break;
  11009. }
  11010. case 4:
  11011. if (testnum != 0)
  11012. {
  11013. PrintToConsole("Async: Testing security\n") ;
  11014. AsyncSecurityThreads() ;
  11015. CHECK_ERRORS;
  11016. break;
  11017. }
  11018. case 5:
  11019. PrintToConsole("Async: Testing sync and async exceptions\n") ;
  11020. AsyncExceptions(Async) ;
  11021. CHECK_ERRORS;
  11022. if (testnum != 0)
  11023. {
  11024. break;
  11025. }
  11026. case 6:
  11027. PrintToConsole("Async: Testing multiple outstanding calls and causal ordering\n") ;
  11028. MultipleOutstandingCalls(Async, 20) ;
  11029. CHECK_ERRORS;
  11030. if (testnum != 0)
  11031. {
  11032. break;
  11033. }
  11034. case 7:
  11035. PrintToConsole("Async: Testing context handles\n") ;
  11036. ContextHandles(Async, 20, 20) ;
  11037. if (testnum != 0)
  11038. {
  11039. break;
  11040. }
  11041. case 8:
  11042. PrintToConsole("Async: Testing Sync/Async interop\n") ;
  11043. for (i = 0; i < sizeof(AsyncSizes)/sizeof(int); i++)
  11044. {
  11045. SyncAsyncInterop(Async, AsyncSizes[i], AsyncSizes[i]) ;
  11046. CHECK_ERRORS;
  11047. }
  11048. if (testnum != 0)
  11049. {
  11050. break;
  11051. }
  11052. case 9:
  11053. AsyncPingServer(Async);
  11054. CHECK_ERRORS;
  11055. if (testnum != 0)
  11056. {
  11057. break;
  11058. }
  11059. case 10:
  11060. //
  11061. // make a few calls on the Isabelle interface
  11062. //
  11063. for (i=0; i<3; i++)
  11064. {
  11065. AsyncUsingAPC(Async, AsyncSizes[i], AsyncSizes[i]) ;
  11066. CHECK_ERRORS;
  11067. }
  11068. FooProcnum = 7;
  11069. FooInterface = &HelgaInterfaceInformation;
  11070. //
  11071. // make a few calls on the helga interface
  11072. // this should cause an alter context
  11073. //
  11074. for (i=0; i<3; i++)
  11075. {
  11076. AsyncUsingAPC(Async, AsyncSizes[i], AsyncSizes[i]) ;
  11077. CHECK_ERRORS;
  11078. }
  11079. FooProcnum = 16;
  11080. FooInterface = &IsabelleInterfaceInformation;
  11081. //
  11082. // make a few calls on the Isabelle interface
  11083. //
  11084. for (i=0; i<3; i++)
  11085. {
  11086. AsyncUsingAPC(Async, AsyncSizes[i], AsyncSizes[i]) ;
  11087. CHECK_ERRORS;
  11088. }
  11089. if (testnum != 0)
  11090. {
  11091. break;
  11092. }
  11093. case 11:
  11094. PrintToConsole("Async: Test async cancels\n");
  11095. GenerateUuidValue(UUID_SLEEP_1000, &ObjectUuid);
  11096. Status = RpcBindingSetObject(Async, &ObjectUuid);
  11097. if (Status)
  11098. {
  11099. ApiError("Async", "RpcBindingSetObject", Status);
  11100. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  11101. return;
  11102. }
  11103. AsyncCancels(Async);
  11104. CHECK_ERRORS;
  11105. if (testnum != 0)
  11106. {
  11107. break;
  11108. }
  11109. case 12:
  11110. PrintToConsole("Async: Testing multiple outstanding calls and causal ordering\n") ;
  11111. Status = RpcBindingSetOption(Async, RPC_C_OPT_BINDING_NONCAUSAL, TRUE);
  11112. if (Status)
  11113. {
  11114. ApiError("Async", "RpcBindingSetOption", Status);
  11115. return;
  11116. }
  11117. MultipleOutstandingCalls(Async, 20) ;
  11118. CHECK_ERRORS;
  11119. if (testnum != 0)
  11120. {
  11121. break;
  11122. }
  11123. case 13:
  11124. RpcBindingFree(&Async);
  11125. Status = GetBinding(BARTHOLOMEW, &Async);
  11126. if (Status)
  11127. {
  11128. ApiError("Async", "GetBinding", Status);
  11129. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  11130. return;
  11131. }
  11132. PrintToConsole("Async: Bind and async calls\n") ;
  11133. for (i = 0; i < 10; i++)
  11134. {
  11135. Status = GetBinding(BARTHOLOMEW, &AsyncBind);
  11136. if (Status)
  11137. {
  11138. ApiError("Async", "GetBinding", Status);
  11139. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  11140. return;
  11141. }
  11142. Status = RpcBindingSetObject(AsyncBind, &ObjectUuid);
  11143. if (Status)
  11144. {
  11145. ApiError("Async", "RpcBindingSetObject", Status);
  11146. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  11147. return;
  11148. }
  11149. Status = RpcBindingSetAuthInfoA(AsyncBind,
  11150. (unsigned char *) "ServerPrincipal",
  11151. RPC_C_AUTHN_LEVEL_CONNECT,
  11152. 10,
  11153. NULL,
  11154. 0);
  11155. if (Status)
  11156. {
  11157. ApiError("Async", "RpcBindingSetAuthInfo", Status);
  11158. PrintToConsole("Async : FAIL - Unable to Set AuthInfo\n");
  11159. return;
  11160. }
  11161. AsyncUsingAPC(AsyncBind, 10, 10) ;
  11162. CHECK_ERRORS;
  11163. RpcBindingFree(&AsyncBind);
  11164. }
  11165. if (testnum != 0)
  11166. {
  11167. break;
  11168. }
  11169. case 14:
  11170. Status = GetBinding(BARTHOLOMEW, &Async);
  11171. if (Status)
  11172. {
  11173. ApiError("Async", "GetBinding", Status);
  11174. PrintToConsole("Async : FAIL - Unable to Bind (Async)\n");
  11175. return;
  11176. }
  11177. FooProcnum = 7;
  11178. FooInterface = &HelgaInterfaceInformation;
  11179. //
  11180. // make a few calls on the helga interface
  11181. // this should cause an alter context
  11182. //
  11183. for (i=0; i<3; i++)
  11184. {
  11185. AsyncUsingAPC(Async, AsyncSizes[i], AsyncSizes[i]) ;
  11186. CHECK_ERRORS;
  11187. }
  11188. if (testnum != 0)
  11189. {
  11190. break;
  11191. }
  11192. case LAST:
  11193. PrintToConsole("hacked-up test\n");
  11194. GenerateUuidValue(UUID_SLEEP_2000, &ObjectUuid);
  11195. Status = RpcBindingSetObject(Async, &ObjectUuid);
  11196. if (Status)
  11197. {
  11198. ApiError("Async", "RpcBindingSetObject", Status);
  11199. PrintToConsole("Async : FAIL - Unable to Set Object\n");
  11200. return;
  11201. }
  11202. AsyncUsingEvent( Async, 100, 100 );
  11203. if (testnum != 0)
  11204. {
  11205. break;
  11206. }
  11207. default:
  11208. PrintToConsole("Async tests:\n") ;
  11209. PrintToConsole("0: Run all the tests\n") ;
  11210. PrintToConsole("1: Async using APCs, events and polling\n") ;
  11211. PrintToConsole("2: Async pipes using events\n") ;
  11212. PrintToConsole("3: Async pipes using APC, and flow control\n") ;
  11213. PrintToConsole("4: Async with security\n") ;
  11214. PrintToConsole("5: Sync and async exceptions\n") ;
  11215. PrintToConsole("6: Multiple outstanding calls and causal ordering\n") ;
  11216. PrintToConsole("7: Context handles\n") ;
  11217. PrintToConsole("8: Sync/Async interop\n") ;
  11218. PrintToConsole("9: Async ping server") ;
  11219. PrintToConsole("10: Alter context during async calls\n") ;
  11220. PrintToConsole("11: Async cancels\n") ;
  11221. PrintToConsole("12: Multiple outstanding non causal calls\n") ;
  11222. PrintToConsole("13: Rebinds on secure calls with uuids\n") ;
  11223. NumberOfTestsRun++ ;
  11224. return ;
  11225. break;
  11226. }
  11227. if (Async)
  11228. {
  11229. IsabelleShutdown(Async);
  11230. }
  11231. CHECK_ERRORS;
  11232. CloseHandle(SyncEvent) ;
  11233. RpcBindingFree(&Async);
  11234. PrintToConsole("Async : PASS\n");
  11235. }
  11236. //
  11237. // datagram SendAck test data
  11238. //
  11239. #include "dgpkt.hxx"
  11240. typedef DWORD
  11241. (RPCRTAPI RPC_ENTRY *SET_TEST_HOOK_FN)(
  11242. RPC_TEST_HOOK_ID id,
  11243. RPC_TEST_HOOK_FN fn
  11244. );
  11245. SET_TEST_HOOK_FN SetTestHookFn;
  11246. PVOID ChosenConnection;
  11247. RPC_TEST_HOOK_ID BasicHookId;
  11248. void
  11249. BasicPokeEventFn(
  11250. RPC_TEST_HOOK_ID id,
  11251. PVOID arg1,
  11252. PVOID arg2
  11253. )
  11254. {
  11255. PrintToConsole("PokeEventFn: conn = %p, setting the sync event\n", arg1);
  11256. SetEvent( SyncEvent );
  11257. }
  11258. void BasicSendAckTest(
  11259. int Hook
  11260. )
  11261. {
  11262. RPC_BINDING_HANDLE binding;
  11263. // housekeeping
  11264. //
  11265. DWORD Status = 0;
  11266. ++NumberOfTestsRun;
  11267. ChosenConnection = 0;
  11268. Status = GetBinding(BARTHOLOMEW, &binding);
  11269. if (Status)
  11270. {
  11271. ApiError("SendAck", "GetBinding", Status);
  11272. PrintToConsole("SetAsync : FAIL - Unable to Bind \n");
  11273. return;
  11274. }
  11275. SyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  11276. if (SyncEvent == 0)
  11277. {
  11278. ApiError("SendAck", "CreateEvent", Status);
  11279. return;
  11280. }
  11281. HMODULE hRpc = GetModuleHandle(L"RPCRT4.DLL");
  11282. if (!hRpc)
  11283. {
  11284. ApiError("SendAck","GetModuleHandle",GetLastError());
  11285. return;
  11286. }
  11287. SetTestHookFn = (SET_TEST_HOOK_FN) GetProcAddress( hRpc, "I_RpcSetTestHook" );
  11288. if (!SetTestHookFn)
  11289. {
  11290. ApiError("SendAck", "GetProcAddress: I_RpcSetTestHook", GetLastError());
  11291. if (GetLastError() == ERROR_PROC_NOT_FOUND)
  11292. {
  11293. PrintToConsole("you need to recompile with -DRPC_ENABLE_TEST_HOOKS\n");
  11294. }
  11295. return;
  11296. }
  11297. BasicHookId = MAKE_TEST_HOOK_ID( TH_DG_SEND_ACK, Hook );
  11298. (*SetTestHookFn)( BasicHookId, BasicPokeEventFn );
  11299. // make first call
  11300. //
  11301. PrintToConsole("SendAck: first call...\n") ;
  11302. Helga( binding );
  11303. // wait for the ACK to complete
  11304. //
  11305. TRACE(("SendAck: Waiting...\n")) ;
  11306. WaitForSingleObject(SyncEvent, INFINITE) ;
  11307. // make second call
  11308. //
  11309. PrintToConsole("SendAck: second call...\n") ;
  11310. Helga( binding );
  11311. // clear the hook
  11312. //
  11313. (*SetTestHookFn)( BasicHookId, 0 );
  11314. PrintToConsole("PASS\n");
  11315. }
  11316. void
  11317. Test5EventFn(
  11318. RPC_TEST_HOOK_ID id,
  11319. PVOID arg1,
  11320. PVOID arg2
  11321. )
  11322. {
  11323. // release the app thread to make calls
  11324. //
  11325. PrintToConsole("PokeEventFn: conn = %p, setting the sync event\n", arg1);
  11326. SetEvent( SyncEvent );
  11327. // wait for it to finish
  11328. //
  11329. WaitForSingleObject(SyncEvent, INFINITE);
  11330. PrintToConsole("PokeEventFn: signalled\n");
  11331. }
  11332. void AckTest5()
  11333. {
  11334. RPC_BINDING_HANDLE binding;
  11335. // housekeeping
  11336. //
  11337. DWORD Status = 0;
  11338. ++NumberOfTestsRun;
  11339. ChosenConnection = 0;
  11340. Status = GetBinding(BARTHOLOMEW, &binding);
  11341. if (Status)
  11342. {
  11343. ApiError("SendAck", "GetBinding", Status);
  11344. PrintToConsole("SetAsync : FAIL - Unable to Bind \n");
  11345. return;
  11346. }
  11347. SyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  11348. if (SyncEvent == 0)
  11349. {
  11350. ApiError("SendAck", "CreateEvent", Status);
  11351. return;
  11352. }
  11353. HMODULE hRpc = GetModuleHandle(L"RPCRT4.DLL");
  11354. if (!hRpc)
  11355. {
  11356. ApiError("SendAck","GetModuleHandle",GetLastError());
  11357. return;
  11358. }
  11359. SetTestHookFn = (SET_TEST_HOOK_FN) GetProcAddress( hRpc, "I_RpcSetTestHook" );
  11360. if (!SetTestHookFn)
  11361. {
  11362. ApiError("SendAck", "GetProcAddress: I_RpcSetTestHook", GetLastError());
  11363. if (GetLastError() == ERROR_PROC_NOT_FOUND)
  11364. {
  11365. PrintToConsole("you need to recompile with -DRPC_ENABLE_TEST_HOOKS\n");
  11366. }
  11367. return;
  11368. }
  11369. // set hook for beginning of procedure
  11370. //
  11371. (*SetTestHookFn)( MAKE_TEST_HOOK_ID( TH_DG_SEND_ACK, 1 ), Test5EventFn );
  11372. // make first call
  11373. //
  11374. PrintToConsole("SendAck: first call, will cause a delayed ACK\n") ;
  11375. Helga( binding );
  11376. // wait for the ACK to start
  11377. //
  11378. TRACE(("SendAck: Waiting...\n")) ;
  11379. WaitForSingleObject(SyncEvent, INFINITE) ;
  11380. // make a couple of calls
  11381. //
  11382. PrintToConsole("SendAck: second call, completes quickly\n") ;
  11383. Helga( binding );
  11384. PrintToConsole("SendAck: third call, completes quickly\n") ;
  11385. Helga( binding );
  11386. // clear the hook and add one for the end of the ACK proc.
  11387. //
  11388. (*SetTestHookFn)( MAKE_TEST_HOOK_ID( TH_DG_SEND_ACK, 1 ), 0 );
  11389. (*SetTestHookFn)( MAKE_TEST_HOOK_ID( TH_DG_SEND_ACK, 6 ), BasicPokeEventFn );
  11390. // release the ACK thread
  11391. PrintToConsole("SendAck: releasing orphaned delayed-ACK call and waiting for completion\n") ;
  11392. SetEvent( SyncEvent );
  11393. WaitForSingleObject(SyncEvent, INFINITE) ;
  11394. // make a couple of calls
  11395. //
  11396. PrintToConsole("SendAck: first post-ACK call...\n") ;
  11397. Helga( binding );
  11398. PrintToConsole("SendAck: second post-ACK call...\n") ;
  11399. Helga( binding );
  11400. // wait for the ACK to finish
  11401. //
  11402. TRACE(("SendAck: waiting for delayed ACK to complete\n")) ;
  11403. WaitForSingleObject(SyncEvent, INFINITE) ;
  11404. // clear the hook.
  11405. //
  11406. (*SetTestHookFn)( MAKE_TEST_HOOK_ID( TH_DG_SEND_ACK, 6 ), 0 );
  11407. PrintToConsole("PASS\n");
  11408. }
  11409. void
  11410. SendAck (
  11411. int testnum
  11412. )
  11413. {
  11414. switch (testnum)
  11415. {
  11416. default:
  11417. {
  11418. PrintToConsole("unknown send-ack case!\n");
  11419. // no break here
  11420. }
  11421. case 100:
  11422. {
  11423. //
  11424. // wants a list
  11425. //
  11426. PrintToConsole("cases:\n"
  11427. "\n"
  11428. " 1 - make 2nd call after delayed-ACK proc has finished\n"
  11429. " 2 - make 2nd call before ACK proc can take connection mutex\n"
  11430. " 3 - make 2nd call just after ACK proc takes conn mutex\n"
  11431. " 4 - make 2nd call after ACK proc decrements AckPending\n"
  11432. " 5 - ACK proc blocks just before taking mutex - other calls proceed.\n"
  11433. );
  11434. return;
  11435. }
  11436. case 0:
  11437. {
  11438. PrintToConsole("SendAck: testing each case\n");
  11439. // no break here
  11440. }
  11441. case 1:
  11442. {
  11443. //
  11444. // 1. thread makes one call
  11445. // 2. ACK is sent
  11446. // 3. thread makes second call
  11447. //
  11448. PrintToConsole("case 1 - make 2nd call after delayed-ACK proc has finished\n");
  11449. BasicSendAckTest( 6 );
  11450. if (testnum != 0)
  11451. {
  11452. break;
  11453. }
  11454. }
  11455. case 2:
  11456. {
  11457. // 1. thread makes a call
  11458. // 2. ACK proc is launched but has not yet taken mutex
  11459. // 3. thread makes second call
  11460. PrintToConsole("case 2 - make 2nd call before ACK proc can take connection mutex\n");
  11461. BasicSendAckTest( 1 );
  11462. if (testnum != 0)
  11463. {
  11464. break;
  11465. }
  11466. }
  11467. case 3:
  11468. {
  11469. // 1. thread makes a call
  11470. // 2. ACK proc is launched, takes connection mutex
  11471. // 3. thread makes second call
  11472. PrintToConsole("case 3 - make 2nd call just after ACK proc takes conn mutex\n");
  11473. BasicSendAckTest( 2 );
  11474. if (testnum != 0)
  11475. {
  11476. break;
  11477. }
  11478. }
  11479. case 4:
  11480. {
  11481. // 1. thread makes a call
  11482. // 2. ACK proc is launched, sends ACK, decrements AckPending
  11483. // 3. thread makes second call
  11484. PrintToConsole("case 4 - make 2nd call after ACK proc decrements AckPending\n");
  11485. BasicSendAckTest( 4 );
  11486. if (testnum != 0)
  11487. {
  11488. break;
  11489. }
  11490. }
  11491. case 5:
  11492. {
  11493. // 1. make a call, and wait for the ACK.
  11494. // 3, ACK proc runs in delayed-proc thread , and signals the first thread
  11495. // 4. first thread makes a couple of calls, calling CancelDelayedAck several times.
  11496. // 5. ACK proc finishes.
  11497. // 6. Make anther call, and wait for the ACK.
  11498. // 6. Make anther call, and wait for the ACK.
  11499. PrintToConsole("case 5 - test orphaned ACK proc handling");
  11500. AckTest5();
  11501. if (testnum != 0)
  11502. {
  11503. break;
  11504. }
  11505. }
  11506. }
  11507. }
  11508. void
  11509. SendErrorHook(
  11510. RPC_TEST_HOOK_ID id,
  11511. PVOID arg1,
  11512. PVOID arg2
  11513. )
  11514. {
  11515. ASSERT( id == TH_X_DG_SEND );
  11516. NCA_PACKET_HEADER * header = (NCA_PACKET_HEADER *) arg1;
  11517. DWORD * pStatus = (DWORD *) arg2;
  11518. TRACE(("SendErrorHook called: pkt type %d, serial %d\n", header->PacketType, header->SerialLo));
  11519. switch (Subtest)
  11520. {
  11521. case 1:
  11522. {
  11523. // first request is dropped with RPC_P_SEND_FAILED
  11524. //
  11525. if (header->PacketType == DG_REQUEST && header->SerialLo == 0)
  11526. {
  11527. *pStatus = RPC_P_SEND_FAILED;
  11528. }
  11529. break;
  11530. }
  11531. case 2:
  11532. {
  11533. // first request is dropped with RPC_S_OUT_OF_RESOURCES
  11534. //
  11535. if (header->PacketType == DG_REQUEST && header->SerialLo == 0)
  11536. {
  11537. *pStatus = RPC_S_OUT_OF_RESOURCES;
  11538. }
  11539. break;
  11540. }
  11541. case 3:
  11542. {
  11543. // first request is dropped with ERROR_NOT_ENOUGH_MEMORY
  11544. //
  11545. if (header->PacketType == DG_REQUEST && header->SerialLo == 0)
  11546. {
  11547. *pStatus = ERROR_NOT_ENOUGH_MEMORY;
  11548. }
  11549. break;
  11550. }
  11551. case 4:
  11552. {
  11553. // first request is dropped with RPC_P_HOST_DOWN
  11554. //
  11555. if (header->PacketType == DG_REQUEST && header->SerialLo == 0)
  11556. {
  11557. *pStatus = RPC_P_HOST_DOWN;
  11558. }
  11559. break;
  11560. }
  11561. default:
  11562. {
  11563. PrintToConsole("SendErrorHook: subtest %d is not defined\n", Subtest);
  11564. }
  11565. }
  11566. TRACE(("status is %d (0x%x)\n", *pStatus, *pStatus));
  11567. }
  11568. void
  11569. DgTransport (
  11570. int testnum
  11571. )
  11572. {
  11573. RPC_BINDING_HANDLE binding;
  11574. // housekeeping
  11575. //
  11576. DWORD Status = 0;
  11577. ++NumberOfTestsRun;
  11578. char * name = "DgTransport";
  11579. ChosenConnection = 0;
  11580. Status = GetBinding(BARTHOLOMEW, &binding);
  11581. if (Status)
  11582. {
  11583. ApiError(name, "GetBinding", Status);
  11584. PrintToConsole("%s : FAIL - Unable to Bind \n", name);
  11585. return;
  11586. }
  11587. SyncEvent = CreateEvent(NULL, FALSE, FALSE, NULL) ;
  11588. if (SyncEvent == 0)
  11589. {
  11590. ApiError(name, "CreateEvent", Status);
  11591. return;
  11592. }
  11593. HMODULE hRpc = GetModuleHandle(L"RPCRT4.DLL");
  11594. if (!hRpc)
  11595. {
  11596. ApiError(name, "GetModuleHandle",GetLastError());
  11597. return;
  11598. }
  11599. SetTestHookFn = (SET_TEST_HOOK_FN) GetProcAddress( hRpc, "I_RpcSetTestHook" );
  11600. if (!SetTestHookFn)
  11601. {
  11602. PrintToConsole("%s: can't find rpcrt4!I_RpcSetTestHook.\nRecompile RPCRT4.DLL with MSC_OPTIMIZATION=-DRPC_ENABLE_TEST_HOOKS\n");
  11603. ApiError(name, "GetProcAddress: I_RpcSetTestHook", GetLastError());
  11604. return;
  11605. }
  11606. switch (testnum)
  11607. {
  11608. default:
  11609. {
  11610. PrintToConsole("unknown DG transport case!\n");
  11611. // no break here
  11612. }
  11613. case 100:
  11614. {
  11615. //
  11616. // wants a list
  11617. //
  11618. PrintToConsole("cases:\n");
  11619. PrintToConsole("case 1 - first request dropped with RPC_P_SEND_FAILED \n");
  11620. PrintToConsole("case 2 - first request dropped with RPC_S_OUT_OF_RESOURCES \n");
  11621. PrintToConsole("case 3 - first request dropped with ERROR_NOT_ENOUGH_MEMORY \n");
  11622. PrintToConsole("case 4 - first request dropped with RPC_P_HOST_DOWN \n");
  11623. PrintToConsole("case 5 - simulate ICMP reject on first request \n");
  11624. return;
  11625. }
  11626. case 0:
  11627. {
  11628. PrintToConsole("DgTransport: testing each case\n");
  11629. // no break here
  11630. }
  11631. case 1:
  11632. {
  11633. PrintToConsole("case 1 - first request dropped with RPC_P_SEND_FAILED \n");
  11634. Subtest = testnum;
  11635. (*SetTestHookFn)( TH_X_DG_SEND, SendErrorHook );
  11636. // make first call
  11637. //
  11638. PrintToConsole("%s: calling...", name) ;
  11639. Helga( binding );
  11640. PrintToConsole("done\n");
  11641. (*SetTestHookFn)( TH_X_DG_SEND, 0 );
  11642. PrintToConsole("PASS\n");
  11643. if (testnum != 0)
  11644. {
  11645. break;
  11646. }
  11647. }
  11648. case 2:
  11649. {
  11650. PrintToConsole("case 2 - first request dropped with RPC_S_OUT_OF_RESOURCES \n");
  11651. Subtest = testnum;
  11652. (*SetTestHookFn)( TH_X_DG_SEND, SendErrorHook );
  11653. // make first call
  11654. //
  11655. PrintToConsole("%s: calling...", name) ;
  11656. Helga( binding );
  11657. PrintToConsole("done\n");
  11658. (*SetTestHookFn)( TH_X_DG_SEND, 0 );
  11659. PrintToConsole("PASS\n");
  11660. if (testnum != 0)
  11661. {
  11662. break;
  11663. }
  11664. }
  11665. case 3:
  11666. {
  11667. PrintToConsole("case 3 - first request dropped with ERROR_NOT_ENOUGH_MEMORY \n");
  11668. Subtest = testnum;
  11669. (*SetTestHookFn)( TH_X_DG_SEND, SendErrorHook );
  11670. // make first call
  11671. //
  11672. PrintToConsole("%s: calling...", name) ;
  11673. Helga( binding );
  11674. PrintToConsole("done\n");
  11675. (*SetTestHookFn)( TH_X_DG_SEND, 0 );
  11676. PrintToConsole("PASS\n");
  11677. if (testnum != 0)
  11678. {
  11679. break;
  11680. }
  11681. }
  11682. case 4:
  11683. {
  11684. PrintToConsole("case 4 - first request dropped with RPC_P_HOST_DOWN \n");
  11685. Subtest = testnum;
  11686. (*SetTestHookFn)( TH_X_DG_SEND, SendErrorHook );
  11687. // make first call
  11688. //
  11689. PrintToConsole("%s: calling...", name) ;
  11690. Status = HelgaSendReceiveFailure( binding, 0 );
  11691. PrintToConsole("done\n");
  11692. (*SetTestHookFn)( TH_X_DG_SEND, 0 );
  11693. if (Status != RPC_S_SERVER_UNAVAILABLE)
  11694. {
  11695. PrintToConsole("FAIL: wrong error code %d (0x%x)\n", Status, Status);
  11696. }
  11697. else
  11698. {
  11699. PrintToConsole("PASS\n");
  11700. }
  11701. if (testnum != 0)
  11702. {
  11703. break;
  11704. }
  11705. }
  11706. case 5:
  11707. {
  11708. PrintToConsole("case 4 - first request dropped with RPC_P_HOST_DOWN \n");
  11709. Subtest = testnum;
  11710. (*SetTestHookFn)( TH_X_DG_SEND, SendErrorHook );
  11711. // make first call
  11712. //
  11713. PrintToConsole("%s: calling...", name) ;
  11714. Status = HelgaSendReceiveFailure( binding, 0 );
  11715. PrintToConsole("done\n");
  11716. (*SetTestHookFn)( TH_X_DG_SEND, 0 );
  11717. if (Status != RPC_S_SERVER_UNAVAILABLE)
  11718. {
  11719. PrintToConsole("FAIL: wrong error code %d (0x%x)\n", Status, Status);
  11720. }
  11721. else
  11722. {
  11723. PrintToConsole("PASS\n");
  11724. }
  11725. if (testnum != 0)
  11726. {
  11727. break;
  11728. }
  11729. }
  11730. }
  11731. }
  11732. PVOID LastConnectionCreated = 0;
  11733. PVOID MySecurityContext = 0;
  11734. DWORD ChosenErrorCode = 0;
  11735. void
  11736. ShutdownHookFn(
  11737. DWORD id,
  11738. PVOID subject,
  11739. PVOID object
  11740. )
  11741. {
  11742. switch (id)
  11743. {
  11744. case TH_RPC_LOG_EVENT:
  11745. {
  11746. RPC_EVENT * event = (RPC_EVENT *) subject;
  11747. // TRACE((" hook: %c %c %p %p\n", event->Subject, event->Verb, event->SubjectPointer, event->ObjectPointer));
  11748. //
  11749. // Record sconnection creation.
  11750. //
  11751. if (event->Subject == SU_CCONN &&
  11752. event->Verb == EV_CREATE)
  11753. {
  11754. TRACE((" hook: created connection %p\n", event->SubjectPointer));
  11755. LastConnectionCreated = event->SubjectPointer;
  11756. }
  11757. break;
  11758. }
  11759. default:
  11760. {
  11761. break;
  11762. }
  11763. }
  11764. }
  11765. void
  11766. SecurityContextHook(
  11767. DWORD id,
  11768. PVOID subject,
  11769. PVOID object
  11770. )
  11771. {
  11772. if (subject == MySecurityContext)
  11773. {
  11774. TRACE((" hook executed: context %p, hook ID %x, error code is 0x%x\n", subject, id, ChosenErrorCode));
  11775. DWORD * pStatus = (DWORD *) object;
  11776. *pStatus = ChosenErrorCode;
  11777. }
  11778. else
  11779. {
  11780. TRACE((" hook: ignoring notification, my cxt = %p, context %p, hook ID %x, error code is 0x%x\n",
  11781. MySecurityContext, subject, id, ChosenErrorCode));
  11782. }
  11783. }
  11784. void
  11785. SecurityErrorWrapper(
  11786. int subtest
  11787. )
  11788. {
  11789. RPC_BINDING_HANDLE binding;
  11790. // housekeeping
  11791. //
  11792. DWORD Status = 0;
  11793. ++NumberOfTestsRun;
  11794. char * name = "security error test";
  11795. ChosenConnection = 0;
  11796. Status = GetBinding(SECURITY_ERROR, &binding);
  11797. if (Status)
  11798. {
  11799. ApiError(name, "GetBinding", Status);
  11800. PrintToConsole("%s : FAIL - Unable to Bind \n", name);
  11801. return;
  11802. }
  11803. Status = RpcBindingSetAuthInfo( binding,
  11804. NULL,
  11805. RPC_C_AUTHN_LEVEL_PKT_PRIVACY,
  11806. ulSecurityPackage,
  11807. NULL,
  11808. RPC_C_AUTHZ_NONE
  11809. );
  11810. if (Status)
  11811. {
  11812. ApiError(name, "SetAuthInfo", Status);
  11813. PrintToConsole("%s : FAIL\n", name);
  11814. return;
  11815. }
  11816. //
  11817. // Set up the test hook.
  11818. //
  11819. {
  11820. HMODULE hRpc = GetModuleHandle(L"RPCRT4.DLL");
  11821. if (!hRpc)
  11822. {
  11823. ApiError("","GetModuleHandle",GetLastError());
  11824. return;
  11825. }
  11826. SetTestHookFn = (SET_TEST_HOOK_FN) GetProcAddress( hRpc, "I_RpcSetTestHook" );
  11827. if (!SetTestHookFn)
  11828. {
  11829. ApiError("", "GetProcAddress: I_RpcSetTestHook", GetLastError());
  11830. }
  11831. }
  11832. switch (subtest)
  11833. {
  11834. default:
  11835. {
  11836. PrintToConsole("unknown security-error case!\n");
  11837. // no break here
  11838. }
  11839. case 100:
  11840. {
  11841. //
  11842. // wants a list
  11843. //
  11844. PrintToConsole("cases:\n"
  11845. "\n"
  11846. " 1 - AcceptFirstTime returns SEC_E_SHUTDOWN_IN_PROGRESS\n"
  11847. " 2 - AcceptThirdLeg returns SEC_E_SHUTDOWN_IN_PROGRESS\n"
  11848. );
  11849. return;
  11850. }
  11851. case 0:
  11852. {
  11853. PrintToConsole("running all sub tests\n");
  11854. }
  11855. case 1:
  11856. {
  11857. PrintToConsole("subtest 1: AcceptFirstTime returns SEC_E_SHUTDOWN_IN_PROGRESS\n");
  11858. Synchro(SECURITY_ERROR);
  11859. // make first call
  11860. //
  11861. PrintToConsole("%s: calling...", name) ;
  11862. Status = HelgaSendReceiveFailure( binding, 0 );
  11863. PrintToConsole("done\n");
  11864. DWORD ExpectedStatus;
  11865. if (TransportType == RPC_TRANSPORT_UDP ||
  11866. TransportType == RPC_TRANSPORT_IPX)
  11867. {
  11868. ExpectedStatus = RPC_S_SERVER_UNAVAILABLE;
  11869. }
  11870. else
  11871. {
  11872. ExpectedStatus = RPC_S_UNKNOWN_AUTHN_SERVICE;
  11873. }
  11874. if (Status != ExpectedStatus)
  11875. {
  11876. PrintToConsole("FAIL: expected error %d, received error code %d (0x%x)\n", ExpectedStatus, Status, Status);
  11877. }
  11878. else
  11879. {
  11880. PrintToConsole("PASS\n");
  11881. }
  11882. IsabelleShutdown(binding);
  11883. if (subtest)
  11884. {
  11885. break;
  11886. }
  11887. }
  11888. case 2:
  11889. {
  11890. PrintToConsole("subtest 2: AcceptThirdLeg returns SEC_E_SHUTDOWN_IN_PROGRESS\n");
  11891. Synchro(SECURITY_ERROR);
  11892. // make first call
  11893. //
  11894. PrintToConsole("%s: calling...", name) ;
  11895. Status = HelgaSendReceiveFailure( binding, 0 );
  11896. PrintToConsole("done\n");
  11897. DWORD ExpectedStatus;
  11898. if (TransportType == RPC_TRANSPORT_UDP ||
  11899. TransportType == RPC_TRANSPORT_IPX)
  11900. {
  11901. ExpectedStatus = RPC_S_SERVER_UNAVAILABLE;
  11902. }
  11903. else
  11904. {
  11905. ExpectedStatus = RPC_S_UNKNOWN_AUTHN_SERVICE;
  11906. }
  11907. if (Status != ExpectedStatus)
  11908. {
  11909. PrintToConsole("FAIL: expected error %d, received error code %d (0x%x)\n", ExpectedStatus, Status, Status);
  11910. }
  11911. else
  11912. {
  11913. PrintToConsole("PASS\n");
  11914. }
  11915. IsabelleShutdown(binding);
  11916. if (subtest)
  11917. {
  11918. break;
  11919. }
  11920. }
  11921. }
  11922. }
  11923. EVENT::EVENT (
  11924. IN OUT RPC_STATUS PAPI * RpcStatus,
  11925. IN int ManualReset,
  11926. IN BOOL fDelayInit
  11927. )
  11928. {
  11929. EventHandle = NULL;
  11930. // DelayInit events are auto reset
  11931. ASSERT(ManualReset == FALSE || fDelayInit == FALSE);
  11932. if (!fDelayInit && *RpcStatus == RPC_S_OK )
  11933. {
  11934. EventHandle = CreateEvent(NULL, ManualReset, 0, NULL);
  11935. if ( EventHandle != NULL )
  11936. {
  11937. *RpcStatus = RPC_S_OK;
  11938. }
  11939. else
  11940. {
  11941. *RpcStatus = RPC_S_OUT_OF_MEMORY;
  11942. }
  11943. }
  11944. }
  11945. EVENT::~EVENT (
  11946. )
  11947. {
  11948. if ( EventHandle )
  11949. {
  11950. BOOL bResult;
  11951. bResult = CloseHandle(EventHandle);
  11952. ASSERT(bResult != 0);
  11953. }
  11954. }
  11955. int
  11956. EVENT::Wait (
  11957. long timeout
  11958. )
  11959. {
  11960. DWORD result;
  11961. if (NULL == EventHandle)
  11962. {
  11963. InitializeEvent();
  11964. }
  11965. result = WaitForSingleObject(EventHandle, timeout);
  11966. if (result == WAIT_TIMEOUT)
  11967. return(1);
  11968. return(0);
  11969. }
  11970. void
  11971. EVENT::InitializeEvent (
  11972. )
  11973. // Used when fDelayInit is TRUE in the c'tor.
  11974. {
  11975. if (EventHandle)
  11976. {
  11977. return;
  11978. }
  11979. HANDLE event = CreateEvent(0, FALSE, FALSE, 0);
  11980. if (event)
  11981. {
  11982. if (InterlockedCompareExchangePointer(&EventHandle, event, 0) != 0)
  11983. {
  11984. CloseHandle(event);
  11985. }
  11986. return;
  11987. }
  11988. // Can't allocate an event.
  11989. RpcRaiseException(RPC_S_OUT_OF_RESOURCES);
  11990. }
  11991. void
  11992. Indent(
  11993. int indentlevel
  11994. )
  11995. {
  11996. const int SPACES_PER_INDENT = 4;
  11997. int i;
  11998. for (i=0; i < SPACES_PER_INDENT * indentlevel; ++i)
  11999. {
  12000. PrintToConsole(" ");
  12001. }
  12002. }
  12003. DWORD
  12004. DumpEeInfo(
  12005. int indentlevel
  12006. )
  12007. {
  12008. RPC_STATUS Status2;
  12009. RPC_ERROR_ENUM_HANDLE EnumHandle;
  12010. Status2 = RpcErrorStartEnumeration(&EnumHandle);
  12011. if (Status2 == RPC_S_ENTRY_NOT_FOUND)
  12012. {
  12013. PrintToConsole("eeinfo: no extended error info available\n");
  12014. }
  12015. else if (Status2 != RPC_S_OK)
  12016. {
  12017. PrintToConsole("Couldn't get EEInfo: %d\n", Status2);
  12018. }
  12019. else
  12020. {
  12021. RPC_EXTENDED_ERROR_INFO ErrorInfo;
  12022. int Records;
  12023. BOOL Result;
  12024. BOOL CopyStrings = TRUE;
  12025. PVOID Blob;
  12026. size_t BlobSize;
  12027. BOOL fUseFileTime = TRUE;
  12028. SYSTEMTIME *SystemTimeToUse;
  12029. SYSTEMTIME SystemTimeBuffer;
  12030. Status2 = RpcErrorGetNumberOfRecords(&EnumHandle, &Records);
  12031. if (Status2 == RPC_S_OK)
  12032. {
  12033. Indent(indentlevel);
  12034. PrintToConsole("Number of records is: %d\n", Records);
  12035. }
  12036. while (Status2 == RPC_S_OK)
  12037. {
  12038. ErrorInfo.Version = RPC_EEINFO_VERSION;
  12039. ErrorInfo.Flags = 0;
  12040. ErrorInfo.NumberOfParameters = 4;
  12041. if (fUseFileTime)
  12042. {
  12043. ErrorInfo.Flags |= EEInfoUseFileTime;
  12044. }
  12045. Status2 = RpcErrorGetNextRecord(&EnumHandle, CopyStrings, &ErrorInfo);
  12046. if (Status2 == RPC_S_ENTRY_NOT_FOUND)
  12047. {
  12048. RpcErrorResetEnumeration(&EnumHandle);
  12049. break;
  12050. }
  12051. else if (Status2 != RPC_S_OK)
  12052. {
  12053. PrintToConsole("Couldn't finish enumeration: %d\n", Status2);
  12054. break;
  12055. }
  12056. else
  12057. {
  12058. int i;
  12059. if (ErrorInfo.ComputerName)
  12060. {
  12061. Indent(indentlevel+1);
  12062. PrintToConsole("ComputerName is %S\n", ErrorInfo.ComputerName);
  12063. if (CopyStrings)
  12064. {
  12065. Result = HeapFree(GetProcessHeap(), 0, ErrorInfo.ComputerName);
  12066. ASSERT(Result);
  12067. }
  12068. }
  12069. Indent(indentlevel+1);
  12070. PrintToConsole("ProcessID is %d\n", ErrorInfo.ProcessID);
  12071. if (fUseFileTime)
  12072. {
  12073. Result = FileTimeToSystemTime(&ErrorInfo.u.FileTime, &SystemTimeBuffer);
  12074. ASSERT(Result);
  12075. SystemTimeToUse = &SystemTimeBuffer;
  12076. }
  12077. else
  12078. SystemTimeToUse = &ErrorInfo.u.SystemTime;
  12079. Indent(indentlevel+1);
  12080. PrintToConsole("System Time is: %d/%d/%d %d:%d:%d:%d\n",
  12081. SystemTimeToUse->wMonth,
  12082. SystemTimeToUse->wDay,
  12083. SystemTimeToUse->wYear,
  12084. SystemTimeToUse->wHour,
  12085. SystemTimeToUse->wMinute,
  12086. SystemTimeToUse->wSecond,
  12087. SystemTimeToUse->wMilliseconds);
  12088. Indent(indentlevel+1);
  12089. PrintToConsole("Generating component is %d\n", ErrorInfo.GeneratingComponent);
  12090. Indent(indentlevel+1);
  12091. PrintToConsole("Status is %d\n", ErrorInfo.Status);
  12092. Indent(indentlevel+1);
  12093. PrintToConsole("Detection location is %d\n", (int)ErrorInfo.DetectionLocation);
  12094. Indent(indentlevel+1);
  12095. PrintToConsole("Flags is %d\n", ErrorInfo.Flags);
  12096. Indent(indentlevel+1);
  12097. PrintToConsole("NumberOfParameters is %d\n", ErrorInfo.NumberOfParameters);
  12098. for (i = 0; i < ErrorInfo.NumberOfParameters; i ++)
  12099. {
  12100. switch(ErrorInfo.Parameters[i].ParameterType)
  12101. {
  12102. case eeptAnsiString:
  12103. Indent(indentlevel+1);
  12104. PrintToConsole("Ansi string: %s\n", ErrorInfo.Parameters[i].u.AnsiString);
  12105. if (CopyStrings)
  12106. {
  12107. Result = HeapFree(GetProcessHeap(), 0, ErrorInfo.Parameters[i].u.AnsiString);
  12108. ASSERT(Result);
  12109. }
  12110. break;
  12111. case eeptUnicodeString:
  12112. Indent(indentlevel+1);
  12113. PrintToConsole("Unicode string: %S\n", ErrorInfo.Parameters[i].u.UnicodeString);
  12114. if (CopyStrings)
  12115. {
  12116. Result = HeapFree(GetProcessHeap(), 0, ErrorInfo.Parameters[i].u.UnicodeString);
  12117. ASSERT(Result);
  12118. }
  12119. break;
  12120. case eeptLongVal:
  12121. Indent(indentlevel+1);
  12122. PrintToConsole("Long val: %d\n", ErrorInfo.Parameters[i].u.LVal);
  12123. break;
  12124. case eeptShortVal:
  12125. Indent(indentlevel+1);
  12126. PrintToConsole("Short val: %d\n", (int)ErrorInfo.Parameters[i].u.SVal);
  12127. break;
  12128. case eeptPointerVal:
  12129. Indent(indentlevel+1);
  12130. PrintToConsole("Pointer val: %d\n", ErrorInfo.Parameters[i].u.PVal);
  12131. break;
  12132. case eeptNone:
  12133. Indent(indentlevel+1);
  12134. PrintToConsole("Truncated\n");
  12135. break;
  12136. default:
  12137. Indent(indentlevel+1);
  12138. PrintToConsole("Invalid type: %d\n", ErrorInfo.Parameters[i].ParameterType);
  12139. return ERROR_INVALID_PARAMETER;
  12140. }
  12141. }
  12142. }
  12143. }
  12144. Status2 = RpcErrorSaveErrorInfo(&EnumHandle, &Blob, &BlobSize);
  12145. if (Status2)
  12146. {
  12147. PrintToConsole("RpcErrorSaveErrorInfo: %d", Status2);
  12148. }
  12149. RpcErrorClearInformation();
  12150. RpcErrorEndEnumeration(&EnumHandle);
  12151. Status2 = RpcErrorLoadErrorInfo(Blob, BlobSize, &EnumHandle);
  12152. if (Status2)
  12153. {
  12154. PrintToConsole("RpcErrorLoadErrorInfo: %d", Status2);
  12155. }
  12156. }
  12157. return Status2;
  12158. }