Example #1
0
        public static PackageTestResult IsArk(IFile fn)
        {
            if (!fn.Name.ToLower().EndsWith(".hdr") && !fn.Name.ToLower().EndsWith(".ark"))
            {
                return(PackageTestResult.NO);
            }

            using (Stream s = fn.GetStream())
            {
                s.Position = 0;
                uint version = s.ReadUInt32LE();
                if (version == ARK) // header from Frequency
                {
                    return(PackageTestResult.YES);
                }
                if (version > HIGHEST_VERSION)
                {
                    // hdr is encrypted, probably
                    using (var decryptor = new HdrCryptStream(s))
                    {
                        version = decryptor.ReadUInt32LE();
                    }
                    if (version == 0xFFFFFFF5)
                    {
                        version = 10;
                    }
                    else if (version == 0xFFFFFFF6)
                    {
                        version = 9;
                    }
                    else if (version == 0xFFFFFFF7)
                    {
                        version = 8;                   // Hopefully?
                    }
                }
                return(version <= HIGHEST_VERSION &&
                       version >= LOWEST_VERSION ? PackageTestResult.MAYBE : PackageTestResult.NO);
            }
        }
Example #2
0
 public static PackageTestResult IsArk(IFile fn)
 {
     using (Stream s = fn.GetStream())
     {
         s.Position = 0;
         uint version = s.ReadUInt32LE();
         if (version == ARK) // header from Frequency
         {
             return(PackageTestResult.YES);
         }
         if (version > HIGHEST_VERSION)
         {
             // hdr is encrypted, probably
             using (var decryptor = new HdrCryptStream(s))
             {
                 version = decryptor.ReadUInt32LE();
             }
         }
         return(version <= HIGHEST_VERSION &&
                version >= LOWEST_VERSION ? PackageTestResult.MAYBE : PackageTestResult.NO);
     }
 }