mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[PR #3857] [MERGED] cpu_patches: Patch stack canary accesses #3765
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3765
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/3857
Author: @StevenMiller123
Created: 12/6/2025
Status: ✅ Merged
Merged: 12/7/2025
Merged by: @squidbus
Base:
main← Head:rdr2-test📝 Commits (5)
ac82d2cPatch stack checks done using fs:[0x28]d788310Merge branch 'shadps4-emu:main' into rdr2-testbd6a565Missing includeabf7256Disable patches for Apple74ecd69Oops📊 Changes
1 file changed (+90 additions, -55 deletions)
View changed files
📝
src/core/cpu_patches.cpp(+90 -55)📄 Description
Some compilers emit direct reads to the stack canary (fs:[0x28]) instead of using the stack check guard provided by libkernel. This is usually done by storing the canary to a register with a
movinstruction at the start of the function, then checking that register against the canary at the end of the function with axorinstruction.In this PR, I've added code patches to handle mov and xor instructions using fs:[0x28], stubbing the returned canary value with 0. Additionally, I've updated our code to support having multiple patches per instruction, since mov instructions also need Tcb access patches.
This PR brings Red Dead Redemption 2 to menus for Windows users. It now crashes when trying to go ingame, just like how Linux behaves.

This is my first time working with our cpu patches, let me know if I need to change anything. Additionally, if there is a better hardcoded value I should use for the stack canary, please let me know.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.