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

954 lines
26 KiB

  1. /*++
  2. Copyright (c) 1995-2001 Microsoft Corporation
  3. Module Name:
  4. logconf.c
  5. Abstract:
  6. This module contains the API routines that operate directly on logical
  7. configurations.
  8. CM_Add_Empty_Log_Conf
  9. CM_Free_Log_Conf
  10. CM_Get_First_Log_Conf
  11. CM_Get_Next_Log_Conf
  12. CM_Free_Log_Conf_Handle
  13. CM_Get_Log_Conf_Priority_Ex
  14. Author:
  15. Paula Tomlinson (paulat) 9-26-1995
  16. Environment:
  17. User mode only.
  18. Revision History:
  19. 26-Sept-1995 paulat
  20. Creation and initial implementation.
  21. --*/
  22. //
  23. // includes
  24. //
  25. #include "precomp.h"
  26. #include "cfgi.h"
  27. #include "setupapi.h"
  28. #include "spapip.h"
  29. //
  30. // Private prototypes
  31. //
  32. CONFIGRET
  33. CreateLogConfHandle(
  34. PLOG_CONF plcLogConf,
  35. DEVINST dnDevInst,
  36. ULONG ulLogType,
  37. ULONG ulLogTag
  38. );
  39. BOOL
  40. ValidateLogConfHandle(
  41. PPrivate_Log_Conf_Handle pLogConf
  42. );
  43. CONFIGRET
  44. CM_Add_Empty_Log_Conf_Ex(
  45. OUT PLOG_CONF plcLogConf,
  46. IN DEVINST dnDevInst,
  47. IN PRIORITY Priority,
  48. IN ULONG ulFlags,
  49. IN HMACHINE hMachine
  50. )
  51. /*++
  52. Routine Description:
  53. This routine creates an empty logical configuration. This configuration
  54. has no resource descriptor.
  55. Parameters:
  56. plcLogConf Address of a variable that receives the handle of the logical
  57. configuration.
  58. dnDevNode Handle of a device instance. This handle is typically
  59. retrieved by a call to CM_Locate_DevNode or CM_Create_DevNode.
  60. Priority Specifies the priority of the logical configuration.
  61. ulFlags Supplies flags relating to the logical configuration. Must
  62. be either BASIC_LOG_CONF or FILTERED_LOG_CONF, combined with
  63. either PRIORITY_EQUAL_FIRST or PRIORITY_EQUAL_LAST.
  64. BASIC_LOG_CONF - Specifies the requirements list
  65. FILTERED_LOG_CONF - Specifies the filtered requirements list
  66. PRIORITY_EQUAL_FIRST - Same priority, new one is first
  67. PRIORITY_EQUAL_LAST - Same priority, new one is last
  68. hMachine Machine handle returned from CM_Connect_Machine or NULL.
  69. Return Value:
  70. If the function succeeds, the return value is CR_SUCCESS.
  71. If the function fails, the return value is one of the following:
  72. CR_INVALID_DEVNODE,
  73. CR_INVALID_FLAG,
  74. CR_INVALID_POINTER,
  75. CR_OUT_OF_MEMORY,
  76. CR_INVALID_PRIORITY,
  77. CR_INVALID_LOG_CONF.
  78. --*/
  79. {
  80. CONFIGRET Status = CR_SUCCESS;
  81. WCHAR pDeviceID [MAX_DEVICE_ID_LEN];
  82. ULONG ulTag = 0;
  83. ULONG ulLen = MAX_DEVICE_ID_LEN;
  84. PVOID hStringTable = NULL;
  85. handle_t hBinding = NULL;
  86. BOOL Success;
  87. try {
  88. //
  89. // validate parameters
  90. //
  91. if (dnDevInst == 0) {
  92. Status = CR_INVALID_DEVINST;
  93. goto Clean0;
  94. }
  95. if (plcLogConf == NULL) {
  96. Status = CR_INVALID_POINTER;
  97. goto Clean0;
  98. }
  99. if (Priority > MAX_LCPRI) {
  100. Status = CR_INVALID_PRIORITY;
  101. goto Clean0;
  102. }
  103. if (INVALID_FLAGS(ulFlags, LOG_CONF_BITS | PRIORITY_BIT)) {
  104. Status = CR_INVALID_FLAG;
  105. goto Clean0;
  106. }
  107. //
  108. // initialize output parameters
  109. //
  110. *plcLogConf = 0;
  111. //
  112. // setup rpc binding handle and string table handle
  113. //
  114. if (!PnPGetGlobalHandles(hMachine, &hStringTable, &hBinding)) {
  115. Status = CR_FAILURE;
  116. goto Clean0;
  117. }
  118. //
  119. // retreive device instance string that corresponds to dnDevInst
  120. //
  121. Success = pSetupStringTableStringFromIdEx(hStringTable, dnDevInst,pDeviceID,&ulLen);
  122. if (Success == FALSE || INVALID_DEVINST(pDeviceID)) {
  123. Status = CR_INVALID_DEVINST; // "input" devinst doesn't exist
  124. goto Clean0;
  125. }
  126. RpcTryExcept {
  127. //
  128. // call rpc service entry point
  129. //
  130. Status = PNP_AddEmptyLogConf(
  131. hBinding, // rpc binding handle
  132. pDeviceID, // device id string
  133. Priority, // priority for new log conf
  134. &ulTag, // return tag of log conf
  135. ulFlags); // type of log conf to add
  136. }
  137. RpcExcept (I_RpcExceptionFilter(RpcExceptionCode())) {
  138. KdPrintEx((DPFLTR_PNPMGR_ID,
  139. DBGF_ERRORS,
  140. "PNP_AddEmptyLogConf caused an exception (%d)\n",
  141. RpcExceptionCode()));
  142. Status = MapRpcExceptionToCR(RpcExceptionCode());
  143. }
  144. RpcEndExcept
  145. if (Status == CR_SUCCESS) {
  146. //
  147. // allocate a new log conf handle, fill with log conf info
  148. //
  149. Status = CreateLogConfHandle(plcLogConf, dnDevInst,
  150. ulFlags & LOG_CONF_BITS,
  151. ulTag);
  152. }
  153. Clean0:
  154. NOTHING;
  155. } except(EXCEPTION_EXECUTE_HANDLER) {
  156. Status = CR_FAILURE;
  157. }
  158. return Status;
  159. } // CM_Add_Empty_Log_Conf_Ex
  160. CONFIGRET
  161. CM_Free_Log_Conf_Ex(
  162. IN LOG_CONF lcLogConfToBeFreed,
  163. IN ULONG ulFlags,
  164. IN HMACHINE hMachine
  165. )
  166. /*++
  167. Routine Description:
  168. This routine frees a logical configuration and all resource descriptors
  169. associated with it. This API may invalidate the logical configuration
  170. handles returned by the CM_Get_First_Log_Conf and CM_Get_Next_Log_Conf
  171. APIs. To continue enumerating logical configurations, always use the
  172. CM_Get_First_Log_Conf API to start again from the beginning.
  173. Parameters:
  174. lcLogConfToBeFreed Supplies the handle of the logical configuration to
  175. free. This handle must have been previously returned from
  176. a call to CM_Add_Empty_Log_Conf.
  177. ulFlags Must be zero.
  178. hMachine Machine handle returned from CM_Connect_Machine or NULL.
  179. Return Value:
  180. If the function succeeds, the return value is CR_SUCCESS.
  181. If the function fails, the return value is one of the following:
  182. CR_INVALID_FLAG,
  183. CR_INVALID_LOG_CONF.
  184. --*/
  185. {
  186. CONFIGRET Status = CR_SUCCESS;
  187. DEVINST dnDevInst;
  188. ULONG ulTag, ulType,ulLen = MAX_DEVICE_ID_LEN;
  189. WCHAR pDeviceID [MAX_DEVICE_ID_LEN];
  190. PVOID hStringTable = NULL;
  191. handle_t hBinding = NULL;
  192. BOOL Success;
  193. try {
  194. //
  195. // validate parameters
  196. //
  197. if (!ValidateLogConfHandle((PPrivate_Log_Conf_Handle)lcLogConfToBeFreed)) {
  198. Status = CR_INVALID_LOG_CONF;
  199. goto Clean0;
  200. }
  201. if (INVALID_FLAGS(ulFlags, 0)) {
  202. Status = CR_INVALID_FLAG;
  203. goto Clean0;
  204. }
  205. //
  206. // extract the devnode and log conf info from the log conf handle
  207. //
  208. dnDevInst = ((PPrivate_Log_Conf_Handle)lcLogConfToBeFreed)->LC_DevInst;
  209. ulTag = ((PPrivate_Log_Conf_Handle)lcLogConfToBeFreed)->LC_LogConfTag;
  210. ulType = ((PPrivate_Log_Conf_Handle)lcLogConfToBeFreed)->LC_LogConfType;
  211. //
  212. // setup rpc binding handle and string table handle
  213. //
  214. if (!PnPGetGlobalHandles(hMachine, &hStringTable, &hBinding)) {
  215. Status = CR_FAILURE;
  216. goto Clean0;
  217. }
  218. //
  219. // retreive device instance string that corresponds to dnDevInst
  220. //
  221. Success = pSetupStringTableStringFromIdEx(hStringTable, dnDevInst,pDeviceID,&ulLen);
  222. if (Success == FALSE || INVALID_DEVINST(pDeviceID)) {
  223. Status = CR_INVALID_LOG_CONF;
  224. goto Clean0;
  225. }
  226. KdPrintEx((DPFLTR_PNPMGR_ID,
  227. DBGF_REGISTRY,
  228. "CM_Free_Log_Conf_Ex: Deleting LogConf (pDeviceID = %s, Type = %d\r\n",
  229. pDeviceID,
  230. ulType));
  231. RpcTryExcept {
  232. //
  233. // call rpc service entry point
  234. //
  235. Status = PNP_FreeLogConf(
  236. hBinding, // rpc binding handle
  237. pDeviceID, // device id string
  238. ulType, // identifies which type of log conf
  239. ulTag, // identifies which actual log conf
  240. ulFlags); // not used
  241. }
  242. RpcExcept (I_RpcExceptionFilter(RpcExceptionCode())) {
  243. KdPrintEx((DPFLTR_PNPMGR_ID,
  244. DBGF_ERRORS,
  245. "PNP_FreeLogConf caused an exception (%d)\n",
  246. RpcExceptionCode()));
  247. Status = MapRpcExceptionToCR(RpcExceptionCode());
  248. }
  249. RpcEndExcept
  250. Clean0:
  251. NOTHING;
  252. } except(EXCEPTION_EXECUTE_HANDLER) {
  253. Status = CR_INVALID_LOG_CONF; // probably a bad log conf got us here
  254. }
  255. return Status;
  256. } // CM_Free_Log_Conf_Ex
  257. CONFIGRET
  258. CM_Get_First_Log_Conf_Ex(
  259. OUT PLOG_CONF plcLogConf, OPTIONAL
  260. IN DEVINST dnDevInst,
  261. IN ULONG ulFlags,
  262. IN HMACHINE hMachine
  263. )
  264. /*++
  265. Routine Description:
  266. This routine returns a handle to the first logical configuration of the
  267. specified type in a device instance. The CM_Add_Empty_Log_Conf and
  268. CM_Free_Log_Conf APIs may invalidate the handle of the logical
  269. configuration returned by this API. To enumerate logical configurations
  270. after adding or freeing a logical configuration, always call this API
  271. again to retrieve a valid handle.
  272. Parameters:
  273. plcLogConf Supplies the address of the variable that receives the handle
  274. of the logical configuration.
  275. dnDevNode Supplies the handle of the device instance for which to
  276. retrieve the logical configuration.
  277. ulFlags Configuration type. Can be one of the following values:
  278. ALLOC_LOG_CONF - Retrieve the allocated configuration.
  279. BASIC_LOG_CONF - Retrieve the requirements list.
  280. BOOT_LOG_CONF - Retrieve the boot configuration.
  281. The following additional configuration type is also defined
  282. for Windows 95:
  283. FILTERED_LOG_CONF - Retrieve the filtered requirements list.
  284. hMachine Machine handle returned from CM_Connect_Machine or NULL.
  285. Return Value:
  286. If the function succeeds, the return value is CR_SUCCESS.
  287. If the function fails, the return value is one of the following:
  288. CR_INVALID_DEVNODE,
  289. CR_INVALID_FLAG,
  290. CR_INVALID_POINTER,
  291. CR_NO_MORE_LOF_CONF.
  292. --*/
  293. {
  294. CONFIGRET Status = CR_SUCCESS;
  295. WCHAR pDeviceID [MAX_DEVICE_ID_LEN];
  296. ULONG ulTag = 0,ulLen = MAX_DEVICE_ID_LEN;
  297. PVOID hStringTable = NULL;
  298. handle_t hBinding = NULL;
  299. BOOL Success;
  300. try {
  301. //
  302. // validate parameters
  303. //
  304. if (dnDevInst == 0) {
  305. Status = CR_INVALID_DEVINST;
  306. goto Clean0;
  307. }
  308. if (INVALID_FLAGS(ulFlags, LOG_CONF_BITS)) {
  309. Status = CR_INVALID_FLAG;
  310. goto Clean0;
  311. }
  312. //
  313. // Initialize paramters (plcLogConf is optional)
  314. //
  315. if (plcLogConf != NULL) {
  316. *plcLogConf = 0;
  317. }
  318. //
  319. // setup rpc binding handle and string table handle
  320. //
  321. if (!PnPGetGlobalHandles(hMachine, &hStringTable, &hBinding)) {
  322. Status = CR_FAILURE;
  323. goto Clean0;
  324. }
  325. //
  326. // retreive device instance string that corresponds to dnDevInst
  327. //
  328. Success = pSetupStringTableStringFromIdEx(hStringTable, dnDevInst,pDeviceID,&ulLen);
  329. if (Success == FALSE || INVALID_DEVINST(pDeviceID)) {
  330. Status = CR_INVALID_DEVINST; // "input" devinst doesn't exist
  331. goto Clean0;
  332. }
  333. RpcTryExcept {
  334. //
  335. // call rpc service entry point
  336. //
  337. Status = PNP_GetFirstLogConf(
  338. hBinding, // rpc binding handle
  339. pDeviceID, // device id string
  340. ulFlags, // type of long conf
  341. &ulTag, // return tag of specific log conf
  342. ulFlags); // not used
  343. }
  344. RpcExcept (I_RpcExceptionFilter(RpcExceptionCode())) {
  345. KdPrintEx((DPFLTR_PNPMGR_ID,
  346. DBGF_ERRORS,
  347. "PNP_GetFirstLogConf caused an exception (%d)\n",
  348. RpcExceptionCode()));
  349. Status = MapRpcExceptionToCR(RpcExceptionCode());
  350. }
  351. RpcEndExcept
  352. if (Status == CR_SUCCESS && plcLogConf != NULL) {
  353. //
  354. // allocate a new log conf handle, fill with log conf info
  355. //
  356. Status = CreateLogConfHandle(plcLogConf, dnDevInst,
  357. ulFlags & LOG_CONF_BITS,
  358. ulTag);
  359. }
  360. Clean0:
  361. NOTHING;
  362. } except(EXCEPTION_EXECUTE_HANDLER) {
  363. Status = CR_FAILURE;
  364. }
  365. return Status;
  366. } // CM_Get_First_Log_Conf_Ex
  367. CONFIGRET
  368. CM_Get_Next_Log_Conf_Ex(
  369. OUT PLOG_CONF plcLogConf, OPTIONAL
  370. IN LOG_CONF lcLogConf,
  371. IN ULONG ulFlags,
  372. IN HMACHINE hMachine
  373. )
  374. /*++
  375. Routine Description:
  376. This routine returns a handle to the next logical configuration following
  377. the given configuration. This API returns CR_NO_MORE_LOG_CONF if the given
  378. handle was retrieved using the CM_Get_First_Log_Conf API with either the
  379. ALLOC_LOG_CONF or BOOT_LOG_CONF flag. There is never more than one active
  380. boot logical configuration or currently-allocated logical configuration.
  381. The CM_Add_Empty_Log_Conf and CM_Free_Log_Conf APIs may invalidate the
  382. logical configuration handle returned by this API. To continue enumerating
  383. logical configuration after addding or freeing a logical configuration,
  384. always use the CM_Get_First_Log_Conf API to start again from the beginning.
  385. Parameters:
  386. plcLogConf Supplies the address of the variable that receives the handle
  387. of the next logical configuration.
  388. lcLogConf Supplies the handle of a logical configuration. This handle
  389. must have been previously retrieved using either this API or
  390. the CM_Get_First_Log_Conf API. Logical configurations are in
  391. priority order.
  392. ulFlags Must be zero.
  393. hMachine Machine handle returned from CM_Connect_Machine or NULL.
  394. Return Value:
  395. If the function succeeds, the return value is CR_SUCCESS.
  396. If the function fails, the return value is one of the following:
  397. CR_INVALID_FLAG,
  398. CR_INVALID_LOG_CONF,
  399. CR_INVALID_POINTER,
  400. CR_NO_MORE_LOG_CONF.
  401. --*/
  402. {
  403. CONFIGRET Status = CR_SUCCESS;
  404. DEVINST dnDevInst;
  405. WCHAR pDeviceID [MAX_DEVICE_ID_LEN];
  406. ULONG ulType = 0, ulCurrentTag = 0, ulNextTag = 0,ulLen = MAX_DEVICE_ID_LEN;
  407. PVOID hStringTable = NULL;
  408. handle_t hBinding = NULL;
  409. BOOL Success;
  410. try {
  411. //
  412. // validate parameters
  413. //
  414. if (!ValidateLogConfHandle((PPrivate_Log_Conf_Handle)lcLogConf)) {
  415. Status = CR_INVALID_LOG_CONF;
  416. goto Clean0;
  417. }
  418. if (INVALID_FLAGS(ulFlags, 0)) {
  419. Status = CR_INVALID_FLAG;
  420. goto Clean0;
  421. }
  422. //
  423. // Initialize paramters (plcLogConf is optional)
  424. //
  425. if (plcLogConf != NULL) {
  426. *plcLogConf = 0;
  427. }
  428. //
  429. // extract devnode and log conf info from the current log conf handle
  430. //
  431. dnDevInst = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_DevInst;
  432. ulType = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_LogConfType;
  433. ulCurrentTag = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_LogConfTag;
  434. //
  435. // setup rpc binding handle and string table handle
  436. //
  437. if (!PnPGetGlobalHandles(hMachine, &hStringTable, &hBinding)) {
  438. Status = CR_FAILURE;
  439. goto Clean0;
  440. }
  441. //
  442. // retreive device instance string that corresponds to dnDevInst
  443. //
  444. Success = pSetupStringTableStringFromIdEx(hStringTable, dnDevInst,pDeviceID,&ulLen);
  445. if (Success == FALSE || INVALID_DEVINST(pDeviceID)) {
  446. Status = CR_INVALID_LOG_CONF;
  447. goto Clean0;
  448. }
  449. RpcTryExcept {
  450. //
  451. // call rpc service entry point
  452. //
  453. Status = PNP_GetNextLogConf(
  454. hBinding, // rpc binding handle
  455. pDeviceID, // device id string
  456. ulType, // specifes which type of log conf
  457. ulCurrentTag, // specifies current log conf tag
  458. &ulNextTag, // return tag of next log conf
  459. ulFlags); // not used
  460. }
  461. RpcExcept (I_RpcExceptionFilter(RpcExceptionCode())) {
  462. KdPrintEx((DPFLTR_PNPMGR_ID,
  463. DBGF_ERRORS,
  464. "PNP_GetNextLogConf caused an exception (%d)\n",
  465. RpcExceptionCode()));
  466. Status = MapRpcExceptionToCR(RpcExceptionCode());
  467. }
  468. RpcEndExcept
  469. if (Status == CR_SUCCESS && plcLogConf != NULL) {
  470. //
  471. // allocate a new log conf handle, fill with log conf info
  472. //
  473. Status = CreateLogConfHandle(plcLogConf, dnDevInst,
  474. ulType, ulNextTag);
  475. }
  476. Clean0:
  477. NOTHING;
  478. } except(EXCEPTION_EXECUTE_HANDLER) {
  479. Status = CR_FAILURE;
  480. }
  481. return Status;
  482. } // CM_Get_Next_Log_Conf_Ex
  483. CONFIGRET
  484. CM_Free_Log_Conf_Handle(
  485. IN LOG_CONF lcLogConf
  486. )
  487. /*++
  488. Routine Description:
  489. This routine frees the handle to the specified log conf and frees and
  490. memory associated with that log conf handle.
  491. Parameters:
  492. lcLogConf Supplies the handle of a logical configuration. This handle
  493. must have been previously retrieved using CM_Add_Empty_Log_Conf,
  494. CM_Get_First_Log_Conf or CM_Get_Next_Log_Conf.
  495. Return Value:
  496. If the function succeeds, the return value is CR_SUCCESS.
  497. If the function fails, the return value is one of the following:
  498. CR_INVALID_LOG_CONF.
  499. --*/
  500. {
  501. CONFIGRET Status = CR_SUCCESS;
  502. try {
  503. //
  504. // Validate parameters
  505. //
  506. if (!ValidateLogConfHandle((PPrivate_Log_Conf_Handle)lcLogConf)) {
  507. Status = CR_INVALID_LOG_CONF;
  508. goto Clean0;
  509. }
  510. //
  511. // It's a valid log conf handle, which is a pointer to memory
  512. // allocated when the log conf was created or retrieved using
  513. // the first/next routines. Free the associated memory.
  514. //
  515. ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_Signature = 0;
  516. pSetupFree((PPrivate_Log_Conf_Handle)lcLogConf);
  517. Clean0:
  518. NOTHING;
  519. } except(EXCEPTION_EXECUTE_HANDLER) {
  520. Status = CR_FAILURE;
  521. }
  522. return Status;
  523. } // CM_Free_Log_Conf_Handle
  524. CMAPI
  525. CONFIGRET
  526. WINAPI
  527. CM_Get_Log_Conf_Priority_Ex(
  528. IN LOG_CONF lcLogConf,
  529. OUT PPRIORITY pPriority,
  530. IN ULONG ulFlags,
  531. IN HMACHINE hMachine
  532. )
  533. /*++
  534. Routine Description:
  535. This routine returns the priority value of the specified log conf.
  536. Only BASIC, FILTERED and OVERRIDE log confs (requirements lists) have
  537. a priority value associated with them. If a FORCED, BOOT, or ALLOC
  538. config is passed in, then CR_INVALID_LOG_CONF will be returned.
  539. Parameters:
  540. lcLogConf Supplies the handle of a logical configuration. This handle
  541. must have been previously retrieved using either the
  542. CM_Add_Emptry_Log_Conf, CM_Get_First_Log_Conf, or
  543. CM_Get_Next_Log_Conf API.
  544. pPriority Supplies the address of the variable that receives the
  545. priorty (if any) associated with this logical configuration.
  546. ulFlags Must be zero.
  547. hMachine Machine handle returned from CM_Connect_Machine or NULL.
  548. Return Value:
  549. If the function succeeds, the return value is CR_SUCCESS.
  550. If the function fails, the return value is one of the following:
  551. CR_INVALID_FLAG,
  552. CR_INVALID_LOG_CONF,
  553. CR_INVALID_POINTER,
  554. CR_NO_MORE_LOG_CONF.
  555. --*/
  556. {
  557. CONFIGRET Status = CR_SUCCESS;
  558. DEVINST dnDevInst;
  559. WCHAR pDeviceID [MAX_DEVICE_ID_LEN];
  560. ULONG ulType = 0, ulTag = 0,ulLen = MAX_DEVICE_ID_LEN;
  561. PVOID hStringTable = NULL;
  562. handle_t hBinding = NULL;
  563. BOOL Success;
  564. try {
  565. //
  566. // validate parameters
  567. //
  568. if (!ValidateLogConfHandle((PPrivate_Log_Conf_Handle)lcLogConf)) {
  569. Status = CR_INVALID_LOG_CONF;
  570. goto Clean0;
  571. }
  572. if (INVALID_FLAGS(ulFlags, 0)) {
  573. Status = CR_INVALID_FLAG;
  574. goto Clean0;
  575. }
  576. if (pPriority == NULL) {
  577. Status = CR_INVALID_POINTER;
  578. goto Clean0;
  579. }
  580. //
  581. // extract devnode and log conf info from the current log conf handle
  582. //
  583. dnDevInst = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_DevInst;
  584. ulType = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_LogConfType;
  585. ulTag = ((PPrivate_Log_Conf_Handle)lcLogConf)->LC_LogConfTag;
  586. //
  587. // only "requirements list" style log confs have priorities and
  588. // are valid in this call.
  589. //
  590. if ((ulType != BASIC_LOG_CONF) &&
  591. (ulType != FILTERED_LOG_CONF) &&
  592. (ulType != OVERRIDE_LOG_CONF)) {
  593. Status = CR_INVALID_LOG_CONF;
  594. goto Clean0;
  595. }
  596. //
  597. // setup rpc binding handle and string table handle
  598. //
  599. if (!PnPGetGlobalHandles(hMachine, &hStringTable, &hBinding)) {
  600. Status = CR_FAILURE;
  601. goto Clean0;
  602. }
  603. //
  604. // retreive device instance string that corresponds to dnDevInst
  605. //
  606. Success = pSetupStringTableStringFromIdEx(hStringTable, dnDevInst,pDeviceID,&ulLen);
  607. if (Success == FALSE || INVALID_DEVINST(pDeviceID)) {
  608. Status = CR_INVALID_LOG_CONF;
  609. goto Clean0;
  610. }
  611. RpcTryExcept {
  612. //
  613. // call rpc service entry point
  614. //
  615. Status = PNP_GetLogConfPriority(
  616. hBinding, // rpc binding handle
  617. pDeviceID, // device id string
  618. ulType, // specifes which type of log conf
  619. ulTag, // specifies current log conf tag
  620. pPriority, // return tag of next log conf
  621. ulFlags); // not used
  622. }
  623. RpcExcept (I_RpcExceptionFilter(RpcExceptionCode())) {
  624. KdPrintEx((DPFLTR_PNPMGR_ID,
  625. DBGF_ERRORS,
  626. "PNP_GetLogConfPriority caused an exception (%d)\n",
  627. RpcExceptionCode()));
  628. Status = MapRpcExceptionToCR(RpcExceptionCode());
  629. }
  630. RpcEndExcept
  631. Clean0:
  632. NOTHING;
  633. } except(EXCEPTION_EXECUTE_HANDLER) {
  634. Status = CR_FAILURE;
  635. }
  636. return Status;
  637. } // CM_Free_Log_Conf_Handle
  638. //-------------------------------------------------------------------
  639. // Local Stubs
  640. //-------------------------------------------------------------------
  641. CONFIGRET
  642. CM_Add_Empty_Log_Conf(
  643. OUT PLOG_CONF plcLogConf,
  644. IN DEVINST dnDevInst,
  645. IN PRIORITY Priority,
  646. IN ULONG ulFlags
  647. )
  648. {
  649. return CM_Add_Empty_Log_Conf_Ex(plcLogConf, dnDevInst, Priority,
  650. ulFlags, NULL);
  651. }
  652. CONFIGRET
  653. CM_Free_Log_Conf(
  654. IN LOG_CONF lcLogConfToBeFreed,
  655. IN ULONG ulFlags
  656. )
  657. {
  658. return CM_Free_Log_Conf_Ex(lcLogConfToBeFreed, ulFlags, NULL);
  659. }
  660. CONFIGRET
  661. CM_Get_First_Log_Conf(
  662. OUT PLOG_CONF plcLogConf,
  663. IN DEVINST dnDevInst,
  664. IN ULONG ulFlags
  665. )
  666. {
  667. return CM_Get_First_Log_Conf_Ex(plcLogConf, dnDevInst, ulFlags, NULL);
  668. }
  669. CONFIGRET
  670. CM_Get_Next_Log_Conf(
  671. OUT PLOG_CONF plcLogConf,
  672. IN LOG_CONF lcLogConf,
  673. IN ULONG ulFlags
  674. )
  675. {
  676. return CM_Get_Next_Log_Conf_Ex(plcLogConf, lcLogConf, ulFlags, NULL);
  677. }
  678. CMAPI
  679. CONFIGRET
  680. WINAPI
  681. CM_Get_Log_Conf_Priority(
  682. IN LOG_CONF lcLogConf,
  683. OUT PPRIORITY pPriority,
  684. IN ULONG ulFlags
  685. )
  686. {
  687. return CM_Get_Log_Conf_Priority_Ex(lcLogConf, pPriority, ulFlags, NULL);
  688. }
  689. //-------------------------------------------------------------------
  690. // Local Utility Routines
  691. //-------------------------------------------------------------------
  692. CONFIGRET
  693. CreateLogConfHandle(
  694. PLOG_CONF plcLogConf,
  695. DEVINST dnDevInst,
  696. ULONG ulLogType,
  697. ULONG ulLogTag
  698. )
  699. {
  700. PPrivate_Log_Conf_Handle pLogConfHandle;
  701. //
  702. // allocate memory for the res des handle data
  703. //
  704. pLogConfHandle = (PPrivate_Log_Conf_Handle)pSetupMalloc(
  705. sizeof(Private_Log_Conf_Handle));
  706. if (pLogConfHandle == NULL) {
  707. return CR_OUT_OF_MEMORY;
  708. }
  709. //
  710. // fill in the private res des info and return as handle
  711. //
  712. pLogConfHandle->LC_Signature = CM_PRIVATE_LOGCONF_SIGNATURE;
  713. pLogConfHandle->LC_DevInst = dnDevInst;
  714. pLogConfHandle->LC_LogConfType = ulLogType;
  715. pLogConfHandle->LC_LogConfTag = ulLogTag;
  716. *plcLogConf = (LOG_CONF)pLogConfHandle;
  717. return CR_SUCCESS;
  718. } // CreateLogConfHandle
  719. BOOL
  720. ValidateLogConfHandle(
  721. PPrivate_Log_Conf_Handle pLogConf
  722. )
  723. {
  724. //
  725. // validate parameters
  726. //
  727. if (pLogConf == NULL || pLogConf == 0) {
  728. return FALSE;
  729. }
  730. //
  731. // check for the private log conf signature
  732. //
  733. if (pLogConf->LC_Signature != CM_PRIVATE_LOGCONF_SIGNATURE) {
  734. return FALSE;
  735. }
  736. return TRUE;
  737. } // ValidateLogConfHandle