Difference between revisions of "SceSdstor"

From Vita Development Wiki
Jump to navigation Jump to search
Line 72: Line 72:
 
typedef struct sd_stor_device //size is 0x54
 
typedef struct sd_stor_device //size is 0x54
 
{
 
{
   uint32_t unk_0;
+
   uint32_t fast_mutex_SceSdStorDevice;
 
   uint32_t unk_4;
 
   uint32_t unk_4;
 
   uint32_t unk_8;
 
   uint32_t unk_8;

Revision as of 14:42, 28 February 2017

Module

SceSdstor module does not export any functions exсept module_start.

This module is responsible for initializing all storage devices. This includes:

Based on layout of data segment and code of some subroutines (mbr table init, partition entry table init etc) it can be said that there are 5 devices in total. However only first 3 devices are known at the moment.

Known NIDs

Version Name World Privilege NID
1.69 SceSdstor Non-secure Kernel 0x5804A397
3.60 SceSdstor ? Kernel 0xD7FBAE7C

Libraries

Known NIDs

Version Name World Visibility NID

Types

typedef struct partition_entry //size is 0x1C
{
   uint32_t partitionOffset; //from MBR
   uint32_t partitionSize; //from MBR
   sdstor_mbr_ctx* ctx;
   void* partitionEntryPtr; //pointer to partition entry in MBR
   char numericName[4]; //null terminated name (000, 001, ...)
   uint32_t flags1; //from MBR
   uint16_t unk2;  //from MBR
   uint16_t unk3; //?
}partition_entry;

typedef struct sdstor_mbr_ctx //size is 0x238
{
 uint32_t fast_mutex_SceSdStorPartitionTable;
 uint32_t unk_4;
 uint32_t unk_8;
 uint32_t unk_C;

 uint8_t unk_0[0x30];

 uint32_t unk_40;
 sd_stor_device* unk_44;
 uint32_t unk_48;
 uint32_t unk_4C;

 uint32_t unk_50;
 void* mbr_ptr; //pointer to corresponding MBR record in array (offset 0x40)
 partition_entry partitions[17]; // 16 real partition entries from MBR + some hardcoded 17th partition entry
 uint8_t unk_234; //some initialization flag (0, 1, 2)
 uint8_t unk_235;
 uint8_t unk_236; //some initialization flag (set to 0 if partition table is initialized)
 uint8_t unk_237;
}sdstor_mbr_ctx;

//named after "SceSdStorDevice" mutex
typedef struct sd_stor_device //size is 0x54
{
   uint32_t fast_mutex_SceSdStorDevice;
   uint32_t unk_4;
   uint32_t unk_8;
   uint32_t unk_C;
   
   uint32_t unk_10;
   uint32_t unk_14;
   uint32_t unk_18;
   uint32_t unk_1C;
   
   uint32_t unk_20;
   uint32_t unk_24;
   uint32_t unk_28;
   uint32_t unk_2C;
   
   uint32_t unk_30;
   uint32_t unk_34;
   uint32_t unk_38;
   uint32_t unk_3C;
   
   char index1; // (0x00, 0x01, 0xFF, 0xFF, 0x03) // sd ctx index ?
   char index2; // (0x00, 0x00, 0x02, 0x03, 0x01) // device type idx ?
   char unk_42;
   char unk_43;
   
   uint32_t unk_44;
   uint32_t unk_48;
   uint32_t unk_4C;
   
   void* devCtx; //pointer to dev ctx (sd_context_part_mmc*) or zero
}sd_stor_device;

//named after SceSdStorDeviceHandle mutex and pool
typedef struct sd_stor_device_handle //size is 0x58
{
   uint32_t fast_mutex_SceSdStorDeviceHandle;
   uint32_t unk_4;
   uint32_t unk_8;
   uint32_t unk_C;
   
   uint32_t unk_10;
   uint32_t unk_14;
   uint32_t unk_18;
   uint32_t unk_1C;
   
   uint32_t unk_20;
   uint32_t unk_24;
   uint32_t unk_28;
   uint32_t unk_2C;
   
   uint32_t unk_30;
   uint32_t unk_34;
   uint32_t unk_38;
   uint32_t unk_3C;

   uint32_t unk_40;
   uint32_t partitionOffset;
   uint32_t partitionSize;
   uint32_t unk_4C;

   partition_entry* pentry;
   sd_stor_device* dev;
}sd_stor_device_handle;

Data segment layout

Address Size Description
0x0000 0x20 unknown
0x0020 0x14 array of 5 integers (number of visible partitions that have filesystem) (each corresponds to sd_stor_device)
0x0034 0x4 unknown
0x0038 0x4 SceSdStorDeviceHandle mempool SceUID of size 0x2000
0x003C 0x4 unknown
0x0040 0x200 MBR of eMMC
0x0240 0x200 MBR of Game gard
0x0440 0x200 MBR of Memory card
0x0640 0x200 unknown (most likely for MBR since there are 5 elements in all arrays)
0x0840 0x200 unknown (most likely for MBR since there are 5 elements in all arrays)
0x0A40 0x238 sdstor_mbr_ctx element 0
0x0C78 0x238 sdstor_mbr_ctx element 1
0x0EB0 0x238 sdstor_mbr_ctx element 2
0x10E8 0x238 sdstor_mbr_ctx element 3
0x1320 0x238 sdstor_mbr_ctx element 4
0x1558 0x54 sd_stor_device element 0
0x15AC 0x54 sd_stor_device element 1
0x1600 0x54 sd_stor_device element 2
0x1654 0x54 sd_stor_device element 3
0x16A8 0x54 sd_stor_device element 4
0x16FC 0x20 vfs_add_data sdstor_dev_fs node
0x171C 0x04 SceSdStorVfs mempool SceUID of size 0x2000
0x1720 0x200 unknown
0x1920 0x200 unknown
0x1B20 0xC8 array of 5 structures of size 0x28
0x1BE8 0x8 suspend_register_callback opt
0x1BF0 0x3C array of 5 structures of size 0xC
0x1C2C 0x8C array of 5 structures of size 0x1C
0x1CB8 0x8 unknown
0x1CC0 0x200 MBR of Game gard

SceSdstor

module_start

Version NID
3.60 0x935cd196
int module_start();