fix breakpoints on Wine

This commit is contained in:
m 2024-06-03 12:37:53 -05:00
parent 7a011437d7
commit 76d291edd7
2 changed files with 29 additions and 14 deletions

View File

@ -13,6 +13,10 @@
#include "breakpoints.hpp" #include "breakpoints.hpp"
#include "illegal_instructions.hpp" #include "illegal_instructions.hpp"
#ifdef DEBUG
//#define PATCH_BREAKPOINTS
#endif
#define PRECOMPUTED_INTEGRITY_CHECKS #define PRECOMPUTED_INTEGRITY_CHECKS
#define PRECOMPUTED_BREAKPOINTS #define PRECOMPUTED_BREAKPOINTS
#define PRECOMPUTED_ILLEGAL_INSTRUCTIONS #define PRECOMPUTED_ILLEGAL_INSTRUCTIONS
@ -473,6 +477,7 @@ namespace arxan
utils::hook::jump(game_address, stub, false); utils::hook::jump(game_address, stub, false);
} }
#ifdef PATCH_BREAKPOINTS
#ifdef PRECOMPUTED_BREAKPOINTS #ifdef PRECOMPUTED_BREAKPOINTS
void patch_breakpoints_precomputed() void patch_breakpoints_precomputed()
{ {
@ -632,6 +637,7 @@ namespace arxan
handle_handler[handle] = nullptr; handle_handler[handle] = nullptr;
return RemoveVectoredExceptionHandler(handle); return RemoveVectoredExceptionHandler(handle);
} }
#endif
} }
} }
using namespace anti_debug; using namespace anti_debug;
@ -645,14 +651,20 @@ namespace arxan
{ {
return set_thread_context_stub; return set_thread_context_stub;
} }
else if (function == "AddVectoredExceptionHandler")
#ifdef PATCH_BREAKPOINTS
if (!utils::nt::is_wine())
{ {
return exceptions::add_vectored_exception_handler_stub; if (function == "AddVectoredExceptionHandler")
} {
else if (function == "RemoveVectoredExceptionHandler") return exceptions::add_vectored_exception_handler_stub;
{ }
return exceptions::remove_vectored_exception_handler_stub; else if (function == "RemoveVectoredExceptionHandler")
{
return exceptions::remove_vectored_exception_handler_stub;
}
} }
#endif
return nullptr; return nullptr;
} }
@ -664,7 +676,10 @@ namespace arxan
remove_hardware_breakpoints(); remove_hardware_breakpoints();
hide_being_debugged(); hide_being_debugged();
scheduler::loop(hide_being_debugged, scheduler::pipeline::async); scheduler::loop(hide_being_debugged, scheduler::pipeline::async);
store_debug_functions(); if (!utils::nt::is_wine())
{
store_debug_functions();
}
const utils::nt::library ntdll("ntdll.dll"); const utils::nt::library ntdll("ntdll.dll");
nt_close_hook.create(ntdll.get_proc<void*>("NtClose"), nt_close_stub); nt_close_hook.create(ntdll.get_proc<void*>("NtClose"), nt_close_stub);
@ -682,7 +697,10 @@ namespace arxan
remove_hardware_breakpoints(); remove_hardware_breakpoints();
search_and_patch_integrity_checks(); search_and_patch_integrity_checks();
restore_debug_functions(); if (!utils::nt::is_wine())
{
restore_debug_functions();
}
} }
component_priority priority() override component_priority priority() override
@ -692,4 +710,4 @@ namespace arxan
}; };
} }
REGISTER_COMPONENT(arxan::component) REGISTER_COMPONENT(arxan::component)

View File

@ -67,12 +67,9 @@ namespace system_check
void verify_binary_version() void verify_binary_version()
{ {
const auto value = *reinterpret_cast<DWORD*>(0x1337_b); const auto value = *reinterpret_cast<DWORD*>(0x1337_b);
if (!utils::nt::is_wine()) if (!utils::nt::is_wine() && value != 0xB43C9275)
{ {
if (value != 0xB43C9275) throw std::runtime_error("Unsupported Call of Duty: Infinite Warfare version");
{
throw std::runtime_error("Unsupported Call of Duty: Infinite Warfare version");
}
} }
} }
} }