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.

976 lines
29 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. dgm.c
  5. Abstract:
  6. Implements the initialization/termination code for the data gather portion
  7. of scanstate v1 compatiblity.
  8. Author:
  9. Calin Negreanu (calinn) 16-Mar-2000
  10. Revision History:
  11. <alias> <date> <comments>
  12. --*/
  13. //
  14. // Includes
  15. //
  16. #include "pch.h"
  17. #include "v1p.h"
  18. #define DBG_V1 "v1"
  19. //
  20. // Strings
  21. //
  22. // None
  23. //
  24. // Constants
  25. //
  26. // None
  27. //
  28. // Macros
  29. //
  30. // None
  31. //
  32. // Types
  33. //
  34. // None
  35. //
  36. // Globals
  37. //
  38. MIG_OPERATIONID g_DestAddObject;
  39. //
  40. // Macro expansion list
  41. //
  42. // None
  43. //
  44. // Private function prototypes
  45. //
  46. DGMINITIALIZE ScriptDgmInitialize;
  47. DGMQUEUEENUMERATION ScriptDgmQueueEnumeration;
  48. //
  49. // Macro expansion definition
  50. //
  51. // None
  52. //
  53. // Code
  54. //
  55. BOOL
  56. WINAPI
  57. ScriptDgmInitialize (
  58. IN PMIG_LOGCALLBACK LogCallback,
  59. IN PVOID Reserved
  60. )
  61. {
  62. TCHAR userName[256];
  63. TCHAR domainName[256];
  64. LogReInit (NULL, NULL, NULL, (PLOGCALLBACK) LogCallback);
  65. if (IsmIsEnvironmentFlagSet (PLATFORM_DESTINATION, NULL, S_ENV_CREATE_USER)) {
  66. if (!IsmGetEnvironmentString (
  67. PLATFORM_SOURCE,
  68. S_SYSENVVAR_GROUP,
  69. TEXT("USERNAME"),
  70. userName,
  71. sizeof (userName),
  72. NULL
  73. )) {
  74. IsmSetCancel();
  75. SetLastError (ERROR_INVALID_DATA);
  76. LOG ((LOG_ERROR, (PCSTR) MSG_USER_REQUIRED));
  77. return FALSE;
  78. }
  79. if (!IsmGetEnvironmentString (
  80. PLATFORM_SOURCE,
  81. S_SYSENVVAR_GROUP,
  82. TEXT("USERDOMAIN"),
  83. domainName,
  84. sizeof (domainName),
  85. NULL
  86. )) {
  87. IsmSetCancel();
  88. SetLastError (ERROR_INVALID_DOMAINNAME);
  89. LOG ((LOG_ERROR, (PCSTR) MSG_DOMAIN_REQUIRED));
  90. return FALSE;
  91. }
  92. LOG ((LOG_INFORMATION, (PCSTR) MSG_PROFILE_CREATE_INFO, domainName, userName));
  93. if (!IsmCreateUser (userName, domainName)) {
  94. IsmSetCancel();
  95. return FALSE;
  96. }
  97. }
  98. return TRUE;
  99. }
  100. BOOL
  101. pParseDestinationDetect (
  102. IN HINF InfHandle
  103. )
  104. {
  105. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  106. BOOL result = FALSE;
  107. GROWBUFFER multiSz = INIT_GROWBUFFER;
  108. GROWBUFFER appList = INIT_GROWBUFFER;
  109. PCTSTR displayName = NULL;
  110. MULTISZ_ENUM e;
  111. UINT sizeNeeded;
  112. PCTSTR appSection = NULL;
  113. BOOL detected = FALSE;
  114. BOOL appFound = FALSE;
  115. QUESTION_DATA questionData;
  116. ULONG_PTR appResult;
  117. PCTSTR loadedStr = NULL;
  118. __try {
  119. if (!IsmGetEnvironmentMultiSz (
  120. PLATFORM_SOURCE,
  121. NULL,
  122. S_ENV_DEST_CHECKDETECT,
  123. NULL,
  124. 0,
  125. &sizeNeeded
  126. )) {
  127. result = TRUE;
  128. __leave;
  129. }
  130. if (!GbGrow (&multiSz, sizeNeeded)) {
  131. __leave;
  132. }
  133. if (!IsmGetEnvironmentMultiSz (
  134. PLATFORM_SOURCE,
  135. NULL,
  136. S_ENV_DEST_CHECKDETECT,
  137. (PTSTR) multiSz.Buf,
  138. multiSz.End,
  139. NULL
  140. )) {
  141. __leave;
  142. }
  143. loadedStr = GetStringResource (MSG_INSTALL_APPS1);
  144. if (loadedStr) {
  145. GbAppendString (&appList, loadedStr);
  146. FreeStringResource (loadedStr);
  147. loadedStr = NULL;
  148. }
  149. GbAppendString (&appList, TEXT("\n\n"));
  150. if (EnumFirstMultiSz (&e, (PCTSTR) multiSz.Buf)) {
  151. do {
  152. // e.CurrentString is the actual section that we need to execute
  153. // we are going to append a .DETECT to it though
  154. appSection = JoinText (e.CurrentString, TEXT(".Detect"));
  155. detected = ParseAppDetectSection (PLATFORM_DESTINATION, InfHandle, e.CurrentString, appSection);
  156. if (!detected) {
  157. // let's try to find the display name for this app
  158. if (InfFindFirstLine (InfHandle, TEXT("Strings"), e.CurrentString, &is)) {
  159. displayName = InfGetStringField (&is, 1);
  160. }
  161. if (!displayName) {
  162. displayName = e.CurrentString;
  163. }
  164. if (displayName) {
  165. appFound = TRUE;
  166. GbAppendString (&appList, TEXT("- "));
  167. GbAppendString (&appList, displayName);
  168. GbAppendString (&appList, TEXT("\n"));
  169. LOG ((LOG_WARNING, (PCSTR) MSG_APP_NOT_DETECTED, displayName));
  170. }
  171. }
  172. FreeText (appSection);
  173. appSection = NULL;
  174. GlFree (&g_SectionStack);
  175. } while (EnumNextMultiSz (&e));
  176. }
  177. result = TRUE;
  178. }
  179. __finally {
  180. GbFree (&multiSz);
  181. InfCleanUpInfStruct (&is);
  182. }
  183. // now, if we have something in our app list, we will send it to the wizard, so he can
  184. // prompt the user about it.
  185. if (appFound) {
  186. GbAppendString (&appList, TEXT("\n"));
  187. loadedStr = GetStringResource (MSG_INSTALL_APPS2);
  188. if (loadedStr) {
  189. GbAppendString (&appList, loadedStr);
  190. FreeStringResource (loadedStr);
  191. loadedStr = NULL;
  192. }
  193. GbAppendString (&appList, TEXT("\n"));
  194. // we have some applications that were not detected. Let's tell the wizard about them
  195. ZeroMemory (&questionData, sizeof (QUESTION_DATA));
  196. questionData.Question = (PCTSTR)appList.Buf;
  197. questionData.MessageStyle = MB_ICONWARNING | MB_OKCANCEL;
  198. questionData.WantedResult = IDOK;
  199. appResult = IsmSendMessageToApp (MODULEMESSAGE_ASKQUESTION, (ULONG_PTR)(&questionData));
  200. if (appResult != APPRESPONSE_SUCCESS) {
  201. // the user cancelled
  202. IsmSetCancel ();
  203. }
  204. }
  205. GbFree (&appList);
  206. return result;
  207. }
  208. UINT
  209. pSuppressDestinationSettings (
  210. IN PCMIG_OBJECTENUMDATA Data,
  211. IN ULONG_PTR CallerArg
  212. )
  213. {
  214. IsmMakeApplyObject (
  215. Data->ObjectTypeId,
  216. Data->ObjectName
  217. );
  218. IsmSetOperationOnObject (
  219. Data->ObjectTypeId,
  220. Data->ObjectName,
  221. g_DeleteOp,
  222. NULL,
  223. NULL
  224. );
  225. return CALLBACK_ENUM_CONTINUE;
  226. }
  227. BOOL
  228. pParseInfForExclude (
  229. IN HINF InfHandle
  230. )
  231. {
  232. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  233. PCTSTR pattern;
  234. ENCODEDSTRHANDLE srcHandle = NULL;
  235. ENCODEDSTRHANDLE srcBase = NULL;
  236. BOOL result = FALSE;
  237. GROWBUFFER multiSz = INIT_GROWBUFFER;
  238. MULTISZ_ENUM e;
  239. UINT sizeNeeded;
  240. BOOL hadLeaf = FALSE;
  241. __try {
  242. if (!IsmGetEnvironmentMultiSz (
  243. PLATFORM_SOURCE,
  244. NULL,
  245. S_ENV_DEST_DELREG,
  246. NULL,
  247. 0,
  248. &sizeNeeded
  249. )) {
  250. result = TRUE;
  251. __leave;
  252. }
  253. if (!GbGrow (&multiSz, sizeNeeded)) {
  254. __leave;
  255. }
  256. if (!IsmGetEnvironmentMultiSz (
  257. PLATFORM_SOURCE,
  258. NULL,
  259. S_ENV_DEST_DELREG,
  260. (PTSTR) multiSz.Buf,
  261. multiSz.End,
  262. NULL
  263. )) {
  264. __leave;
  265. }
  266. if (EnumFirstMultiSz (&e, (PCTSTR) multiSz.Buf)) {
  267. do {
  268. // on all systems, process "DestDelRegEx"
  269. if (InfFindFirstLine (InfHandle, e.CurrentString, NULL, &is)) {
  270. do {
  271. if (IsmCheckCancel()) {
  272. __leave;
  273. }
  274. pattern = InfGetStringField (&is, 0);
  275. if (!pattern) {
  276. LOG ((LOG_WARNING, (PCSTR) MSG_EMPTY_REG_SPEC));
  277. continue;
  278. }
  279. srcHandle = TurnRegStringIntoHandle (pattern, TRUE, &hadLeaf);
  280. if (!srcHandle) {
  281. LOG ((LOG_ERROR, (PCSTR) MSG_REG_SPEC_BAD, pattern));
  282. continue;
  283. }
  284. if (!hadLeaf) {
  285. srcBase = TurnRegStringIntoHandle (pattern, FALSE, NULL);
  286. if (!srcBase) {
  287. LOG ((LOG_ERROR, (PCSTR) MSG_REG_SPEC_BAD, pattern));
  288. continue;
  289. }
  290. IsmQueueEnumeration (
  291. g_RegType,
  292. srcBase,
  293. pSuppressDestinationSettings,
  294. 0,
  295. NULL
  296. );
  297. }
  298. IsmQueueEnumeration (
  299. g_RegType,
  300. srcHandle,
  301. pSuppressDestinationSettings,
  302. 0,
  303. NULL
  304. );
  305. IsmDestroyObjectHandle (srcHandle);
  306. srcHandle = NULL;
  307. } while (InfFindNextLine (&is));
  308. }
  309. } while (EnumNextMultiSz (&e));
  310. }
  311. result = TRUE;
  312. }
  313. __finally {
  314. GbFree (&multiSz);
  315. InfCleanUpInfStruct (&is);
  316. }
  317. return result;
  318. }
  319. BOOL
  320. pParseInfForExcludeEx (
  321. IN HINF InfHandle
  322. )
  323. {
  324. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  325. PCTSTR srcNode;
  326. PCTSTR srcLeaf;
  327. ENCODEDSTRHANDLE srcHandle = NULL;
  328. ENCODEDSTRHANDLE srcBase = NULL;
  329. BOOL result = FALSE;
  330. GROWBUFFER multiSz = INIT_GROWBUFFER;
  331. MULTISZ_ENUM e;
  332. UINT sizeNeeded;
  333. BOOL hadLeaf = FALSE;
  334. __try {
  335. if (!IsmGetEnvironmentMultiSz (
  336. PLATFORM_SOURCE,
  337. NULL,
  338. S_ENV_DEST_DELREGEX,
  339. NULL,
  340. 0,
  341. &sizeNeeded
  342. )) {
  343. result = TRUE;
  344. __leave;
  345. }
  346. if (!GbGrow (&multiSz, sizeNeeded)) {
  347. __leave;
  348. }
  349. if (!IsmGetEnvironmentMultiSz (
  350. PLATFORM_SOURCE,
  351. NULL,
  352. S_ENV_DEST_DELREGEX,
  353. (PTSTR) multiSz.Buf,
  354. multiSz.End,
  355. NULL
  356. )) {
  357. __leave;
  358. }
  359. if (EnumFirstMultiSz (&e, (PCTSTR) multiSz.Buf)) {
  360. do {
  361. // on all systems, process "DestDelReg"
  362. if (InfFindFirstLine (InfHandle, e.CurrentString, NULL, &is)) {
  363. do {
  364. if (IsmCheckCancel()) {
  365. __leave;
  366. }
  367. srcNode = InfGetStringField (&is, 1);
  368. srcLeaf = InfGetStringField (&is, 2);
  369. if (!srcNode && !srcLeaf) {
  370. LOG ((LOG_WARNING, (PCSTR) MSG_EMPTY_REG_SPEC));
  371. continue;
  372. }
  373. // Validate rule
  374. if (!StringIMatchTcharCount (srcNode, S_HKLM, ARRAYSIZE(S_HKLM) - 1) &&
  375. !StringIMatchTcharCount (srcNode, S_HKR, ARRAYSIZE(S_HKR) - 1) &&
  376. !StringIMatchTcharCount (srcNode, S_HKCC, ARRAYSIZE(S_HKCC) - 1)
  377. ) {
  378. LOG ((LOG_ERROR, (PCSTR) MSG_INVALID_REGROOT, srcNode));
  379. __leave;
  380. }
  381. srcHandle = CreatePatternFromNodeLeaf (srcNode, srcLeaf);
  382. if (!srcHandle) {
  383. LOG ((LOG_ERROR, (PCSTR) MSG_REG_SPEC_BAD, srcNode));
  384. __leave;
  385. }
  386. if (!hadLeaf) {
  387. srcBase = MakeRegExBase (srcNode, srcLeaf);
  388. if (!srcBase) {
  389. LOG ((LOG_ERROR, (PCSTR) MSG_REG_SPEC_BAD, srcNode));
  390. continue;
  391. }
  392. IsmQueueEnumeration (
  393. g_RegType,
  394. srcBase,
  395. pSuppressDestinationSettings,
  396. 0,
  397. NULL
  398. );
  399. }
  400. IsmQueueEnumeration (
  401. g_RegType,
  402. srcHandle,
  403. pSuppressDestinationSettings,
  404. 0,
  405. NULL
  406. );
  407. IsmDestroyObjectHandle (srcHandle);
  408. srcHandle = NULL;
  409. } while (InfFindNextLine (&is));
  410. }
  411. } while (EnumNextMultiSz (&e));
  412. }
  413. result = TRUE;
  414. }
  415. __finally {
  416. GbFree (&multiSz);
  417. InfCleanUpInfStruct (&is);
  418. }
  419. return result;
  420. }
  421. BOOL
  422. pParseInfForDestAdd (
  423. IN HINF InfHandle
  424. )
  425. {
  426. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  427. PCTSTR objectTypeName;
  428. UINT objectPriority;
  429. MIG_OBJECTTYPEID objectTypeId;
  430. PCTSTR objectMultiSz;
  431. MIG_CONTENT objectContent;
  432. MIG_OBJECTSTRINGHANDLE objectName;
  433. MIG_OBJECTID objectId;
  434. MIG_CONTENT existentContent;
  435. MIG_BLOB blob;
  436. MIG_DATAHANDLE dataHandle;
  437. BOOL added = FALSE;
  438. BOOL result = FALSE;
  439. GROWBUFFER multiSz = INIT_GROWBUFFER;
  440. MULTISZ_ENUM e;
  441. UINT sizeNeeded;
  442. __try {
  443. if (!IsmGetEnvironmentMultiSz (
  444. PLATFORM_SOURCE,
  445. NULL,
  446. S_ENV_DEST_ADDOBJECT,
  447. NULL,
  448. 0,
  449. &sizeNeeded
  450. )) {
  451. result = TRUE;
  452. __leave;
  453. }
  454. if (!GbGrow (&multiSz, sizeNeeded)) {
  455. __leave;
  456. }
  457. if (!IsmGetEnvironmentMultiSz (
  458. PLATFORM_SOURCE,
  459. NULL,
  460. S_ENV_DEST_ADDOBJECT,
  461. (PTSTR) multiSz.Buf,
  462. multiSz.End,
  463. NULL
  464. )) {
  465. __leave;
  466. }
  467. if (EnumFirstMultiSz (&e, (PCTSTR) multiSz.Buf)) {
  468. do {
  469. // on all systems, process "DestAddObject"
  470. if (InfFindFirstLine (InfHandle, e.CurrentString, NULL, &is)) {
  471. do {
  472. if (IsmCheckCancel()) {
  473. __leave;
  474. }
  475. objectTypeName = InfGetStringField (&is, 1);
  476. if (!InfGetIntField (&is, 2, &objectPriority)) {
  477. objectPriority = 0;
  478. }
  479. if (objectTypeName) {
  480. objectTypeId = IsmGetObjectTypeId (objectTypeName);
  481. if (objectTypeId) {
  482. // let's read the object multi-sz
  483. objectMultiSz = InfGetMultiSzField (&is, 3);
  484. if (objectMultiSz) {
  485. if (IsmConvertMultiSzToObject (
  486. objectTypeId,
  487. objectMultiSz,
  488. &objectName,
  489. &objectContent
  490. )) {
  491. // finally we have the object
  492. // We need to:
  493. // 1. Verify that the destination object does not exist
  494. // 2. Add the destination object handle in ISMs database
  495. // 3. Set an operation on the object passing the objectContent
  496. // as data
  497. added = FALSE;
  498. if (IsmAcquireObject (
  499. objectTypeId | PLATFORM_DESTINATION,
  500. objectName,
  501. &existentContent
  502. )) {
  503. if (objectPriority) {
  504. objectId = IsmGetObjectIdFromName (
  505. objectTypeId | PLATFORM_DESTINATION,
  506. objectName,
  507. TRUE
  508. );
  509. if (objectId) {
  510. blob.Type = BLOBTYPE_BINARY;
  511. blob.BinarySize = sizeof (objectContent);
  512. blob.BinaryData = (PBYTE) &objectContent;
  513. dataHandle = IsmRegisterOperationData (&blob);
  514. if (dataHandle) {
  515. IsmMakeApplyObjectId (objectId);
  516. IsmSetOperationOnObjectId2 (
  517. objectId,
  518. g_DestAddObject,
  519. 0,
  520. dataHandle
  521. );
  522. added = TRUE;
  523. }
  524. }
  525. } else {
  526. IsmReleaseObject (&existentContent);
  527. }
  528. } else {
  529. objectId = IsmGetObjectIdFromName (
  530. objectTypeId | PLATFORM_DESTINATION,
  531. objectName,
  532. FALSE
  533. );
  534. if (objectId) {
  535. blob.Type = BLOBTYPE_BINARY;
  536. blob.BinarySize = sizeof (objectContent);
  537. blob.BinaryData = (PBYTE) &objectContent;
  538. dataHandle = IsmRegisterOperationData (&blob);
  539. if (dataHandle) {
  540. IsmMakeApplyObjectId (objectId);
  541. IsmSetOperationOnObjectId2 (
  542. objectId,
  543. g_DestAddObject,
  544. 0,
  545. dataHandle
  546. );
  547. added = TRUE;
  548. }
  549. }
  550. }
  551. if (!added) {
  552. IsmDestroyObjectHandle (objectName);
  553. if (objectContent.ContentInFile) {
  554. if (objectContent.FileContent.ContentPath) {
  555. IsmReleaseMemory (objectContent.FileContent.ContentPath);
  556. }
  557. } else {
  558. if (objectContent.MemoryContent.ContentBytes) {
  559. IsmReleaseMemory (objectContent.MemoryContent.ContentBytes);
  560. }
  561. }
  562. if (objectContent.Details.DetailsData) {
  563. IsmReleaseMemory (objectContent.Details.DetailsData);
  564. }
  565. }
  566. }
  567. }
  568. }
  569. }
  570. } while (InfFindNextLine (&is));
  571. }
  572. } while (EnumNextMultiSz (&e));
  573. }
  574. result = TRUE;
  575. }
  576. __finally {
  577. GbFree (&multiSz);
  578. InfCleanUpInfStruct (&is);
  579. }
  580. return result;
  581. }
  582. BOOL
  583. pParseInfForExecute (
  584. IN HINF InfHandle
  585. )
  586. {
  587. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  588. PCTSTR time;
  589. PCTSTR currString;
  590. UINT index;
  591. BOOL result = FALSE;
  592. GROWBUFFER multiSz = INIT_GROWBUFFER;
  593. GROWBUFFER funcStr = INIT_GROWBUFFER;
  594. MULTISZ_ENUM e;
  595. UINT sizeNeeded;
  596. __try {
  597. if (!IsmGetEnvironmentMultiSz (
  598. PLATFORM_SOURCE,
  599. NULL,
  600. S_ENV_SCRIPT_EXECUTE,
  601. NULL,
  602. 0,
  603. &sizeNeeded
  604. )) {
  605. result = TRUE;
  606. __leave;
  607. }
  608. if (!GbGrow (&multiSz, sizeNeeded)) {
  609. __leave;
  610. }
  611. if (!IsmGetEnvironmentMultiSz (
  612. PLATFORM_SOURCE,
  613. NULL,
  614. S_ENV_SCRIPT_EXECUTE,
  615. (PTSTR) multiSz.Buf,
  616. multiSz.End,
  617. NULL
  618. )) {
  619. __leave;
  620. }
  621. if (EnumFirstMultiSz (&e, (PCTSTR) multiSz.Buf)) {
  622. do {
  623. if (InfFindFirstLine (InfHandle, e.CurrentString, NULL, &is)) {
  624. do {
  625. if (IsmCheckCancel()) {
  626. __leave;
  627. }
  628. time = InfGetStringField (&is, 0);
  629. if (!time) {
  630. continue;
  631. }
  632. index = 1;
  633. funcStr.End = 0;
  634. while (currString = InfGetStringField (&is, index)) {
  635. GbMultiSzAppend (&funcStr, currString);
  636. index ++;
  637. }
  638. if (funcStr.End) {
  639. GbMultiSzAppend (&funcStr, TEXT(""));
  640. if (StringIMatch (time, TEXT("PreProcess"))) {
  641. IsmExecuteFunction (MIG_EXECUTE_PREPROCESS, (PCTSTR)funcStr.Buf);
  642. }
  643. if (StringIMatch (time, TEXT("Refresh"))) {
  644. IsmExecuteFunction (MIG_EXECUTE_REFRESH, (PCTSTR)funcStr.Buf);
  645. }
  646. if (StringIMatch (time, TEXT("PostProcess"))) {
  647. IsmExecuteFunction (MIG_EXECUTE_POSTPROCESS, (PCTSTR)funcStr.Buf);
  648. }
  649. }
  650. } while (InfFindNextLine (&is));
  651. }
  652. } while (EnumNextMultiSz (&e));
  653. }
  654. result = TRUE;
  655. }
  656. __finally {
  657. GbFree (&multiSz);
  658. GbFree (&funcStr);
  659. InfCleanUpInfStruct (&is);
  660. }
  661. return result;
  662. }
  663. BOOL
  664. pParseDestinationEnvironment (
  665. IN HINF InfHandle
  666. )
  667. {
  668. BOOL result = TRUE;
  669. if (InfHandle == INVALID_HANDLE_VALUE) {
  670. return FALSE;
  671. }
  672. //
  673. // Process the application sections
  674. //
  675. if (!ParseApplications (PLATFORM_DESTINATION, InfHandle, TEXT("Applications"), FALSE, MASTERGROUP_APP)) {
  676. LOG ((LOG_FATAL_ERROR, (PCSTR) MSG_APP_PARSE_FAILURE));
  677. IsmSetCancel();
  678. return FALSE;
  679. }
  680. //
  681. // Process system settings
  682. //
  683. if (!ParseApplications (PLATFORM_DESTINATION, InfHandle, TEXT("System Settings"), FALSE, MASTERGROUP_SYSTEM)) {
  684. LOG ((LOG_FATAL_ERROR, (PCSTR) MSG_SYSTEM_PARSE_FAILURE));
  685. IsmSetCancel();
  686. return FALSE;
  687. }
  688. //
  689. // Process user settings
  690. //
  691. if (!ParseApplications (PLATFORM_DESTINATION, InfHandle, TEXT("User Settings"), FALSE, MASTERGROUP_USER)) {
  692. LOG ((LOG_FATAL_ERROR, (PCSTR) MSG_USER_PARSE_FAILURE));
  693. IsmSetCancel();
  694. return FALSE;
  695. }
  696. //
  697. // Process the administrator script sections
  698. //
  699. if (!ParseApplications (PLATFORM_DESTINATION, InfHandle, TEXT("Administrator Scripts"), FALSE, MASTERGROUP_SCRIPT)) {
  700. LOG ((LOG_FATAL_ERROR, (PCSTR) MSG_SCRIPT_PARSE_FAILURE));
  701. IsmSetCancel();
  702. return FALSE;
  703. }
  704. return TRUE;
  705. }
  706. BOOL
  707. WINAPI
  708. ScriptDgmQueueEnumeration (
  709. IN PVOID Reserved
  710. )
  711. {
  712. PTSTR multiSz = NULL;
  713. MULTISZ_ENUM e;
  714. UINT sizeNeeded;
  715. HINF infHandle = INVALID_HANDLE_VALUE;
  716. ENVENTRY_TYPE dataType;
  717. BOOL result = TRUE;
  718. if (IsmGetEnvironmentValue (
  719. IsmGetRealPlatform (),
  720. NULL,
  721. S_GLOBAL_INF_HANDLE,
  722. (PBYTE)(&infHandle),
  723. sizeof (HINF),
  724. &sizeNeeded,
  725. &dataType
  726. ) &&
  727. (sizeNeeded == sizeof (HINF)) &&
  728. (dataType == ENVENTRY_BINARY)
  729. ) {
  730. if (!pParseDestinationEnvironment (infHandle)) {
  731. result = FALSE;
  732. }
  733. if (!pParseDestinationDetect (infHandle)) {
  734. result = FALSE;
  735. }
  736. if (!pParseInfForExclude (infHandle)) {
  737. result = FALSE;
  738. }
  739. if (!pParseInfForExcludeEx (infHandle)) {
  740. result = FALSE;
  741. }
  742. if (!pParseInfForExecute (infHandle)) {
  743. result = FALSE;
  744. }
  745. if (!pParseInfForDestAdd (infHandle)) {
  746. result = FALSE;
  747. }
  748. } else {
  749. if (!IsmGetEnvironmentValue (IsmGetRealPlatform (), NULL, S_INF_FILE_MULTISZ, NULL, 0, &sizeNeeded, NULL)) {
  750. return TRUE; // no INF files specified
  751. }
  752. __try {
  753. multiSz = AllocText (sizeNeeded);
  754. if (!multiSz) {
  755. result = FALSE;
  756. __leave;
  757. }
  758. if (!IsmGetEnvironmentValue (IsmGetRealPlatform (), NULL, S_INF_FILE_MULTISZ, (PBYTE) multiSz, sizeNeeded, NULL, NULL)) {
  759. result = FALSE;
  760. __leave;
  761. }
  762. if (EnumFirstMultiSz (&e, multiSz)) {
  763. do {
  764. infHandle = InfOpenInfFile (e.CurrentString);
  765. if (infHandle != INVALID_HANDLE_VALUE) {
  766. if (!pParseDestinationEnvironment (infHandle)) {
  767. InfCloseInfFile (infHandle);
  768. infHandle = INVALID_HANDLE_VALUE;
  769. result = FALSE;
  770. __leave;
  771. }
  772. if (!pParseDestinationDetect (infHandle)) {
  773. InfCloseInfFile (infHandle);
  774. infHandle = INVALID_HANDLE_VALUE;
  775. result = FALSE;
  776. __leave;
  777. }
  778. if (!pParseInfForExclude (infHandle)) {
  779. InfCloseInfFile (infHandle);
  780. infHandle = INVALID_HANDLE_VALUE;
  781. result = FALSE;
  782. __leave;
  783. }
  784. if (!pParseInfForExcludeEx (infHandle)) {
  785. InfCloseInfFile (infHandle);
  786. infHandle = INVALID_HANDLE_VALUE;
  787. result = FALSE;
  788. __leave;
  789. }
  790. if (!pParseInfForExecute (infHandle)) {
  791. InfCloseInfFile (infHandle);
  792. infHandle = INVALID_HANDLE_VALUE;
  793. result = FALSE;
  794. __leave;
  795. }
  796. if (!pParseInfForDestAdd (infHandle)) {
  797. InfCloseInfFile (infHandle);
  798. infHandle = INVALID_HANDLE_VALUE;
  799. result = FALSE;
  800. __leave;
  801. }
  802. InfCloseInfFile (infHandle);
  803. infHandle = INVALID_HANDLE_VALUE;
  804. } else {
  805. LOG ((LOG_ERROR, (PCSTR) MSG_CANT_OPEN_INF, e.CurrentString));
  806. }
  807. } while (EnumNextMultiSz (&e));
  808. }
  809. }
  810. __finally {
  811. if (multiSz) {
  812. FreeText (multiSz);
  813. multiSz = NULL;
  814. }
  815. }
  816. }
  817. return result;
  818. }