Advertisement
LaPanthere

SQLiteHandler.cs

Apr 25th, 2015
1,218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 25.41 KB | None | 0 0
  1.  //
  2.     //
  3.     //             Coded By: RockingWithTheBest
  4.     //
  5.     //             v 0.1
  6.     //
  7.     //
  8.     //      A Handler for SQLite without needing the sqlite3.dll!
  9.     //      You can read every table and value from database, but
  10.     //      there is no support for input. Also no support for
  11.     //      journal files and overflow pages, maybe i will add
  12.     //      that in a later release.
  13.     //      
  14.     //
  15.     //             Have Fun!
  16.     //
  17.     //   If u want to learn more about or enhance it then visit:
  18.     //      http://www.sqlite.org/fileformat.html
  19.     //
  20.     //   If you copy or modify it, please add me to credits!
  21.     //
  22.     //   Questions etc. to:      peterrlustig@googlemail.com
  23.     //   Converted by Unknown and added to as needed by LaPanthere
  24.  
  25.     enum SchemaFormat : int
  26.     {
  27.         /// <summary>
  28.         /// Format 1 is understood by all versions of SQLite back to version 3.0.0.
  29.         /// </summary>
  30.         Format1 = 1,
  31.         /// <summary>
  32.         /// Format 2 adds the ability of rows within the same table to have a varying number of columns, in order to support the ALTER TABLE ... ADD COLUMN functionality. Support for reading and writing format 2 was added in SQLite version 3.1.3 on 2005-02-19.
  33.         /// </summary>
  34.         Format2 = 2,
  35.         /// <summary>
  36.         /// Format 3 adds the ability of extra columns added by ALTER TABLE ... ADD COLUMN to have non-NULL default values. This capability was added in SQLite version 3.1.4 on 2005-03-11.
  37.         /// </summary>
  38.         Format3 = 3,
  39.         /// <summary>
  40.         /// Format 4 causes SQLite to respect the DESC keyword on index declarations. (The DESC keyword is ignored in indexes for formats 1, 2, and 3.) Format 4 also adds two new boolean record type values (serial types 8 and 9). Support for format 4 was added in SQLite 3.3.0 on 2006-01-10.
  41.         /// </summary>
  42.         Format4 = 4
  43.     }
  44.     public class SQLiteHandler
  45.     {
  46.         private byte[] db_bytes;
  47.         private ulong encoding;
  48.         private string[] field_names;
  49.         private sqlite_master_entry[] master_table_entries;
  50.         private ushort page_size;
  51.         private byte[] SQLDataTypeSize = new byte[] { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0 };
  52.         private table_entry[] table_entries;
  53.         private SchemaFormat format;
  54.         public SQLiteHandler(string baseName)
  55.         {
  56.             if (File.Exists(baseName))
  57.             {
  58.                 FileSystem.FileOpen(1, baseName, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared, -1);
  59.                 string str = Strings.Space((int)FileSystem.LOF(1));
  60.                 FileSystem.FileGet(1, ref str, -1L, false);
  61.                 FileSystem.FileClose(new int[] { 1 });
  62.                 this.db_bytes = Encoding.Default.GetBytes(str);
  63.                 if (Encoding.Default.GetString(this.db_bytes, 0, 15).CompareTo("SQLite format 3") != 0)
  64.                 {
  65.                     throw new Exception("Not a valid SQLite 3 Database File");
  66.                 }
  67.                 if (this.db_bytes[0x34] != 0)
  68.                 {
  69.                     throw new Exception("Auto-vacuum capable database is not supported");
  70.                 }
  71.                 decimal checker = new decimal(this.ConvertToInteger(44, 4));
  72.                 format = (SchemaFormat)checker;
  73.                 //if (decimal.Compare(checker, 4M) >= 0)
  74.                 //{
  75.                 //    throw new Exception("No supported Schema layer file-format");
  76.                // }
  77.                 this.page_size = (ushort)this.ConvertToInteger(0x10, 2);
  78.                 this.encoding = this.ConvertToInteger(0x38, 4);
  79.                 if (decimal.Compare(new decimal(this.encoding), decimal.Zero) == 0)
  80.                 {
  81.                     this.encoding = 1L;
  82.                 }
  83.                 this.ReadMasterTable(100L);
  84.             }
  85.         }
  86.  
  87.         private ulong ConvertToInteger(int startIndex, int Size)
  88.         {
  89.             if ((Size > 8) | (Size == 0))
  90.             {
  91.                 return 0L;
  92.             }
  93.             ulong num2 = 0L;
  94.             int num4 = Size - 1;
  95.             for (int i = 0; i <= num4; i++)
  96.             {
  97.                 num2 = (num2 << 8) | this.db_bytes[startIndex + i];
  98.             }
  99.             return num2;
  100.         }
  101.  
  102.         private long CVL(int startIndex, int endIndex)
  103.         {
  104.             endIndex++;
  105.             byte[] buffer = new byte[8];
  106.             int num4 = endIndex - startIndex;
  107.             bool flag = false;
  108.             if ((num4 == 0) | (num4 > 9))
  109.             {
  110.                 return 0L;
  111.             }
  112.             if (num4 == 1)
  113.             {
  114.                 buffer[0] = (byte)(this.db_bytes[startIndex] & 0x7f);
  115.                 return BitConverter.ToInt64(buffer, 0);
  116.             }
  117.             if (num4 == 9)
  118.             {
  119.                 flag = true;
  120.             }
  121.             int num2 = 1;
  122.             int num3 = 7;
  123.             int index = 0;
  124.             if (flag)
  125.             {
  126.                 buffer[0] = this.db_bytes[endIndex - 1];
  127.                 endIndex--;
  128.                 index = 1;
  129.             }
  130.             int num7 = startIndex;
  131.             for (int i = endIndex - 1; i >= num7; i += -1)
  132.             {
  133.                 if ((i - 1) >= startIndex)
  134.                 {
  135.                     buffer[index] = (byte)((((byte)(this.db_bytes[i] >> ((num2 - 1) & 7))) & (((int)0xff) >> num2)) | ((byte)(this.db_bytes[i - 1] << (num3 & 7))));
  136.                     num2++;
  137.                     index++;
  138.                     num3--;
  139.                 }
  140.                 else if (!flag)
  141.                 {
  142.                     buffer[index] = (byte)(((byte)(this.db_bytes[i] >> ((num2 - 1) & 7))) & (((int)0xff) >> num2));
  143.                 }
  144.             }
  145.             return BitConverter.ToInt64(buffer, 0);
  146.         }
  147.  
  148.         public int GetRowCount()
  149.         {
  150.             return this.table_entries.Length;
  151.         }
  152.  
  153.         public string[] GetTableNames()
  154.         {
  155.             string[] strArray2 = null;
  156.             int index = 0;
  157.             int num3 = this.master_table_entries.Length - 1;
  158.             for (int i = 0; i <= num3; i++)
  159.             {
  160.                 if (this.master_table_entries[i].item_type == "table")
  161.                 {
  162.                     strArray2 = (string[])Utils.CopyArray((Array)strArray2, new string[index + 1]);
  163.                     strArray2[index] = this.master_table_entries[i].item_name;
  164.                     index++;
  165.                 }
  166.             }
  167.             return strArray2;
  168.         }
  169.  
  170.         public string GetValue(int row_num, int field)
  171.         {
  172.             if (row_num >= this.table_entries.Length)
  173.             {
  174.                 return null;
  175.             }
  176.             if (field >= this.table_entries[row_num].content.Length)
  177.             {
  178.                 return null;
  179.             }
  180.             return this.table_entries[row_num].content[field];
  181.         }
  182.  
  183.         public string GetValue(int row_num, string field)
  184.         {
  185.             int num = -1;
  186.             int length = this.field_names.Length - 1;
  187.             for (int i = 0; i <= length; i++)
  188.             {
  189.                 if (this.field_names[i].ToLower().CompareTo(field.ToLower()) == 0)
  190.                 {
  191.                     num = i;
  192.                     break;
  193.                 }
  194.             }
  195.             if (num == -1)
  196.             {
  197.                 return null;
  198.             }
  199.             return this.GetValue(row_num, num);
  200.         }
  201.  
  202.         private int GVL(int startIndex)
  203.         {
  204.             if (startIndex > this.db_bytes.Length)
  205.             {
  206.                 return 0;
  207.             }
  208.             int num3 = startIndex + 8;
  209.             for (int i = startIndex; i <= num3; i++)
  210.             {
  211.                 if (i > (this.db_bytes.Length - 1))
  212.                 {
  213.                     return 0;
  214.                 }
  215.                 if ((this.db_bytes[i] & 0x80) != 0x80)
  216.                 {
  217.                     return i;
  218.                 }
  219.             }
  220.             return (startIndex + 8);
  221.         }
  222.  
  223.         private bool IsOdd(long value)
  224.         {
  225.             return ((value & 1L) == 1L);
  226.         }
  227.  
  228.         private void ReadMasterTable(ulong Offset)
  229.         {
  230.             if (this.db_bytes[(int)Offset] == 13)
  231.             {
  232.                 ushort num2 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
  233.                 int length = 0;
  234.                 if (this.master_table_entries != null)
  235.                 {
  236.                     length = this.master_table_entries.Length;
  237.                     this.master_table_entries = (sqlite_master_entry[])Utils.CopyArray((Array)this.master_table_entries, new sqlite_master_entry[(this.master_table_entries.Length + num2) + 1]);
  238.                 }
  239.                 else
  240.                 {
  241.                     this.master_table_entries = new sqlite_master_entry[num2 + 1];
  242.                 }
  243.                 int num13 = num2;
  244.                 for (int i = 0; i <= num13; i++)
  245.                 {
  246.                     ulong num = this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
  247.                     if (decimal.Compare(new decimal(Offset), 100M) != 0)
  248.                     {
  249.                         num += Offset;
  250.                     }
  251.                     int endIndex = this.GVL((int)num);
  252.                     long num7 = this.CVL((int)num, endIndex);
  253.                     int num6 = this.GVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)));
  254.                     this.master_table_entries[length + i].row_id = this.CVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num6);
  255.                     num = Convert.ToUInt64(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(num6), new decimal(num))), decimal.One));
  256.                     endIndex = this.GVL((int)num);
  257.                     num6 = endIndex;
  258.                     long num5 = this.CVL((int)num, endIndex);
  259.                     long[] numArray = new long[5];
  260.                     int index = 0;
  261.                     do
  262.                     {
  263.                         endIndex = num6 + 1;
  264.                         num6 = this.GVL(endIndex);
  265.                         numArray[index] = this.CVL(endIndex, num6);
  266.                         if (numArray[index] > 9L)
  267.                         {
  268.                             if (this.IsOdd(numArray[index]))
  269.                             {
  270.                                 numArray[index] = (long)Math.Round((double)(((double)(numArray[index] - 13L)) / 2.0));
  271.                             }
  272.                             else
  273.                             {
  274.                                 numArray[index] = (long)Math.Round((double)(((double)(numArray[index] - 12L)) / 2.0));
  275.                             }
  276.                         }
  277.                         else
  278.                         {
  279.                             numArray[index] = this.SQLDataTypeSize[(int)numArray[index]];
  280.                         }
  281.                         index++;
  282.                     }
  283.                     while (index <= 4);
  284.                     if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
  285.                     {
  286.                         this.master_table_entries[length + i].item_type = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  287.                     }
  288.                     else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
  289.                     {
  290.                         this.master_table_entries[length + i].item_type = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  291.                     }
  292.                     else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
  293.                     {
  294.                         this.master_table_entries[length + i].item_type = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  295.                     }
  296.                     if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
  297.                     {
  298.                         this.master_table_entries[length + i].item_name = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
  299.                     }
  300.                     else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
  301.                     {
  302.                         this.master_table_entries[length + i].item_name = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
  303.                     }
  304.                     else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
  305.                     {
  306.                         this.master_table_entries[length + i].item_name = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0]))), (int)numArray[1]);
  307.                     }
  308.                     this.master_table_entries[length + i].root_num = (long)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2]))), (int)numArray[3]);
  309.                     if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
  310.                     {
  311.                         this.master_table_entries[length + i].sql_statement = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  312.                     }
  313.                     else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
  314.                     {
  315.                         this.master_table_entries[length + i].sql_statement = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  316.                     }
  317.                     else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
  318.                     {
  319.                         this.master_table_entries[length + i].sql_statement = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(decimal.Add(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)), new decimal(numArray[0])), new decimal(numArray[1])), new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  320.                     }
  321.                 }
  322.             }
  323.             else if (this.db_bytes[(int)Offset] == 5)
  324.             {
  325.                 ushort num11 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
  326.                 int num14 = num11;
  327.                 for (int j = 0; j <= num14; j++)
  328.                 {
  329.                     ushort startIndex = (ushort)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(j * 2))), 2);
  330.                     if (decimal.Compare(new decimal(Offset), 100M) == 0)
  331.                     {
  332.                         this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(startIndex, 4)), decimal.One), new decimal(this.page_size))));
  333.                     }
  334.                     else
  335.                     {
  336.                         this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger((int)(Offset + startIndex), 4)), decimal.One), new decimal(this.page_size))));
  337.                     }
  338.                 }
  339.                 this.ReadMasterTable(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)), decimal.One), new decimal(this.page_size))));
  340.             }
  341.         }
  342.  
  343.         public bool ReadTable(string TableName)
  344.         {
  345.             int index = -1;
  346.             int length = this.master_table_entries.Length - 1;
  347.             for (int i = 0; i <= length; i++)
  348.             {
  349.                 if (this.master_table_entries[i].item_name.ToLower().CompareTo(TableName.ToLower()) == 0)
  350.                 {
  351.                     index = i;
  352.                     break;
  353.                 }
  354.             }
  355.             if (index == -1)
  356.             {
  357.                 return false;
  358.             }
  359.             string[] strArray = this.master_table_entries[index].sql_statement.Substring(this.master_table_entries[index].sql_statement.IndexOf("(") + 1).Split(new char[] { ',' });
  360.             int num6 = strArray.Length - 1;
  361.             for (int j = 0; j <= num6; j++)
  362.             {
  363.                 strArray[j] = (strArray[j]).TrimStart();
  364.                 int num4 = strArray[j].IndexOf(" ");
  365.                 if (num4 > 0)
  366.                 {
  367.                     strArray[j] = strArray[j].Substring(0, num4);
  368.                 }
  369.                 if (strArray[j].IndexOf("UNIQUE") == 0)
  370.                 {
  371.                     break;
  372.                 }
  373.                 this.field_names = (string[])Utils.CopyArray((Array)this.field_names, new string[j + 1]);
  374.                 this.field_names[j] = strArray[j];
  375.             }
  376.             return this.ReadTableFromOffset((ulong)((this.master_table_entries[index].root_num - 1L) * this.page_size));
  377.         }
  378.  
  379.         private bool ReadTableFromOffset(ulong Offset)
  380.         {
  381.             if (this.db_bytes[(int)Offset] == 13)
  382.             {
  383.                 int num2 = Convert.ToInt32(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
  384.                 int length = 0;
  385.                 if (this.table_entries != null)
  386.                 {
  387.                     length = this.table_entries.Length;
  388.                     this.table_entries = (table_entry[])Utils.CopyArray((Array)this.table_entries, new table_entry[(this.table_entries.Length + num2) + 1]);
  389.                 }
  390.                 else
  391.                 {
  392.                     this.table_entries = new table_entry[num2 + 1];
  393.                 }
  394.                 int num16 = num2;
  395.                 for (int i = 0; i <= num16; i++)
  396.                 {
  397.                     record_header_field[] _fieldArray = null;
  398.                     ulong num = this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
  399.                     if (decimal.Compare(new decimal(Offset), 100M) != 0)
  400.                     {
  401.                         num += Offset;
  402.                     }
  403.                     int endIndex = this.GVL((int)num);
  404.                     long num9 = this.CVL((int)num, endIndex);
  405.                     int num8 = this.GVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)));
  406.                     this.table_entries[length + i].row_id = this.CVL(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num8);
  407.                     num = Convert.ToUInt64(decimal.Add(decimal.Add(new decimal(num), decimal.Subtract(new decimal(num8), new decimal(num))), decimal.One));
  408.                     endIndex = this.GVL((int)num);
  409.                     num8 = endIndex;
  410.                     long num7 = this.CVL((int)num, endIndex);
  411.                     long num10 = Convert.ToInt64(decimal.Add(decimal.Subtract(new decimal(num), new decimal(endIndex)), decimal.One));
  412.                     for (int j = 0; num10 < num7; j++)
  413.                     {
  414.                         _fieldArray = (record_header_field[])Utils.CopyArray((Array)_fieldArray, new record_header_field[j + 1]);
  415.                         endIndex = num8 + 1;
  416.                         num8 = this.GVL(endIndex);
  417.                         _fieldArray[j].type = this.CVL(endIndex, num8);
  418.                         if (_fieldArray[j].type > 9L)
  419.                         {
  420.                             if (this.IsOdd(_fieldArray[j].type))
  421.                             {
  422.                                 _fieldArray[j].size = (long)Math.Round((double)(((double)(_fieldArray[j].type - 13L)) / 2.0));
  423.                             }
  424.                             else
  425.                             {
  426.                                 _fieldArray[j].size = (long)Math.Round((double)(((double)(_fieldArray[j].type - 12L)) / 2.0));
  427.                             }
  428.                         }
  429.                         else
  430.                         {
  431.                             _fieldArray[j].size = this.SQLDataTypeSize[(int)_fieldArray[j].type];
  432.                         }
  433.                         num10 = (num10 + (num8 - endIndex)) + 1L;
  434.                     }
  435.                     this.table_entries[length + i].content = new string[(_fieldArray.Length - 1) + 1];
  436.                     int num4 = 0;
  437.                     int num17 = _fieldArray.Length - 1;
  438.                     for (int k = 0; k <= num17; k++)
  439.                     {
  440.                         if (_fieldArray[k].type > 9L)
  441.                         {
  442.                             if (!this.IsOdd(_fieldArray[k].type))
  443.                             {
  444.                                 if (decimal.Compare(new decimal(this.encoding), decimal.One) == 0)
  445.                                 {
  446.                                     this.table_entries[length + i].content[k] = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
  447.                                 }
  448.                                 else if (decimal.Compare(new decimal(this.encoding), 2M) == 0)
  449.                                 {
  450.                                     this.table_entries[length + i].content[k] = Encoding.Unicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
  451.                                 }
  452.                                 else if (decimal.Compare(new decimal(this.encoding), 3M) == 0)
  453.                                 {
  454.                                     this.table_entries[length + i].content[k] = Encoding.BigEndianUnicode.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
  455.                                 }
  456.                             }
  457.                             else
  458.                             {
  459.                                 this.table_entries[length + i].content[k] = Encoding.Default.GetString(this.db_bytes, Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size);
  460.                             }
  461.                         }
  462.                         else
  463.                         {
  464.                             this.table_entries[length + i].content[k] = Conversions.ToString(this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)), new decimal(num4))), (int)_fieldArray[k].size));
  465.                         }
  466.                         num4 += (int)_fieldArray[k].size;
  467.                     }
  468.                 }
  469.             }
  470.             else if (this.db_bytes[(int)Offset] == 5)
  471.             {
  472.                 ushort num14 = Convert.ToUInt16(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)), decimal.One));
  473.                 int num18 = num14;
  474.                 for (int m = 0; m <= num18; m++)
  475.                 {
  476.                     ushort num13 = (ushort)this.ConvertToInteger(Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(m * 2))), 2);
  477.                     this.ReadTableFromOffset(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger((int)(Offset + num13), 4)), decimal.One), new decimal(this.page_size))));
  478.                 }
  479.                 this.ReadTableFromOffset(Convert.ToUInt64(decimal.Multiply(decimal.Subtract(new decimal(this.ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)), decimal.One), new decimal(this.page_size))));
  480.             }
  481.             return true;
  482.         }
  483.  
  484.         [StructLayout(LayoutKind.Sequential)]
  485.         private struct record_header_field
  486.         {
  487.             public long size;
  488.             public long type;
  489.         }
  490.  
  491.         [StructLayout(LayoutKind.Sequential)]
  492.         private struct sqlite_master_entry
  493.         {
  494.             public long row_id;
  495.             public string item_type;
  496.             public string item_name;
  497.             public string astable_name;
  498.             public long root_num;
  499.             public string sql_statement;
  500.         }
  501.  
  502.         [StructLayout(LayoutKind.Sequential)]
  503.         private struct table_entry
  504.         {
  505.             public long row_id;
  506.             public string[] content;
  507.         }
  508.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement