From 136ff118d478a0aaf4906f38b279df4e5efb1d56 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Tue, 24 Sep 2024 20:17:38 +0200 Subject: [PATCH] Fix warnings --- deps/mini-gdbstub | 2 +- src/bad-sample/bad.cpp | 8 +------ src/sample/main.cpp | 1 + src/unicorn-emulator/function_wrapper.hpp | 7 +++++- src/unicorn-emulator/unicorn.hpp | 11 ++++++++++ src/unicorn-emulator/unicorn_x64_emulator.cpp | 2 +- src/windows-emulator/syscalls.cpp | 22 ------------------- 7 files changed, 21 insertions(+), 32 deletions(-) diff --git a/deps/mini-gdbstub b/deps/mini-gdbstub index 4628d9d..25b60f5 160000 --- a/deps/mini-gdbstub +++ b/deps/mini-gdbstub @@ -1 +1 @@ -Subproject commit 4628d9dfd2af21d95fc0f64ea3982ea3fdf3f72e +Subproject commit 25b60f545bd9aa4ecdd392b7da959fff7237449b diff --git a/src/bad-sample/bad.cpp b/src/bad-sample/bad.cpp index 6633362..50aa364 100644 --- a/src/bad-sample/bad.cpp +++ b/src/bad-sample/bad.cpp @@ -4,8 +4,7 @@ #define THE_SIZE 30 -extern "C" __declspec(noinline) -__declspec(dllexport) +extern "C" __declspec(noinline) __declspec(dllexport) void vulnerable(const uint8_t* data, const size_t size) { if (size < 10) @@ -38,11 +37,6 @@ void vulnerable(const uint8_t* data, const size_t size) return; } - if (data[0] != 'H' || data[1] != 'u') - { - return; - } - if (size < 100) { return; diff --git a/src/sample/main.cpp b/src/sample/main.cpp index 435ad51..a651b49 100644 --- a/src/sample/main.cpp +++ b/src/sample/main.cpp @@ -66,6 +66,7 @@ namespace application, {} }; + (void)&watch_system_objects; //watch_system_objects(win_emu); win_emu.buffer_stdout = true; //win_emu.verbose_calls = true; diff --git a/src/unicorn-emulator/function_wrapper.hpp b/src/unicorn-emulator/function_wrapper.hpp index daa48a9..ec54311 100644 --- a/src/unicorn-emulator/function_wrapper.hpp +++ b/src/unicorn-emulator/function_wrapper.hpp @@ -18,7 +18,7 @@ class function_wrapper : public object { } - c_function_type* get_function() const + c_function_type* get_c_function() const { return +[](Args... args, user_data_pointer user_data) -> ReturnType { @@ -26,6 +26,11 @@ class function_wrapper : public object }; } + void* get_function() const + { + return reinterpret_cast(this->get_c_function()); + } + user_data_pointer get_user_data() const { return this->functor_.get(); diff --git a/src/unicorn-emulator/unicorn.hpp b/src/unicorn-emulator/unicorn.hpp index e82ab63..20ee619 100644 --- a/src/unicorn-emulator/unicorn.hpp +++ b/src/unicorn-emulator/unicorn.hpp @@ -2,8 +2,19 @@ #pragma warning(push) #pragma warning(disable: 4505) + +#ifdef __clang__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#endif + #define NOMINMAX #include + +#ifdef __clang__ +#pragma GCC diagnostic pop +#endif + #pragma warning(pop) #include diff --git a/src/unicorn-emulator/unicorn_x64_emulator.cpp b/src/unicorn-emulator/unicorn_x64_emulator.cpp index 693f1e2..db8ff3f 100644 --- a/src/unicorn-emulator/unicorn_x64_emulator.cpp +++ b/src/unicorn-emulator/unicorn_x64_emulator.cpp @@ -353,7 +353,7 @@ namespace unicorn }*/ emulator_hook* hook_instruction(int instruction_type, - instruction_hook_callback callback) + instruction_hook_callback callback) override { function_wrapper wrapper([c = std::move(callback)](uc_engine*) { diff --git a/src/windows-emulator/syscalls.cpp b/src/windows-emulator/syscalls.cpp index 9a98846..3feb337 100644 --- a/src/windows-emulator/syscalls.cpp +++ b/src/windows-emulator/syscalls.cpp @@ -92,28 +92,6 @@ namespace } } - uint64_t get_syscall_id(const std::vector& ntdll_syscalls, - const std::vector& win32u_syscalls, const std::string_view name) - { - for (size_t i = 0; i < ntdll_syscalls.size(); ++i) - { - if (ntdll_syscalls[i] == name) - { - return i; - } - } - - for (size_t i = 0; i < win32u_syscalls.size(); ++i) - { - if (win32u_syscalls[i] == name) - { - return i + 0x1000; - } - } - - throw std::runtime_error("Unable to determine syscall id: " + std::string(name)); - } - template requires(std::is_integral_v || std::is_enum_v) T resolve_argument(x64_emulator& emu, const size_t index)