Guest User

Untitled

a guest
Dec 7th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. TMD::TMD( u64 TitleID )
  2. {
  3.     if(TitleID)
  4.     {
  5.         static fstats stats ATTRIBUTE_ALIGN(32);
  6.        
  7.         u32 high = (u32)(TitleID >> 32);
  8.         u32 low  = (u32)(TitleID & 0xFFFFFFFF);
  9.        
  10.         s32 fd = ISFS_Open(fmt("/title/%08x/%08x/content/title.tmd", high, low), ISFS_OPEN_READ);
  11.         if (fd >= 0)
  12.         {
  13.             if (ISFS_GetFileStats(fd, &stats) >= 0)
  14.             {
  15.                 u32* data = NULL;
  16.                
  17.                 if (stats.file_length > 0)
  18.                     data = (u32*)memalign(32, RU(stats.file_length, 32));
  19.                
  20.                 if (data)
  21.                 {
  22.                     if (ISFS_Read(fd, (char*)data, stats.file_length) > 4)
  23.                     {
  24.                         p_tmd = (tmd *) SIGNATURE_PAYLOAD(data);
  25.                        
  26.                         gprintf("\n\tGID: %u", p_tmd->group_id);
  27.                     }
  28.                     free(data);
  29.                 }
  30.             }
  31.             ISFS_Close(fd);
  32.         }
  33.     }
  34. }
  35.  
  36. TMD::~TMD()
  37. {
  38. }
  39.  
  40. u16 TMD::GetGroupID()
  41. {
  42.     if( !p_tmd )
  43.         return 0;
  44.     return p_tmd->group_id;
  45. }
  46.  
  47. ///HFILE:
  48.  
  49. class TMD
  50. {
  51. public:
  52.     TMD( u64 TitleID = 0 );
  53.     ~TMD();
  54.  
  55.     //!expose the tmd data to the rest of the code so it can read directly from the p_tmd instead of having to add a function to access all the data
  56.     //!the pointer should be good until "data" is changed
  57.     const tmd *payload(){ return p_tmd; }
  58.  
  59.     u16 GetGroupID();
  60.  
  61. private:
  62.     tmd *p_tmd;
  63. }
Add Comment
Please, Sign In to add comment