Ejemplo n.º 1
0
        private static List <SKUCheckData> GetSKUCheckData(bool reversed, ref byte[] data, ref Common.TypeData checkdata)
        {
            var ret = new List <SKUCheckData>();

            foreach (var skuDataEntry in checkdata.SKUDataList.Value)
            {
                var skuCheckDataEntry = new SKUCheckData
                {
                    Type = skuDataEntry.Type
                };
                var tmpdata = new byte[skuDataEntry.Size];
                Buffer.BlockCopy(data, (int)skuDataEntry.Offset, tmpdata, 0, tmpdata.Length);
                if (reversed)
                {
                    if (skuDataEntry.Size == 1)
                    {
                        if ((skuDataEntry.Offset % 2) == 0)
                        {
                            if (data.Length < skuDataEntry.Offset + 1)
                            {
                                Logger.WriteLine2("FAILED! Offset is at end of image!");
                                tmpdata[0] = 0;
                            }
                            else
                            {
                                tmpdata[0] = data[skuDataEntry.Offset + 1];
                            }
                        }
                        else
                        {
                            tmpdata[0] = data[skuDataEntry.Offset - 1];
                        }
                    }
                    else
                    {
                        Common.SwapBytes(ref tmpdata);
                    }
                }
                if (skuDataEntry.Type.Equals("bootldrsize", StringComparison.CurrentCultureIgnoreCase))
                {
                    if (tmpdata.Length == 2)
                    {
                        skuCheckDataEntry.Size = Common.GetLdrSize(ref tmpdata);
                    }
                    else
                    {
                        throw new ArgumentException("The bootloader argument size should be 2");
                    }
                }
                else
                {
                    skuCheckDataEntry.Data = Common.GetDataForTest(tmpdata);
                }
                ret.Add(skuCheckDataEntry);
            }
            return(ret);
        }
Ejemplo n.º 2
0
 private static List<SKUCheckData> GetSKUCheckData(bool reversed, ref byte[] data, ref Common.TypeData checkdata)
 {
     var ret = new List<SKUCheckData>();
     foreach (var skuDataEntry in checkdata.SKUDataList.Value)
     {
         var skuCheckDataEntry = new SKUCheckData
         {
             Type = skuDataEntry.Type
         };
         var tmpdata = new byte[skuDataEntry.Size];
         Buffer.BlockCopy(data, (int)skuDataEntry.Offset, tmpdata, 0, tmpdata.Length);
         if (reversed)
         {
             if (skuDataEntry.Size == 1)
             {
                 if ((skuDataEntry.Offset % 2) == 0)
                 {
                     if (data.Length < skuDataEntry.Offset + 1)
                     {
                         Logger.WriteLine2("FAILED! Offset is at end of image!");
                         tmpdata[0] = 0;
                     }
                     else
                         tmpdata[0] = data[skuDataEntry.Offset + 1];
                 }
                 else
                     tmpdata[0] = data[skuDataEntry.Offset - 1];
             }
             else
                 Common.SwapBytes(ref tmpdata);
         }
         if (skuDataEntry.Type.Equals("bootldrsize", StringComparison.CurrentCultureIgnoreCase))
         {
             if (tmpdata.Length == 2)
                 skuCheckDataEntry.Size = Common.GetLdrSize(ref tmpdata);
             else
                 throw new ArgumentException("The bootloader argument size should be 2");
         }
         else
             skuCheckDataEntry.Data = Common.GetDataForTest(tmpdata);
         ret.Add(skuCheckDataEntry);
     }
     return ret;
 }
Ejemplo n.º 3
0
 private static List<Common.SKUEntry> GetFilterList(IEnumerable<Common.SKUEntry> skuEntryList, SKUCheckData dataEntry)
 {
     var ret = new List<Common.SKUEntry>();
     foreach (var skuEntry in skuEntryList)
     {
         if (!skuEntry.Type.Equals(dataEntry.Type, StringComparison.CurrentCultureIgnoreCase))
             continue;
         bool isok;
         if (dataEntry.Type.Equals("bootldrsize", StringComparison.CurrentCultureIgnoreCase))
         {
             uint tmpval;
             if (uint.TryParse(skuEntry.Data, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out tmpval))
                 isok = tmpval == dataEntry.Size;
             else isok = false;
         }
         else
             isok = dataEntry.Data.Equals(skuEntry.Data, StringComparison.CurrentCultureIgnoreCase);
         if (isok)
             ret.Add(skuEntry);
     }
     return ret;
 }
Ejemplo n.º 4
0
        private static List <Common.SKUEntry> GetFilterList(IEnumerable <Common.SKUEntry> skuEntryList, SKUCheckData dataEntry)
        {
            var ret = new List <Common.SKUEntry>();

            foreach (var skuEntry in skuEntryList)
            {
                if (!skuEntry.Type.Equals(dataEntry.Type, StringComparison.CurrentCultureIgnoreCase))
                {
                    continue;
                }
                bool isok;
                if (dataEntry.Type.Equals("bootldrsize", StringComparison.CurrentCultureIgnoreCase))
                {
                    uint tmpval;
                    if (uint.TryParse(skuEntry.Data, NumberStyles.HexNumber, CultureInfo.CurrentCulture, out tmpval))
                    {
                        isok = tmpval == dataEntry.Size;
                    }
                    else
                    {
                        isok = false;
                    }
                }
                else
                {
                    isok = dataEntry.Data.Equals(skuEntry.Data, StringComparison.CurrentCultureIgnoreCase);
                }
                if (isok)
                {
                    ret.Add(skuEntry);
                }
            }
            return(ret);
        }