Example #1
0
        private bool ReadTableFromOffset(ulong offset)
        {
            bool result;

            try
            {
                if (this._fileBytes[(int)((IntPtr)(checked ((long)offset)))] == 13)
                {
                    ushort num  = (ushort)(this.ConvertToULong((int)offset + 3, 2) - 1UL);
                    int    num2 = 0;
                    if (this._tableEntries != null)
                    {
                        num2 = this._tableEntries.Length;
                        Array.Resize <Decod.TableEntry>(ref this._tableEntries, this._tableEntries.Length + (int)num + 1);
                    }
                    else
                    {
                        this._tableEntries = new Decod.TableEntry[(int)(num + 1)];
                    }
                    for (ushort num3 = 0; num3 <= num; num3 += 1)
                    {
                        ulong num4 = this.ConvertToULong((int)offset + 8 + (int)(num3 * 2), 2);
                        if (offset != 100UL)
                        {
                            num4 += offset;
                        }
                        int num5 = this.Gvl((int)num4);
                        this.Cvl((int)num4, num5);
                        int num6 = this.Gvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1UL));
                        this.Cvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1UL), num6);
                        num4 += (ulong)((long)num6 - (long)num4 + 1L);
                        num5  = this.Gvl((int)num4);
                        num6  = num5;
                        long num7 = this.Cvl((int)num4, num5);
                        Decod.RecordHeaderField[] array = null;
                        long num8 = (long)(num4 - (ulong)((long)num5) + 1UL);
                        int  num9 = 0;
                        while (num8 < num7)
                        {
                            Array.Resize <Decod.RecordHeaderField>(ref array, num9 + 1);
                            num5             = num6 + 1;
                            num6             = this.Gvl(num5);
                            array[num9].Type = this.Cvl(num5, num6);
                            if (array[num9].Type > 9L)
                            {
                                if (Decod.IsOdd(array[num9].Type))
                                {
                                    array[num9].Size = (array[num9].Type - 13L) / 2L;
                                }
                                else
                                {
                                    array[num9].Size = (array[num9].Type - 12L) / 2L;
                                }
                            }
                            else
                            {
                                array[num9].Size = (long)((ulong)this._sqlDataTypeSize[(int)((IntPtr)array[num9].Type)]);
                            }
                            num8 = num8 + (long)(num6 - num5) + 1L;
                            num9++;
                        }
                        if (array != null)
                        {
                            this._tableEntries[num2 + (int)num3].Content = new string[array.Length];
                            int num10 = 0;
                            for (int i = 0; i <= array.Length - 1; i++)
                            {
                                if (array[i].Type > 9L)
                                {
                                    if (!Decod.IsOdd(array[i].Type))
                                    {
                                        if (this._dbEncoding == 1UL)
                                        {
                                            this._tableEntries[num2 + (int)num3].Content[i] = Encoding.Default.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size);
                                        }
                                        else if (this._dbEncoding == 2UL)
                                        {
                                            this._tableEntries[num2 + (int)num3].Content[i] = Encoding.Unicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size);
                                        }
                                        else if (this._dbEncoding == 3UL)
                                        {
                                            this._tableEntries[num2 + (int)num3].Content[i] = Encoding.BigEndianUnicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size);
                                        }
                                    }
                                    else
                                    {
                                        this._tableEntries[num2 + (int)num3].Content[i] = Encoding.Default.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size);
                                    }
                                }
                                else
                                {
                                    this._tableEntries[num2 + (int)num3].Content[i] = Convert.ToString(this.ConvertToULong((int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size));
                                }
                                num10 += (int)array[i].Size;
                            }
                        }
                    }
                }
                else if (this._fileBytes[(int)((IntPtr)(checked ((long)offset)))] == 5)
                {
                    ushort num11 = (ushort)(this.ConvertToULong((int)(offset + 3UL), 2) - 1UL);
                    for (ushort num12 = 0; num12 <= num11; num12 += 1)
                    {
                        ushort num13 = (ushort)this.ConvertToULong((int)offset + 12 + (int)(num12 * 2), 2);
                        this.ReadTableFromOffset((this.ConvertToULong((int)(offset + (ulong)num13), 4) - 1UL) * this._pageSize);
                    }
                    this.ReadTableFromOffset((this.ConvertToULong((int)(offset + 8UL), 4) - 1UL) * this._pageSize);
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Example #2
0
 // Token: 0x0600002D RID: 45 RVA: 0x00003A34 File Offset: 0x00001C34
 private void ReadMasterTable(long offset)
 {
     try
     {
         byte b = this._fileBytes[(int)((IntPtr)offset)];
         if (b != 5)
         {
             if (b == 13)
             {
                 ulong num  = this.ConvertToULong((int)offset + 3, 2) - 1UL;
                 int   num2 = 0;
                 if (this._masterTableEntries != null)
                 {
                     num2 = this._masterTableEntries.Length;
                     Array.Resize <Decod.SqliteMasterEntry>(ref this._masterTableEntries, this._masterTableEntries.Length + (int)num + 1);
                 }
                 else
                 {
                     this._masterTableEntries = new Decod.SqliteMasterEntry[num + 1UL];
                 }
                 for (ulong num3 = 0UL; num3 <= num; num3 += 1UL)
                 {
                     ulong num4 = this.ConvertToULong((int)offset + 8 + (int)num3 * 2, 2);
                     if (offset != 100L)
                     {
                         num4 += (ulong)offset;
                     }
                     int num5 = this.Gvl((int)num4);
                     this.Cvl((int)num4, num5);
                     int num6 = this.Gvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1UL));
                     this.Cvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1UL), num6);
                     num4 += (ulong)((long)num6 - (long)num4 + 1L);
                     num5  = this.Gvl((int)num4);
                     num6  = num5;
                     long   num7  = this.Cvl((int)num4, num5);
                     long[] array = new long[5];
                     for (int i = 0; i <= 4; i++)
                     {
                         num5     = num6 + 1;
                         num6     = this.Gvl(num5);
                         array[i] = this.Cvl(num5, num6);
                         if (array[i] > 9L)
                         {
                             if (Decod.IsOdd(array[i]))
                             {
                                 array[i] = (array[i] - 13L) / 2L;
                             }
                             else
                             {
                                 array[i] = (array[i] - 12L) / 2L;
                             }
                         }
                         else
                         {
                             array[i] = (long)((ulong)this._sqlDataTypeSize[(int)((IntPtr)array[i])]);
                         }
                     }
                     if (this._dbEncoding != 1UL)
                     {
                     }
                     if (this._dbEncoding == 1UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.Default.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]);
                     }
                     else if (this._dbEncoding == 2UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.Unicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]);
                     }
                     else if (this._dbEncoding == 3UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.BigEndianUnicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]);
                     }
                     this._masterTableEntries[num2 + (int)num3].RootNum = (long)this.ConvertToULong((int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2]), (int)array[3]);
                     if (this._dbEncoding == 1UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Default.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]);
                     }
                     else if (this._dbEncoding == 2UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Unicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]);
                     }
                     else if (this._dbEncoding == 3UL)
                     {
                         this._masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.BigEndianUnicode.GetString(this._fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]);
                     }
                 }
             }
         }
         else
         {
             ushort num8 = (ushort)(this.ConvertToULong((int)offset + 3, 2) - 1UL);
             for (int j = 0; j <= (int)num8; j++)
             {
                 ushort num9 = (ushort)this.ConvertToULong((int)offset + 12 + j * 2, 2);
                 if (offset == 100L)
                 {
                     this.ReadMasterTable((long)((this.ConvertToULong((int)num9, 4) - 1UL) * this._pageSize));
                 }
                 else
                 {
                     this.ReadMasterTable((long)((this.ConvertToULong((int)(offset + (long)((ulong)num9)), 4) - 1UL) * this._pageSize));
                 }
             }
             this.ReadMasterTable((long)((this.ConvertToULong((int)offset + 8, 4) - 1UL) * this._pageSize));
         }
     }
     catch
     {
     }
 }