示例#1
0
        public static EBXInformation[] GetEBXInformation(ToolStripStatusLabel label)
        {
            List <EBXInformation> result = new List <EBXInformation>();
            SQLiteConnection      con    = GetConnection();

            con.Open();
            SQLiteDataReader reader = getAll("ebxlut", con);
            int count     = 0;
            int animcount = 0;

            while (reader.Read())
            {
                EBXInformation ebx = new EBXInformation();
                ebx.ebxname      = reader.GetString(1);
                ebx.sha1         = reader.GetString(2);
                ebx.basesha1     = reader.GetString(3);
                ebx.deltasha1    = reader.GetString(4);
                ebx.casPatchType = reader.GetInt32(5);
                ebx.guid         = reader.GetString(6);
                ebx.bundlepath   = reader.GetString(7);
                ebx.offset       = reader.GetInt32(8);
                ebx.size         = reader.GetInt32(9);
                ebx.isbase       = reader.GetString(10) == "True";
                ebx.isdelta      = reader.GetString(11) == "True";
                ebx.tocfilepath  = reader.GetString(12);
                ebx.incas        = reader.GetString(13) == "True";
                switch (reader.GetString(14))
                {
                default:
                    ebx.isbasegamefile = true;
                    break;

                case "u":
                    ebx.isDLC = true;
                    break;

                case "p":
                    ebx.isPatch = true;
                    break;
                }
                result.Add(ebx);
                if (count++ % 10000 == 0)
                {
                    Application.DoEvents();
                    label.Text = "Refreshing... " + Helpers.GetWaiter(animcount++);
                }
            }
            con.Close();
            GC.Collect();
            return(result.ToArray());
        }
示例#2
0
        public static EBXInformation[] GetEBXInformationByPath(string path)
        {
            List <EBXInformation> result = new List <EBXInformation>();

            path = path.ToLower();
            SQLiteConnection con = GetConnection();

            con.Open();
            SQLiteDataReader reader = getAllWhere("ebxlut", "lower(path) = '" + path + "'", con);
            int count = 0;

            while (reader.Read())
            {
                EBXInformation ebx = new EBXInformation();
                ebx.ebxname      = reader.GetString(1);
                ebx.sha1         = reader.GetString(2);
                ebx.basesha1     = reader.GetString(3);
                ebx.deltasha1    = reader.GetString(4);
                ebx.casPatchType = reader.GetInt32(5);
                ebx.guid         = reader.GetString(6);
                ebx.bundlepath   = reader.GetString(7);
                ebx.offset       = reader.GetInt32(8);
                ebx.size         = reader.GetInt32(9);
                ebx.isbase       = reader.GetString(10) == "True";
                ebx.isdelta      = reader.GetString(11) == "True";
                ebx.tocfilepath  = reader.GetString(12);
                ebx.incas        = reader.GetString(13) == "True";
                switch (reader.GetString(14))
                {
                default:
                    ebx.isbasegamefile = true;
                    break;

                case "u":
                    ebx.isDLC = true;
                    break;

                case "p":
                    ebx.isPatch = true;
                    break;
                }
                result.Add(ebx);
                if (count++ % 1000 == 0)
                {
                    Application.DoEvents();
                }
            }
            con.Close();
            return(result.ToArray());
        }
示例#3
0
 public static EBXInformation[] GetEBXInformationBySHA1(string sha1)
 {
     List<EBXInformation> result = new List<EBXInformation>();
     sha1 = sha1.ToUpper();
     SQLiteConnection con = GetConnection();
     con.Open();
     SQLiteDataReader reader = getAllWhere("ebxlut", "sha1 = '" + sha1 + "' or basesha1 = '" + sha1 + "' or deltasha1 = '" + sha1 + "' ", con);
     int count = 0;
     while (reader.Read())
     {
         EBXInformation ebx = new EBXInformation();
         ebx.ebxname = reader.GetString(1);
         ebx.sha1 = reader.GetString(2);
         ebx.basesha1 = reader.GetString(3);
         ebx.deltasha1 = reader.GetString(4);
         ebx.casPatchType = reader.GetInt32(5);
         ebx.guid = reader.GetString(6);
         ebx.bundlepath = reader.GetString(7);
         ebx.offset = reader.GetInt32(8);
         ebx.size = reader.GetInt32(9);
         ebx.isbase = reader.GetString(10) == "True";
         ebx.isdelta = reader.GetString(11) == "True";
         ebx.tocfilepath = reader.GetString(12);
         ebx.incas = reader.GetString(13) == "True";
         switch (reader.GetString(14))
         {
             default:
                 ebx.isbasegamefile = true;
                 break;
             case "u":
                 ebx.isDLC = true;
                 break;
             case "p":
                 ebx.isPatch = true;
                 break;
         }
         result.Add(ebx);
         if (count++ % 1000 == 0)
             Application.DoEvents();
     }
     con.Close();
     return result.ToArray();
 }
示例#4
0
 public static EBXInformation[] GetEBXInformation(ToolStripStatusLabel label)
 {
     List<EBXInformation> result = new List<EBXInformation>();
     SQLiteConnection con = GetConnection();
     con.Open();
     SQLiteDataReader reader = getAll("ebxlut", con);
     int count = 0;
     int animcount = 0;
     while (reader.Read())
     {
         EBXInformation ebx = new EBXInformation();
         ebx.ebxname = reader.GetString(1);
         ebx.sha1 = reader.GetString(2);
         ebx.basesha1 = reader.GetString(3);
         ebx.deltasha1 = reader.GetString(4);
         ebx.casPatchType = reader.GetInt32(5);
         ebx.guid = reader.GetString(6);
         ebx.bundlepath = reader.GetString(7);
         ebx.offset = reader.GetInt32(8);
         ebx.size = reader.GetInt32(9);
         ebx.isbase = reader.GetString(10) == "True";
         ebx.isdelta = reader.GetString(11) == "True";
         ebx.tocfilepath = reader.GetString(12);
         ebx.incas = reader.GetString(13) == "True";
         switch (reader.GetString(14))
         {
             default:
                 ebx.isbasegamefile = true;
                 break;
             case "u":
                 ebx.isDLC = true;
                 break;
             case "p":
                 ebx.isPatch = true;
                 break;
         }
         result.Add(ebx);
         if (count++ % 10000 == 0)
         {
             Application.DoEvents();
             label.Text = "Refreshing... " + Helpers.GetWaiter(animcount++);
         }
     }
     con.Close();
     GC.Collect();
     return result.ToArray();
 }
示例#5
0
 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
 public static void AddEBXLUTFile(EBXInformation ebx, SQLiteConnection con)
 {
     string ftype = "b";
     if (ebx.isDLC)
         ftype = "u";
     if (ebx.isPatch)
         ftype = "p";
     string guid = "";
     byte[] data = new byte[0];
     if (ebx.incas)
         data = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ebx.sha1));
     else
     {
         BinaryBundle b  = null;
         foreach(AddEBXHelpStruct h in aehelp)
             if (h.tocpath == ebx.tocfilepath && h.bpath == ebx.bundlepath)
             {
                 b = h.b;
                 break;
             }
         if (b == null)
         {
             TOCFile toc = new TOCFile(ebx.tocfilepath);
             byte[] bundledata = toc.ExportBundleDataByPath(ebx.bundlepath);
             b = new BinaryBundle(new MemoryStream(bundledata));
             AddEBXHelpStruct h = new AddEBXHelpStruct();
             h.tocpath = ebx.tocfilepath;
             h.bpath = ebx.bundlepath;
             h.b = b;
             if (aehelp.Count > 10)
                 aehelp.RemoveAt(0);
         }
         foreach (BinaryBundle.EbxEntry ebx2 in b.EbxList)
             if (ebx.ebxname == ebx2._name)
                 data = ebx2._data;
     }
     guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10);
     SQLCommand("INSERT INTO ebxlut (path,sha1,basesha1,deltasha1,casptype,guid,bundlepath,offset,size,isbase,isdelta,tocpath,incas,filetype) VALUES ('"
         + ebx.ebxname.Replace("'","''") + "','"
         + ebx.sha1 + "','"
         + ebx.basesha1 + "','"
         + ebx.deltasha1 + "',"
         + ebx.casPatchType + ",'"
         + guid + "','"
         + ebx.bundlepath + "',"
         + ebx.offset + ","
         + ebx.size + ",'"
         + ebx.isbase + "','"
         + ebx.isdelta + "','"
         + ebx.tocfilepath + "','"
         + ebx.incas + "','"
         + ftype + "')", con);
 }
示例#7
0
        public static void AddEBXLUTFile(EBXInformation ebx, SQLiteConnection con)
        {
            string ftype = "b";

            if (ebx.isDLC)
            {
                ftype = "u";
            }
            if (ebx.isPatch)
            {
                ftype = "p";
            }
            string guid = "";

            byte[] data = new byte[0];
            if (ebx.incas)
            {
                data = SHA1Access.GetDataBySha1(Helpers.HexStringToByteArray(ebx.sha1));
            }
            else
            {
                BinaryBundle b = null;
                foreach (AddEBXHelpStruct h in aehelp)
                {
                    if (h.tocpath == ebx.tocfilepath && h.bpath == ebx.bundlepath)
                    {
                        b = h.b;
                        break;
                    }
                }
                if (b == null)
                {
                    TOCFile toc        = new TOCFile(ebx.tocfilepath);
                    byte[]  bundledata = toc.ExportBundleDataByPath(ebx.bundlepath);
                    b = new BinaryBundle(new MemoryStream(bundledata));
                    AddEBXHelpStruct h = new AddEBXHelpStruct();
                    h.tocpath = ebx.tocfilepath;
                    h.bpath   = ebx.bundlepath;
                    h.b       = b;
                    if (aehelp.Count > 10)
                    {
                        aehelp.RemoveAt(0);
                    }
                }
                foreach (BinaryBundle.EbxEntry ebx2 in b.EbxList)
                {
                    if (ebx.ebxname == ebx2._name)
                    {
                        data = ebx2._data;
                    }
                }
            }
            guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10);
            SQLCommand("INSERT INTO ebxlut (path,sha1,basesha1,deltasha1,casptype,guid,bundlepath,offset,size,isbase,isdelta,tocpath,incas,filetype) VALUES ('"
                       + ebx.ebxname.Replace("'", "''") + "','"
                       + ebx.sha1 + "','"
                       + ebx.basesha1 + "','"
                       + ebx.deltasha1 + "',"
                       + ebx.casPatchType + ",'"
                       + guid + "','"
                       + ebx.bundlepath + "',"
                       + ebx.offset + ","
                       + ebx.size + ",'"
                       + ebx.isbase + "','"
                       + ebx.isdelta + "','"
                       + ebx.tocfilepath + "','"
                       + ebx.incas + "','"
                       + ftype + "')", con);
        }
示例#8
0
        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();
        }