mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-11 16:46:16 +00:00
Fix more clang tidy warnings
This commit is contained in:
@@ -44,7 +44,10 @@ namespace apiset
|
||||
{
|
||||
auto buffer = utils::compression::zlib::decompress(apiset);
|
||||
if (buffer.empty())
|
||||
{
|
||||
throw std::runtime_error("Failed to decompress API-SET");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -66,7 +69,10 @@ namespace apiset
|
||||
case location::file: {
|
||||
const auto apiset = utils::io::read_file(root / "api-set.bin");
|
||||
if (apiset.empty())
|
||||
{
|
||||
throw std::runtime_error("Failed to read file api-set.bin");
|
||||
}
|
||||
|
||||
return decompress_apiset(apiset);
|
||||
}
|
||||
case location::default_windows_10: {
|
||||
@@ -123,9 +129,9 @@ namespace apiset
|
||||
api_set.HashOffset = static_cast<ULONG>(hash_entries_obj.value() - api_set_map_obj.value());
|
||||
});
|
||||
|
||||
const auto orig_ns_entries =
|
||||
const auto* orig_ns_entries =
|
||||
offset_pointer<API_SET_NAMESPACE_ENTRY>(&orig_api_set_map, orig_api_set_map.EntryOffset);
|
||||
const auto orig_hash_entries =
|
||||
const auto* orig_hash_entries =
|
||||
offset_pointer<API_SET_HASH_ENTRY>(&orig_api_set_map, orig_api_set_map.HashOffset);
|
||||
|
||||
for (ULONG i = 0; i < orig_api_set_map.Count; ++i)
|
||||
@@ -142,7 +148,7 @@ namespace apiset
|
||||
}
|
||||
|
||||
const auto values_obj = allocator.reserve<API_SET_VALUE_ENTRY>(ns_entry.ValueCount);
|
||||
const auto orig_values = offset_pointer<API_SET_VALUE_ENTRY>(&orig_api_set_map, ns_entry.ValueOffset);
|
||||
const auto* orig_values = offset_pointer<API_SET_VALUE_ENTRY>(&orig_api_set_map, ns_entry.ValueOffset);
|
||||
|
||||
ns_entry.ValueOffset = static_cast<ULONG>(values_obj.value() - api_set_map_obj.value());
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace cpu_context
|
||||
}
|
||||
}
|
||||
|
||||
if ((context.ContextFlags & CONTEXT_XSTATE_64) == CONTEXT_INTEGER_64)
|
||||
if ((context.ContextFlags & CONTEXT_INTEGER_64) == CONTEXT_INTEGER_64)
|
||||
{
|
||||
context.MxCsr = emu.reg<uint32_t>(x64_register::mxcsr);
|
||||
for (int i = 0; i < 16; i++)
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
struct afd_creation_data
|
||||
{
|
||||
uint64_t unk1;
|
||||
@@ -45,6 +47,8 @@ namespace
|
||||
uint32_t sin6_scope_id;
|
||||
};
|
||||
|
||||
// NOLINTEND(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
|
||||
static_assert(sizeof(win_sockaddr) == 16);
|
||||
static_assert(sizeof(win_sockaddr_in) == 16);
|
||||
static_assert(sizeof(win_sockaddr_in6) == 28);
|
||||
@@ -77,7 +81,7 @@ namespace
|
||||
|
||||
int16_t translate_host_to_win_address_family(const int host_af)
|
||||
{
|
||||
for (auto& entry : address_family_map)
|
||||
for (const auto& entry : address_family_map)
|
||||
{
|
||||
if (entry.second == host_af)
|
||||
{
|
||||
@@ -130,7 +134,7 @@ namespace
|
||||
win_addr.sin_port = htons(win_emu.get_emulator_port(a.get_port()));
|
||||
memcpy(&win_addr.sin_addr, &a.get_in_addr().sin_addr, sizeof(win_addr.sin_addr));
|
||||
|
||||
const auto ptr = reinterpret_cast<std::byte*>(&win_addr);
|
||||
const auto* ptr = reinterpret_cast<std::byte*>(&win_addr);
|
||||
return {ptr, ptr + sizeof(win_addr)};
|
||||
}
|
||||
|
||||
@@ -140,12 +144,12 @@ namespace
|
||||
win_addr.sin6_family = translate_host_to_win_address_family(a.get_family());
|
||||
win_addr.sin6_port = htons(win_emu.get_emulator_port(a.get_port()));
|
||||
|
||||
auto& addr = a.get_in6_addr();
|
||||
const auto& addr = a.get_in6_addr();
|
||||
memcpy(&win_addr.sin6_addr, &addr.sin6_addr, sizeof(win_addr.sin6_addr));
|
||||
win_addr.sin6_flowinfo = addr.sin6_flowinfo;
|
||||
win_addr.sin6_scope_id = addr.sin6_scope_id;
|
||||
|
||||
const auto ptr = reinterpret_cast<std::byte*>(&win_addr);
|
||||
const auto* ptr = reinterpret_cast<std::byte*>(&win_addr);
|
||||
return {ptr, ptr + sizeof(win_addr)};
|
||||
}
|
||||
|
||||
@@ -241,7 +245,7 @@ namespace
|
||||
handle_info.emplace_back(handle_info_obj.read(i));
|
||||
}
|
||||
|
||||
return {std::move(poll_info), std::move(handle_info)};
|
||||
return {poll_info, std::move(handle_info)};
|
||||
}
|
||||
|
||||
int16_t map_afd_request_events_to_socket(const ULONG poll_events)
|
||||
@@ -317,7 +321,7 @@ namespace
|
||||
for (size_t i = 0; i < endpoints.size() && i < handles.size(); ++i)
|
||||
{
|
||||
auto& pfd = poll_data.at(i);
|
||||
auto& handle = handles[i];
|
||||
const auto& handle = handles[i];
|
||||
|
||||
pfd.fd = endpoints[i];
|
||||
pfd.events = map_afd_request_events_to_socket(handle.PollEvents);
|
||||
@@ -525,6 +529,11 @@ namespace
|
||||
|
||||
NTSTATUS ioctl_bind(windows_emulator& win_emu, const io_device_context& c) const
|
||||
{
|
||||
if (!this->s_)
|
||||
{
|
||||
throw std::runtime_error("Invalid AFD endpoint socket!");
|
||||
}
|
||||
|
||||
auto data = win_emu.emu().read_memory(c.input_buffer, c.input_buffer_length);
|
||||
|
||||
constexpr auto address_offset = 4;
|
||||
@@ -561,9 +570,9 @@ namespace
|
||||
}
|
||||
|
||||
const auto* endpoint = device->get_internal_device<afd_endpoint>();
|
||||
if (!endpoint)
|
||||
if (!endpoint || !endpoint->s_)
|
||||
{
|
||||
throw std::runtime_error("Device is not an AFD endpoint!");
|
||||
throw std::runtime_error("Invalid AFD endpoint!");
|
||||
}
|
||||
|
||||
endpoints.push_back(*endpoint->s_);
|
||||
@@ -604,6 +613,11 @@ namespace
|
||||
|
||||
NTSTATUS ioctl_receive_datagram(windows_emulator& win_emu, const io_device_context& c)
|
||||
{
|
||||
if (!this->s_)
|
||||
{
|
||||
throw std::runtime_error("Invalid AFD endpoint socket!");
|
||||
}
|
||||
|
||||
auto& emu = win_emu.emu();
|
||||
|
||||
if (c.input_buffer_length < sizeof(AFD_RECV_DATAGRAM_INFO<EmulatorTraits<Emu64>>))
|
||||
@@ -668,6 +682,11 @@ namespace
|
||||
|
||||
NTSTATUS ioctl_send_datagram(windows_emulator& win_emu, const io_device_context& c)
|
||||
{
|
||||
if (!this->s_)
|
||||
{
|
||||
throw std::runtime_error("Invalid AFD endpoint socket!");
|
||||
}
|
||||
|
||||
const auto& emu = win_emu.emu();
|
||||
|
||||
if (c.input_buffer_length < sizeof(AFD_SEND_DATAGRAM_INFO<EmulatorTraits<Emu64>>))
|
||||
|
||||
@@ -219,6 +219,11 @@ bool emulator_thread::is_thread_ready(process_context& process, utils::clock& cl
|
||||
|
||||
void emulator_thread::setup_registers(x64_emulator& emu, const process_context& context) const
|
||||
{
|
||||
if (!this->gs_segment)
|
||||
{
|
||||
throw std::runtime_error("Missing GS segment");
|
||||
}
|
||||
|
||||
setup_stack(emu, this->stack_base, this->stack_size);
|
||||
setup_gs_segment(emu, *this->gs_segment);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user