Forward the suspend, resume, kill, exception and ready-for-suspend wrappers to their LncUtil exports, as the debt records. The targets keep their documented throws, so behaviour is unchanged.
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 <[email protected]>
Runs thirteen host environments (LANG, LC_MESSAGES and LC_ALL precedence,
LANGUAGE, C, nothing set, an unlisted language) and checks that parameters 1
and 400 and SystemServiceConsoleLanguage answer the expected console language,
that the answer does not change when the host locale changes afterwards, that
integers, the empty value and an unset variable still behave as before after
auto, that exactly the expected number of notices is printed, and that near
misses of auto and invalid values are refused with an error that names the
variable and lists auto. Registered on Linux, where the environment is the
locale source.
A value that is neither a console language number from 0 to 30 nor auto still
stops the game at its first language query with an error that names the
variable, which now lists auto as the other accepted value.
auto, in any letter case, resolves the host locale once per process and answers
that console language for every later query of parameters 1 and 400 and for
every other consumer of SystemServiceConsoleLanguage (the trophy texts, and the
keyboard type the user service derives from parameter 1). An unset or empty
variable and every integer behave as before and are read at each query; any
other text is still refused.
ResolveHostLanguage takes the host locales in order of preference from a source
and the console language of the first one that is recognised. When none is
(or the source returns none), it reports one notice line that names the
detected locale and the English (United States) fallback and returns it, so
auto never fails. Source and notice are injectable so tests do not depend on
the host.
The macOS locale source calls CFLocaleCopyPreferredLanguages. The header is
inline, so every target that resolves the language needs the framework: an
interface target carries it on macOS and nothing elsewhere, and the system
service library, the trophy library and the locale test link it.
MacHostLocales returns the user's preferred languages in order from
CFLocaleCopyPreferredLanguages, BCP-47 tags such as en-US, zh-Hans-CN or
pt-BR, which the process environment of a macOS desktop session does not
carry. Only built on macOS.
WindowsHostLocales returns the user default locale name from
GetUserDefaultLocaleName, a BCP-47 tag such as en-US, zh-Hans-CN or pt-BR. It
reads the regional-format locale of the user, not the list of preferred
display languages, because that is one documented call with a fixed buffer.
A name with a non-ASCII character is treated as no locale. Only built on
Windows.
PosixHostLocales takes an injectable environment reader and returns the locales
in order of preference: LC_ALL, then LC_MESSAGES, then LANG, the first one that
is set and not empty, as the C library chooses the locale of the messages
category. When that locale is a real one (not C, POSIX or unset) the entries of
LANGUAGE, the GNU preference list, come before it, as gettext ignores LANGUAGE
under the C locale.
MatchLocale returns the console language of a locale and whether the locale was
recognised. An empty, C, POSIX, malformed or unlisted locale is not
recognised and gives English (United States), the language the console answers
when ANYPS5_LANGUAGE is unset, so resolving a host locale cannot fail. A
recognised language with no row for its region already takes the language's
main row.
Each has a single console language, so every region maps to it. The legacy
code in for Indonesian, still used by some POSIX and Java hosts, is accepted
as well as id.
Russian, Ukrainian, Polish, Czech, Finnish, Swedish and Danish map to their
console language. Norwegian is the console's one Norwegian language, so no,
nb (Bokmal) and nn (Nynorsk) all map to it. Lithuanian, Latvian, Estonian and
the other Slavic languages the console has no entry for stay unrecognised.
A script decides first (zh-Hant is Traditional, zh-Hans Simplified, also
against a contradicting region such as zh-Hans-TW), then the region (TW, HK and
MO are Traditional), and a bare zh is Simplified. Mandarin (cmn) follows the
same rules and Cantonese (yue) is Traditional unless it names Hans.
The console has Spanish (Spain) and Spanish (Latin America), and Portuguese
(Portugal) and Portuguese (Brazil). A bare es is Spain, and the Latin American
countries, the es-419 region and es-US are Latin America. A bare pt is Brazil,
the language's larger variant, and Portugal and the African and Asian
territories that follow the European standard (AO, MZ, CV, GW, ST, TL, MO) are
Portugal.
ConsoleLanguageForTag picks, among the rows of the tag's language whose script
and region are empty or equal to the tag's, the one that names the most
(script outranks region), so a regional row wins over the language's main row
and a language with no row for the tag's region falls back to its main row.
The first group of rows covers the Latin-script European languages that have
no regional split but a few: English (United Kingdom for GB, IE, AU and NZ,
English (United States) otherwise), French and French (Canada), German,
Italian, Dutch and Romanian.
ParseLocale normalises the text as a POSIX name first, which leaves a BCP-47
tag unchanged except for underscores, and then parses the result, so the
caller handles en-US and en_US.UTF-8 alike. C, POSIX and an empty text report
no locale and leave the output tag as it was.
POSIX hosts name their locale language[_territory][.codeset][@modifier], such
as en_GB.UTF-8@euro, and use C and POSIX for no locale at all. NormalizePosixLocale
drops the codeset and the modifier, turns underscores into hyphens, maps the
@latin and @cyrillic modifiers to the Latn and Cyrl scripts where the name has
no script, and returns an empty string for C, POSIX and an empty name so the
caller sees "no locale" instead of a language called C.
Adds a host-only test, system_service_language_locale, for ParseTag: case
normalisation of the language, script and region subtags, the three-digit
region of es-419, variants and extensions that are ignored, and the inputs it
must reject (empty and oversized subtags, one-letter and long languages, the
POSIX underscore and codeset forms) without touching the output tag.
ANYPS5_LANGUAGE can only name a console language number. Taking the language
from the host needs the host's locale, which arrives as a BCP-47 tag such as
en-US, pt-BR or zh-Hant-TW. ParseTag reads the language, script and region
subtags, normalises their case, ignores variants and extensions, and rejects
empty subtags, subtags over 8 characters and languages that are not 2 or 3
letters.
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.
LoadExec replaces the running process with the target executable on
Windows, Linux and macOS. With ANYPS5_LOG_FILE set the standard output and
error are the pipes the log copy reads, and its threads end with this
process, so the new executable would write into pipes nobody reads and a
POSIX one would be killed by SIGPIPE. Before the replacement starts, call
LogFileRelease, which empties the pipes into the file and puts the
original streams back on descriptors 1 and 2 (the standard handles on
Windows) when they still are the pipes. The new executable starts its own
copy from the inherited variable and appends to the same file.
With -DBUILD_TESTING=ON -DANYPS5_RELINKER_CLI=OFF the generate step
failed: exec_arguments, loadexec_arguments, guest_timed_join_import_*,
guest_runtime_lifecycle and agc_driver_guest_memory_lifetime_converted
name the relinker target, which core/relinker defines only when the
option is on. The option is now declared in the root CMakeLists.txt,
before core/libs, and those tests are registered only with the command
line, as core/relinker already does for its own command line tests.
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.
The sceSystemServiceUsbStorage* exports jump straight into the USB storage
module, so call the matching libSceUsbStorage export instead of throwing.
RequestMapWSB keeps its marker while its two declarations disagree on the
fourth argument and the output type.
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.