Advertisement
xerpi

rmauth_sm.self test

Jun 24th, 2018
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.44 KB | None | 0 0
  1. #define SCE_KERNEL_SYSROOT_SELF_INDEX_RMAUTH_SM 1
  2.  
  3. typedef struct SceSblSmCommContext130 {
  4.     uint32_t unk_0;
  5.     uint32_t self_type; // 2 - user = 1 / kernel = 0
  6.     char data0[0x90]; //hardcoded data
  7.     char data1[0x90];
  8.     uint32_t pathId; // 2 (2 = os0)
  9.     uint32_t unk_12C;
  10. } SceSblSmCommContext130;
  11.  
  12. typedef struct SceSblSmCommPair {
  13.     uint32_t unk_0;
  14.     uint32_t unk_4;
  15. } SceSblSmCommPair;
  16.  
  17. typedef struct SceSblSmCommMsifData {
  18.     unsigned int unk00;
  19.     unsigned int unk04;
  20.     unsigned int unk08;
  21.     unsigned int unk0C;
  22.     unsigned int unk10;
  23.     unsigned int unk14;
  24.     unsigned int unk18;
  25.     unsigned int unk1C;
  26. } SceSblSmCommMsifData;
  27.  
  28. extern int ksceSblSmCommStartSmFromData(int priority, const char *elf_data, int elf_size, int num1, SceSblSmCommContext130 *ctx, int *id);
  29. extern int ksceSblSmCommStopSm(int id, SceSblSmCommPair *res);
  30. extern int ksceSblSmCommCallFunc(int id, int command_id, int *f00d_resp, void *data, int size);
  31.  
  32. static const unsigned char ctx_130_data[0x90] =
  33. {
  34.     0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x28, 0x00, 0x00,
  35.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
  36.     0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
  37.     0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  38.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x09,
  39.     0x80, 0x03, 0x00, 0x00, 0xC3, 0x00, 0x00, 0x00, 0x80, 0x09,
  40.     0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  41.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
  42.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  43.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  44.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  45.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  46.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  47.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  48.     0x00, 0x00, 0x00, 0x00
  49. };
  50.  
  51. static int sblcomm_start_rmauth_sm(int *rmauth_sm_id)
  52. {
  53.     int ret;
  54.     SceKernelSysrootSelfInfo self_info;
  55.     SceSblSmCommContext130 smcomm_ctx;
  56.  
  57.     memset(&self_info, 0, sizeof(self_info));
  58.     self_info.size = sizeof(self_info);
  59.  
  60.     ret = ksceSysrootGetSelfInfo(SCE_KERNEL_SYSROOT_SELF_INDEX_RMAUTH_SM, &self_info);
  61.     if (ret < 0)
  62.         return ret;
  63.  
  64.     memset(&smcomm_ctx, 0, sizeof(smcomm_ctx));
  65.     memcpy(smcomm_ctx.data0, ctx_130_data, 0x90);
  66.     smcomm_ctx.pathId = 2;
  67.     smcomm_ctx.self_type = (smcomm_ctx.self_type & 0xFFFFFFF0) | 2;
  68.  
  69.     ret = ksceSblSmCommStartSmFromData(0, self_info.self_data,
  70.                        self_info.self_size, 0,
  71.                        &smcomm_ctx, rmauth_sm_id);
  72.     if (ret < 0)
  73.         return ret;
  74.  
  75.     return 0;
  76. }
  77.  
  78. static int f00d_rmauth_sm_cmd_1(int *res)
  79. {
  80.     int ret;
  81.     int rmauth_sm_id;
  82.     int f00d_resp;
  83.         SceSblSmCommPair stop_res;
  84.         SceSblSmCommMsifData data;
  85.  
  86.     ret = sblcomm_start_rmauth_sm(&rmauth_sm_id);
  87.     if (ret < 0)
  88.         return ret;
  89.  
  90.     ret = ksceSblSmCommCallFunc(rmauth_sm_id, 1, &f00d_resp, &data, 0x20);
  91.     if (ret < 0)
  92.         return ret;
  93.  
  94.     ret = ksceSblSmCommStopSm(rmauth_sm_id, &stop_res);
  95.     if (ret < 0)
  96.         return ret;
  97.  
  98.     *res = data.unk10;
  99.  
  100.     return f00d_resp;
  101. }
  102.  
  103. static int f00d_rmauth_sm_cmd_2(uint32_t seed[8])
  104. {
  105.     int ret;
  106.     int rmauth_sm_id;
  107.     int f00d_resp;
  108.         SceSblSmCommPair stop_res;
  109.  
  110.     ret = sblcomm_start_rmauth_sm(&rmauth_sm_id);
  111.     if (ret < 0)
  112.         return ret;
  113.  
  114.     ret = ksceSblSmCommCallFunc(rmauth_sm_id, 2, &f00d_resp, seed, 0x20);
  115.     if (ret < 0)
  116.         return ret;
  117.  
  118.     ret = ksceSblSmCommStopSm(rmauth_sm_id, &stop_res);
  119.     if (ret < 0)
  120.         return ret;
  121.  
  122.     return f00d_resp;
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement