private bool ReadTableFromOffset(ulong offset) { bool result; try { if (_fileBytes[(int)(checked ((IntPtr)offset))] == 13) { ushort num = (ushort)(ConvertToULong((int)offset + 3, 2) - 1uL); int num2 = 0; if (_tableEntries != null) { num2 = _tableEntries.Length; Array.Resize <Sqlite.TableEntry>(ref _tableEntries, _tableEntries.Length + (int)num + 1); } else { _tableEntries = new Sqlite.TableEntry[(int)(num + 1)]; } for (ushort num3 = 0; num3 <= num; num3 += 1) { ulong num4 = ConvertToULong((int)offset + 8 + (int)(num3 * 2), 2); if (offset != 100uL) { num4 += offset; } int num5 = Gvl((int)num4); Cvl((int)num4, num5); int num6 = Gvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1uL)); Cvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1uL), num6); num4 += (ulong)((long)num6 - (long)num4 + 1L); num5 = Gvl((int)num4); num6 = num5; long num7 = Cvl((int)num4, num5); Sqlite.RecordHeaderField[] array = null; long num8 = (long)(num4 - (ulong)((long)num5) + 1uL); int num9 = 0; while (num8 < num7) { Array.Resize <Sqlite.RecordHeaderField>(ref array, num9 + 1); num5 = num6 + 1; num6 = Gvl(num5); array[num9].Type = Cvl(num5, num6); if (array[num9].Type > 9L) { if (Sqlite.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)_sqlDataTypeSize[(int)(checked ((IntPtr)array[num9].Type))]); } num8 = num8 + (long)(num6 - num5) + 1L; num9++; } if (array != null) { _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 (!Sqlite.IsOdd(array[i].Type)) { if (_dbEncoding == 1uL) { _tableEntries[num2 + (int)num3].Content[i] = Encoding.Default.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size); } else if (_dbEncoding == 2uL) { _tableEntries[num2 + (int)num3].Content[i] = Encoding.Unicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size); } else if (_dbEncoding == 3uL) { _tableEntries[num2 + (int)num3].Content[i] = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size); } } else { _tableEntries[num2 + (int)num3].Content[i] = Encoding.Default.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size); } } else { _tableEntries[num2 + (int)num3].Content[i] = Convert.ToString(ConvertToULong((int)(num4 + (ulong)num7 + (ulong)((long)num10)), (int)array[i].Size)); } num10 += (int)array[i].Size; } } } } else if (_fileBytes[(int)(checked ((IntPtr)offset))] == 5) { ushort num11 = (ushort)(ConvertToULong((int)(offset + 3uL), 2) - 1uL); for (ushort num12 = 0; num12 <= num11; num12 += 1) { ushort num13 = (ushort)ConvertToULong((int)offset + 12 + (int)(num12 * 2), 2); ReadTableFromOffset((ConvertToULong((int)(offset + (ulong)num13), 4) - 1uL) * _pageSize); } ReadTableFromOffset((ConvertToULong((int)(offset + 8uL), 4) - 1uL) * _pageSize); } result = true; } catch { result = false; } return(result); }
private void ReadMasterTable(long offset) { try { byte b = _fileBytes[(int)(checked ((IntPtr)offset))]; if (b != 5) { if (b == 13) { ulong num = ConvertToULong((int)offset + 3, 2) - 1uL; int num2 = 0; if (_masterTableEntries != null) { num2 = _masterTableEntries.Length; Array.Resize <Sqlite.SqliteMasterEntry>(ref _masterTableEntries, _masterTableEntries.Length + (int)num + 1); } else { _masterTableEntries = new Sqlite.SqliteMasterEntry[num + 1uL]; } for (ulong num3 = 0uL; num3 <= num; num3 += 1uL) { ulong num4 = ConvertToULong((int)offset + 8 + (int)num3 * 2, 2); if (offset != 100L) { num4 += (ulong)offset; } int num5 = Gvl((int)num4); Cvl((int)num4, num5); int num6 = Gvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1uL)); Cvl((int)(num4 + (ulong)((long)num5 - (long)num4) + 1uL), num6); num4 += (ulong)((long)num6 - (long)num4 + 1L); num5 = Gvl((int)num4); num6 = num5; long num7 = Cvl((int)num4, num5); long[] array = new long[5]; for (int i = 0; i <= 4; i++) { num5 = num6 + 1; num6 = Gvl(num5); array[i] = Cvl(num5, num6); if (array[i] > 9L) { if (Sqlite.IsOdd(array[i])) { array[i] = (array[i] - 13L) / 2L; } else { array[i] = (array[i] - 12L) / 2L; } } else { array[i] = (long)((ulong)_sqlDataTypeSize[(int)(checked ((IntPtr)array[i]))]); } } if (_dbEncoding != 1uL && _dbEncoding != 2uL) { ulong arg_19A_0 = _dbEncoding; } if (_dbEncoding == 1uL) { _masterTableEntries[num2 + (int)num3].ItemName = Encoding.Default.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]); } else if (_dbEncoding == 2uL) { _masterTableEntries[num2 + (int)num3].ItemName = Encoding.Unicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]); } else if (_dbEncoding == 3uL) { _masterTableEntries[num2 + (int)num3].ItemName = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0]), (int)array[1]); } _masterTableEntries[num2 + (int)num3].RootNum = (long)ConvertToULong((int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2]), (int)array[3]); if (_dbEncoding == 1uL) { _masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Default.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]); } else if (_dbEncoding == 2uL) { _masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.Unicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]); } else if (_dbEncoding == 3uL) { _masterTableEntries[num2 + (int)num3].SqlStatement = Encoding.BigEndianUnicode.GetString(_fileBytes, (int)(num4 + (ulong)num7 + (ulong)array[0] + (ulong)array[1] + (ulong)array[2] + (ulong)array[3]), (int)array[4]); } } } } else { ushort num8 = (ushort)(ConvertToULong((int)offset + 3, 2) - 1uL); for (int j = 0; j <= (int)num8; j++) { ushort num9 = (ushort)ConvertToULong((int)offset + 12 + j * 2, 2); if (offset == 100L) { ReadMasterTable((long)((ConvertToULong((int)num9, 4) - 1uL) * _pageSize)); } else { ReadMasterTable((long)((ConvertToULong((int)(offset + (long)((ulong)num9)), 4) - 1uL) * _pageSize)); } } ReadMasterTable((long)((ConvertToULong((int)offset + 8, 4) - 1uL) * _pageSize)); } } catch { } }