Windows CI fixes

- some weird function call business
- string formatting
- etc
This commit is contained in:
dr7ana 2023-10-26 09:20:49 -07:00
parent c46c18ea30
commit 98583b8f58
5 changed files with 35 additions and 5 deletions

View File

@ -275,7 +275,8 @@ namespace
(MINIDUMP_TYPE)(MiniDumpWithFullMemory | MiniDumpWithFullMemoryInfo | MiniDumpWithHandleData | MiniDumpWithUnloadedModules | MiniDumpWithThreadInfo);
const std::string fname =
"C:\\ProgramData\\lokinet\\crash-{}.dump"_format(llarp::time_now_ms().count());
fmt::format("C:\\ProgramData\\lokinet\\crash-{}.dump", llarp::time_now_ms().count());
HANDLE hDumpFile;
SYSTEMTIME stLocalTime;
GetLocalTime(&stLocalTime);

View File

@ -95,4 +95,22 @@ namespace llarp
ch = ch + ('a' - 'A');
return src;
}
std::wstring
to_wide(std::string data)
{
std::wstring buf;
buf.resize(data.size());
#ifdef _WIN32
// win32 specific codepath because balmer made windows so that man may suffer
if (MultiByteToWideChar(CP_UTF8, 0, data.c_str(), data.size(), buf.data(), buf.size()) == 0)
throw win32::error{GetLastError(), "failed to convert string to wide string"};
#else
// this dumb but probably works (i guess?)
std::transform(
data.begin(), data.end(), buf.begin(), [](const auto& ch) -> wchar_t { return ch; });
#endif
return buf;
}
} // namespace llarp

View File

@ -2,6 +2,7 @@
#include <fmt/format.h>
#include <algorithm>
#include <charconv>
#include <chrono>
#include <iterator>
@ -96,4 +97,9 @@ namespace llarp
std::string_view
TrimWhitespace(std::string_view str);
/// convert a "normal" string into a wide string
std::wstring
to_wide(std::string data);
} // namespace llarp

View File

@ -89,8 +89,10 @@ namespace llarp::win32
if (not range.Contains(ifaddr))
b = false;
}
// TODO: FIXME
if (b)
gateways.emplace(*iface.gateway);
throw std::runtime_error{"FIXME ALREADY"};
// gateways.emplace(*iface.gateway);
}
return {gateways.begin(), gateways.end()};
}

View File

@ -15,12 +15,15 @@ namespace llarp::win32
MakeDeterministicGUID(Data data)
{
ShortHash h{};
auto hash = [&h](auto data) { crypto::shorthash(h, data); };
auto hash = [&h](uint8_t* d, size_t size) { crypto::shorthash(h, d, size); };
if constexpr (std::is_same_v<Data, std::string>)
hash(llarp_buffer_t{reinterpret_cast<const byte_t*>(data.data()), data.size()});
hash(reinterpret_cast<uint8_t*>(data.data()), data.size());
else
hash(llarp_buffer_t{data});
{
auto dat = llarp_buffer_t{data};
hash(dat.base, dat.sz);
}
GUID guid{};
std::copy_n(
h.begin(), std::min(sizeof(GUID), sizeof(ShortHash)), reinterpret_cast<uint8_t*>(&guid));