Esempio n. 1
0
 public ScriptDialog(HeroScript pScript)
 {
     InitializeComponent();
     this.HideIcon();
     Script     = pScript;
     this.Title = pScript.Name + " Info";
     this.scriptName.Content     = Script.Name;
     this.stringCount.Content    = Script.Strings.Count;
     this.stringList.DataContext = Script.Strings;
 }
Esempio n. 2
0
        void ParseScript(byte[] Data, String[] Scripts, int Index)
        {
            //Log(LogLevel.Info, "Parsing script [{0}/{1}].", Index + 1, Count);
            MemoryStream Stream = new MemoryStream(Data);
            BinaryReader Reader = new BinaryReader(Stream);

            if (Reader.ReadUInt32() != 0x54504353)
            {
                Log(LogLevel.Warning, "Invalid script file!");
                return;
            }

            Int16 SmallVer = Reader.ReadInt16();
            Int16 BigVer   = Reader.ReadInt16();

            Reader.ReadUInt64(); // 0x01
            byte[] CheckSum = Reader.ReadBytes(6);

            Log(LogLevel.Debug, "Loaded SCTP File version {0} and checksum 0x{1}.", BigVer, CheckSum.GetHEX());

            Reader.ReadBytes(2);

            if (SmallVer == 0x05 && BigVer == 0x05)
            {
                v5Count++;
                bool IsEncrypted = Reader.ReadBoolean();
                Reader.ReadUInt64();

                Int32  DataLength = Reader.ReadInt32();
                byte[] pData      = Reader.ReadBytes(DataLength);

                if (IsEncrypted)
                {
                    EncCount++;
                    byte[] DecData = new Byte[pData.Length];

                    uint Unk = 0x35;
                    for (int i = 0; i < pData.Length; i++)
                    {
                        DecData[i] = (byte)(pData[i] ^ Unk);
                        Unk       += 0x36;
                    }
                    pData = DecData;
                }

                File.WriteAllBytes(DecryptPath + "\\" + System.IO.Path.GetFileName(Scripts[Index]), pData);

                return;
            }

            Int32  NameLength = Reader.ReadInt32();
            String FileName   = Encoding.ASCII.GetString(Reader.ReadBytes(NameLength));

            Log(LogLevel.Debug, "Got File Name: {0}.", FileName);

            HeroScript Script = new HeroScript(FileName, SmallVer, BigVer);

            Reader.ReadUInt64();
            Int32 FileSize = Reader.ReadInt32();


            int StringCount = (int)Reader.ReadVarNumeric();

            Log(LogLevel.Debug, "Found {0} Strings.", StringCount);
            for (int i = 0; i < StringCount; i++)
            {
                String TempString = Encoding.ASCII.GetString(Reader.ReadBytes((int)Reader.ReadVarNumeric()));
                Log(LogLevel.Debug, "Found String: {0}", TempString);
                Script.AddString(TempString);
            }

            long ELFLength = Reader.ReadVarNumeric();

            Script.ELF = Reader.ReadBytes((int)ELFLength);

            Log(LogLevel.Debug, "Saving ELF file '{0}.elf'.", Script.Name);

            if (Script.ELF[0] != 0x7F && Script.ELF[1] != 'E' && Script.ELF[2] != 'L')
            {
                Log(LogLevel.Error, "Invalid ELF file '{0}'.", Path.GetFileName(Scripts[Index]));
                throw new Exception(String.Format("Invalid ELF file '{0}'.", Path.GetFileName(Scripts[Index])));
            }

            Script.Save(ExtractPath);

            this.scriptBox.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(
                    delegate()
            {
                ScriptList.Add(Script);
            }
                    ));
        }