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.

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