public void readRecordsDoWork(object sender, DoWorkEventArgs e) { Tuple <Table, bool> tableData = (Tuple <Table, bool>)e.Argument; Table table = tableData.Item1; bool status = tableData.Item2; List <ListViewItem> listVIewItemList = new List <ListViewItem>(); List <Dictionary <int, Item> > recordList; this.formWait.end(""); this.formWait.setLabel("Table Analyzing : " + table.getTableName()); if (status == true)//normal { recordList = table.getRecordList(); } else { recordList = table.getDeletedRecordList(); } int totalSize = recordList.Count; formWait.maxProgress(totalSize); int longValueNumber = table.getLongValueNumber(); if (longValueNumber != -1) { if (lvTableDict.ContainsKey(longValueNumber)) { Table lvTable = lvTableDict[longValueNumber]; Dictionary <int, LVItem> lvItems = lvTable.parseLVItems(); table.setLVItemDict(lvItems); } } if (recordList.Count == 0) { e.Result = listVIewItemList; } this.formWait.end(""); List <Column> columnList = table.getColumnList(); int count = 0; foreach (Dictionary <int, Item> record in recordList) { if (backgroudWoker.CancellationPending == true) { break; } ++count; if (count % 1000 == 0 || recordList.Count == count) { formWait.setPrgress(count); } ListViewItem listVIewItem = new ListViewItem(); foreach (Column column in columnList) { /* * if (table.getTableName().Contains("Cookies")) * { * String a = ""; * a += column.getID(); a += ","; * a += column.getType(); a += ","; * a += column.getSpaceUsage(); a += ","; * a += column.getName(); * using (System.IO.StreamWriter file = * new System.IO.StreamWriter(@"C:\Users\KJH\Desktop\d.txt", true)) * { * file.WriteLine(a); * } * } */ int columnID = column.getID(); if (columnID == 999) { try { if (table.getTableName().Contains("History")) { String responseHeader = listVIewItem.SubItems[22].Text; int startOffset = responseHeader.IndexOf("000000001F000000"); if (startOffset == -1) { listVIewItem.SubItems.Add(""); } else { startOffset += 24; int len = BitConverter.ToInt32(hextoByte(responseHeader.Substring(startOffset - 8, 8)), 0) * 4; listVIewItem.SubItems.Add(Encoding.Unicode.GetString(hextoByte(responseHeader.Substring(startOffset, len)))); } } else if (table.getTableName().Contains("Content")) { String responseHeader = listVIewItem.SubItems[22].Text; int startOffset = responseHeader.IndexOf("48545450"); if (startOffset == -1) { listVIewItem.SubItems.Add(""); } else { int len = responseHeader.Length - 4; String url = Encoding.UTF8.GetString(hextoByte(responseHeader.Substring(startOffset, len))); try { url = WebUtility.HtmlDecode(url); url = Uri.UnescapeDataString(url); } catch {} listVIewItem.SubItems.Add(url); } } else if (table.getTableName().Contains("iecompatua")) { String responseHeader = listVIewItem.SubItems[22].Text; listVIewItem.SubItems.Add(responseHeader); } else if (table.getTableName().Contains("feedplat")) { String responseHeader = listVIewItem.SubItems[22].Text; int len = responseHeader.IndexOf("00000000"); if (len == -1) { listVIewItem.SubItems.Add(""); } else { if (len % 2 == 1) { len++; } listVIewItem.SubItems.Add(Encoding.UTF8.GetString(hextoByte(responseHeader.Substring(0, len)))); } } else if (table.getTableName().Contains("iedownload")) { String responseHeader = listVIewItem.SubItems[22].Text; int startOffset = responseHeader.LastIndexOf("00000000"); if (startOffset == -1) { listVIewItem.SubItems.Add(""); } else { if (startOffset % 2 == 1) { startOffset++; } int j = 0; byte[] bytes = hextoByte(responseHeader.Substring(startOffset + 8)); byte[] newBytes = new byte[bytes.Length + 100]; for (int i = 0; i < bytes.Length; i += 2) { if (bytes.Length > i + 1) { newBytes[j] = bytes[i]; newBytes[j + 1] = bytes[i + 1]; if (bytes[i] == 0x00 && bytes[i + 1] == 0x00) { newBytes[j] = 0x0D; newBytes[j + 1] = 0x00; newBytes[j + 2] = 0x0A; newBytes[j + 3] = 0x00; newBytes[j + 4] = 0x0D; newBytes[j + 5] = 0x00; newBytes[j + 6] = 0x0A; newBytes[j + 7] = 0x00; j += 6; } j += 2; } } newBytes[j] = 0x00; newBytes[j + 1] = 0x00; listVIewItem.SubItems.Add(Encoding.Unicode.GetString(newBytes)); /* * * * * * * for (int i = 0; i < bytes.Length; i += 2) * { * newBytes[j] = bytes[i]; * newBytes[j + 1] = bytes[i + 1]; * j += 2; * if (bytes[i] == 0 && bytes[i + 1] == 0) * { * writeString += Encoding.Unicode.GetString(newBytes) + @"\r\n"; * j = 0; * } * } * writeString = writeString.Replace(Encoding.Unicode.GetString(new byte[] { 0, 0 }), @"\r\n"); * writeString += Encoding.Unicode.GetString(new byte[] { 0, 0 }); * */ //listVIewItem.SubItems.Add(writeString); /* * if (startOffset % 2 == 1) * startOffset++; * listVIewItem.SubItems.Add(Encoding.Unicode.GetString(hextoByte(responseHeader.Substring(startOffset + 8).Replace("000000", "000D000A000D000A00")))); * */ } } } catch { listVIewItem.SubItems.Add(""); } } else if (!record.ContainsKey(columnID)) { listVIewItem.SubItems.Add(""); } else { Item item = record[columnID]; int recordID = item.getID(); int recordSize = item.getSize(); if (recordID > 0 && recordID <= 0x80) { listVIewItem.SubItems.Add(item.getValue()); if (columnID == 7 && column.getName().Equals("Type")) { int index = listVIewItem.SubItems.Count - 1; String strType = listVIewItem.SubItems[index].Text; int iType = 0; if (Int32.TryParse(strType, out iType)) { strType = ""; if ((iType & 0x00000001) == 0x00000001) { strType += "[Normal]"; } if ((iType & 0x00000400) == 0x00000400) { strType += "[Download]"; } if ((iType & 0x00000800) == 0x00000800) { strType += "[Redirect]"; } if ((iType & 0x00020000) == 0x00020000) { strType += "[PrivateBrowsing]"; } if ((iType & 0x00100000) == 0x00100000) { strType += "[Cookie]"; } if ((iType & 0x00200000) == 0x00200000) { strType += "[Url]"; } if ((iType & 0x00400000) == 0x00400000) { strType += "[PendingDelete]"; } if ((iType & 0x04000000) == 0x04000000) { strType += "[PostResponse]"; } if ((iType & 0x10000000) == 0x10000000) { strType += "[Installed]"; } listVIewItem.SubItems[index].Text = strType; } } } else if (recordID >= 0x80 && recordID < 0x100) { if (recordSize < 0 || recordSize >= 256) { listVIewItem.SubItems.Add("Parsig Error : fixed size item"); } else { listVIewItem.SubItems.Add(item.getValue()); } } else if (recordID >= 0x100 && recordID < 0xFFFF) { if (recordSize < 0 || recordSize >= 65535) { listVIewItem.SubItems.Add("Parsig Error : variable size item"); } else { byte tagFlag = item.getTaggedDataItemFlag(); if (tagFlag == 0 || tagFlag == 1) { //common listVIewItem.SubItems.Add(item.getValue()); } else if (tagFlag == 3) { //compress text listVIewItem.SubItems.Add(item.getDecompressText()); } else { //Pointer int pointerNumber = item.getPointNumber(); Dictionary <int, LVItem> lvItemDict = table.getLvItemDict(); if (lvItemDict.ContainsKey(pointerNumber)) { listVIewItem.SubItems.Add(lvItemDict[pointerNumber].getData(item.getID(), item.getType())); } else { listVIewItem.SubItems.Add("Parsig Error : lV pointer"); } } } if (columnID == 256 && column.getName().Equals("Url")) { int index = listVIewItem.SubItems.Count - 1; String url = listVIewItem.SubItems[index].Text; try { url = WebUtility.HtmlDecode(url); url = Uri.UnescapeDataString(url); } catch {} listVIewItem.SubItems[index].Text = url; } } } } listVIewItemList.Add(listVIewItem); } this.formWait.end(""); if (isSaveData) { this.formWait.setLabel("Saving table : " + table.getTableName()); } else { this.formWait.setLabel("Showing table : " + table.getTableName()); } var result = new Tuple <Table, List <ListViewItem> >(table, listVIewItemList); e.Result = result; }