Skip to content

[Feature Request]: Loading native shared libraries for patching, modding and debugging games #3997

@Dasaav-dsv

Description

@Dasaav-dsv

Checklist

  • I have searched for a similar issue in this repository and did not find one.

Description

ShadPS4 should be able to load native to the user's OS shared libraries (.dll/.so) from a list they provided when launching ShadPS4.

Reason

It would be very useful for executing custom code in the game's context by e.g. placing hooks or applying complex patches, where the existing ShadPS4 patch system does not cut it.

Not having to write assembly and having easy access to all native OS functionality (as opposed to loading a custom-built .prx).

An example of something I had to do to debug Bloodborne bugs was writing a heap allocation sanitizer tool that detects OOB writes with readonly pages:
https://github.com/Dasaav-dsv/bb-heap-x
In order to get it working on windows, I wrote a version.dll proxy DLL that gets loaded by ShadPS4, loads my actual library (on Linux all of this can be replaced by LD_PRELOAD), which then registers an exception handler to catch a software breakpoint I placed at the eboot entrypoint and finally execute my logic. Not having to do this would be great.

Another possibility is game mods, and in the future, proper ShadPS4 plugins (this initial implementation leaves a lot of room for this).

Examples

  1. ShadPS4 should document at least a single symbol it recognizes as a library entrypoint as a part of its API, using the system's native C ABI.
  2. The user should be able to provide a list of libraries to load via the CLI and/or an environment variable.
  3. After the loader has ran but before it starts executing the game's entrypoint, ShadPS4 should load these libraries one by one in the listed order and call their entrypoint (if present).
  4. The loader proceeds with starting the Game:Main thread

Mock-up library entrypoint declaration (in C):

void ShadPS4Ext_init(void* eboot_base_address);

NOTE: I am willing to implement and maintain this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions