private void parse(File tmd) throws IOException {
  RandomAccessFile f=new RandomAccessFile(tmd,"r");
  f.seek(0);
  this.signatureType=f.readInt();
  f.read(signature,0,0x100);
  f.seek(0x140);
  f.read(issuer,0,0x40);
  f.seek(0x180);
  this.version=f.readByte();
  this.CACRLVersion=f.readByte();
  this.signerCRLVersion=f.readByte();
  f.seek(0x184);
  this.systemVersion=f.readLong();
  this.titleID=f.readLong();
  this.titleType=f.readInt();
  this.groupID=f.readShort();
  f.seek(0x19A);
  f.read(reserved,0,62);
  f.seek(0x1D8);
  this.accessRights=f.readInt();
  this.titleVersion=f.readShort();
  this.contentCount=f.readShort();
  this.bootIndex=f.readShort();
  f.seek(0x1E4);
  f.read(SHA2,0,32);
  f.seek(0x204);
  short indexOffset;
  short commandCount;
  for (int i=0; i < 64; i++) {
    f.seek(0x204 + (0x24 * i));
    indexOffset=f.readShort();
    commandCount=f.readShort();
    byte[] buffer=new byte[0x20];
    f.read(buffer,0,0x20);
    this.contentInfos[i]=new ContentInfo(indexOffset,commandCount,buffer);
  }
  this.contents=new Content[contentCount];
  int ID;
  short index;
  short type;
  long size;
  for (int i=0; i < contentCount; i++) {
    f.seek(0xB04 + (0x30 * i));
    ID=f.readInt();
    index=f.readShort();
    type=f.readShort();
    size=f.readLong();
    byte[] buffer=new byte[0x20];
    f.read(buffer,0,0x20);
    this.contents[i]=new Content(ID,index,type,size,buffer,this);
  }
  if (f.read(cert2,0,0x300) != 0x300) {
    Logger.log("Error reading TMD cert2");
  }
  if (f.read(cert1,0,0x400) != 0x400) {
    Logger.log("Error reading TMD cert1");
  }
  f.close();
}

private void parse ( File tmd ) throws IOException { RandomAccessFile f = new RandomAccessFile ( tmd , "r" ) ; f . seek ( 0 ) ; this . signatureType = f . readInt ( ) ; f . read ( signature , 0 , 0x100 ) ; f . seek ( 0x140 ) ; f . read ( issuer , 0 , 0x40 ) ; f . seek ( 0x180 ) ; this . version = f . readByte ( ) ; this . CACRLVersion = f . readByte ( ) ; this . signerCRLVersion = f . readByte ( ) ; f . seek ( 0x184 ) ; this . systemVersion = f . readLong ( ) ; this . titleID = f . readLong ( ) ; this . titleType = f . readInt ( ) ; this . groupID = f . readShort ( ) ; f . seek ( 0x19A ) ; f . read ( reserved , 0 , 62 ) ; f . seek ( 0x1D8 ) ; this . accessRights = f . readInt ( ) ; this . titleVersion = f . readShort ( ) ; this . contentCount = f . readShort ( ) ; this . bootIndex = f . readShort ( ) ; f . seek ( 0x1E4 ) ; f . read ( SHA2 , 0 , 32 ) ; f . seek ( 0x204 ) ; short indexOffset ; short commandCount ; for ( int i = 0 ; i < 64 ; i ++ ) { f . seek ( 0x204 + ( 0x24 * i ) ) ; indexOffset = f . readShort ( ) ; commandCount = f . readShort ( ) ; byte [ ] buffer = new byte [ 0x20 ] ; f . read ( buffer , 0 , 0x20 ) ; this . contentInfos [ i ] = new ContentInfo ( indexOffset , commandCount , buffer ) ; } this . contents = new Content [ contentCount ] ; int ID ; short index ; short type ; long size ; for ( int i = 0 ; i < contentCount ; i ++ ) { f . seek ( 0xB04 + ( 0x30 * i ) ) ; ID = f . readInt ( ) ; index = f . readShort ( ) ; type = f . readShort ( ) ; size = f . readLong ( ) ; byte [ ] buffer = new byte [ 0x20 ] ; f . read ( buffer , 0 , 0x20 ) ; this . contents [ i ] = new Content ( ID , index , type , size , buffer , this ) ; } if ( f . read ( cert2 , 0 , 0x300 ) != 0x300 ) { Logger . log ( "Error reading TMD cert2" ) ; } if ( f . read ( cert1 , 0 , 0x400 ) != 0x400 ) { Logger . log ( "Error reading TMD cert1" ) ; } f . close ( ) ; }
parses a tmd file
