diff --git a/src/OrcCommand/FastFind_Run.cpp b/src/OrcCommand/FastFind_Run.cpp index 02489222..633397d1 100644 --- a/src/OrcCommand/FastFind_Run.cpp +++ b/src/OrcCommand/FastFind_Run.cpp @@ -463,7 +463,7 @@ HRESULT Main::Run() if (config.outObject.Type != OutputSpec::Kind::None) pObjectTableOutput = TableOutput::GetWriter(config.outObject); - if (config.outStructured.Type & OutputSpec::Kind::StructuredFile) + if ((config.outStructured.Type & OutputSpec::Kind::StructuredFile) == OutputSpec::Kind::StructuredFile) { pStructuredOutput = StructuredOutputWriter::GetWriter(config.outStructured, nullptr); } diff --git a/src/OrcCommand/GetSamples_Run.cpp b/src/OrcCommand/GetSamples_Run.cpp index e3a2b3a2..225a30f5 100644 --- a/src/OrcCommand/GetSamples_Run.cpp +++ b/src/OrcCommand/GetSamples_Run.cpp @@ -473,7 +473,7 @@ HRESULT Main::Run() Log::Info(L"Verifying code signatures... Done"); } - if (config.sampleinfoOutput.Type & OutputSpec::Kind::TableFile) + if ((config.sampleinfoOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { hr = WriteSampleInformation(results); if (FAILED(hr)) @@ -483,7 +483,7 @@ HRESULT Main::Run() } } - if (config.timelineOutput.Type & OutputSpec::Kind::TableFile) + if ((config.timelineOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { // Collect time line related information const TaskTracker::TimeLine& timeline = tk.GetTimeLine(); diff --git a/src/OrcCommand/RegInfo_Config.cpp b/src/OrcCommand/RegInfo_Config.cpp index efd08ab0..2cba0508 100644 --- a/src/OrcCommand/RegInfo_Config.cpp +++ b/src/OrcCommand/RegInfo_Config.cpp @@ -246,7 +246,7 @@ HRESULT Main::CheckConfiguration() Log::Error("No valid output specified (only directory or csv|tsv are allowed"); return E_INVALIDARG; } - if (config.Output.Type & OutputSpec::Kind::Archive) + if ((config.Output.Type & OutputSpec::Kind::Archive) == OutputSpec::Kind::Archive) { Log::Error("Archive output is not supported (only directory or csv|tsv are allowed"); return E_INVALIDARG; diff --git a/src/OrcCommand/RegInfo_Run.cpp b/src/OrcCommand/RegInfo_Run.cpp index 108de7ad..04d51b32 100644 --- a/src/OrcCommand/RegInfo_Run.cpp +++ b/src/OrcCommand/RegInfo_Run.cpp @@ -467,7 +467,7 @@ HRESULT Main::Run() std::shared_ptr pRegInfoWriter; - if (config.Output.Type & OutputSpec::Kind::TableFile) + if ((config.Output.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { pRegInfoWriter = GetRegInfoWriter(config.Output); if (nullptr == pRegInfoWriter) @@ -482,7 +482,7 @@ HRESULT Main::Run() { auto node = root.AddNode("Parsing hive '{}'", hive.FileName); - if (config.Output.Type & OutputSpec::Kind::Directory) + if ((config.Output.Type & OutputSpec::Kind::Directory) == OutputSpec::Kind::Directory) { std::wstring fileName(hive.FileName); std::replace(fileName.begin(), fileName.end(), L'\\', L'_'); diff --git a/src/OrcCommand/Usage.h b/src/OrcCommand/Usage.h index ff55eac0..6c83a416 100644 --- a/src/OrcCommand/Usage.h +++ b/src/OrcCommand/Usage.h @@ -255,7 +255,7 @@ auto PrintColumnSelectionParameter( const ColumnNameDef* pCurCol = pColumnNames; while (pCurCol->dwIntention != Intentions::FILEINFO_NONE) { - if (pCurAlias->dwIntention & pCurCol->dwIntention) + if ((pCurAlias->dwIntention & pCurCol->dwIntention) == pCurCol->dwIntention) { PrintValue(aliasNode, pCurCol->szColumnName, pCurCol->szColumnDesc); dwNumCol++; diff --git a/src/OrcCommand/WolfExecution.h b/src/OrcCommand/WolfExecution.h index 71e3ab8a..67126b8b 100644 --- a/src/OrcCommand/WolfExecution.h +++ b/src/OrcCommand/WolfExecution.h @@ -175,12 +175,12 @@ class WolfExecution m_Temporary = temporary; m_JobStatisticsOutput = jobstats; - if (m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) + if ((m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { m_JobStatisticsOutput.Path = m_Temporary.Path + L"\\" + m_JobStatisticsOutput.Path; } m_ProcessStatisticsOutput = processstats; - if (m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) + if ((m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { m_ProcessStatisticsOutput.Path = m_Temporary.Path + L"\\" + m_ProcessStatisticsOutput.Path; } diff --git a/src/OrcCommand/WolfExecution_Execute.cpp b/src/OrcCommand/WolfExecution_Execute.cpp index 62b7cce3..36e6b3a1 100644 --- a/src/OrcCommand/WolfExecution_Execute.cpp +++ b/src/OrcCommand/WolfExecution_Execute.cpp @@ -504,7 +504,7 @@ HRESULT WolfExecution::CreateCommandAgent( m_pTermination = std::make_shared(m_commandSet, this); Robustness::AddTerminationHandler(m_pTermination); - if (m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) + if ((m_ProcessStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { m_ProcessStatisticsWriter = TableOutput::GetWriter(m_ProcessStatisticsOutput); @@ -514,7 +514,7 @@ HRESULT WolfExecution::CreateCommandAgent( } } - if (m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) + if ((m_JobStatisticsOutput.Type & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { m_JobStatisticsWriter = TableOutput::GetWriter(m_JobStatisticsOutput); if (m_JobStatisticsWriter == nullptr) diff --git a/src/OrcCommand/WolfLauncher_Output.cpp b/src/OrcCommand/WolfLauncher_Output.cpp index 3ed08310..9d12efa5 100644 --- a/src/OrcCommand/WolfLauncher_Output.cpp +++ b/src/OrcCommand/WolfLauncher_Output.cpp @@ -50,22 +50,22 @@ std::wstring Main::ToString(Main::WolfPowerState value) return L""; } - if (value & Main::WolfPowerState::SystemRequired) + if ((value & Main::WolfPowerState::SystemRequired) == Main::WolfPowerState::SystemRequired) { properties.push_back(L"SystemRequired"); } - if (value & Main::WolfPowerState::DisplayRequired) + if ((value & Main::WolfPowerState::DisplayRequired) == Main::WolfPowerState::DisplayRequired) { properties.push_back(L"DisplayRequired"); } - if (value & Main::WolfPowerState::UserPresent) + if ((value & Main::WolfPowerState::UserPresent) == Main::WolfPowerState::UserPresent) { properties.push_back(L"UserPresent"); } - if (value & Main::WolfPowerState::AwayMode) + if ((value & Main::WolfPowerState::AwayMode) == Main::WolfPowerState::AwayMode) { properties.push_back(L"AwayMode"); } diff --git a/src/OrcLib/CryptoHashStream.cpp b/src/OrcLib/CryptoHashStream.cpp index 08ef34d6..4409ec5a 100644 --- a/src/OrcLib/CryptoHashStream.cpp +++ b/src/OrcLib/CryptoHashStream.cpp @@ -102,18 +102,19 @@ HRESULT CryptoHashStream::ResetHash(bool bContinue) } m_bHashIsValid = true; - if ((m_Algorithms & Algorithm::MD5) && !CryptCreateHash(g_hProv, CALG_MD5, 0, 0, &m_MD5)) + if ((m_Algorithms & Algorithm::MD5) == Algorithm::MD5 && !CryptCreateHash(g_hProv, CALG_MD5, 0, 0, &m_MD5)) { hr = HRESULT_FROM_WIN32(GetLastError()); Log::Debug(L"Failed to initialise MD5 hash [{}]", SystemError(hr)); } - if ((m_Algorithms & Algorithm::SHA1) && !CryptCreateHash(g_hProv, CALG_SHA1, 0, 0, &m_Sha1)) + if ((m_Algorithms & Algorithm::SHA1) == Algorithm::SHA1 && !CryptCreateHash(g_hProv, CALG_SHA1, 0, 0, &m_Sha1)) { hr = HRESULT_FROM_WIN32(GetLastError()); Log::Debug(L"Failed to initialise SHA1 hash [{}]", SystemError(hr)); } - if ((m_Algorithms & Algorithm::SHA256) && !CryptCreateHash(g_hProv, CALG_SHA_256, 0, 0, &m_Sha256)) + if ((m_Algorithms & Algorithm::SHA256) == Algorithm::SHA256 + && !CryptCreateHash(g_hProv, CALG_SHA_256, 0, 0, &m_Sha256)) { hr = HRESULT_FROM_WIN32(GetLastError()); Log::Debug(L"Failed to initialise SHA256 hash [{}]", SystemError(hr)); @@ -227,18 +228,18 @@ std::wstring CryptoHashStream::GetSupportedAlgorithm(Algorithm algs) retval.reserve(16); - if (algs & Algorithm::MD5) + if ((algs & Algorithm::MD5) == Algorithm::MD5) { retval.append(L"MD5"sv); } - if (algs & Algorithm::SHA1) + if ((algs & Algorithm::SHA1) == Algorithm::SHA1) { if (retval.empty()) retval.append(L"SHA1"sv); else retval.append(L",SHA1"sv); } - if (algs & Algorithm::SHA256) + if ((algs & Algorithm::SHA256) == Algorithm::SHA256) { if (retval.empty()) retval.append(L"SHA256"sv); diff --git a/src/OrcLib/FileFind.cpp b/src/OrcLib/FileFind.cpp index 7aa847f4..882e9817 100644 --- a/src/OrcLib/FileFind.cpp +++ b/src/OrcLib/FileFind.cpp @@ -781,9 +781,7 @@ std::shared_ptr FileFind::GetSearchTermFromConfig(const Co else { Log::Warn( - L"Invalid hex string passed as header: {} [{}]", - item[CONFIG_FILEFIND_HEADER_HEX], - SystemError(hr)); + L"Invalid hex string passed as header: {} [{}]", item[CONFIG_FILEFIND_HEADER_HEX], SystemError(hr)); } } if (item[CONFIG_FILEFIND_HEADER_REGEX]) @@ -3496,11 +3494,14 @@ HRESULT FileFind::ComputeMatchHashes(const std::shared_ptr& aMatch) for (auto& attr_match : aMatch->MatchingAttributes) { CryptoHashStream::Algorithm needed = CryptoHashStream::Algorithm::Undefined; - if (m_MatchHash & CryptoHashStream::Algorithm::MD5 && attr_match.MD5.empty()) + if ((m_MatchHash & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 + && attr_match.MD5.empty()) needed |= CryptoHashStream::Algorithm::MD5; - if (m_MatchHash & CryptoHashStream::Algorithm::SHA1 && attr_match.SHA1.empty()) + if ((m_MatchHash & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 + && attr_match.SHA1.empty()) needed |= CryptoHashStream::Algorithm::SHA1; - if (m_MatchHash & CryptoHashStream::Algorithm::SHA256 && attr_match.SHA256.empty()) + if ((m_MatchHash & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 + && attr_match.SHA256.empty()) needed |= CryptoHashStream::Algorithm::SHA256; if (needed != CryptoHashStream::Algorithm::Undefined) @@ -3525,19 +3526,19 @@ HRESULT FileFind::ComputeMatchHashes(const std::shared_ptr& aMatch) if (ullWritten > 0) { - if (needed & CryptoHashStream::Algorithm::MD5 + if ((needed & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::MD5, attr_match.MD5))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (needed & CryptoHashStream::Algorithm::SHA1 + if ((needed & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, attr_match.SHA1))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (needed & CryptoHashStream::Algorithm::SHA256 + if ((needed & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, attr_match.SHA256))) { if (hr != MK_E_UNAVAILABLE) diff --git a/src/OrcLib/FileInfo.cpp b/src/OrcLib/FileInfo.cpp index cf65d0cb..d44bcbcc 100644 --- a/src/OrcLib/FileInfo.cpp +++ b/src/OrcLib/FileInfo.cpp @@ -269,7 +269,7 @@ HRESULT FileInfo::WriteFileInformation( try { - if (localIntentions & pCurCol->dwIntention) + if ((localIntentions & pCurCol->dwIntention) == pCurCol->dwIntention) { if (FAILED(hr = HandleIntentions(pCurCol->dwIntention, output))) { @@ -413,7 +413,7 @@ HRESULT FileInfo::BindColumns( while (pCurCol->dwIntention != Intentions::FILEINFO_NONE) { - if (dwIntentions & pCurCol->dwIntention) + if ((dwIntentions & pCurCol->dwIntention) == pCurCol->dwIntention) { dwIndex++; @@ -451,7 +451,7 @@ DWORD FileInfo::GetRequiredAccessMask(const ColumnNameDef columnNames[]) const ColumnNameDef* pCurCol = columnNames; while (pCurCol->dwIntention != Intentions::FILEINFO_NONE) { - if (m_DefaultIntentions & pCurCol->dwIntention) + if ((m_DefaultIntentions & pCurCol->dwIntention) == pCurCol->dwIntention) dwRequiredAccess |= pCurCol->dwRequiredAccess; pCurCol++; } @@ -460,7 +460,7 @@ DWORD FileInfo::GetRequiredAccessMask(const ColumnNameDef columnNames[]) const ColumnNameDef* pCurCol = columnNames; while (pCurCol->dwIntention != Intentions::FILEINFO_NONE) { - if (filter.intent & pCurCol->dwIntention) + if ((filter.intent & pCurCol->dwIntention) == pCurCol->dwIntention) dwRequiredAccess |= pCurCol->dwRequiredAccess; pCurCol++; } @@ -559,14 +559,17 @@ HRESULT FileInfo::OpenHash() Intentions localIntentions = FilterIntentions(m_Filters); - if (localIntentions & Intentions::FILEINFO_MD5 || localIntentions & Intentions::FILEINFO_SHA1 - || localIntentions & Intentions::FILEINFO_SHA256 || localIntentions & Intentions::FILEINFO_SSDEEP - || localIntentions & Intentions::FILEINFO_TLSH) - { - if (localIntentions & Intentions::FILEINFO_PE_MD5 || localIntentions & Intentions::FILEINFO_PE_SHA1 - || localIntentions & Intentions::FILEINFO_PE_SHA256 - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) + if ((localIntentions & Intentions::FILEINFO_MD5) == Intentions::FILEINFO_MD5 + || (localIntentions & Intentions::FILEINFO_SHA1) == Intentions::FILEINFO_SHA1 + || (localIntentions & Intentions::FILEINFO_SHA256) == Intentions::FILEINFO_SHA256 + || (localIntentions & Intentions::FILEINFO_SSDEEP) == Intentions::FILEINFO_SSDEEP + || (localIntentions & Intentions::FILEINFO_TLSH) == Intentions::FILEINFO_TLSH) + { + if ((localIntentions & Intentions::FILEINFO_PE_MD5) == Intentions::FILEINFO_PE_MD5 + || (localIntentions & Intentions::FILEINFO_PE_SHA1) == Intentions::FILEINFO_PE_SHA1 + || (localIntentions & Intentions::FILEINFO_PE_SHA256) == Intentions::FILEINFO_PE_SHA256 + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS) == Intentions::FILEINFO_AUTHENTICODE_STATUS + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) == Intentions::FILEINFO_AUTHENTICODE_SIGNER) { if (FAILED(hr = m_PEInfo.CheckPEInformation())) return hr; @@ -579,10 +582,11 @@ HRESULT FileInfo::OpenHash() return OpenCryptoAndFuzzyHash(localIntentions); } else if ( - localIntentions & Intentions::FILEINFO_PE_MD5 || localIntentions & Intentions::FILEINFO_PE_SHA1 - || localIntentions & Intentions::FILEINFO_PE_SHA256 - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) + (localIntentions & Intentions::FILEINFO_PE_MD5) == Intentions::FILEINFO_PE_MD5 + || (localIntentions & Intentions::FILEINFO_PE_SHA1) == Intentions::FILEINFO_PE_SHA1 + || (localIntentions & Intentions::FILEINFO_PE_SHA256) == Intentions::FILEINFO_PE_SHA256 + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS) == Intentions::FILEINFO_AUTHENTICODE_STATUS + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) == Intentions::FILEINFO_AUTHENTICODE_SIGNER) { if (FAILED(hr = m_PEInfo.CheckPEInformation())) return hr; @@ -600,11 +604,11 @@ HRESULT FileInfo::OpenCryptoHash(Intentions localIntentions) return S_OK; CryptoHashStream::Algorithm algs = CryptoHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_MD5) + if ((localIntentions & Intentions::FILEINFO_MD5) == Intentions::FILEINFO_MD5) algs |= CryptoHashStream::Algorithm::MD5; - if (localIntentions & Intentions::FILEINFO_SHA1) + if ((localIntentions & Intentions::FILEINFO_SHA1) == Intentions::FILEINFO_SHA1) algs |= CryptoHashStream::Algorithm::SHA1; - if (localIntentions & Intentions::FILEINFO_SHA256) + if ((localIntentions & Intentions::FILEINFO_SHA256) == Intentions::FILEINFO_SHA256) algs |= CryptoHashStream::Algorithm::SHA256; auto stream = GetDetails()->GetDataStream(); @@ -627,19 +631,19 @@ HRESULT FileInfo::OpenCryptoHash(Intentions localIntentions) if (ullWritten > 0) { - if (algs & CryptoHashStream::Algorithm::MD5 + if ((algs & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::MD5, GetDetails()->MD5()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (algs & CryptoHashStream::Algorithm::SHA1 + if ((algs & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, GetDetails()->SHA1()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (algs & CryptoHashStream::Algorithm::SHA256 + if ((algs & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, GetDetails()->SHA256()))) { if (hr != MK_E_UNAVAILABLE) @@ -658,9 +662,9 @@ HRESULT FileInfo::OpenFuzzyHash(Intentions localIntentions) return S_OK; FuzzyHashStream::Algorithm algs = FuzzyHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_SSDEEP) + if ((localIntentions & Intentions::FILEINFO_SSDEEP) == Intentions::FILEINFO_SSDEEP) algs |= FuzzyHashStream::Algorithm::SSDeep; - if (localIntentions & Intentions::FILEINFO_TLSH) + if ((localIntentions & Intentions::FILEINFO_TLSH) == Intentions::FILEINFO_TLSH) algs |= FuzzyHashStream::Algorithm::TLSH; auto stream = GetDetails()->GetDataStream(); @@ -683,7 +687,7 @@ HRESULT FileInfo::OpenFuzzyHash(Intentions localIntentions) if (ullWritten > 0) { - if (algs & FuzzyHashStream::Algorithm::SSDeep) + if ((algs & FuzzyHashStream::Algorithm::SSDeep) == FuzzyHashStream::Algorithm::SSDeep) { hr = hashstream->GetHash(FuzzyHashStream::Algorithm::SSDeep, GetDetails()->SSDeep()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -692,7 +696,7 @@ HRESULT FileInfo::OpenFuzzyHash(Intentions localIntentions) } } - if (algs & FuzzyHashStream::Algorithm::TLSH) + if ((algs & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH) { hr = hashstream->GetHash(FuzzyHashStream::Algorithm::TLSH, GetDetails()->TLSH()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -713,17 +717,17 @@ HRESULT FileInfo::OpenCryptoAndFuzzyHash(Intentions localIntentions) return S_OK; CryptoHashStream::Algorithm crypto_algs = CryptoHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_MD5) + if ((localIntentions & Intentions::FILEINFO_MD5) == Intentions::FILEINFO_MD5) crypto_algs |= CryptoHashStream::Algorithm::MD5; - if (localIntentions & Intentions::FILEINFO_SHA1) + if ((localIntentions & Intentions::FILEINFO_SHA1) == Intentions::FILEINFO_SHA1) crypto_algs |= CryptoHashStream::Algorithm::SHA1; - if (localIntentions & Intentions::FILEINFO_SHA256) + if ((localIntentions & Intentions::FILEINFO_SHA256) == Intentions::FILEINFO_SHA256) crypto_algs |= CryptoHashStream::Algorithm::SHA256; FuzzyHashStream::Algorithm fuzzy_algs = FuzzyHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_SSDEEP) + if ((localIntentions & Intentions::FILEINFO_SSDEEP) == Intentions::FILEINFO_SSDEEP) fuzzy_algs |= FuzzyHashStream::Algorithm::SSDeep; - if (localIntentions & Intentions::FILEINFO_TLSH) + if ((localIntentions & Intentions::FILEINFO_TLSH) == Intentions::FILEINFO_TLSH) fuzzy_algs |= FuzzyHashStream::Algorithm::TLSH; auto stream = GetDetails()->GetDataStream(); @@ -767,19 +771,19 @@ HRESULT FileInfo::OpenCryptoAndFuzzyHash(Intentions localIntentions) if (ullWritten > 0) { - if (crypto_algs & CryptoHashStream::Algorithm::MD5 + if ((crypto_algs & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 && FAILED(hr = crypto_hashstream->GetHash(CryptoHashStream::Algorithm::MD5, GetDetails()->MD5()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (crypto_algs & CryptoHashStream::Algorithm::SHA1 + if ((crypto_algs & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 && FAILED(hr = crypto_hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, GetDetails()->SHA1()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (crypto_algs & CryptoHashStream::Algorithm::SHA256 + if ((crypto_algs & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 && FAILED(hr = crypto_hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, GetDetails()->SHA256()))) { if (hr != MK_E_UNAVAILABLE) @@ -793,7 +797,7 @@ HRESULT FileInfo::OpenCryptoAndFuzzyHash(Intentions localIntentions) return hr; } #endif - if (fuzzy_algs & FuzzyHashStream::Algorithm::TLSH + if ((fuzzy_algs & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH && FAILED(hr = fuzzy_hashstream->GetHash(FuzzyHashStream::Algorithm::TLSH, GetDetails()->TLSH()))) { if (hr != MK_E_UNAVAILABLE) diff --git a/src/OrcLib/FuzzyHashStream.cpp b/src/OrcLib/FuzzyHashStream.cpp index 17f0cfa0..9d7cc9b4 100644 --- a/src/OrcLib/FuzzyHashStream.cpp +++ b/src/OrcLib/FuzzyHashStream.cpp @@ -46,7 +46,7 @@ std::wstring FuzzyHashStream::GetSupportedAlgorithm(Algorithm algs) retval.append(L"SSDeep"); } #endif // ORC_BUILD_SSDEEP - if (algs & FuzzyHashStream::Algorithm::TLSH) + if ((algs & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH) { if (retval.empty()) retval.append(L"TLSH"); @@ -128,7 +128,7 @@ HRESULT FuzzyHashStream::ResetHash(bool bContinue) } #endif // ORC_BUILD_SSDEEP - if (m_Algorithms & FuzzyHashStream::Algorithm::TLSH) + if ((m_Algorithms & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH) { m_tlsh = std::make_unique(); } @@ -173,7 +173,7 @@ HRESULT FuzzyHashStream::GetHash(FuzzyHashStream::Algorithm alg, CBinaryBuffer& #endif // ORC_BUILD_SSDEEP break; case FuzzyHashStream::Algorithm::TLSH: - if (m_Algorithms & FuzzyHashStream::Algorithm::TLSH && m_tlsh) + if ((m_Algorithms & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH && m_tlsh) { if (!m_tlsh->isValid()) { diff --git a/src/OrcLib/MftRecordAttribute.cpp b/src/OrcLib/MftRecordAttribute.cpp index 157695db..167004a0 100644 --- a/src/OrcLib/MftRecordAttribute.cpp +++ b/src/OrcLib/MftRecordAttribute.cpp @@ -438,11 +438,13 @@ HRESULT MftRecordAttribute::GetHashInformation( CryptoHashStream::Algorithm needed = CryptoHashStream::Algorithm::Undefined; - if (required & CryptoHashStream::Algorithm::MD5 && m_Details->MD5().empty()) + if ((required & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 && m_Details->MD5().empty()) needed |= CryptoHashStream::Algorithm::MD5; - if (required & CryptoHashStream::Algorithm::SHA1 && m_Details->SHA1().empty()) + if ((required & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 + && m_Details->SHA1().empty()) needed |= CryptoHashStream::Algorithm::SHA1; - if (required & CryptoHashStream::Algorithm::SHA256 && m_Details->SHA256().empty()) + if ((required & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 + && m_Details->SHA256().empty()) needed |= CryptoHashStream::Algorithm::SHA256; if (needed == CryptoHashStream::Algorithm::Undefined) @@ -475,21 +477,21 @@ HRESULT MftRecordAttribute::GetHashInformation( return hr; } - if (needed & CryptoHashStream::Algorithm::MD5) + if ((needed & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5) { CBinaryBuffer md5; if (FAILED(hr = pHashStream->GetMD5(md5))) return hr; m_Details->SetMD5(std::move(md5)); } - if (needed & CryptoHashStream::Algorithm::SHA1) + if ((needed & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1) { CBinaryBuffer sha1; if (FAILED(hr = pHashStream->GetSHA1(sha1))) return hr; m_Details->SetSHA1(std::move(sha1)); } - if (needed & CryptoHashStream::Algorithm::SHA256) + if ((needed & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256) { CBinaryBuffer sha256; if (FAILED(hr = pHashStream->GetSHA256(sha256))) diff --git a/src/OrcLib/Output/Text/Print/Intentions.h b/src/OrcLib/Output/Text/Print/Intentions.h index 2df20099..29c7a47a 100644 --- a/src/OrcLib/Output/Text/Print/Intentions.h +++ b/src/OrcLib/Output/Text/Print/Intentions.h @@ -22,7 +22,7 @@ void PrintValue(Orc::Text::Tree& root, const N& name, Orc::Intentions intenti while (pCurCol->dwIntention != Intentions::FILEINFO_NONE) { - if (intentions & pCurCol->dwIntention) + if ((intentions & pCurCol->dwIntention) == pCurCol->dwIntention) { columns.push_back(pCurCol->szColumnName); } diff --git a/src/OrcLib/OutputSpec.cpp b/src/OrcLib/OutputSpec.cpp index f3643fce..84d7c7a5 100644 --- a/src/OrcLib/OutputSpec.cpp +++ b/src/OrcLib/OutputSpec.cpp @@ -97,36 +97,42 @@ OutputSpec::ApplyPattern(const std::wstring& strPattern, const std::wstring& str bool OutputSpec::IsDirectory() const { - return Type & Kind::Directory; + return (Type & Kind::Directory) == Kind::Directory; }; bool OutputSpec::IsFile() const { - return Type & Kind::File || Type & Kind::TableFile || Type & Kind::StructuredFile || Type & Kind::Archive - || Type & Kind::CSV || Type & Kind::TSV || Type & Kind::Parquet || Type & Kind::ORC || Type & Kind::XML - || Type & Kind::JSON; + return (Type & Kind::File) == Kind::File || (Type & Kind::TableFile) == Kind::TableFile + || (Type & Kind::StructuredFile) == Kind::StructuredFile || (Type & Kind::Archive) == Kind::Archive + || (Type & Kind::CSV) == Kind::CSV || (Type & Kind::TSV) == Kind::TSV || (Type & Kind::Parquet) == Kind::Parquet + || (Type & Kind::ORC) == Kind::ORC || (Type & Kind::XML) == Kind::XML || (Type & Kind::JSON) == Kind::JSON; } // the same but without archive bool OutputSpec::IsRegularFile() const { - return Type & Kind::File || Type & Kind::TableFile || Type & Kind::StructuredFile || Type & Kind::CSV - || Type & Kind::TSV || Type & Kind::Parquet || Type & Kind::ORC || Type & Kind::XML || Type & Kind::JSON; + return (Type & Kind::File) == Kind::File || (Type & Kind::TableFile) == Kind::TableFile + || (Type & Kind::StructuredFile) == Kind::StructuredFile || (Type & Kind::CSV) == Kind::CSV + || (Type & Kind::TSV) == Kind::TSV || (Type & Kind::Parquet) == Kind::Parquet || (Type & Kind::ORC) == Kind::ORC + || (Type & Kind::XML) == Kind::XML || (Type & Kind::JSON) == Kind::JSON; } bool OutputSpec::IsTableFile() const { - return Type & Kind::TableFile || Type & Kind::CSV || Type & Kind::TSV || Type & Kind::Parquet || Type & Kind::ORC; + return (Type & Kind::TableFile) == Kind::TableFile || (Type & Kind::CSV) == Kind::CSV + || (Type & Kind::TSV) == Kind::TSV || (Type & Kind::Parquet) == Kind::Parquet + || (Type & Kind::ORC) == Kind::ORC; } bool OutputSpec::IsStructuredFile() const { - return Type & Kind::StructuredFile || Type & Kind::XML || Type & Kind::JSON; + return (Type & Kind::StructuredFile) == Kind::StructuredFile || (Type & Kind::XML) == Kind::XML + || (Type & Kind::JSON) == Kind::JSON; } bool OutputSpec::IsArchive() const { - return Type & Kind::Archive; + return (Type & Kind::Archive) == Kind::Archive; } HRESULT OutputSpec::Configure( @@ -138,7 +144,7 @@ HRESULT OutputSpec::Configure( Type = OutputSpec::Kind::None; - if (OutputSpec::Kind::SQL & supported) // Getting the SQL stuff out of the door asap + if ((supported & OutputSpec::Kind::SQL) == OutputSpec::Kind::SQL) // Getting the SQL stuff out of the door asap { static std::wregex reConnectionString(LR"RAW(^(([\w\s]+=[\w\s{}.]+;?)+)#([\w]+)$)RAW"); @@ -188,7 +194,7 @@ HRESULT OutputSpec::Configure( auto extension = outPath.extension(); - if (OutputSpec::Kind::TableFile & supported) + if ((supported & OutputSpec::Kind::TableFile) == OutputSpec::Kind::TableFile) { if (equalCaseInsensitive(extension.c_str(), L".csv"sv)) { @@ -219,7 +225,7 @@ HRESULT OutputSpec::Configure( return Orc::GetOutputFile(outPath.c_str(), Path, true); } } - if (OutputSpec::Kind::StructuredFile & supported) + if ((supported & OutputSpec::Kind::StructuredFile) == OutputSpec::Kind::StructuredFile) { if (equalCaseInsensitive(extension.c_str(), L".xml"sv)) { @@ -228,7 +234,7 @@ HRESULT OutputSpec::Configure( return Orc::GetOutputFile(outPath.c_str(), Path, true); } } - if (OutputSpec::Kind::StructuredFile & supported) + if ((supported & OutputSpec::Kind::StructuredFile) == OutputSpec::Kind::StructuredFile) { if (equalCaseInsensitive(extension.c_str(), L".json"sv)) { @@ -237,7 +243,7 @@ HRESULT OutputSpec::Configure( return Orc::GetOutputFile(outPath.c_str(), Path, true); } } - if (OutputSpec::Kind::Archive & supported) + if ((supported & OutputSpec::Kind::Archive) == OutputSpec::Kind::Archive) { auto fmt = OrcArchive::GetArchiveFormat(extension.c_str()); if (fmt != ArchiveFormat::Unknown) @@ -248,7 +254,8 @@ HRESULT OutputSpec::Configure( } } - if (OutputSpec::Kind::Directory & supported && wcslen(extension.c_str()) == 0L && !outPath.empty()) + if ((supported & OutputSpec::Kind::Directory) == OutputSpec::Kind::Directory && wcslen(extension.c_str()) == 0L + && !outPath.empty()) { // Output without extension could very well be a dir if (SUCCEEDED(VerifyDirectoryExists(outPath.c_str()))) @@ -266,7 +273,7 @@ HRESULT OutputSpec::Configure( } } - if (OutputSpec::Kind::File & supported) + if ((supported & OutputSpec::Kind::File) == OutputSpec::Kind::File) { Type = OutputSpec::Kind::File; return Orc::GetOutputFile(outPath.c_str(), Path, true); @@ -284,7 +291,7 @@ OutputSpec::Configure(OutputSpec::Kind supported, const ConfigItem& item, std::o Type = OutputSpec::Kind::None; - if (supported & static_cast(OutputSpec::Kind::SQL)) + if ((supported & static_cast(OutputSpec::Kind::SQL)) == OutputSpec::Kind::SQL) { bool bDone = false; if (::HasValue(item, CONFIG_OUTPUT_CONNECTION)) diff --git a/src/OrcLib/PEInfo.cpp b/src/OrcLib/PEInfo.cpp index 99c89880..19fe8ed3 100644 --- a/src/OrcLib/PEInfo.cpp +++ b/src/OrcLib/PEInfo.cpp @@ -532,19 +532,19 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) return S_OK; CryptoHashStream::Algorithm algs = CryptoHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_MD5) + if ((localIntentions & Intentions::FILEINFO_MD5) == Intentions::FILEINFO_MD5) algs |= CryptoHashStream::Algorithm::MD5; - if (localIntentions & Intentions::FILEINFO_SHA1) + if ((localIntentions & Intentions::FILEINFO_SHA1) == Intentions::FILEINFO_SHA1) algs |= CryptoHashStream::Algorithm::SHA1; - if (localIntentions & Intentions::FILEINFO_SHA256) + if ((localIntentions & Intentions::FILEINFO_SHA256) == Intentions::FILEINFO_SHA256) algs |= CryptoHashStream::Algorithm::SHA256; CryptoHashStream::Algorithm pe_algs = CryptoHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_PE_MD5) + if ((localIntentions & Intentions::FILEINFO_PE_MD5) == Intentions::FILEINFO_PE_MD5) pe_algs |= CryptoHashStream::Algorithm::MD5; - if (localIntentions & Intentions::FILEINFO_PE_SHA1) + if ((localIntentions & Intentions::FILEINFO_PE_SHA1) == Intentions::FILEINFO_PE_SHA1) pe_algs |= CryptoHashStream::Algorithm::SHA1; - if (localIntentions & Intentions::FILEINFO_PE_SHA256) + if ((localIntentions & Intentions::FILEINFO_PE_SHA256) == Intentions::FILEINFO_PE_SHA256) pe_algs |= CryptoHashStream::Algorithm::SHA256; FuzzyHashStream::Algorithm fuzzy_algs = FuzzyHashStream::Algorithm::Undefined; @@ -554,11 +554,13 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) fuzzy_algs = fuzzy_algs | FuzzyHashStream::Algorithm::SSDeep; #endif - if (localIntentions & Intentions::FILEINFO_TLSH) + if ((localIntentions & Intentions::FILEINFO_TLSH) == Intentions::FILEINFO_TLSH) + { fuzzy_algs |= FuzzyHashStream::Algorithm::TLSH; + } - if (localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) + if ((localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS) == Intentions::FILEINFO_AUTHENTICODE_STATUS + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) == Intentions::FILEINFO_AUTHENTICODE_SIGNER) { pe_algs |= CryptoHashStream::Algorithm::MD5 | CryptoHashStream::Algorithm::SHA1 | CryptoHashStream::Algorithm::SHA256; @@ -595,7 +597,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) ULONGLONG ullHashed = 0LL; hashstream->Write(pData.GetData(), ullWritten, &ullHashed); - if (algs & CryptoHashStream::Algorithm::MD5) + if ((algs & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5) { hr = hashstream->GetHash(CryptoHashStream::Algorithm::MD5, m_FileInfo.GetDetails()->MD5()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -604,7 +606,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) } } - if (algs & CryptoHashStream::Algorithm::SHA1) + if ((algs & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1) { hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, m_FileInfo.GetDetails()->SHA1()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -613,7 +615,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) } } - if (algs & CryptoHashStream::Algorithm::SHA256) + if ((algs & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256) { hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, m_FileInfo.GetDetails()->SHA256()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -631,7 +633,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) ULONGLONG ullHashed = 0LL; hashstream->Write(pData.GetData(), ullWritten, &ullHashed); - if (fuzzy_algs & FuzzyHashStream::Algorithm::SSDeep) + if ((fuzzy_algs & FuzzyHashStream::Algorithm::SSDeep) == FuzzyHashStream::Algorithm::SSDeep) { hr = hashstream->GetHash(FuzzyHashStream::Algorithm::SSDeep, m_FileInfo.GetDetails()->SSDeep()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -640,7 +642,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) } } - if (fuzzy_algs & FuzzyHashStream::Algorithm::TLSH) + if ((fuzzy_algs & FuzzyHashStream::Algorithm::TLSH) == FuzzyHashStream::Algorithm::TLSH) { hr = hashstream->GetHash(FuzzyHashStream::Algorithm::TLSH, m_FileInfo.GetDetails()->TLSH()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -691,7 +693,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) ullPeHashed += ullThisWriteHashed; } - if (pe_algs & CryptoHashStream::Algorithm::MD5) + if ((pe_algs & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5) { hr = pe_hashstream->GetHash(CryptoHashStream::Algorithm::MD5, m_FileInfo.GetDetails()->PeMD5()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -700,7 +702,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) } } - if (pe_algs & CryptoHashStream::Algorithm::SHA1) + if ((pe_algs & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1) { hr = pe_hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, m_FileInfo.GetDetails()->PeSHA1()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -709,7 +711,7 @@ HRESULT PEInfo::OpenAllHash(Intentions localIntentions) } } - if (pe_algs & CryptoHashStream::Algorithm::SHA256) + if ((pe_algs & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256) { hr = pe_hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, m_FileInfo.GetDetails()->PeSHA256()); if (FAILED(hr) && hr != MK_E_UNAVAILABLE) @@ -783,14 +785,14 @@ HRESULT PEInfo::OpenPeHash(Intentions localIntentions) auto hashstream = std::make_shared(); CryptoHashStream::Algorithm algs = CryptoHashStream::Algorithm::Undefined; - if (localIntentions & Intentions::FILEINFO_PE_MD5) + if ((localIntentions & Intentions::FILEINFO_PE_MD5) == Intentions::FILEINFO_PE_MD5) algs |= CryptoHashStream::Algorithm::MD5; - if (localIntentions & Intentions::FILEINFO_PE_SHA1) + if ((localIntentions & Intentions::FILEINFO_PE_SHA1) == Intentions::FILEINFO_PE_SHA1) algs |= CryptoHashStream::Algorithm::SHA1; - if (localIntentions & Intentions::FILEINFO_PE_SHA256) + if ((localIntentions & Intentions::FILEINFO_PE_SHA256) == Intentions::FILEINFO_PE_SHA256) algs |= CryptoHashStream::Algorithm::SHA256; - if (localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS - || localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) + if ((localIntentions & Intentions::FILEINFO_AUTHENTICODE_STATUS) == Intentions::FILEINFO_AUTHENTICODE_STATUS + || (localIntentions & Intentions::FILEINFO_AUTHENTICODE_SIGNER) == Intentions::FILEINFO_AUTHENTICODE_SIGNER) { algs |= CryptoHashStream::Algorithm::MD5 | CryptoHashStream::Algorithm::SHA1 | CryptoHashStream::Algorithm::SHA256; @@ -806,19 +808,19 @@ HRESULT PEInfo::OpenPeHash(Intentions localIntentions) ullHashed += ullThisWriteHashed; } - if (algs & CryptoHashStream::Algorithm::MD5 + if ((algs & CryptoHashStream::Algorithm::MD5) == CryptoHashStream::Algorithm::MD5 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::MD5, m_FileInfo.GetDetails()->PeMD5()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (algs & CryptoHashStream::Algorithm::SHA1 + if ((algs & CryptoHashStream::Algorithm::SHA1) == CryptoHashStream::Algorithm::SHA1 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA1, m_FileInfo.GetDetails()->PeSHA1()))) { if (hr != MK_E_UNAVAILABLE) return hr; } - if (algs & CryptoHashStream::Algorithm::SHA256 + if ((algs & CryptoHashStream::Algorithm::SHA256) == CryptoHashStream::Algorithm::SHA256 && FAILED(hr = hashstream->GetHash(CryptoHashStream::Algorithm::SHA256, m_FileInfo.GetDetails()->PeSHA256()))) { if (hr != MK_E_UNAVAILABLE) diff --git a/src/OrcLib/Partition.cpp b/src/OrcLib/Partition.cpp index 908ae7f7..9498c93f 100644 --- a/src/OrcLib/Partition.cpp +++ b/src/OrcLib/Partition.cpp @@ -16,27 +16,27 @@ namespace Orc { bool Partition::IsBootable() const { - return PartitionFlags & Flags::Bootable; + return (PartitionFlags & Flags::Bootable) == Flags::Bootable; } bool Partition::IsSystem() const { - return PartitionFlags & Flags::System; + return (PartitionFlags & Flags::System) == Flags::System; } bool Partition::IsReadOnly() const { - return PartitionFlags & Flags::ReadOnly; + return (PartitionFlags & Flags::ReadOnly) == Flags::ReadOnly; } bool Partition::IsHidden() const { - return PartitionFlags & Flags::Hidden; + return (PartitionFlags & Flags::Hidden) == Flags::Hidden; } bool Partition::IsNotAutoMountable() const { - return PartitionFlags & Flags::NoAutoMount; + return (PartitionFlags & Flags::NoAutoMount) == Flags::NoAutoMount; } bool Partition::IsFAT12() const diff --git a/src/OrcLib/PartitionFlags.cpp b/src/OrcLib/PartitionFlags.cpp index 578773ee..dc1c65e8 100644 --- a/src/OrcLib/PartitionFlags.cpp +++ b/src/OrcLib/PartitionFlags.cpp @@ -19,37 +19,37 @@ std::wstring ToString(PartitionFlags flags) { std::vector activeFlags; - if (flags & PartitionFlags::Bootable) + if ((flags & PartitionFlags::Bootable) == PartitionFlags::Bootable) { activeFlags.push_back(L"BOOTABLE"); } - if (flags & PartitionFlags::Hidden) + if ((flags & PartitionFlags::Hidden) == PartitionFlags::Hidden) { activeFlags.push_back(L"HIDDEN"); } - if (flags & PartitionFlags::Invalid) + if ((flags & PartitionFlags::Invalid) == PartitionFlags::Invalid) { activeFlags.push_back(L"INVALID"); } - if (flags & PartitionFlags::NoAutoMount) + if ((flags & PartitionFlags::NoAutoMount) == PartitionFlags::NoAutoMount) { activeFlags.push_back(L"NO_AUTO_MOUNT"); } - if (flags & PartitionFlags::None) + if ((flags & PartitionFlags::None) == PartitionFlags::None) { activeFlags.push_back(L"NONE"); } - if (flags & PartitionFlags::ReadOnly) + if ((flags & PartitionFlags::ReadOnly) == PartitionFlags::ReadOnly) { activeFlags.push_back(L"READONLY"); } - if (flags & PartitionFlags::System) + if ((flags & PartitionFlags::System) == PartitionFlags::System) { activeFlags.push_back(L"SYSTEM"); } diff --git a/src/OrcLib/Utils/EnumFlags.h b/src/OrcLib/Utils/EnumFlags.h index c10ac836..dcd1b74a 100644 --- a/src/OrcLib/Utils/EnumFlags.h +++ b/src/OrcLib/Utils/EnumFlags.h @@ -24,31 +24,31 @@ struct EnableBitMaskOperators }; template -typename std::enable_if::enable, bool>::type constexpr operator&(Enum lhs, Enum rhs) +typename std::enable_if::enable, Enum>::type constexpr operator&(Enum lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; - return static_cast(lhs) & static_cast(rhs); + using underlying = typename std::underlying_type_t; + return static_cast(static_cast(lhs) & static_cast(rhs)); } template -typename std::enable_if::enable, bool>::type constexpr operator&=(Enum& lhs, Enum rhs) +typename std::enable_if::enable, Enum>::type constexpr operator&=(Enum& lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; - lhs = static_cast(lhs) & static_cast(rhs); + using underlying = typename std::underlying_type_t; + lhs = static_cast(static_cast(lhs) & static_cast(rhs)); return lhs; } template typename std::enable_if::enable, Enum>::type constexpr operator|(Enum lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; + using underlying = typename std::underlying_type_t; return static_cast(static_cast(lhs) | static_cast(rhs)); } template typename std::enable_if::enable, Enum>::type constexpr operator|=(Enum& lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; + using underlying = typename std::underlying_type_t; lhs = static_cast(static_cast(lhs) | static_cast(rhs)); return lhs; } @@ -56,14 +56,14 @@ typename std::enable_if::enable, Enum>::type conste template typename std::enable_if::enable, Enum>::type constexpr operator^(Enum lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; + using underlying = typename std::underlying_type_t; return static_cast(static_cast(lhs) ^ static_cast(rhs)); } template typename std::enable_if::enable, Enum>::type constexpr operator^=(Enum& lhs, Enum rhs) { - using underlying = typename std::underlying_type::type; + using underlying = typename std::underlying_type_t; lhs = static_cast(static_cast(lhs) ^ static_cast(rhs)); return lhs; } @@ -71,8 +71,8 @@ typename std::enable_if::enable, Enum>::type conste template typename std::enable_if::enable, Enum>::type constexpr operator~(Enum value) { - using underlying = typename std::underlying_type::type; - return static_cast(static_cast(value)); + using underlying = typename std::underlying_type_t; + return static_cast(~static_cast(value)); } #define ENABLE_BITMASK_OPERATORS(x) \