mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 12:34:45 +00:00
Fixup signal context functions
This commit is contained in:
parent
75ce77468b
commit
7037924a3a
2 changed files with 12 additions and 10 deletions
|
@ -54,20 +54,22 @@ void* GetXmmPointer(void* ctx, u8 index) {
|
|||
|
||||
void* GetRip(void* ctx) {
|
||||
#if defined(_WIN32)
|
||||
return &((EXCEPTION_POINTERS*)ctx)->ContextRecord->Rip;
|
||||
return (void*)((EXCEPTION_POINTERS*)ctx)->ContextRecord->Rip;
|
||||
#elif defined(__APPLE__)
|
||||
return &((ucontext_t*)ctx)->uc_mcontext->__ss.__rip;
|
||||
return (void*)((ucontext_t*)ctx)->uc_mcontext->__ss.__rip;
|
||||
#else
|
||||
return &((ucontext_t*)ctx)->uc_mcontext.gregs[REG_RIP];
|
||||
return (void*)((ucontext_t*)ctx)->uc_mcontext.gregs[REG_RIP];
|
||||
#endif
|
||||
}
|
||||
|
||||
void IncrementRip(void* ctx, u64 length) {
|
||||
void* rip = GetRip(ctx);
|
||||
u64 new_rip;
|
||||
memcpy(&new_rip, rip, sizeof(u64));
|
||||
new_rip += length;
|
||||
memcpy(rip, &new_rip, sizeof(u64));
|
||||
#if defined(_WIN32)
|
||||
((EXCEPTION_POINTERS*)ctx)->ContextRecord->Rip += length;
|
||||
#elif defined(__APPLE__)
|
||||
((ucontext_t*)ctx)->uc_mcontext->__ss.__rip += length;
|
||||
#else
|
||||
((ucontext_t*)ctx)->uc_mcontext.gregs[REG_RIP] += length;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsWriteError(void* ctx) {
|
||||
|
|
|
@ -153,9 +153,9 @@ struct PageManager::Impl {
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool GuestFaultSignalHandler(void* code_address, void* fault_address) {
|
||||
static bool GuestFaultSignalHandler(void* context, void* fault_address) {
|
||||
const auto addr = reinterpret_cast<VAddr>(fault_address);
|
||||
const bool is_write = Common::IsWriteError(code_address);
|
||||
const bool is_write = Common::IsWriteError(context);
|
||||
if (is_write && owned_ranges.find(addr) != owned_ranges.end()) {
|
||||
const VAddr addr_aligned = Common::AlignDown(addr, PAGESIZE);
|
||||
rasterizer->InvalidateMemory(addr_aligned, PAGESIZE);
|
||||
|
|
Loading…
Add table
Reference in a new issue