Commit Graph
94 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Sonnet 5 83b1d13c88 Debugger: add kernel object introspection over the WebSocket API
New events, all read-only (never mutate kernel state, no cleanup/sort calls
- see HLEKernelObjectSubscriber.cpp's header comment):

- hle.object.list: every live kernel object of every type at once (uid,
  type, name, one-line quickInfo), with an optional 'type' filter. Uses
  KernelObjectPool::IterateAll(), a new type-agnostic sibling of the
  existing Iterate<T>().
- hle.eventflag.list/info, hle.mutex.list/info, hle.semaphore.list/info,
  hle.msgpipe.list/info, hle.callback.list/info: per-type full detail
  (all Native* status struct fields plus waiting-thread lists), reading
  straight off the classes exposed in the previous commit.

Also adds JsonWriter::DictScope/ArrayScope (Common/Data/Format/JSONWriter.h)
- RAII push/pop for pushDict()/pushArray(), used throughout the new
  handlers. A forgotten or early-returned pop() previously just produced
  silently malformed JSON; with 11 new handlers each writing a handful of
  nested arrays/dicts, that seemed worth fixing at the API level rather
  than trusting every call site to pair things up by hand. Existing
  handlers are untouched - this is purely additive.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-17 16:01:23 +02:00
Henrik Rydgård 4239c29928 BackgroundAudio: fix crashes and OOB reads parsing WAV/AT3 files
raw_bytes_per_frame (the 'fmt ' chunk's blockAlign field) is
unvalidated file data, and was used unchecked in three places:
- Divided into the 'data' chunk size to compute numFrames - a value
  of 0 divides by zero (crash).
- malloc()'d for raw_data was never null-checked before ReadData()
  wrote into it.
- Passed directly as the read length to the audio decoder on every
  frame, regardless of how much data is actually left in raw_data at
  the current offset - a bogus blockAlign larger than the real 'data'
  chunk size reads past the (padded) allocation into the decoder.
  Clamp it to what's actually available.

IsSimpleWAV() only checked raw_bytes_per_frame's upper bound, not that
it exactly matched one of the two cases Sample::Load() actually
handles (16-bit or 8-bit raw PCM) - a value in between passed the
check but matched neither of Load()'s conversion branches, leaving its
output buffer uninitialized and played back as heap garbage.

Reachable via a WAV/AT3 file parsed by BackgroundAudio.cpp - either
the menu background music preview (any EBOOT.PBP's SND0.AT3 track,
just from browsing the game list) or a user-configurable achievement
sound file.
2026-08-12 09:29:17 +02:00
Henrik Rydgård cd052ea640 Adjust the level of Claude-based paranoia here and there 2026-08-11 20:08:01 +02:00
Henrik RydgårdandClaude Sonnet 5 406033dc3d RIFF/BackgroundAudio: fix OOB reads on short/corrupt WAV chunks
RIFFReader::ReadData() trusted its count argument completely and
memcpy'd straight from the internal buffer with no bounds check.
Hardened it to clamp against the buffer and zero-fill any shortfall,
as defense in depth.

The actual reachable bug was in BackgroundAudio.cpp: it read a WAV
'smpl' chunk into a vector sized by GetCurrentChunkSize(), then
unconditionally indexed smplData[28] (and, for the loop array,
smplData[36]) with no check that the chunk was actually that large -
a short/corrupt chunk in a game's background-music WAV caused a heap
OOB read. Also fixes &smplData[0] being UB when the chunk is empty.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
2026-08-09 19:31:02 +02:00
Henrik RydgårdandClaude Sonnet 5 44b5a4df74 JSONReader: fix null deref in getInt/getFloat/getBool no-default overloads
These dereferenced get()'s result unconditionally, unlike the
two/three-arg "OrDefault" overloads which check. Hit on externally
sourced JSON: UI/Store.cpp reads the remote homebrew-store listing,
UI/DriverManagerScreen.cpp reads user-supplied GPU driver package
metadata - a field simply missing from either crashed the app instead
of failing gracefully.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4QAoxV2KY7ek4PcZw3WvY
2026-08-09 19:31:02 +02:00
Henrik Rydgård a7b1b319ce Limit PNG decode dimensions to prevent decompression bombs
pngLoadPtr allocated the decoded buffer directly from attacker-controlled
PNG IHDR dimensions with no upper bound, so browsing a crafted game icon
or savedata could trigger a multi-gigabyte allocation.

- Add maxWidth/maxHeight parameters to pngLoadPtr (default 8192x8192)
  and reject images larger than the limits.
- Thread the limits through LoadTextureLevelsFromFileData,
  CreateTextureFromFileData, and CreateTextureFromFile.
- Limit game icons to 256x128 in GameInfoCache and IconCache.
2026-08-01 11:41:24 +02:00
Acts1631 e34fe29625 Validate ZIM image sizes before loading
Check the ZIM header, dimensions, mip count, allocation arithmetic,
and uncompressed payload size before allocating or copying image data.
This prevents crafted texture files from overflowing the image buffer.
2026-07-23 15:17:11 -04:00
Henrik Rydgård ed274c8a7e Just some lint fixing 2026-05-13 11:37:26 +02:00
Henrik Rydgård 61e76fcf68 Add the ability to hide adhoc servers using a "hidden" entry in the json.
Useful when servers are temporarily down.
2026-04-23 11:12:58 +02:00
Henrik Rydgård 0153761de0 IniFile: Disallow section headers from starting at other line offsets than 0.
See #21479
2026-03-26 13:04:23 -06:00
Henrik Rydgård cf28fd3a8d More cleanup in pngLoadPtr 2026-02-26 23:41:38 +01:00
Henrik Rydgård 48dc36be2e pngLoadPtr: Protect against over-reads from truncated files 2026-02-26 23:37:52 +01:00
Henrik Rydgård 5a5c7028b9 Assorted warning fixes and data initialization to please valgrind 2026-02-19 11:24:46 +01:00
刘皓 18ac1ec937 Use the libretro VFS when reading/writing cheats 2026-01-02 17:07:22 -05:00
刘皓 5716cbd41d Use the libretro VFS interface in libretro builds 2026-01-01 00:24:01 -05:00
Henrik Rydgård 2b863aafe1 Prepare for the new defaulting mechanism, IniFile cleanup 2025-11-05 12:49:52 +01:00
Henrik Rydgård 4ec26d5002 More cleanup. Fix some warnings. 2025-10-31 22:37:28 +01:00
Henrik Rydgård 14ddad5ce3 Change how defaults work in the inifile reader (more flexible this way) 2025-10-31 21:57:52 +01:00
Henrik Rydgård c98b7591d3 Improve the overload resolution in IniFile 2025-10-31 15:43:52 +01:00
Henrik Rydgård d401915627 More string_view in IniFile 2025-10-29 16:02:50 +01:00
Henrik Rydgård 60aed95e7b More config refactor 2025-10-29 15:49:43 +01:00
Henrik Rydgård 947ddf865f Extract some duplicated code into a pngSave function 2025-09-15 11:46:54 -06:00
Henrik Rydgård 6e5c567809 Fix some ini file misbehaviors 2025-08-31 14:13:12 +02:00
Henrik Rydgård 3056e977cc Misc 2025-08-31 13:37:59 +02:00
Henrik Rydgård 60608b2b39 Allow customizing the proAdhoc server list by editing the ini 2025-08-15 16:35:25 +02:00
Henrik Rydgård dbe6ec80a0 Fix some bad "for (auto x : y)" usage 2025-04-29 16:46:14 +02:00
Henrik Rydgård 176edb93a5 IniFile: Add faster way of reading everything in a section, use it when reading hashes for texreplace 2025-04-22 17:35:40 +02:00
Henrik Rydgård 5adfe62fa3 libpng: Ignore benign errors. Should fix #20050 2025-03-01 23:46:40 +01:00
Henrik Rydgård d156a5e98f libpng full api: Remember to enable interlace handling, fix error handling
I hate hate hate libpng's API with all passion in the world. Why are all
the defaults wrong?
2025-02-26 10:55:03 -06:00
Henrik Rydgård 857c3393c0 Use libpng's full API so we can ignore gamma. Fixes Driver '76's icon. 2025-02-25 10:47:03 -06:00
Henrik Rydgård 4dd3621fa0 Remove some unnecessary <algorithm> includes. 2024-12-18 17:04:27 +01:00
Henrik Rydgård cf88d8b693 Fix bug in ini parsing on non-Windows 2024-11-30 13:51:38 +01:00
Henrik Rydgård 755b062abd Minor perf improvement in ini file parser 2024-11-30 02:43:58 +01:00
Henrik Rydgård e51c58716b Fix minor code issues flagged by PVS-Studio and reported by alphrixus. 2024-10-10 14:10:30 +02:00
Herman Semenov 9f5ac80430 Fixed merge conflict 2024-09-18 11:10:55 +02:00
Herman Semenov 45429bcd85 [Common/Data/File/Input/Net/Serialize/System/UI] Using for based loop C++17 and replaced on structured binding map C++17 2024-09-17 17:42:08 +02:00
Herman Semenov 3c66f149d3 [Common/Core/Windows] Removed excess check pointer before delete or free() 2024-09-17 11:34:42 +02:00
Henrik Rydgård fd9daf7594 Fix some minor issues found by --sanitize. Add --sanitizeub.
Unfortunately the ub (undefined behavior) sanitizer has some bugs, it doesn't
understand pointers to member functions, so can't use it in-game (due to the
vertex decoder).

Thanks Nemoumbra for the reminder.
2024-07-22 11:37:18 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 9d0c127961 IniFile: Switch keys to string_view (avoids recomputing length every time) 2024-05-05 12:04:58 +02:00
Henrik Rydgård e5178d2bc4 Remove unused code, some string_view 2024-05-05 11:58:35 +02:00
Henrik Rydgård fc58a97024 Merge pull request #19027 from GermanAizek/char-as-param-for-string-methods
Minor optimize methods std::string using param as char with simpler implementation
2024-04-10 17:16:14 +02:00
Herman Semenov c20cb3f4be Minor optimize methods std::string using param as char with simpler implementation 2024-04-10 17:57:05 +03:00
Henrik Rydgård e903287f4c Game info screen: Show list of any plugins that will be loaded on start of the game 2024-04-09 12:55:50 +02:00
Henrik Rydgård 1f129b6dca Replace "ReadFileToString" with a few semantically clearer wrappers. 2024-01-25 09:55:54 +01:00
Henrik Rydgård 9253bf9cb5 Add a new screen for managing installed Adreno drivers 2024-01-17 10:51:08 +01:00
Henrik Rydgård 8faba8426a AdrenoTools: Fix picking zip files from the Downloads folder. Add more validation. 2024-01-15 11:46:41 +01:00
Henrik Rydgård 26db1cb05d IniFile: Remove some allocations 2024-01-12 14:03:02 +01:00
Herman Semenov 4ea842a3c1 Minor replaced insert to emplace C++11 2023-12-19 16:06:48 +03:00
Henrik Rydgård 155222145a Merge pull request #18550 from GermanAizek/fix-memsize-type
[Common Data Net/Core Debugger HLE/GPU Debugger] Fixed reduction data type size to strict 32-bit integer
2023-12-14 17:51:08 +01:00