public void Open(string QQID, string QQPath) { if (QQPath == null) { using (Microsoft.Win32.RegistryKey reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Tencent\QQ")) { QQPath = reg.GetValue("Install") as string; } if (QQPath == null) { return; } } for (int i = 0; i < m_MsgList.Length; ++i) { m_MsgList[i] = new List <string>(); } m_Storage = null; m_Password = null; m_Storage = new IStorageWrapper(QQPath + QQID + @"\MsgEx.db"); m_Password = QQMsgMgr.GetGlobalPass(m_Storage, QQID); if (m_Password == null) { m_Storage = null; } foreach (IBaseStorageWrapper.FileObjects.FileObject fileObject in m_Storage.foCollection) { if (fileObject.FileType == 1) { for (int i = 0; i < m_MsgList.Length; ++i) { if (fileObject.FilePath == s_MsgName[i]) { m_MsgList[i].Add(fileObject.FileName); } } } } }
private void OutputMsg(QQMsgType type, string QQID, string fileName) { string msgPath = s_MsgName[(int)type] + QQID; IList <byte[]> msgList = QQMsgMgr.DecryptMsg(m_Storage, msgPath, m_Password); Encoding encoding = Encoding.GetEncoding(936); using (FileStream fs = new FileStream(fileName, FileMode.Create)) { using (StreamWriter sw = new StreamWriter(fs)) { for (int i = 0; i < msgList.Count; ++i) { using (MemoryStream ms = new MemoryStream(msgList[i])) { using (BinaryReader br = new BinaryReader(ms, Encoding.GetEncoding(936))) { #if false fs.Write(msgList[i], 0, msgList[i].Length); #else int ticks = br.ReadInt32(); DateTime time = new DateTime(1970, 1, 1) + new TimeSpan(0, 0, ticks); switch (type) { case QQMsgType.BIM: case QQMsgType.C2C: case QQMsgType.Mobile: ms.Seek(1, SeekOrigin.Current); break; case QQMsgType.Group: ms.Seek(8, SeekOrigin.Current); break; case QQMsgType.Sys: ms.Seek(4, SeekOrigin.Current); break; case QQMsgType.TempSession: //? ms.Seek(9, SeekOrigin.Current); break; } if (type == QQMsgType.TempSession) { int gLen = br.ReadInt32(); string groupName = encoding.GetString(br.ReadBytes(gLen)); if (groupName.Length > 0) { sw.WriteLine("{0}", groupName); } } int nLen = br.ReadInt32(); string id = encoding.GetString(br.ReadBytes(nLen)); sw.WriteLine("{0}: {1}", id, time.ToString()); int cLen = br.ReadInt32(); string msg = encoding.GetString(br.ReadBytes(cLen)); msg.Replace("\n", Environment.NewLine); sw.WriteLine(msg); sw.WriteLine(); #endif } } } } } }