コード例 #1
0
ファイル: FolderCompare.cs プロジェクト: tirnoney/DAIToolsWV
 private string CompareEBX(Bundle.ebxtype ebx, Bundle.ebxtype ebx2, bool cdiff, out bool diff)
 {
     StringBuilder sb = new StringBuilder();
     bool tdiff = false;
     sb.Append("  D:ebx " + ebx.name + "\n");
     if (ebx.baseSha1 != null && !Helpers.ByteArrayCompare(ebx.baseSha1, ebx2.baseSha1))
     {
         sb.AppendFormat("  D:-ebx basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.baseSha1), Helpers.ByteArrayToHexString(ebx2.baseSha1));
         tdiff = true;
     }
     if (ebx.deltaSha1 != null && !Helpers.ByteArrayCompare(ebx.deltaSha1, ebx2.deltaSha1))
     {
         sb.AppendFormat("  D:-ebx deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.deltaSha1), Helpers.ByteArrayToHexString(ebx2.deltaSha1));
         tdiff = true;
     }
     if (ebx.Sha1 != null && !Helpers.ByteArrayCompare(ebx.Sha1, ebx2.Sha1))
     {
         sb.AppendFormat("  D:-ebx sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(ebx.Sha1), Helpers.ByteArrayToHexString(ebx2.Sha1));
         tdiff = true;
     }
     if (ebx.size != null && !Helpers.ByteArrayCompare(ebx.size, ebx2.size))
     {
         sb.AppendFormat("  D:-ebx size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(ebx.size, 0), BitConverter.ToInt32(ebx2.size, 0));
         tdiff = true;
     }
     if (ebx.originalSize != null && !Helpers.ByteArrayCompare(ebx.originalSize, ebx2.originalSize))
     {
         sb.AppendFormat("  D:-ebx original size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(ebx.originalSize, 0), BitConverter.ToInt32(ebx2.originalSize, 0));
         tdiff = true;
     }
     if (ebx.casPatchType != ebx2.casPatchType)
     {
         sb.AppendFormat("  D:-ebx caspatchtype is different - ({0}) vs ({1})\n", ebx.casPatchType, ebx2.casPatchType);
         tdiff = true;
     }
     if (tdiff)
     {
         diff = true;
         return sb.ToString();
     }
     else
     {
         diff = cdiff;
         return "";
     }
 }
コード例 #2
0
ファイル: Bundle.cs プロジェクト: tirnoney/DAIToolsWV
 public static Bundle Create(BJSON.Entry e)
 {
     Bundle res = new Bundle();
     res.iscas = true;
     res.ebx = new List<ebxtype>();
     res.res = new List<restype>();
     res.chunk = new List<chunktype>();
     foreach (BJSON.Field f in e.fields)
         switch (f.fieldname)
         {
             case "path":
                 res.path = (string)f.data;
                 break;
             case "magicSalt":
                 res.salt = BitConverter.ToUInt32((byte[])f.data, 0).ToString("X4");
                 break;
             case "alignMembers":
                 res.align = (bool)f.data;
                 break;
             case "storeCompressedSizes":
                 res.compressed = (bool)f.data;
                 break;
             case "totalSize":
                 res.totalsize = BitConverter.ToUInt64((byte[])f.data, 0);
                 break;
             case "dbxtotalSize":
                 res.dbxtotalsize = BitConverter.ToUInt64((byte[])f.data, 0);
                 break;
             case "ebx":
                 res.ebx = ReadEbx(f);
                 break;
             case "dbx":
                 res.dbx = ReadDbx(f);
                 break;
             case "res":
                 res.res = ReadRes(f);
                 break;
             case "chunks":
             case "chunks0":
                 res.chunk.AddRange(ReadChunks(f));
                 break;
         }
     return res;
 }
コード例 #3
0
ファイル: FolderCompare.cs プロジェクト: tirnoney/DAIToolsWV
 private string CompareCHUNK(Bundle.chunktype chunk, Bundle.chunktype chunk2, bool cdiff, out bool diff)
 {
     StringBuilder sb = new StringBuilder();
     bool tdiff = false;
     sb.Append("  D:chunk " + Helpers.ByteArrayToHexString(chunk.id) + "\n");
     if (chunk.baseSha1 != null && !Helpers.ByteArrayCompare(chunk.baseSha1, chunk2.baseSha1))
     {
         sb.AppendFormat("  D:-chunk basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.baseSha1), Helpers.ByteArrayToHexString(chunk2.baseSha1));
         tdiff = true;
     }
     if (chunk.deltaSha1 != null && !Helpers.ByteArrayCompare(chunk.deltaSha1, chunk2.deltaSha1))
     {
         sb.AppendFormat("  D:-chunk deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.deltaSha1), Helpers.ByteArrayToHexString(chunk2.deltaSha1));
         tdiff = true;
     }
     if (chunk.SHA1 != null && !Helpers.ByteArrayCompare(chunk.SHA1, chunk2.SHA1))
     {
         sb.AppendFormat("  D:-chunk sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(chunk.SHA1), Helpers.ByteArrayToHexString(chunk2.SHA1));
         tdiff = true;
     }
     if (chunk.size != null && !Helpers.ByteArrayCompare(chunk.size, chunk2.size))
     {
         sb.AppendFormat("  D:-chunk size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(chunk.size, 0), BitConverter.ToInt32(chunk2.size, 0));
         tdiff = true;
     }
     if (chunk.casPatchType != chunk2.casPatchType)
     {
         sb.AppendFormat("  D:-chunk caspatchtype is different - ({0}) vs ({1})\n", chunk.casPatchType, chunk2.casPatchType);
         tdiff = true;
     }
     if (tdiff)
     {
         diff = true;
         return sb.ToString();
     }
     else
     {
         diff = cdiff;
         return "";
     }
 }
コード例 #4
0
ファイル: Bundle.cs プロジェクト: tirnoney/DAIToolsWV
 public static Bundle Create(byte[] binary, bool fast = false)
 {
     Bundle res = new Bundle();
     res.iscas = false;
     res.ebx = new List<ebxtype>();
     res.res = new List<restype>();
     res.chunk = new List<chunktype>();
     BinaryBundle bin = new BinaryBundle(new MemoryStream(binary), fast);
     if(bin.EbxList != null)
         foreach (BinaryBundle.EbxEntry ebx in bin.EbxList)
         {
             ebxtype e = new ebxtype();
             e.name = ebx._name;
             e.originalSize = BitConverter.GetBytes((long)ebx.ucsize);
             e.Sha1 = ebx._sha1;
             res.ebx.Add(e);
         }
     if (bin.ResList != null)
         foreach (BinaryBundle.ResEntry r in bin.ResList)
         {
             restype e = new restype();
             e.name = r._name;
             e.osize = BitConverter.GetBytes((long)r.ucsize);
             e.SHA1 = r._sha1;
             e.rtype = BitConverter.GetBytes(r.type);
             res.res.Add(e);
         }
     if (bin.ChunkList!= null)
         foreach (BinaryBundle.ChunkEntry c in bin.ChunkList)
         {
             chunktype e = new chunktype();
             e.size = BitConverter.GetBytes((long)c._originalSize);
             e.SHA1 = c._sha1;
             e.id = c.id;
             res.chunk.Add(e);
         }
     return res;
 }
コード例 #5
0
ファイル: DBAccess.cs プロジェクト: tirnoney/DAIToolsWV
 public static void AddBundle(int tocid, bool incas, Bundle b, TOCFile.TOCBundleInfoStruct info, SQLiteConnection con)
 {
     Debug.LogLn(" EBX:" + b.ebx.Count + " RES:" + b.res.Count + " CHUNK:" + b.chunk.Count, true);
     SQLCommand("INSERT INTO bundles (tocfile, frostid, offset, size, base, delta) VALUES (" + tocid + ",'" + info.id + "'," + info.offset + ", " + info.size + ", '" + info.isbase + "', '" + info.isdelta + "' )", con);
     int bundleid = (int)GetLastRowId(con);
     TOCInformation toci = GetTocInformationByIndex(tocid);
     var transaction = con.BeginTransaction();
     int counter = 0;
     if (b.ebx != null)
         foreach (Bundle.ebxtype ebx in b.ebx)
             try
             {
                 if (ebx.name != null && ebx.originalSize != null && ebx.size != null)
                 {
                     EBXInformation inf = new EBXInformation();
                     inf.basesha1 = Helpers.ByteArrayToHexString(ebx.baseSha1);
                     inf.bundlepath = b.path;
                     inf.casPatchType = ebx.casPatchType;
                     inf.deltasha1 = Helpers.ByteArrayToHexString(ebx.deltaSha1);
                     inf.ebxname = ebx.name;
                     inf.incas = incas;
                     inf.isbase = info.isbase;
                     inf.isdelta = info.isdelta;
                     if (toci.type == TYPE_BASEGAME)
                         inf.isbasegamefile = true;
                     if (toci.type == TYPE_UPDATE)
                         inf.isDLC = true;
                     if (toci.type == TYPE_PATCH)
                         inf.isPatch = true;
                     inf.offset = info.offset;
                     inf.sha1 = Helpers.ByteArrayToHexString(ebx.Sha1);
                     inf.size = info.size;
                     inf.tocfilepath = toci.path;
                     byte[] data = new byte[0];
                     if (inf.incas)
                         data = SHA1Access.GetDataBySha1(ebx.Sha1, 0x38);
                     else
                     {
                         BinaryBundle bb = null;
                         foreach (AddEBXHelpStruct h in aehelp)
                             if (h.tocpath == inf.tocfilepath && h.bpath == inf.bundlepath)
                             {
                                 bb = h.b;
                                 break;
                             }
                         if (bb == null)
                         {
                             TOCFile toc = new TOCFile(inf.tocfilepath);
                             byte[] bundledata = toc.ExportBundleDataByPath(inf.bundlepath);
                             bb = new BinaryBundle(new MemoryStream(bundledata));
                             AddEBXHelpStruct h = new AddEBXHelpStruct();
                             h.tocpath = inf.tocfilepath;
                             h.bpath = inf.bundlepath;
                             h.b = bb;
                             if (aehelp.Count > 10)
                                 aehelp.RemoveAt(0);
                         }
                         foreach (BinaryBundle.EbxEntry ebx2 in bb.EbxList)
                             if (inf.ebxname == ebx2._name)
                                 data = ebx2._data;
                     }
                     inf.guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10);
                     AddEBXLUTFile(inf, con);
                     if ((counter++) % 100 == 0)
                     {
                         transaction.Commit();
                         transaction = con.BeginTransaction();
                     }
                 }
             }
             catch (Exception ex)
             {
                 throw ex;
             }
     transaction.Commit();
     transaction = con.BeginTransaction();
     if (b.res != null)
         foreach (Bundle.restype res in b.res)
             try
             {
                 if (res.name != null)
                     AddRESFile(res.name, res.SHA1, res.rtype, bundleid, con);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
     transaction.Commit();
     transaction = con.BeginTransaction();
     if (b.chunk != null)
         foreach (Bundle.chunktype chunk in b.chunk)
             try
             {
                 AddChunk(chunk.id, chunk.SHA1, bundleid, con);
             }
             catch (Exception ex)
             {
                 throw ex;
             }
     transaction.Commit();
 }
コード例 #6
0
ファイル: FolderCompare.cs プロジェクト: tirnoney/DAIToolsWV
 private string CompareRES(Bundle.restype res, Bundle.restype res2, bool cdiff, out bool diff)
 {
     StringBuilder sb = new StringBuilder();
     bool tdiff = false;
     sb.Append("  D:res " + res.name + "\n");
     if (res.rtype != null && !Helpers.ByteArrayCompare(res.rtype, res2.rtype))
     {
         sb.AppendFormat("  D:-res ressource type is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.rtype), Helpers.ByteArrayToHexString(res2.rtype));
         tdiff = true;
     }
     if (res.baseSha1 != null && !Helpers.ByteArrayCompare(res.baseSha1, res2.baseSha1))
     {
         sb.AppendFormat("  D:-res basesha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.baseSha1), Helpers.ByteArrayToHexString(res2.baseSha1));
         tdiff = true;
     }
     if (res.deltaSha1 != null && !Helpers.ByteArrayCompare(res.deltaSha1, res2.deltaSha1))
     {
         sb.AppendFormat("  D:-res deltasha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.deltaSha1), Helpers.ByteArrayToHexString(res2.deltaSha1));
         tdiff = true;
     }
     if (res.SHA1 != null && !Helpers.ByteArrayCompare(res.SHA1, res2.SHA1))
     {
         sb.AppendFormat("  D:-res sha1 is different - ({0}) vs ({1})\n", Helpers.ByteArrayToHexString(res.SHA1), Helpers.ByteArrayToHexString(res2.SHA1));
         tdiff = true;
     }
     if (res.size != null && res2.size != null && !Helpers.ByteArrayCompare(res.size, res2.size))
     {
         sb.AppendFormat("  D:-res size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(res.size, 0), BitConverter.ToInt32(res2.size, 0));
         tdiff = true;
     }
     if (res.osize != null && res2.osize != null && !Helpers.ByteArrayCompare(res.osize, res2.osize))
     {
         sb.AppendFormat("  D:-res original size is different - ({0}) vs ({1})\n", BitConverter.ToInt32(res.osize, 0), BitConverter.ToInt32(res2.osize, 0));
         tdiff = true;
     }
     if (res.casPatchType != res2.casPatchType)
     {
         sb.AppendFormat("  D:-res caspatchtype is different - ({0}) vs ({1})\n", res.casPatchType, res2.casPatchType);
         tdiff = true;
     }
     if (tdiff)
     {
         diff = true;
         return sb.ToString();
     }
     else
     {
         diff = cdiff;
         return "";
     }
 }