diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-04-27 16:54:28 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-04-28 14:23:08 -0500 |
| commit | 681da11cfc9a266304b47b88843cb8a365015c63 (patch) | |
| tree | d670f3a45d15d1fe43c8d5dee04b2dac548d8cf6 /src/burn/engine | |
| parent | 7860559202d01cef07a9996d2c12606ac8d56221 (diff) | |
| download | wix-681da11cfc9a266304b47b88843cb8a365015c63.tar.gz wix-681da11cfc9a266304b47b88843cb8a365015c63.tar.bz2 wix-681da11cfc9a266304b47b88843cb8a365015c63.zip | |
Add ability to disable file system redirection for File/DirectorySearch
Fixes 5476
Diffstat (limited to 'src/burn/engine')
| -rw-r--r-- | src/burn/engine/search.cpp | 114 | ||||
| -rw-r--r-- | src/burn/engine/search.h | 1 |
2 files changed, 114 insertions, 1 deletions
diff --git a/src/burn/engine/search.cpp b/src/burn/engine/search.cpp index a57e703e..f521cdbd 100644 --- a/src/burn/engine/search.cpp +++ b/src/burn/engine/search.cpp | |||
| @@ -139,6 +139,10 @@ extern "C" HRESULT SearchesParseFromXml( | |||
| 139 | hr = XmlGetAttributeEx(pixnNode, L"Path", &pSearch->FileSearch.sczPath); | 139 | hr = XmlGetAttributeEx(pixnNode, L"Path", &pSearch->FileSearch.sczPath); |
| 140 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Path."); | 140 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Path."); |
| 141 | 141 | ||
| 142 | // @DisableFileRedirection | ||
| 143 | hr = XmlGetYesNoAttribute(pixnNode, L"DisableFileRedirection", &pSearch->FileSearch.fDisableFileRedirection); | ||
| 144 | ExitOnOptionalXmlQueryFailure(hr, fXmlFound, "Failed to get DisableFileRedirection attribute."); | ||
| 145 | |||
| 142 | // @Type | 146 | // @Type |
| 143 | hr = XmlGetAttributeEx(pixnNode, L"Type", &scz); | 147 | hr = XmlGetAttributeEx(pixnNode, L"Type", &scz); |
| 144 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Type."); | 148 | ExitOnRequiredXmlQueryFailure(hr, "Failed to get @Type."); |
| @@ -557,6 +561,49 @@ extern "C" void SearchesUninitialize( | |||
| 557 | 561 | ||
| 558 | // internal function definitions | 562 | // internal function definitions |
| 559 | 563 | ||
| 564 | #if !defined(_WIN64) | ||
| 565 | |||
| 566 | typedef struct _BURN_FILE_SEARCH | ||
| 567 | { | ||
| 568 | BURN_SEARCH* pSearch; | ||
| 569 | PROC_FILESYSTEMREDIRECTION pfsr; | ||
| 570 | } BURN_FILE_SEARCH; | ||
| 571 | |||
| 572 | static HRESULT FileSystemSearchStart( | ||
| 573 | __in BURN_FILE_SEARCH* pFileSearch | ||
| 574 | ) | ||
| 575 | { | ||
| 576 | HRESULT hr = S_OK; | ||
| 577 | |||
| 578 | if (pFileSearch->pSearch->FileSearch.fDisableFileRedirection) | ||
| 579 | { | ||
| 580 | hr = ProcDisableWowFileSystemRedirection(&pFileSearch->pfsr); | ||
| 581 | if (hr == E_NOTIMPL) | ||
| 582 | { | ||
| 583 | hr = S_FALSE; | ||
| 584 | } | ||
| 585 | ExitOnFailure(hr, "Failed to disable file system redirection."); | ||
| 586 | } | ||
| 587 | |||
| 588 | LExit: | ||
| 589 | return hr; | ||
| 590 | } | ||
| 591 | |||
| 592 | static void FileSystemSearchEnd( | ||
| 593 | __in BURN_FILE_SEARCH* pFileSearch | ||
| 594 | ) | ||
| 595 | { | ||
| 596 | HRESULT hr = S_OK; | ||
| 597 | |||
| 598 | hr = ProcRevertWowFileSystemRedirection(&pFileSearch->pfsr); | ||
| 599 | ExitOnFailure(hr, "Failed to revert file system redirection."); | ||
| 600 | |||
| 601 | LExit: | ||
| 602 | return; | ||
| 603 | } | ||
| 604 | |||
| 605 | #endif | ||
| 606 | |||
| 560 | static HRESULT DirectorySearchExists( | 607 | static HRESULT DirectorySearchExists( |
| 561 | __in BURN_SEARCH* pSearch, | 608 | __in BURN_SEARCH* pSearch, |
| 562 | __in BURN_VARIABLES* pVariables | 609 | __in BURN_VARIABLES* pVariables |
| @@ -566,6 +613,15 @@ static HRESULT DirectorySearchExists( | |||
| 566 | LPWSTR sczPath = NULL; | 613 | LPWSTR sczPath = NULL; |
| 567 | BOOL fExists = FALSE; | 614 | BOOL fExists = FALSE; |
| 568 | 615 | ||
| 616 | #if !defined(_WIN64) | ||
| 617 | BURN_FILE_SEARCH bfs = { }; | ||
| 618 | |||
| 619 | bfs.pSearch = pSearch; | ||
| 620 | |||
| 621 | hr = FileSystemSearchStart(&bfs); | ||
| 622 | ExitOnFailure(hr, "Failed to initialize file search."); | ||
| 623 | #endif | ||
| 624 | |||
| 569 | // format path | 625 | // format path |
| 570 | hr = VariableFormatString(pVariables, pSearch->DirectorySearch.sczPath, &sczPath, NULL); | 626 | hr = VariableFormatString(pVariables, pSearch->DirectorySearch.sczPath, &sczPath, NULL); |
| 571 | ExitOnFailure(hr, "Failed to format variable string."); | 627 | ExitOnFailure(hr, "Failed to format variable string."); |
| @@ -593,6 +649,10 @@ static HRESULT DirectorySearchExists( | |||
| 593 | ExitOnFailure(hr, "Failed to set variable."); | 649 | ExitOnFailure(hr, "Failed to set variable."); |
| 594 | 650 | ||
| 595 | LExit: | 651 | LExit: |
| 652 | #if !defined(_WIN64) | ||
| 653 | FileSystemSearchEnd(&bfs); | ||
| 654 | #endif | ||
| 655 | |||
| 596 | StrSecureZeroFreeString(sczPath); | 656 | StrSecureZeroFreeString(sczPath); |
| 597 | 657 | ||
| 598 | return hr; | 658 | return hr; |
| @@ -606,6 +666,15 @@ static HRESULT DirectorySearchPath( | |||
| 606 | HRESULT hr = S_OK; | 666 | HRESULT hr = S_OK; |
| 607 | LPWSTR sczPath = NULL; | 667 | LPWSTR sczPath = NULL; |
| 608 | 668 | ||
| 669 | #if !defined(_WIN64) | ||
| 670 | BURN_FILE_SEARCH bfs = { }; | ||
| 671 | |||
| 672 | bfs.pSearch = pSearch; | ||
| 673 | |||
| 674 | hr = FileSystemSearchStart(&bfs); | ||
| 675 | ExitOnFailure(hr, "Failed to initialize file search."); | ||
| 676 | #endif | ||
| 677 | |||
| 609 | // format path | 678 | // format path |
| 610 | hr = VariableFormatString(pVariables, pSearch->DirectorySearch.sczPath, &sczPath, NULL); | 679 | hr = VariableFormatString(pVariables, pSearch->DirectorySearch.sczPath, &sczPath, NULL); |
| 611 | ExitOnFailure(hr, "Failed to format variable string."); | 680 | ExitOnFailure(hr, "Failed to format variable string."); |
| @@ -634,6 +703,10 @@ static HRESULT DirectorySearchPath( | |||
| 634 | ExitOnFailure(hr, "Failed while searching directory search: %ls, for path: %ls", pSearch->sczKey, sczPath); | 703 | ExitOnFailure(hr, "Failed while searching directory search: %ls, for path: %ls", pSearch->sczKey, sczPath); |
| 635 | 704 | ||
| 636 | LExit: | 705 | LExit: |
| 706 | #if !defined(_WIN64) | ||
| 707 | FileSystemSearchEnd(&bfs); | ||
| 708 | #endif | ||
| 709 | |||
| 637 | StrSecureZeroFreeString(sczPath); | 710 | StrSecureZeroFreeString(sczPath); |
| 638 | 711 | ||
| 639 | return hr; | 712 | return hr; |
| @@ -649,6 +722,15 @@ static HRESULT FileSearchExists( | |||
| 649 | LPWSTR sczPath = NULL; | 722 | LPWSTR sczPath = NULL; |
| 650 | BOOL fExists = FALSE; | 723 | BOOL fExists = FALSE; |
| 651 | 724 | ||
| 725 | #if !defined(_WIN64) | ||
| 726 | BURN_FILE_SEARCH bfs = { }; | ||
| 727 | |||
| 728 | bfs.pSearch = pSearch; | ||
| 729 | |||
| 730 | hr = FileSystemSearchStart(&bfs); | ||
| 731 | ExitOnFailure(hr, "Failed to initialize file search."); | ||
| 732 | #endif | ||
| 733 | |||
| 652 | // format path | 734 | // format path |
| 653 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); | 735 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); |
| 654 | ExitOnFailure(hr, "Failed to format variable string."); | 736 | ExitOnFailure(hr, "Failed to format variable string."); |
| @@ -665,7 +747,7 @@ static HRESULT FileSearchExists( | |||
| 665 | } | 747 | } |
| 666 | else | 748 | else |
| 667 | { | 749 | { |
| 668 | ExitOnWin32Error(er, hr, "Failed get to file attributes. '%ls'", pSearch->DirectorySearch.sczPath); | 750 | ExitOnWin32Error(er, hr, "Failed get to file attributes. '%ls'", pSearch->FileSearch.sczPath); |
| 669 | } | 751 | } |
| 670 | } | 752 | } |
| 671 | else if (FILE_ATTRIBUTE_DIRECTORY != (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) | 753 | else if (FILE_ATTRIBUTE_DIRECTORY != (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) |
| @@ -678,6 +760,10 @@ static HRESULT FileSearchExists( | |||
| 678 | ExitOnFailure(hr, "Failed to set variable."); | 760 | ExitOnFailure(hr, "Failed to set variable."); |
| 679 | 761 | ||
| 680 | LExit: | 762 | LExit: |
| 763 | #if !defined(_WIN64) | ||
| 764 | FileSystemSearchEnd(&bfs); | ||
| 765 | #endif | ||
| 766 | |||
| 681 | StrSecureZeroFreeString(sczPath); | 767 | StrSecureZeroFreeString(sczPath); |
| 682 | return hr; | 768 | return hr; |
| 683 | } | 769 | } |
| @@ -692,6 +778,15 @@ static HRESULT FileSearchVersion( | |||
| 692 | LPWSTR sczPath = NULL; | 778 | LPWSTR sczPath = NULL; |
| 693 | VERUTIL_VERSION* pVersion = NULL; | 779 | VERUTIL_VERSION* pVersion = NULL; |
| 694 | 780 | ||
| 781 | #if !defined(_WIN64) | ||
| 782 | BURN_FILE_SEARCH bfs = { }; | ||
| 783 | |||
| 784 | bfs.pSearch = pSearch; | ||
| 785 | |||
| 786 | hr = FileSystemSearchStart(&bfs); | ||
| 787 | ExitOnFailure(hr, "Failed to initialize file search."); | ||
| 788 | #endif | ||
| 789 | |||
| 695 | // format path | 790 | // format path |
| 696 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); | 791 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); |
| 697 | ExitOnFailure(hr, "Failed to format path string."); | 792 | ExitOnFailure(hr, "Failed to format path string."); |
| @@ -714,6 +809,10 @@ static HRESULT FileSearchVersion( | |||
| 714 | ExitOnFailure(hr, "Failed to set variable."); | 809 | ExitOnFailure(hr, "Failed to set variable."); |
| 715 | 810 | ||
| 716 | LExit: | 811 | LExit: |
| 812 | #if !defined(_WIN64) | ||
| 813 | FileSystemSearchEnd(&bfs); | ||
| 814 | #endif | ||
| 815 | |||
| 717 | StrSecureZeroFreeString(sczPath); | 816 | StrSecureZeroFreeString(sczPath); |
| 718 | ReleaseVerutilVersion(pVersion); | 817 | ReleaseVerutilVersion(pVersion); |
| 719 | return hr; | 818 | return hr; |
| @@ -727,6 +826,15 @@ static HRESULT FileSearchPath( | |||
| 727 | HRESULT hr = S_OK; | 826 | HRESULT hr = S_OK; |
| 728 | LPWSTR sczPath = NULL; | 827 | LPWSTR sczPath = NULL; |
| 729 | 828 | ||
| 829 | #if !defined(_WIN64) | ||
| 830 | BURN_FILE_SEARCH bfs = { }; | ||
| 831 | |||
| 832 | bfs.pSearch = pSearch; | ||
| 833 | |||
| 834 | hr = FileSystemSearchStart(&bfs); | ||
| 835 | ExitOnFailure(hr, "Failed to initialize file search."); | ||
| 836 | #endif | ||
| 837 | |||
| 730 | // format path | 838 | // format path |
| 731 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); | 839 | hr = VariableFormatString(pVariables, pSearch->FileSearch.sczPath, &sczPath, NULL); |
| 732 | ExitOnFailure(hr, "Failed to format variable string."); | 840 | ExitOnFailure(hr, "Failed to format variable string."); |
| @@ -755,6 +863,10 @@ static HRESULT FileSearchPath( | |||
| 755 | ExitOnFailure(hr, "Failed while searching file search: %ls, for path: %ls", pSearch->sczKey, sczPath); | 863 | ExitOnFailure(hr, "Failed while searching file search: %ls, for path: %ls", pSearch->sczKey, sczPath); |
| 756 | 864 | ||
| 757 | LExit: | 865 | LExit: |
| 866 | #if !defined(_WIN64) | ||
| 867 | FileSystemSearchEnd(&bfs); | ||
| 868 | #endif | ||
| 869 | |||
| 758 | StrSecureZeroFreeString(sczPath); | 870 | StrSecureZeroFreeString(sczPath); |
| 759 | 871 | ||
| 760 | return hr; | 872 | return hr; |
diff --git a/src/burn/engine/search.h b/src/burn/engine/search.h index bc53f197..341fe1aa 100644 --- a/src/burn/engine/search.h +++ b/src/burn/engine/search.h | |||
| @@ -88,6 +88,7 @@ typedef struct _BURN_SEARCH | |||
| 88 | { | 88 | { |
| 89 | BURN_FILE_SEARCH_TYPE Type; | 89 | BURN_FILE_SEARCH_TYPE Type; |
| 90 | LPWSTR sczPath; | 90 | LPWSTR sczPath; |
| 91 | BOOL fDisableFileRedirection; | ||
| 91 | } FileSearch; | 92 | } FileSearch; |
| 92 | struct | 93 | struct |
| 93 | { | 94 | { |
