Commit Graph

1212 Commits

Author SHA1 Message Date
kalaposfos13
98fd0689ac Revert non-Linux parts of #3819 (#3852)
* Revert non-Linux parts of #3819

* More OpenOrbis stuff that I couldn't be bothered to put in a new PR
2025-12-03 15:05:19 +02:00
Pirky
e5ea55e425 np: Add dialog state tracking for NpCommerce (#3841) 2025-12-02 10:22:41 +02:00
Stephen Miller
a5f9280841 Return CPU mode based on param.sfo attributes (#3846)
Values are based on hardware observations.
2025-12-01 10:21:19 +02:00
kalaposfos13
cf866ab294 Don't bother trying to restart the emulator if sceSystemServiceLoadExec is called with an invalid path (#3845) 2025-11-30 22:40:58 +02:00
TheThunderTurner
78e301c3db libSceNpCommerce (#3839)
* libSceNpCommerce

* copyright notice
2025-11-29 23:47:15 +02:00
kalaposfos13
2577dfde7e Add assert on SFO file being empty (#3815) 2025-11-23 17:30:09 -08:00
Stephen Miller
f6ae5544fd Kernel.Vmm: Protect Fixes (#3822)
* Some mprotect fixes

The biggest thing here is preventing mprotect on memory that isn't mapped in address space. This would cause exceptions before, but succeeds on real hardware.
I've also included a couple other minor fixes, mostly based around some tests I recently performed.

Note: All changes to memory pools in this PR are assumed. I have not yet tested memory pools with any of this logic, but I do at least want to prevent mprotect on pool reserved memory to avoid crashes.

* Update memory.cpp

* clang
2025-11-22 10:32:53 +02:00
oltolm
4922d526fe msys2: fix build (#3818)
* cmake: fix mingw-w64 build

* time.cpp: fix build with Clang on Windows

* tls.h: include malloc.h for alloca
2025-11-22 10:32:29 +02:00
kalaposfos13
56109a1331 Avoid storing the Tcb pointer on the stack (#3819)
* Avoid storing the Tcb pointer on the stack

* Just return the already stored pointer in GetTcbBase

* Replace uses of GetTcbBase with g_curthread->tcb

* copyright 2025

* sir clang offnir, the all-formatting
2025-11-21 00:42:49 -08:00
marecl
6612a32523 Prevent writing to directories (#3820)
* Prevent writing to directories

* Prevent writing to directories
2025-11-20 19:41:01 +02:00
rainmakerv2
ed14359c87 Re-implement custom trophy sounds using sdl3 mixer (#3805)
* re-implement custom trophy sounds using sdl3 mixer

* fix build vars

* Don't change SDL version
2025-11-16 10:36:54 +02:00
Stephen Miller
93c340c6e1 calloc libusb_interface instead of pointer (#3793)
interface->num_altsetting is oob
2025-11-12 17:26:26 +02:00
Joshua de Reeper
25344a3b89 calloc UsbDevice instead of pointer (#3790) 2025-11-12 12:40:39 +02:00
Stephen Miller
ee2bc97248 Windows: Limit address space maximum when higher addresses are not needed (#3775)
* Earlier initialization of elf info.

Everything used for elf info initialization comes from the param.sfo, so we can initialize this earlier to have this information accessible during memory init.

* Extract compiled SDK version from pubtoolinfo string

Up until now, we've been using the game's reported "firmware version" as our compiled SDK version. This behavior is inaccurate, and is something that has come up in my hardware tests before.

For the actual compiled SDK version, we should use the SDK version in the PUBTOOLINFO string of the param.sfo, only falling back on the firmware version when that the sdk_ver component isn't present.

* Store compiled SDK version in ElfInfo

* Limit address space for compiled SDK version at or above FW 3

Sony placed a hard cap at 0xfc00000000, with a slight extension for stack mappings. For now, though stack mappings aren't implemented, there's no harm in keeping a slightly extended address space (since this cap is lower than our old user max).

Limiting the max through address space is necessary for Windows due to performance issues, in the future I plan to properly implement checks in memory manager code to properly handle this behavior for all platforms.

* Use compiled SDK version for sceKernelGetCompiledSdkVersion

I think this is pretty self explanatory.

* Log SDK version

Since this value is what most internal firmware version checks are against, logging the value will help with debugging.

* Update address_space.cpp

* Update emulator.cpp

* Backwards compatible logging

Because that's apparently an issue now
2025-11-10 17:07:17 +02:00
Emma
2f022a462d filesystem: return st_mtim in posix_stat (fixes RB4 / CUSA02901 DLC crash) (#3781)
* filesystem: return st_mtim in posix_stat

* filesystem: stat - remove reliance on clock_cast

* filesystem: stat - remove reliance on to_time_t
2025-11-06 22:47:40 +02:00
Joshua de Reeper
f5505daaca usbd: Emulate Dimensions Toypad (#3779)
* Dimensions Toypad

* update comment
2025-11-06 17:46:43 +02:00
Joshua de Reeper
8c1ec863da Add Infinity Base Backend (#3778) 2025-11-06 16:34:52 +02:00
kalaposfos13
604f8d9398 More OpenOrbis stuff (#3776) 2025-11-06 13:22:26 +02:00
Stephen Miller
19e974bf21 Libkernel: Implement/stub some functions (#3774)
* Define latest released firmware version, use that for sceKernelGetSystemSwVersion

I feel this is less hacky and error-prone than just returning the game firmware.

* sceKernelGetAllowedSdkVersionOnSystem

* sceKernelHasNeoMode

* sceKernelGetAppInfo stub

* sceKernelGetCurrentCpu

* fixups

* sceKernelGetMainSocId

Used by libSceAvPlayer to determine if console is a pro or not.

* Update process.cpp

* Set has_param_sfo to true

* Clang
2025-11-05 16:58:15 -08:00
Stephen Miller
7031f5968e Better return stub (#3773)
Gets THE PLAYROOM (CUSA00001) further.
2025-11-05 18:32:24 +02:00
georgemoralis
ff8869262f [Libs] Font lib HLE implementation (#2761)
* dummy fontlib libs

* register font libs

* typo fix

* added font error file

* added sceFontCharacterGetBidiLevel (from RE)

* fixup

* sceFontCharacterGetTextOrder , sceFontCharacterLooksFormatCharacters , sceFontCharacterLooksWhiteSpace RE

* sceFontCharacterRefersTextBack,sceFontCharacterRefersTextNext,sceFontRenderSurfaceInit,sceFontRenderSurfaceSetScissor  RE

* sceFontRenderSurfaceSetStyleFrame ,sceFontStyleFrameGetEffectSlant RE added

* clang fix

* sceFontStyleFrameGetEffectWeight

* added sceFontStyleFrameGetScalePixel

* Update types.h

* fixup merge
2025-11-04 17:14:22 +02:00
Stephen Miller
683e5f3b04 Core: Simulate write-only file access with read-write access (#3360)
* Swap write access mode for read write

Opening with access mode w will erase the opened file. We do not want this.

* Create mode

Opening with write access was previously the only way to create a file through open, so add a separate FileAccessMode that uses the write access mode to create files.

* Update file_system.cpp

Remove a hack added to posix_rename to bypass the file clearing behaviors of FileAccessMode::Write

* Check access mode in read functions

Write-only files cause the EBADF return on the various read functions. Now that we're opening files differently, properly handling this is necessary.

* Separate appends into proper modes

Fixes a potential regression from one of my prior PRs, and ensures the Write | Append flag combo also behaves properly in read-related functions.

* Move IsWriteOnly check after device/socket reads

file->f is only valid for files, so checking this before checking for sockets/devices will cause access violations.

* Fix issues

Now that Write is identical to ReadWrite, internal uses of Write need to be swapped to my new Create mode

* Fix remaining uses of FileAccessMode write to create files

Missed these before.

* Fix rebase

* Add stubbed get_authinfo (#3722)

* mostly stubbed get_authinfo

* Return value observed on console if get_authinfo was called for the current thread, esrch otherwise

---------

Co-authored-by: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com>
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-11-04 10:57:26 +02:00
georgemoralis
08fe66a97f [Libs] Http HLE (part2) (#2762)
* added sceHttpParseStatusLine

* added sceHttpUriMerge

* macOS fix

* more macOS fix?

* typo

* Update src/core/libraries/network/http.cpp

Co-authored-by: illusony <37698908+illusion0001@users.noreply.github.com>

* some work on sceHttpGetStatusCode

* more draft on GetStatusCode

* added some debug info

* fixup

---------

Co-authored-by: illusony <37698908+illusion0001@users.noreply.github.com>
2025-11-04 10:41:26 +02:00
Stephen Miller
bc44865cda Implement sceGnmDrawInitToDefaultContextStateInternal functions (#3770)
These are used by LLE libSceVideodec.
From decompiling the two GnmDriver libraries, it seems like sceGnmDrawInitToDefaultContextStateInternalCommand inlines a call to sceGnmDrawInitToDefaultContextState, so I've replaced that with an actual call to the function for readability.
sceGnmDrawInitToDefaultContextStateInternalSize is one to one with decomp.
2025-11-03 11:06:26 -08:00
Vinicius Rangel
a4c3c665fe add null gpu notice (#3768) 2025-11-02 19:55:43 +02:00
Joshua de Reeper
8bbb3956a2 Skylander Portal (#3762) 2025-11-01 12:18:34 +02:00
Pavel
6c7c5eb59c get_authinfo (#3760) 2025-10-31 15:56:11 +02:00
oltolm
493cda07c0 fix divide by zero (#3759) 2025-10-31 15:36:27 +02:00
ElBread3
eda6be746f usbd: Implement usb backend system (#3737)
* initial impl

* reviews

* upstreamed deReaperJosh changes

* fixed config.cpp

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-10-31 11:11:14 +02:00
georgemoralis
ed9ffbfb64 Remove Qt from emulator (#3733)
* actions removal

* removed qt dir

# Conflicts:
#	src/qt_gui/check_update.cpp
#	src/qt_gui/translations/ar_SA.ts
#	src/qt_gui/translations/ca_ES.ts
#	src/qt_gui/translations/da_DK.ts
#	src/qt_gui/translations/de_DE.ts
#	src/qt_gui/translations/el_GR.ts
#	src/qt_gui/translations/en_US.ts
#	src/qt_gui/translations/es_ES.ts
#	src/qt_gui/translations/fa_IR.ts
#	src/qt_gui/translations/fi_FI.ts
#	src/qt_gui/translations/fr_FR.ts
#	src/qt_gui/translations/hu_HU.ts
#	src/qt_gui/translations/id_ID.ts
#	src/qt_gui/translations/it_IT.ts
#	src/qt_gui/translations/ja_JP.ts
#	src/qt_gui/translations/ko_KR.ts
#	src/qt_gui/translations/lt_LT.ts
#	src/qt_gui/translations/nb_NO.ts
#	src/qt_gui/translations/nl_NL.ts
#	src/qt_gui/translations/pl_PL.ts
#	src/qt_gui/translations/pt_BR.ts
#	src/qt_gui/translations/pt_PT.ts
#	src/qt_gui/translations/ro_RO.ts
#	src/qt_gui/translations/ru_RU.ts
#	src/qt_gui/translations/sl_SI.ts
#	src/qt_gui/translations/sq_AL.ts
#	src/qt_gui/translations/sr_CS.ts
#	src/qt_gui/translations/sv_SE.ts
#	src/qt_gui/translations/tr_TR.ts
#	src/qt_gui/translations/uk_UA.ts
#	src/qt_gui/translations/ur_PK.ts
#	src/qt_gui/translations/vi_VN.ts
#	src/qt_gui/translations/zh_CN.ts
#	src/qt_gui/translations/zh_TW.ts

* removed CMakePresets for qt builds

* clear cmakelists from qt

* sync config file with qtlauncher

* fixing review stuff

* Remove Qt code from memory patcher and add non-Qt fallback for automatic loading of patches
The second feature is disabled if IPC is present, to avoid conflicts with it.

* Add json submodule

* More Qt removal

* Documentation update

* fix build

* fix REUSE?

* removed qrc file

* fix clang

* Simplify Qt installation instructions for macOS

Removed instructions for installing x86_64 Qt on ARM and x86_64 Macs.

* Remove Qt installation instructions from guide

Removed instructions for downloading and configuring Qt.

---------

Co-authored-by: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com>
2025-10-31 10:28:39 +02:00
Stephen Miller
715eb512c9 Core: Read-only file mmap fix (#3757)
* Extra validity checks for file mmaps

* Add comment
2025-10-30 15:47:08 -07:00
jzwmvqttmd-svg
87e09b613b Fixes scePlayGoDialog status stub (#3750)
* Fixes scePlayGoDialog status stub

* input: Fix analog stick stuttering caused by excessive state buffering
2025-10-26 05:40:00 +02:00
Valdis Bogdāns
db9921baf2 GE2: Fix IME text conversion length handling (#3735)
- Reserve an extra space for the terminating character, resolving an issue in GE2 where the last character did not appear when input reached the maximum length.

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-10-14 08:41:47 +03:00
rainmakerv2
17fab7fdf1 IPC: commands for volume adjustment, input parsing, fsr, gamepad select (#3734)
* Add IPC functions: volume, fsr settings, parse inputs

* always process fsr values

* set controller command
2025-10-13 15:04:34 +03:00
Valdis Bogdāns
0cd6248eee Ime fixes (#3731)
* Changes
-Added support for OrbisImeParamExtended (extended IME parameters) in ImeHandler, ImeState, and ImeUi
-Updated all relevant constructors and logic to propagate and store the extended parameter
- Now fully supports passing extended options from sceImeOpen to the IME UI and backend

* Potential CUSA00434 [Debug] <Critical> assert.cpp:30 assert_fail_debug_msg: Assertion Failed!
buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?" at C:/VS/shadPS4-ime-fixes/externals/dear_imgui/imgui_widgets.cpp:4601 fix

* Attempting to resolve an assertion failure in Diablo III:
- Adjusted buffer sizes
- Updated the calculation of text‑length values

* ime-lib another hotfix

Fixed incorrect param->title validation, which caused the IME dialog to fail to appear in Stardew Valley. Need to be checked.

* Clang fix

* FF9 ImeDialog Hotfix

* Removed the validation that disallowed null text and null placeholder, since using null values is valid in `ImeDialog`.
* Added additional debug logs to aid troubleshooting.

* IME Fixes
- Add missing flags to `OrbisImeExtOption`
- Improve debug logging
- Resolve nonstop `sceImeKeyboardOpen` calls in Stardew Valley (MonoGame engine) for `userId = 254`

* IME: guard null params for CUSA04909

- Add null checks in IME constructors to prevent crashes seen in CUSA04909.
- Leave a clear note about deferring keyboard event dispatch until guest-space translation is ready.

* Some improvements
- Added debug logs so every IME event and host callback (text/caret updates) shows what the guest sent back.
- Updated ImeState to respect the guest’s text-length limit, keep buffers in sync, and record caret/text changes without duplicates.
- Fixed shutdown by actually destroying the handler on close and letting sceImeUpdate exit quietly once the IME is gone.

* CLang

* IME: simplify handlers, add param checks, fix caret index

- Unify ImeHandler init; support optional OrbisImeParamExtended; drop userId from keyboard handler.
- Add basic null checks for work and inputTextBuffer; early error logging.
- Fixed incorrect caret position. Make caret and text area indices 1-based in ImeUi::InputTextCallback.
- Set default user_id to ORBIS_USER_SERVICE_USER_ID_INVALID in sceImeParamInit.
- Reduce noisy debug logs; promote key calls to LOG_INFO.
- Remove unused extended fields from ImeState; minor cleanups.

* IME: text/caret sync fixes; add Enter payload

- Sync UI input and work buffers on UpdateText
- Sync caret position on mouse click by emiting multiple UpdateCaret events for jumps (loop over delta)
- Add text payload to PressEnter (and Close); fixes IME in God Eater 2
- Queue initial Open event after open
- Fix UTF-8 → UTF-16 conversion bounds
- Add debug logs for all queued events

* CLang

* fixed accidental copy / paste replacement in text update event that broke text deletion.

* IME: Add code-point limited InputText and use in IME UI

- Add InputTextExLimited helper to cap Unicode code points and forward callbacks
- Switch IME input to InputTextExLimited with ime_param->maxTextLength and CallbackAlways

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-10-13 13:38:44 +03:00
Stephen Miller
6b6294a750 Filesystem: Always log mode as an octal (#3729)
Mode is an octal, print it as one.
2025-10-11 20:22:35 -07:00
Alexandre Bouvier
999960a6e6 fix for fmt 12 (#3719) 2025-10-08 01:49:46 -07:00
kalaposfos13
6805baffb2 posix_pthread_mutex_destroy (#3720) 2025-10-08 01:44:17 -07:00
Stephen Miller
109b239ddf Fix NoOverwrite flag behavior in MapMemory (#3718)
Reserved memory counts here, so we need to use !IsFree instead of IsMapped.
I swear this is like the 10th time I've messed this sorta thing up. Seems like it's the last case of this type of mistake in our current code though.
2025-10-07 18:39:39 -07:00
Stephen Miller
1714647343 Fix return for running out of flexible memory (#3717) 2025-10-07 17:33:09 -07:00
Stephen Miller
794d593a02 Fix alignment for mmap (#3716) 2025-10-07 16:22:21 -07:00
Stephen Miller
b34556702e NpAuth: Improved stubs (#3712)
* Some structs and function definitions

* Fill in remaining function definitions and structs

The original variants of GetIdToken and GetAuthorizationCode use an online id instead of user id.
The V3 functions use the same internal function, but with a different flag. Unless games show me something different, they likely use the same structs, and definitely use the same parameters.

* Some errors

* Minor formatting change

* Some more errors

* GetIdToken error cases

* Remaining error cases

Just need to tackle request-related logic now.

* Basic request handling

Seems to internally behave similarly to libSceNpManager, but the actual data stored in libSceNpAuth requests appears to be different, so I've kept everything separated.

* NpAuthRequest usage

Again, behavior mirrors libSceNpManager request behavior, though it appears to be a separate implementation.
The only time libSceNpAuth uses libSceNpManager is to actually send the requests, where the act of sending a request involves creating a completely separate NpManager request, using NpManager functions to retrieve the desired data, then deleting the underlying NpManager request. All of this would happen inside GetAuthorizationCode and GetIdToken.

* Oops

* Missing mutexes

* Default output variables to zero

Not sure what all games might check for here, but setting the outputs to zero is probably safe.
2025-10-05 17:31:21 -07:00
Stephen Miller
a0e7f7fb65 NpManager: Implement more request-related behavior (#3703)
* Implement sceNpCheckPlus

* Rework request storage

We'll need to store more data to "fake" async requests.

* sceNpAbortRequest

Pretty simple to add, so might as well.

* Formatting changes

* Async request logic

There's probably some things I'm getting wrong for cases where PSN is connected, but for reasons that should be pretty obvious, learning how that all works is a little more involved than the PSN disconnected results.

* Add missing error check

* Update np_manager.cpp

* Add a mutex to prevent concurrent reads/writes to g_requests

I imagine multi-threading is a lot more commonly used with the async functions, though I haven't tested enough to know.

* Update np_manager.h

* Move request creation to separate internal function

* Oops

Not sure how that got missed, but good thing I spotted it

* Oops
2025-10-05 17:25:46 -07:00
TheTurtle
8f37cfb739 amdgpu: Split liverpool registers and cleanup (#3707) 2025-10-05 13:42:40 -07:00
Stephen Miller
d17a4fb8cc Include older Windows 11 builds in the address space workaround (#3711)
For now, I've included up to Windows 11 22H2 in the workaround.
I've only personally seen reports of issues on Windows 11 21H2, but better safe than sorry (considering Windows 10 22H2 has issues).
2025-10-05 12:46:06 -07:00
kalaposfos13
4fa435490c Add missing function exports for OpenOrbis (#3708)
* Add missing function exports for OpenOrbis

* copyright 2025

* review comment
2025-10-05 19:31:05 +03:00
Stephen Miller
11229c1dc0 Use correct trophy folder for games with multiple trophy lists (#3704)
Based on the games I've checked, it seems like the service label parameter of sceNpTrophyCreateContext is what determines the trophy list.
Since we're already storing the service label in our contexts, and we're already extracting all trophy lists, all that needs doing is using the service label to select the right trophy list.
2025-10-05 18:39:14 +03:00
Stephen Miller
455cd37aae Fix tess addr (#3706) 2025-10-05 18:23:42 +03:00
Stephen Miller
e7194af881 Core: Increase address space limits and rework Windows address space initialization. (#3697)
* SearchFree adjustments

* Robust address validation

I've adjusted IsValidAddress to take in a size, and check whether the whole range is contained in vma map.
If no size is provided, the function reverts to the old form of address validation instead.

* Map around gaps

As is, this should work mostly.
Only remaining issue is adding logic to pass the "mapped regions" to the guest vma map (and make such logic cross-platform).

* Initialize vma_map using gaps

This should allow memory code to catch any issues from address space gaps, and prevent non-fixed mappings from jumping to a location that isn't actually available.

* Clang

* Fix compile

* Clang

* Fix compile again

* Set system_managed_base and system_managed_size based on

Many places in our code use system_managed_base as the minimum mappable address, ensure this fact remains the same  on Windows to prevent potential bugs.

* Reduce address validation in SearchFree

Allows SearchFree to function when a certain Windows GPU driver goes and reserves the whole system managed area.

Since SearchFree is only called on flexible addresses, allowing this particular case, where addresses are in bounds, but there's not enough space to map, should be safe enough.

* Bump address space size further

To handle Madden NFL 16 (and any games like it)

* More thorough logging of available memory regions

Should help with spotting weirdness.

* Formatting fixes

* Clang

* Slight reduction of user space

Still large enough to handle EA's shenanigans, but small enough that Linux doesn't break.

* Assert on VirtualQuery failure

* Extra debugging information

* Further reduce user space

This will unfix most of EA's titles, but UFC will still work.
Older windows versions support the high addresses, but trying to actually use them causes significant performance issues.

* Extra debugging info

Just in case other testers still run into issues.

* Remove debug logging

* Revert user space increases

Technically this constant is still higher than before, but weird side effects of our old logic resulted in a max address somewhere around this in main.

* address_space: Support expanded virtual memory space on macOS.

Co-Authored-By: squidbus <175574877+squidbus@users.noreply.github.com>

* Move address space constants to address_space.cpp

This ensures that all code must use the calculated address space memory values instead of the constants, since the calculated values can differ based on the platform.

This does require slight modification to thread state and gnmdriver code, since both were already using these constants directly.

* Workaround Windows 10 limitations

If a Windows 10 device is detected, use a lower value for USER_MAX to prevent system-wide hangs in VirtualAlloc2 calls.

* Fix compile for Windows-Qt

* Move tessellation_factors_ring_addr initialization to sceGnmGetTheTessellationFactorRingBufferBaseAddress

* Set image base address on Windows

This seems to work fine on Windows 11, needs testing from Windows 10 due to the previously discussed bugs.

* Set Linux executable base to 0x700000000000

This allows Linux to map the full user space without any workarounds.

Co-Authored-By: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>

* Basic formatting changes

* Reduce USER_MAX on Linux

Seems like finding a reliable way to move shadPS4's position in memory is difficult, for now limit the user size so we aren't trying to overwrite ourselves.

* Move memory and address_space variables.

---------

Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
Co-authored-by: Marcin Mikołajczyk <2052578+mikusp@users.noreply.github.com>
2025-10-04 14:52:50 -07:00
kalaposfos13
5fedf9daea add missing pthread_condvar_signal export (#3701) 2025-10-04 12:09:03 +03:00