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.

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