Skip to content

Refactor OrbisFiber to match PS4 layout and obfuscation#3955

Open
w1naenator wants to merge 16 commits intoshadps4-emu:mainfrom
w1naenator:gr2fix
Open

Refactor OrbisFiber to match PS4 layout and obfuscation#3955
w1naenator wants to merge 16 commits intoshadps4-emu:mainfrom
w1naenator:gr2fix

Conversation

@w1naenator
Copy link
Contributor

  • Redesign OrbisFiber struct to match PS4's internal layout, including new fields, padding, and explicit size/alignment checks.
  • Store entry, arg_on_initialize, and name in obfuscated (XORed) form; add helper functions for encoding/decoding.
  • Replace plain name string with XORed byte array and per-fiber randomization.
  • Add random_pad field, filled with pseudo-random data on init.
  • Use atomic helpers for fiber state transitions instead of direct atomic access.
  • Update all code to use new accessors for obfuscated fields.
  • Improve stack overflow and context size margin checks.
  • Zero-initialize OrbisFiberOptParam in its initializer.
  • Add and includes for new memory operations.
  • Miscellaneous bug fixes and code cleanup.

w1naenator and others added 2 commits January 24, 2026 20:26
- Redesign OrbisFiber struct to match PS4's internal layout, including new fields, padding, and explicit size/alignment checks.
- Store entry, arg_on_initialize, and name in obfuscated (XORed) form; add helper functions for encoding/decoding.
- Replace plain name string with XORed byte array and per-fiber randomization.
- Add random_pad field, filled with pseudo-random data on init.
- Use atomic helpers for fiber state transitions instead of direct atomic access.
- Update all code to use new accessors for obfuscated fields.
- Improve stack overflow and context size margin checks.
- Zero-initialize OrbisFiberOptParam in its initializer.
- Add <cstring> and <cstddef> includes for new memory operations.
- Miscellaneous bug fixes and code cleanup.
@w1naenator
Copy link
Contributor Author

w1naenator commented Jan 24, 2026

This fixes the emulator crashing in Gravity Rush 2 on Windows, which I used to test the font library. Together with the fontlib branch in HLE mode, the font is now visible. I am not sure whether this is usable in the project, but you can test it.

w1naenator added 3 commits January 26, 2026 03:40
- Added Ulobjmgr support in logging and fiber management, including new functions for registration and unregistration.
- Updated fiber context structure to include ASan (AddressSanitizer) support and improved stack handling.
- Enhanced fiber switching logic to accommodate ASan and Razor CPU features.
- Introduced logging for Ulobjmgr function calls to aid in debugging.
- Modified memory and pthread headers to include necessary function declarations for ASan and thread management.
- Improved error handling and logging throughout the fiber management code.
@w1naenator
Copy link
Contributor Author

Actually, after rewriting the fiber library, I found that the TLS hygiene (ClearStack<12_KB>()) causes a stack overflow on Windows in the fiber library. Please check this; I think the structs should better match the ABI.

@tochnonechelovek
Copy link

No changes in my titles.

@wuguo13842

This comment was marked as abuse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants