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.

855 lines
23 KiB

  1. /********************************************************************/
  2. /** Copyright(c) 1995 Microsoft Corporation. **/
  3. /********************************************************************/
  4. //***
  5. //
  6. // Filename: ddmapi.c
  7. //
  8. // Description: This file contains code to call into DDM to process
  9. // admin requests
  10. //
  11. // History: May 11,1995 NarenG Created original version.
  12. //
  13. #include "dimsvcp.h"
  14. #include <dimsvc.h>
  15. //#define DimIndexToHandle(_x) ((_x == 0xFFFFFFFF) ? INVALID_HANDLE_VALUE : (HANDLE) UlongToPtr(_x))
  16. //**
  17. //
  18. // Call: IsDDMRunning
  19. //
  20. // Returns: TRUE - Service is running and API calls can be serviced
  21. // FALSE - API calls cannot be serviced.
  22. //
  23. // Description: Called to see if API calls can be serviced.
  24. //
  25. BOOL
  26. IsDDMRunning(
  27. VOID
  28. )
  29. {
  30. switch( gblDIMConfigInfo.ServiceStatus.dwCurrentState )
  31. {
  32. case SERVICE_STOP_PENDING:
  33. case SERVICE_START_PENDING:
  34. case SERVICE_STOPPED:
  35. return( FALSE );
  36. default:
  37. return( TRUE );
  38. }
  39. }
  40. //**
  41. //
  42. // Call: RMprAdminServerGetInfo
  43. //
  44. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  45. // non-zero returns from DDMAdminServerGetInfo
  46. //
  47. // Description: Simply calles into DDM to do the work
  48. //
  49. DWORD
  50. RMprAdminServerGetInfo(
  51. IN MPR_SERVER_HANDLE hMprServer,
  52. IN DWORD dwLevel,
  53. IN OUT PDIM_INFORMATION_CONTAINER pInfoStruct
  54. )
  55. {
  56. DWORD dwAccessStatus;
  57. ULARGE_INTEGER qwCurrentTime;
  58. ULARGE_INTEGER qwUpTime;
  59. DWORD dwRemainder;
  60. //
  61. // Check if caller has access
  62. //
  63. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  64. {
  65. return( ERROR_ACCESS_DENIED );
  66. }
  67. if ( dwAccessStatus != NO_ERROR )
  68. {
  69. return( ERROR_ACCESS_DENIED );
  70. }
  71. if ( !IsDDMRunning() )
  72. {
  73. return( ERROR_DDM_NOT_RUNNING );
  74. }
  75. if ( dwLevel != 0 )
  76. {
  77. return( ERROR_NOT_SUPPORTED );
  78. }
  79. pInfoStruct->pBuffer = MIDL_user_allocate( sizeof( MPR_SERVER_0 ) );
  80. if ( pInfoStruct->pBuffer == NULL )
  81. {
  82. return( ERROR_NOT_ENOUGH_MEMORY );
  83. }
  84. pInfoStruct->dwBufferSize = sizeof( MPR_SERVER_0 );
  85. GetSystemTimeAsFileTime( (FILETIME*)&qwCurrentTime );
  86. if ( ( qwCurrentTime.QuadPart > gblDIMConfigInfo.qwStartTime.QuadPart ) &&
  87. ( gblDIMConfigInfo.qwStartTime.QuadPart > 0 ) )
  88. {
  89. qwUpTime.QuadPart = qwCurrentTime.QuadPart
  90. - gblDIMConfigInfo.qwStartTime.QuadPart;
  91. ((MPR_SERVER_0*)(pInfoStruct->pBuffer))->dwUpTime =
  92. RtlEnlargedUnsignedDivide(
  93. qwUpTime,
  94. (DWORD)10000000,
  95. &dwRemainder );
  96. }
  97. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  98. {
  99. ((MPR_SERVER_0*)(pInfoStruct->pBuffer))->fLanOnlyMode = TRUE;
  100. return( NO_ERROR );
  101. }
  102. else
  103. {
  104. DWORD (*DDMAdminServerGetInfo)( PVOID, DWORD ) =
  105. (DWORD(*)( PVOID, DWORD ))GetDDMEntryPoint("DDMAdminServerGetInfo");
  106. if(NULL == DDMAdminServerGetInfo)
  107. {
  108. return ERROR_PROC_NOT_FOUND;
  109. }
  110. return( DDMAdminServerGetInfo( pInfoStruct->pBuffer, dwLevel ) );
  111. }
  112. }
  113. //**
  114. //
  115. // Call: RRasAdminConnectionEnum
  116. //
  117. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  118. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  119. // not loaded
  120. // non-zero returns from DDMAdminConnectionEnum
  121. //
  122. // Description: Simply calles into DDM to do the work
  123. //
  124. DWORD
  125. RRasAdminConnectionEnum(
  126. IN RAS_SERVER_HANDLE hRasServer,
  127. IN DWORD dwLevel,
  128. IN OUT PDIM_INFORMATION_CONTAINER pInfoStruct,
  129. IN DWORD dwPreferedMaximumLength,
  130. OUT LPDWORD lpdwEntriesRead,
  131. OUT LPDWORD lpdwTotalEntries,
  132. IN OUT LPDWORD lpdwResumeHandle OPTIONAL
  133. )
  134. {
  135. DWORD dwAccessStatus;
  136. //
  137. // Check if caller has access
  138. //
  139. if ( DimSecObjAccessCheck(DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  140. {
  141. return( ERROR_ACCESS_DENIED );
  142. }
  143. if ( dwAccessStatus )
  144. {
  145. return( ERROR_ACCESS_DENIED );
  146. }
  147. if ( !IsDDMRunning() )
  148. {
  149. return( ERROR_DDM_NOT_RUNNING );
  150. }
  151. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  152. {
  153. return( ERROR_DDM_NOT_RUNNING );
  154. }
  155. else
  156. {
  157. DWORD (*DDMAdminConnectionEnum)( PDIM_INFORMATION_CONTAINER,
  158. DWORD,
  159. DWORD,
  160. LPDWORD,
  161. LPDWORD,
  162. LPDWORD ) =
  163. (DWORD(*)( PDIM_INFORMATION_CONTAINER,
  164. DWORD,
  165. DWORD,
  166. LPDWORD,
  167. LPDWORD,
  168. LPDWORD ))GetDDMEntryPoint("DDMAdminConnectionEnum");
  169. if(NULL == DDMAdminConnectionEnum)
  170. {
  171. return ERROR_PROC_NOT_FOUND;
  172. }
  173. return( DDMAdminConnectionEnum( pInfoStruct,
  174. dwLevel,
  175. dwPreferedMaximumLength,
  176. lpdwEntriesRead,
  177. lpdwTotalEntries,
  178. lpdwResumeHandle ) );
  179. }
  180. }
  181. //**
  182. //
  183. // Call: RRasAdminConnectionGetInfo
  184. //
  185. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  186. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  187. // not loaded
  188. // non-zero returns from DDMAdminConnectionGetInfo
  189. //
  190. // Description: Simply calles into DDM to do the work.
  191. //
  192. DWORD
  193. RRasAdminConnectionGetInfo(
  194. IN RAS_SERVER_HANDLE hRasServer,
  195. IN DWORD dwLevel,
  196. IN DWORD hDimConnection,
  197. IN OUT PDIM_INFORMATION_CONTAINER pInfoStruct
  198. )
  199. {
  200. DWORD dwAccessStatus;
  201. //
  202. // Check if caller has access
  203. //
  204. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  205. {
  206. return( ERROR_ACCESS_DENIED );
  207. }
  208. if ( dwAccessStatus )
  209. {
  210. return( ERROR_ACCESS_DENIED );
  211. }
  212. if ( !IsDDMRunning() )
  213. {
  214. return( ERROR_DDM_NOT_RUNNING );
  215. }
  216. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  217. {
  218. return( ERROR_DDM_NOT_RUNNING );
  219. }
  220. else
  221. {
  222. DWORD (*DDMAdminConnectionGetInfo)(
  223. HANDLE,
  224. PDIM_INFORMATION_CONTAINER,
  225. DWORD ) =
  226. (DWORD(*)( HANDLE,
  227. PDIM_INFORMATION_CONTAINER,
  228. DWORD ) )
  229. GetDDMEntryPoint("DDMAdminConnectionGetInfo");
  230. if(NULL == DDMAdminConnectionGetInfo)
  231. {
  232. return ERROR_PROC_NOT_FOUND;
  233. }
  234. return( DDMAdminConnectionGetInfo(
  235. DimIndexToHandle(hDimConnection),
  236. pInfoStruct,
  237. dwLevel ) );
  238. }
  239. }
  240. //**
  241. //
  242. // Call: RRasAdminConnectionClearStats
  243. //
  244. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  245. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  246. // not loaded
  247. // non-zero returns from DDMAdminConnectionClearStats
  248. //
  249. // Description: Simply calles into DDM to do the work.
  250. //
  251. DWORD
  252. RRasAdminConnectionClearStats(
  253. IN RAS_SERVER_HANDLE hRasServer,
  254. IN DWORD hRasConnection
  255. )
  256. {
  257. DWORD dwAccessStatus;
  258. //
  259. // Check if caller has access
  260. //
  261. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  262. {
  263. return( ERROR_ACCESS_DENIED );
  264. }
  265. if ( dwAccessStatus )
  266. {
  267. return( ERROR_ACCESS_DENIED );
  268. }
  269. if ( !IsDDMRunning() )
  270. {
  271. return( ERROR_DDM_NOT_RUNNING );
  272. }
  273. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  274. {
  275. return( ERROR_DDM_NOT_RUNNING );
  276. }
  277. else
  278. {
  279. DWORD (*DDMAdminConnectionClearStats)( HANDLE ) =
  280. (DWORD(*)( HANDLE ) )GetDDMEntryPoint("DDMAdminConnectionClearStats");
  281. if(NULL == DDMAdminConnectionClearStats)
  282. {
  283. return ERROR_PROC_NOT_FOUND;
  284. }
  285. return( DDMAdminConnectionClearStats( DimIndexToHandle(hRasConnection ) ));
  286. }
  287. }
  288. //**
  289. //
  290. // Call: RRasAdminPortEnum
  291. //
  292. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  293. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  294. // not loaded
  295. // non-zero returns from DDMAdminPortEnum
  296. //
  297. // Description: Simply calles into DDM to do the work.
  298. //
  299. DWORD
  300. RRasAdminPortEnum(
  301. IN RAS_SERVER_HANDLE hRasServer,
  302. IN DWORD dwLevel,
  303. IN DWORD hDimConnection,
  304. IN OUT PDIM_INFORMATION_CONTAINER pInfoStruct,
  305. IN DWORD dwPreferedMaximumLength,
  306. OUT LPDWORD lpdwEntriesRead,
  307. OUT LPDWORD lpdwTotalEntries,
  308. IN OUT LPDWORD lpdwResumeHandle OPTIONAL
  309. )
  310. {
  311. DWORD dwAccessStatus;
  312. //
  313. // Check if caller has access
  314. //
  315. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  316. {
  317. return( ERROR_ACCESS_DENIED );
  318. }
  319. if ( dwAccessStatus )
  320. {
  321. return( ERROR_ACCESS_DENIED );
  322. }
  323. if ( !IsDDMRunning() )
  324. {
  325. return( ERROR_DDM_NOT_RUNNING );
  326. }
  327. if (dwPreferedMaximumLength == 0)
  328. {
  329. return( ERROR_MORE_DATA );
  330. }
  331. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  332. {
  333. return( ERROR_DDM_NOT_RUNNING );
  334. }
  335. else
  336. {
  337. DWORD (*DDMAdminPortEnum)( PDIM_INFORMATION_CONTAINER,
  338. HANDLE,
  339. DWORD,
  340. DWORD,
  341. LPDWORD,
  342. LPDWORD,
  343. LPDWORD ) =
  344. (DWORD(*)( PDIM_INFORMATION_CONTAINER,
  345. HANDLE,
  346. DWORD,
  347. DWORD,
  348. LPDWORD,
  349. LPDWORD,
  350. LPDWORD ))GetDDMEntryPoint("DDMAdminPortEnum");
  351. if(NULL == DDMAdminPortEnum)
  352. {
  353. return ERROR_PROC_NOT_FOUND;
  354. }
  355. return( DDMAdminPortEnum( pInfoStruct,
  356. DimIndexToHandle(hDimConnection),
  357. dwLevel,
  358. dwPreferedMaximumLength,
  359. lpdwEntriesRead,
  360. lpdwTotalEntries,
  361. lpdwResumeHandle ) );
  362. }
  363. }
  364. //**
  365. //
  366. // Call: RRasAdminPortGetInfo
  367. //
  368. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  369. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  370. // not loaded
  371. // non-zero returns from DDMAdminPortGetInfo
  372. //
  373. // Description: Simply calles into DDM to do the work.
  374. //
  375. DWORD
  376. RRasAdminPortGetInfo(
  377. IN RAS_SERVER_HANDLE hRasServer,
  378. IN DWORD dwLevel,
  379. IN DWORD hPort,
  380. IN OUT PDIM_INFORMATION_CONTAINER pInfoStruct
  381. )
  382. {
  383. DWORD dwAccessStatus;
  384. //
  385. // Check if caller has access
  386. //
  387. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  388. {
  389. return( ERROR_ACCESS_DENIED );
  390. }
  391. if ( dwAccessStatus )
  392. {
  393. return( ERROR_ACCESS_DENIED );
  394. }
  395. if ( !IsDDMRunning() )
  396. {
  397. return( ERROR_DDM_NOT_RUNNING );
  398. }
  399. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  400. {
  401. return( ERROR_DDM_NOT_RUNNING );
  402. }
  403. else
  404. {
  405. DWORD (*DDMAdminPortGetInfo)( HANDLE,
  406. PDIM_INFORMATION_CONTAINER,
  407. DWORD ) =
  408. (DWORD(*)( HANDLE,
  409. PDIM_INFORMATION_CONTAINER,
  410. DWORD ) )
  411. GetDDMEntryPoint("DDMAdminPortGetInfo");
  412. if(NULL == DDMAdminPortGetInfo)
  413. {
  414. return ERROR_PROC_NOT_FOUND;
  415. }
  416. return( DDMAdminPortGetInfo( DimIndexToHandle(hPort), pInfoStruct, dwLevel ) );
  417. }
  418. }
  419. //**
  420. //
  421. // Call: RRasAdminPortClearStats
  422. //
  423. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  424. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  425. // not loaded
  426. // non-zero returns from DDMAdminPortClearStats
  427. //
  428. // Description: Simply calles into DDM to do the work.
  429. //
  430. DWORD
  431. RRasAdminPortClearStats(
  432. IN RAS_SERVER_HANDLE hRasServer,
  433. IN DWORD hPort
  434. )
  435. {
  436. DWORD dwAccessStatus;
  437. //
  438. // Check if caller has access
  439. //
  440. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  441. {
  442. return( ERROR_ACCESS_DENIED );
  443. }
  444. if ( dwAccessStatus )
  445. {
  446. return( ERROR_ACCESS_DENIED );
  447. }
  448. if ( !IsDDMRunning() )
  449. {
  450. return( ERROR_DDM_NOT_RUNNING );
  451. }
  452. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  453. {
  454. return( ERROR_DDM_NOT_RUNNING );
  455. }
  456. else
  457. {
  458. DWORD (*DDMAdminPortClearStats)( HANDLE ) =
  459. (DWORD(*)( HANDLE ) )GetDDMEntryPoint("DDMAdminPortClearStats");
  460. if(NULL == DDMAdminPortClearStats)
  461. {
  462. return ERROR_PROC_NOT_FOUND;
  463. }
  464. return( DDMAdminPortClearStats( DimIndexToHandle(hPort ) ));
  465. }
  466. }
  467. //**
  468. //
  469. // Call: RRasAdminPortReset
  470. //
  471. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  472. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  473. // not loaded
  474. // non-zero returns from DDMAdminPortReset
  475. //
  476. // Description: Simply calles into DDM to do the work
  477. //
  478. DWORD
  479. RRasAdminPortReset(
  480. IN RAS_SERVER_HANDLE hRasServer,
  481. IN DWORD hPort
  482. )
  483. {
  484. DWORD dwAccessStatus;
  485. //
  486. // Check if caller has access
  487. //
  488. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  489. {
  490. return( ERROR_ACCESS_DENIED );
  491. }
  492. if ( dwAccessStatus )
  493. {
  494. return( ERROR_ACCESS_DENIED );
  495. }
  496. if ( !IsDDMRunning() )
  497. {
  498. return( ERROR_DDM_NOT_RUNNING );
  499. }
  500. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  501. {
  502. return( ERROR_DDM_NOT_RUNNING );
  503. }
  504. else
  505. {
  506. DWORD (*DDMAdminPortReset)( HANDLE ) =
  507. (DWORD(*)( HANDLE ) )GetDDMEntryPoint("DDMAdminPortReset");
  508. if(NULL == DDMAdminPortReset)
  509. {
  510. return ERROR_PROC_NOT_FOUND;
  511. }
  512. return( DDMAdminPortReset( DimIndexToHandle(hPort ) ));
  513. }
  514. }
  515. //**
  516. //
  517. // Call: RRasAdminPortDisconnect
  518. //
  519. // Returns: ERROR_ACCESS_DENIED - The caller does not have sufficient priv.
  520. // ERROR_DDM_NOT_RUNNING - This call cannot be made because DDM is
  521. // not loaded
  522. // non-zero returns from DDMAdminPortDisconnect
  523. //
  524. // Description: Simply calles into DDM to do the work.
  525. //
  526. DWORD
  527. RRasAdminPortDisconnect(
  528. IN RAS_SERVER_HANDLE hRasServer,
  529. IN DWORD hPort
  530. )
  531. {
  532. DWORD dwAccessStatus;
  533. //
  534. // Check if caller has access
  535. //
  536. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  537. {
  538. return( ERROR_ACCESS_DENIED );
  539. }
  540. if ( dwAccessStatus )
  541. {
  542. return( ERROR_ACCESS_DENIED );
  543. }
  544. if ( !IsDDMRunning() )
  545. {
  546. return( ERROR_DDM_NOT_RUNNING );
  547. }
  548. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  549. {
  550. return( ERROR_DDM_NOT_RUNNING );
  551. }
  552. else
  553. {
  554. DWORD (*DDMAdminPortDisconnect)( HANDLE ) =
  555. (DWORD(*)( HANDLE ) )GetDDMEntryPoint("DDMAdminPortDisconnect");
  556. if(NULL == DDMAdminPortDisconnect)
  557. {
  558. return ERROR_PROC_NOT_FOUND;
  559. }
  560. return( DDMAdminPortDisconnect( DimIndexToHandle(hPort ) ));
  561. }
  562. }
  563. //**
  564. //
  565. // Call: RRasAdminConnectionNotification
  566. //
  567. // Returns: NO_ERROR - Success
  568. // Non-zero returns - Failure
  569. //
  570. // Description:
  571. //
  572. DWORD
  573. RRasAdminConnectionNotification(
  574. IN MPR_SERVER_HANDLE hMprServer,
  575. IN DWORD fRegister,
  576. IN DWORD dwCallersProcessId,
  577. IN ULONG_PTR hEventNotification
  578. )
  579. {
  580. DWORD dwRetCode = NO_ERROR;
  581. DWORD dwAccessStatus;
  582. DWORD (*DDMRegisterConnectionNotification)( BOOL, HANDLE, HANDLE ) =
  583. (DWORD(*)( BOOL, HANDLE, HANDLE ))
  584. GetDDMEntryPoint("DDMRegisterConnectionNotification");
  585. //
  586. // Check if caller has access
  587. //
  588. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  589. {
  590. return( ERROR_ACCESS_DENIED );
  591. }
  592. if ( dwAccessStatus )
  593. {
  594. return( ERROR_ACCESS_DENIED );
  595. }
  596. if ( !IsDDMRunning() )
  597. {
  598. return( ERROR_DDM_NOT_RUNNING );
  599. }
  600. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  601. {
  602. return( ERROR_DDM_NOT_RUNNING );
  603. }
  604. if ( (BOOL)fRegister )
  605. {
  606. HANDLE hEventDuplicated = NULL;
  607. HANDLE hClientProcess = NULL;
  608. do
  609. {
  610. //
  611. // Get process handle of the caller of this API
  612. //
  613. hClientProcess = OpenProcess(
  614. STANDARD_RIGHTS_REQUIRED | SPECIFIC_RIGHTS_ALL,
  615. FALSE,
  616. dwCallersProcessId);
  617. if ( hClientProcess == NULL )
  618. {
  619. dwRetCode = GetLastError();
  620. break;
  621. }
  622. //
  623. // Duplicate the handle to the event
  624. //
  625. if ( !DuplicateHandle(
  626. hClientProcess,
  627. (HANDLE)hEventNotification,
  628. GetCurrentProcess(),
  629. &hEventDuplicated,
  630. 0,
  631. FALSE,
  632. DUPLICATE_SAME_ACCESS ) )
  633. {
  634. dwRetCode = GetLastError();
  635. break;
  636. }
  637. dwRetCode = DDMRegisterConnectionNotification(
  638. TRUE,
  639. (HANDLE)hEventNotification,
  640. hEventDuplicated );
  641. }while( FALSE );
  642. if ( hClientProcess != NULL )
  643. {
  644. CloseHandle( hClientProcess );
  645. }
  646. if ( dwRetCode != NO_ERROR )
  647. {
  648. if ( hEventDuplicated != NULL )
  649. {
  650. CloseHandle( hEventDuplicated );
  651. }
  652. }
  653. }
  654. else
  655. {
  656. dwRetCode = DDMRegisterConnectionNotification(
  657. FALSE,
  658. (HANDLE)hEventNotification,
  659. NULL );
  660. }
  661. return( dwRetCode );
  662. }
  663. //**
  664. //
  665. // Call: RRasAdminSendUserMessage
  666. //
  667. // Returns: NO_ERROR - Success
  668. // Non-zero returns - Failure
  669. //
  670. // Description: Send message for ARAP
  671. //
  672. DWORD
  673. RRasAdminSendUserMessage(
  674. IN MPR_SERVER_HANDLE hMprServer,
  675. IN DWORD hRasConnection,
  676. IN LPWSTR lpwszMessage
  677. )
  678. {
  679. DWORD dwAccessStatus;
  680. DWORD (*DDMSendUserMessage)(HANDLE, LPWSTR ) =
  681. (DWORD(*)( HANDLE, LPWSTR ) )GetDDMEntryPoint("DDMSendUserMessage");
  682. //
  683. // Check if caller has access
  684. //
  685. if ( DimSecObjAccessCheck( DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR )
  686. {
  687. return( ERROR_ACCESS_DENIED );
  688. }
  689. if ( dwAccessStatus )
  690. {
  691. return( ERROR_ACCESS_DENIED );
  692. }
  693. if ( !IsDDMRunning() )
  694. {
  695. return( ERROR_DDM_NOT_RUNNING );
  696. }
  697. if ( gblDIMConfigInfo.dwRouterRole == ROUTER_ROLE_LAN )
  698. {
  699. return( ERROR_DDM_NOT_RUNNING );
  700. }
  701. return( DDMSendUserMessage( (HANDLE)UlongToPtr(hRasConnection), lpwszMessage ) );
  702. }
  703. DWORD
  704. RRasAdminConnectionRemoveQuarantine(
  705. IN MPR_SERVER_HANDLE hMprServer,
  706. IN DWORD hRasConnection,
  707. IN BOOL fIsIpAddress)
  708. {
  709. DWORD dwAccessStatus;
  710. DWORD (*DDMAdminRemoveQuarantine) (HANDLE, BOOL) =
  711. (DWORD (*) (HANDLE, BOOL))
  712. GetDDMEntryPoint("DDMAdminRemoveQuarantine");
  713. //
  714. // Check to see if caller has access
  715. //
  716. if(DimSecObjAccessCheck(DIMSVC_ALL_ACCESS, &dwAccessStatus) != NO_ERROR)
  717. {
  718. //
  719. // Check to see if the thread is running as local service.
  720. // We want services running as local service to also be able
  721. // to remove the quarantine on a connection.
  722. //
  723. if(!DimIsLocalService())
  724. {
  725. return ERROR_ACCESS_DENIED;
  726. }
  727. }
  728. if(!IsDDMRunning())
  729. {
  730. return ERROR_DDM_NOT_RUNNING;
  731. }
  732. return DDMAdminRemoveQuarantine((HANDLE)
  733. UlongToPtr(hRasConnection), fIsIpAddress);
  734. }