Support hardware breakpoints

This commit is contained in:
momo5502
2025-02-04 18:31:29 +01:00
parent d8002edf42
commit f2c5df5139
3 changed files with 17 additions and 8 deletions

2
deps/unicorn vendored

View File

@@ -7,14 +7,15 @@ using NTSTATUS = std::uint32_t;
#ifndef OS_WINDOWS
#define STATUS_WAIT_0 ((NTSTATUS)0x00000000L)
#define STATUS_TIMEOUT ((NTSTATUS)0x00000102L)
#define STATUS_PENDING ((NTSTATUS)0x00000103L)
#define STATUS_SINGLE_STEP ((NTSTATUS)0x80000004L)
#define STATUS_ACCESS_VIOLATION ((NTSTATUS)0xC0000005L)
#define STATUS_INVALID_HANDLE ((NTSTATUS)0xC0000008L)
#define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL)
#define STATUS_ILLEGAL_INSTRUCTION ((NTSTATUS)0xC000001DL)
#define STATUS_INTEGER_DIVIDE_BY_ZERO ((NTSTATUS)0xC0000094L)
#define STATUS_PENDING ((NTSTATUS)0x00000103L)
#endif
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)

View File

@@ -505,6 +505,11 @@ namespace
dispatch_exception(emu, proc, STATUS_INTEGER_DIVIDE_BY_ZERO, {});
}
void dispatch_single_step(x64_emulator& emu, const process_context& proc)
{
dispatch_exception(emu, proc, STATUS_SINGLE_STEP, {});
}
void perform_context_switch_work(windows_emulator& win_emu)
{
auto& devices = win_emu.process().devices;
@@ -1033,16 +1038,19 @@ void windows_emulator::setup_hooks()
});
this->emu().hook_interrupt([&](const int interrupt) {
if (interrupt == 0)
switch (interrupt)
{
case 0:
dispatch_integer_division_by_zero(this->emu(), this->process());
return;
}
if (interrupt == 6)
{
case 1:
dispatch_single_step(this->emu(), this->process());
return;
case 6:
dispatch_illegal_instruction_violation(this->emu(), this->process());
return;
default:
break;
}
const auto rip = this->emu().read_instruction_pointer();