aboutsummaryrefslogtreecommitdiff
path: root/src/burn/engine/search.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/burn/engine/search.cpp')
-rw-r--r--src/burn/engine/search.cpp114
1 files changed, 113 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
566typedef struct _BURN_FILE_SEARCH
567{
568 BURN_SEARCH* pSearch;
569 PROC_FILESYSTEMREDIRECTION pfsr;
570} BURN_FILE_SEARCH;
571
572static 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
588LExit:
589 return hr;
590}
591
592static 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
601LExit:
602 return;
603}
604
605#endif
606
560static HRESULT DirectorySearchExists( 607static 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
595LExit: 651LExit:
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
636LExit: 705LExit:
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
680LExit: 762LExit:
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
716LExit: 811LExit:
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
757LExit: 865LExit:
866#if !defined(_WIN64)
867 FileSystemSearchEnd(&bfs);
868#endif
869
758 StrSecureZeroFreeString(sczPath); 870 StrSecureZeroFreeString(sczPath);
759 871
760 return hr; 872 return hr;