Windows NT 4.0 source code leak
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.

9406 lines
230 KiB

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