mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-10 16:16:16 +00:00
Fix more warnings
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
Checks: '-*,bugprone-*,cert-dcl21-cpp,cert-dcl50-cpp,cert-env33-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,cert-msc50-cpp,cert-msc51-cpp,cppcoreguidelines-*,-cppcoreguidelines-macro-usage,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,google-build-using-namespace,google-explicit-constructor,google-global-names-in-headers,google-readability-casting,google-runtime-int,google-runtime-operator,hicpp-*,-hicpp-vararg,misc-*,modernize-*,performance-*,readability-*,-readability-named-parameter,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-named-parameter,-cppcoreguidelines-avoid-goto,-cppcoreguidelines-avoid-non-const-global-variables,-hicpp-avoid-goto,-cppcoreguidelines-owning-memory,-readability-uppercase-literal-suffix,-readability-implicit-bool-conversion,-hicpp-no-array-decay,-hicpp-no-malloc,-readability-use-anyofallof,-cppcoreguidelines-prefer-member-initializer,-performance-no-int-to-ptr,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters, -bugprone-implicit-widening-of-multiplication-result,-google-explicit-constructor,-bugprone-exception-escape,-hicpp-exception-baseclass,-cppcoreguidelines-prefer-member-initializer,-bugprone-macro-parentheses,-bugprone-suspicious-missing-comma,-bugprone-sizeof-expression,-bugprone-throw-keyword-missing,-cppcoreguidelines-no-malloc,-bugprone-branch-clone,-cppcoreguidelines-pro-bounds-constant-array-index,-hicpp-explicit-conversions,-cppcoreguidelines-pro-type-member-init,-hicpp-member-init,-bugprone-lambda-function-name,-readability-function-cognitive-complexity,-misc-no-recursion,-misc-throw-by-value-catch-by-reference,-readability-simplify-boolean-expr,-readability-identifier-length,-readability-container-data-pointer,-cppcoreguidelines-virtual-class-destructor,-misc-non-private-member-variables-in-classes,-modernize-use-default-member-init,-google-readability-casting,-bugprone-suspicious-memory-comparison,-modernize-use-nodiscard,-modernize-concat-nested-namespaces,-cppcoreguidelines-avoid-do-while,-modernize-macro-to-enum,-misc-const-correctness,-cppcoreguidelines-avoid-const-or-ref-data-members,-misc-use-anonymous-namespace,-misc-misplaced-const,-readability-redundant-member-init,-cppcoreguidelines-macro-to-enum,-misc-include-cleaner,-performance-enum-size,-bugprone-empty-catch,-readability-duplicate-include,-readability-avoid-unconditional-preprocessor-if,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-missing-std-forward,-bugprone-casting-through-void,-cppcoreguidelines-non-private-member-variables-in-classes'
|
Checks: '-*,bugprone-*,cert-dcl21-cpp,cert-dcl50-cpp,cert-env33-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,cert-msc50-cpp,cert-msc51-cpp,cppcoreguidelines-*,-cppcoreguidelines-macro-usage,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-union-access,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,google-build-using-namespace,google-explicit-constructor,google-global-names-in-headers,google-readability-casting,google-runtime-int,google-runtime-operator,hicpp-*,-hicpp-vararg,misc-*,modernize-*,performance-*,readability-*,-readability-named-parameter,-modernize-use-trailing-return-type,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-hicpp-signed-bitwise,-hicpp-uppercase-literal-suffix,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-named-parameter,-cppcoreguidelines-avoid-goto,-cppcoreguidelines-avoid-non-const-global-variables,-hicpp-avoid-goto,-cppcoreguidelines-owning-memory,-readability-uppercase-literal-suffix,-readability-implicit-bool-conversion,-hicpp-no-array-decay,-hicpp-no-malloc,-readability-use-anyofallof,-cppcoreguidelines-prefer-member-initializer,-performance-no-int-to-ptr,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,-bugprone-reserved-identifier,-bugprone-easily-swappable-parameters, -bugprone-implicit-widening-of-multiplication-result,-google-explicit-constructor,-bugprone-exception-escape,-hicpp-exception-baseclass,-cppcoreguidelines-prefer-member-initializer,-bugprone-macro-parentheses,-bugprone-suspicious-missing-comma,-bugprone-sizeof-expression,-bugprone-throw-keyword-missing,-cppcoreguidelines-no-malloc,-bugprone-branch-clone,-cppcoreguidelines-pro-bounds-constant-array-index,-hicpp-explicit-conversions,-cppcoreguidelines-pro-type-member-init,-hicpp-member-init,-bugprone-lambda-function-name,-readability-function-cognitive-complexity,-misc-no-recursion,-misc-throw-by-value-catch-by-reference,-readability-simplify-boolean-expr,-readability-identifier-length,-readability-container-data-pointer,-cppcoreguidelines-virtual-class-destructor,-misc-non-private-member-variables-in-classes,-modernize-use-default-member-init,-google-readability-casting,-bugprone-suspicious-memory-comparison,-modernize-use-nodiscard,-modernize-concat-nested-namespaces,-cppcoreguidelines-avoid-do-while,-modernize-macro-to-enum,-misc-const-correctness,-cppcoreguidelines-avoid-const-or-ref-data-members,-misc-use-anonymous-namespace,-misc-misplaced-const,-readability-redundant-member-init,-cppcoreguidelines-macro-to-enum,-misc-include-cleaner,-performance-enum-size,-bugprone-empty-catch,-readability-duplicate-include,-readability-avoid-unconditional-preprocessor-if,-cppcoreguidelines-rvalue-reference-param-not-moved,-cppcoreguidelines-missing-std-forward,-bugprone-casting-through-void,-cppcoreguidelines-non-private-member-variables-in-classes,-bugprone-multi-level-implicit-pointer-conversion,-bugprone-unchecked-optional-access'
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- key: bugprone-argument-comment.StrictMode
|
- key: bugprone-argument-comment.StrictMode
|
||||||
value: 1
|
value: 1
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ namespace
|
|||||||
static uint64_t count{0};
|
static uint64_t count{0};
|
||||||
++count;
|
++count;
|
||||||
if (count > 100 && count % 10000 != 0)
|
if (count > 100 && count % 10000 != 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
win_emu.log.print(color::green,
|
win_emu.log.print(color::green,
|
||||||
@@ -184,7 +186,9 @@ namespace
|
|||||||
static uint64_t count{0};
|
static uint64_t count{0};
|
||||||
++count;
|
++count;
|
||||||
if (count > 100 && count % 10000 != 0)
|
if (count > 100 && count % 10000 != 0)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
win_emu.log.print(color::blue, "Writing to executable section %s at 0x%" PRIx64 " via 0x%" PRIx64 "\n",
|
win_emu.log.print(color::blue, "Writing to executable section %s at 0x%" PRIx64 " via 0x%" PRIx64 "\n",
|
||||||
|
|||||||
@@ -27,4 +27,5 @@
|
|||||||
|
|
||||||
#include <platform/platform.hpp>
|
#include <platform/platform.hpp>
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(google-global-names-in-headers)
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|||||||
@@ -27,4 +27,5 @@
|
|||||||
|
|
||||||
#include <platform/platform.hpp>
|
#include <platform/platform.hpp>
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(google-global-names-in-headers)
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ std::optional<registry_key> registry_manager::get_key(const utils::path_key& key
|
|||||||
return {std::move(reg_key)};
|
return {std::move(reg_key)};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto entry = iterator->second->get_sub_key(reg_key.path.get());
|
const auto* entry = iterator->second->get_sub_key(reg_key.path.get());
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
@@ -124,7 +124,7 @@ std::optional<registry_value> registry_manager::get_value(const registry_key& ke
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* entry = iterator->second->get_value(key.path.get(), name);
|
const auto* entry = iterator->second->get_value(key.path.get(), name);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ namespace
|
|||||||
NTSTATUS handle_NtSetEvent(const syscall_context& c, const uint64_t handle,
|
NTSTATUS handle_NtSetEvent(const syscall_context& c, const uint64_t handle,
|
||||||
const emulator_object<LONG> previous_state)
|
const emulator_object<LONG> previous_state)
|
||||||
{
|
{
|
||||||
const auto entry = c.proc.events.get(handle);
|
auto* entry = c.proc.events.get(handle);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_HANDLE;
|
return STATUS_INVALID_HANDLE;
|
||||||
@@ -427,7 +427,7 @@ namespace
|
|||||||
|
|
||||||
if (h.value.type == handle_types::thread)
|
if (h.value.type == handle_types::thread)
|
||||||
{
|
{
|
||||||
const auto t = c.proc.threads.get(h);
|
const auto* t = c.proc.threads.get(h);
|
||||||
if (t == c.proc.active_thread && t->ref_count == 1)
|
if (t == c.proc.active_thread && t->ref_count == 1)
|
||||||
{
|
{
|
||||||
// TODO: Better handle ref counting
|
// TODO: Better handle ref counting
|
||||||
@@ -750,7 +750,7 @@ namespace
|
|||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto section_entry = c.proc.sections.get(section_handle);
|
auto* section_entry = c.proc.sections.get(section_handle);
|
||||||
if (!section_entry)
|
if (!section_entry)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_HANDLE;
|
return STATUS_INVALID_HANDLE;
|
||||||
@@ -758,7 +758,7 @@ namespace
|
|||||||
|
|
||||||
if (section_entry->is_image())
|
if (section_entry->is_image())
|
||||||
{
|
{
|
||||||
const auto binary = c.win_emu.mod_manager.map_module(section_entry->file_name, c.win_emu.log);
|
const auto* binary = c.win_emu.mod_manager.map_module(section_entry->file_name, c.win_emu.log);
|
||||||
if (!binary)
|
if (!binary)
|
||||||
{
|
{
|
||||||
return STATUS_FILE_INVALID;
|
return STATUS_FILE_INVALID;
|
||||||
@@ -855,14 +855,14 @@ namespace
|
|||||||
const auto region_info = c.win_emu.memory.get_region_info(base_address);
|
const auto region_info = c.win_emu.memory.get_region_info(base_address);
|
||||||
|
|
||||||
assert(!region_info.is_committed || region_info.is_reserved);
|
assert(!region_info.is_committed || region_info.is_reserved);
|
||||||
|
const auto state = region_info.is_reserved ? MEM_RESERVE : MEM_FREE;
|
||||||
|
image_info.State = region_info.is_committed ? MEM_COMMIT : state;
|
||||||
image_info.BaseAddress = reinterpret_cast<void*>(region_info.start);
|
image_info.BaseAddress = reinterpret_cast<void*>(region_info.start);
|
||||||
image_info.AllocationBase = reinterpret_cast<void*>(region_info.allocation_base);
|
image_info.AllocationBase = reinterpret_cast<void*>(region_info.allocation_base);
|
||||||
image_info.AllocationProtect = 0;
|
image_info.AllocationProtect = 0;
|
||||||
image_info.PartitionId = 0;
|
image_info.PartitionId = 0;
|
||||||
image_info.RegionSize = static_cast<int64_t>(region_info.length);
|
image_info.RegionSize = static_cast<int64_t>(region_info.length);
|
||||||
image_info.State =
|
|
||||||
region_info.is_committed ? MEM_COMMIT : (region_info.is_reserved ? MEM_RESERVE : MEM_FREE);
|
|
||||||
image_info.Protect = map_emulator_to_nt_protection(region_info.permissions);
|
image_info.Protect = map_emulator_to_nt_protection(region_info.permissions);
|
||||||
image_info.Type = MEM_PRIVATE;
|
image_info.Type = MEM_PRIVATE;
|
||||||
});
|
});
|
||||||
@@ -882,7 +882,7 @@ namespace
|
|||||||
return STATUS_BUFFER_OVERFLOW;
|
return STATUS_BUFFER_OVERFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto mod = c.win_emu.mod_manager.find_by_address(base_address);
|
const auto* mod = c.win_emu.mod_manager.find_by_address(base_address);
|
||||||
if (!mod)
|
if (!mod)
|
||||||
{
|
{
|
||||||
c.win_emu.log.error("Bad address for memory image request: 0x%" PRIx64 "\n", base_address);
|
c.win_emu.log.error("Bad address for memory image request: 0x%" PRIx64 "\n", base_address);
|
||||||
@@ -893,7 +893,7 @@ namespace
|
|||||||
|
|
||||||
info.access([&](MEMORY_IMAGE_INFORMATION64& image_info) {
|
info.access([&](MEMORY_IMAGE_INFORMATION64& image_info) {
|
||||||
image_info.ImageBase = reinterpret_cast<void*>(mod->image_base);
|
image_info.ImageBase = reinterpret_cast<void*>(mod->image_base);
|
||||||
image_info.SizeOfImage = mod->size_of_image;
|
image_info.SizeOfImage = static_cast<int64_t>(mod->size_of_image);
|
||||||
image_info.ImageFlags = 0;
|
image_info.ImageFlags = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1998,11 +1998,11 @@ namespace
|
|||||||
thread_iterator->second.teb->access([&](TEB64& teb) {
|
thread_iterator->second.teb->access([&](TEB64& teb) {
|
||||||
entry.ThreadId = teb.ClientId.UniqueThread;
|
entry.ThreadId = teb.ClientId.UniqueThread;
|
||||||
|
|
||||||
const auto tls_vector = teb.ThreadLocalStoragePointer;
|
auto* tls_vector = teb.ThreadLocalStoragePointer;
|
||||||
|
|
||||||
if (tls_info.TlsRequest == ProcessTlsReplaceIndex)
|
if (tls_info.TlsRequest == ProcessTlsReplaceIndex)
|
||||||
{
|
{
|
||||||
const auto tls_entry_ptr = tls_vector + tls_info.TlsIndex;
|
auto* tls_entry_ptr = tls_vector + tls_info.TlsIndex;
|
||||||
|
|
||||||
const auto old_entry = c.emu.read_memory<EmulatorTraits<Emu64>::PVOID>(tls_entry_ptr);
|
const auto old_entry = c.emu.read_memory<EmulatorTraits<Emu64>::PVOID>(tls_entry_ptr);
|
||||||
c.emu.write_memory<EmulatorTraits<Emu64>::PVOID>(tls_entry_ptr, entry.TlsModulePointer);
|
c.emu.write_memory<EmulatorTraits<Emu64>::PVOID>(tls_entry_ptr, entry.TlsModulePointer);
|
||||||
@@ -2011,11 +2011,11 @@ namespace
|
|||||||
}
|
}
|
||||||
else if (tls_info.TlsRequest == ProcessTlsReplaceVector)
|
else if (tls_info.TlsRequest == ProcessTlsReplaceVector)
|
||||||
{
|
{
|
||||||
const auto new_tls_vector = entry.TlsVector;
|
auto* new_tls_vector = entry.TlsVector;
|
||||||
|
|
||||||
for (uint32_t index = 0; index < tls_info.TlsVectorLength; ++index)
|
for (uint32_t index = 0; index < tls_info.TlsVectorLength; ++index)
|
||||||
{
|
{
|
||||||
const auto old_entry = c.emu.read_memory<void*>(tls_vector + index);
|
auto* old_entry = c.emu.read_memory<void*>(tls_vector + index);
|
||||||
c.emu.write_memory<void*>(new_tls_vector + index, old_entry);
|
c.emu.write_memory<void*>(new_tls_vector + index, old_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2270,7 +2270,7 @@ namespace
|
|||||||
const auto attributes = object_attributes.read();
|
const auto attributes = object_attributes.read();
|
||||||
if (attributes.ObjectName)
|
if (attributes.ObjectName)
|
||||||
{
|
{
|
||||||
const auto name = read_unicode_string(
|
auto name = read_unicode_string(
|
||||||
c.emu, reinterpret_cast<UNICODE_STRING<EmulatorTraits<Emu64>>*>(attributes.ObjectName));
|
c.emu, reinterpret_cast<UNICODE_STRING<EmulatorTraits<Emu64>>*>(attributes.ObjectName));
|
||||||
c.win_emu.log.print(color::dark_gray, "--> Section with name %s\n", u16_to_u8(name).c_str());
|
c.win_emu.log.print(color::dark_gray, "--> Section with name %s\n", u16_to_u8(name).c_str());
|
||||||
s.name = std::move(name);
|
s.name = std::move(name);
|
||||||
@@ -2510,6 +2510,7 @@ namespace
|
|||||||
return STATUS_NOT_SUPPORTED;
|
return STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||||
const uint8_t sid[] = {
|
const uint8_t sid[] = {
|
||||||
0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0x84, 0x94,
|
0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x15, 0x00, 0x00, 0x00, 0x84, 0x94,
|
||||||
0xD4, 0x04, 0x4B, 0x68, 0x42, 0x34, 0x23, 0xBE, 0x69, 0x4E, 0xE9, 0x03, 0x00, 0x00,
|
0xD4, 0x04, 0x4B, 0x68, 0x42, 0x34, 0x23, 0xBE, 0x69, 0x4E, 0xE9, 0x03, 0x00, 0x00,
|
||||||
@@ -3229,7 +3230,7 @@ namespace
|
|||||||
return STATUS_NOT_SUPPORTED;
|
return STATUS_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto file = c.proc.files.get(handle);
|
const auto* file = c.proc.files.get(handle);
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_HANDLE;
|
return STATUS_INVALID_HANDLE;
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ void windows_emulator::perform_thread_switch()
|
|||||||
|
|
||||||
bool windows_emulator::activate_thread(const uint32_t id)
|
bool windows_emulator::activate_thread(const uint32_t id)
|
||||||
{
|
{
|
||||||
const auto thread = get_thread_by_id(this->process, id);
|
auto* thread = get_thread_by_id(this->process, id);
|
||||||
if (!thread)
|
if (!thread)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -576,6 +576,7 @@ void windows_emulator::deserialize(utils::buffer_deserializer& buffer)
|
|||||||
this->dispatcher.deserialize(buffer);
|
this->dispatcher.deserialize(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
|
||||||
void windows_emulator::save_snapshot()
|
void windows_emulator::save_snapshot()
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Not supported");
|
throw std::runtime_error("Not supported");
|
||||||
@@ -591,6 +592,7 @@ void windows_emulator::save_snapshot()
|
|||||||
// this->process_snapshot_ = this->process;*/
|
// this->process_snapshot_ = this->process;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(readability-convert-member-functions-to-static)
|
||||||
void windows_emulator::restore_snapshot()
|
void windows_emulator::restore_snapshot()
|
||||||
{
|
{
|
||||||
throw std::runtime_error("Not supported");
|
throw std::runtime_error("Not supported");
|
||||||
|
|||||||
Reference in New Issue
Block a user