Skip to content

The way to Unity, pt.3 #1681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2024
Merged

The way to Unity, pt.3 #1681

merged 1 commit into from
Dec 8, 2024

Conversation

polybiusproxy
Copy link
Contributor

@polybiusproxy polybiusproxy commented Dec 7, 2024

This should be the last of my PR series regarding Unity. The last main thing to implement is exception support.

To emulate POSIX's behavior, we will use special user APCs, which will allow us to 'inject' code on a remote thread, regardless of what the thread was executing—when the APC returns, the thread goes back to what it was executing.
The only caveat is that APCs won't execute if the thread is on a non-alertable wait at the time of the APC raise. This is why we did a rework of sync primitives in part 2, using wrappers that use Win32 sync primitives and WaitForSingleObjectEx.
To make use of APCs, we use NtQueueApcThreadEx and rely on its undocumented behavior to have x86 context on the APC routine as well (thanks to red_prig and Roamic).

In addition, this PR does some additional fixes on the linker to improve Unity games further—if sceKernelLoadStartModule is called more than once for a module, a handle will be returned instead of loading and calling the module's module_start function again. This fixes both crashes and race conditions on later Unity games.
Event flag cancelling is also implemented as seen on Unity (makes no effect, but it's nice to have).

image
image

@ElBread3
Copy link
Contributor

ElBread3 commented Dec 7, 2024

So far most of my Unity games either crash at net calls, PromoteFormatToDepth unreachable, or "existing mapping does not contain requested unmap range". Again, could you please add the missing mappings for the pthread sem functions?
Interesting, one of them also spams "Stub: sigprocmask (nid: aPcyptbOiZs)" while booting.

@ElBread3
Copy link
Contributor

ElBread3 commented Dec 7, 2024

Now that that's fixed, immediately crashes on JoinRegionsAfterUnmap.

[Kernel.Vmm] memory.cpp:Free:141: Unmaping direct mapping 0x1f77c0000 with size 0x100000
[Core] stubs.cpp:CommonStub:42: Stub: sceMouseRead (nid: x8qnXqh-tiM) called, returning zero to 0x900dc50ee
[Kernel.Vmm] memory.cpp:sceKernelMunmap:493: addr = 0x1f77c0000, len = 0x100000
[Debug] address_space.cpp:operator():268: Assertion Failed!
Invalid address/size given to unmap.

Additionally, a different variant of the error from the Unmap function:

[Kernel.Vmm] memory.cpp:Free:141: Unmaping direct mapping 0x1fe100000 with size 0xd40000
[Kernel.Vmm] memory.cpp:sceKernelMunmap:493: addr = 0x1fe100000, len = 0xd40000
[Debug] address_space.cpp:operator():182: Assertion Failed!
Unmap operation on virtual_addr=0X1FE100000 failed: Attempt to access invalid address.

@Randomuser8219
Copy link
Contributor

we should rebase this because of the recent huge changes

@GHU7924
Copy link

GHU7924 commented Dec 8, 2024

Build f496c6b

CUSA05297 INSIDE

Unlike last time, the game is now starting to load
The game crashed
shad_log_1.txt

The game crashed with an error
shad_log_2.txt

CUSA23081 Untitled Goose Game

Unlike last time, the game is now starting to load
I went to the menu, selected a slot to save, the game started loading, but it looks like either it's an endless download or a crash
shad_log_3.txt
shad_log_4.txt

@5jd
Copy link

5jd commented Dec 8, 2024

Build f496c6b

Race The Sun CUSA00708 01.00

Now boots but loading is stuck on

[Core] <Error> stubs.cpp:CommonStub:42: Stub: sceMoveReadStateRecent (nid: f2bcpK6kJfg) called, returning zero to 0x9000009c2

shad_log.txt

@georgemoralis georgemoralis merged commit fea2593 into main Dec 8, 2024
20 checks passed
@georgemoralis georgemoralis deleted the unity-pt3 branch December 8, 2024 16:31
diegolix29 pushed a commit to diegolix29/shadPS4 that referenced this pull request Dec 9, 2024
diegolix29 added a commit to diegolix29/shadPS4 that referenced this pull request Dec 9, 2024
diegolix29 added a commit to diegolix29/shadPS4 that referenced this pull request Dec 9, 2024
diegolix29 added a commit to diegolix29/shadPS4 that referenced this pull request Dec 10, 2024
Xcedf pushed a commit to Xcedf/shadPS4 that referenced this pull request Dec 10, 2024
diegolix29 pushed a commit to diegolix29/shadPS4 that referenced this pull request Dec 11, 2024
@GHU7924
Copy link

GHU7924 commented Dec 12, 2024

I am updating the report on my two games on the Unity engine.

Build 5be807f

CUSA05297 INSIDE

[Debug] liverpool_to_vk.h:PromoteFormatToDepth:107: Unreachable code!

CUSA23081 Untitled Goose Game
Goose
Now you can play.

@Inui-senpai
Copy link

Inui-senpai commented Dec 17, 2024

Unmap operation on virtual_addr=0X1FE100000 failed: Attempt to access invalid address.

DDLC+ crashes with the same error (but with the other virtual address). Maybe we should create an another "[Aggregate Issue]" issue. 🤔

Just in case (used build 6d728ec):

[Debug] <Critical> address_space.cpp:operator():182: Assertion Failed!
Unmap operation on virtual_addr=0X1F5C80000 failed: Attempt to access invalid address.

shad_log.txt

Xcedf pushed a commit to Xcedf/shadPS4 that referenced this pull request Dec 28, 2024
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.

7 participants