Commit Graph
26 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 52299a5e17 Savestate: Save sceDmac and sceUsbCam, which were never called, and NpDrm
__DmacDoState and __UsbCamDoState existed but weren't in the module list,
so the memcpy deadline and camera state carried over from before a load.
The NpDrm licensee key wasn't saved or reset at all, so EDATA opened after
a load in a fresh session couldn't be decrypted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 11:32:07 -06:00
Henrik RydgårdandClaude Opus 5 f9bd5682db libkirk: let C++ callers include its headers directly
kirk_engine.h and amctrl.h guard their declarations, but AES.h and SHA1.h
never did, and kirk_engine.h includes them from outside its own guard. So the
AES_* and SHA1* functions got C++ linkage in any C++ file that reached them
through there, and only linked for callers that happened to wrap the whole
header in an extern "C" of their own. Nothing had called AES_* from C++
before, so it stayed hidden until something did.

Guarding the two headers instead lets every caller include them plainly, and
the wrappers scattered around the tree come out. Both are pure declarations
over kirk_common.h's typedefs with no system headers behind them, so there's
nothing in there that shouldn't be wrapped.

kirk_engine.h also uses size_t without including anything that defines it,
which only held together because its includers happened to have it already.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 11:15:15 -06:00
Henrik RydgårdandClaude Opus 5 19723f59eb Decrypt the NPDRM modules a PKG game update installs
A .sprx from one of these packages is an NPDRM "\0PSPEDAT" container: a
0x90-byte header, then an ordinary ~PSP PRX. The loader only ever saw the
EDAT magic and gave up with SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE.

Step over the header, then derive the key the PRX inside is really
encrypted against: sceNpDrmGetFixedKey() over the content ID, XOR in the
licensee key the game handed us through sceNpDrmSetLicenseeKey(), then AES
under a module key that had to be added. Both halves of that were already
lying around unused - sceNpDrmGetFixedKey() had no callers at all, and the
licensee key was being kept and never read.

The rest of it is a fixed XOR that the PRX header's decrypt_mode selects
rather than its tag, so it's applied on the mode the way JPCSP does it and
the tag table is left alone - tag 0x407810F0 carries no seed of its own
there either, so ours was never wrong about it. pspDecryptType5() already
had a slot for both XORs; no new decryption logic was needed.

Decryption is only half of it: these modules are KL4E-compressed rather
than gzipped, so they also need Core/Util/KL4E.cpp, which is already there
for the firmware modules that use the same compression. With both halves
Shiren 4 Plus loads its one big .sprx and runs. God Eater 2 needed one
further fix that isn't in this commit - the type-B relocation bug in
ElfReader::LoadRelocations2, issue #8075 - and then plays.

docs/pkg_notes.md has the container layout and the key derivation.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 11:15:15 -06:00
Henrik Rydgård 827430e1b1 sceNpDrmEdataSetupKey: Only check that the key has been set if the file is encrypted. Fixes Wipeout Pulse DLC.
Fixes #21335
2026-03-04 11:23:59 +01:00
Henrik Rydgård 5dbfa420d5 Merge pull request #21190 from sonninnos/libretro-drm-key
Libretro: NpDrm LicenseeKey check band-aid
2026-02-03 11:42:17 +01:00
sonninnos 7fcd48fca3 Libretro: NpDrm LicenseeKey check band-aid 2026-02-03 00:10:10 +02:00
Henrik Rydgård a591fbff38 Move two more error codes to the enum 2026-01-08 22:02:08 +01:00
sum2012 dbf10eee3d Update sceNpDrmSetLicensee* function
by minimax AI by JPCSP
Some process for #16238
2025-11-09 07:11:29 +08:00
Henrik Rydgård 4e25f44eef Rename some module-related functions to include HLE where appropriate 2025-03-31 11:17:50 +02:00
Henrik Rydgård 28b2c7f540 HLE log rename part 1: Remove duplicate log functions. Return type should be determined by metadata. 2025-01-29 09:45:39 +01:00
Henrik Rydgård ba6a9119fc Minor logging fixes 2025-01-28 09:29:01 +01:00
Henrik Rydgård 3dc46666ff Fix logging problem in npdrm functions 2025-01-23 14:25:05 +01:00
Henrik Rydgård 5abb1be440 Some more logging cleanup 2025-01-21 17:33:59 +01:00
Henrik Rydgård 2a924ff4df Logging fixes, buildfix on some systems 2025-01-21 12:55:32 +01:00
Henrik Rydgård 2e53d2f9f9 NPDRM: Logging cleanup, remove assert (turn into debug assert) 2024-11-01 20:10:23 +01: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 c5e0dafa44 Fix "double delay" error in sceNpDrmEdataSetupKey 2023-05-25 10:02:52 +02:00
Unknown W. Brackets fcf0518223 Update all the HLE tables with arg and ret info. 2015-03-22 20:51:55 -07:00
Lioncash 4ccb838306 Core: Mark some module functions as static 2014-12-08 04:40:08 -05:00
Unknown W. Brackets 05ab192c9c Reduce includes in Core/HLE/.
Especially templates.
2014-03-15 11:22:19 -07:00
The Dax 0f59767984 Add SceNpDrmOpen to the table so it can be logged properly. 2013-08-14 09:23:58 -04:00
tpu 40926e5d5b make sceKernelLoadModuleNpDrm works. sprx can be load now. 2013-05-29 10:39:28 +08:00
tpu 641b78ab67 add DLC support 2013-04-20 13:51:40 +08:00
Henrik Rydgard f355137156 Update native. some stubs and a buildfix. 2013-03-21 20:24:47 +01:00
Henrik Rydgard 3714eebbbe Actually register scePspNpDrm_user 2013-03-04 23:54:03 +01:00
vakko 02371b2949 DLC encryption 2013-02-24 19:27:37 +02:00