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.

3420 lines
81 KiB

  1. /*********************************************************************/
  2. /** Copyright(c) 1995 Microsoft Corporation. **/
  3. /*********************************************************************/
  4. //***
  5. //
  6. // Filename: apistub.c
  7. //
  8. // Description: This module contains the DIM/DDM server API RPC
  9. // client stubs.
  10. //
  11. // History: June 11,1995. NarenG Created original version.
  12. //
  13. #include <nt.h>
  14. #include <ntrtl.h> // For ASSERT
  15. #include <nturtl.h> // needed for winbase.h
  16. #include <windows.h> // Win32 base API's
  17. #include <rpc.h>
  18. #include <ntseapi.h>
  19. #include <ntlsa.h>
  20. #include <ntsam.h>
  21. #include <ntsamp.h>
  22. #include <nturtl.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <wchar.h>
  26. #include <lm.h>
  27. #include <lmsvc.h>
  28. #include <raserror.h>
  29. #include <mprapip.h>
  30. #include <mprerror.h>
  31. #include <dimsvc.h>
  32. DWORD
  33. DimRPCBind(
  34. IN LPWSTR lpwsServerName,
  35. OUT HANDLE * phDimServer
  36. );
  37. DWORD APIENTRY
  38. MprAdminInterfaceSetCredentialsEx(
  39. IN MPR_SERVER_HANDLE hMprServer,
  40. IN HANDLE hInterface,
  41. IN DWORD dwLevel,
  42. IN LPBYTE lpbBuffer
  43. );
  44. PVOID
  45. MprAdminAlloc(
  46. IN DWORD dwSize)
  47. {
  48. return MIDL_user_allocate(dwSize);
  49. }
  50. VOID
  51. MprAdminFree(
  52. IN PVOID pvData)
  53. {
  54. MIDL_user_free(pvData);
  55. }
  56. //**
  57. //
  58. // Call: RasAdminIsServiceRunning
  59. //
  60. // Returns: TRUE - Service is running.
  61. // FALSE - Servicis in not running.
  62. //
  63. //
  64. // Description: Checks to see of Remote Access Service is running on the
  65. // remote machine
  66. //
  67. BOOL
  68. RasAdminIsServiceRunning(
  69. IN LPWSTR lpwsServerName
  70. )
  71. {
  72. SC_HANDLE hSM = NULL, hRemoteAccess = NULL, hRouter = NULL;
  73. DWORD dwErr = NO_ERROR;
  74. BOOL fIsRouterRunning = FALSE, bOk = FALSE;
  75. SERVICE_STATUS Status;
  76. do
  77. {
  78. // Get a handle to the service controller
  79. //
  80. hSM = OpenSCManager(
  81. lpwsServerName,
  82. NULL,
  83. GENERIC_READ);
  84. if (hSM == NULL)
  85. {
  86. break;
  87. }
  88. // Open the remoteaccess service
  89. //
  90. hRemoteAccess = OpenService(
  91. hSM,
  92. L"RemoteAccess",
  93. SERVICE_QUERY_STATUS);
  94. if (hRemoteAccess == NULL)
  95. {
  96. break;
  97. }
  98. // If remoteaccess service is running, return
  99. // true
  100. //
  101. bOk = QueryServiceStatus(
  102. hRemoteAccess,
  103. &Status);
  104. if (bOk && (Status.dwCurrentState == SERVICE_RUNNING))
  105. {
  106. fIsRouterRunning = TRUE;
  107. break;
  108. }
  109. // Otherwise, see if the router service is running.
  110. //
  111. hRouter = OpenService(
  112. hSM,
  113. L"Router",
  114. SERVICE_QUERY_STATUS);
  115. if (hRouter == NULL)
  116. {
  117. break;
  118. }
  119. // If router service is running, return
  120. // true
  121. //
  122. bOk = QueryServiceStatus(
  123. hRouter,
  124. &Status);
  125. if (bOk && (Status.dwCurrentState == SERVICE_RUNNING))
  126. {
  127. fIsRouterRunning = TRUE;
  128. break;
  129. }
  130. } while (FALSE);
  131. // Cleanup
  132. {
  133. if (hRemoteAccess)
  134. {
  135. CloseServiceHandle(hRemoteAccess);
  136. }
  137. if (hRouter)
  138. {
  139. CloseServiceHandle(hRouter);
  140. }
  141. if (hSM)
  142. {
  143. CloseServiceHandle(hSM);
  144. }
  145. }
  146. return fIsRouterRunning;
  147. }
  148. //**
  149. //
  150. // Call: RasAdminServerConnect
  151. //
  152. // Returns: NO_ERROR - success
  153. // non-zero returns from the DimRPCBind routine.
  154. //
  155. //
  156. // Description: This is the DLL entrypoint for RasAdminServerConnect
  157. //
  158. DWORD
  159. RasAdminServerConnect(
  160. IN LPWSTR lpwsServerName,
  161. OUT RAS_SERVER_HANDLE * phRasServer
  162. )
  163. {
  164. //
  165. // Bind with the server
  166. //
  167. return( DimRPCBind( lpwsServerName, phRasServer ) );
  168. }
  169. //**
  170. //
  171. // Call: RasAdminServerDisconnect
  172. //
  173. // Returns: none.
  174. //
  175. // Description: This is the DLL entrypoint for RasAdminServerDisconnect
  176. //
  177. VOID
  178. RasAdminServerDisconnect(
  179. IN RAS_SERVER_HANDLE hRasServer
  180. )
  181. {
  182. RpcBindingFree( (handle_t *)&hRasServer );
  183. }
  184. //**
  185. //
  186. // Call: RasAdminBufferFree
  187. //
  188. // Returns: none
  189. //
  190. // Description: This is the DLL entrypoint for RasAdminBufferFree
  191. //
  192. DWORD
  193. RasAdminBufferFree(
  194. IN PVOID pBuffer
  195. )
  196. {
  197. if ( pBuffer == NULL )
  198. {
  199. return( ERROR_INVALID_PARAMETER );
  200. }
  201. MIDL_user_free( pBuffer );
  202. return( NO_ERROR );
  203. }
  204. //**
  205. //
  206. // Call: RasAdminConnectionEnum
  207. //
  208. // Returns: NO_ERROR - success
  209. // ERROR_INVALID_PARAMETER
  210. // non-zero returns from RRasAdminConnectionEnum
  211. //
  212. // Description: This is the DLL entry point for RasAdminConnectionEnum.
  213. //
  214. DWORD APIENTRY
  215. RasAdminConnectionEnum(
  216. IN RAS_SERVER_HANDLE hRasServer,
  217. IN DWORD dwLevel,
  218. OUT LPBYTE * lplpbBuffer, // RAS_CONNECTION_0
  219. IN DWORD dwPrefMaxLen,
  220. OUT LPDWORD lpdwEntriesRead,
  221. OUT LPDWORD lpdwTotalEntries,
  222. IN LPDWORD lpdwResumeHandle OPTIONAL
  223. )
  224. {
  225. DWORD dwRetCode;
  226. DIM_INFORMATION_CONTAINER InfoStruct;
  227. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  228. // Validate parameters
  229. //
  230. if (dwPrefMaxLen == 0)
  231. {
  232. return ERROR_MORE_DATA;
  233. }
  234. //
  235. // Touch all pointers
  236. //
  237. try
  238. {
  239. *lplpbBuffer = NULL;
  240. *lpdwEntriesRead = 0;
  241. *lpdwTotalEntries = 0;
  242. if ( lpdwResumeHandle )
  243. {
  244. *lpdwResumeHandle;
  245. }
  246. }
  247. except( EXCEPTION_EXECUTE_HANDLER )
  248. {
  249. return( ERROR_INVALID_PARAMETER );
  250. }
  251. RpcTryExcept
  252. {
  253. dwRetCode = RRasAdminConnectionEnum(
  254. hRasServer,
  255. dwLevel,
  256. &InfoStruct,
  257. dwPrefMaxLen,
  258. lpdwEntriesRead,
  259. lpdwTotalEntries,
  260. lpdwResumeHandle );
  261. if ( InfoStruct.pBuffer != NULL )
  262. {
  263. dwRetCode =
  264. MprThunkConnection_WtoH(
  265. dwLevel,
  266. InfoStruct.pBuffer,
  267. InfoStruct.dwBufferSize,
  268. *lpdwEntriesRead,
  269. MprAdminAlloc,
  270. MprAdminFree,
  271. lplpbBuffer);
  272. }
  273. }
  274. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  275. {
  276. dwRetCode = RpcExceptionCode();
  277. }
  278. RpcEndExcept
  279. return( dwRetCode );
  280. }
  281. //**
  282. //
  283. // Call: RasAdminPortEnum
  284. //
  285. // Returns: NO_ERROR - success
  286. // ERROR_INVALID_PARAMETER
  287. // non-zero returns from RRasAdminPortEnum
  288. //
  289. // Description: This is the DLL entry point for RasAdminPortEnum.
  290. //
  291. DWORD APIENTRY
  292. RasAdminPortEnum(
  293. IN RAS_SERVER_HANDLE hRasServer,
  294. IN DWORD dwLevel,
  295. IN HANDLE hRasConnection,
  296. OUT LPBYTE * lplpbBuffer, // RAS_PORT_0
  297. IN DWORD dwPrefMaxLen,
  298. OUT LPDWORD lpdwEntriesRead,
  299. OUT LPDWORD lpdwTotalEntries,
  300. IN LPDWORD lpdwResumeHandle OPTIONAL
  301. )
  302. {
  303. DWORD dwRetCode;
  304. DIM_INFORMATION_CONTAINER InfoStruct;
  305. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  306. //
  307. // Touch all pointers
  308. //
  309. try
  310. {
  311. *lplpbBuffer = NULL;
  312. *lpdwEntriesRead = 0;
  313. *lpdwTotalEntries = 0;
  314. if ( lpdwResumeHandle )
  315. {
  316. *lpdwResumeHandle;
  317. }
  318. }
  319. except( EXCEPTION_EXECUTE_HANDLER )
  320. {
  321. return( ERROR_INVALID_PARAMETER );
  322. }
  323. RpcTryExcept
  324. {
  325. dwRetCode = RRasAdminPortEnum(
  326. hRasServer,
  327. dwLevel,
  328. PtrToUlong(hRasConnection),
  329. &InfoStruct,
  330. dwPrefMaxLen,
  331. lpdwEntriesRead,
  332. lpdwTotalEntries,
  333. lpdwResumeHandle );
  334. if ( InfoStruct.pBuffer != NULL )
  335. {
  336. dwRetCode =
  337. MprThunkPort_WtoH(
  338. dwLevel,
  339. InfoStruct.pBuffer,
  340. InfoStruct.dwBufferSize,
  341. *lpdwEntriesRead,
  342. MprAdminAlloc,
  343. MprAdminFree,
  344. lplpbBuffer);
  345. }
  346. }
  347. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  348. {
  349. dwRetCode = RpcExceptionCode();
  350. }
  351. RpcEndExcept
  352. return( dwRetCode );
  353. }
  354. //**
  355. //
  356. // Call: RasAdminConnectionGetInfo
  357. //
  358. // Returns: NO_ERROR - success
  359. // ERROR_INVALID_PARAMETER
  360. // non-zero return codes from RRasAdminConnectionGetInfo
  361. //
  362. // Description: This is the DLL entrypoint for RasAdminConnectionGetInfo
  363. //
  364. DWORD APIENTRY
  365. RasAdminConnectionGetInfo(
  366. IN RAS_SERVER_HANDLE hRasServer,
  367. IN DWORD dwLevel,
  368. IN HANDLE hRasConnection,
  369. OUT LPBYTE * lplpbBuffer
  370. )
  371. {
  372. DWORD dwRetCode;
  373. DIM_INFORMATION_CONTAINER InfoStruct;
  374. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  375. //
  376. // Make sure that all pointers passed in are valid
  377. //
  378. try
  379. {
  380. *lplpbBuffer = NULL;
  381. }
  382. except( EXCEPTION_EXECUTE_HANDLER )
  383. {
  384. return( ERROR_INVALID_PARAMETER );
  385. }
  386. RpcTryExcept
  387. {
  388. dwRetCode = RRasAdminConnectionGetInfo(
  389. hRasServer,
  390. dwLevel,
  391. PtrToUlong(hRasConnection),
  392. &InfoStruct );
  393. }
  394. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  395. {
  396. dwRetCode = RpcExceptionCode();
  397. }
  398. RpcEndExcept
  399. if ( dwRetCode == NO_ERROR )
  400. {
  401. if ( InfoStruct.pBuffer != NULL )
  402. {
  403. MprThunkConnection_WtoH(
  404. dwLevel,
  405. InfoStruct.pBuffer,
  406. InfoStruct.dwBufferSize,
  407. 1,
  408. MprAdminAlloc,
  409. MprAdminFree,
  410. lplpbBuffer);
  411. }
  412. }
  413. return( dwRetCode );
  414. }
  415. //**
  416. //
  417. // Call: RasAdminPortGetInfo
  418. //
  419. // Returns: NO_ERROR - success
  420. // ERROR_INVALID_PARAMETER
  421. // non-zero return codes from RRasAdminPortGetInfo
  422. //
  423. // Description: This is the DLL entrypoint for RasAdminPortGetInfo
  424. //
  425. DWORD APIENTRY
  426. RasAdminPortGetInfo(
  427. IN RAS_SERVER_HANDLE hRasServer,
  428. IN DWORD dwLevel,
  429. IN HANDLE hPort,
  430. OUT LPBYTE * lplpbBuffer
  431. )
  432. {
  433. DWORD dwRetCode;
  434. DIM_INFORMATION_CONTAINER InfoStruct;
  435. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  436. //
  437. // Make sure that all pointers passed in are valid
  438. //
  439. try
  440. {
  441. *lplpbBuffer = NULL;
  442. }
  443. except( EXCEPTION_EXECUTE_HANDLER )
  444. {
  445. return( ERROR_INVALID_PARAMETER );
  446. }
  447. RpcTryExcept
  448. {
  449. dwRetCode = RRasAdminPortGetInfo(
  450. hRasServer,
  451. dwLevel,
  452. PtrToUlong(hPort),
  453. &InfoStruct );
  454. }
  455. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  456. {
  457. dwRetCode = RpcExceptionCode();
  458. }
  459. RpcEndExcept
  460. if ( dwRetCode == NO_ERROR )
  461. {
  462. if ( InfoStruct.pBuffer != NULL )
  463. {
  464. MprThunkPort_WtoH(
  465. dwLevel,
  466. InfoStruct.pBuffer,
  467. InfoStruct.dwBufferSize,
  468. 1,
  469. MprAdminAlloc,
  470. MprAdminFree,
  471. lplpbBuffer);
  472. }
  473. }
  474. return( dwRetCode );
  475. }
  476. //**
  477. //
  478. // Call: RasAdminGetErrorString
  479. //
  480. // Returns: NO_ERROR - success
  481. // ERROR_INVALID_PARAMETER
  482. // non-zero return codes from RRasAdminGetErrorString
  483. //
  484. // Description: This is the DLL entrypoint for RasAdminGetErrorString
  485. //
  486. DWORD APIENTRY
  487. RasAdminGetErrorString(
  488. IN DWORD dwError,
  489. OUT LPWSTR * lplpwsErrorString
  490. )
  491. {
  492. return( MprAdminGetErrorString( dwError, lplpwsErrorString ) );
  493. }
  494. //**
  495. //
  496. // Call: RasAdminConnectionClearStats
  497. //
  498. // Returns: NO_ERROR - success
  499. // ERROR_INVALID_PARAMETER
  500. // non-zero return codes from RRasAdminConnectionClearStats
  501. //
  502. // Description: This is the DLL entrypoint for RasAdminConnectionClearStats
  503. //
  504. DWORD APIENTRY
  505. RasAdminConnectionClearStats(
  506. IN RAS_SERVER_HANDLE hRasServer,
  507. IN HANDLE hRasConnection
  508. )
  509. {
  510. DWORD dwRetCode;
  511. RpcTryExcept
  512. {
  513. dwRetCode = RRasAdminConnectionClearStats(
  514. hRasServer,
  515. PtrToUlong(hRasConnection) );
  516. }
  517. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  518. {
  519. dwRetCode = RpcExceptionCode();
  520. }
  521. RpcEndExcept
  522. return( dwRetCode );
  523. }
  524. //**
  525. //
  526. // Call: RasAdminPortClearStats
  527. //
  528. // Returns: NO_ERROR - success
  529. // ERROR_INVALID_PARAMETER
  530. // non-zero return codes from RRasAdminPortClearStats
  531. //
  532. // Description: This is the DLL entrypoint for RasAdminPortClearStats
  533. //
  534. DWORD APIENTRY
  535. RasAdminPortClearStats(
  536. IN RAS_SERVER_HANDLE hRasServer,
  537. IN HANDLE hPort
  538. )
  539. {
  540. DWORD dwRetCode;
  541. RpcTryExcept
  542. {
  543. dwRetCode = RRasAdminPortClearStats( hRasServer, PtrToUlong(hPort) );
  544. }
  545. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  546. {
  547. dwRetCode = RpcExceptionCode();
  548. }
  549. RpcEndExcept
  550. return( dwRetCode );
  551. }
  552. //**
  553. //
  554. // Call: RasAdminPortReset
  555. //
  556. // Returns: NO_ERROR - success
  557. // ERROR_INVALID_PARAMETER
  558. // non-zero return codes from RRasAdminPortReset
  559. //
  560. // Description: This is the DLL entrypoint for RasAdminPortReset
  561. //
  562. DWORD APIENTRY
  563. RasAdminPortReset(
  564. IN RAS_SERVER_HANDLE hRasServer,
  565. IN HANDLE hPort
  566. )
  567. {
  568. DWORD dwRetCode;
  569. RpcTryExcept
  570. {
  571. dwRetCode = RRasAdminPortReset( hRasServer, PtrToUlong(hPort) );
  572. }
  573. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  574. {
  575. dwRetCode = RpcExceptionCode();
  576. }
  577. RpcEndExcept
  578. return( dwRetCode );
  579. }
  580. //**
  581. //
  582. // Call: RasAdminPortDisconnect
  583. //
  584. // Returns: NO_ERROR - success
  585. // ERROR_INVALID_PARAMETER
  586. // non-zero return codes from RRasAdminPortDisconnect
  587. //
  588. // Description: This is the DLL entrypoint for RasAdminPortDisconnect
  589. //
  590. DWORD APIENTRY
  591. RasAdminPortDisconnect(
  592. IN RAS_SERVER_HANDLE hRasServer,
  593. IN HANDLE hPort
  594. )
  595. {
  596. DWORD dwRetCode;
  597. RpcTryExcept
  598. {
  599. dwRetCode = RRasAdminPortDisconnect( hRasServer, PtrToUlong(hPort) );
  600. }
  601. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  602. {
  603. dwRetCode = RpcExceptionCode();
  604. }
  605. RpcEndExcept
  606. return( dwRetCode );
  607. }
  608. //**
  609. //
  610. // Call: MprAdminSendUserMessage
  611. //
  612. // Returns: NO_ERROR - Success
  613. // Non-zero returns - Failure
  614. //
  615. // Description:
  616. //
  617. DWORD APIENTRY
  618. MprAdminSendUserMessage(
  619. IN MPR_SERVER_HANDLE hMprServer,
  620. IN HANDLE hRasConnection,
  621. IN LPWSTR lpwszMessage
  622. )
  623. {
  624. DWORD dwRetCode;
  625. BOOL fZeroLengthMessage = FALSE;
  626. //
  627. // make sure the buffer is valid, and enough bytes are really available
  628. //
  629. try
  630. {
  631. if ( wcslen( lpwszMessage ) == 0 )
  632. {
  633. fZeroLengthMessage = TRUE;
  634. }
  635. }
  636. except( EXCEPTION_EXECUTE_HANDLER )
  637. {
  638. return( ERROR_INVALID_PARAMETER );
  639. }
  640. if ( fZeroLengthMessage )
  641. {
  642. return( NO_ERROR );
  643. }
  644. RpcTryExcept
  645. {
  646. dwRetCode = RRasAdminSendUserMessage(
  647. hMprServer,
  648. PtrToUlong(hRasConnection),
  649. lpwszMessage );
  650. }
  651. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  652. {
  653. dwRetCode = RpcExceptionCode();
  654. }
  655. RpcEndExcept
  656. return( dwRetCode );
  657. }
  658. //**
  659. //
  660. // Call: MprAdminServerGetInfo
  661. //
  662. // Returns: NO_ERROR - success
  663. // ERROR_INVALID_PARAMETER
  664. // non-zero return codes from RMprAdminServerGetInfo
  665. //
  666. // Description: This is the DLL entrypoint for MprAdminServerGetInfo
  667. //
  668. DWORD APIENTRY
  669. MprAdminServerGetInfo(
  670. IN MPR_SERVER_HANDLE hMprServer,
  671. IN DWORD dwLevel,
  672. IN LPBYTE * lplpbBuffer
  673. )
  674. {
  675. DWORD dwRetCode;
  676. DIM_INFORMATION_CONTAINER InfoStruct;
  677. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  678. //
  679. // Make sure that all pointers passed in are valid
  680. //
  681. try
  682. {
  683. *lplpbBuffer = NULL;
  684. }
  685. except( EXCEPTION_EXECUTE_HANDLER )
  686. {
  687. return( ERROR_INVALID_PARAMETER );
  688. }
  689. RpcTryExcept
  690. {
  691. dwRetCode = RMprAdminServerGetInfo(
  692. hMprServer,
  693. dwLevel,
  694. &InfoStruct );
  695. }
  696. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  697. {
  698. dwRetCode = RpcExceptionCode();
  699. }
  700. RpcEndExcept
  701. if ( dwRetCode == NO_ERROR )
  702. {
  703. if ( InfoStruct.pBuffer != NULL )
  704. {
  705. *lplpbBuffer = InfoStruct.pBuffer;
  706. }
  707. }
  708. return( dwRetCode );
  709. }
  710. DWORD APIENTRY
  711. MprAdminServerSetCredentials(
  712. IN MPR_SERVER_HANDLE hMprServer,
  713. IN DWORD dwLevel,
  714. IN LPBYTE lpbBuffer
  715. )
  716. {
  717. if(0 != dwLevel)
  718. {
  719. return ERROR_INVALID_PARAMETER;
  720. }
  721. return MprAdminInterfaceSetCredentialsEx(
  722. hMprServer,
  723. NULL,
  724. 2,
  725. lpbBuffer);
  726. }
  727. DWORD APIENTRY
  728. MprAdminServerGetCredentials(
  729. IN MPR_SERVER_HANDLE hMprServer,
  730. IN DWORD dwLevel,
  731. IN LPBYTE * lplpbBuffer)
  732. {
  733. if( (0 != dwLevel)
  734. || (NULL == lplpbBuffer))
  735. {
  736. return ERROR_INVALID_PARAMETER;
  737. }
  738. return MprAdminInterfaceGetCredentialsEx(
  739. hMprServer,
  740. NULL,
  741. 2,
  742. lplpbBuffer);
  743. }
  744. //**
  745. //
  746. // Call: MprAdminIsServiceRunning
  747. //
  748. // Returns: TRUE - Service is running.
  749. // FALSE - Servicis in not running.
  750. //
  751. //
  752. // Description: Checks to see of Remote Access Service is running on the
  753. // remote machine
  754. //
  755. BOOL
  756. MprAdminIsServiceRunning(
  757. IN LPWSTR lpwsServerName
  758. )
  759. {
  760. BOOL fServiceStarted;
  761. DWORD dwErr;
  762. HANDLE hServer;
  763. // First query the service controller to see whether
  764. // the service is running.
  765. //
  766. fServiceStarted = RasAdminIsServiceRunning( lpwsServerName );
  767. if ( fServiceStarted == FALSE )
  768. {
  769. return FALSE;
  770. }
  771. // pmay: 209235
  772. //
  773. // Even if the service controller says that the service is
  774. // started, it may still be initializing.
  775. //
  776. // Initalize
  777. {
  778. fServiceStarted = FALSE;
  779. dwErr = NO_ERROR;
  780. hServer = NULL;
  781. }
  782. do
  783. {
  784. // Connect to the service rpc
  785. //
  786. dwErr = MprAdminServerConnect(
  787. lpwsServerName,
  788. &hServer);
  789. if (dwErr != NO_ERROR)
  790. {
  791. break;
  792. }
  793. // Return TRUE iff the service has been
  794. // running for more than zero seconds
  795. //
  796. fServiceStarted = TRUE;
  797. } while (FALSE);
  798. // Cleanup
  799. {
  800. if (hServer)
  801. {
  802. MprAdminServerDisconnect( hServer );
  803. }
  804. }
  805. return fServiceStarted;
  806. }
  807. //
  808. // Call: MprAdminServerConnect
  809. //
  810. // Returns: NO_ERROR - success
  811. // non-zero returns from the DimRPCBind routine.
  812. //
  813. //
  814. // Description: This is the DLL entrypoint for RouterInterfaceServerConnect
  815. //
  816. DWORD
  817. MprAdminServerConnect(
  818. IN LPWSTR lpwsServerName,
  819. OUT MPR_SERVER_HANDLE * phMprServer
  820. )
  821. {
  822. DWORD dwErr = NO_ERROR;
  823. MPR_SERVER_0 * pMprServer0 = NULL;
  824. do
  825. {
  826. //
  827. // Bind with the server
  828. //
  829. dwErr = DimRPCBind( lpwsServerName, phMprServer );
  830. if ( dwErr != NO_ERROR )
  831. {
  832. break;
  833. }
  834. //
  835. // pmay: 209235
  836. //
  837. // Only return success if the service is running.
  838. //
  839. dwErr = MprAdminServerGetInfo(
  840. *phMprServer,
  841. 0,
  842. (LPBYTE*)&pMprServer0);
  843. if (dwErr != NO_ERROR)
  844. {
  845. break;
  846. }
  847. } while (FALSE);
  848. // Cleanup
  849. {
  850. if ( pMprServer0 != NULL)
  851. {
  852. MprAdminBufferFree( pMprServer0 );
  853. }
  854. if ( (dwErr != NO_ERROR )
  855. && (NULL != *phMprServer))
  856. {
  857. MprAdminServerDisconnect( *phMprServer );
  858. *phMprServer = NULL;
  859. }
  860. }
  861. return dwErr;
  862. }
  863. //**
  864. //
  865. // Call: MprAdminServerDisconnect
  866. //
  867. // Returns: none.
  868. //
  869. // Description: This is the DLL entrypoint for RouterInterfaceServerDisconnect
  870. //
  871. VOID
  872. MprAdminServerDisconnect(
  873. IN MPR_SERVER_HANDLE hMprServer
  874. )
  875. {
  876. RpcBindingFree( (handle_t *)&hMprServer );
  877. }
  878. //**
  879. //
  880. // Call: MprAdminBufferFree
  881. //
  882. // Returns: none
  883. //
  884. // Description: This is the DLL entrypoint for RouterInterfaceBufferFree
  885. //
  886. DWORD
  887. MprAdminBufferFree(
  888. IN PVOID pBuffer
  889. )
  890. {
  891. if ( pBuffer == NULL )
  892. {
  893. return( ERROR_INVALID_PARAMETER );
  894. }
  895. MIDL_user_free( pBuffer );
  896. return( NO_ERROR );
  897. }
  898. //**
  899. //
  900. // Call: MprAdminTransportCreate
  901. //
  902. // Returns: NO_ERROR - Success
  903. // Non-zero returns - Failure
  904. //
  905. // Description: This is the DLL entrypoint for MprAdminTransportCreate
  906. //
  907. DWORD APIENTRY
  908. MprAdminTransportCreate(
  909. IN MPR_SERVER_HANDLE hMprServer,
  910. IN DWORD dwTransportId,
  911. IN LPWSTR lpwsTransportName OPTIONAL,
  912. IN LPBYTE pGlobalInfo,
  913. IN DWORD dwGlobalInfoSize,
  914. IN LPBYTE pClientInterfaceInfo OPTIONAL,
  915. IN DWORD dwClientInterfaceInfoSize OPTIONAL,
  916. IN LPWSTR lpwsDLLPath
  917. )
  918. {
  919. DWORD dwRetCode;
  920. DIM_INTERFACE_CONTAINER InfoStruct;
  921. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  922. try
  923. {
  924. if ( pGlobalInfo != NULL )
  925. {
  926. InfoStruct.dwGlobalInfoSize = dwGlobalInfoSize;
  927. InfoStruct.pGlobalInfo = pGlobalInfo;
  928. }
  929. if ( pClientInterfaceInfo != NULL )
  930. {
  931. InfoStruct.dwInterfaceInfoSize = dwClientInterfaceInfoSize;
  932. InfoStruct.pInterfaceInfo = pClientInterfaceInfo;
  933. }
  934. }
  935. except( EXCEPTION_EXECUTE_HANDLER )
  936. {
  937. return( ERROR_INVALID_PARAMETER );
  938. }
  939. RpcTryExcept
  940. {
  941. dwRetCode = RRouterInterfaceTransportCreate(
  942. hMprServer,
  943. dwTransportId,
  944. lpwsTransportName,
  945. &InfoStruct,
  946. lpwsDLLPath );
  947. }
  948. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  949. {
  950. dwRetCode = RpcExceptionCode();
  951. }
  952. RpcEndExcept
  953. return( dwRetCode );
  954. }
  955. //**
  956. //
  957. // Call: MprAdminTransportSetInfo
  958. //
  959. // Returns: NO_ERROR - success
  960. // ERROR_INVALID_PARAMETER
  961. // non-zero return codes from
  962. // RRouterInterfaceTransportSetGlobalInfo
  963. //
  964. // Description: This is the DLL entrypoint for
  965. // RouterInterfaceTransportSetGlobalInfo
  966. //
  967. DWORD APIENTRY
  968. MprAdminTransportSetInfo(
  969. IN MPR_SERVER_HANDLE hMprServer,
  970. IN DWORD dwTransportId,
  971. IN LPBYTE pGlobalInfo OPTIONAL,
  972. IN DWORD dwGlobalInfoSize,
  973. IN LPBYTE pClientInterfaceInfo OPTIONAL,
  974. IN DWORD dwClientInterfaceInfoSize
  975. )
  976. {
  977. DWORD dwRetCode;
  978. DIM_INTERFACE_CONTAINER InfoStruct;
  979. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  980. //
  981. // Make sure that all pointers passed in are valid
  982. //
  983. if ( ( pGlobalInfo == NULL ) && ( pClientInterfaceInfo == NULL ) )
  984. {
  985. return( ERROR_INVALID_PARAMETER );
  986. }
  987. try
  988. {
  989. if ( pGlobalInfo != NULL )
  990. {
  991. InfoStruct.dwGlobalInfoSize = dwGlobalInfoSize;
  992. InfoStruct.pGlobalInfo = pGlobalInfo;
  993. }
  994. if ( pClientInterfaceInfo != NULL )
  995. {
  996. InfoStruct.dwInterfaceInfoSize = dwClientInterfaceInfoSize;
  997. InfoStruct.pInterfaceInfo = pClientInterfaceInfo;
  998. }
  999. }
  1000. except( EXCEPTION_EXECUTE_HANDLER )
  1001. {
  1002. return( ERROR_INVALID_PARAMETER );
  1003. }
  1004. RpcTryExcept
  1005. {
  1006. dwRetCode = RRouterInterfaceTransportSetGlobalInfo(
  1007. hMprServer,
  1008. dwTransportId,
  1009. &InfoStruct );
  1010. }
  1011. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1012. {
  1013. dwRetCode = RpcExceptionCode();
  1014. }
  1015. RpcEndExcept
  1016. return( dwRetCode );
  1017. }
  1018. //**
  1019. //
  1020. // Call: MprAdminTransportGetInfo
  1021. //
  1022. // Returns: NO_ERROR - success
  1023. // ERROR_INVALID_PARAMETER
  1024. // non-zero return codes from
  1025. // RRouterInterfaceTransportGetGlobalInfo
  1026. //
  1027. // Description: This is the DLL entrypoint for
  1028. // RouterInterfaceTransportGetGlobalInfo
  1029. //
  1030. DWORD APIENTRY
  1031. MprAdminTransportGetInfo(
  1032. IN MPR_SERVER_HANDLE hMprServer,
  1033. IN DWORD dwTransportId,
  1034. OUT LPBYTE * ppGlobalInfo OPTIONAL,
  1035. OUT LPDWORD lpdwGlobalInfoSize OPTIONAL,
  1036. OUT LPBYTE * ppClientInterfaceInfo OPTIONAL,
  1037. OUT LPDWORD lpdwClientInterfaceInfoSize OPTIONAL
  1038. )
  1039. {
  1040. DWORD dwRetCode;
  1041. DIM_INTERFACE_CONTAINER InfoStruct;
  1042. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1043. if ( ( ppGlobalInfo == NULL ) && ( ppClientInterfaceInfo == NULL ) )
  1044. {
  1045. return( ERROR_INVALID_PARAMETER );
  1046. }
  1047. //
  1048. // Make sure that all pointers passed in are valid
  1049. //
  1050. try
  1051. {
  1052. if ( ppGlobalInfo != NULL )
  1053. {
  1054. *ppGlobalInfo = NULL;
  1055. InfoStruct.fGetGlobalInfo = TRUE;
  1056. }
  1057. if ( ppClientInterfaceInfo != NULL )
  1058. {
  1059. *ppClientInterfaceInfo = NULL;
  1060. InfoStruct.fGetInterfaceInfo = TRUE;
  1061. }
  1062. }
  1063. except( EXCEPTION_EXECUTE_HANDLER )
  1064. {
  1065. return( ERROR_INVALID_PARAMETER );
  1066. }
  1067. RpcTryExcept
  1068. {
  1069. dwRetCode = RRouterInterfaceTransportGetGlobalInfo(
  1070. hMprServer,
  1071. dwTransportId,
  1072. &InfoStruct );
  1073. }
  1074. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1075. {
  1076. dwRetCode = RpcExceptionCode();
  1077. }
  1078. RpcEndExcept
  1079. if ( dwRetCode == NO_ERROR )
  1080. {
  1081. if ( InfoStruct.pGlobalInfo != NULL )
  1082. {
  1083. *ppGlobalInfo = (LPBYTE)(InfoStruct.pGlobalInfo);
  1084. if ( lpdwGlobalInfoSize != NULL )
  1085. {
  1086. *lpdwGlobalInfoSize = InfoStruct.dwGlobalInfoSize;
  1087. }
  1088. }
  1089. if ( InfoStruct.pInterfaceInfo != NULL )
  1090. {
  1091. *ppClientInterfaceInfo = (LPBYTE)(InfoStruct.pInterfaceInfo);
  1092. if ( lpdwClientInterfaceInfoSize != NULL )
  1093. {
  1094. *lpdwClientInterfaceInfoSize = InfoStruct.dwInterfaceInfoSize;
  1095. }
  1096. }
  1097. }
  1098. return( dwRetCode );
  1099. }
  1100. DWORD APIENTRY
  1101. MprAdminDeviceEnum(
  1102. IN MPR_SERVER_HANDLE hMprServer,
  1103. IN DWORD dwLevel,
  1104. OUT LPBYTE* lplpbBuffer,
  1105. OUT LPDWORD lpdwTotalEntries)
  1106. {
  1107. DWORD dwRetCode;
  1108. DIM_INFORMATION_CONTAINER InfoStruct;
  1109. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1110. if ( dwLevel != 0 )
  1111. {
  1112. return ERROR_NOT_SUPPORTED;
  1113. }
  1114. //
  1115. // Make sure that all pointers passed in are valid
  1116. //
  1117. try
  1118. {
  1119. *lplpbBuffer;
  1120. *lpdwTotalEntries;
  1121. }
  1122. except( EXCEPTION_EXECUTE_HANDLER )
  1123. {
  1124. return( ERROR_INVALID_PARAMETER );
  1125. }
  1126. RpcTryExcept
  1127. {
  1128. dwRetCode = RRouterDeviceEnum(
  1129. hMprServer,
  1130. dwLevel,
  1131. &InfoStruct,
  1132. lpdwTotalEntries );
  1133. }
  1134. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1135. {
  1136. dwRetCode = RpcExceptionCode();
  1137. }
  1138. RpcEndExcept
  1139. if ( dwRetCode == NO_ERROR )
  1140. {
  1141. // Assign the return value
  1142. //
  1143. *lplpbBuffer = (LPBYTE)(InfoStruct.pBuffer);
  1144. }
  1145. return( dwRetCode );
  1146. }
  1147. //**
  1148. //
  1149. // Call: MprAdminInterfaceCreate
  1150. //
  1151. // Returns: NO_ERROR - success
  1152. // ERROR_INVALID_PARAMETER
  1153. // non-zero return codes from RRouterInterfaceCreate
  1154. //
  1155. // Description: This is the DLL entrypoint for RouterInterfaceCreate
  1156. //
  1157. DWORD APIENTRY
  1158. MprAdminInterfaceCreate(
  1159. IN MPR_SERVER_HANDLE hMprServer,
  1160. IN DWORD dwLevel,
  1161. IN LPBYTE lpbBuffer,
  1162. OUT HANDLE * phInterface
  1163. )
  1164. {
  1165. DWORD dwRetCode = NO_ERROR, dwInterface = 0;
  1166. DIM_INFORMATION_CONTAINER InfoStruct;
  1167. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1168. //
  1169. // Make sure that all pointers passed in are valid
  1170. //
  1171. try
  1172. {
  1173. *phInterface = INVALID_HANDLE_VALUE;
  1174. *lpbBuffer;
  1175. //
  1176. // Set up the interface information
  1177. //
  1178. dwRetCode = MprThunkInterface_HtoW(
  1179. dwLevel,
  1180. lpbBuffer,
  1181. &InfoStruct.pBuffer,
  1182. &InfoStruct.dwBufferSize);
  1183. }
  1184. except( EXCEPTION_EXECUTE_HANDLER )
  1185. {
  1186. return( ERROR_INVALID_PARAMETER );
  1187. }
  1188. if ( dwRetCode != NO_ERROR )
  1189. {
  1190. return( dwRetCode );
  1191. }
  1192. RpcTryExcept
  1193. {
  1194. dwRetCode = RRouterInterfaceCreate(
  1195. hMprServer,
  1196. dwLevel,
  1197. &InfoStruct,
  1198. &dwInterface );
  1199. if (dwRetCode == NO_ERROR)
  1200. {
  1201. *phInterface = UlongToPtr(dwInterface);
  1202. }
  1203. }
  1204. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1205. {
  1206. dwRetCode = RpcExceptionCode();
  1207. }
  1208. RpcEndExcept
  1209. MprThunkInterfaceFree( InfoStruct.pBuffer, dwLevel );
  1210. return( dwRetCode );
  1211. }
  1212. //
  1213. // Call: MprAdminInterfaceGetInfo
  1214. //
  1215. // Returns: NO_ERROR - success
  1216. // ERROR_INVALID_PARAMETER
  1217. // non-zero return codes from RRouterInterfaceGetInfo
  1218. //
  1219. // Description: This is the DLL entrypoint for RouterInterfaceGetInfo
  1220. //
  1221. DWORD APIENTRY
  1222. MprAdminInterfaceGetInfo(
  1223. IN MPR_SERVER_HANDLE hMprServer,
  1224. IN HANDLE hInterface,
  1225. IN DWORD dwLevel,
  1226. IN LPBYTE * lplpbBuffer
  1227. )
  1228. {
  1229. DWORD dwRetCode;
  1230. DIM_INFORMATION_CONTAINER InfoStruct;
  1231. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1232. //
  1233. // Make sure that all pointers passed in are valid
  1234. //
  1235. try
  1236. {
  1237. *lplpbBuffer;
  1238. }
  1239. except( EXCEPTION_EXECUTE_HANDLER )
  1240. {
  1241. return( ERROR_INVALID_PARAMETER );
  1242. }
  1243. RpcTryExcept
  1244. {
  1245. dwRetCode = RRouterInterfaceGetInfo(
  1246. hMprServer,
  1247. dwLevel,
  1248. &InfoStruct,
  1249. PtrToUlong(hInterface) );
  1250. }
  1251. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1252. {
  1253. dwRetCode = RpcExceptionCode();
  1254. }
  1255. RpcEndExcept
  1256. if ( ( dwRetCode == NO_ERROR ) && ( InfoStruct.pBuffer != NULL ) )
  1257. {
  1258. dwRetCode =
  1259. MprThunkInterface_WtoH(
  1260. dwLevel,
  1261. InfoStruct.pBuffer,
  1262. InfoStruct.dwBufferSize,
  1263. 1,
  1264. MprAdminAlloc,
  1265. MprAdminFree,
  1266. lplpbBuffer);
  1267. }
  1268. return( dwRetCode );
  1269. }
  1270. //**
  1271. //
  1272. // Call: MprAdminInterfaceSetInfo
  1273. //
  1274. // Returns: NO_ERROR - success
  1275. // ERROR_INVALID_PARAMETER
  1276. // non-zero return codes from RRouterInterfaceSetInfo
  1277. //
  1278. // Description: This is the DLL entrypoint for RouterInterfaceSetInfo
  1279. //
  1280. DWORD APIENTRY
  1281. MprAdminInterfaceSetInfo(
  1282. IN MPR_SERVER_HANDLE hMprServer,
  1283. IN HANDLE hInterface,
  1284. IN DWORD dwLevel,
  1285. IN LPBYTE lpbBuffer
  1286. )
  1287. {
  1288. DWORD dwRetCode;
  1289. DIM_INFORMATION_CONTAINER InfoStruct;
  1290. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1291. //
  1292. // Make sure that all pointers passed in are valid
  1293. //
  1294. try
  1295. {
  1296. *lpbBuffer;
  1297. //
  1298. // Set up the interface information
  1299. //
  1300. dwRetCode = MprThunkInterface_HtoW(
  1301. dwLevel,
  1302. lpbBuffer,
  1303. &InfoStruct.pBuffer,
  1304. &InfoStruct.dwBufferSize);
  1305. }
  1306. except( EXCEPTION_EXECUTE_HANDLER )
  1307. {
  1308. return( ERROR_INVALID_PARAMETER );
  1309. }
  1310. if ( dwRetCode != NO_ERROR )
  1311. {
  1312. return( dwRetCode );
  1313. }
  1314. RpcTryExcept
  1315. {
  1316. dwRetCode = RRouterInterfaceSetInfo(
  1317. hMprServer,
  1318. dwLevel,
  1319. &InfoStruct,
  1320. PtrToUlong(hInterface) );
  1321. }
  1322. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1323. {
  1324. dwRetCode = RpcExceptionCode();
  1325. }
  1326. RpcEndExcept
  1327. MprThunkInterfaceFree( &InfoStruct.pBuffer, dwLevel );
  1328. return( dwRetCode );
  1329. }
  1330. DWORD APIENTRY
  1331. MprAdminInterfaceDeviceGetInfo(
  1332. IN MPR_SERVER_HANDLE hMprServer,
  1333. IN HANDLE hInterface,
  1334. IN DWORD dwIndex,
  1335. IN DWORD dwLevel,
  1336. OUT LPBYTE* lplpBuffer)
  1337. {
  1338. DWORD dwRetCode = NO_ERROR;
  1339. DIM_INFORMATION_CONTAINER InfoStruct;
  1340. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1341. if ( ( (int) dwLevel < 0 ) || ( dwLevel > 1 ) )
  1342. {
  1343. return ERROR_NOT_SUPPORTED;
  1344. }
  1345. //
  1346. // Make sure that all pointers passed in are valid
  1347. //
  1348. try
  1349. {
  1350. *lplpBuffer;
  1351. }
  1352. except( EXCEPTION_EXECUTE_HANDLER )
  1353. {
  1354. return( ERROR_INVALID_PARAMETER );
  1355. }
  1356. if (dwRetCode != NO_ERROR)
  1357. {
  1358. return ( dwRetCode );
  1359. }
  1360. RpcTryExcept
  1361. {
  1362. dwRetCode = RRouterInterfaceDeviceGetInfo(
  1363. hMprServer,
  1364. dwLevel,
  1365. &InfoStruct,
  1366. dwIndex,
  1367. PtrToUlong(hInterface) );
  1368. }
  1369. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1370. {
  1371. dwRetCode = RpcExceptionCode();
  1372. }
  1373. RpcEndExcept
  1374. // Process return values
  1375. //
  1376. if ( dwRetCode == NO_ERROR )
  1377. {
  1378. // Fix any variable length structure pointers
  1379. //
  1380. switch ( dwLevel )
  1381. {
  1382. case 0:
  1383. break;
  1384. case 1:
  1385. {
  1386. MPR_DEVICE_1* pDev1 =
  1387. (MPR_DEVICE_1*)InfoStruct.pBuffer;
  1388. if ( ( InfoStruct.dwBufferSize != 0 ) &&
  1389. ( pDev1 != NULL ) &&
  1390. ( pDev1->szAlternates != NULL )
  1391. )
  1392. {
  1393. pDev1->szAlternates = (PWCHAR) (pDev1 + 1);
  1394. }
  1395. }
  1396. break;
  1397. }
  1398. // Assign the return value
  1399. //
  1400. if ( InfoStruct.dwBufferSize != 0 )
  1401. {
  1402. *lplpBuffer = InfoStruct.pBuffer;
  1403. }
  1404. }
  1405. return( dwRetCode );
  1406. }
  1407. DWORD APIENTRY
  1408. MprAdminInterfaceDeviceSetInfo(
  1409. IN MPR_SERVER_HANDLE hMprServer,
  1410. IN HANDLE hInterface,
  1411. IN DWORD dwIndex,
  1412. IN DWORD dwLevel,
  1413. OUT LPBYTE lpbBuffer)
  1414. {
  1415. DWORD dwRetCode = NO_ERROR, dwAltSize = 0;
  1416. DIM_INFORMATION_CONTAINER InfoStruct;
  1417. MPR_DEVICE_0* pDev0 = (MPR_DEVICE_0*)lpbBuffer;
  1418. MPR_DEVICE_1* pDev1 = (MPR_DEVICE_1*)lpbBuffer;
  1419. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1420. //
  1421. // Make sure that all pointers passed in are valid
  1422. //
  1423. try
  1424. {
  1425. *lpbBuffer;
  1426. //
  1427. // Set up the interface information
  1428. //
  1429. switch ( dwLevel )
  1430. {
  1431. case 0:
  1432. InfoStruct.dwBufferSize = sizeof(MPR_DEVICE_0);
  1433. InfoStruct.pBuffer = (LPBYTE)pDev0;
  1434. break;
  1435. case 1:
  1436. dwAltSize = MprUtilGetSizeOfMultiSz(pDev1->szAlternates);
  1437. if ( pDev1->szAlternates == NULL )
  1438. {
  1439. InfoStruct.dwBufferSize = sizeof(MPR_DEVICE_1);
  1440. InfoStruct.pBuffer = (LPBYTE)pDev1;
  1441. break;
  1442. }
  1443. InfoStruct.dwBufferSize = sizeof(MPR_DEVICE_1) + dwAltSize;
  1444. InfoStruct.pBuffer =
  1445. LocalAlloc(LPTR, InfoStruct.dwBufferSize);
  1446. if ( InfoStruct.pBuffer == NULL )
  1447. {
  1448. dwRetCode = ERROR_NOT_ENOUGH_MEMORY;
  1449. break;
  1450. }
  1451. CopyMemory(
  1452. InfoStruct.pBuffer,
  1453. pDev1,
  1454. sizeof(MPR_DEVICE_1));
  1455. ((MPR_DEVICE_1*)InfoStruct.pBuffer)->szAlternates =
  1456. (PWCHAR) InfoStruct.pBuffer + sizeof(MPR_DEVICE_1);
  1457. CopyMemory(
  1458. InfoStruct.pBuffer + sizeof(MPR_DEVICE_1),
  1459. pDev1->szAlternates,
  1460. dwAltSize);
  1461. break;
  1462. default:
  1463. dwRetCode = ERROR_NOT_SUPPORTED;
  1464. break;
  1465. }
  1466. }
  1467. except( EXCEPTION_EXECUTE_HANDLER )
  1468. {
  1469. return( ERROR_INVALID_PARAMETER );
  1470. }
  1471. if (dwRetCode != NO_ERROR)
  1472. {
  1473. return ( dwRetCode );
  1474. }
  1475. RpcTryExcept
  1476. {
  1477. dwRetCode = RRouterInterfaceDeviceSetInfo(
  1478. hMprServer,
  1479. dwLevel,
  1480. &InfoStruct,
  1481. dwIndex,
  1482. PtrToUlong(hInterface) );
  1483. }
  1484. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1485. {
  1486. dwRetCode = RpcExceptionCode();
  1487. }
  1488. RpcEndExcept
  1489. if ( dwLevel == 1 )
  1490. {
  1491. if (InfoStruct.pBuffer == NULL)
  1492. {
  1493. LocalFree( InfoStruct.pBuffer );
  1494. }
  1495. }
  1496. return( dwRetCode );
  1497. }
  1498. //**
  1499. //
  1500. // Call: MprAdminInterfaceGetHandle
  1501. //
  1502. // Returns: NO_ERROR - success
  1503. // ERROR_INVALID_PARAMETER
  1504. // non-zero return codes from RRouterInterfaceGetHandle
  1505. //
  1506. // Description: This is the DLL entrypoint for RouterInterfaceGetHandle
  1507. //
  1508. DWORD APIENTRY
  1509. MprAdminInterfaceGetHandle(
  1510. IN MPR_SERVER_HANDLE hMprServer,
  1511. IN LPWSTR lpwsInterfaceName,
  1512. IN OUT HANDLE * phInterface,
  1513. IN BOOL fIncludeClientInterfaces
  1514. )
  1515. {
  1516. DWORD dwRetCode, dwInterface = 0;
  1517. //
  1518. // Make sure that all pointers passed in are valid
  1519. //
  1520. try
  1521. {
  1522. *phInterface = INVALID_HANDLE_VALUE;
  1523. }
  1524. except( EXCEPTION_EXECUTE_HANDLER )
  1525. {
  1526. return( ERROR_INVALID_PARAMETER );
  1527. }
  1528. RpcTryExcept
  1529. {
  1530. dwRetCode = RRouterInterfaceGetHandle(
  1531. hMprServer,
  1532. lpwsInterfaceName,
  1533. &dwInterface,
  1534. (DWORD)fIncludeClientInterfaces );
  1535. if (dwRetCode == NO_ERROR)
  1536. {
  1537. *phInterface = UlongToPtr(dwInterface);
  1538. }
  1539. }
  1540. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1541. {
  1542. dwRetCode = RpcExceptionCode();
  1543. }
  1544. RpcEndExcept
  1545. return( dwRetCode );
  1546. }
  1547. //**
  1548. //
  1549. // Call: MprAdminInterfaceDelete
  1550. //
  1551. // Returns: NO_ERROR - success
  1552. // ERROR_INVALID_PARAMETER
  1553. // non-zero return codes from RRouterInterfaceDelete
  1554. //
  1555. // Description: This is the DLL entrypoint for RouterInterfaceDelete
  1556. //
  1557. DWORD APIENTRY
  1558. MprAdminInterfaceDelete(
  1559. IN MPR_SERVER_HANDLE hMprServer,
  1560. IN HANDLE hInterface
  1561. )
  1562. {
  1563. DWORD dwRetCode;
  1564. RpcTryExcept
  1565. {
  1566. dwRetCode = RRouterInterfaceDelete(
  1567. hMprServer,
  1568. PtrToUlong(hInterface) );
  1569. }
  1570. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1571. {
  1572. dwRetCode = RpcExceptionCode();
  1573. }
  1574. RpcEndExcept
  1575. return( dwRetCode );
  1576. }
  1577. //**
  1578. //
  1579. // Call: MprAdminInterfaceTransportRemove
  1580. //
  1581. // Returns: NO_ERROR - success
  1582. // ERROR_INVALID_PARAMETER
  1583. // non-zero return codes from RRouterInterfaceTransportRemove
  1584. //
  1585. // Description: This is the DLL entrypoint for RouterInterfaceTransportRemove
  1586. //
  1587. DWORD APIENTRY
  1588. MprAdminInterfaceTransportRemove(
  1589. IN MPR_SERVER_HANDLE hMprServer,
  1590. IN HANDLE hInterface,
  1591. IN DWORD dwTransportId
  1592. )
  1593. {
  1594. DWORD dwRetCode;
  1595. RpcTryExcept
  1596. {
  1597. dwRetCode = RRouterInterfaceTransportRemove(
  1598. hMprServer,
  1599. PtrToUlong(hInterface),
  1600. dwTransportId );
  1601. }
  1602. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1603. {
  1604. dwRetCode = RpcExceptionCode();
  1605. }
  1606. RpcEndExcept
  1607. return( dwRetCode );
  1608. }
  1609. //**
  1610. //
  1611. // Call: MprAdminInterfaceEnum
  1612. //
  1613. // Returns: NO_ERROR - success
  1614. // ERROR_INVALID_PARAMETER
  1615. // non-zero returns from RRouterInterfaceEnum
  1616. //
  1617. // Description: This is the DLL entry point for RouterInterfaceEnum.
  1618. //
  1619. DWORD APIENTRY
  1620. MprAdminInterfaceEnum(
  1621. IN MPR_SERVER_HANDLE hMprServer,
  1622. IN DWORD dwLevel,
  1623. OUT LPBYTE * lplpbBuffer,
  1624. IN DWORD dwPrefMaxLen,
  1625. OUT LPDWORD lpdwEntriesRead,
  1626. OUT LPDWORD lpdwTotalEntries,
  1627. IN LPDWORD lpdwResumeHandle OPTIONAL
  1628. )
  1629. {
  1630. DWORD dwRetCode;
  1631. DIM_INFORMATION_CONTAINER InfoStruct;
  1632. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1633. //
  1634. // Touch all pointers
  1635. //
  1636. try
  1637. {
  1638. *lplpbBuffer = NULL;
  1639. *lpdwEntriesRead = 0;
  1640. *lpdwTotalEntries = 0;
  1641. if ( lpdwResumeHandle )
  1642. {
  1643. *lpdwResumeHandle;
  1644. }
  1645. }
  1646. except( EXCEPTION_EXECUTE_HANDLER )
  1647. {
  1648. return( ERROR_INVALID_PARAMETER );
  1649. }
  1650. RpcTryExcept
  1651. {
  1652. dwRetCode = RRouterInterfaceEnum(
  1653. hMprServer,
  1654. dwLevel,
  1655. &InfoStruct,
  1656. dwPrefMaxLen,
  1657. lpdwEntriesRead,
  1658. lpdwTotalEntries,
  1659. lpdwResumeHandle );
  1660. if ( InfoStruct.pBuffer != NULL)
  1661. {
  1662. dwRetCode =
  1663. MprThunkInterface_WtoH(
  1664. dwLevel,
  1665. InfoStruct.pBuffer,
  1666. InfoStruct.dwBufferSize,
  1667. *lpdwEntriesRead,
  1668. MprAdminAlloc,
  1669. MprAdminFree,
  1670. lplpbBuffer);
  1671. }
  1672. }
  1673. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1674. {
  1675. dwRetCode = RpcExceptionCode();
  1676. }
  1677. RpcEndExcept
  1678. return( dwRetCode );
  1679. }
  1680. //**
  1681. //
  1682. // Call: MprAdminInterfaceTransportGetInfo
  1683. //
  1684. // Returns: NO_ERROR - success
  1685. // ERROR_INVALID_PARAMETER
  1686. // non-zero return codes from RRouterInterfaceTransportGetInfo
  1687. //
  1688. // Description: This is the DLL entrypoint for RouterInterfaceTransportGetInfo
  1689. //
  1690. DWORD APIENTRY
  1691. MprAdminInterfaceTransportGetInfo(
  1692. IN MPR_SERVER_HANDLE hMprServer,
  1693. IN HANDLE hInterface,
  1694. IN DWORD dwTransportId,
  1695. OUT LPBYTE * ppInterfaceInfo,
  1696. OUT LPDWORD lpdwInterfaceInfoSize
  1697. )
  1698. {
  1699. DWORD dwRetCode;
  1700. DIM_INTERFACE_CONTAINER InfoStruct;
  1701. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1702. if ( ppInterfaceInfo == NULL )
  1703. {
  1704. return( ERROR_INVALID_PARAMETER );
  1705. }
  1706. //
  1707. // Make sure that all pointers passed in are valid
  1708. //
  1709. try
  1710. {
  1711. if ( ppInterfaceInfo != NULL )
  1712. {
  1713. *ppInterfaceInfo = NULL;
  1714. InfoStruct.fGetInterfaceInfo = TRUE;
  1715. }
  1716. }
  1717. except( EXCEPTION_EXECUTE_HANDLER )
  1718. {
  1719. return( ERROR_INVALID_PARAMETER );
  1720. }
  1721. RpcTryExcept
  1722. {
  1723. dwRetCode = RRouterInterfaceTransportGetInfo(
  1724. hMprServer,
  1725. PtrToUlong(hInterface),
  1726. dwTransportId,
  1727. &InfoStruct );
  1728. }
  1729. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1730. {
  1731. dwRetCode = RpcExceptionCode();
  1732. }
  1733. RpcEndExcept
  1734. if ( dwRetCode == NO_ERROR )
  1735. {
  1736. *ppInterfaceInfo = (LPBYTE)(InfoStruct.pInterfaceInfo);
  1737. if ( lpdwInterfaceInfoSize != NULL )
  1738. {
  1739. *lpdwInterfaceInfoSize = InfoStruct.dwInterfaceInfoSize;
  1740. }
  1741. }
  1742. return( dwRetCode );
  1743. }
  1744. //**
  1745. //
  1746. // Call: MprAdminInterfaceTransportAdd
  1747. //
  1748. // Returns: NO_ERROR - success
  1749. // ERROR_INVALID_PARAMETER
  1750. // non-zero return codes from RRouterInterfaceTransportAdd
  1751. //
  1752. // Description: This is the DLL entrypoint for RouterInterfaceTransportAdd
  1753. //
  1754. DWORD APIENTRY
  1755. MprAdminInterfaceTransportAdd(
  1756. IN MPR_SERVER_HANDLE hMprServer,
  1757. IN HANDLE hInterface,
  1758. IN DWORD dwTransportId,
  1759. IN LPBYTE pInterfaceInfo,
  1760. IN DWORD dwInterfaceInfoSize
  1761. )
  1762. {
  1763. DWORD dwRetCode;
  1764. DIM_INTERFACE_CONTAINER InfoStruct;
  1765. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1766. //
  1767. // Make sure that all pointers passed in are valid
  1768. //
  1769. if ( pInterfaceInfo == NULL )
  1770. {
  1771. return( ERROR_INVALID_PARAMETER );
  1772. }
  1773. try
  1774. {
  1775. if ( pInterfaceInfo != NULL )
  1776. {
  1777. InfoStruct.pInterfaceInfo = pInterfaceInfo;
  1778. InfoStruct.dwInterfaceInfoSize = dwInterfaceInfoSize;
  1779. }
  1780. }
  1781. except( EXCEPTION_EXECUTE_HANDLER )
  1782. {
  1783. return( ERROR_INVALID_PARAMETER );
  1784. }
  1785. RpcTryExcept
  1786. {
  1787. dwRetCode = RRouterInterfaceTransportAdd(
  1788. hMprServer,
  1789. PtrToUlong(hInterface),
  1790. dwTransportId,
  1791. &InfoStruct );
  1792. }
  1793. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1794. {
  1795. dwRetCode = RpcExceptionCode();
  1796. }
  1797. RpcEndExcept
  1798. return( dwRetCode );
  1799. }
  1800. //**
  1801. //
  1802. // Call: MprAdminInterfaceTransportSetInfo
  1803. //
  1804. // Returns: NO_ERROR - success
  1805. // ERROR_INVALID_PARAMETER
  1806. // non-zero return codes from RRouterInterfaceTransportSetInfo
  1807. //
  1808. // Description: This is the DLL entrypoint for RouterInterfaceTransportSetInfo
  1809. //
  1810. DWORD APIENTRY
  1811. MprAdminInterfaceTransportSetInfo(
  1812. IN MPR_SERVER_HANDLE hMprServer,
  1813. IN HANDLE hInterface,
  1814. IN DWORD dwTransportId,
  1815. IN LPBYTE pInterfaceInfo OPTIONAL,
  1816. IN DWORD dwInterfaceInfoSize
  1817. )
  1818. {
  1819. DWORD dwRetCode;
  1820. DIM_INTERFACE_CONTAINER InfoStruct;
  1821. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  1822. //
  1823. // Make sure that all pointers passed in are valid
  1824. //
  1825. if ( pInterfaceInfo == NULL )
  1826. {
  1827. return( ERROR_INVALID_PARAMETER );
  1828. }
  1829. try
  1830. {
  1831. if ( pInterfaceInfo != NULL )
  1832. {
  1833. InfoStruct.dwInterfaceInfoSize = dwInterfaceInfoSize;
  1834. InfoStruct.pInterfaceInfo = pInterfaceInfo;
  1835. }
  1836. }
  1837. except( EXCEPTION_EXECUTE_HANDLER )
  1838. {
  1839. return( ERROR_INVALID_PARAMETER );
  1840. }
  1841. RpcTryExcept
  1842. {
  1843. dwRetCode = RRouterInterfaceTransportSetInfo(
  1844. hMprServer,
  1845. PtrToUlong(hInterface),
  1846. dwTransportId,
  1847. &InfoStruct );
  1848. }
  1849. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1850. {
  1851. dwRetCode = RpcExceptionCode();
  1852. }
  1853. RpcEndExcept
  1854. return( dwRetCode );
  1855. }
  1856. //**
  1857. //
  1858. // Call: MprAdminInterfaceUpdateRoutes
  1859. //
  1860. // Returns: NO_ERROR - success
  1861. // ERROR_INVALID_PARAMETER
  1862. // non-zero return codes from
  1863. //
  1864. // Description: This is the DLL entrypoint for RouterInterfaceUpdateRoutes
  1865. //
  1866. //
  1867. DWORD APIENTRY
  1868. MprAdminInterfaceUpdateRoutes(
  1869. IN MPR_SERVER_HANDLE hMprServer,
  1870. IN HANDLE hDimInterface,
  1871. IN DWORD dwPid,
  1872. IN HANDLE hEvent
  1873. )
  1874. {
  1875. DWORD dwRetCode;
  1876. DWORD dwCurrentProcessId = GetCurrentProcessId();
  1877. RpcTryExcept
  1878. {
  1879. dwRetCode = RRouterInterfaceUpdateRoutes(
  1880. hMprServer,
  1881. PtrToUlong(hDimInterface),
  1882. dwPid,
  1883. (ULONG_PTR) hEvent,
  1884. dwCurrentProcessId );
  1885. }
  1886. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1887. {
  1888. dwRetCode = RpcExceptionCode();
  1889. }
  1890. RpcEndExcept
  1891. return( dwRetCode );
  1892. }
  1893. //**
  1894. //
  1895. // Call: MprAdminInterfaceQueryUpdateResult
  1896. //
  1897. // Returns: NO_ERROR - success
  1898. // ERROR_INVALID_PARAMETER
  1899. // non-zero return codes from
  1900. //
  1901. // Description: This is the DLL entrypoint for RouterInterfaceQueryUpdateResult
  1902. //
  1903. DWORD APIENTRY
  1904. MprAdminInterfaceQueryUpdateResult(
  1905. IN MPR_SERVER_HANDLE hMprServer,
  1906. IN HANDLE hDimInterface,
  1907. IN DWORD dwPid,
  1908. OUT LPDWORD lpdwUpdateResult
  1909. )
  1910. {
  1911. DWORD dwRetCode;
  1912. //
  1913. // Make sure that all pointers passed in are valid
  1914. //
  1915. try
  1916. {
  1917. *lpdwUpdateResult = 0;
  1918. }
  1919. except( EXCEPTION_EXECUTE_HANDLER )
  1920. {
  1921. return( ERROR_INVALID_PARAMETER );
  1922. }
  1923. RpcTryExcept
  1924. {
  1925. dwRetCode = RRouterInterfaceQueryUpdateResult(
  1926. hMprServer,
  1927. PtrToUlong(hDimInterface),
  1928. dwPid,
  1929. lpdwUpdateResult );
  1930. }
  1931. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  1932. {
  1933. dwRetCode = RpcExceptionCode();
  1934. }
  1935. RpcEndExcept
  1936. return( dwRetCode );
  1937. }
  1938. //**
  1939. //
  1940. // Call: MprAdminGetErrorString
  1941. //
  1942. // Returns: NO_ERROR - success
  1943. // ERROR_INVALID_PARAMETER
  1944. //
  1945. // Description: This is the DLL entrypoint for MprAdminGetErrorString
  1946. //
  1947. DWORD APIENTRY
  1948. MprAdminGetErrorString(
  1949. IN DWORD dwError,
  1950. OUT LPWSTR * lplpwsErrorString
  1951. )
  1952. {
  1953. DWORD dwRetCode = NO_ERROR;
  1954. DWORD dwFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER;
  1955. DWORD dwBufferSize;
  1956. HINSTANCE hDll = NULL;
  1957. if ( ( ( dwError >= RASBASE ) && ( dwError <= RASBASEEND ) ) ||
  1958. ( ( dwError >= ROUTEBASE ) && ( dwError <= ROUTEBASEEND ) ) )
  1959. {
  1960. dwFlags |= FORMAT_MESSAGE_FROM_HMODULE;
  1961. hDll=LoadLibrary(TEXT("mprmsg.dll") );
  1962. if ( hDll == NULL )
  1963. {
  1964. return( GetLastError() );
  1965. }
  1966. }
  1967. else
  1968. {
  1969. dwFlags |= FORMAT_MESSAGE_FROM_SYSTEM;
  1970. }
  1971. dwRetCode = FormatMessage( dwFlags,
  1972. hDll,
  1973. dwError,
  1974. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
  1975. (LPWSTR)lplpwsErrorString,
  1976. 0,
  1977. NULL );
  1978. if ( hDll != NULL )
  1979. {
  1980. FreeLibrary( hDll );
  1981. }
  1982. if ( dwRetCode == 0 )
  1983. {
  1984. return( GetLastError() );
  1985. }
  1986. return( NO_ERROR );
  1987. }
  1988. //**
  1989. //
  1990. // Call: MprAdminInterfaceConnect
  1991. //
  1992. // Returns: NO_ERROR - success
  1993. // ERROR_INVALID_PARAMETER
  1994. // non-zero return codes from RRouterInterfaceConnect
  1995. //
  1996. // Description: This is the DLL entrypoint for RouterInterfaceConnect
  1997. //
  1998. DWORD APIENTRY
  1999. MprAdminInterfaceConnect(
  2000. IN MPR_SERVER_HANDLE hMprServer,
  2001. IN HANDLE hDimInterface,
  2002. IN HANDLE hEvent,
  2003. IN BOOL fBlocking
  2004. )
  2005. {
  2006. DWORD dwRetCode;
  2007. DWORD dwCurrentProcessId = GetCurrentProcessId();
  2008. RpcTryExcept
  2009. {
  2010. dwRetCode = RRouterInterfaceConnect(
  2011. hMprServer,
  2012. PtrToUlong(hDimInterface),
  2013. (ULONG_PTR)hEvent,
  2014. (DWORD)fBlocking,
  2015. dwCurrentProcessId );
  2016. }
  2017. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2018. {
  2019. dwRetCode = RpcExceptionCode();
  2020. }
  2021. RpcEndExcept
  2022. return( dwRetCode );
  2023. }
  2024. //**
  2025. //
  2026. // Call: MprAdminInterfaceDisconnect
  2027. //
  2028. // Returns: NO_ERROR - success
  2029. // ERROR_INVALID_PARAMETER
  2030. // non-zero return codes from RRouterInterfaceDisconnect
  2031. //
  2032. // Description: This is the DLL entrypoint for RouterInterfaceDisconnect
  2033. //
  2034. DWORD APIENTRY
  2035. MprAdminInterfaceDisconnect(
  2036. IN MPR_SERVER_HANDLE hMprServer,
  2037. IN HANDLE hDimInterface
  2038. )
  2039. {
  2040. DWORD dwRetCode;
  2041. RpcTryExcept
  2042. {
  2043. dwRetCode = RRouterInterfaceDisconnect(
  2044. hMprServer,
  2045. PtrToUlong(hDimInterface) );
  2046. }
  2047. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2048. {
  2049. dwRetCode = RpcExceptionCode();
  2050. }
  2051. RpcEndExcept
  2052. return( dwRetCode );
  2053. }
  2054. //**
  2055. //
  2056. // Call: MprAdminInterfaceUpdatePhonebookInfo
  2057. //
  2058. // Returns: NO_ERROR - success
  2059. // ERROR_INVALID_PARAMETER
  2060. // non-zero return codes from RRouterInterfaceUpdatePhonebookInfo
  2061. //
  2062. // Description: This is the DLL entrypoint for
  2063. // RouterInterfaceUpdatePhonebookInfo
  2064. //
  2065. DWORD APIENTRY
  2066. MprAdminInterfaceUpdatePhonebookInfo(
  2067. IN MPR_SERVER_HANDLE hMprServer,
  2068. IN HANDLE hDimInterface
  2069. )
  2070. {
  2071. DWORD dwRetCode;
  2072. RpcTryExcept
  2073. {
  2074. dwRetCode = RRouterInterfaceUpdatePhonebookInfo(
  2075. hMprServer,
  2076. PtrToUlong(hDimInterface) );
  2077. }
  2078. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2079. {
  2080. dwRetCode = RpcExceptionCode();
  2081. }
  2082. RpcEndExcept
  2083. return( dwRetCode );
  2084. }
  2085. DWORD APIENTRY
  2086. MprAdminInterfaceSetCredentialsEx(
  2087. IN MPR_SERVER_HANDLE hMprServer,
  2088. IN HANDLE hInterface,
  2089. IN DWORD dwLevel,
  2090. IN LPBYTE lpbBuffer)
  2091. {
  2092. DWORD dwRetCode = NO_ERROR;
  2093. DIM_INFORMATION_CONTAINER InfoStruct;
  2094. MPR_CREDENTIALSEXI* pCredsI = NULL;
  2095. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  2096. //
  2097. // Make sure that all pointers passed in are valid
  2098. //
  2099. try
  2100. {
  2101. *lpbBuffer;
  2102. //
  2103. // Set up the interface information
  2104. //
  2105. switch ( dwLevel )
  2106. {
  2107. case 0:
  2108. {
  2109. MPR_CREDENTIALSEX_0* pCredsEx0 =
  2110. (MPR_CREDENTIALSEX_0*)lpbBuffer;
  2111. dwRetCode = MprThunkCredentials_HtoW(
  2112. dwLevel,
  2113. (PBYTE) pCredsEx0,
  2114. MprThunkAlloc,
  2115. &InfoStruct.dwBufferSize,
  2116. &InfoStruct.pBuffer);
  2117. break;
  2118. }
  2119. case 1:
  2120. case 2:
  2121. {
  2122. MPR_CREDENTIALSEX_1* pCredsEx1 =
  2123. (MPR_CREDENTIALSEX_1 *)lpbBuffer;
  2124. dwRetCode = MprThunkCredentials_HtoW(
  2125. dwLevel,
  2126. (PBYTE) pCredsEx1,
  2127. MprThunkAlloc,
  2128. &InfoStruct.dwBufferSize,
  2129. &InfoStruct.pBuffer);
  2130. break;
  2131. }
  2132. default:
  2133. dwRetCode = ERROR_NOT_SUPPORTED;
  2134. break;
  2135. }
  2136. }
  2137. except( EXCEPTION_EXECUTE_HANDLER )
  2138. {
  2139. return( ERROR_INVALID_PARAMETER );
  2140. }
  2141. if (dwRetCode != NO_ERROR)
  2142. {
  2143. return ( dwRetCode );
  2144. }
  2145. RpcTryExcept
  2146. {
  2147. dwRetCode = RRouterInterfaceSetCredentialsEx(
  2148. hMprServer,
  2149. dwLevel,
  2150. &InfoStruct,
  2151. PtrToUlong(hInterface) );
  2152. }
  2153. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2154. {
  2155. dwRetCode = RpcExceptionCode();
  2156. }
  2157. RpcEndExcept
  2158. if ( dwLevel == 0 )
  2159. {
  2160. if (InfoStruct.pBuffer == NULL)
  2161. {
  2162. ZeroMemory(InfoStruct.pBuffer, InfoStruct.dwBufferSize);
  2163. MprThunkFree( InfoStruct.pBuffer );
  2164. }
  2165. }
  2166. return( dwRetCode );
  2167. }
  2168. DWORD APIENTRY
  2169. MprAdminInterfaceGetCredentialsEx(
  2170. IN MPR_SERVER_HANDLE hMprServer,
  2171. IN HANDLE hInterface,
  2172. IN DWORD dwLevel,
  2173. IN LPBYTE * lplpbBuffer)
  2174. {
  2175. DWORD dwRetCode;
  2176. DIM_INFORMATION_CONTAINER InfoStruct;
  2177. ZeroMemory( &InfoStruct, sizeof( InfoStruct ) );
  2178. if ( (dwLevel != 0)
  2179. && (dwLevel != 1)
  2180. && (dwLevel != 2))
  2181. {
  2182. return ERROR_NOT_SUPPORTED;
  2183. }
  2184. //
  2185. // Make sure that all pointers passed in are valid
  2186. //
  2187. try
  2188. {
  2189. *lplpbBuffer;
  2190. }
  2191. except( EXCEPTION_EXECUTE_HANDLER )
  2192. {
  2193. return( ERROR_INVALID_PARAMETER );
  2194. }
  2195. RpcTryExcept
  2196. {
  2197. dwRetCode = RRouterInterfaceGetCredentialsEx(
  2198. hMprServer,
  2199. dwLevel,
  2200. &InfoStruct,
  2201. PtrToUlong(hInterface) );
  2202. }
  2203. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2204. {
  2205. dwRetCode = RpcExceptionCode();
  2206. }
  2207. RpcEndExcept
  2208. //
  2209. // Assign the return value
  2210. //
  2211. if ( dwRetCode == NO_ERROR )
  2212. {
  2213. *lplpbBuffer = NULL;
  2214. switch(dwLevel)
  2215. {
  2216. case 0:
  2217. {
  2218. MPR_CREDENTIALSEXI *pCredsI = (MPR_CREDENTIALSEXI *)
  2219. InfoStruct.pBuffer;
  2220. MPR_CREDENTIALSEX_0* pCred0 = NULL;
  2221. dwRetCode = MprThunkCredentials_WtoH(
  2222. dwLevel,
  2223. pCredsI,
  2224. MprAdminAlloc,
  2225. (PBYTE *) &pCred0);
  2226. if(NULL != InfoStruct.pBuffer)
  2227. {
  2228. ZeroMemory(InfoStruct.pBuffer, InfoStruct.dwBufferSize);
  2229. MprAdminFree(InfoStruct.pBuffer);
  2230. }
  2231. *lplpbBuffer = (PBYTE) pCred0;
  2232. break;
  2233. }
  2234. case 1:
  2235. case 2:
  2236. {
  2237. MPR_CREDENTIALSEXI *pCredsI = (MPR_CREDENTIALSEXI *)
  2238. InfoStruct.pBuffer;
  2239. MPR_CREDENTIALSEX_1* pCred1 = NULL;
  2240. dwRetCode = MprThunkCredentials_WtoH(
  2241. dwLevel,
  2242. pCredsI,
  2243. MprAdminAlloc,
  2244. (PBYTE *) &pCred1);
  2245. if(NULL != InfoStruct.pBuffer)
  2246. {
  2247. ZeroMemory(InfoStruct.pBuffer, InfoStruct.dwBufferSize);
  2248. MprAdminFree(InfoStruct.pBuffer);
  2249. }
  2250. *lplpbBuffer = (PBYTE) pCred1;
  2251. break;
  2252. }
  2253. }
  2254. }
  2255. return( dwRetCode );
  2256. }
  2257. //**
  2258. //
  2259. // Call: MprAdminRegisterConnectionNotification
  2260. //
  2261. // Returns: NO_ERROR - Success
  2262. // Non-zero returns - Failure
  2263. //
  2264. // Description:
  2265. //
  2266. DWORD APIENTRY
  2267. MprAdminRegisterConnectionNotification(
  2268. IN MPR_SERVER_HANDLE hMprServer,
  2269. IN HANDLE hEventNotification
  2270. )
  2271. {
  2272. DWORD dwRetCode;
  2273. DWORD dwCurrentProcessId = GetCurrentProcessId();
  2274. if ( ( hEventNotification == INVALID_HANDLE_VALUE ) ||
  2275. ( hEventNotification == NULL ) )
  2276. {
  2277. return( ERROR_INVALID_PARAMETER );
  2278. }
  2279. RpcTryExcept
  2280. {
  2281. dwRetCode = RRasAdminConnectionNotification(
  2282. hMprServer,
  2283. TRUE,
  2284. dwCurrentProcessId,
  2285. (ULONG_PTR) hEventNotification );
  2286. }
  2287. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2288. {
  2289. dwRetCode = RpcExceptionCode();
  2290. }
  2291. RpcEndExcept
  2292. return( dwRetCode );
  2293. }
  2294. //**
  2295. //
  2296. // Call: MprAdminDeregisterConnectionNotification
  2297. //
  2298. // Returns: NO_ERROR - Success
  2299. // Non-zero returns - Failure
  2300. //
  2301. // Description:
  2302. //
  2303. DWORD APIENTRY
  2304. MprAdminDeregisterConnectionNotification(
  2305. IN MPR_SERVER_HANDLE hMprServer,
  2306. IN HANDLE hEventNotification
  2307. )
  2308. {
  2309. DWORD dwRetCode;
  2310. if ( ( hEventNotification == INVALID_HANDLE_VALUE ) ||
  2311. ( hEventNotification == NULL ) )
  2312. {
  2313. return( ERROR_INVALID_PARAMETER );
  2314. }
  2315. RpcTryExcept
  2316. {
  2317. dwRetCode = RRasAdminConnectionNotification(
  2318. hMprServer,
  2319. FALSE,
  2320. 0,
  2321. (ULONG_PTR)hEventNotification );
  2322. }
  2323. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2324. {
  2325. dwRetCode = RpcExceptionCode();
  2326. }
  2327. RpcEndExcept
  2328. return( dwRetCode );
  2329. }
  2330. //
  2331. // Call: MprAdminMIBServerConnect
  2332. //
  2333. // Returns: NO_ERROR - success
  2334. // non-zero returns from the DimRPCBind routine.
  2335. //
  2336. //
  2337. // Description: This is the DLL entrypoint for MIBServerConnect
  2338. //
  2339. DWORD
  2340. MprAdminMIBServerConnect(
  2341. IN LPWSTR lpwsServerName,
  2342. OUT MIB_SERVER_HANDLE * phMIBServer
  2343. )
  2344. {
  2345. //
  2346. // Bind with the server
  2347. //
  2348. return( DimRPCBind( lpwsServerName, phMIBServer ) );
  2349. }
  2350. //**
  2351. //
  2352. // Call: MprAdminMIBServerDisconnect
  2353. //
  2354. // Returns: none.
  2355. //
  2356. // Description: This is the DLL entrypoint for MIBServerDisconnect
  2357. //
  2358. VOID
  2359. MprAdminMIBServerDisconnect(
  2360. IN MIB_SERVER_HANDLE hMIBServer
  2361. )
  2362. {
  2363. RpcBindingFree( (handle_t *)&hMIBServer );
  2364. }
  2365. //**
  2366. //
  2367. // Call: MprAdminMIBBufferFree
  2368. //
  2369. // Returns: none
  2370. //
  2371. // Description: This is the DLL entrypoint for MIBBufferFree
  2372. //
  2373. DWORD
  2374. MprAdminMIBBufferFree(
  2375. IN PVOID pBuffer
  2376. )
  2377. {
  2378. if ( pBuffer == NULL )
  2379. {
  2380. return( ERROR_INVALID_PARAMETER );
  2381. }
  2382. MIDL_user_free( pBuffer );
  2383. return( NO_ERROR );
  2384. }
  2385. //**
  2386. //
  2387. // Call: MprAdminMIBEntryCreate
  2388. //
  2389. // Returns: NO_ERROR - success
  2390. // ERROR_INVALID_PARAMETER
  2391. // non-zero return codes from RMIBEntryCreate
  2392. //
  2393. // Description: This is the DLL entrypoint for MIBEntryCreate
  2394. //
  2395. DWORD APIENTRY
  2396. MprAdminMIBEntryCreate(
  2397. IN MIB_SERVER_HANDLE hMIBServer,
  2398. IN DWORD dwPid,
  2399. IN DWORD dwRoutingPid,
  2400. IN LPVOID lpEntry,
  2401. IN DWORD dwEntrySize
  2402. )
  2403. {
  2404. DWORD dwRetCode;
  2405. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2406. //
  2407. // Make sure that all pointers passed in are valid
  2408. //
  2409. if ( lpEntry == NULL )
  2410. {
  2411. return( ERROR_INVALID_PARAMETER );
  2412. }
  2413. try
  2414. {
  2415. InfoStruct.dwMibInEntrySize = dwEntrySize;
  2416. InfoStruct.pMibInEntry = lpEntry;
  2417. InfoStruct.dwMibOutEntrySize = 0;
  2418. InfoStruct.pMibOutEntry = NULL;
  2419. }
  2420. except( EXCEPTION_EXECUTE_HANDLER )
  2421. {
  2422. return( ERROR_INVALID_PARAMETER );
  2423. }
  2424. RpcTryExcept
  2425. {
  2426. dwRetCode = RMIBEntryCreate(hMIBServer,
  2427. dwPid,
  2428. dwRoutingPid,
  2429. &InfoStruct );
  2430. }
  2431. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2432. {
  2433. dwRetCode = RpcExceptionCode();
  2434. }
  2435. RpcEndExcept
  2436. return( dwRetCode );
  2437. }
  2438. //**
  2439. //
  2440. // Call: MprAdminMIBEntryDelete
  2441. //
  2442. // Returns: NO_ERROR - success
  2443. // ERROR_INVALID_PARAMETER
  2444. // non-zero return codes from RMIBEntryDelete
  2445. //
  2446. // Description: This is the DLL entrypoint for MIBEntryDelete
  2447. //
  2448. DWORD APIENTRY
  2449. MprAdminMIBEntryDelete(
  2450. IN MIB_SERVER_HANDLE hMIBServer,
  2451. IN DWORD dwPid,
  2452. IN DWORD dwRoutingPid,
  2453. IN LPVOID lpEntry,
  2454. IN DWORD dwEntrySize
  2455. )
  2456. {
  2457. DWORD dwRetCode;
  2458. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2459. //
  2460. // Make sure that all pointers passed in are valid
  2461. //
  2462. if ( lpEntry == NULL )
  2463. {
  2464. return( ERROR_INVALID_PARAMETER );
  2465. }
  2466. try
  2467. {
  2468. InfoStruct.dwMibInEntrySize = dwEntrySize;
  2469. InfoStruct.pMibInEntry = lpEntry;
  2470. InfoStruct.dwMibOutEntrySize = 0;
  2471. InfoStruct.pMibOutEntry = NULL;
  2472. }
  2473. except( EXCEPTION_EXECUTE_HANDLER )
  2474. {
  2475. return( ERROR_INVALID_PARAMETER );
  2476. }
  2477. RpcTryExcept
  2478. {
  2479. dwRetCode = RMIBEntryDelete(hMIBServer,
  2480. dwPid,
  2481. dwRoutingPid,
  2482. &InfoStruct );
  2483. }
  2484. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2485. {
  2486. dwRetCode = RpcExceptionCode();
  2487. }
  2488. RpcEndExcept
  2489. return( dwRetCode );
  2490. }
  2491. //**
  2492. //
  2493. // Call: MprAdminMIBEntrySet
  2494. //
  2495. // Returns: NO_ERROR - success
  2496. // ERROR_INVALID_PARAMETER
  2497. // non-zero return codes from RMIBEntrySet
  2498. //
  2499. // Description: This is the DLL entrypoint for MIBEntrySet
  2500. //
  2501. DWORD APIENTRY
  2502. MprAdminMIBEntrySet(
  2503. IN MIB_SERVER_HANDLE hMIBServer,
  2504. IN DWORD dwPid,
  2505. IN DWORD dwRoutingPid,
  2506. IN LPVOID lpEntry,
  2507. IN DWORD dwEntrySize
  2508. )
  2509. {
  2510. DWORD dwRetCode;
  2511. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2512. //
  2513. // Make sure that all pointers passed in are valid
  2514. //
  2515. if ( lpEntry == NULL )
  2516. {
  2517. return( ERROR_INVALID_PARAMETER );
  2518. }
  2519. try
  2520. {
  2521. InfoStruct.dwMibInEntrySize = dwEntrySize;
  2522. InfoStruct.pMibInEntry = lpEntry;
  2523. InfoStruct.dwMibOutEntrySize = 0;
  2524. InfoStruct.pMibOutEntry = NULL;
  2525. }
  2526. except( EXCEPTION_EXECUTE_HANDLER )
  2527. {
  2528. return( ERROR_INVALID_PARAMETER );
  2529. }
  2530. RpcTryExcept
  2531. {
  2532. dwRetCode = RMIBEntrySet( hMIBServer,
  2533. dwPid,
  2534. dwRoutingPid,
  2535. &InfoStruct );
  2536. }
  2537. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2538. {
  2539. dwRetCode = RpcExceptionCode();
  2540. }
  2541. RpcEndExcept
  2542. return( dwRetCode );
  2543. }
  2544. //**
  2545. //
  2546. // Call: MprAdminMIBEntryGet
  2547. //
  2548. // Returns: NO_ERROR - success
  2549. // ERROR_INVALID_PARAMETER
  2550. // non-zero return codes from RMIBEntryGet
  2551. //
  2552. // Description: This is the DLL entrypoint for MIBEntryGet
  2553. //
  2554. DWORD APIENTRY
  2555. MprAdminMIBEntryGet(
  2556. IN MIB_SERVER_HANDLE hMIBServer,
  2557. IN DWORD dwPid,
  2558. IN DWORD dwRoutingPid,
  2559. IN LPVOID lpInEntry,
  2560. IN DWORD dwInEntrySize,
  2561. OUT LPVOID * lplpOutEntry,
  2562. OUT LPDWORD lpdwOutEntrySize
  2563. )
  2564. {
  2565. DWORD dwRetCode;
  2566. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2567. //
  2568. // Make sure that all pointers passed in are valid
  2569. //
  2570. if ( lpInEntry == NULL )
  2571. {
  2572. return( ERROR_INVALID_PARAMETER );
  2573. }
  2574. try
  2575. {
  2576. *lplpOutEntry = NULL;
  2577. *lpdwOutEntrySize = 0;
  2578. InfoStruct.pMibInEntry = lpInEntry;
  2579. InfoStruct.dwMibInEntrySize = dwInEntrySize;
  2580. InfoStruct.dwMibOutEntrySize = 0;
  2581. InfoStruct.pMibOutEntry = NULL;
  2582. }
  2583. except( EXCEPTION_EXECUTE_HANDLER )
  2584. {
  2585. return( ERROR_INVALID_PARAMETER );
  2586. }
  2587. RpcTryExcept
  2588. {
  2589. dwRetCode = RMIBEntryGet(hMIBServer,
  2590. dwPid,
  2591. dwRoutingPid,
  2592. &InfoStruct );
  2593. if ( InfoStruct.pMibOutEntry != NULL )
  2594. {
  2595. *lplpOutEntry = (LPVOID)(InfoStruct.pMibOutEntry);
  2596. *lpdwOutEntrySize = InfoStruct.dwMibOutEntrySize;
  2597. }
  2598. }
  2599. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2600. {
  2601. dwRetCode = RpcExceptionCode();
  2602. }
  2603. RpcEndExcept
  2604. return( dwRetCode );
  2605. }
  2606. //**
  2607. //
  2608. // Call: MprAdminMIBEntryGetFirst
  2609. //
  2610. // Returns: NO_ERROR - success
  2611. // ERROR_INVALID_PARAMETER
  2612. // non-zero return codes from RMIBEntryGetFirst
  2613. //
  2614. // Description: This is the DLL entrypoint for MIBEntryGetFirst
  2615. //
  2616. DWORD APIENTRY
  2617. MprAdminMIBEntryGetFirst(
  2618. IN MIB_SERVER_HANDLE hMIBServer,
  2619. IN DWORD dwPid,
  2620. IN DWORD dwRoutingPid,
  2621. IN LPVOID lpInEntry,
  2622. IN DWORD dwInEntrySize,
  2623. OUT LPVOID * lplpOutEntry,
  2624. OUT LPDWORD lpdwOutEntrySize
  2625. )
  2626. {
  2627. DWORD dwRetCode;
  2628. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2629. //
  2630. // Make sure that all pointers passed in are valid
  2631. //
  2632. if ( lpInEntry == NULL )
  2633. {
  2634. return( ERROR_INVALID_PARAMETER );
  2635. }
  2636. try
  2637. {
  2638. *lplpOutEntry = NULL;
  2639. *lpdwOutEntrySize = 0;
  2640. InfoStruct.pMibInEntry = lpInEntry;
  2641. InfoStruct.dwMibInEntrySize = dwInEntrySize;
  2642. InfoStruct.dwMibOutEntrySize = 0;
  2643. InfoStruct.pMibOutEntry = NULL;
  2644. }
  2645. except( EXCEPTION_EXECUTE_HANDLER )
  2646. {
  2647. return( ERROR_INVALID_PARAMETER );
  2648. }
  2649. RpcTryExcept
  2650. {
  2651. dwRetCode = RMIBEntryGetFirst(
  2652. hMIBServer,
  2653. dwPid,
  2654. dwRoutingPid,
  2655. &InfoStruct );
  2656. if ( InfoStruct.pMibOutEntry != NULL )
  2657. {
  2658. *lplpOutEntry = (LPVOID)(InfoStruct.pMibOutEntry);
  2659. *lpdwOutEntrySize = InfoStruct.dwMibOutEntrySize;
  2660. }
  2661. }
  2662. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2663. {
  2664. dwRetCode = RpcExceptionCode();
  2665. }
  2666. RpcEndExcept
  2667. return( dwRetCode );
  2668. }
  2669. //**
  2670. //
  2671. // Call: MprAdminMIBEntryGetNext
  2672. //
  2673. // Returns: NO_ERROR - success
  2674. // non-zero return codes from RMIBEntryGetNext
  2675. //
  2676. // Description: This is the DLL entrypoint for MIBEntryGetNext
  2677. //
  2678. DWORD APIENTRY
  2679. MprAdminMIBEntryGetNext(
  2680. IN MIB_SERVER_HANDLE hMIBServer,
  2681. IN DWORD dwPid,
  2682. IN DWORD dwRoutingPid,
  2683. IN LPVOID lpInEntry,
  2684. IN DWORD dwInEntrySize,
  2685. OUT LPVOID * lplpOutEntry,
  2686. OUT LPDWORD lpdwOutEntrySize
  2687. )
  2688. {
  2689. DWORD dwRetCode;
  2690. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2691. //
  2692. // Make sure that all pointers passed in are valid
  2693. //
  2694. if ( lpInEntry == NULL )
  2695. {
  2696. return( ERROR_INVALID_PARAMETER );
  2697. }
  2698. try
  2699. {
  2700. *lplpOutEntry = NULL;
  2701. *lpdwOutEntrySize = 0;
  2702. InfoStruct.pMibInEntry = lpInEntry;
  2703. InfoStruct.dwMibInEntrySize = dwInEntrySize;
  2704. InfoStruct.pMibOutEntry = NULL;
  2705. InfoStruct.dwMibOutEntrySize = 0;
  2706. }
  2707. except( EXCEPTION_EXECUTE_HANDLER )
  2708. {
  2709. return( ERROR_INVALID_PARAMETER );
  2710. }
  2711. RpcTryExcept
  2712. {
  2713. dwRetCode = RMIBEntryGetNext(
  2714. hMIBServer,
  2715. dwPid,
  2716. dwRoutingPid,
  2717. &InfoStruct );
  2718. if ( InfoStruct.pMibOutEntry != NULL )
  2719. {
  2720. *lplpOutEntry = (LPVOID)(InfoStruct.pMibOutEntry);
  2721. *lpdwOutEntrySize = InfoStruct.dwMibOutEntrySize;
  2722. }
  2723. }
  2724. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2725. {
  2726. dwRetCode = RpcExceptionCode();
  2727. }
  2728. RpcEndExcept
  2729. return( dwRetCode );
  2730. }
  2731. //**
  2732. //
  2733. // Call: MprAdminMIBGetTrapInfo
  2734. //
  2735. // Returns: NO_ERROR - success
  2736. // non-zero return codes from RMIBGetTrapInfo
  2737. //
  2738. // Description: This is the DLL entrypoint for MIBGetTrapInfo
  2739. //
  2740. DWORD APIENTRY
  2741. MprAdminMIBGetTrapInfo(
  2742. IN MIB_SERVER_HANDLE hMIBServer,
  2743. IN DWORD dwPid,
  2744. IN DWORD dwRoutingPid,
  2745. IN LPVOID lpInData,
  2746. IN DWORD dwInDataSize,
  2747. OUT LPVOID* lplpOutData,
  2748. IN OUT LPDWORD lpdwOutDataSize
  2749. )
  2750. {
  2751. DWORD dwRetCode;
  2752. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2753. //
  2754. // Make sure that all pointers passed in are valid
  2755. //
  2756. if ( lpInData == NULL )
  2757. {
  2758. return( ERROR_INVALID_PARAMETER );
  2759. }
  2760. try
  2761. {
  2762. *lplpOutData = NULL;
  2763. *lpdwOutDataSize = 0;
  2764. InfoStruct.pMibInEntry = lpInData;
  2765. InfoStruct.dwMibInEntrySize = dwInDataSize;
  2766. InfoStruct.pMibOutEntry = NULL;
  2767. InfoStruct.dwMibOutEntrySize = 0;
  2768. }
  2769. except( EXCEPTION_EXECUTE_HANDLER )
  2770. {
  2771. return( ERROR_INVALID_PARAMETER );
  2772. }
  2773. RpcTryExcept
  2774. {
  2775. dwRetCode = RMIBGetTrapInfo(
  2776. hMIBServer,
  2777. dwPid,
  2778. dwRoutingPid,
  2779. &InfoStruct );
  2780. if ( InfoStruct.pMibOutEntry != NULL )
  2781. {
  2782. *lplpOutData = (LPVOID)(InfoStruct.pMibOutEntry);
  2783. *lpdwOutDataSize = InfoStruct.dwMibOutEntrySize;
  2784. }
  2785. }
  2786. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2787. {
  2788. dwRetCode = RpcExceptionCode();
  2789. }
  2790. RpcEndExcept
  2791. return( dwRetCode );
  2792. }
  2793. //**
  2794. //
  2795. // Call: MprAdminMIBSetTrapInfo
  2796. //
  2797. // Returns: NO_ERROR - success
  2798. // non-zero return codes from RMIBSetTrapInfo
  2799. //
  2800. // Description: This is the DLL entrypoint for MIBSetTrapInfo
  2801. //
  2802. DWORD APIENTRY
  2803. MprAdminMIBSetTrapInfo(
  2804. IN DWORD dwPid,
  2805. IN DWORD dwRoutingPid,
  2806. IN HANDLE hEvent,
  2807. IN LPVOID lpInData,
  2808. IN DWORD dwInDataSize,
  2809. OUT LPVOID* lplpOutData,
  2810. IN OUT LPDWORD lpdwOutDataSize
  2811. )
  2812. {
  2813. DWORD dwRetCode;
  2814. DIM_MIB_ENTRY_CONTAINER InfoStruct;
  2815. MIB_SERVER_HANDLE hMIBServer;
  2816. DWORD dwCurrentProcessId = GetCurrentProcessId();
  2817. dwRetCode = MprAdminMIBServerConnect( NULL, &hMIBServer );
  2818. if ( dwRetCode != NO_ERROR )
  2819. {
  2820. return( dwRetCode );
  2821. }
  2822. if ( lpInData == NULL )
  2823. {
  2824. return( ERROR_INVALID_PARAMETER );
  2825. }
  2826. //
  2827. // Make sure that all pointers passed in are valid
  2828. //
  2829. try
  2830. {
  2831. *lplpOutData = NULL;
  2832. *lpdwOutDataSize = 0;
  2833. InfoStruct.pMibInEntry = lpInData;
  2834. InfoStruct.dwMibInEntrySize = dwInDataSize;
  2835. InfoStruct.pMibOutEntry = NULL;
  2836. InfoStruct.dwMibOutEntrySize = 0;
  2837. }
  2838. except( EXCEPTION_EXECUTE_HANDLER )
  2839. {
  2840. return( ERROR_INVALID_PARAMETER );
  2841. }
  2842. RpcTryExcept
  2843. {
  2844. dwRetCode = RMIBSetTrapInfo(
  2845. hMIBServer,
  2846. dwPid,
  2847. dwRoutingPid,
  2848. (ULONG_PTR) hEvent,
  2849. dwCurrentProcessId,
  2850. &InfoStruct );
  2851. if ( InfoStruct.pMibOutEntry != NULL )
  2852. {
  2853. *lplpOutData = (LPVOID)(InfoStruct.pMibOutEntry);
  2854. *lpdwOutDataSize = InfoStruct.dwMibOutEntrySize;
  2855. }
  2856. }
  2857. RpcExcept(I_RpcExceptionFilter(RpcExceptionCode()))
  2858. {
  2859. dwRetCode = RpcExceptionCode();
  2860. }
  2861. RpcEndExcept
  2862. MprAdminMIBServerDisconnect( hMIBServer );
  2863. return( dwRetCode );
  2864. }
  2865. DWORD APIENTRY
  2866. MprAdminConnectionEnum(
  2867. IN RAS_SERVER_HANDLE hRasServer,
  2868. IN DWORD dwLevel,
  2869. OUT LPBYTE * lplpbBuffer, // RAS_CONNECTION_0
  2870. IN DWORD dwPrefMaxLen,
  2871. OUT LPDWORD lpdwEntriesRead,
  2872. OUT LPDWORD lpdwTotalEntries,
  2873. IN LPDWORD lpdwResumeHandle OPTIONAL
  2874. )
  2875. {
  2876. return( RasAdminConnectionEnum( hRasServer, dwLevel, lplpbBuffer,
  2877. dwPrefMaxLen, lpdwEntriesRead,
  2878. lpdwTotalEntries, lpdwResumeHandle ) );
  2879. }
  2880. DWORD APIENTRY
  2881. MprAdminPortEnum(
  2882. IN RAS_SERVER_HANDLE hRasServer,
  2883. IN DWORD dwLevel,
  2884. IN HANDLE hRasConnection,
  2885. OUT LPBYTE * lplpbBuffer, // RAS_PORT_0
  2886. IN DWORD dwPrefMaxLen,
  2887. OUT LPDWORD lpdwEntriesRead,
  2888. OUT LPDWORD lpdwTotalEntries,
  2889. IN LPDWORD lpdwResumeHandle OPTIONAL
  2890. )
  2891. {
  2892. return( RasAdminPortEnum( hRasServer, dwLevel, hRasConnection, lplpbBuffer,
  2893. dwPrefMaxLen, lpdwEntriesRead, lpdwTotalEntries,
  2894. lpdwResumeHandle ) );
  2895. }
  2896. DWORD APIENTRY
  2897. MprAdminConnectionGetInfo(
  2898. IN RAS_SERVER_HANDLE hRasServer,
  2899. IN DWORD dwLevel,
  2900. IN HANDLE hRasConnection,
  2901. OUT LPBYTE * lplpbBuffer
  2902. )
  2903. {
  2904. return( RasAdminConnectionGetInfo( hRasServer, dwLevel, hRasConnection,
  2905. lplpbBuffer ) );
  2906. }
  2907. DWORD APIENTRY
  2908. MprAdminPortGetInfo(
  2909. IN RAS_SERVER_HANDLE hRasServer,
  2910. IN DWORD dwLevel,
  2911. IN HANDLE hPort,
  2912. OUT LPBYTE * lplpbBuffer
  2913. )
  2914. {
  2915. return( RasAdminPortGetInfo( hRasServer, dwLevel, hPort, lplpbBuffer ) );
  2916. }
  2917. DWORD APIENTRY
  2918. MprAdminConnectionClearStats(
  2919. IN RAS_SERVER_HANDLE hRasServer,
  2920. IN HANDLE hRasConnection
  2921. )
  2922. {
  2923. return( RasAdminConnectionClearStats( hRasServer, hRasConnection ) );
  2924. }
  2925. DWORD APIENTRY
  2926. MprAdminPortClearStats(
  2927. IN RAS_SERVER_HANDLE hRasServer,
  2928. IN HANDLE hPort
  2929. )
  2930. {
  2931. return( RasAdminPortClearStats( hRasServer, hPort ) );
  2932. }
  2933. DWORD APIENTRY
  2934. MprAdminPortReset(
  2935. IN RAS_SERVER_HANDLE hRasServer,
  2936. IN HANDLE hPort
  2937. )
  2938. {
  2939. return( RasAdminPortReset( hRasServer, hPort ) );
  2940. }
  2941. DWORD APIENTRY
  2942. MprAdminPortDisconnect(
  2943. IN RAS_SERVER_HANDLE hRasServer,
  2944. IN HANDLE hPort
  2945. )
  2946. {
  2947. return( RasAdminPortDisconnect( hRasServer, hPort ) );
  2948. }
  2949. DWORD APIENTRY
  2950. MprAdminInterfaceSetCredentials(
  2951. IN LPWSTR lpwsServer OPTIONAL,
  2952. IN LPWSTR lpwsInterfaceName,
  2953. IN LPWSTR lpwsUserName OPTIONAL,
  2954. IN LPWSTR lpwsDomainName OPTIONAL,
  2955. IN LPWSTR lpwsPassword OPTIONAL
  2956. )
  2957. {
  2958. return
  2959. MprAdminInterfaceSetCredentialsInternal(
  2960. lpwsServer,
  2961. lpwsInterfaceName,
  2962. lpwsUserName,
  2963. lpwsDomainName,
  2964. lpwsPassword);
  2965. }
  2966. DWORD APIENTRY
  2967. MprAdminInterfaceGetCredentials(
  2968. IN LPWSTR lpwsServer OPTIONAL,
  2969. IN LPWSTR lpwsInterfaceName,
  2970. IN LPWSTR lpwsUserName OPTIONAL,
  2971. IN LPWSTR lpwsPassword OPTIONAL,
  2972. IN LPWSTR lpwsDomainName OPTIONAL
  2973. )
  2974. {
  2975. DWORD dwErr;
  2976. dwErr =
  2977. MprAdminInterfaceGetCredentialsInternal(
  2978. lpwsServer,
  2979. lpwsInterfaceName,
  2980. lpwsUserName,
  2981. NULL,
  2982. lpwsDomainName);
  2983. if (dwErr == NO_ERROR)
  2984. {
  2985. if (lpwsPassword != NULL)
  2986. {
  2987. wcscpy(lpwsPassword, L"****************");
  2988. }
  2989. }
  2990. return dwErr;
  2991. }