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

2522 lines
58 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1990 - 1999
  6. //
  7. // File: hndlsvr.hxx
  8. //
  9. //--------------------------------------------------------------------------
  10. /* --------------------------------------------------------------------
  11. Microsoft OS/2 LAN Manager
  12. Copyright(c) Microsoft Corp., 1990
  13. -------------------------------------------------------------------- */
  14. /* --------------------------------------------------------------------
  15. File : hndlsvr.hxx
  16. Description :
  17. The classes in the handle management layer which are specific to the
  18. server runtime live in this file. Classes common to both the client
  19. and server runtimes are in handle.hxx. The classes described here
  20. are independent of specific RPC protocol as well as transport.
  21. The class GENERIC_OBJECT is defined in handle.hxx.
  22. A pointer to a SERVER_HANDLE object is returned by the
  23. RpcCreateServer API.
  24. The INTERFACE_HANDLE class represents an interface and each
  25. INTERFACE_HANDLE object hangs from a SERVER_HANDLE object.
  26. An ADDRESS_HANDLE object is a transport address. When the
  27. ADDRESS_HANDLE object is added to a SERVER_HANDLE object, a manager
  28. will be started for the ADDRESS_HANDLE object.
  29. The SCONNECTION class represents a call handle on the server side.
  30. The ASSOCIATION_HANDLE class represents a client from the servers
  31. perspective.
  32. GENERIC_OBJECT
  33. SERVER_HANDLE
  34. INTERFACE_HANDLE
  35. ADDRESS_HANDLE
  36. MESSAGE_OBJECT
  37. SCONNECTION
  38. ASSOCIATION_HANDLE
  39. History :
  40. mikemon ??-??-?? Beginning of recorded history.
  41. mikemon 10-15-90 Changed the shutdown functionality to PauseExecution
  42. rather than suspending and resuming a thread.
  43. mikemon 12-28-90 Updated the comments to match reality.
  44. davidst ?? Add DG_SCALL as friend of RPC_SERVER
  45. connieh 8-2-93 Remove DG_SCALL as friend of RPC_SERVER
  46. tonychan 7-15-95 change RPC_ADDRESS class to have a list of NetAddr
  47. -------------------------------------------------------------------- */
  48. // Each association handle has a set of rundown routines associated with
  49. // it.
  50. #ifndef __HNDLSVR_HXX__
  51. #define __HNDLSVR_HXX__
  52. //typedef RPC_STATUS RPC_FORWARD_FUNCTION(
  53. // IN RPC_UUID InterfaceId,
  54. // IN RPC_VERSION * InterfaceVersion,
  55. // IN RPC_UUID ObjectId,
  56. // IN RPC_CHAR PAPI * RpcProtocolSequence,
  57. // IN void * * ppDestEndpoint);
  58. #define MAX_IF_CALLS 0xFFFFFFFF
  59. #define EP_REGISTER_NOREPLACE 0x00L
  60. #define EP_REGISTER_REPLACE 0x01L
  61. class RPC_SERVER;
  62. class SCONNECTION;
  63. class SCALL;
  64. RPC_STATUS
  65. RegisterEntries(
  66. IN RPC_IF_HANDLE IfSpec,
  67. IN RPC_BINDING_VECTOR * BindingVector,
  68. IN UUID_VECTOR * ObjUuidVector,
  69. IN unsigned char * Annotation,
  70. IN unsigned long ReplaceNoReplace
  71. );
  72. class RPC_INTERFACE_MANAGER
  73. /*++
  74. Class Description:
  75. An instance of this class is the manager for a particular type UUID
  76. for a particular interface. Each RPC_INTERFACE instance will contain
  77. a dictionary of these objects. Rather than keep a count of the calls
  78. using each manager, we just never delete these objects.
  79. Fields:
  80. TypeUuid - Contains the type of this interface manager. This is the
  81. key which we will use to find the correct interface manager in
  82. dictionary of interface managers maintained by each rpc interface.
  83. ManagerEpv - Contains a pointer to the manager entry point vector
  84. for this interface manager.
  85. ValidManagerFlag - Contains a flag indicating whether or not this
  86. manager is valid (that it has been registered more recently that
  87. it has been unregistered). The flag is zero if the the manager
  88. is not valid, and non-zero otherwise.
  89. ActiveCallCount - Contains a count of the number of calls which are
  90. active on this type manager.
  91. --*/
  92. {
  93. private:
  94. RPC_UUID TypeUuid;
  95. RPC_MGR_EPV PAPI * ManagerEpv;
  96. unsigned int ValidManagerFlag;
  97. INTERLOCKED_INTEGER ActiveCallCount;
  98. public:
  99. RPC_INTERFACE_MANAGER (
  100. IN RPC_UUID PAPI * TypeUuid,
  101. IN RPC_MGR_EPV PAPI * ManagerEpv
  102. );
  103. unsigned int
  104. ValidManager (
  105. );
  106. void
  107. SetManagerEpv (
  108. IN RPC_MGR_EPV PAPI * ManagerEpv
  109. );
  110. int
  111. MatchTypeUuid (
  112. IN RPC_UUID PAPI * TypeUuid
  113. );
  114. void
  115. InvalidateManager (
  116. );
  117. RPC_MGR_EPV PAPI *
  118. QueryManagerEpv (
  119. );
  120. void
  121. CallBeginning (
  122. );
  123. void
  124. CallEnding (
  125. );
  126. unsigned int
  127. InquireActiveCallCount (
  128. );
  129. };
  130. inline
  131. RPC_INTERFACE_MANAGER::RPC_INTERFACE_MANAGER (
  132. IN RPC_UUID PAPI * TypeUuid,
  133. IN RPC_MGR_EPV PAPI * ManagerEpv
  134. ) : ActiveCallCount(0)
  135. /*++
  136. Routine Description:
  137. An RPC_INTERFACE_MANAGER instance starts out being valid, so
  138. we make sure of that here. We also need make the type UUID of
  139. this be the same as the specified type UUID.
  140. --*/
  141. {
  142. ValidManagerFlag = 1;
  143. this->TypeUuid.CopyUuid(TypeUuid);
  144. this->ManagerEpv = ManagerEpv;
  145. }
  146. inline unsigned int
  147. RPC_INTERFACE_MANAGER::ValidManager (
  148. )
  149. /*++
  150. Routine Description:
  151. An indication of whether this manager is valid manager or not is
  152. returned.
  153. Return Value:
  154. Zero will be returned if this manager is not a valid manager;
  155. otherwise, non-zero will be returned.
  156. --*/
  157. {
  158. return(ValidManagerFlag);
  159. }
  160. inline void
  161. RPC_INTERFACE_MANAGER::SetManagerEpv (
  162. IN RPC_MGR_EPV PAPI * ManagerEpv
  163. )
  164. /*++
  165. Routine Description:
  166. This writer is used to set the manager entry point vector for
  167. this interface manager.
  168. Arguments:
  169. ManagerEpv - Supplies the new manager entry point vector for this.
  170. --*/
  171. {
  172. this->ManagerEpv = ManagerEpv;
  173. ValidManagerFlag = 1;
  174. }
  175. inline int
  176. RPC_INTERFACE_MANAGER::MatchTypeUuid (
  177. IN RPC_UUID PAPI * TypeUuid
  178. )
  179. /*++
  180. Routine Description:
  181. This method compares the supplied type UUID against the type UUID
  182. contained in this rpc interface manager.
  183. Arguments:
  184. TypeUuid - Supplies the type UUID.
  185. Return Value:
  186. Zero will be returned if the supplied type UUID is the same as the
  187. type UUID contained in this.
  188. --*/
  189. {
  190. return(this->TypeUuid.MatchUuid(TypeUuid));
  191. }
  192. inline void
  193. RPC_INTERFACE_MANAGER::InvalidateManager (
  194. )
  195. /*++
  196. Routine Description:
  197. This method is used to invalidate a manager
  198. --*/
  199. {
  200. ValidManagerFlag = 0;
  201. }
  202. inline RPC_MGR_EPV PAPI *
  203. RPC_INTERFACE_MANAGER::QueryManagerEpv (
  204. )
  205. /*++
  206. Routine Description:
  207. This method is called to obtain the manager entry point vector
  208. for this interface manager.
  209. Return Value:
  210. The manager entry point vector for this interface manager is returned.
  211. --*/
  212. {
  213. return(ManagerEpv);
  214. }
  215. inline void
  216. RPC_INTERFACE_MANAGER::CallBeginning (
  217. )
  218. /*++
  219. Routine Description:
  220. This method is used to indicate that a remote procedure call using this
  221. type manager is beginning.
  222. --*/
  223. {
  224. ActiveCallCount.Increment();
  225. }
  226. inline void
  227. RPC_INTERFACE_MANAGER::CallEnding (
  228. )
  229. /*++
  230. Routine Description:
  231. We are being notified that a remote procedure call using this type
  232. manager is done.
  233. --*/
  234. {
  235. ActiveCallCount.Decrement();
  236. }
  237. inline unsigned int
  238. RPC_INTERFACE_MANAGER::InquireActiveCallCount (
  239. )
  240. /*++
  241. Return Value:
  242. The number of remote procedure calls actively using this type manager
  243. will be returned.
  244. --*/
  245. {
  246. return((unsigned int) ActiveCallCount.GetInteger());
  247. }
  248. class RPC_INTERFACE;
  249. #if !defined(NO_LOCATOR_CODE)
  250. class NS_ENTRY
  251. {
  252. friend class RPC_INTERFACE;
  253. public:
  254. int Key;
  255. private:
  256. unsigned long EntryNameSyntax;
  257. RPC_CHAR *EntryName;
  258. public:
  259. NS_ENTRY(
  260. IN unsigned long MyEntryNameSyntax,
  261. RPC_CHAR *MyEntryName,
  262. OUT RPC_STATUS *Status
  263. );
  264. ~NS_ENTRY(
  265. );
  266. BOOL
  267. Match (
  268. IN unsigned long MyEntryNameSyntax,
  269. IN RPC_CHAR *MyEntryName
  270. );
  271. };
  272. inline
  273. NS_ENTRY::NS_ENTRY(
  274. IN unsigned long MyEntryNameSyntax,
  275. IN RPC_CHAR *MyEntryName,
  276. IN RPC_STATUS *Status
  277. )
  278. {
  279. int Length = (RpcpStringLength(MyEntryName)+1) * sizeof(RPC_CHAR);
  280. EntryNameSyntax = MyEntryNameSyntax;
  281. Key = -1;
  282. EntryName = (RPC_CHAR *) RpcpFarAllocate(Length);
  283. if (EntryName == 0)
  284. {
  285. *Status = RPC_S_OUT_OF_MEMORY;
  286. return;
  287. }
  288. RpcpStringCopy(EntryName, MyEntryName);
  289. *Status = RPC_S_OK;
  290. }
  291. inline
  292. NS_ENTRY::~NS_ENTRY(
  293. )
  294. {
  295. if (EntryName)
  296. {
  297. RpcpFarFree(EntryName);
  298. }
  299. }
  300. inline
  301. BOOL
  302. NS_ENTRY::Match (
  303. IN unsigned long MyEntryNameSyntax,
  304. IN RPC_CHAR *MyEntryName
  305. )
  306. {
  307. if (MyEntryNameSyntax == EntryNameSyntax
  308. && RpcpStringCompare(MyEntryName, EntryName) == 0)
  309. {
  310. return TRUE;
  311. }
  312. return FALSE;
  313. }
  314. NEW_SDICT(NS_ENTRY);
  315. #endif
  316. NEW_SDICT(RPC_INTERFACE_MANAGER);
  317. #if DBG
  318. typedef enum tagInterfaceUsesStrictContextHandles
  319. {
  320. iuschNo,
  321. iuschDontKnow,
  322. iuschYes
  323. } InterfaceUsesStrictContextHandles;
  324. #endif
  325. class RPC_INTERFACE
  326. /*++
  327. Class Description:
  328. This class represents an RPC interface. Rather than keep a count
  329. of the number of calls active (and bindings in the connection
  330. oriented runtimes), we never delete instances of this class. Hence,
  331. we need a flag indicating whether this interface is active or not.
  332. What we do is to keep a count of the number of managers for this
  333. interface.
  334. Once an interface is loaded, it can not be unloaded. The application
  335. has no way of knowing when all calls using stubs for the interface
  336. have completed.
  337. Fields:
  338. RpcInterfaceInformation - Contains a description of this interface.
  339. The interface UUID and version, as well as transfer syntax, live
  340. in this field. In addition, the stub dispatch table can be
  341. found here as well.
  342. InterfaceManagerDictionary - Contains the dictionary of interface
  343. managers for this interface.
  344. NullManagerEpv - Contains the manager entry point vector for the
  345. NULL type UUID. This is an optimization for the case in which
  346. object UUIDs are not used.
  347. NullManagerFlag - Contains a flag indictating whether or not this
  348. interface has a manager for the NULL type UUID. A non-zero value
  349. indicates there is a manager for the NULL type UUID.
  350. ManagerCount - Contains a count of the number of managers for this
  351. interface.
  352. Server - Contains a pointer to the rpc server which owns this
  353. interface.
  354. NullManagerActiveCallCount - Contains a count of the number of calls
  355. which are active on this interface using the manager for the NULL
  356. type UUID.
  357. --*/
  358. {
  359. private:
  360. RPC_SERVER * Server;
  361. unsigned int Flags ;
  362. unsigned int NullManagerFlag;
  363. RPC_MGR_EPV PAPI * NullManagerEpv;
  364. RPC_IF_CALLBACK_FN PAPI *CallbackFn ;
  365. RPC_SERVER_INTERFACE RpcInterfaceInformation;
  366. MIDL_SYNTAX_INFO *TransferSyntaxesArray;
  367. // the count of elements in the TransferSyntaxesArray. If this is 0,
  368. // the server supports only one transfer syntax and this is the transfer
  369. // syntax in the RpcInterfaceInformation->TransferSyntax
  370. ULONG NumberOfSupportedTransferSyntaxes;
  371. // the index of the transfer syntax preferred by the server
  372. ULONG PreferredTransferSyntax;
  373. int PipeInterfaceFlag ; // if 1, the interface contains methods that use pipes
  374. unsigned int ManagerCount;
  375. unsigned int MaxCalls ;
  376. BOOL fReplace;
  377. UUID_VECTOR *UuidVector;
  378. RPC_INTERFACE_MANAGER_DICT InterfaceManagerDictionary;
  379. unsigned char Annotation[64];
  380. #if !defined(NO_LOCATOR_CODE)
  381. NS_ENTRY_DICT NsEntries;
  382. #endif
  383. unsigned int MaxRpcSize;
  384. BOOL fBindingsExported;
  385. INTERLOCKED_INTEGER NullManagerActiveCallCount;
  386. INTERLOCKED_INTEGER AutoListenCallCount ;
  387. #if DBG
  388. InterfaceUsesStrictContextHandles Strict;
  389. #endif
  390. RPC_STATUS
  391. DispatchToStubWorker (
  392. IN OUT PRPC_MESSAGE Message,
  393. IN unsigned int CallbackFlag,
  394. IN PRPC_DISPATCH_TABLE DispatchTableToUse,
  395. OUT RPC_STATUS PAPI * ExceptionCode
  396. );
  397. public:
  398. unsigned long SequenceNumber ;
  399. RPC_INTERFACE (
  400. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  401. IN RPC_SERVER * Server,
  402. IN unsigned int Flags,
  403. IN unsigned int MaxCalls,
  404. IN unsigned int MaxRpcSize,
  405. IN RPC_IF_CALLBACK_FN PAPI *IfCallbackFn,
  406. OUT RPC_STATUS *Status
  407. );
  408. ~RPC_INTERFACE (
  409. );
  410. int
  411. MatchRpcInterfaceInformation (
  412. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation
  413. );
  414. RPC_STATUS
  415. RegisterTypeManager (
  416. IN RPC_UUID PAPI * ManagerTypeUuid OPTIONAL,
  417. IN RPC_MGR_EPV PAPI * ManagerEpv OPTIONAL
  418. );
  419. RPC_INTERFACE_MANAGER *
  420. FindInterfaceManager (
  421. IN RPC_UUID PAPI * ManagerTypeUuid
  422. );
  423. RPC_STATUS
  424. DispatchToStub (
  425. IN OUT PRPC_MESSAGE Message,
  426. IN unsigned int CallbackFlag,
  427. IN PRPC_DISPATCH_TABLE DispatchTableToUse,
  428. OUT RPC_STATUS PAPI * ExceptionCode
  429. );
  430. RPC_STATUS
  431. DispatchToStubWithObject (
  432. IN OUT PRPC_MESSAGE Message,
  433. IN RPC_UUID * ObjectUuid,
  434. IN unsigned int CallbackFlag,
  435. IN PRPC_DISPATCH_TABLE DispatchTableToUse,
  436. OUT RPC_STATUS PAPI * ExceptionCode
  437. );
  438. unsigned int
  439. MatchInterfaceIdentifier (
  440. IN PRPC_SYNTAX_IDENTIFIER InterfaceIdentifier
  441. );
  442. unsigned int
  443. SelectTransferSyntax (
  444. IN PRPC_SYNTAX_IDENTIFIER ProposedTransferSyntaxes,
  445. IN unsigned int NumberOfTransferSyntaxes,
  446. OUT PRPC_SYNTAX_IDENTIFIER AcceptedTransferSyntax,
  447. OUT BOOL *fIsInterfaceTransferPreferred,
  448. OUT int *ProposedTransferSyntaxIndex,
  449. OUT int *AvailableTransferSyntaxIndex
  450. );
  451. RPC_STATUS
  452. UnregisterManagerEpv (
  453. IN RPC_UUID PAPI * ManagerTypeUuid, OPTIONAL
  454. IN unsigned int WaitForCallsToComplete
  455. );
  456. RPC_STATUS
  457. InquireManagerEpv (
  458. IN RPC_UUID PAPI * ManagerTypeUuid, OPTIONAL
  459. OUT RPC_MGR_EPV PAPI * PAPI * ManagerEpv
  460. );
  461. RPC_STATUS
  462. UpdateRpcInterfaceInformation (
  463. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  464. IN unsigned int Flags,
  465. IN unsigned int MaxCalls,
  466. IN unsigned int MaxRpcSize,
  467. IN RPC_IF_CALLBACK_FN PAPI *IfCallbackFn
  468. );
  469. RPC_IF_ID __RPC_FAR *
  470. InquireInterfaceId (
  471. );
  472. inline int
  473. IsAutoListenInterface(
  474. ) ;
  475. inline BOOL
  476. IsUnknownAuthorityAllowed();
  477. void
  478. BeginAutoListenCall (
  479. ) ;
  480. void
  481. EndAutoListenCall (
  482. ) ;
  483. long
  484. InqAutoListenCallCount(
  485. );
  486. RPC_STATUS
  487. CheckSecurityIfNecessary(
  488. IN void * Context
  489. );
  490. inline int
  491. IsSecurityCallbackReqd(
  492. );
  493. inline int
  494. IsPipeInterface(
  495. ) ;
  496. BOOL
  497. IsObjectSupported (
  498. IN RPC_UUID * ObjectUuid
  499. );
  500. void
  501. EndCall(
  502. IN unsigned int CallbackFlag,
  503. IN BOOL fAsync = 0
  504. ) ;
  505. RPC_STATUS
  506. UpdateBindings(
  507. IN RPC_BINDING_VECTOR *BindingVector
  508. );
  509. inline BOOL
  510. NeedToUpdateBindings(
  511. void
  512. );
  513. RPC_STATUS
  514. InterfaceExported (
  515. IN UUID_VECTOR *MyObjectUuidVector,
  516. IN unsigned char *MyAnnotation,
  517. IN BOOL MyfReplace
  518. );
  519. void
  520. WaitForCalls(
  521. void
  522. );
  523. #if !defined(NO_LOCATOR_CODE)
  524. RPC_STATUS
  525. NsInterfaceExported (
  526. IN unsigned long EntryNameSyntax,
  527. IN RPC_CHAR *EntryName
  528. );
  529. RPC_STATUS
  530. NsInterfaceUnexported (
  531. IN unsigned long EntryNameSyntax,
  532. IN RPC_CHAR *EntryName
  533. );
  534. NS_ENTRY *
  535. FindEntry (
  536. IN unsigned long EntryNameSyntax,
  537. IN RPC_CHAR *EntryName
  538. );
  539. #endif
  540. BOOL
  541. CallSizeLimitReached (
  542. IN DWORD CurrentCallSize
  543. )
  544. {
  545. return (CurrentCallSize > MaxRpcSize);
  546. }
  547. DWORD GetInterfaceFirstDWORD(void)
  548. {
  549. return RpcInterfaceInformation.InterfaceId.SyntaxGUID.Data1;
  550. }
  551. PRPC_DISPATCH_TABLE GetDefaultDispatchTable(void)
  552. {
  553. return RpcInterfaceInformation.DispatchTable;
  554. }
  555. void GetSelectedTransferSyntaxAndDispatchTable(IN int SelectedTransferSyntaxIndex,
  556. OUT RPC_SYNTAX_IDENTIFIER **SelectedTransferSyntax,
  557. OUT PRPC_DISPATCH_TABLE *SelectedDispatchTable);
  558. #if DBG
  559. inline void
  560. InterfaceDoesNotUseStrict (
  561. void
  562. )
  563. {
  564. // it can go from No to No and from DontKnow to No,
  565. // but not from Yes to No
  566. ASSERT(Strict != iuschYes);
  567. if (Strict != iuschNo)
  568. Strict = iuschNo;
  569. }
  570. inline BOOL
  571. DoesInterfaceUseNonStrict (
  572. void
  573. )
  574. {
  575. // in this interface using non-strict?
  576. return (Strict == iuschNo);
  577. }
  578. #endif
  579. private:
  580. inline BOOL AreMultipleTransferSyntaxesSupported(void)
  581. {
  582. return NumberOfSupportedTransferSyntaxes;
  583. }
  584. };
  585. inline
  586. RPC_INTERFACE::~RPC_INTERFACE (
  587. )
  588. {
  589. #if !defined(NO_LOCATOR_CODE)
  590. NS_ENTRY *NsEntry;
  591. #endif
  592. unsigned int Length;
  593. DictionaryCursor cursor;
  594. if (fBindingsExported)
  595. {
  596. RpcpFarFree(UuidVector);
  597. }
  598. #if !defined(NO_LOCATOR_CODE)
  599. NsEntries.Reset(cursor);
  600. while (NsEntry = NsEntries.Next(cursor))
  601. {
  602. delete NsEntry;
  603. }
  604. #endif
  605. }
  606. // check if the interface has methods that use pipes
  607. inline int
  608. RPC_INTERFACE::IsPipeInterface (
  609. )
  610. {
  611. return (PipeInterfaceFlag) ;
  612. }
  613. inline int
  614. RPC_INTERFACE::IsSecurityCallbackReqd(
  615. )
  616. {
  617. if (CallbackFn)
  618. {
  619. return TRUE;
  620. }
  621. return FALSE;
  622. }
  623. inline void
  624. RPC_INTERFACE::BeginAutoListenCall (
  625. )
  626. {
  627. int Count ;
  628. Count = AutoListenCallCount.Increment() ;
  629. LogEvent(SU_HANDLE, EV_INC, this, 0, Count, 1);
  630. }
  631. inline void
  632. RPC_INTERFACE::EndAutoListenCall (
  633. )
  634. {
  635. int Count ;
  636. ASSERT(AutoListenCallCount.GetInteger() >= 1);
  637. Count = AutoListenCallCount.Decrement() ;
  638. LogEvent(SU_HANDLE, EV_DEC, this, 0, Count, 1);
  639. }
  640. inline long
  641. RPC_INTERFACE::InqAutoListenCallCount (
  642. )
  643. {
  644. return AutoListenCallCount.GetInteger() ;
  645. }
  646. inline int
  647. RPC_INTERFACE::IsAutoListenInterface (
  648. )
  649. {
  650. return (Flags & RPC_IF_AUTOLISTEN) ;
  651. }
  652. inline BOOL
  653. RPC_INTERFACE::IsUnknownAuthorityAllowed()
  654. {
  655. return ((Flags & RPC_IF_ALLOW_UNKNOWN_AUTHORITY) != 0);
  656. }
  657. inline int
  658. RPC_INTERFACE::MatchRpcInterfaceInformation (
  659. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation
  660. )
  661. /*++
  662. Routine Description:
  663. This method compares the supplied rpc interface information against
  664. that contained in this rpc interface.
  665. Arguments:
  666. RpcInterfaceInformation - Supplies the rpc interface information.
  667. Return Value:
  668. Zero will be returned if the supplied rpc interface information
  669. (interface and transfer syntaxes) is the same as in this rpc interface;
  670. otherwise, non-zero will be returned.
  671. --*/
  672. {
  673. return(RpcpMemoryCompare(&(this->RpcInterfaceInformation),
  674. RpcInterfaceInformation, sizeof(RPC_SYNTAX_IDENTIFIER) * 2));
  675. }
  676. inline BOOL
  677. RPC_INTERFACE::NeedToUpdateBindings(
  678. void
  679. )
  680. /*++
  681. Function Name:NeedToUpdateBindings
  682. Parameters:
  683. Description:
  684. Returns TRUE if this interface has been exported to the epmapper
  685. or the name service. In this case, we need to update the
  686. bindings via UpdateBindings
  687. Returns:
  688. TRUE - the bindings need updating
  689. FALSE - the bindings don't need updating
  690. --*/
  691. {
  692. #if defined(NO_LOCATOR_CODE)
  693. return (fBindingsExported);
  694. #else
  695. return (fBindingsExported || (NsEntries.Size() > 0));
  696. #endif
  697. }
  698. extern RPC_INTERFACE *GlobalManagementInterface;
  699. class RPC_ADDRESS : public GENERIC_OBJECT
  700. /*++
  701. Class Description:
  702. This class represents an address (or protocol sequence in the DCE
  703. lingo). An address is responsible for receiving calls, dispatching
  704. them to an interface, and then returning the reply.
  705. Fields:
  706. StaticEndpointFlag - This field specifies whether this address has
  707. a static endpoint or a dynamic endpoint. This information is
  708. necessary so that when we create a binding handle from this
  709. address we know whether or not to specify an endpoint. See
  710. the InquireBinding method of this class. A value of zero
  711. indicates a dynamic endpoint, and a value of non-zero indicates
  712. a static endpoint.
  713. --*/
  714. {
  715. protected:
  716. TRANS_INFO *TransInfo;
  717. private:
  718. RPC_CHAR PAPI * Endpoint;
  719. RPC_CHAR PAPI * RpcProtocolSequence;
  720. RPC_CHAR PAPI * NetworkAddress;
  721. NETWORK_ADDRESS_VECTOR *pNetworkAddressVector;
  722. unsigned int StaticEndpointFlag;
  723. protected:
  724. int ActiveCallCount;
  725. unsigned int PendingQueueSize;
  726. void PAPI *SecurityDescriptor;
  727. unsigned long NICFlags;
  728. unsigned long EndpointFlags;
  729. RPC_ADDRESS (
  730. IN OUT RPC_STATUS PAPI * RpcStatus
  731. );
  732. public:
  733. RPC_SERVER * Server;
  734. MUTEX AddressMutex;
  735. int DictKey;
  736. virtual ~RPC_ADDRESS (
  737. );
  738. virtual RPC_STATUS
  739. ServerSetupAddress (
  740. IN RPC_CHAR PAPI * NetworkAddress,
  741. IN RPC_CHAR PAPI * PAPI *Endpoint,
  742. IN unsigned int PendingQueueSize,
  743. IN void PAPI * SecurityDescriptor, OPTIONAL
  744. IN unsigned long EndpointFlags,
  745. IN unsigned long NICFlags,
  746. OUT NETWORK_ADDRESS_VECTOR **ppNetworkAddressVector
  747. ) = 0;
  748. virtual void
  749. PnpNotify (
  750. ) {};
  751. virtual void
  752. EncourageCallCleanup(
  753. RPC_INTERFACE * Interface
  754. );
  755. RPC_CHAR *
  756. GetListNetworkAddress (IN unsigned int Index
  757. );
  758. unsigned int
  759. InqNumNetworkAddress();
  760. RPC_STATUS
  761. SetEndpointAndStuff (
  762. IN RPC_CHAR PAPI * NetworkAddress,
  763. IN RPC_CHAR PAPI * Endpoint,
  764. IN RPC_CHAR PAPI * RpcProtocolSequence,
  765. IN RPC_SERVER * Server,
  766. IN unsigned int StaticEndpointFlag,
  767. IN unsigned int PendingQueueSize,
  768. IN void PAPI *SecurityDescriptor,
  769. IN unsigned long EndpointFlags,
  770. IN unsigned long NICFlags,
  771. IN NETWORK_ADDRESS_VECTOR *pNetworkAddressVector
  772. );
  773. RPC_STATUS
  774. FindInterfaceTransfer (
  775. IN PRPC_SYNTAX_IDENTIFIER InterfaceIdentifier,
  776. IN PRPC_SYNTAX_IDENTIFIER ProposedTransferSyntaxes,
  777. IN unsigned int NumberOfTransferSyntaxes,
  778. OUT PRPC_SYNTAX_IDENTIFIER AcceptedTransferSyntax,
  779. OUT RPC_INTERFACE ** RpcInterface,
  780. OUT BOOL *fIsInterfaceTransferPreferred,
  781. OUT int *ProposedTransferSyntaxIndex,
  782. OUT int *AvailableTransferSyntaxIndex
  783. );
  784. virtual RPC_STATUS
  785. CompleteListen (
  786. ) ;
  787. BINDING_HANDLE *
  788. InquireBinding (RPC_CHAR * LocalNetworkAddress = 0
  789. );
  790. virtual RPC_STATUS
  791. ServerStartingToListen (
  792. IN unsigned int MinimumCallThreads,
  793. IN unsigned int MaximumConcurrentCalls
  794. );
  795. virtual void
  796. ServerStoppedListening (
  797. );
  798. int
  799. SameEndpointAndProtocolSequence (
  800. IN RPC_CHAR PAPI * NetworkAddress,
  801. IN RPC_CHAR PAPI * RpcProtocolSequence,
  802. IN RPC_CHAR PAPI * Endpoint
  803. );
  804. int
  805. SameProtocolSequence (
  806. IN RPC_CHAR PAPI * NetworkAddress,
  807. IN RPC_CHAR PAPI * RpcProtocolSequence
  808. );
  809. virtual long
  810. InqNumberOfActiveCalls (
  811. );
  812. RPC_CHAR *
  813. InqEndpoint (
  814. )
  815. {
  816. return(Endpoint);
  817. }
  818. RPC_CHAR *
  819. InqRpcProtocolSequence (
  820. );
  821. virtual void
  822. WaitForCalls(
  823. ) ;
  824. RPC_STATUS
  825. RestartAddress (
  826. IN unsigned int MinThreads,
  827. IN unsigned int MaxCalls
  828. );
  829. RPC_STATUS
  830. CopyDescriptor (
  831. IN void *SecurityDescriptor,
  832. OUT void **OutDescriptor
  833. );
  834. virtual void
  835. DestroyContextHandlesForInterface (
  836. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  837. IN BOOL RundownContextHandles
  838. );
  839. virtual void
  840. CleanupIdleSContexts (
  841. void
  842. );
  843. };
  844. inline void
  845. RPC_ADDRESS::EncourageCallCleanup(
  846. RPC_INTERFACE * Interface
  847. )
  848. {
  849. }
  850. inline void
  851. RPC_ADDRESS::WaitForCalls(
  852. )
  853. {
  854. }
  855. inline RPC_STATUS
  856. RPC_ADDRESS::CompleteListen (
  857. )
  858. {
  859. return RPC_S_OK ;
  860. }
  861. inline int
  862. RPC_ADDRESS::SameProtocolSequence (
  863. IN RPC_CHAR PAPI * NetworkAddress,
  864. IN RPC_CHAR PAPI * ProtocolSequence
  865. )
  866. /*++
  867. Routine Description:
  868. This routine is used to determine if the rpc address has the same
  869. protocol sequence as the protocol sequence
  870. supplied as the argument.
  871. Arguments:
  872. ProtocolSequence - Supplies the protocol sequence to compare against
  873. the protocol sequence of this address.
  874. Return Value:
  875. Non-zero will be returned if this address and the supplied endpoint and
  876. protocol sequence are the same, otherwise, zero will be returned.
  877. --*/
  878. {
  879. if (NetworkAddress == NULL && this->NetworkAddress == NULL)
  880. {
  881. return (RpcpStringCompare(this->RpcProtocolSequence, ProtocolSequence) == 0);
  882. }
  883. else if (NetworkAddress == NULL || this->NetworkAddress == NULL)
  884. {
  885. return 0;
  886. }
  887. return (RpcpStringCompare(this->RpcProtocolSequence, ProtocolSequence) == 0)
  888. && (RpcpStringCompare(this->NetworkAddress, NetworkAddress) == 0);
  889. }
  890. inline int
  891. RPC_ADDRESS::SameEndpointAndProtocolSequence (
  892. IN RPC_CHAR PAPI * NetworkAddress,
  893. IN RPC_CHAR PAPI * ProtocolSequence,
  894. IN RPC_CHAR PAPI * Endpoint
  895. )
  896. /*++
  897. Routine Description:
  898. This routine is used to determine if the rpc address has the same
  899. endpoint and protocol sequence as the endpoint and protocol sequence
  900. supplied as arguments.
  901. Arguments:
  902. ProtocolSequence - Supplies the protocol sequence to compare against
  903. the protocol sequence of this address.
  904. Endpoint - Supplies the endpoint to compare against the endpoint in this
  905. address.
  906. Return Value:
  907. Non-zero will be returned if this address and the supplied endpoint and
  908. protocol sequence are the same, otherwise, zero will be returned.
  909. --*/
  910. {
  911. if (NetworkAddress == NULL && this->NetworkAddress == NULL)
  912. {
  913. return(( RpcpStringCompare(this->Endpoint, Endpoint) == 0 )
  914. && ( RpcpStringCompare(this->RpcProtocolSequence,
  915. ProtocolSequence) == 0 ));
  916. }
  917. else if (NetworkAddress == NULL || this->NetworkAddress == NULL)
  918. {
  919. return 0;
  920. }
  921. return(( RpcpStringCompare(this->Endpoint, Endpoint) == 0 )
  922. && ( RpcpStringCompare(this->RpcProtocolSequence, ProtocolSequence) == 0 )
  923. && ( RpcpStringCompare(this->NetworkAddress, NetworkAddress) == 0 ));
  924. }
  925. inline RPC_CHAR *
  926. RPC_ADDRESS::InqRpcProtocolSequence (
  927. )
  928. {
  929. return(RpcProtocolSequence);
  930. }
  931. inline unsigned int
  932. RPC_ADDRESS::InqNumNetworkAddress (
  933. )
  934. {
  935. return(pNetworkAddressVector->Count);
  936. }
  937. NEW_SDICT(RPC_INTERFACE);
  938. NEW_SDICT(RPC_ADDRESS);
  939. class RPC_AUTHENTICATION
  940. {
  941. public:
  942. RPC_CHAR __RPC_FAR * ServerPrincipalName;
  943. unsigned long AuthenticationService;
  944. RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFunction;
  945. void __RPC_FAR * Argument;
  946. };
  947. NEW_SDICT(RPC_AUTHENTICATION);
  948. class TIMER
  949. {
  950. private:
  951. HANDLE hThread;
  952. public:
  953. TIMER(RPC_STATUS *Status, int fManualReset)
  954. {
  955. hThread = 0;
  956. *Status = RPC_S_OK;
  957. ASSERT(fManualReset == 0);
  958. }
  959. BOOL Wait(
  960. IN DWORD Milliseconds
  961. )
  962. {
  963. NTSTATUS NtStatus;
  964. LARGE_INTEGER Timeout;
  965. Timeout.QuadPart = Int32x32To64(Milliseconds, -10000);
  966. rewait:
  967. {
  968. NtStatus = NtDelayExecution(TRUE, &Timeout);
  969. if (NtStatus == STATUS_USER_APC)
  970. goto rewait;
  971. }
  972. if (NtStatus == STATUS_ALERTED)
  973. {
  974. return 0;
  975. }
  976. return 1;
  977. }
  978. void Raise()
  979. {
  980. NTSTATUS NtStatus;
  981. ASSERT(hThread);
  982. NtStatus = NtAlertThread(hThread);
  983. ASSERT(NT_SUCCESS(NtStatus));
  984. }
  985. void SetThread(THREAD *pThread)
  986. {
  987. hThread = pThread->ThreadHandle();
  988. ASSERT(hThread);
  989. }
  990. };
  991. typedef enum CachedThreadWorkAvailableTag
  992. {
  993. WorkIsNotAvailable = 0,
  994. WorkIsAvailable
  995. } CachedThreadWorkAvailable;
  996. class CACHED_THREAD
  997. /*++
  998. Class Description:
  999. This class is used to implement a thread cache. Each thread which
  1000. has been cached is represented by an object of this class. All of the
  1001. fields of this class are protected by the server mutex of the owning
  1002. rpc server.
  1003. Fields:
  1004. Next - Forward link pointer of cached thread list.
  1005. Previous - Backward link pointer of cached thread list.
  1006. Procedure - The procedure which the thread should execute will be
  1007. placed here before the event gets kicked.
  1008. Parameter - The parameter which the thread should pass to the procedure
  1009. will be placed here.
  1010. OwningRpcServer - Contains a pointer to the rpc server which owns this
  1011. cached thread. This is necessary so that we can put this cached
  1012. thread into the cache.
  1013. WaitForWorkEvent - Contains the event which this cached thread will
  1014. wait on for more work to do.
  1015. WorkAvailableFlag - A non-zero value of this flag indicates that there
  1016. is work available for this thread. This is necessary to close a
  1017. race condition between the thread timing out waiting for work, and
  1018. the server requesting this thread to do work.
  1019. --*/
  1020. {
  1021. friend class RPC_SERVER;
  1022. friend void
  1023. BaseCachedThreadRoutine (
  1024. IN CACHED_THREAD * CachedThread
  1025. );
  1026. private:
  1027. CACHED_THREAD * Next;
  1028. CACHED_THREAD * Previous;
  1029. THREAD_PROC Procedure;
  1030. PVOID Parameter;
  1031. RPC_SERVER * OwningRpcServer;
  1032. CachedThreadWorkAvailable WorkAvailableFlag;
  1033. TIMER WaitForWorkEvent;
  1034. public:
  1035. CACHED_THREAD (
  1036. IN THREAD_PROC Procedure,
  1037. IN void * Parameter,
  1038. IN RPC_SERVER * RpcServer,
  1039. IN RPC_STATUS * RpcStatus
  1040. ) : WaitForWorkEvent(RpcStatus, 0),
  1041. Procedure(Procedure),
  1042. Parameter(Parameter),
  1043. OwningRpcServer(RpcServer),
  1044. WorkAvailableFlag(WorkIsNotAvailable),
  1045. Next(0),
  1046. Previous(0)
  1047. {
  1048. }
  1049. BOOL
  1050. CallProcedure (
  1051. )
  1052. {
  1053. // by convention, IOCP worker threads will return non-zero,
  1054. // while LRPC worker threads will return 0.
  1055. return((*Procedure)(Parameter));
  1056. }
  1057. void SetThread(THREAD *p)
  1058. {
  1059. WaitForWorkEvent.SetThread(p);
  1060. }
  1061. void SetWakeUpThreadParams(THREAD_PROC Procedure, PVOID Parameter)
  1062. {
  1063. this->Procedure = Procedure;
  1064. this->Parameter = Parameter;
  1065. WorkAvailableFlag = WorkIsAvailable;
  1066. }
  1067. void WakeUpThread(void)
  1068. {
  1069. WaitForWorkEvent.Raise();
  1070. }
  1071. inline void *GetParameter(void)
  1072. {
  1073. return Parameter;
  1074. }
  1075. };
  1076. typedef (*NS_EXPORT_FUNC) (
  1077. IN unsigned long EntryNameSyntax,
  1078. IN RPC_CHAR *EntryName,
  1079. IN RPC_IF_HANDLE RpcInterfaceInformation,
  1080. IN RPC_BINDING_VECTOR * BindingVector,
  1081. IN UUID_VECTOR *UuidVector
  1082. );
  1083. typedef (*NS_UNEXPORT_FUNC) (
  1084. IN unsigned long EntryNameSyntax,
  1085. IN RPC_CHAR *EntryName,
  1086. IN RPC_IF_HANDLE RpcInterfaceInformation,
  1087. IN UUID_VECTOR *UuidVector
  1088. );
  1089. class RPC_SERVER
  1090. /*++
  1091. Class Description:
  1092. This class represents an RPC server. Interfaces and addresses get
  1093. hung from an rpc server object.
  1094. Fields:
  1095. RpcInterfaceDictionary - Contains a dictionary of rpc interfaces
  1096. which have been registered with this server.
  1097. ServerMutex - Contains a mutex used to serialize access to this
  1098. data structure.
  1099. AvailableCallCount - Contains a count of the number of available calls
  1100. on all rpc interfaces owned by this server.
  1101. ServerListeningFlag - Contains an indication of whether or not
  1102. this rpc server is listening for remote procedure calls. If
  1103. this flag is zero, the server is not listening; otherwise, if
  1104. the flag is non-zero, the server is listening.
  1105. RpcAddressDictionary - Contains a dictionary of rpc addresses which
  1106. have been registered with this server.
  1107. ListeningThreadFlag - Contains a flag which indicates whether or
  1108. not there is a thread in the ServerListen method. The
  1109. ServerListeningFlag can not be used because it will be zero
  1110. will the listening thread is waiting for all active calls to
  1111. complete.
  1112. StopListeningEvent - Contains an event which the thread which called
  1113. ServerListen will wait on. When StopServerListening is called,
  1114. this event will get kicked. If a non-recoverable error occurs,
  1115. the event will also get kicked.
  1116. ListenStatusCode - Contains the status code which ServerListen will
  1117. return.
  1118. MaximumConcurrentCalls - Contains the maximum number of concurrent
  1119. remote procedure calls allowed for this rpc server.
  1120. MinimumCallThreads - Contains the minimum number of call threads
  1121. which should be available to service remote procedure calls on
  1122. each protocol sequence.
  1123. IncomingRpcCount - This field keeps track of the number of incoming
  1124. remote procedure calls (or callbacks) which this server has
  1125. received.
  1126. OutgoingRpcCount - This field keeps track of the number of outgoing
  1127. remote procedure callbacks initiated by this server.
  1128. ReceivedPacketCount - Contains the number of network packets received
  1129. by this server.
  1130. SentPacketCount - Contains the number of network packets sent by this
  1131. server.
  1132. AuthenticationDictionary - Contains the set of authentication services
  1133. supported by this server.
  1134. WaitingThreadFlag - Contains a flag indicating whether or not there
  1135. is a thread waiting for StopServerListening to be called and then
  1136. for all calls to complete.
  1137. ThreadCache - This field points to the top of the stack of CACHED_THREAD
  1138. objects which forms the thread cache. This field is protected by the
  1139. thread cache mutex rather than the server mutex.
  1140. ThreadCacheMutex - This field is used to serialize access to the thread
  1141. cache. We need to do this to prevent deadlocks between the server
  1142. mutex and an address mutex.
  1143. pEpmapperForwardFunction - Function to determine if and where a
  1144. packet is to be forwarded to.
  1145. --*/
  1146. {
  1147. friend void
  1148. BaseCachedThreadRoutine (
  1149. IN CACHED_THREAD * CachedThread
  1150. );
  1151. public:
  1152. // accessed by all threads independently - put in separate cache line
  1153. MUTEX ServerMutex;
  1154. private:
  1155. #if !defined(NO_LOCATOR_CODE)
  1156. NS_EXPORT_FUNC pNsBindingExport;
  1157. #endif
  1158. RPC_STATUS ListenStatusCode;
  1159. unsigned int ListeningThreadFlag;
  1160. public:
  1161. unsigned int MinimumCallThreads;
  1162. private:
  1163. unsigned int WaitingThreadFlag;
  1164. unsigned long OutgoingRpcCount;
  1165. long padding0;
  1166. // accessed by all threads independently - put in separate cache line
  1167. unsigned long IncomingRpcCount;
  1168. RPC_ADDRESS_DICT RpcAddressDictionary;
  1169. // accessed by all threads independently - put in separate cache line
  1170. INTERLOCKED_INTEGER AvailableCallCount;
  1171. QUEUE RpcDormantAddresses;
  1172. // accessed by all threads independently - put in separate cache line
  1173. unsigned long SentPacketCount;
  1174. CACHED_THREAD *ThreadCache;
  1175. MUTEX ThreadCacheMutex;
  1176. // accessed by all threads independently - put in separate cache line
  1177. unsigned int MaximumConcurrentCalls;
  1178. EVENT StopListeningEvent;
  1179. INTERLOCKED_INTEGER NumAutoListenInterfaces ;
  1180. #if !defined(NO_LOCATOR_CODE)
  1181. NS_UNEXPORT_FUNC pNsBindingUnexport;
  1182. #endif
  1183. long padding1[4];
  1184. // accessed by all threads independently - put in separate cache line
  1185. RPC_INTERFACE_DICT RpcInterfaceDictionary;
  1186. public:
  1187. // accessed by all threads independently - put in separate cache line
  1188. unsigned int ServerListeningFlag;
  1189. BOOL fAccountForMaxCalls;
  1190. long padding2[6];
  1191. // accessed by all threads independently - put in separate cache line
  1192. unsigned long ReceivedPacketCount;
  1193. public:
  1194. RPC_FORWARD_FUNCTION * pRpcForwardFunction;
  1195. private:
  1196. long padding3[6];
  1197. // accessed by all threads independently - put in separate cache line
  1198. RPC_AUTHENTICATION_DICT AuthenticationDictionary;
  1199. public:
  1200. RPC_SERVER (
  1201. IN OUT RPC_STATUS PAPI * RpcStatus
  1202. );
  1203. RPC_INTERFACE *
  1204. FindInterface (
  1205. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation
  1206. );
  1207. int
  1208. AddInterface (
  1209. IN RPC_INTERFACE * RpcInterface
  1210. );
  1211. unsigned int
  1212. IsServerListening (
  1213. );
  1214. long InqNumAutoListenInterfaces (
  1215. ) ;
  1216. unsigned int
  1217. CallBeginning (
  1218. );
  1219. void
  1220. CallEnding (
  1221. );
  1222. RPC_STATUS
  1223. FindInterfaceTransfer (
  1224. IN PRPC_SYNTAX_IDENTIFIER InterfaceIdentifier,
  1225. IN PRPC_SYNTAX_IDENTIFIER ProposedTransferSyntaxes,
  1226. IN unsigned int NumberOfTransferSyntaxes,
  1227. OUT PRPC_SYNTAX_IDENTIFIER AcceptedTransferSyntax,
  1228. OUT RPC_INTERFACE ** RpcInterface,
  1229. OUT BOOL *fInterfaceTransferIsPreferred,
  1230. OUT int *ProposedTransferSyntaxIndex,
  1231. OUT int *AvailableTransferSyntaxIndex
  1232. );
  1233. RPC_INTERFACE *
  1234. FindInterface (
  1235. IN PRPC_SYNTAX_IDENTIFIER InterfaceIdentifier
  1236. );
  1237. RPC_STATUS
  1238. ServerListen (
  1239. IN unsigned int MinimumCallThreads,
  1240. IN unsigned int MaximumConcurrentCalls,
  1241. IN unsigned int DontWait
  1242. );
  1243. RPC_STATUS
  1244. WaitForStopServerListening (
  1245. );
  1246. RPC_STATUS
  1247. WaitServerListen (
  1248. );
  1249. void
  1250. InquireStatistics (
  1251. OUT RPC_STATS_VECTOR * Statistics
  1252. );
  1253. RPC_STATUS
  1254. StopServerListening (
  1255. );
  1256. RPC_STATUS
  1257. UseRpcProtocolSequence (
  1258. IN RPC_CHAR PAPI * NetworkAddress,
  1259. IN RPC_CHAR PAPI * RpcProtocolSequence,
  1260. IN unsigned int PendingQueueSize,
  1261. IN RPC_CHAR PAPI *Endpoint,
  1262. IN void PAPI * SecurityDescriptor,
  1263. IN unsigned long EndpointFlags,
  1264. IN unsigned long NICFlags
  1265. );
  1266. RPC_STATUS
  1267. UnregisterEndpoint (
  1268. IN RPC_CHAR __RPC_FAR * RpcProtocolSequence,
  1269. IN RPC_CHAR __RPC_FAR * Endpoint
  1270. );
  1271. int
  1272. AddAddress (
  1273. IN RPC_ADDRESS * RpcAddress
  1274. );
  1275. RPC_STATUS
  1276. UnregisterIf (
  1277. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1278. IN RPC_UUID PAPI * ManagerTypeUuid OPTIONAL,
  1279. IN unsigned int WaitForCallsToComplete
  1280. );
  1281. RPC_STATUS
  1282. InquireManagerEpv (
  1283. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1284. IN RPC_UUID PAPI * ManagerTypeUuid, OPTIONAL
  1285. OUT RPC_MGR_EPV PAPI * PAPI * ManagerEpv
  1286. );
  1287. RPC_STATUS
  1288. InquireBindings (
  1289. OUT RPC_BINDING_VECTOR PAPI * PAPI * BindingVector
  1290. );
  1291. RPC_STATUS
  1292. AutoRegisterAuthSvc(
  1293. IN RPC_CHAR * ServerPrincipalName,
  1294. IN unsigned long AuthenticationService
  1295. );
  1296. RPC_STATUS
  1297. RegisterAuthInfoHelper (
  1298. IN RPC_CHAR PAPI * ServerPrincipalName,
  1299. IN unsigned long AuthenticationService,
  1300. IN RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFunction, OPTIONAL
  1301. IN void PAPI * Argument OPTIONAL
  1302. );
  1303. RPC_STATUS
  1304. RegisterAuthInformation (
  1305. IN RPC_CHAR PAPI * ServerPrincipalName,
  1306. IN unsigned long AuthenticationService,
  1307. IN RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFunction, OPTIONAL
  1308. IN void PAPI * Argument OPTIONAL
  1309. );
  1310. RPC_STATUS
  1311. AcquireCredentials (
  1312. IN unsigned long AuthenticationService,
  1313. IN unsigned long AuthenticationLevel,
  1314. OUT SECURITY_CREDENTIALS ** SecurityCredentials
  1315. );
  1316. void
  1317. FreeCredentials (
  1318. IN SECURITY_CREDENTIALS * SecurityCredentials
  1319. );
  1320. RPC_STATUS
  1321. RegisterInterface (
  1322. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1323. IN RPC_UUID PAPI * ManagerTypeUuid,
  1324. IN RPC_MGR_EPV PAPI * ManagerEpv,
  1325. IN unsigned int Flags,
  1326. IN unsigned int MaxCalls,
  1327. IN unsigned int MaxRpcSize,
  1328. IN RPC_IF_CALLBACK_FN PAPI *IfCallbackFn
  1329. );
  1330. void IncomingCall(void);
  1331. void OutgoingCallback(void);
  1332. void PacketReceived(void);
  1333. void PacketSent(void);
  1334. RPC_STATUS
  1335. CreateThread (
  1336. IN THREAD_PROC Procedure,
  1337. IN void * Parameter);
  1338. RPC_STATUS
  1339. InquireInterfaceIds (
  1340. OUT RPC_IF_ID_VECTOR __RPC_FAR * __RPC_FAR * InterfaceIdVector
  1341. );
  1342. RPC_STATUS
  1343. InquirePrincipalName (
  1344. IN unsigned long AuthenticationService,
  1345. OUT RPC_CHAR __RPC_FAR * __RPC_FAR * ServerPrincipalName
  1346. );
  1347. void
  1348. RegisterRpcForwardFunction(
  1349. RPC_FORWARD_FUNCTION * pForwardFunction
  1350. );
  1351. void
  1352. IncrementAutoListenInterfaceCount (
  1353. ) ;
  1354. void
  1355. DecrementAutoListenInterfaceCount (
  1356. ) ;
  1357. void
  1358. InsertIntoFreeList(
  1359. CACHED_THREAD *CachedThread
  1360. );
  1361. void
  1362. RemoveFromFreeList(
  1363. CACHED_THREAD *CachedThread
  1364. );
  1365. CACHED_THREAD *RemoveHeadFromFreeList(void);
  1366. void CreateOrUpdateAddresses (void);
  1367. RPC_INTERFACE *
  1368. FindOrCreateInterface (
  1369. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1370. OUT RPC_STATUS *Status
  1371. );
  1372. RPC_STATUS
  1373. InterfaceExported (
  1374. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1375. IN UUID_VECTOR *MyObjectUuidVector,
  1376. IN unsigned char *MyAnnotation,
  1377. IN BOOL MyfReplace
  1378. );
  1379. #if !defined(NO_LOCATOR_CODE)
  1380. RPC_STATUS
  1381. NsInterfaceExported (
  1382. IN unsigned long EntryNameSyntax,
  1383. IN RPC_CHAR *EntryName,
  1384. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1385. IN BOOL fUnexport
  1386. );
  1387. RPC_STATUS
  1388. NsBindingUnexport (
  1389. IN unsigned long EntryNameSyntax,
  1390. IN RPC_CHAR *EntryName,
  1391. IN RPC_IF_HANDLE IfSpec
  1392. );
  1393. RPC_STATUS
  1394. NsBindingExport(
  1395. IN unsigned long EntryNameSyntax,
  1396. IN RPC_CHAR *EntryName,
  1397. IN RPC_IF_HANDLE IfSpec,
  1398. IN RPC_BINDING_VECTOR *BindingVector
  1399. );
  1400. #endif
  1401. typedef enum
  1402. {
  1403. actDestroyContextHandle = 0,
  1404. actCleanupIdleSContext
  1405. } AddressCallbackType;
  1406. RPC_STATUS
  1407. EnumerateAndCallEachAddress (
  1408. IN AddressCallbackType actType,
  1409. IN OUT void *Context OPTIONAL
  1410. );
  1411. private:
  1412. RPC_INTERFACE *
  1413. RPC_SERVER::FindOrCreateInterfaceInternal (
  1414. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1415. IN unsigned int Flags,
  1416. IN unsigned int MaxCalls,
  1417. IN unsigned int MaxRpcSize,
  1418. IN RPC_IF_CALLBACK_FN PAPI *IfCallbackFn,
  1419. OUT RPC_STATUS *Status,
  1420. OUT BOOL *fInterfaceFound
  1421. );
  1422. };
  1423. #if !defined(NO_LOCATOR_CODE)
  1424. inline RPC_STATUS
  1425. RPC_SERVER::NsBindingUnexport (
  1426. IN unsigned long EntryNameSyntax,
  1427. IN RPC_CHAR *EntryName,
  1428. IN RPC_IF_HANDLE IfSpec
  1429. )
  1430. {
  1431. return (*pNsBindingUnexport)
  1432. (EntryNameSyntax, EntryName, IfSpec, NULL);
  1433. }
  1434. inline RPC_STATUS
  1435. RPC_SERVER::NsBindingExport (
  1436. IN unsigned long EntryNameSyntax,
  1437. IN RPC_CHAR *EntryName,
  1438. IN RPC_IF_HANDLE IfSpec,
  1439. IN RPC_BINDING_VECTOR *BindingVector
  1440. )
  1441. {
  1442. return (*pNsBindingExport)
  1443. (EntryNameSyntax, EntryName, IfSpec, BindingVector, NULL);
  1444. }
  1445. #endif
  1446. inline void
  1447. RPC_SERVER::IncrementAutoListenInterfaceCount (
  1448. )
  1449. {
  1450. NumAutoListenInterfaces.Increment() ;
  1451. }
  1452. inline void
  1453. RPC_SERVER::DecrementAutoListenInterfaceCount (
  1454. )
  1455. {
  1456. NumAutoListenInterfaces.Decrement() ;
  1457. }
  1458. inline long
  1459. RPC_SERVER::InqNumAutoListenInterfaces (
  1460. )
  1461. {
  1462. return (NumAutoListenInterfaces.GetInteger()) ;
  1463. }
  1464. inline unsigned int
  1465. RPC_SERVER::IsServerListening (
  1466. )
  1467. /*++
  1468. Routine Description:
  1469. This method returns an indication of whether or not this rpc server
  1470. is listening for remote procedure calls.
  1471. Return Value:
  1472. Zero will be returned if this rpc server is not listening for
  1473. remote procedure calls; otherwise, non-zero will be returned.
  1474. --*/
  1475. {
  1476. return(ServerListeningFlag);
  1477. }
  1478. inline unsigned int
  1479. RPC_SERVER::CallBeginning (
  1480. )
  1481. /*++
  1482. Routine Description:
  1483. Before dispatching a new remote procedure call to a stub, this method
  1484. will get called. It checks to see if this call will cause there to
  1485. be too many concurrent remote procedure calls. If the call is allowed
  1486. the call count is updated so we can tell when all calls have
  1487. completed.
  1488. Zero will be returned if another concurrent remote procedure call
  1489. is not allowed; otherwise, non-zero will be returned.
  1490. --*/
  1491. {
  1492. if (AvailableCallCount.Decrement() >= 0)
  1493. return TRUE;
  1494. else
  1495. {
  1496. AvailableCallCount.Increment();
  1497. return FALSE;
  1498. }
  1499. }
  1500. inline void
  1501. RPC_SERVER::CallEnding (
  1502. )
  1503. /*++
  1504. Routine Description:
  1505. This method is the mirror image of RPC_SERVER::CallBeginning; it
  1506. is used to notify this rpc server that a call using an rpc
  1507. interface owned by this rpc server is ending.
  1508. --*/
  1509. {
  1510. long Temp;
  1511. Temp = AvailableCallCount.Increment();
  1512. ASSERT(Temp <= (long)MaximumConcurrentCalls);
  1513. }
  1514. inline void RPC_SERVER::IncomingCall (void)
  1515. /*++
  1516. Routine Description:
  1517. RPC_INTERFACE::DispatchToStub calls this method so that the server
  1518. can keep track of the number of incoming remote procedure calls (and
  1519. callbacks).
  1520. --*/
  1521. {
  1522. IncomingRpcCount += 1;
  1523. }
  1524. inline void RPC_SERVER::OutgoingCallback (void)
  1525. /*++
  1526. Routine Description:
  1527. Each protocol module must call this method when it sends a callback
  1528. from the server to the client; we need to do this so that the server
  1529. can keep track of the number of outgoing remote procedure callbacks.
  1530. --*/
  1531. {
  1532. OutgoingRpcCount += 1;
  1533. }
  1534. inline void RPC_SERVER::PacketReceived (void)
  1535. /*++
  1536. Routine Description:
  1537. In order for the server to keep track of the number of incoming
  1538. packets, each protocol module must call this method each time a
  1539. packet is received from the network.
  1540. --*/
  1541. {
  1542. ReceivedPacketCount += 1;
  1543. }
  1544. inline void RPC_SERVER::PacketSent (void)
  1545. /*++
  1546. Routine Description:
  1547. This method is the same as RPC_SERVER::PacketReceived, except that
  1548. it should be called for each packet sent rather than received.
  1549. --*/
  1550. {
  1551. SentPacketCount += 1;
  1552. }
  1553. inline CACHED_THREAD *RPC_SERVER::RemoveHeadFromFreeList(void)
  1554. /*++
  1555. Routine Description:
  1556. Removes a cached thread object for the ThreadCache list.
  1557. Note: ThreadCachedMutex() should be held when called.
  1558. --*/
  1559. {
  1560. CACHED_THREAD *pFirst = ThreadCache;
  1561. #if DBG
  1562. ThreadCacheMutex.VerifyOwned();
  1563. #endif
  1564. if (pFirst)
  1565. {
  1566. ThreadCache = pFirst->Next;
  1567. if (ThreadCache)
  1568. ThreadCache->Previous = NULL;
  1569. }
  1570. return pFirst;
  1571. }
  1572. inline void
  1573. RPC_SERVER::RemoveFromFreeList(
  1574. IN CACHED_THREAD *CachedThread)
  1575. /*++
  1576. Routine Description:
  1577. Removes a cached thread object for the ThreadCache list.
  1578. Note: ThreadCachedMutex() should be held when called.
  1579. --*/
  1580. {
  1581. if (CachedThread->Previous)
  1582. {
  1583. ASSERT(CachedThread->Previous->Next == CachedThread);
  1584. CachedThread->Previous->Next = CachedThread->Next;
  1585. }
  1586. if (CachedThread->Next)
  1587. {
  1588. ASSERT(CachedThread->Next->Previous == CachedThread);
  1589. CachedThread->Next->Previous = CachedThread->Previous;
  1590. }
  1591. if (ThreadCache == CachedThread)
  1592. {
  1593. ASSERT(CachedThread->Previous == NULL);
  1594. ASSERT( (CachedThread->Next == 0)
  1595. || (CachedThread->Next->Previous == NULL));
  1596. ThreadCache = CachedThread->Next;
  1597. }
  1598. }
  1599. inline void
  1600. RPC_SERVER::InsertIntoFreeList(
  1601. IN CACHED_THREAD *CachedThread
  1602. )
  1603. /*++
  1604. Routine Description:
  1605. Inserts a cached thread object into ThreadCache list.
  1606. Note: ThreadCachedMutex() should be held when called.
  1607. --*/
  1608. {
  1609. CachedThread->Next = ThreadCache;
  1610. if (ThreadCache)
  1611. {
  1612. ASSERT(ThreadCache->Previous == 0);
  1613. ThreadCache->Previous = CachedThread;
  1614. }
  1615. CachedThread->Previous = 0;
  1616. ThreadCache = CachedThread;
  1617. }
  1618. NEW_SDICT(ServerContextHandle);
  1619. class NO_VTABLE SCALL : public CALL
  1620. /*++
  1621. Class Description:
  1622. --*/
  1623. {
  1624. public:
  1625. inline
  1626. SCALL (
  1627. IN CLIENT_AUTH_INFO * myAuthInfo,
  1628. OUT RPC_STATUS * pStatus
  1629. )
  1630. {
  1631. }
  1632. inline SCALL (
  1633. void
  1634. )
  1635. {
  1636. }
  1637. inline
  1638. ~SCALL (
  1639. )
  1640. {
  1641. }
  1642. virtual RPC_STATUS
  1643. NegotiateTransferSyntax (
  1644. IN OUT PRPC_MESSAGE Message
  1645. )
  1646. {
  1647. // we shouldn't be here at all
  1648. ASSERT(!"Negotiating a transfer syntax is not supported on the server side");
  1649. return RPC_S_CANNOT_SUPPORT;
  1650. }
  1651. inline RPC_STATUS
  1652. AddToActiveContextHandles (
  1653. ServerContextHandle *ContextHandle
  1654. )
  1655. /*++
  1656. Routine Description:
  1657. Adds a context handle to the dictionary of active context handles
  1658. for this call.
  1659. Arguments:
  1660. ContextHandle - the context handle to add to the dictionary
  1661. Return Value:
  1662. RPC_S_OK for success or RPC_S_OUT_OF_MEMORY
  1663. --*/
  1664. {
  1665. int Key;
  1666. Key = ActiveContextHandles.Insert(ContextHandle);
  1667. if (Key == -1)
  1668. return RPC_S_OUT_OF_MEMORY;
  1669. else
  1670. return RPC_S_OK;
  1671. }
  1672. inline ServerContextHandle *
  1673. RemoveFromActiveContextHandles (
  1674. ServerContextHandle *ContextHandle
  1675. )
  1676. /*++
  1677. Routine Description:
  1678. Removes a context handle from the active context handle
  1679. dictionary. If the context handle is not there, this is
  1680. just a no-op
  1681. Arguments:
  1682. ContextHandle - the context handle to remove from the dictionary
  1683. Return Value:
  1684. NULL if the context handle is not found. The context handle if it
  1685. is found
  1686. --*/
  1687. {
  1688. return (ServerContextHandle *)ActiveContextHandles.DeleteItemByBruteForce(ContextHandle);
  1689. }
  1690. void
  1691. DoPreDispatchProcessing (
  1692. IN PRPC_MESSAGE Message,
  1693. IN BOOL CallbackFlag
  1694. ) ;
  1695. void
  1696. DoPostDispatchProcessing (
  1697. void
  1698. ) ;
  1699. virtual void
  1700. InquireObjectUuid (
  1701. OUT RPC_UUID PAPI * ObjectUuid
  1702. ) = 0;
  1703. virtual RPC_STATUS
  1704. InquireAuthClient (
  1705. OUT RPC_AUTHZ_HANDLE PAPI * Privileges,
  1706. OUT RPC_CHAR PAPI * PAPI * ServerPrincipalName, OPTIONAL
  1707. OUT unsigned long PAPI * AuthenticationLevel,
  1708. OUT unsigned long PAPI * AuthenticationService,
  1709. OUT unsigned long PAPI * AuthorizationService,
  1710. IN unsigned long Flags
  1711. ) = 0;
  1712. virtual RPC_STATUS
  1713. InquireCallAttributes (
  1714. IN OUT void *
  1715. )
  1716. {
  1717. return RPC_S_CANNOT_SUPPORT;
  1718. }
  1719. virtual RPC_STATUS // Value to be returned by RpcImpersonateClient.
  1720. ImpersonateClient ( // Impersonate the client represented (at the other
  1721. );// end of) by this connection.
  1722. virtual RPC_STATUS // Value to be returned by RpcRevertToSelf.
  1723. RevertToSelf ( // Stop impersonating a client, if the server thread
  1724. );// is impersonating a client.
  1725. virtual RPC_STATUS
  1726. GetAssociationContextCollection (
  1727. OUT ContextCollection **CtxCollection
  1728. ) = 0;
  1729. virtual RPC_STATUS
  1730. ToStringBinding (
  1731. OUT RPC_CHAR PAPI * PAPI * StringBinding
  1732. ) = 0;
  1733. virtual RPC_STATUS
  1734. IsClientLocal (
  1735. OUT unsigned int PAPI * ClientLocalFlag
  1736. ) = 0;
  1737. virtual RPC_STATUS
  1738. ConvertToServerBinding (
  1739. OUT RPC_BINDING_HANDLE __RPC_FAR * ServerBinding
  1740. ) = 0;
  1741. virtual RPC_STATUS
  1742. InqTransportType (
  1743. OUT unsigned int __RPC_FAR * Type
  1744. ) = 0;
  1745. virtual RPC_STATUS
  1746. InqConnection (
  1747. OUT void **ConnId,
  1748. OUT BOOL *pfFirstCall
  1749. ) = 0;
  1750. #if DBG
  1751. virtual void
  1752. InterfaceForCallDoesNotUseStrict (
  1753. void
  1754. )
  1755. {
  1756. }
  1757. #endif
  1758. virtual RPC_STATUS
  1759. GetAuthorizationContext (
  1760. IN BOOL ImpersonateOnReturn,
  1761. IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager,
  1762. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1763. IN LUID Identifier,
  1764. IN DWORD Flags,
  1765. IN PVOID DynamicGroupArgs OPTIONAL,
  1766. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext
  1767. )
  1768. {
  1769. // we shouldn't be here at all
  1770. ASSERT(!"Get authz context should have landed in a derived class method");
  1771. return RPC_S_CANNOT_SUPPORT;
  1772. }
  1773. protected:
  1774. static RPC_STATUS
  1775. CreateAndSaveAuthzContextFromToken (
  1776. IN OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContextPlaceholder OPTIONAL,
  1777. IN HANDLE ImpersonationToken,
  1778. IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager,
  1779. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1780. IN LUID Identifier,
  1781. IN DWORD Flags,
  1782. IN PVOID DynamicGroupArgs OPTIONAL,
  1783. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext
  1784. );
  1785. static RPC_STATUS
  1786. DuplicateAuthzContext (
  1787. IN AUTHZ_CLIENT_CONTEXT_HANDLE AuthzClientContext,
  1788. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1789. IN LUID Identifier,
  1790. IN DWORD Flags,
  1791. IN PVOID DynamicGroupArgs OPTIONAL,
  1792. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext
  1793. );
  1794. void __RPC_FAR * DispatchBuffer ;
  1795. public:
  1796. static const int DictionaryEntryIsBuffer = 1;
  1797. ServerContextHandle_DICT ActiveContextHandles;
  1798. };
  1799. inline void
  1800. SCALL::DoPreDispatchProcessing (
  1801. IN PRPC_MESSAGE Message,
  1802. IN BOOL CallbackFlag
  1803. )
  1804. {
  1805. if (CallbackFlag == 0)
  1806. {
  1807. ASSERT(ActiveContextHandles.Size() == 0);
  1808. }
  1809. DispatchBuffer = Message->Buffer ;
  1810. }
  1811. class NO_VTABLE SCONNECTION : public REFERENCED_OBJECT
  1812. /*++
  1813. Class Description:
  1814. This class represents a call on the server side. The name of the
  1815. class, SCONNECTION, is slightly misleading; this is a historical
  1816. artifact due to the connection oriented protocol module being
  1817. implemented first. We add some more methods to this class to
  1818. be implemented by each protocol module.
  1819. --*/
  1820. {
  1821. public:
  1822. inline
  1823. SCONNECTION(
  1824. )
  1825. {
  1826. }
  1827. inline
  1828. ~SCONNECTION(
  1829. )
  1830. {
  1831. }
  1832. virtual RPC_STATUS
  1833. IsClientLocal (
  1834. OUT unsigned int PAPI * ClientLocalFlag
  1835. );
  1836. virtual RPC_STATUS
  1837. InqTransportType(
  1838. OUT unsigned int __RPC_FAR * Type
  1839. ) = 0;
  1840. };
  1841. /* ====================================================================
  1842. ASSOCIATION_HANDLE :
  1843. An association represents a client. We need to take care of the
  1844. rundown routines here as well as the association context and
  1845. association id. This is all independent of RPC protocol and
  1846. transport (well except for datagrams).
  1847. ====================================================================
  1848. */
  1849. class NO_VTABLE ASSOCIATION_HANDLE : public REFERENCED_OBJECT
  1850. {
  1851. protected:
  1852. unsigned long AssociationID;
  1853. ASSOCIATION_HANDLE ( // Constructor.
  1854. void
  1855. );
  1856. public:
  1857. ContextCollection *CtxCollection;
  1858. virtual ~ASSOCIATION_HANDLE ( // Destructor.
  1859. );
  1860. // Returns the context handle collection for this association.
  1861. RPC_STATUS
  1862. GetAssociationContextCollection (
  1863. ContextCollection **CtxCollectionPlaceholder
  1864. ) ;
  1865. void
  1866. FireRundown (
  1867. void
  1868. );
  1869. virtual RPC_STATUS
  1870. CreateThread (
  1871. void
  1872. );
  1873. virtual void
  1874. RundownNotificationCompleted(
  1875. void
  1876. );
  1877. void
  1878. DestroyContextHandlesForInterface (
  1879. IN RPC_SERVER_INTERFACE PAPI * RpcInterfaceInformation,
  1880. IN BOOL RundownContextHandles
  1881. );
  1882. };
  1883. extern int
  1884. InitializeServerDLL ( // This routine will be called at DLL load time.
  1885. );
  1886. extern int
  1887. InitializeSTransports ( // This routine is defined in transvr.cxx.
  1888. );
  1889. extern int
  1890. InitializeRpcServer (
  1891. );
  1892. extern void PAPI *
  1893. OsfServerMapRpcProtocolSequence (
  1894. IN RPC_CHAR * RpcProtocolSequence,
  1895. OUT RPC_STATUS PAPI * Status
  1896. );
  1897. extern int
  1898. InitializeRpcProtocolLrpc (
  1899. ) ;
  1900. extern RPC_ADDRESS *
  1901. LrpcCreateRpcAddress (
  1902. ) ;
  1903. extern RPC_ADDRESS *
  1904. OsfCreateRpcAddress (
  1905. IN TRANS_INFO PAPI * TransportInfo
  1906. );
  1907. extern RPC_ADDRESS *
  1908. DgCreateRpcAddress (
  1909. IN TRANS_INFO PAPI * TransportInfo
  1910. );
  1911. RPC_STATUS
  1912. SetThreadSecurityContext(
  1913. SECURITY_CONTEXT * Context
  1914. );
  1915. SECURITY_CONTEXT *
  1916. QueryThreadSecurityContext(
  1917. );
  1918. SECURITY_CONTEXT *
  1919. ClearThreadSecurityContext(
  1920. );
  1921. typedef AUTHZAPI
  1922. BOOL
  1923. (WINAPI *AuthzInitializeContextFromTokenFnType)(
  1924. IN DWORD Flags,
  1925. IN HANDLE TokenHandle,
  1926. IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager,
  1927. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1928. IN LUID Identifier,
  1929. IN PVOID DynamicGroupArgs OPTIONAL,
  1930. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE pAuthzClientContext
  1931. );
  1932. typedef AUTHZAPI
  1933. BOOL
  1934. (WINAPI *AuthzInitializeContextFromSidFnType)(
  1935. IN DWORD Flags,
  1936. IN PSID UserSid,
  1937. IN AUTHZ_RESOURCE_MANAGER_HANDLE hAuthzResourceManager,
  1938. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1939. IN LUID Identifier,
  1940. IN PVOID DynamicGroupArgs OPTIONAL,
  1941. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE phAuthzClientContext
  1942. );
  1943. typedef AUTHZAPI
  1944. BOOL
  1945. (WINAPI *AuthzInitializeContextFromAuthzContextFnType)(
  1946. IN DWORD Flags OPTIONAL,
  1947. IN AUTHZ_CLIENT_CONTEXT_HANDLE hAuthzClientContext,
  1948. IN PLARGE_INTEGER pExpirationTime OPTIONAL,
  1949. IN LUID Identifier OPTIONAL,
  1950. IN PVOID DynamicGroupArgs OPTIONAL,
  1951. OUT PAUTHZ_CLIENT_CONTEXT_HANDLE phNewAuthzClientContext
  1952. );
  1953. typedef AUTHZAPI
  1954. BOOL
  1955. (WINAPI *AuthzFreeContextFnType)(
  1956. IN OUT AUTHZ_CLIENT_CONTEXT_HANDLE AuthzClientContext
  1957. );
  1958. extern AuthzInitializeContextFromTokenFnType AuthzInitializeContextFromTokenFn;
  1959. extern AuthzInitializeContextFromSidFnType AuthzInitializeContextFromSidFn;
  1960. extern AuthzInitializeContextFromAuthzContextFnType AuthzInitializeContextFromAuthzContextFn;
  1961. extern AuthzFreeContextFnType AuthzFreeContextFn;
  1962. #define MO(_Message) ((MESSAGE_OBJECT *) _Message->Handle)
  1963. #define SCALL(_Message) ((SCALL *) _Message->Handle)
  1964. RPC_STATUS
  1965. InqLocalConnAddress (
  1966. IN SCALL *SCall,
  1967. IN OUT void *Buffer,
  1968. IN OUT unsigned long *BufferSize,
  1969. OUT unsigned long *AddressFormat
  1970. );
  1971. typedef struct tagDestroyContextHandleCallbackContext
  1972. {
  1973. RPC_SERVER_INTERFACE *RpcInterfaceInformation;
  1974. BOOL RundownContextHandles;
  1975. } DestroyContextHandleCallbackContext;
  1976. #endif // __HNDLSVR_HXX__