Main's Windows patched_libraries test fails from the merge of #12970
(5bd71fb5bc): 15 modules, libSceSystemService among them, report
LoadLibraryEx error 127 (procedure not found). #17076 (212b75d984) renamed
the cross-library release call to a _nid_no_patch name but the same 15 modules
still fail on main push 42471325636, and its pull request run never ran
patched_libraries, so the rename was not shown to fix it.
Revert both merges as one change until the cause is found and shown
passing on Windows: 14 files from #12970 removed, the #17076 rename reverted
with them.
libSceSystemService calls ReleaseHostInstanceLock across the libkernel
DLL boundary. Every other cross-library host call from libkernel uses a
_nid_postfix or _nid_no_patch name so the patched libraries resolve it.
The plain name is not resolved after patching, so libSceSystemService.prx
and the modules that import it fail LoadLibraryEx with error 127 and the
patched_libraries test goes red on Windows. Rename it to
ReleaseHostInstanceLock_nid_no_patch, next to LogFileRelease_nid_no_patch
at the same call site.
Windows starts the next process with CreateProcessW and only then terminates
the current one, so with ANYPS5_INSTANCE_LOCK=on the new process could reach
its own lock while this one still held it and stop with the already-running
error. Drop the lock just before CreateProcessW. POSIX hosts need nothing:
execv replaces the image in place and the close-on-exec lock descriptor is
released with it. Not built or run on Windows by the author.
Fix-up on MarcZX10's change: resolve the conflicts with main's console
date and time format settings by keeping both sides: both includes in
Export.cpp, the ANYPS5_OPEN_URLS row beside main's ANYPS5_DATE_FORMAT
and ANYPS5_TIME_FORMAT rows, and both USAGE sections.
sceSystemServiceParamGetInt returned a fixed 1 (day, month, year) for the date
format and a fixed 1 (24-hour) for the time format. They now come from
ConsoleDateFormat and ConsoleTimeFormat, which return those same values while
the variables are unset or empty, so nothing changes by default. An invalid
value throws at the first query of that parameter, naming the variable.
obSCEne's PS5 run (system software 12.40) returned 0x80A10004 for a null
event pointer as for a real one, with no event pending; the host
returned 0x80A10003.
All guest threads and all addresses now share one OpenUrlGate: callers that
arrive during a dialog or launch, repeats after a Cancel and more than three
attempts a minute return the existing EOPNOTSUPP without touching a backend.
The mutex that queued callers is gone. The test hook takes the clock too and
resets the gate; the existing exported-call test advances a fake clock between
calls so its sequence is unaffected by the limits.
After the sourced argument checks (null, 6015 bytes, http:, https: or psno:),
the call now consults ANYPS5_OPEN_URLS. Unset, empty or never keep today's
EOPNOTSUPP result. With ask or always, a URL that passes the host validator is
confirmed and launched through the injectable backends and the call returns 0;
a declined, rejected or failed launch still returns EOPNOTSUPP. The launch is
serialised so two guest threads never stack confirmation boxes. An invalid
ANYPS5_OPEN_URLS value throws an error naming the variable at the first call
that gets past the argument checks.
The branch defined SHELL_CORE_UTIL_ERROR_NULL_OUTPUT (0x80e30003) and
LNC_UTIL_ERROR_NULL_OUTPUT (0x80940005), while #10801 on main already
names the same values SHELL_CORE_UTIL_ERROR_INVALID_ARGUMENT and
LNC_UTIL_ERROR_INVALID_ARGUMENT. The two duplicates are gone and their
uses in the status exports and their tests take main's names. The
values, and so the behaviour, are unchanged.
main's #10706 requires each export to be declared once, in its
library's public header. GuestSystemServiceStatus.cpp now includes
prx/libSceSystemService/include/SystemService.hpp instead of declaring
25 of its exports in its own extern "C" lines, as jotitadev suggested
in review.
Co-authored-by: jotitadev <139649225+jotitadev@users.noreply.github.com>
sceSystemServiceLoadExec of a host executable ends this process after it
starts the target, so with ANYPS5_LOG_FILE set the target would inherit
the pipes of the log copy with no reader left. Call LogFileRelease before
the launch (after the existing restore of the kept standard error on
POSIX) so the target inherits the original streams.
sceSystemServiceEnableSuspendConfirmationDialog and
sceSystemServiceDisableSuspendConfirmationDialog set an atomic flag
that sceShellCoreUtilGetSuspendConfirmationDialogFlag reads back for
the running title. The flag starts enabled. Another app ID still
throws NotImplemented_nid_no_patch because the console's answer is
unknown. AnyPS5 has no shell to suspend the title and show the
dialog, so the debt document lists the flag under Silent stubs.
sceSystemServiceSetGpuLoadEmulationMode and
sceSystemServiceGetGpuLoadEmulationMode, with the sceShellCoreUtil
Set/Get pair and their ByAppId variants, now share one atomic mode
instead of throwing. Modes 0 (off) and 1 (normal) are accepted; the
getter returns the mode itself rather than a result code. The initial
mode is 1. Any other mode, and any app ID other than the running
title, still throws NotImplemented_nid_no_patch because the console's
errors for them are unknown. The host GPU is not throttled, which the
debt document lists under Silent stubs.
BunnyFl ran firmware 13.42's libSceSystemService.sprx in an emulator and
recorded the checks these calls make before they pass a request on. A
null title ID or one whose length isn't 9 makes sceSystemServiceGetAppId
and sceLncUtilGetAppId return -1 and sceLncUtilIsAppLaunched return
0x80940005. A null output, list, count or user returns 0x80940005 from
the LncUtil and SystemService calls and 0x80e30003 from
sceShellCoreUtilGetUserFocus, before the app ID is looked at, and a null
sceLncUtilLoadExec path returns 0x80940005.
What the module passes on as a request still throws: another
9-character title ID, another app ID, a list capacity of 0 and an empty
sceLncUtilLoadExec path.
sceLncUtilLoadExec takes the same path and null-terminated argument
list, which the SystemService call passes on to it on the console. It
returns sceSystemServiceLoadExec's result: the same parameter errors,
the same refusals for paths it cannot start, and "exit" ends the title
in the same way.
sceLncUtilIsAppSuspended, sceSystemServiceIsAppSuspended and
sceLncUtilIsSpeculativeLaunch write false for the running title's app
ID. The title that calls them is running and has no shell to suspend
it. It was started from the host rather than by sceLncUtilLaunchApp,
so no LncLaunchParam asked for a speculative launch. Another app ID
and a null output still throw.
sceLncUtilGetAppLaunchedUser, sceSystemServiceGetAppLaunchedUser and
sceShellCoreUtilGetUserFocus write the initial user for the running
title's app ID. That is the user sceUserServiceGetInitialUser and
sceUserServiceGetForegroundUser report. Another app ID and a null user
pointer still throw.
sceLncUtilGetAppId and sceLncUtilIsAppLaunched accept the running
title's ID as sceSystemServiceGetAppId does, and
sceLncUtilGetAppIdOfRunningBigApp returns what
sceSystemServiceGetAppIdOfRunningBigApp returns. Both big-app lists
write the running title's app ID as their only entry, because AnyPS5
runs one title. Another title ID, a null pointer and a list capacity of
0 still throw.
BunnyFl measured these cases against firmware 13.42's libSceSystemService
in the PR thread (behaviour only), so they no longer throw:
- sceShellCoreUtilGetRemotePlayStatus, GetSharePlayStatus and
GetGameLiveStreamingStatus return 0x80e30003 for a null output and
write nothing.
- sceSystemServiceGetRemoteplayStatus has no null check of its own: it
forwards, so a null output returns the ShellCoreUtil error, not
SYSTEM_SERVICE_ERROR_PARAMETER.
- sceLncUtilIsPs2Emu returns 0x80940005 for a null output.
- sceLncUtilUnblockAppSuspend with no block left returns
SCE_KERNEL_ERROR_EBUSY and changes nothing, before reading the reason.
A null reason in sceLncUtilBlockAppSuspend, a null reason in an unblock
while a block is held, sceShellCoreUtilGetSocialScreenStatus with a null
output and the service-answered eye-to-eye cases still throw, and the
debt entries say why.
A null reason, an unblock with no block left and an eye-to-eye query for a user other than the logged-in one now go through NotImplemented_nid_no_patch instead of throwing invented errors, since the console's answers to them are not measured.
AnyPS5 runs the title from its folder as /app0 and models none of these:
libSceDiscId and sceKernelHwGetBdDriveInfo throw, every libSceUsbStorage
device call throws, sceShellCoreUtilDeclareBeginOfExternalStorageAppMove
throws, and sceSystemServiceAddLocalProcessForPs2Emu throws, so the
running process is always the title's own PS5 executable.
sceSystemStateMgrIsBdDriveReady, sceShellCoreUtilIsUsbMassStorageMounted
and sceShellCoreUtilIsExternalStorageAppMoveInProgress return false, and
sceLncUtilIsPs2Emu writes false. A null output to sceLncUtilIsPs2Emu
throws, since no sceLncUtil function in the tree answers one.
AnyPS5 has no shell UI: sceSystemServiceGetStatus never reports a system
UI overlay or background execution, and the host has no auto power-off
timer. The shell UI therefore never takes the foreground, overlays the
impose screen, runs a screen saver or shuts down, and those queries
return false.
libSceHmd detects no headset, so there is no PS VR social screen and the
logged-in user's eye-to-eye distance was never adjusted. Another user ID
throws, since the console's error for it is not measured.
The sceSystemService twins forward to their sceShellCoreUtil and
sceLncUtil targets. sceSystemServiceIsEyeToEyeDistanceAdjusted returns
SYSTEM_SERVICE_ERROR_PARAMETER for a null output before forwarding, as
its neighbours do, and the sceShellCoreUtil forms throw for one.