Exemplo n.º 1
0
        // Token: 0x060000CE RID: 206 RVA: 0x00007E74 File Offset: 0x00006074
        private bool ReadTableFromOffset(ulong offset)
        {
            bool result;

            try
            {
                if (this._fileBytes[(int)(checked ((IntPtr)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 <SqlHandler.TableEntry>(ref this._tableEntries, this._tableEntries.Length + (int)num + 1);
                    }
                    else
                    {
                        this._tableEntries = new SqlHandler.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);
                        SqlHandler.RecordHeaderField[] array = null;
                        long num8 = (long)(num4 - (ulong)((long)num5) + 1uL);
                        int  num9 = 0;
                        while (num8 < num7)
                        {
                            Array.Resize <SqlHandler.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 (SqlHandler.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)(checked ((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 (!SqlHandler.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)(checked ((IntPtr)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);
        }
Exemplo n.º 2
0
 // Token: 0x060000CF RID: 207 RVA: 0x000083FC File Offset: 0x000065FC
 private void ReadMasterTable(long offset)
 {
     try
     {
         byte b = this._fileBytes[(int)(checked ((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 <SqlHandler.SqliteMasterEntry>(ref this._masterTableEntries, this._masterTableEntries.Length + (int)num + 1);
                 }
                 else
                 {
                     this._masterTableEntries = new SqlHandler.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 (SqlHandler.IsOdd(array[i]))
                             {
                                 array[i] = (array[i] - 13L) / 2L;
                             }
                             else
                             {
                                 array[i] = (array[i] - 12L) / 2L;
                             }
                         }
                         else
                         {
                             array[i] = (long)((ulong)this._sqlDataTypeSize[(int)(checked ((IntPtr)array[i]))]);
                         }
                     }
                     if (this._dbEncoding == 1uL || this._dbEncoding != 2uL)
                     {
                     }
                     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
     {
     }
 }