Exemplo n.º 1
0
 /// <summary>Find <c>dataOffset</c>, <c>idxOffset</c>, and <c>idxSize</c></summary>
 private void findOffsets()
 {
     try
     {
         var     parser = new ISOFile();
         ISONode node;
         iso.Position = 0;
         parser.Parse(iso);
         if (parser.Root.Children.TryGetValue("SYSTEM.CNF;1", out node))
         {
             dataOffset = node.Offset * 2048;
         }
         if (parser.Root.Children.TryGetValue("KINGDOM.IDX;1", out node))
         {
             idxOffset = node.Offset * 2048;
             idxSize   = node.Length;
         }
         if (dataOffset != 0 && idxOffset != 0)
         {
             return;
         }
     }
     catch (Exception e)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("KH1ISOReader:findOffsets: Error while reading ISO, trying fallback! ({0})", e.Message);
         Console.ResetColor();
     }
     if (dataOffset == 0)
     {
         iso.Position = 0;
         do
         {
             if (br.ReadUInt64() == 0x203D2032544F4F42) //BOOT2 =
             {
                 dataOffset = iso.Position - 8;
                 break;
             }
         } while ((iso.Position += 2040) < iso.Length);
     }
     if (idxOffset == 0)
     {
         iso.Position = dataOffset;
         do
         {
             if (br.ReadUInt64() == 0x000000010000171D) //First Hash of the IDX + first flag
             {
                 idxOffset     = iso.Position - 8;
                 iso.Position += 8;
                 do
                 {
                     if (br.ReadUInt32() == 0x0393eba4) //Finding the size by looking into the idx
                     {
                         iso.Position += 8;
                         idxSize       = br.ReadUInt32();
                         break;
                     }
                 } while ((iso.Position += 12) < iso.Length);
                 break;
             }
         } while ((iso.Position += 2040) < iso.Length);
     }
 }
Exemplo n.º 2
0
 /// <summary>Find <c>dataOffset</c>, <c>idxOffset</c>, and <c>idxSize</c></summary>
 private void findOffsets()
 {
     try
     {
         var parser = new ISOFile();
         ISONode node;
         iso.Position = 0;
         parser.Parse(iso);
         if (parser.Root.Children.TryGetValue("SYSTEM.CNF;1", out node))
         {
             dataOffset = node.Offset*2048;
         }
         if (parser.Root.Children.TryGetValue("KINGDOM.IDX;1", out node))
         {
             idxOffset = node.Offset*2048;
             idxSize = node.Length;
         }
         if (dataOffset != 0 && idxOffset != 0)
         {
             return;
         }
     }
     catch (Exception e)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("KH1ISOReader:findOffsets: Error while reading ISO, trying fallback! ({0})", e.Message);
         Console.ResetColor();
     }
     if (dataOffset == 0)
     {
         iso.Position = 0;
         do
         {
             if (br.ReadUInt64() == 0x203D2032544F4F42) //BOOT2 =
             {
                 dataOffset = iso.Position - 8;
                 break;
             }
         } while ((iso.Position += 2040) < iso.Length);
     }
     if (idxOffset == 0)
     {
         iso.Position = dataOffset;
         do
         {
             if (br.ReadUInt64() == 0x000000010000171D) //First Hash of the IDX + first flag
             {
                 idxOffset = iso.Position - 8;
                 iso.Position += 8;
                 do
                 {
                     if (br.ReadUInt32() == 0x0393eba4) //Finding the size by looking into the idx
                     {
                         iso.Position += 8;
                         idxSize = br.ReadUInt32();
                         break;
                     }
                 } while ((iso.Position += 12) < iso.Length);
                 break;
             }
         } while ((iso.Position += 2040) < iso.Length);
     }
 }