Exemple #1
0
        // Token: 0x06000215 RID: 533 RVA: 0x0000DE7C File Offset: 0x0000C07C
        private bool ReadTableFromOffset(ulong offset)
        {
            bool result;

            try
            {
                if (this._fileBytes[(int)(checked ((IntPtr)offset))] == 13)
                {
                    uint num  = (uint)(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[num + 1U];
                    }
                    for (uint num3 = 0U; num3 <= num; num3 += 1U)
                    {
                        ulong num4 = this.ConvertToULong((int)offset + 8 + (int)(num3 * 2U), 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);
                        ulong num7  = num4 + (ulong)((long)num6 - (long)num4 + 1L);
                        int   num8  = this.Gvl((int)num7);
                        int   num9  = num8;
                        long  num10 = this.Cvl((int)num7, num8);
                        SqlHandler.RecordHeaderField[] array = null;
                        long num11 = (long)(num7 - (ulong)((long)num8) + 1UL);
                        int  num12 = 0;
                        while (num11 < num10)
                        {
                            Array.Resize <SqlHandler.RecordHeaderField>(ref array, num12 + 1);
                            int num13 = num9 + 1;
                            num9 = this.Gvl(num13);
                            array[num12].Type = this.Cvl(num13, num9);
                            array[num12].Size = (long)((array[num12].Type <= 9L) ? ((ulong)this._sqlDataTypeSize[(int)(checked ((IntPtr)array[num12].Type))]) : ((ulong)((!SqlHandler.IsOdd(array[num12].Type)) ? ((array[num12].Type - 12L) / 2L) : ((array[num12].Type - 13L) / 2L))));
                            num11             = num11 + (long)(num9 - num13) + 1L;
                            num12++;
                        }
                        if (array != null)
                        {
                            this._tableEntries[num2 + (int)num3].Content = new string[array.Length];
                            int num14 = 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)(num7 + (ulong)num10 + (ulong)((long)num14)), (int)array[i].Size);
                                        }
                                        else if (this._dbEncoding == 2UL)
                                        {
                                            this._tableEntries[num2 + (int)num3].Content[i] = Encoding.Unicode.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)((long)num14)), (int)array[i].Size);
                                        }
                                        else if (this._dbEncoding == 3UL)
                                        {
                                            this._tableEntries[num2 + (int)num3].Content[i] = Encoding.BigEndianUnicode.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)((long)num14)), (int)array[i].Size);
                                        }
                                    }
                                    else
                                    {
                                        this._tableEntries[num2 + (int)num3].Content[i] = Encoding.Default.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)((long)num14)), (int)array[i].Size);
                                    }
                                }
                                else
                                {
                                    this._tableEntries[num2 + (int)num3].Content[i] = Convert.ToString(this.ConvertToULong((int)(num7 + (ulong)num10 + (ulong)((long)num14)), (int)array[i].Size));
                                }
                                num14 += (int)array[i].Size;
                            }
                        }
                    }
                }
                else if (this._fileBytes[(int)(checked ((IntPtr)offset))] == 5)
                {
                    uint num15 = (uint)(this.ConvertToULong((int)(offset + 3UL), 2) - 1UL);
                    for (uint num16 = 0U; num16 <= num15; num16 += 1U)
                    {
                        uint num17 = (uint)this.ConvertToULong((int)offset + 12 + (int)(num16 * 2U), 2);
                        this.ReadTableFromOffset((this.ConvertToULong((int)(offset + (ulong)num17), 4) - 1UL) * this._pageSize);
                    }
                    this.ReadTableFromOffset((this.ConvertToULong((int)(offset + 8UL), 4) - 1UL) * this._pageSize);
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Exemple #2
0
 // Token: 0x06000216 RID: 534 RVA: 0x0000E2E8 File Offset: 0x0000C4E8
 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);
                     ulong  num7  = num4 + (ulong)((long)num6 - (long)num4 + 1L);
                     int    num8  = this.Gvl((int)num7);
                     int    num9  = num8;
                     long   num10 = this.Cvl((int)num7, num8);
                     long[] array = new long[5];
                     for (int i = 0; i <= 4; i++)
                     {
                         int startIdx = num9 + 1;
                         num9     = this.Gvl(startIdx);
                         array[i] = this.Cvl(startIdx, num9);
                         array[i] = (long)((array[i] <= 9L) ? ((ulong)this._sqlDataTypeSize[(int)(checked ((IntPtr)array[i]))]) : ((ulong)((!SqlHandler.IsOdd(array[i])) ? ((array[i] - 12L) / 2L) : ((array[i] - 13L) / 2L))));
                     }
                     if (this._dbEncoding == 1UL || this._dbEncoding == 2UL)
                     {
                         if (this._dbEncoding == 1UL)
                         {
                             this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.Default.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)array[0]), (int)array[1]);
                         }
                         else if (this._dbEncoding == 2UL)
                         {
                             this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.Unicode.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)array[0]), (int)array[1]);
                         }
                         else if (this._dbEncoding == 3UL)
                         {
                             this._masterTableEntries[num2 + (int)num3].ItemName = Encoding.BigEndianUnicode.GetString(this._fileBytes, (int)(num7 + (ulong)num10 + (ulong)array[0]), (int)array[1]);
                         }
                     }
                     this._masterTableEntries[num2 + (int)num3].RootNum = (long)this.ConvertToULong((int)(num7 + (ulong)num10 + (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)(num7 + (ulong)num10 + (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)(num7 + (ulong)num10 + (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)(num7 + (ulong)num10 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]);
                     }
                 }
             }
         }
         else
         {
             uint num11 = (uint)(this.ConvertToULong((int)offset + 3, 2) - 1UL);
             for (int j = 0; j <= (int)num11; j++)
             {
                 uint num12 = (uint)this.ConvertToULong((int)offset + 12 + j * 2, 2);
                 if (offset == 100L)
                 {
                     this.ReadMasterTable((long)((this.ConvertToULong((int)num12, 4) - 1UL) * this._pageSize));
                 }
                 else
                 {
                     this.ReadMasterTable((long)((this.ConvertToULong((int)(offset + (long)((ulong)num12)), 4) - 1UL) * this._pageSize));
                 }
             }
             this.ReadMasterTable((long)((this.ConvertToULong((int)offset + 8, 4) - 1UL) * this._pageSize));
         }
     }
     catch
     {
     }
 }