Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Technique:SCE NID imports and exports

From ReverseEngineering.wiki
Technique
On this wiki Facts · Code · Notes · Topics

How Sony console modules (PSP PRX, PS3 SPRX/SELF, PS Vita velf) refer to library functions by 32-bit NID instead of by name: the NID of a name is the first 4 bytes of a SHA-1 digest, imports are stub tables of NIDs resolved by the loader against export tables, and names must be recovered from public NID databases.

Overview

Sony SDKs from the PSP onward link against stub libraries that contain no code, only a library name and a list of function NIDs (and variable NIDs). The executable stores the NIDs; the system loader resolves each against the export table of the module that provides the library. A stripped binary therefore shows sceKernelCreateThread only as a number.

Computing a NID

  • PSP: the NID of a function or variable is the first 4 bytes of SHA-1(name) read as a little-endian u32 (pspsdk psp-build-exports.c). Module-defined (user) names hashed the same way; system entry points such as module_start have fixed NIDs in the syslib export.
  • PS3: RPCS3 ppu_generate_id hashes the name followed by a fixed 16-byte suffix and reads the first 4 bytes of the digest as little-endian u32 (see Format:SCE SELF (PS3 and PS Vita)).
  • PS Vita: names come from NID database files (vita-toolchain nid_db yml: modules, libraries with their own library NID, functions and variables with NID values); the NID is also stored for each library and module.

Tables

See Format:PRX (PSP module) (.lib.stub, .lib.ent, .rodata.sceNid), Format:SCE SELF (PS3 and PS Vita) (.lib.stub, .rodata.sceFNID) and Format:PS Vita module info.

Recovering names

With a hash function you can confirm a guessed name; to name unknown NIDs you need a database of known names (vitasdk nid yml files, pspsdk exports .exp files, PSL1GHT and RPCS3 name tables). Marking a NID as hashed from a guessed name proves nothing without a second source.

Pitfalls

  • NIDs of different consoles are not interchangeable even for the same-named function.
  • Collisions of 32-bit NIDs are possible; check the library name as well.

Code & repositories

Platform:PlayStation Portable, Platform:PlayStation 3, Platform:PlayStation Vita.