Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2163 lines
49 KiB

  1. /*++
  2. Copyright (c) 1995-2002 Microsoft Corporation
  3. Module Name:
  4. clusrtl.h
  5. Abstract:
  6. Header file for definitions and structures for the NT Cluster
  7. Run Time Library
  8. Author:
  9. John Vert (jvert) 30-Nov-1995
  10. Revision History:
  11. --*/
  12. #ifndef _CLUSRTL_INCLUDED_
  13. #define _CLUSRTL_INCLUDED_
  14. //
  15. // Service Message IDs
  16. //
  17. #pragma warning( push )
  18. #include "clusvmsg.h"
  19. #include "resapi.h"
  20. #include <aclapi.h>
  21. #include <netcon.h>
  22. #include <winioctl.h>
  23. #pragma warning( pop )
  24. #include "clstrcmp.h"
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. //
  29. // Routine Description:
  30. //
  31. // Initializes the cluster run time library.
  32. //
  33. // Arguments:
  34. //
  35. // DbgOutputToConsole - TRUE if the debug output should be written to a
  36. // console window
  37. //
  38. // DbgLogLevel - pointer to a DWORD that contains the current msg filter
  39. // level. checked by ClRtlDbgPrint.
  40. //
  41. // Return Value:
  42. //
  43. // ERROR_SUCCESS if the function succeeds.
  44. // A Win32 error code otherwise.
  45. //
  46. DWORD
  47. ClRtlInitialize(
  48. IN BOOL DbgOutputToConsole,
  49. IN PDWORD DbgLogLevel
  50. );
  51. //
  52. // Routine Description:
  53. //
  54. // Cleans up the cluster run time library.
  55. //
  56. // Arguments:
  57. //
  58. // None.
  59. //
  60. // Return Value:
  61. //
  62. // None.
  63. //
  64. VOID
  65. ClRtlCleanup(
  66. VOID
  67. );
  68. //
  69. // Routine Description:
  70. //
  71. // Checks to see if Services for MacIntosh is installed.
  72. //
  73. // Arguments:
  74. //
  75. // Pointer to boolean that tells if SFM is installed.
  76. //
  77. // Return Value:
  78. //
  79. // Status of request.
  80. //
  81. DWORD
  82. ClRtlIsServicesForMacintoshInstalled(
  83. OUT BOOL * pfInstalled
  84. );
  85. //////////////////////////////////////////////////////////////////////////
  86. //
  87. // Event logging interfaces
  88. //
  89. //
  90. // There are three currently defined logging levels:
  91. // LOG_CRITICAL - fatal error, chaos and destruction will ensue
  92. // LOG_UNUSUAL - unexpected event, but will be handled
  93. // LOG_NOISE - normal occurence
  94. //
  95. //////////////////////////////////////////////////////////////////////////
  96. #define LOG_CRITICAL 1
  97. #define LOG_UNUSUAL 2
  98. #define LOG_NOISE 3
  99. //
  100. // A few interfaces for reporting of errors.
  101. //
  102. VOID
  103. ClRtlEventLogInit(
  104. VOID
  105. );
  106. VOID
  107. ClRtlEventLogCleanup(
  108. VOID
  109. );
  110. VOID
  111. ClusterLogFatalError(
  112. IN ULONG LogModule,
  113. IN ULONG Line,
  114. IN LPSTR File,
  115. IN ULONG ErrCode
  116. );
  117. VOID
  118. ClusterLogNonFatalError(
  119. IN ULONG LogModule,
  120. IN ULONG Line,
  121. IN LPSTR File,
  122. IN ULONG ErrCode
  123. );
  124. VOID
  125. ClusterLogAssertionFailure(
  126. IN ULONG LogModule,
  127. IN ULONG Line,
  128. IN LPSTR File,
  129. IN LPSTR Expression
  130. );
  131. VOID
  132. ClusterLogEvent0(
  133. IN DWORD LogLevel,
  134. IN DWORD LogModule,
  135. IN LPSTR FileName,
  136. IN DWORD LineNumber,
  137. IN DWORD MessageId,
  138. IN DWORD dwByteCount,
  139. IN PVOID lpBytes
  140. );
  141. VOID
  142. ClusterLogEvent1(
  143. IN DWORD LogLevel,
  144. IN DWORD LogModule,
  145. IN LPSTR FileName,
  146. IN DWORD LineNumber,
  147. IN DWORD MessageId,
  148. IN DWORD dwByteCount,
  149. IN PVOID lpBytes,
  150. IN LPCWSTR Arg1
  151. );
  152. VOID
  153. ClusterLogEvent2(
  154. IN DWORD LogLevel,
  155. IN DWORD LogModule,
  156. IN LPSTR FileName,
  157. IN DWORD LineNumber,
  158. IN DWORD MessageId,
  159. IN DWORD dwByteCount,
  160. IN PVOID lpBytes,
  161. IN LPCWSTR Arg1,
  162. IN LPCWSTR Arg2
  163. );
  164. VOID
  165. ClusterLogEvent3(
  166. IN DWORD LogLevel,
  167. IN DWORD LogModule,
  168. IN LPSTR FileName,
  169. IN DWORD LineNumber,
  170. IN DWORD MessageId,
  171. IN DWORD dwByteCount,
  172. IN PVOID lpBytes,
  173. IN LPCWSTR Arg1,
  174. IN LPCWSTR Arg2,
  175. IN LPCWSTR Arg3
  176. );
  177. VOID
  178. ClusterLogEvent4(
  179. IN DWORD LogLevel,
  180. IN DWORD LogModule,
  181. IN LPSTR FileName,
  182. IN DWORD LineNumber,
  183. IN DWORD MessageId,
  184. IN DWORD dwByteCount,
  185. IN PVOID lpBytes,
  186. IN LPCWSTR Arg1,
  187. IN LPCWSTR Arg2,
  188. IN LPCWSTR Arg3,
  189. IN LPCWSTR Arg4
  190. );
  191. //
  192. // Routine Description:
  193. //
  194. // Prints a message to the debugger if running as a service
  195. // or the console window if running as a console app.
  196. //
  197. // Arguments:
  198. //
  199. // LogLevel - Supplies the logging level, one of
  200. // LOG_CRITICAL 1
  201. // LOG_UNUSUAL 2
  202. // LOG_NOISE 3
  203. //
  204. // FormatString - Message string.
  205. //
  206. // Any FormatMessage-compatible arguments to be inserted in the
  207. // ErrorMessage before it is logged.
  208. //
  209. // Return Value:
  210. //
  211. // None.
  212. //
  213. VOID
  214. __cdecl
  215. ClRtlDbgPrint(
  216. DWORD LogLevel,
  217. PCHAR FormatString,
  218. ...
  219. );
  220. //
  221. // Same as ClRtlDbgPrint, only uses a message ID instead of a string.
  222. //
  223. VOID
  224. __cdecl
  225. ClRtlMsgPrint(
  226. IN DWORD MessageId,
  227. ...
  228. );
  229. //
  230. // Same as ClRtlDbgPrint, only logs to a file instead of screen.
  231. //
  232. VOID
  233. __cdecl
  234. ClRtlLogPrint(
  235. DWORD LogLevel,
  236. PCHAR FormatString,
  237. ...
  238. );
  239. //
  240. // Macros/prototypes for unexpected error handling.
  241. //
  242. WINBASEAPI
  243. BOOL
  244. APIENTRY
  245. IsDebuggerPresent(
  246. VOID
  247. );
  248. #define CL_UNEXPECTED_ERROR(_errcode_) \
  249. ClusterLogFatalError(LOG_CURRENT_MODULE, \
  250. __LINE__, \
  251. __FILE__, \
  252. (_errcode_))
  253. #if DBG
  254. #define CL_ASSERT( exp ) \
  255. if (!(exp)) { \
  256. ClusterLogAssertionFailure(LOG_CURRENT_MODULE, \
  257. __LINE__, \
  258. __FILE__, \
  259. #exp); \
  260. }
  261. #define CL_LOGFAILURE( _errcode_ ) \
  262. ClusterLogNonFatalError(LOG_CURRENT_MODULE, \
  263. __LINE__, \
  264. __FILE__, \
  265. (_errcode_))
  266. #else
  267. #define CL_ASSERT( exp )
  268. #define CL_LOGFAILURE( _errorcode_ )
  269. #endif
  270. // Use the following to put cluster specific errors in the event log
  271. #define CL_LOGCLUSINFO( _errcode_ ) \
  272. ClusterLogEvent0(LOG_NOISE, \
  273. LOG_CURRENT_MODULE, \
  274. __FILE__, \
  275. __LINE__, \
  276. (_errcode_), \
  277. 0, \
  278. NULL)
  279. #define CL_LOGCLUSWARNING( _errcode_ ) \
  280. ClusterLogEvent0(LOG_UNUSUAL, \
  281. LOG_CURRENT_MODULE, \
  282. __FILE__, \
  283. __LINE__, \
  284. (_errcode_), \
  285. 0, \
  286. NULL)
  287. #define CL_LOGCLUSWARNING1(_msgid_,_arg1_) \
  288. ClusterLogEvent1(LOG_UNUSUAL, \
  289. LOG_CURRENT_MODULE, \
  290. __FILE__, \
  291. __LINE__, \
  292. (_msgid_), \
  293. 0, \
  294. NULL, \
  295. (_arg1_))
  296. #define CL_LOGCLUSERROR( _errcode_ ) \
  297. ClusterLogEvent0(LOG_CRITICAL, \
  298. LOG_CURRENT_MODULE, \
  299. __FILE__, \
  300. __LINE__, \
  301. (_errcode_), \
  302. 0, \
  303. NULL)
  304. #define CL_LOGCLUSERROR1(_msgid_,_arg1_) \
  305. ClusterLogEvent1(LOG_CRITICAL, \
  306. LOG_CURRENT_MODULE, \
  307. __FILE__, \
  308. __LINE__, \
  309. (_msgid_), \
  310. 0, \
  311. NULL, \
  312. (_arg1_))
  313. #define CL_LOGCLUSERROR2(_msgid_,_arg1_, _arg2_) \
  314. ClusterLogEvent2(LOG_CRITICAL, \
  315. LOG_CURRENT_MODULE, \
  316. __FILE__, \
  317. __LINE__, \
  318. (_msgid_), \
  319. 0, \
  320. NULL, \
  321. (_arg1_), \
  322. (_arg2_))
  323. //////////////////////////////////////////////////////////////////////////
  324. //
  325. // General-purpose hash table package
  326. //
  327. //////////////////////////////////////////////////////////////////////////
  328. #define MAX_CL_HASH 16 // the size of the table
  329. typedef struct _CL_HASH_ITEM {
  330. LIST_ENTRY ListHead;
  331. DWORD Id;
  332. PVOID pData;
  333. } CL_HASH_ITEM, *PCL_HASH_ITEM;
  334. typedef struct _CL_HASH {
  335. CRITICAL_SECTION Lock;
  336. BOOL bRollover; // flag to handle rollover
  337. DWORD LastId; // last id used
  338. DWORD CacheFreeId[MAX_CL_HASH]; // a cache of available id's
  339. CL_HASH_ITEM Head[MAX_CL_HASH];
  340. } CL_HASH, *PCL_HASH;
  341. VOID
  342. ClRtlInitializeHash(
  343. IN PCL_HASH pTable
  344. );
  345. DWORD
  346. ClRtlInsertTailHash(
  347. IN PCL_HASH pTable,
  348. IN PVOID pData,
  349. OUT LPDWORD pId
  350. );
  351. PVOID
  352. ClRtlGetEntryHash(
  353. IN PCL_HASH pTable,
  354. IN DWORD Id
  355. );
  356. PVOID
  357. ClRtlRemoveEntryHash(
  358. IN PCL_HASH pTable,
  359. IN DWORD Id
  360. );
  361. VOID
  362. ClRtlDeleteHash(
  363. IN PCL_HASH pTable
  364. );
  365. //////////////////////////////////////////////////////////////////////////
  366. //
  367. // General-purpose queue package.
  368. //
  369. //////////////////////////////////////////////////////////////////////////
  370. typedef struct _CL_QUEUE {
  371. LIST_ENTRY ListHead;
  372. CRITICAL_SECTION Lock;
  373. HANDLE Event;
  374. DWORD Count;
  375. HANDLE Abort;
  376. } CL_QUEUE, *PCL_QUEUE;
  377. DWORD
  378. ClRtlInitializeQueue(
  379. IN PCL_QUEUE Queue
  380. );
  381. VOID
  382. ClRtlDeleteQueue(
  383. IN PCL_QUEUE Queue
  384. );
  385. PLIST_ENTRY
  386. ClRtlRemoveHeadQueue(
  387. IN PCL_QUEUE Queue
  388. );
  389. typedef
  390. DWORD
  391. (*CLRTL_CHECK_HEAD_QUEUE_CALLBACK)(
  392. IN PLIST_ENTRY ListEntry,
  393. IN PVOID Context
  394. );
  395. /*++
  396. Routine Description:
  397. Called by ClRtlRemoveHeadQueueTimeout to determine
  398. whether or not an entry at the head of the queue is
  399. appropriate to dequeue and return or not.
  400. Arguments:
  401. ListEntry - value of the PLIST_ENTRY we're examining
  402. Context - caller-defined data
  403. Return Value:
  404. ERROR_SUCCESS if it's appropriate to return the event.
  405. A Win32 error code if the initialization failed. This value
  406. can be retrieved by calling GetLastError().
  407. --*/
  408. PLIST_ENTRY
  409. ClRtlRemoveHeadQueueTimeout(
  410. IN PCL_QUEUE Queue,
  411. IN DWORD dwMilliseconds,
  412. IN CLRTL_CHECK_HEAD_QUEUE_CALLBACK pfnCallback,
  413. IN PVOID pvContext
  414. );
  415. VOID
  416. ClRtlInsertTailQueue(
  417. IN PCL_QUEUE Queue,
  418. IN PLIST_ENTRY Item
  419. );
  420. VOID
  421. ClRtlRundownQueue(
  422. IN PCL_QUEUE Queue,
  423. OUT PLIST_ENTRY ListHead
  424. );
  425. //////////////////////////////////////////////////////////////////////////
  426. //
  427. // General-purpose buffer pool package.
  428. //
  429. //////////////////////////////////////////////////////////////////////////
  430. //
  431. // Buffer pool definition.
  432. //
  433. typedef struct _CLRTL_BUFFER_POOL *PCLRTL_BUFFER_POOL;
  434. //
  435. // Maximum number of buffers that can be allocated from a pool.
  436. //
  437. #define CLRTL_MAX_POOL_BUFFERS 0xFFFFFFFE
  438. //
  439. // Routines for utilizing buffer pools.
  440. //
  441. typedef
  442. DWORD
  443. (*CLRTL_BUFFER_CONSTRUCTOR)(
  444. PVOID Buffer
  445. );
  446. /*++
  447. Routine Description:
  448. Called to initialize a buffer which has been newly allocated
  449. from system memory.
  450. Arguments:
  451. Buffer - A pointer to the buffer to initialize.
  452. Return Value:
  453. ERROR_SUCCESS if the initialization succeeded.
  454. A Win32 error code if the initialization failed.
  455. --*/
  456. typedef
  457. VOID
  458. (*CLRTL_BUFFER_DESTRUCTOR)(
  459. PVOID Buffer
  460. );
  461. /*++
  462. Routine Description:
  463. Called to cleanup a buffer which is about to be returned to
  464. system memory.
  465. Arguments:
  466. Buffer - A pointer to the buffer to cleanup.
  467. Return Value:
  468. None.
  469. --*/
  470. PCLRTL_BUFFER_POOL
  471. ClRtlCreateBufferPool(
  472. IN DWORD BufferSize,
  473. IN DWORD MaximumCached,
  474. IN DWORD MaximumAllocated,
  475. IN CLRTL_BUFFER_CONSTRUCTOR Constructor, OPTIONAL
  476. IN CLRTL_BUFFER_DESTRUCTOR Destructor OPTIONAL
  477. );
  478. /*++
  479. Routine Description:
  480. Creates a pool from which fixed-size buffers may be allocated.
  481. Arguments:
  482. BufferSize - Size of the buffers managed by the pool.
  483. MaximumCached - The maximum number of buffers to cache in the pool.
  484. Must be less than or equal to MaximumAllocated.
  485. MaximumAllocated - The maximum number of buffers to allocate from
  486. system memory. Must be less than or equal to
  487. CLRTL_MAX_POOL_BUFFERS.
  488. Constructor - An optional routine to be called when a new buffer
  489. is allocated from system memory. May be NULL
  490. Destructor - An optional routine to be called when a buffer
  491. is returned to system memory. May be NULL.
  492. Return Value:
  493. A pointer to the created buffer pool or NULL on error.
  494. Extended error information is available from GetLastError().
  495. --*/
  496. VOID
  497. ClRtlDestroyBufferPool(
  498. IN PCLRTL_BUFFER_POOL Pool
  499. );
  500. /*++
  501. Routine Description:
  502. Destroys a previously created buffer pool.
  503. Arguments:
  504. Pool - A pointer to the pool to destroy.
  505. Return Value:
  506. None.
  507. Notes:
  508. The pool will not actually be destroyed until all outstanding
  509. buffers have been returned. Each outstanding buffer is effectively
  510. a reference on the pool.
  511. --*/
  512. PVOID
  513. ClRtlAllocateBuffer(
  514. IN PCLRTL_BUFFER_POOL Pool
  515. );
  516. /*++
  517. Routine Description:
  518. Allocates a buffer from a previously created buffer pool.
  519. Arguments:
  520. Pool - A pointer to the pool from which to allocate the buffer.
  521. Return Value:
  522. A pointer to the allocated buffer if the routine was successfull.
  523. NULL if the routine failed. Extended error information is available
  524. by calling GetLastError().
  525. --*/
  526. VOID
  527. ClRtlFreeBuffer(
  528. PVOID Buffer
  529. );
  530. /*++
  531. Routine Description:
  532. Frees a buffer back to its owning pool.
  533. Arguments:
  534. Buffer - The buffer to free.
  535. Return Value:
  536. None.
  537. --*/
  538. //////////////////////////////////////////////////////////////////////////
  539. //
  540. // General-purpose worker thread queue package.
  541. //
  542. //////////////////////////////////////////////////////////////////////////
  543. typedef struct _CLRTL_WORK_ITEM *PCLRTL_WORK_ITEM;
  544. typedef
  545. VOID
  546. (*PCLRTL_WORK_ROUTINE)(
  547. IN PCLRTL_WORK_ITEM WorkItem,
  548. IN DWORD Status,
  549. IN DWORD BytesTransferred,
  550. IN ULONG_PTR IoContext
  551. );
  552. /*++
  553. Routine Description:
  554. Called to process an item posted to a work queue.
  555. Arguments:
  556. WorkItem - The work item to process.
  557. Status - If the work item represents a completed I/O operation,
  558. this parameter contains the completion status of the
  559. operation.
  560. BytesTransferred - If the work item represents a completed I/O operation,
  561. this parameter contains the number of bytes tranferred
  562. during the operation. For other work items, the
  563. semantics of this parameter are defined by the caller
  564. of ClRtlPostItemWorkQueue.
  565. IoContext - If the work item represents a completed I/O operation,
  566. this parameter contains the context value associated
  567. with the handle on which the I/O was submitted. For
  568. other work items, the semantics of this parameter are
  569. defined by the caller of ClRtlPostItemWorkQueue.
  570. Return Value:
  571. None.
  572. --*/
  573. //
  574. // Work Item Structure.
  575. //
  576. typedef struct _CLRTL_WORK_ITEM {
  577. OVERLAPPED Overlapped;
  578. PCLRTL_WORK_ROUTINE WorkRoutine;
  579. PVOID Context;
  580. } CLRTL_WORK_ITEM;
  581. //
  582. // Work queue definition.
  583. //
  584. typedef struct _CLRTL_WORK_QUEUE *PCLRTL_WORK_QUEUE;
  585. //
  586. // Routines For Utilizing Work Queues
  587. //
  588. #define ClRtlInitializeWorkItem(Item, Routine, Ctx) \
  589. ZeroMemory(&((Item)->Overlapped), sizeof(OVERLAPPED)); \
  590. (Item)->WorkRoutine = (Routine); \
  591. (Item)->Context = (Ctx);
  592. PCLRTL_WORK_QUEUE
  593. ClRtlCreateWorkQueue(
  594. IN DWORD MaximumThreads,
  595. IN int ThreadPriority
  596. );
  597. /*++
  598. Routine Description:
  599. Creates a work queue and a dynamic pool of threads to service it.
  600. Arguments:
  601. MaximumThreads - The maximum number of threads to create to service
  602. the queue.
  603. ThreadPriority - The priority level at which the queue worker threads
  604. should run.
  605. Return Value:
  606. A pointer to the created queue if the routine is successful.
  607. NULL if the routine fails. Call GetLastError for extended
  608. error information.
  609. --*/
  610. VOID
  611. ClRtlDestroyWorkQueue(
  612. IN PCLRTL_WORK_QUEUE WorkQueue
  613. );
  614. /*++
  615. Routine Description:
  616. Destroys a work queue and its thread pool.
  617. Arguments:
  618. WorkQueue - The queue to destroy.
  619. Return Value:
  620. None.
  621. Notes:
  622. The following rules must be observed in order to safely destroy a
  623. work queue:
  624. 1) No new work items may be posted to the queue once all previously
  625. posted items have been processed by this routine.
  626. 2) WorkRoutines must be able to process items until this
  627. call returns. After the call returns, no more items will
  628. be delivered from the specified queue.
  629. One workable cleanup procedure is as follows: First, direct the
  630. WorkRoutines to silently discard completed items. Next, eliminate
  631. all sources of new work. Finally, destroy the work queue. Note that
  632. when in discard mode, the WorkRoutines may not access any structures
  633. which will be destroyed by eliminating the sources of new work.
  634. --*/
  635. DWORD
  636. ClRtlPostItemWorkQueue(
  637. IN PCLRTL_WORK_QUEUE WorkQueue,
  638. IN PCLRTL_WORK_ITEM WorkItem,
  639. IN DWORD BytesTransferred, OPTIONAL
  640. IN ULONG_PTR IoContext OPTIONAL
  641. );
  642. /*++
  643. Routine Description:
  644. Posts a specified work item to a specified work queue.
  645. Arguments:
  646. WorkQueue - A pointer to the work queue to which to post the item.
  647. WorkItem - A pointer to the item to post.
  648. BytesTransferred - If the work item represents a completed I/O operation,
  649. this parameter contains the number of bytes
  650. transferred during the operation. For other work items,
  651. the semantics of this parameter may be defined by
  652. the caller.
  653. IoContext - If the work item represents a completed I/O operation,
  654. this parameter contains the context value associated
  655. with the handle on which the operation was submitted.
  656. Of other work items, the semantics of this parameter
  657. may be defined by the caller.
  658. Return Value:
  659. ERROR_SUCCESS if the item was posted successfully.
  660. A Win32 error code if the post operation fails.
  661. --*/
  662. DWORD
  663. ClRtlAssociateIoHandleWorkQueue(
  664. IN PCLRTL_WORK_QUEUE WorkQueue,
  665. IN HANDLE IoHandle,
  666. IN ULONG_PTR IoContext
  667. );
  668. /*++
  669. Routine Description:
  670. Associates a specified I/O handle, opened for overlapped I/O
  671. completion, with a work queue. All pending I/O operations on
  672. the specified handle will be posted to the work queue when
  673. completed. An initialized CLRTL_WORK_ITEM must be used to supply
  674. the OVERLAPPED structure whenever an I/O operation is submitted on
  675. the specified handle.
  676. Arguments:
  677. WorkQueue - The work queue with which to associate the I/O handle.
  678. IoHandle - The I/O handle to associate.
  679. IoContext - A context value to associate with the specified handle.
  680. This value will be supplied as a parameter to the
  681. WorkRoutine which processes completions for this
  682. handle.
  683. Return Value:
  684. ERROR_SUCCESS if the association completes successfully.
  685. A Win32 error code if the association fails.
  686. --*/
  687. //////////////////////////////////////////////////////////////////////////
  688. //
  689. // Utilities for accessing the NT system registry.
  690. //
  691. //////////////////////////////////////////////////////////////////////////
  692. DWORD
  693. ClRtlRegQueryDword(
  694. IN HKEY hKey,
  695. IN LPWSTR lpValueName,
  696. OUT LPDWORD lpValue,
  697. IN LPDWORD lpDefaultValue OPTIONAL
  698. );
  699. DWORD
  700. ClRtlRegQueryString(
  701. IN HKEY Key,
  702. IN LPWSTR ValueName,
  703. IN DWORD ValueType,
  704. IN LPWSTR *StringBuffer,
  705. IN OUT LPDWORD StringBufferSize,
  706. OUT LPDWORD StringSize
  707. );
  708. //////////////////////////////////////////////////////////////////////////
  709. //
  710. // Routines for groveling and managing network configuration.
  711. // Currently, these are specific to TCP/IP.
  712. //
  713. //////////////////////////////////////////////////////////////////////////
  714. //
  715. // Transport interface information structure
  716. //
  717. // The "Ignore" field is intitialized to FALSE. If it is set to
  718. // TRUE by an application, the enum search functions will ignore
  719. // the entry.
  720. //
  721. typedef struct _CLRTL_NET_INTERFACE_INFO {
  722. struct _CLRTL_NET_INTERFACE_INFO * Next;
  723. ULONG Context;
  724. ULONG Flags;
  725. ULONG InterfaceAddress;
  726. LPWSTR InterfaceAddressString;
  727. ULONG NetworkAddress;
  728. LPWSTR NetworkAddressString;
  729. ULONG NetworkMask;
  730. LPWSTR NetworkMaskString;
  731. BOOLEAN Ignore;
  732. } CLRTL_NET_INTERFACE_INFO, *PCLRTL_NET_INTERFACE_INFO;
  733. #define CLRTL_NET_INTERFACE_PRIMARY 0x00000001
  734. #define CLRTL_NET_INTERFACE_DYNAMIC 0x00000002
  735. //
  736. // Adapter information structure
  737. //
  738. // The "Ignore" field is intitialized to FALSE. If it is set to
  739. // TRUE by an application, the enum search functions will ignore
  740. // the entry.
  741. //
  742. typedef struct _CLRTL_NET_ADAPTER_INFO {
  743. struct _CLRTL_NET_ADAPTER_INFO * Next;
  744. LPWSTR ConnectoidName; // INetConnection::get_Name
  745. LPWSTR DeviceGuid; // GUID for INetConnection
  746. BSTR DeviceName; // INetConnection::get_DeviceName
  747. LPWSTR AdapterDomainName; // adapter specific domain
  748. ULONG Index;
  749. ULONG Flags;
  750. NETCON_STATUS NCStatus; // INetConnection::GetProperties->Status
  751. ULONG InterfaceCount;
  752. PCLRTL_NET_INTERFACE_INFO InterfaceList;
  753. BOOLEAN Ignore;
  754. DWORD DnsServerCount;
  755. PDWORD DnsServerList;
  756. } CLRTL_NET_ADAPTER_INFO, *PCLRTL_NET_ADAPTER_INFO;
  757. #define CLRTL_NET_ADAPTER_HIDDEN 0x00000001
  758. typedef struct {
  759. ULONG AdapterCount;
  760. PCLRTL_NET_ADAPTER_INFO AdapterList;
  761. } CLRTL_NET_ADAPTER_ENUM, *PCLRTL_NET_ADAPTER_ENUM;
  762. PCLRTL_NET_ADAPTER_ENUM
  763. ClRtlEnumNetAdapters(
  764. VOID
  765. );
  766. VOID
  767. ClRtlFreeNetAdapterEnum(
  768. IN PCLRTL_NET_ADAPTER_ENUM AdapterEnum
  769. );
  770. PCLRTL_NET_ADAPTER_INFO
  771. ClRtlFindNetAdapterById(
  772. PCLRTL_NET_ADAPTER_ENUM AdapterEnum,
  773. LPWSTR AdapterId
  774. );
  775. PCLRTL_NET_INTERFACE_INFO
  776. ClRtlFindNetInterfaceByNetworkAddress(
  777. IN PCLRTL_NET_ADAPTER_INFO AdapterInfo,
  778. IN LPWSTR NetworkAddress,
  779. IN LPWSTR NetworkMask
  780. );
  781. PCLRTL_NET_ADAPTER_INFO
  782. ClRtlFindNetAdapterByNetworkAddress(
  783. IN PCLRTL_NET_ADAPTER_ENUM AdapterEnum,
  784. IN LPWSTR NetworkAddress,
  785. IN LPWSTR NetworkMask,
  786. OUT PCLRTL_NET_INTERFACE_INFO * InterfaceInfo
  787. );
  788. PCLRTL_NET_ADAPTER_INFO
  789. ClRtlFindNetAdapterByInterfaceAddress(
  790. IN PCLRTL_NET_ADAPTER_ENUM AdapterEnum,
  791. IN LPWSTR InterfaceAddressString,
  792. OUT PCLRTL_NET_INTERFACE_INFO * InterfaceInfo
  793. );
  794. PCLRTL_NET_INTERFACE_INFO
  795. ClRtlGetPrimaryNetInterface(
  796. IN PCLRTL_NET_ADAPTER_INFO AdapterInfo
  797. );
  798. VOID
  799. ClRtlQueryTcpipInformation(
  800. OUT LPDWORD MaxAddressStringLength,
  801. OUT LPDWORD MaxEndpointStringLength,
  802. OUT LPDWORD TdiAddressInfoLength
  803. );
  804. DWORD
  805. ClRtlTcpipAddressToString(
  806. ULONG AddressValue,
  807. LPWSTR * AddressString
  808. );
  809. DWORD
  810. ClRtlTcpipStringToAddress(
  811. LPCWSTR AddressString,
  812. PULONG AddressValue
  813. );
  814. DWORD
  815. ClRtlTcpipEndpointToString(
  816. USHORT EndpointValue,
  817. LPWSTR * EndpointString
  818. );
  819. DWORD
  820. ClRtlTcpipStringToEndpoint(
  821. LPCWSTR EndpointString,
  822. PUSHORT EndpointValue
  823. );
  824. BOOL
  825. ClRtlIsValidTcpipAddress(
  826. IN ULONG Address
  827. );
  828. BOOL
  829. ClRtlIsDuplicateTcpipAddress(
  830. IN ULONG Address
  831. );
  832. BOOL
  833. ClRtlIsValidTcpipSubnetMask(
  834. IN ULONG SubnetMask
  835. );
  836. BOOL
  837. ClRtlIsValidTcpipAddressAndSubnetMask(
  838. IN ULONG Address,
  839. IN ULONG SubnetMask
  840. );
  841. __inline
  842. BOOL
  843. ClRtlAreTcpipAddressesOnSameSubnet(
  844. ULONG Address1,
  845. ULONG Address2,
  846. ULONG SubnetMask
  847. )
  848. {
  849. BOOL fReturn;
  850. if ( ( Address1 & SubnetMask ) == ( Address2 & SubnetMask ) )
  851. {
  852. fReturn = TRUE;
  853. }
  854. else
  855. {
  856. fReturn = FALSE;
  857. }
  858. return fReturn;
  859. }
  860. //#define ClRtlAreTcpipAddressesOnSameSubnet(_Addr1, _Addr2, _Mask) \
  861. // ( ((_Addr1 & _Mask) == (_Addr2 & _Mask)) ? TRUE : FALSE )
  862. DWORD
  863. ClRtlBuildTcpipTdiAddress(
  864. IN LPWSTR NetworkAddress,
  865. IN LPWSTR TransportEndpoint,
  866. OUT LPVOID * TdiAddress,
  867. OUT LPDWORD TdiAddressLength
  868. );
  869. DWORD
  870. ClRtlBuildLocalTcpipTdiAddress(
  871. IN LPWSTR NetworkAddress,
  872. OUT LPVOID TdiAddress,
  873. OUT LPDWORD TdiAddressLength
  874. );
  875. DWORD
  876. ClRtlParseTcpipTdiAddress(
  877. IN LPVOID TdiAddress,
  878. OUT LPWSTR * NetworkAddress,
  879. OUT LPWSTR * TransportEndpoint
  880. );
  881. DWORD
  882. ClRtlParseTcpipTdiAddressInfo(
  883. IN LPVOID TdiAddressInfo,
  884. OUT LPWSTR * NetworkAddress,
  885. OUT LPWSTR * TransportEndpoint
  886. );
  887. //
  888. // Validate network name
  889. //
  890. typedef enum CLRTL_NAME_STATUS {
  891. NetNameOk,
  892. NetNameEmpty,
  893. NetNameTooLong,
  894. NetNameInvalidChars,
  895. NetNameInUse,
  896. NetNameSystemError,
  897. NetNameDNSNonRFCChars
  898. } CLRTL_NAME_STATUS;
  899. BOOL
  900. ClRtlIsNetNameValid(
  901. IN LPCWSTR NetName,
  902. OUT OPTIONAL CLRTL_NAME_STATUS *Result,
  903. IN BOOL CheckIfExists
  904. );
  905. //
  906. // Security related routines
  907. //
  908. LONG
  909. MapSAToRpcSA(
  910. IN LPSECURITY_ATTRIBUTES lpSA,
  911. IN OUT struct _RPC_SECURITY_ATTRIBUTES *pRpcSA
  912. );
  913. LONG
  914. MapSDToRpcSD(
  915. IN PSECURITY_DESCRIPTOR lpSD,
  916. IN OUT struct _RPC_SECURITY_DESCRIPTOR *pRpcSD
  917. );
  918. DWORD
  919. ClRtlSetObjSecurityInfo(
  920. IN HANDLE hObject,
  921. IN SE_OBJECT_TYPE SeObjType,
  922. IN DWORD dwAdminMask,
  923. IN DWORD dwOwnerMask,
  924. IN DWORD dwEveryOneMask
  925. );
  926. DWORD
  927. ClRtlFreeClusterServiceSecurityDescriptor( void );
  928. DWORD
  929. ClRtlBuildClusterServiceSecurityDescriptor(
  930. PSECURITY_DESCRIPTOR * poutSD
  931. );
  932. DWORD
  933. ClRtlEnableThreadPrivilege(
  934. IN ULONG Privilege,
  935. OUT BOOLEAN *pWasEnabled
  936. );
  937. DWORD
  938. ClRtlRestoreThreadPrivilege(
  939. IN ULONG Privilege,
  940. IN BOOLEAN WasEnabled
  941. );
  942. PSECURITY_DESCRIPTOR
  943. ClRtlCopySecurityDescriptor(
  944. IN PSECURITY_DESCRIPTOR psd
  945. );
  946. PSECURITY_DESCRIPTOR
  947. ClRtlConvertClusterSDToNT4Format(
  948. IN PSECURITY_DESCRIPTOR psd
  949. );
  950. PSECURITY_DESCRIPTOR
  951. ClRtlConvertClusterSDToNT5Format(
  952. IN PSECURITY_DESCRIPTOR psd
  953. );
  954. PSECURITY_DESCRIPTOR
  955. ClRtlConvertFileShareSDToNT4Format(
  956. IN PSECURITY_DESCRIPTOR psd
  957. );
  958. BOOL
  959. ClRtlExamineSD(
  960. PSECURITY_DESCRIPTOR psdSD,
  961. LPSTR pszPrefix
  962. );
  963. VOID
  964. ClRtlExamineMask(
  965. ACCESS_MASK amMask,
  966. LPSTR lpszOldIndent
  967. );
  968. DWORD
  969. ClRtlBuildDefaultClusterSD(
  970. IN PSID pOwnerSid,
  971. OUT PSECURITY_DESCRIPTOR * SD,
  972. OUT ULONG * SizeSD
  973. );
  974. BOOL
  975. ClRtlExamineClientToken(
  976. HANDLE hClientToken,
  977. LPSTR pszPrefix
  978. );
  979. DWORD
  980. ClRtlIsCallerAccountLocalSystemAccount(
  981. OUT PBOOL pbIsLocalSystemAccount
  982. );
  983. //
  984. // OS checker
  985. //
  986. DWORD
  987. GetServicePack(
  988. VOID
  989. );
  990. BOOL
  991. ClRtlIsOSValid(
  992. VOID
  993. );
  994. DWORD
  995. ClRtlGetSuiteType(
  996. VOID
  997. );
  998. BOOL
  999. ClRtlIsProcessRunningOnWin64(
  1000. HANDLE hProcess
  1001. );
  1002. DWORD ClRtlCheck64BitCompatibility(
  1003. BOOL bIsClusterRunningWin64,
  1004. BOOL bIsNewNodeRunningWin64
  1005. );
  1006. DWORD ClRtlCheckProcArchCompatibility(
  1007. WORD wClusterProcessorArchitecture,
  1008. WORD wNodeProcessorArchitecture
  1009. );
  1010. BOOL
  1011. ClRtlIsOSTypeValid(
  1012. VOID
  1013. );
  1014. //
  1015. // A few MULTI_SZ string manipulation routines
  1016. //
  1017. DWORD
  1018. ClRtlMultiSzAppend(
  1019. IN OUT LPWSTR *MultiSz,
  1020. IN OUT LPDWORD StringLength,
  1021. IN LPCWSTR lpString
  1022. );
  1023. DWORD
  1024. ClRtlMultiSzRemove(
  1025. IN LPWSTR lpszMultiSz,
  1026. IN OUT LPDWORD StringLength,
  1027. IN LPCWSTR lpString
  1028. );
  1029. LPCWSTR
  1030. ClRtlMultiSzEnum(
  1031. IN LPCWSTR MszString,
  1032. IN DWORD MszStringLength,
  1033. IN DWORD StringIndex
  1034. );
  1035. DWORD
  1036. ClRtlMultiSzLength(
  1037. IN LPCWSTR lpszMultiSz
  1038. );
  1039. LPCWSTR
  1040. ClRtlMultiSzScan(
  1041. IN LPCWSTR lpszMultiSz,
  1042. IN LPCWSTR lpszString
  1043. );
  1044. DWORD
  1045. ClRtlCreateDirectory(
  1046. IN LPCWSTR lpszPath
  1047. );
  1048. BOOL
  1049. WINAPI
  1050. ClRtlIsPathValid(
  1051. IN LPCWSTR lpszPath
  1052. );
  1053. DWORD
  1054. ClRtlGetClusterDirectory(
  1055. IN LPWSTR lpBuffer,
  1056. IN DWORD dwBufSize
  1057. );
  1058. typedef LONG (*PFNCLRTLCREATEKEY)(
  1059. IN PVOID ClusterKey,
  1060. IN LPCWSTR lpszSubKey,
  1061. IN DWORD dwOptions,
  1062. IN REGSAM samDesired,
  1063. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  1064. OUT PVOID * phkResult,
  1065. OUT OPTIONAL LPDWORD lpdwDisposition
  1066. );
  1067. typedef LONG (*PFNCLRTLOPENKEY)(
  1068. IN PVOID ClusterKey,
  1069. IN LPCWSTR lpszSubKey,
  1070. IN REGSAM samDesired,
  1071. OUT PVOID * phkResult
  1072. );
  1073. typedef LONG (*PFNCLRTLCLOSEKEY)(
  1074. IN PVOID ClusterKey
  1075. );
  1076. typedef LONG (*PFNCLRTLENUMVALUE)(
  1077. IN PVOID ClusterKey,
  1078. IN DWORD dwIndex,
  1079. OUT LPWSTR lpszValueName,
  1080. IN OUT LPDWORD lpcbValueName,
  1081. OUT LPDWORD lpType,
  1082. OUT LPBYTE lpData,
  1083. IN OUT LPDWORD lpcbData
  1084. );
  1085. typedef LONG (*PFNCLRTLSETVALUE)(
  1086. IN PVOID ClusterKey,
  1087. IN LPCWSTR lpszValueName,
  1088. IN DWORD dwType,
  1089. IN CONST BYTE* lpData,
  1090. IN DWORD cbData
  1091. );
  1092. typedef LONG (*PFNCLRTLQUERYVALUE)(
  1093. IN PVOID ClusterKey,
  1094. IN LPCWSTR lpszValueName,
  1095. OUT LPDWORD lpValueType,
  1096. OUT LPBYTE lpData,
  1097. IN OUT LPDWORD lpcbData
  1098. );
  1099. typedef DWORD (*PFNCLRTLDELETEVALUE)(
  1100. IN PVOID ClusterKey,
  1101. IN LPCWSTR lpszValueName
  1102. );
  1103. typedef LONG (*PFNCLRTLLOCALCREATEKEY)(
  1104. IN HANDLE hXsaction,
  1105. IN PVOID ClusterKey,
  1106. IN LPCWSTR lpszSubKey,
  1107. IN DWORD dwOptions,
  1108. IN REGSAM samDesired,
  1109. IN LPSECURITY_ATTRIBUTES lpSecurityAttributes,
  1110. OUT PVOID * phkResult,
  1111. OUT OPTIONAL LPDWORD lpdwDisposition
  1112. );
  1113. typedef LONG (*PFNCLRTLLOCALSETVALUE)(
  1114. IN HANDLE hXsaction,
  1115. IN PVOID ClusterKey,
  1116. IN LPCWSTR lpszValueName,
  1117. IN DWORD dwType,
  1118. IN CONST BYTE* lpData,
  1119. IN DWORD cbData
  1120. );
  1121. typedef LONG (*PFNCLRTLLOCALDELETEVALUE)(
  1122. IN HANDLE hXsaction,
  1123. IN PVOID ClusterKey,
  1124. IN LPCWSTR lpszValueName
  1125. );
  1126. typedef struct _CLUSTER_REG_APIS {
  1127. PFNCLRTLCREATEKEY pfnCreateKey;
  1128. PFNCLRTLOPENKEY pfnOpenKey;
  1129. PFNCLRTLCLOSEKEY pfnCloseKey;
  1130. PFNCLRTLSETVALUE pfnSetValue;
  1131. PFNCLRTLQUERYVALUE pfnQueryValue;
  1132. PFNCLRTLENUMVALUE pfnEnumValue;
  1133. PFNCLRTLDELETEVALUE pfnDeleteValue;
  1134. PFNCLRTLLOCALCREATEKEY pfnLocalCreateKey;
  1135. PFNCLRTLLOCALSETVALUE pfnLocalSetValue;
  1136. PFNCLRTLLOCALDELETEVALUE pfnLocalDeleteValue;
  1137. } CLUSTER_REG_APIS, *PCLUSTER_REG_APIS;
  1138. DWORD
  1139. WINAPI
  1140. ClRtlEnumProperties(
  1141. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1142. OUT LPWSTR pszOutProperties,
  1143. IN DWORD cbOutPropertiesSize,
  1144. OUT LPDWORD pcbBytesReturned,
  1145. OUT LPDWORD pcbRequired
  1146. );
  1147. DWORD
  1148. WINAPI
  1149. ClRtlEnumPrivateProperties(
  1150. IN PVOID hkeyClusterKey,
  1151. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1152. OUT LPWSTR pszOutProperties,
  1153. IN DWORD cbOutPropertiesSize,
  1154. OUT LPDWORD pcbBytesReturned,
  1155. OUT LPDWORD pcbRequired
  1156. );
  1157. DWORD
  1158. WINAPI
  1159. ClRtlGetProperties(
  1160. IN PVOID hkeyClusterKey,
  1161. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1162. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1163. OUT PVOID pOutPropertyList,
  1164. IN DWORD cbOutPropertyListSize,
  1165. OUT LPDWORD pcbBytesReturned,
  1166. OUT LPDWORD pcbRequired
  1167. );
  1168. DWORD
  1169. WINAPI
  1170. ClRtlGetPrivateProperties(
  1171. IN PVOID hkeyClusterKey,
  1172. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1173. OUT PVOID pOutPropertyList,
  1174. IN DWORD cbOutPropertyListSize,
  1175. OUT LPDWORD pcbBytesReturned,
  1176. OUT LPDWORD pcbRequired
  1177. );
  1178. DWORD
  1179. WINAPI
  1180. ClRtlGetPropertySize(
  1181. IN PVOID hkeyClusterKey,
  1182. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1183. IN const PRESUTIL_PROPERTY_ITEM pPropertyTableItem,
  1184. IN OUT LPDWORD pcbOutPropertyListSize,
  1185. IN OUT LPDWORD pnPropertyCount
  1186. );
  1187. DWORD
  1188. WINAPI
  1189. ClRtlGetProperty(
  1190. IN PVOID ClusterKey,
  1191. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1192. IN const PRESUTIL_PROPERTY_ITEM pPropertyTableItem,
  1193. OUT PVOID * pOutPropertyItem,
  1194. IN OUT LPDWORD pcbOutPropertyItemSize
  1195. );
  1196. DWORD
  1197. WINAPI
  1198. ClRtlpSetPropertyTable(
  1199. IN HANDLE hXsaction,
  1200. IN PVOID hkeyClusterKey,
  1201. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1202. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1203. IN PVOID Reserved,
  1204. IN BOOL bAllowUnknownProperties,
  1205. IN const PVOID pInPropertyList,
  1206. IN DWORD cbInPropertyListSize,
  1207. IN BOOL bForceWrite,
  1208. OUT OPTIONAL LPBYTE pOutParams
  1209. );
  1210. DWORD
  1211. WINAPI
  1212. ClRtlpSetNonPropertyTable(
  1213. IN HANDLE hXsaction,
  1214. IN PVOID hkeyClusterKey,
  1215. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1216. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1217. IN PVOID Reserved,
  1218. IN const PVOID pInPropertyList,
  1219. IN DWORD cbInPropertyListSize
  1220. );
  1221. DWORD
  1222. WINAPI
  1223. ClRtlSetPropertyParameterBlock(
  1224. IN HANDLE hXsaction,
  1225. IN PVOID hkeyClusterKey,
  1226. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1227. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1228. IN PVOID Reserved,
  1229. IN const LPBYTE pInParams,
  1230. IN const PVOID pInPropertyList,
  1231. IN DWORD cbInPropertyListSize,
  1232. IN BOOL bForceWrite,
  1233. OUT OPTIONAL LPBYTE pOutParams
  1234. );
  1235. DWORD
  1236. WINAPI
  1237. ClRtlGetAllProperties(
  1238. IN PVOID hkeyClusterKey,
  1239. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1240. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1241. OUT PVOID pPropertyList,
  1242. IN DWORD cbPropertyListSize,
  1243. OUT LPDWORD pcbBytesReturned,
  1244. OUT LPDWORD pcbRequired
  1245. );
  1246. DWORD
  1247. WINAPI
  1248. ClRtlGetPropertiesToParameterBlock(
  1249. IN HKEY hkeyClusterKey,
  1250. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1251. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1252. IN OUT LPBYTE pOutParams,
  1253. IN BOOL bCheckForRequiredProperties,
  1254. OUT OPTIONAL LPWSTR * ppszNameOfPropInError
  1255. );
  1256. DWORD
  1257. WINAPI
  1258. ClRtlPropertyListFromParameterBlock(
  1259. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1260. OUT PVOID pOutPropertyList,
  1261. IN OUT LPDWORD pcbOutPropertyListSize,
  1262. IN const LPBYTE pInParams,
  1263. OUT LPDWORD pcbBytesReturned,
  1264. OUT LPDWORD pcbRequired
  1265. );
  1266. DWORD
  1267. WINAPI
  1268. ClRtlGetUnknownProperties(
  1269. IN PVOID hkeyClusterKey,
  1270. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1271. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1272. OUT PVOID pOutPropertyList,
  1273. IN DWORD cbOutPropertyListSize,
  1274. OUT LPDWORD pcbBytesReturned,
  1275. OUT LPDWORD pcbRequired
  1276. );
  1277. DWORD
  1278. WINAPI
  1279. ClRtlAddUnknownProperties(
  1280. IN PVOID hkeyClusterKey,
  1281. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1282. IN const PRESUTIL_PROPERTY_ITEM ppPropertyTable,
  1283. IN OUT PVOID pOutPropertyList,
  1284. IN DWORD cbOutPropertyListSize,
  1285. IN OUT LPDWORD pcbBytesReturned,
  1286. IN OUT LPDWORD pcbRequired
  1287. );
  1288. DWORD
  1289. WINAPI
  1290. ClRtlpFindSzProperty(
  1291. IN const PVOID pPropertyList,
  1292. IN DWORD cbPropertyListSize,
  1293. IN LPCWSTR pszPropertyName,
  1294. OUT LPWSTR * pszPropertyValue,
  1295. IN BOOL bReturnExpandedValue
  1296. );
  1297. __inline
  1298. DWORD
  1299. WINAPI
  1300. ClRtlFindSzProperty(
  1301. IN const PVOID pPropertyList,
  1302. IN DWORD cbPropertyListSize,
  1303. IN LPCWSTR pszPropertyName,
  1304. OUT LPWSTR * pszPropertyValue
  1305. )
  1306. {
  1307. return ClRtlpFindSzProperty(
  1308. pPropertyList,
  1309. cbPropertyListSize,
  1310. pszPropertyName,
  1311. pszPropertyValue,
  1312. FALSE /* bReturnExpandedValue */
  1313. );
  1314. } //*** ClRtlFindSzProperty()
  1315. __inline
  1316. DWORD
  1317. WINAPI
  1318. ClRtlFindExpandSzProperty(
  1319. IN const PVOID pPropertyList,
  1320. IN DWORD cbPropertyListSize,
  1321. IN LPCWSTR pszPropertyName,
  1322. OUT LPWSTR * pszPropertyValue
  1323. )
  1324. {
  1325. return ClRtlpFindSzProperty(
  1326. pPropertyList,
  1327. cbPropertyListSize,
  1328. pszPropertyName,
  1329. pszPropertyValue,
  1330. FALSE /* bReturnExpandedValue */
  1331. );
  1332. } //*** ClRtlFindExpandSzProperty()
  1333. __inline
  1334. DWORD
  1335. WINAPI
  1336. ClRtlFindExpandedSzProperty(
  1337. IN const PVOID pPropertyList,
  1338. IN DWORD cbPropertyListSize,
  1339. IN LPCWSTR pszPropertyName,
  1340. OUT LPWSTR * pszPropertyValue
  1341. )
  1342. {
  1343. return ClRtlpFindSzProperty(
  1344. pPropertyList,
  1345. cbPropertyListSize,
  1346. pszPropertyName,
  1347. pszPropertyValue,
  1348. TRUE /* bReturnExpandedValue */
  1349. );
  1350. } //*** ClRtlFindExpandedSzProperty()
  1351. DWORD
  1352. WINAPI
  1353. ClRtlFindDwordProperty(
  1354. IN const PVOID pPropertyList,
  1355. IN DWORD cbPropertyListSize,
  1356. IN LPCWSTR pszPropertyName,
  1357. OUT LPDWORD pdwPropertyValue
  1358. );
  1359. DWORD
  1360. WINAPI
  1361. ClRtlFindLongProperty(
  1362. IN const PVOID pPropertyList,
  1363. IN DWORD cbPropertyListSize,
  1364. IN LPCWSTR pszPropertyName,
  1365. OUT LPLONG plPropertyValue
  1366. );
  1367. DWORD
  1368. WINAPI
  1369. ClRtlFindBinaryProperty(
  1370. IN const PVOID pPropertyList,
  1371. IN DWORD cbPropertyListSize,
  1372. IN LPCWSTR pszPropertyName,
  1373. OUT LPBYTE * pbPropertyValue,
  1374. OUT LPDWORD pcbPropertyValueSize
  1375. );
  1376. DWORD
  1377. WINAPI
  1378. ClRtlFindMultiSzProperty(
  1379. IN const PVOID pPropertyList,
  1380. IN DWORD cbPropertyListSize,
  1381. IN LPCWSTR pszPropertyName,
  1382. OUT LPWSTR * pszPropertyValue,
  1383. OUT LPDWORD pcbPropertyValueSize
  1384. );
  1385. __inline
  1386. DWORD
  1387. WINAPI
  1388. ClRtlVerifyPropertyTable(
  1389. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1390. IN PVOID Reserved,
  1391. IN BOOL bAllowUnknownProperties,
  1392. IN const PVOID pInPropertyList,
  1393. IN DWORD cbInPropertyListSize,
  1394. OUT OPTIONAL LPBYTE pOutParams
  1395. )
  1396. {
  1397. return ClRtlpSetPropertyTable(
  1398. NULL,
  1399. NULL,
  1400. NULL,
  1401. pPropertyTable,
  1402. Reserved,
  1403. bAllowUnknownProperties,
  1404. pInPropertyList,
  1405. cbInPropertyListSize,
  1406. FALSE, // bForceWrite
  1407. pOutParams);
  1408. }
  1409. __inline
  1410. DWORD
  1411. WINAPI
  1412. ClRtlSetPropertyTable(
  1413. IN HANDLE hXsaction,
  1414. IN PVOID hkeyClusterKey,
  1415. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1416. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1417. IN PVOID Reserved,
  1418. IN BOOL bAllowUnknownProperties,
  1419. IN const PVOID pInPropertyList,
  1420. IN DWORD cbInPropertyListSize,
  1421. IN BOOL bForceWrite,
  1422. OUT OPTIONAL LPBYTE pOutParams
  1423. )
  1424. {
  1425. if ( (hkeyClusterKey == NULL) ||
  1426. (pClusterRegApis == NULL) ){
  1427. return(ERROR_BAD_ARGUMENTS);
  1428. }
  1429. return ClRtlpSetPropertyTable(
  1430. hXsaction,
  1431. hkeyClusterKey,
  1432. pClusterRegApis,
  1433. pPropertyTable,
  1434. Reserved,
  1435. bAllowUnknownProperties,
  1436. pInPropertyList,
  1437. cbInPropertyListSize,
  1438. bForceWrite,
  1439. pOutParams);
  1440. }
  1441. DWORD
  1442. WINAPI
  1443. ClRtlpSetPrivatePropertyList(
  1444. IN HANDLE hXsaction,
  1445. IN PVOID hkeyClusterKey,
  1446. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1447. IN const PVOID pInPropertyList,
  1448. IN DWORD cbInPropertyListSize
  1449. );
  1450. __inline
  1451. DWORD
  1452. WINAPI
  1453. ClRtlVerifyPrivatePropertyList(
  1454. IN const PVOID pInPropertyList,
  1455. IN DWORD cbInPropertyListSize
  1456. )
  1457. {
  1458. return ClRtlpSetPrivatePropertyList( NULL, NULL, NULL, pInPropertyList, cbInPropertyListSize );
  1459. }
  1460. __inline
  1461. DWORD
  1462. WINAPI
  1463. ClRtlSetPrivatePropertyList(
  1464. IN HANDLE hXsaction,
  1465. IN PVOID hkeyClusterKey,
  1466. IN const PCLUSTER_REG_APIS pClusterRegApis,
  1467. IN const PVOID pInPropertyList,
  1468. IN DWORD cbInPropertyListSize
  1469. )
  1470. {
  1471. if ( (hkeyClusterKey == NULL) ||
  1472. (pClusterRegApis == NULL) ){
  1473. return(ERROR_BAD_ARGUMENTS);
  1474. }
  1475. return ClRtlpSetPrivatePropertyList(
  1476. hXsaction,
  1477. hkeyClusterKey,
  1478. pClusterRegApis,
  1479. pInPropertyList,
  1480. cbInPropertyListSize
  1481. );
  1482. }
  1483. DWORD
  1484. WINAPI
  1485. ClRtlGetBinaryValue(
  1486. IN HKEY ClusterKey,
  1487. IN LPCWSTR ValueName,
  1488. OUT LPBYTE * OutValue,
  1489. OUT LPDWORD OutValueSize,
  1490. IN const PCLUSTER_REG_APIS pClusterRegApis
  1491. );
  1492. LPWSTR
  1493. WINAPI
  1494. ClRtlGetSzValue(
  1495. IN HKEY ClusterKey,
  1496. IN LPCWSTR ValueName,
  1497. IN const PCLUSTER_REG_APIS pClusterRegApis
  1498. );
  1499. DWORD
  1500. WINAPI
  1501. ClRtlDupParameterBlock(
  1502. OUT LPBYTE pOutParams,
  1503. IN const LPBYTE pInParams,
  1504. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable
  1505. );
  1506. void
  1507. WINAPI
  1508. ClRtlFreeParameterBlock(
  1509. IN OUT LPBYTE pOutParams,
  1510. IN const LPBYTE pInParams,
  1511. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable
  1512. );
  1513. DWORD
  1514. WINAPI
  1515. ClRtlMarshallPropertyTable(
  1516. IN PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1517. IN OUT DWORD dwSize,
  1518. IN OUT LPBYTE pBuffer,
  1519. OUT DWORD *Required
  1520. );
  1521. DWORD
  1522. WINAPI
  1523. ClRtlUnmarshallPropertyTable(
  1524. IN OUT PRESUTIL_PROPERTY_ITEM *ppPropertyTable,
  1525. IN LPBYTE pBuffer
  1526. );
  1527. LPWSTR
  1528. WINAPI
  1529. ClRtlExpandEnvironmentStrings(
  1530. IN LPCWSTR pszSrc
  1531. );
  1532. DWORD
  1533. WINAPI
  1534. ClRtlGetPropertyFormats(
  1535. IN const PRESUTIL_PROPERTY_ITEM pPropertyTable,
  1536. OUT PVOID pOutPropertyFormatList,
  1537. IN DWORD cbOutPropertyFormatListSize,
  1538. OUT LPDWORD pcbReturned,
  1539. OUT LPDWORD pcbRequired
  1540. );
  1541. DWORD
  1542. WINAPI
  1543. ClRtlGetPropertyFormat(
  1544. IN const PRESUTIL_PROPERTY_ITEM pPropertyTableItem,
  1545. OUT PVOID * pOutPropertyItem,
  1546. IN OUT LPDWORD pcbOutPropertyItemSize
  1547. );
  1548. DWORD
  1549. WINAPI
  1550. ClRtlGetPropertyFormatSize(
  1551. IN const PRESUTIL_PROPERTY_ITEM pPropertyTableItem,
  1552. IN OUT LPDWORD pcbOutPropertyListSize,
  1553. IN OUT LPDWORD pnPropertyCount
  1554. );
  1555. //
  1556. // Miscellaneous Routines
  1557. //
  1558. LPWSTR
  1559. ClRtlMakeGuid(
  1560. VOID
  1561. );
  1562. LPWSTR
  1563. ClRtlGetConnectoidName(
  1564. INetConnection * NetConnection
  1565. );
  1566. INetConnection *
  1567. ClRtlFindConnectoidByGuid(
  1568. LPWSTR ConnectoidGuid
  1569. );
  1570. INetConnection *
  1571. ClRtlFindConnectoidByName(
  1572. LPCWSTR ConnectoidName
  1573. );
  1574. DWORD
  1575. ClRtlSetConnectoidName(
  1576. INetConnection * NetConnection,
  1577. LPWSTR NewConnectoidName
  1578. );
  1579. DWORD
  1580. ClRtlFindConnectoidByGuidAndSetName(
  1581. LPWSTR ConnectoidGuid,
  1582. LPWSTR NewConnectoidName
  1583. );
  1584. DWORD
  1585. ClRtlFindConnectoidByNameAndSetName(
  1586. LPWSTR ConnectoidName,
  1587. LPWSTR NewConnectoidName
  1588. );
  1589. DWORD
  1590. ClRtlGetConnectoidNameFromLANA(
  1591. IN UCHAR LanaNumber,
  1592. OUT LPWSTR * ConnectoidName
  1593. );
  1594. ///////////////////////////////////////////////////////////////////////////
  1595. //
  1596. // General purpose Watchdog timer.
  1597. //
  1598. ///////////////////////////////////////////////////////////////////////////
  1599. PVOID
  1600. ClRtlSetWatchdogTimer(
  1601. DWORD timeout,
  1602. LPWSTR par
  1603. );
  1604. VOID
  1605. ClRtlCancelWatchdogTimer(
  1606. PVOID wTimer
  1607. );
  1608. /* commented out 16 Nov 1998 by GalenB because the DS work has been postponed
  1609. //
  1610. // Active Directory Services (DS) Publication Routines
  1611. //
  1612. HRESULT
  1613. HrClRtlAddClusterNameToDS(
  1614. const TCHAR *pClusterName,
  1615. const HCLUSTER hCluster
  1616. );
  1617. HRESULT
  1618. HrClRtlMoveClusterNodeDS(
  1619. const TCHAR *pClusterName,
  1620. const HCLUSTER hCluster,
  1621. const TCHAR *pNodeName
  1622. );
  1623. end of commented out code */
  1624. // Apis and defines for cluster installation state
  1625. // This enum is used to indicate the state of the Cluster Server installation.
  1626. // The registry key that indicates the state of the Cluster Server installation
  1627. // will be a DWORD representation of one of the following values.
  1628. typedef enum
  1629. {
  1630. eClusterInstallStateUnknown,
  1631. eClusterInstallStateFilesCopied,
  1632. eClusterInstallStateConfigured,
  1633. eClusterInstallStateUpgraded
  1634. } eClusterInstallState;
  1635. DWORD
  1636. ClRtlGetClusterInstallState(
  1637. IN LPCWSTR pszNodeName,
  1638. OUT eClusterInstallState * peState
  1639. );
  1640. BOOL
  1641. ClRtlSetClusterInstallState(
  1642. IN eClusterInstallState InstallState
  1643. );
  1644. //
  1645. // Routine to get drive layout table
  1646. //
  1647. BOOL
  1648. ClRtlGetDriveLayoutTable(
  1649. IN HANDLE hDisk,
  1650. OUT PDRIVE_LAYOUT_INFORMATION * DriveLayout,
  1651. OUT PDWORD InfoSize OPTIONAL
  1652. );
  1653. DWORD ClRtlGetDefaultNodeLimit(
  1654. IN DWORD SuiteType);
  1655. //
  1656. // If async event reporting is required,
  1657. // use the following function to set
  1658. // a work queue
  1659. //
  1660. VOID
  1661. ClRtlEventLogSetWorkQueue(
  1662. PCLRTL_WORK_QUEUE WorkQueue
  1663. );
  1664. //
  1665. // Fast check to see if a file or directory exists.
  1666. //
  1667. BOOL
  1668. ClRtlPathFileExists(
  1669. LPWSTR pwszPath
  1670. );
  1671. //
  1672. // set default failure actions in service controller
  1673. //
  1674. DWORD
  1675. ClRtlSetSCMFailureActions(
  1676. LPWSTR NodeName OPTIONAL
  1677. );
  1678. //
  1679. // Initialize Wmi tracing (noop if wmi is disabled)
  1680. //
  1681. DWORD
  1682. ClRtlInitWmi(
  1683. LPCWSTR ComponentName
  1684. );
  1685. //
  1686. // Get the cluster service domain account info
  1687. //
  1688. DWORD
  1689. ClRtlGetServiceAccountInfo(
  1690. LPWSTR * AccountBuffer
  1691. );
  1692. //
  1693. // set the DACL for Winsta0 and its desktop such that any genapp process can
  1694. // access it
  1695. //
  1696. DWORD
  1697. ClRtlAddClusterServiceAccountToWinsta0DACL(
  1698. VOID
  1699. );
  1700. //
  1701. // add the SID with AccessMask to the SD specified by pOldSd. return the new
  1702. // self-relative SD in ppNewSd
  1703. //
  1704. DWORD
  1705. ClRtlAddAceToSd(
  1706. IN PSECURITY_DESCRIPTOR pOldSd,
  1707. IN PSID pClientSid,
  1708. IN ACCESS_MASK AccessMask,
  1709. OUT PSECURITY_DESCRIPTOR * ppNewSd
  1710. );
  1711. //
  1712. // Cleanup a node that has been evicted (requires cleanup COM component to be registered locally).
  1713. // This function should only be called from the cluster service.
  1714. //
  1715. HRESULT ClRtlCleanupNode(
  1716. const WCHAR * pcszEvictedNodeNameIn
  1717. , DWORD dwDelayIn
  1718. , DWORD dwTimeoutIn
  1719. );
  1720. //
  1721. // Asynchronously cleanup a node that has been evicted.
  1722. //
  1723. HRESULT ClRtlAsyncCleanupNode(
  1724. const WCHAR * pcszEvictedNodeNameIn
  1725. , DWORD dwDelayIn
  1726. , DWORD dwTimeoutIn
  1727. );
  1728. //
  1729. // Find out if a registry value indicating that this node has been evicted, is set or not
  1730. //
  1731. DWORD
  1732. ClRtlHasNodeBeenEvicted(
  1733. BOOL * pfNodeEvictedOut
  1734. );
  1735. //
  1736. // Initiate operations that inform interested parties that the cluster
  1737. // service is starting up
  1738. //
  1739. HRESULT
  1740. ClRtlInitiateStartupNotification( void );
  1741. //
  1742. // Initiate operations that inform interested parties that the a node has
  1743. // been evicted from the cluster.
  1744. //
  1745. HRESULT
  1746. ClRtlInitiateEvictNotification( LPCWSTR pcszNodeNameIn );
  1747. //
  1748. // Start a thread that will perform any periodic cleanup needed while the
  1749. // service is running.
  1750. //
  1751. HRESULT
  1752. ClRtlInitiatePeriodicCleanupThread( void );
  1753. //
  1754. // get the domain account in the form of 'user\domain'
  1755. //
  1756. DWORD
  1757. ClRtlGetRunningAccountInfo(
  1758. LPWSTR * AccountBuffer
  1759. );
  1760. //
  1761. // Checks if cluster version checking has been disabled on a particular computer.
  1762. //
  1763. DWORD
  1764. ClRtlIsVersionCheckingDisabled(
  1765. const WCHAR * pcszNodeNameIn
  1766. , BOOL * pfVerCheckDisabledOut
  1767. );
  1768. //
  1769. // Copy a source file to a destination and flush the destination file buffers.
  1770. //
  1771. BOOL
  1772. ClRtlCopyFileAndFlushBuffers(
  1773. IN LPCWSTR lpszSourceFile,
  1774. IN LPCWSTR lpszDestinationFile
  1775. );
  1776. #ifdef __cplusplus
  1777. }
  1778. #endif
  1779. #endif // ifndef _CLUSRTL_INCLUDED_