Skip to content

Commit 135db77

Browse files
committed
Add support for msvc v143 and cpp23
1 parent b1f36fe commit 135db77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+529
-359
lines changed

src/Orc/Mothership_Config.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace Orc;
2626
using namespace Orc::Command::Mothership;
2727

2828
namespace {
29-
void WriteArgument(std::wstringstream& stream, std::wstring_view& arg)
29+
void WriteArgument(std::wstringstream& stream, std::wstring_view arg)
3030
{
3131
if (arg.find(' ') != std::wstring::npos)
3232
{

src/Orc/Orc.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#include "EmbeddedResource.h"
5959

6060
using WinMainPtr = std::function<int(int argc, const WCHAR* argv[])>;
61+
6162
struct ToolDescription
6263
{
6364
ToolDescription(LPCWSTR toolName, LPCWSTR toolDescr, WinMainPtr main)
@@ -71,7 +72,7 @@ struct ToolDescription
7172
static ToolDescription Get()
7273
{
7374
return ToolDescription(
74-
CommandType::ToolName(), CommandType::ToolDescription(), UtilitiesMain::WMain<CommandType>);
75+
CommandType::ToolName(), CommandType::ToolDescription(), Orc::Command::UtilitiesMain::WMain<CommandType>);
7576
}
7677

7778
LPCWSTR szName;

src/OrcCommand/Command/ToolEmbed/ToolEmbed_Config.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,15 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
304304
switch (argv[i][0])
305305
{
306306
case L'/':
307-
case L'-':
308-
if (OptionalParameterOption(argv[i] + 1, L"Dump", std::optional<std::wstring>(strParameter)))
307+
case L'-': {
308+
std::optional<std::wstring> optionalParameter(strParameter);
309+
if (OptionalParameterOption(argv[i] + 1, L"Dump", optionalParameter))
309310
{
310311
config.Todo = Main::Dump;
311312
if (!strParameter.empty())
312313
config.strInputFile = strParameter;
313314
}
314-
if (OptionalParameterOption(argv[i] + 1, L"FromDump", std::optional<std::wstring>(strParameter)))
315+
if (OptionalParameterOption(argv[i] + 1, L"FromDump", optionalParameter))
315316
{
316317
config.Todo = Main::FromDump;
317318
if (!strParameter.empty())
@@ -425,6 +426,7 @@ HRESULT Main::GetConfigurationFromArgcArgv(int argc, LPCWSTR argv[])
425426
}
426427
}
427428
break;
429+
}
428430
default:
429431
break;
430432
}

src/OrcCommand/Command/WolfLauncher/Journal.h

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,14 @@ namespace Orc::Command::Wolf {
2525
class Journal
2626
{
2727
public:
28-
Journal::Journal(Console& console)
28+
Journal(Console& console)
2929
: m_mutex()
3030
, m_console(console)
3131
{
3232
}
3333

3434
template <typename... FmtArgs>
35-
void
36-
Print(const std::wstring_view& commandSet, const std::wstring_view& agent, Log::Level level, FmtArgs&&... status)
37-
const
35+
void Print(std::wstring_view commandSet, std::wstring_view agent, Log::Level level, FmtArgs&&... status) const
3836
{
3937
const auto timepoint = std::chrono::system_clock::now();
4038

@@ -57,7 +55,7 @@ class Journal
5755
}
5856

5957
template <typename... FmtArgs>
60-
void Print(const std::wstring_view& commandSet, const std::wstring_view& agent, FmtArgs&&... status) const
58+
void Print(std::wstring_view commandSet, std::wstring_view agent, FmtArgs&&... status) const
6159
{
6260
Print(commandSet, agent, Log::Level::Info, std::forward<FmtArgs>(status)...);
6361
}

src/OrcCommand/Command/WolfLauncher/Outcome.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,7 @@ class Recipient
386386
class Outcome
387387
{
388388
public:
389-
std::lock_guard<std::mutex> Lock() const
390-
{
391-
m_mutex.lock();
392-
return {std::move(m_mutex), std::adopt_lock};
393-
}
389+
std::mutex& Mutex() const { return m_mutex; }
394390

395391
CommandSet& GetCommandSet(const std::wstring& keyword) { return m_commandSets[keyword]; }
396392

src/OrcCommand/Command/WolfLauncher/WolfExecution.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "Command/WolfLauncher/Journal.h"
2828
#include "Command/WolfLauncher/Outcome.h"
29+
#include "Utils/Locker.h"
2930

3031
#pragma managed(push, off)
3132

@@ -83,15 +84,15 @@ class WolfExecution
8384
const JobRestrictions& GetJobRestrictions() const { return m_Restrictions; }
8485

8586
private:
86-
void WolfExecution::ArchiveNotificationHandler(const ArchiveNotification::Notification& notfication);
87+
void ArchiveNotificationHandler(const ArchiveNotification::Notification& notfication);
8788
CommandMessage::Message SetCommandFromConfigItem(const ConfigItem& item);
8889
HRESULT
8990
GetExecutableToRun(const ConfigItem& item, std::wstring& strExeToRun, std::wstring& strArgToAdd, bool& isSelf);
9091
HRESULT NotifyTask(const CommandNotification::Ptr& item);
9192

9293
private:
9394
Command::Wolf::Journal& m_journal;
94-
Command::Wolf::Outcome::Outcome& m_outcome;
95+
Locker<Command::Wolf::Outcome::Outcome>& m_outcome;
9596

9697
std::wstring m_commandSet;
9798
std::wstring m_strCompressionLevel;
@@ -259,7 +260,7 @@ class WolfExecution
259260

260261
HRESULT CompleteArchive(UploadMessage::ITarget* pUploadMessageQueue);
261262

262-
WolfExecution(Journal& journal, Wolf::Outcome::Outcome& outcome)
263+
WolfExecution(Journal& journal, Locker<Wolf::Outcome::Outcome>& outcome)
263264
: m_journal(journal)
264265
, m_outcome(outcome)
265266
{

src/OrcCommand/Command/WolfLauncher/WolfExecution_Execute.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ void WolfExecution::ArchiveNotificationHandler(const ArchiveNotification::Notifi
239239
return;
240240
}
241241

242-
auto&& lock = m_outcome.Lock();
243-
auto& commandSet = m_outcome.GetCommandSet(m_commandSet);
242+
auto [outcome, lock] = m_outcome.Get();
243+
auto& commandSet = outcome.GetCommandSet(m_commandSet);
244244
auto& outcomeArchive = commandSet.GetArchive();
245245

246246
switch (notification->GetType())
@@ -556,9 +556,9 @@ HRESULT WolfExecution::CreateCommandAgent(
556556

557557
Log::Info("JOB: Complete");
558558

559-
auto&& lock = m_outcome.Lock();
559+
auto [outcome, lock] = m_outcome.Get();
560560

561-
auto& commandSetOutcome = m_outcome.GetCommandSet(item->GetKeyword());
561+
auto& commandSetOutcome = outcome.GetCommandSet(item->GetKeyword());
562562
commandSetOutcome.SetKeyword(item->GetKeyword());
563563
commandSetOutcome.SetStart(FromFileTime(m_StartTime));
564564
commandSetOutcome.SetEnd(FromFileTime(m_FinishTime));
@@ -721,8 +721,8 @@ HRESULT WolfExecution::EnqueueCommands()
721721
}
722722

723723
{
724-
auto&& lock = m_outcome.Lock();
725-
auto& outcomeCommand = m_outcome.GetCommandSet(m_commandSet).GetCommand(command->Keyword());
724+
auto [outcome, lock] = m_outcome.Get();
725+
auto& outcomeCommand = outcome.GetCommandSet(m_commandSet).GetCommand(command->Keyword());
726726
for (const auto& parameter : command->GetParameters())
727727
{
728728
if (::HasFileOutput(parameter.Kind))

src/OrcCommand/Command/WolfLauncher/WolfLauncher.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Command/WolfLauncher/ConsoleConfiguration.h"
3030
#include "Utils/StdStream/StandardOutput.h"
3131
#include "Utils/EnumFlags.h"
32+
#include "Utils/Locker.h"
3233

3334
#pragma managed(push, off)
3435

@@ -183,7 +184,7 @@ class ORCUTILS_API Main : public UtilitiesMain
183184
HRESULT SetWERDontShowUI(DWORD dwNewValue, DWORD& dwOldValue);
184185

185186
HRESULT CreateAndUploadOutline();
186-
Orc::Result<void> Main::CreateAndUploadOutcome();
187+
Orc::Result<void> CreateAndUploadOutcome();
187188

188189
HRESULT SetLauncherPriority(WolfPriority priority);
189190

@@ -204,7 +205,7 @@ class ORCUTILS_API Main : public UtilitiesMain
204205
ConsoleConfiguration m_consoleConfiguration;
205206

206207
Journal m_journal;
207-
Wolf::Outcome::Outcome m_outcome;
208+
Locker<Wolf::Outcome::Outcome> m_outcome;
208209

209210
Configuration config;
210211

src/OrcCommand/Command/WolfLauncher/WolfLauncher_Run.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Orc::Result<std::string> WincryptBinaryToString(std::string_view buffer)
103103
{
104104
std::error_code ec = LastWin32Error();
105105
Log::Debug("Failed CryptBinaryToStringA while calculating output length [{}]", ec);
106-
return nullptr;
106+
return ec;
107107
}
108108

109109
publicKey.resize(publicKeySize);
@@ -117,7 +117,7 @@ Orc::Result<std::string> WincryptBinaryToString(std::string_view buffer)
117117
{
118118
std::error_code ec = LastWin32Error();
119119
Log::Debug("Failed CryptBinaryToStringA while converting binary blob [{}]", ec);
120-
return nullptr;
120+
return ec;
121121
}
122122

123123
publicKey.erase(boost::remove_if(publicKey, boost::is_any_of("\r\n")), publicKey.end());
@@ -219,8 +219,6 @@ Result<std::wstring> GetProcessExecutableHash(DWORD dwProcessId, CryptoHashStrea
219219

220220
void UpdateOutcome(Command::Wolf::Outcome::Outcome& outcome, const GUID& id, HANDLE hMothership)
221221
{
222-
auto&& lock = outcome.Lock();
223-
224222
outcome.SetId(id);
225223

226224
{
@@ -776,13 +774,15 @@ Orc::Result<void> Main::CreateAndUploadOutcome()
776774
return Success<void>();
777775
}
778776

779-
::UpdateOutcome(m_outcome, m_guid, m_hMothership);
780-
::UpdateOutcome(m_outcome, config.m_Recipients);
781-
::UpdateOutcome(m_outcome, m_standardOutput);
782-
::UpdateOutcome(m_outcome, m_logging);
783-
::UpdateOutcomeWithOutline(m_outcome, config.Outline);
777+
auto [outcome, lock] = m_outcome.Get();
778+
779+
::UpdateOutcome(outcome, m_guid, m_hMothership);
780+
::UpdateOutcome(outcome, config.m_Recipients);
781+
::UpdateOutcome(outcome, m_standardOutput);
782+
::UpdateOutcome(outcome, m_logging);
783+
::UpdateOutcomeWithOutline(outcome, config.Outline);
784784

785-
auto rv = ::DumpOutcome(m_outcome, config.Outcome);
785+
auto rv = ::DumpOutcome(outcome, config.Outcome);
786786
if (rv.has_error())
787787
{
788788

src/OrcCommand/FileInfoCommon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void FileInfoCommon::FreeFilters(Filter* pFilters)
330330
delete[] pFilters;
331331
}
332332

333-
HRESULT FileInfoCommon::ConfigItem_fileinfo_filter(ConfigItem& parent, LPWSTR szName, DWORD dwIndex)
333+
HRESULT FileInfoCommon::ConfigItem_fileinfo_filter(ConfigItem& parent, LPCWSTR szName, DWORD dwIndex)
334334
{
335335
HRESULT hr = E_FAIL;
336336
if (FAILED(hr = parent.AddChildNodeList(szName, dwIndex, ConfigItem::OPTION)))

src/OrcCommand/FileInfoCommon.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FileInfoCommon
5252
static void FreeFilters(Filter* pFilters);
5353

5454
// file info config related static methods
55-
static HRESULT ConfigItem_fileinfo_filter(ConfigItem& parent, LPWSTR szName, DWORD dwIndex);
55+
static HRESULT ConfigItem_fileinfo_filter(ConfigItem& parent, LPCWSTR szName, DWORD dwIndex);
5656
static HRESULT ConfigItem_fileinfo_add_filter(ConfigItem& parent, DWORD dwIndex);
5757
static HRESULT ConfigItem_fileinfo_omit_filter(ConfigItem& parent, DWORD dwIndex);
5858
static HRESULT ConfigItem_fileinfo_column(ConfigItem& parent, DWORD dwIndex);

src/OrcCommand/Text/Fmt/WolfPriority.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct fmt::formatter<Orc::Command::Wolf::Main::WolfPriority> : public fmt::form
2222
auto format(const Orc::Command::Wolf::Main::WolfPriority& priority, FormatContext& ctx) -> decltype(ctx.out())
2323
{
2424
std::error_code ec;
25-
const auto utf8 = Orc::ToUtf8(Orc::Command::Wolf::WolfLauncher::ToString(priority), ec);
25+
const auto utf8 = Orc::ToUtf8(Orc::Command::Wolf::Main::ToString(priority), ec);
2626
if (ec)
2727
{
2828
return formatter<std::string_view>::format(Orc::kFailedConversion, ctx);

src/OrcLib/Archive.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
namespace fs = std::filesystem;
2020
using namespace Orc;
2121

22-
Orc::ArchiveFormat OrcArchive::GetArchiveFormat(const std::wstring_view& filepath)
22+
Orc::ArchiveFormat OrcArchive::GetArchiveFormat(std::wstring_view filepath)
2323
{
2424
auto path = fs::path(std::wstring(filepath));
2525

src/OrcLib/Archive.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class OrcArchive
104104

105105
const ArchiveItem& operator[](const std::wstring& aCabbedName);
106106

107-
static ArchiveFormat GetArchiveFormat(const std::wstring_view& filepath);
107+
static ArchiveFormat GetArchiveFormat(std::wstring_view filepath);
108108
static std::wstring_view GetArchiveFormatString(const ArchiveFormat format);
109109

110110
HRESULT SetCallback(ArchiveCallback aCallback);

src/OrcLib/Archive/7z/Archive7z.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace {
3131
// Call '::Lib7z::Instance()' to initialize the singleton
3232
class Lib7z
3333
{
34-
Lib7z::Lib7z(const Lib7z&) = delete;
35-
Lib7z& Lib7z::operator=(const Lib7z&) = delete;
34+
Lib7z(const Lib7z&) = delete;
35+
Lib7z& operator=(const Lib7z&) = delete;
3636

37-
Lib7z::Lib7z()
37+
Lib7z()
3838
{
3939
::lib7zCrcTableInit();
4040
NArchive::N7z::Register();

src/OrcLib/Authenticode.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1697,11 +1697,12 @@ Orc::Result<void> Authenticode::VerifySignatureWithCatalogHint(
16971697
L"%WINDIR%\\system32\\CatRoot\\{{F750E6C3-38EE-11D1-85E5-00C04FC295EE}}\\{}"sv,
16981698
L"%WINDIR%\\system32\\CatRoot\\{}"sv};
16991699

1700-
auto& cache = data.AuthenticodeCache();
1701-
for (auto& catroot : catrootDirectories)
1700+
for (auto catroot : catrootDirectories)
17021701
{
17031702
std::error_code ec;
1704-
auto catalogPath = ExpandEnvironmentStringsApi(fmt::format(catroot.data(), *filename).c_str(), ec);
1703+
std::wstring path;
1704+
fmt::format_to(std::back_inserter(path), catroot, filename.value());
1705+
auto catalogPath = ExpandEnvironmentStringsApi(path.c_str(), ec);
17051706
if (ec)
17061707
{
17071708
return ec;

src/OrcLib/AutoRuns.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "MemoryStream.h"
1919

2020
#include "AutoRuns.h"
21+
#include "Configuration/ConfigItem.h"
2122

2223
#include "Log/Log.h"
2324

src/OrcLib/BoundTableRecord.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ HRESULT BoundColumn::PrintToBuffer(const CHAR* szFormat, va_list argList)
167167
return S_OK;
168168
}
169169

170-
HRESULT Orc::TableOutput::BoundColumn::WriteString(const std::wstring_view& svString)
170+
HRESULT Orc::TableOutput::BoundColumn::WriteString(std::wstring_view svString)
171171
{
172172
using namespace msl::utilities;
173173
HRESULT hr = E_FAIL;
@@ -203,7 +203,7 @@ HRESULT Orc::TableOutput::BoundColumn::WriteString(const std::wstring_view& svSt
203203
return S_OK;
204204
}
205205

206-
HRESULT Orc::TableOutput::BoundColumn::WriteString(const std::string_view& svString)
206+
HRESULT Orc::TableOutput::BoundColumn::WriteString(std::string_view svString)
207207
{
208208
using namespace msl::utilities;
209209

@@ -239,7 +239,7 @@ HRESULT Orc::TableOutput::BoundColumn::WriteString(const std::string_view& svStr
239239
return S_OK;
240240
}
241241

242-
HRESULT Orc::TableOutput::BoundColumn::WriteFormated(const std::wstring_view& szFormat, fmt::wformat_args args)
242+
HRESULT Orc::TableOutput::BoundColumn::WriteFormated(std::wstring_view szFormat, fmt::wformat_args args)
243243
{
244244
HRESULT hr = E_FAIL;
245245

@@ -281,7 +281,7 @@ HRESULT Orc::TableOutput::BoundColumn::WriteFormated(const std::wstring_view& sz
281281
return S_OK;
282282
}
283283

284-
HRESULT Orc::TableOutput::BoundColumn::WriteFormated(const std::string_view& szFormat, fmt::format_args args)
284+
HRESULT Orc::TableOutput::BoundColumn::WriteFormated(std::string_view szFormat, fmt::format_args args)
285285
{
286286
HRESULT hr = E_FAIL;
287287

0 commit comments

Comments
 (0)