diff options
Diffstat (limited to 'src/burn/engine')
-rw-r--r-- | src/burn/engine/search.cpp | 45 | ||||
-rw-r--r-- | src/burn/engine/search.h | 3 |
2 files changed, 33 insertions, 15 deletions
diff --git a/src/burn/engine/search.cpp b/src/burn/engine/search.cpp index 46dd2395..a57e703e 100644 --- a/src/burn/engine/search.cpp +++ b/src/burn/engine/search.cpp | |||
@@ -65,7 +65,6 @@ extern "C" HRESULT SearchesParseFromXml( | |||
65 | BSTR bstrNodeName = NULL; | 65 | BSTR bstrNodeName = NULL; |
66 | BOOL fXmlFound = FALSE; | 66 | BOOL fXmlFound = FALSE; |
67 | LPWSTR scz = NULL; | 67 | LPWSTR scz = NULL; |
68 | BURN_VARIANT_TYPE valueType = BURN_VARIANT_TYPE_NONE; | ||
69 | 68 | ||
70 | // select search nodes | 69 | // select search nodes |
71 | hr = XmlSelectNodes(pixnBundle, L"DirectorySearch|FileSearch|RegistrySearch|MsiComponentSearch|MsiProductSearch|MsiFeatureSearch|ExtensionSearch|SetVariable", &pixnNodes); | 70 | hr = XmlSelectNodes(pixnBundle, L"DirectorySearch|FileSearch|RegistrySearch|MsiComponentSearch|MsiProductSearch|MsiFeatureSearch|ExtensionSearch|SetVariable", &pixnNodes); |
@@ -357,8 +356,8 @@ extern "C" HRESULT SearchesParseFromXml( | |||
357 | 356 | ||
358 | if (fXmlFound) | 357 | if (fXmlFound) |
359 | { | 358 | { |
360 | hr = BVariantSetString(&pSearch->SetVariable.value, scz, 0, FALSE); | 359 | pSearch->SetVariable.sczValue = scz; |
361 | ExitOnFailure(hr, "Failed to set variant value."); | 360 | scz = NULL; |
362 | 361 | ||
363 | // @Type | 362 | // @Type |
364 | hr = XmlGetAttributeEx(pixnNode, L"Type", &scz); | 363 | hr = XmlGetAttributeEx(pixnNode, L"Type", &scz); |
@@ -366,19 +365,19 @@ extern "C" HRESULT SearchesParseFromXml( | |||
366 | 365 | ||
367 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"formatted", -1)) | 366 | if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"formatted", -1)) |
368 | { | 367 | { |
369 | valueType = BURN_VARIANT_TYPE_FORMATTED; | 368 | pSearch->SetVariable.targetType = BURN_VARIANT_TYPE_FORMATTED; |
370 | } | 369 | } |
371 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"numeric", -1)) | 370 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"numeric", -1)) |
372 | { | 371 | { |
373 | valueType = BURN_VARIANT_TYPE_NUMERIC; | 372 | pSearch->SetVariable.targetType = BURN_VARIANT_TYPE_NUMERIC; |
374 | } | 373 | } |
375 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"string", -1)) | 374 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"string", -1)) |
376 | { | 375 | { |
377 | valueType = BURN_VARIANT_TYPE_STRING; | 376 | pSearch->SetVariable.targetType = BURN_VARIANT_TYPE_STRING; |
378 | } | 377 | } |
379 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"version", -1)) | 378 | else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, scz, -1, L"version", -1)) |
380 | { | 379 | { |
381 | valueType = BURN_VARIANT_TYPE_VERSION; | 380 | pSearch->SetVariable.targetType = BURN_VARIANT_TYPE_VERSION; |
382 | } | 381 | } |
383 | else | 382 | else |
384 | { | 383 | { |
@@ -387,12 +386,8 @@ extern "C" HRESULT SearchesParseFromXml( | |||
387 | } | 386 | } |
388 | else | 387 | else |
389 | { | 388 | { |
390 | valueType = BURN_VARIANT_TYPE_NONE; | 389 | pSearch->SetVariable.targetType = BURN_VARIANT_TYPE_NONE; |
391 | } | 390 | } |
392 | |||
393 | // change value variant to correct type | ||
394 | hr = BVariantChangeType(&pSearch->SetVariable.value, valueType); | ||
395 | ExitOnFailure(hr, "Failed to change variant type."); | ||
396 | } | 391 | } |
397 | else | 392 | else |
398 | { | 393 | { |
@@ -551,7 +546,7 @@ extern "C" void SearchesUninitialize( | |||
551 | ReleaseStr(pSearch->MsiProductSearch.sczGuid); | 546 | ReleaseStr(pSearch->MsiProductSearch.sczGuid); |
552 | break; | 547 | break; |
553 | case BURN_SEARCH_TYPE_SET_VARIABLE: | 548 | case BURN_SEARCH_TYPE_SET_VARIABLE: |
554 | BVariantUninitialize(&pSearch->SetVariable.value); | 549 | ReleaseStr(pSearch->SetVariable.sczValue); |
555 | break; | 550 | break; |
556 | } | 551 | } |
557 | } | 552 | } |
@@ -1207,10 +1202,32 @@ static HRESULT PerformSetVariable( | |||
1207 | ) | 1202 | ) |
1208 | { | 1203 | { |
1209 | HRESULT hr = S_OK; | 1204 | HRESULT hr = S_OK; |
1205 | BURN_VARIANT newValue = { }; | ||
1206 | LPWSTR sczFormattedValue = NULL; | ||
1207 | SIZE_T cchOut = 0; | ||
1208 | |||
1209 | if (BURN_VARIANT_TYPE_NONE == pSearch->SetVariable.targetType) | ||
1210 | { | ||
1211 | BVariantUninitialize(&newValue); | ||
1212 | } | ||
1213 | else | ||
1214 | { | ||
1215 | hr = VariableFormatString(pVariables, pSearch->SetVariable.sczValue, &sczFormattedValue, &cchOut); | ||
1216 | ExitOnFailure(hr, "Failed to format search value."); | ||
1217 | |||
1218 | hr = BVariantSetString(&newValue, sczFormattedValue, 0, FALSE); | ||
1219 | ExitOnFailure(hr, "Failed to set variant value."); | ||
1210 | 1220 | ||
1211 | hr = VariableSetVariant(pVariables, pSearch->sczVariable, &pSearch->SetVariable.value); | 1221 | // change value variant to correct type |
1222 | hr = BVariantChangeType(&newValue, pSearch->SetVariable.targetType); | ||
1223 | ExitOnFailure(hr, "Failed to change variant type."); | ||
1224 | } | ||
1225 | |||
1226 | hr = VariableSetVariant(pVariables, pSearch->sczVariable, &newValue); | ||
1212 | ExitOnFailure(hr, "Failed to set variable: %ls", pSearch->sczVariable); | 1227 | ExitOnFailure(hr, "Failed to set variable: %ls", pSearch->sczVariable); |
1213 | 1228 | ||
1214 | LExit: | 1229 | LExit: |
1230 | BVariantUninitialize(&newValue); | ||
1231 | |||
1215 | return hr; | 1232 | return hr; |
1216 | } | 1233 | } |
diff --git a/src/burn/engine/search.h b/src/burn/engine/search.h index 6397d2a3..bc53f197 100644 --- a/src/burn/engine/search.h +++ b/src/burn/engine/search.h | |||
@@ -117,7 +117,8 @@ typedef struct _BURN_SEARCH | |||
117 | } ExtensionSearch; | 117 | } ExtensionSearch; |
118 | struct | 118 | struct |
119 | { | 119 | { |
120 | BURN_VARIANT value; | 120 | LPWSTR sczValue; |
121 | BURN_VARIANT_TYPE targetType; | ||
121 | } SetVariable; | 122 | } SetVariable; |
122 | }; | 123 | }; |
123 | } BURN_SEARCH; | 124 | } BURN_SEARCH; |