Commit Graph
92 Commits
Author SHA1 Message Date
Henrik Rydgård c5e4d0d90d Rename the get-memory-pointer functions to make it clear where CPU exceptions can happen. 2026-08-12 14:06:16 +02:00
Henrik Rydgård 4cd611b71f Fix out-of-bounds reads in ATRAC track parsing
AnalyzeAtracTrack used max(fileSize, size) as the chunk-parse bound with
fileSize taken from the file's RIFF header, so a crafted inflated RIFF
size could push reads past the end of the buffer. Keep the real-library
behavior of tolerating a too-low size, but clamp the parse bound to the
actual mapped guest memory at the buffer.

Also guard ParseWaveAT3's RIFF scan against a blockSize < 4 underflow
that could make the offset negative and bypass the loop bounds check, and
clamp readSize to the mapped region in Atrac2::SetData before parsing.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 2100e4ec47 Reject ATRAC files with oversized packets at parse time; honor Verify errors
- InitContextFromTrackInfo now rejects files where sampleSize (from
  blockAlign) exceeds the buffer size, instead of only clamping later in
  DecodeForSas. Keep the DecodeForSas check as defense-in-depth since a
  large buffer could still allow a crafted packet to overflow the fixed
  assembly buffer.
- CChunkFileReader::Verify now returns ERROR_BROKEN_STATE if bounds
  checking fails, so modified savestates are rejected here too.
2026-08-01 11:57:27 +02:00
Henrik Rydgård 3ad08377c5 Clamp partial packet copy to main buffer size in Atrac2::DecodeInternal
The loop-with-trailer streaming path copied 'secondBufferByte % sampleSize'
bytes into the main buffer with no clamp. sampleSize is file-derived, so a
crafted value could overflow the destination. Clamp the copy length to
info.bufferByte.
2026-08-01 11:41:24 +02:00
Henrik Rydgård 6d231f3f45 Guard SAS assembly buffer against oversized ATRAC packets
A crafted blockAlign could overflow the fixed 1000-byte assembly stack
buffer in Atrac2::DecodeForSas. Bail out if the packet can't fit.
2026-07-31 20:54:17 +02:00
Henrik Rydgård 188945f0fe Warning fixes 2026-01-19 17:56:30 +01:00
Henrik Rydgård 5e16bf907b VertexDecoder: Improve logging for missing formats. Add missing convert function.
The missing function is mainly used in D3D11, which can be used on
Windows for ARM64. It's not necesssary for the other backends, which is
why it used to be missing in the ARM64 vertex decoder.

Also fix a minor memory leak in AtracCtx2.
2025-09-24 10:52:09 -06:00
Henrik Rydgård b15b0c441e Make the checks for atrac size more lenient. Possible fix for #20834 2025-09-24 10:08:53 -06:00
Henrik Rydgård d0eea81fe6 Fix typo in mono atrac initialization. Fixes crash in StormBasic homebrews 2025-08-14 22:09:50 +02:00
Henrik Rydgård f41bd18a8e Allow Atrac files to be accepted with a little less data provided initially
Fixes #20692
2025-08-04 19:31:35 +02:00
Henrik Rydgård 4d7b51d8cb Reimplement AA3 header parsing 2025-07-22 17:48:20 +02:00
Henrik Rydgård ffb1e01e7e Fix shutdown performance regression 2025-06-26 11:06:21 +02:00
Henrik Rydgård 0fc7d430b4 Reimplement wave parsing more simply, for AtracCtx2. 2025-06-26 11:06:18 +02:00
Henrik Rydgård 5c77ff9147 Atrac: Rework the header dependencies 2025-06-25 11:34:07 +02:00
Henrik Rydgård 33fd29faad Add a sanity check 2025-06-25 01:08:51 +02:00
Henrik Rydgård 6df9e513c1 Logging, comments and debugger fixes, plus simple dumping of the first block of streaming Atrac3 2025-06-25 01:08:47 +02:00
Henrik Rydgård ea29fd284f sceAtrac: Logging improvements, constification (and not) 2025-06-24 21:36:04 +02:00
Henrik Rydgård 43e79aba55 Give Mpeg and Atrac their own log categories 2025-06-24 21:36:04 +02:00
Henrik Rydgård 1f5064d582 Disable error return value in sceAtracLowLevelDecode
See issue #20452
2025-06-06 11:01:34 +02:00
Henrik Rydgård 5260be6f69 Warning fixes, alignment checks 2025-05-15 09:48:23 +02:00
Henrik Rydgård f7ff2e2d20 Remove redundant constants 2025-04-12 11:35:55 +02:00
Henrik Rydgård 693f84d2fb sceAtrac logspam reduction 2025-04-11 13:12:14 +02:00
Henrik Rydgård a555fe8924 Partially implement sceReg 2025-04-03 14:13:50 +02:00
Henrik Rydgård 2af71d049b Lost this behavior by mistake. Should fix the tests. 2025-03-25 23:27:43 +01:00
Henrik Rydgård 96ca0e95f3 Cleanup logging 2025-03-25 22:01:33 +01:00
Henrik Rydgård c418513fa5 Fix bad check, add some comments
And remove unneded initial text.
2025-03-25 22:01:33 +01:00
Henrik Rydgård 5ea7729f66 More work on atrac-through-sas 2025-03-25 22:01:33 +01:00
Henrik Rydgård 172e54286e Refactor a bit to make it easier to expose the streaming state to the debugger. 2025-03-25 22:01:33 +01:00
Henrik Rydgård 1bd5cffa1d Initial work on re-implementing atrac-through-sas 2025-03-25 22:01:30 +01:00
Henrik Rydgård eb251af964 Create decodeTemp_ on demand. Fixes #20150 2025-03-25 00:30:31 +01:00
Henrik Rydgård 3e15d97be8 New atrac: A safety check in DecodeInternal 2025-03-25 00:01:55 +01:00
Henrik Rydgård 0f840e6240 Move JPEG error codes to the big enum, some include cleanup 2025-03-21 20:44:46 +01:00
Henrik Rydgård e3297d84f5 Fix pointer incrementes with low level decoder 2025-03-20 13:30:49 +01:00
Henrik Rydgård 0aec6aeddd Fix silly logic error in Atrac2 2025-03-19 18:17:47 +01:00
Henrik Rydgård e70dd3b2df Break out AtracTrack into its own file. Add a little atrac analysis tool to ImDebugger (for future use) 2025-03-19 16:15:51 +01:00
Henrik Rydgård eff9bd1fc3 mpeg: Minor cleanup 2025-03-19 11:41:17 +01:00
Henrik Rydgård ec169e9fa9 Sol Trigger fix 2025-03-19 11:41:13 +01:00
Henrik Rydgård da2b3fdd13 Warning fixes. Don't clamp readsize to reported file size. 2025-03-19 10:42:32 +01:00
Henrik Rydgård c5ad1548bc Add simple AT3 dumping (non-streaming only) 2025-03-19 10:42:32 +01:00
Henrik Rydgård 6d7625ea6b Implement save state support, with backwards compatibility. 2025-03-18 09:36:33 +01:00
Henrik Rydgård 89a73be155 Compute the joint-stereo flag as needed instead of storing it. 2025-03-18 09:36:33 +01:00
Henrik Rydgård 01076d2a4f InitLowLevel parameter cleanup 2025-03-18 09:36:33 +01:00
Henrik Rydgård 4a4332b22e Remove hack where we snuck AtracID into the contexts. Not suppose to be there. 2025-03-18 09:36:33 +01:00
Henrik Rydgård 34c21ed271 track_ removal, part 2 - done! 2025-03-18 09:36:33 +01:00
Henrik Rydgård 02f06faad1 Atrac2 track_ removal, part 1 2025-03-18 09:36:33 +01:00
Henrik Rydgård 5363159610 Error return fixes 2025-03-18 09:36:33 +01:00
Henrik Rydgård 4379c1ad49 Rebase fixups 2025-03-18 09:36:33 +01:00
Henrik Rydgård bb436cda8f Reimplement a lot of logic, implement loop streaming properly 2025-03-18 09:36:33 +01:00
Henrik Rydgård b99348383c Some new findings, loop work 2025-03-18 09:36:33 +01:00
Henrik Rydgård 4d7a8b8233 Some type and comment cleanup 2025-03-18 09:36:33 +01:00