internal Tag ReadTag() { long posBefore = SWFBinary.BaseStream.Position; RecordHeader rh = new RecordHeader(); rh.ReadData(SWFBinary); int offset = (int)(SWFBinary.BaseStream.Position - posBefore); SWFBinary.BaseStream.Position = posBefore; Tag resTag = null; switch (rh.TagCode) { case (int)TagCodes.DoABC: resTag = new DoABC(); break; case (int)TagCodes.End: resTag = new End(); break; default: resTag = new Tag(SWFBinary.ReadBytes(System.Convert.ToInt32(rh.TagLength + offset))); break; } resTag.ReadData(SWFVersion, SWFBinary); return(resTag); }
public void WriteExternal(BinaryWriter output) { if (0x52 == _header.Type)//DoABC { DoABC abcBody = (DoABC)_body; MemoryStream buffer = new MemoryStream(); BinaryWriter bufferOut = new BinaryWriter(buffer, Encoding.UTF8); // Part 1: Write .abc to buffer abcBody.WriteExternal(bufferOut); // Part 2: Update and write header _header.Length = (int)buffer.Length; _header.WriteExternal(output); // Part 3: Copy .abc buffer into output buffer.Seek(0, SeekOrigin.Begin); byte[] bb = new byte[1024]; int len; while ((len = buffer.Read(bb, 0, 1024)) > 0) { output.Write(bb, 0, len); } } else { // Other tags can be written very simple _header.WriteExternal(output); _body.WriteExternal(output); } }
/// <summary> /// This takes an existing script and merges it into our script by merging /// constants and classes together in a terrifying clash of opcodes. Where we have /// multiple scripts, we will merge into the first one, because we need to pick one /// and have no way to decide what would be best. /// </summary> /// <param name="abc">The script to merge into our one.</param> public void MergeScript(DoABC abc) { if (this.scripts.Count == 0) { this.AddScript(abc); /* Well, that was easy */ return; } this.scripts[0].Merge(abc, this.Context); }
/// <summary> /// Generates the timeline scripts. /// </summary> public void GenerateTimelineScripts() { if (this.scripts.Count != 0) { throw new SWFModellerException( SWFModellerError.Internal, "Internal error. Can't make auto-generated scripts if scripts already exist."); } string flaName = this.Context.Name.Replace('.', '_') + "_swiffotron"; string qualClassName = flaName + ".MainTimeline"; this.scripts.Add(DoABC.GenerateDefaultScript(qualClassName, this)); }
public void Parse(SwfFormat swf) { foreach (Tag tag in swf.Tags) { if (tag.Header.Type != 0x52) { continue; } DoABC abcTag = (DoABC)tag.Body; FormatAbc(abcTag.Abc); } }
public void Instantiate(int frameNum, Sprite sprite, Layer.Position layering, Matrix position, string instanceName, string qClassName) { AS3Class instanceClass = sprite.Class; if (this.Class == null) { throw new SWFModellerException( SWFModellerError.Internal, "Can't instantiate " + instanceName + " on timeline with no code"); } DoABC scriptTag = this.Root.FirstScript; if (scriptTag == null) { /* ISSUE 70: Y'know, we can generate scripts. We should probably do that. */ throw new SWFModellerException( SWFModellerError.Internal, "Can't instantiate clips in a SWF with no code."); } if (instanceClass == null) { DoABC.GenerateDefaultScript(qClassName, sprite); instanceClass = sprite.Class; } /* Create instance variable of type referenced by instanceClass */ Namespace propNS = scriptTag.Code.CreateNamespace(Namespace.NamespaceKind.Package, string.Empty); Multiname propName = scriptTag.Code.CreateMultiname(Multiname.MultinameKind.QName, instanceName, propNS, NamespaceSet.EmptySet); if (this.Class is AS3ClassDef) { ((AS3ClassDef)this.Class).AddInstanceTrait(new SlotTrait() { Kind = TraitKind.Slot, TypeName = instanceClass.Name, Name = propName, ValKind = ConstantKind.ConUndefined }); } this.GetFrame(frameNum).AddTag(new PlaceObject(sprite, this.GetFreeLayer(layering), null, position, instanceName, false, null, null, null)); }
private static String GetVersion(String filename) { SWFReader reader = new SWFReader(filename); foreach (Tag tag in reader.Tags) { if (tag is DoABC) { DoABC abcTag = (DoABC)tag; if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")) { var str = System.Text.Encoding.Default.GetString(abcTag.ABCData); string[] firstSplit = str.Split((char)6); //string[] secondSplit = firstSplit[0].Split((char)19); return(firstSplit[0].Substring(firstSplit[0].IndexOf("CURRENT_VERSION") + 17)); //17 for CURRENT_VERSION + 2 hidden characters } } } return("3.15.14_01_08_11_31"); }
public LoginPage() { InitializeComponent(); //Get client data after patcher completed Client.SQLiteDatabase = new SQLite.SQLiteConnection("gameStats_en_US.sqlite"); Client.Champions = (from s in Client.SQLiteDatabase.Table <champions>() orderby s.name select s).ToList(); if (Properties.Settings.Default.FavouriteChamps == null) { Properties.Settings.Default.FavouriteChamps = new Int32[0]; } foreach (champions c in Client.Champions) { string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath); c.icon = Client.GetImage(Source); Champions.InsertExtraChampData(c); if (Properties.Settings.Default.FavouriteChamps.Contains(c.id)) { c.IsFavourite = true; } } Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>() orderby s.name select s).ToList(); Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>() orderby s.id select s).ToList(); Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>() orderby s.id select s).ToList(); Client.Items = Items.PopulateItems(); Client.Masteries = Masteries.PopulateMasteries(); Client.Runes = Runes.PopulateRunes(); //Retrieve latest client version SWFReader reader = new SWFReader("ClientLibCommon.dat"); foreach (Tag tag in reader.Tags) { if (tag is DoABC) { DoABC abcTag = (DoABC)tag; if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")) { var str = System.Text.Encoding.Default.GetString(abcTag.ABCData); //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg) string[] firstSplit = str.Split((char)6); string[] secondSplit = firstSplit[0].Split((char)18); //Client.Version = secondSplit[1]; } } } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername)) { RememberUsernameCheckbox.IsChecked = true; LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername; } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword)) { RememberPasswordCheckbox.IsChecked = true; LoginPasswordBox.Password = Properties.Settings.Default.SavedPassword; } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region)) { RegionComboBox.SelectedValue = Properties.Settings.Default.Region; } string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(Client.LatestChamp).splashPath); LoginImage.Source = Client.GetImage(uriSource); if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) && !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) && Properties.Settings.Default.AutoLogin) { AutoLoginCheckBox.IsChecked = true; LoginButton_Click(null, null); } }
public override void doABC(DoABC tag) { frame.doABCs.Add(tag); }
internal void AddAbc(DoABC abcTag) { _abcTags.Add(abcTag); }
public LoginPage() { InitializeComponent(); //Get client data after patcher completed string latestVersion = "0.0.0.0"; string GameLocation = Path.Combine("League of Legends", "RADS"); if (Directory.Exists(GameLocation)) { System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); DirectoryInfo dInfo = new DirectoryInfo(Path.Combine(GameLocation, "projects", "lol_air_client", "releases")); DirectoryInfo[] subdirs = null; try { subdirs = dInfo.GetDirectories(); foreach (DirectoryInfo info in subdirs) { latestVersion = GetGreaterVersion(latestVersion, info.Name); } } catch (Exception er) { Console.WriteLine(er.Message); } } Client.SQLiteDatabase = new SQLite.SQLiteConnection(Path.Combine(GameLocation, "projects", "lol_air_client", "releases", latestVersion, "deploy", "assets", "data", "gameStats", "gameStats_en_US.sqlite")); Client.Champions = (from s in Client.SQLiteDatabase.Table <champions>() orderby s.name select s).ToList(); if (Properties.Settings.Default.FavouriteChamps == null) { Properties.Settings.Default.FavouriteChamps = new Int32[0]; } foreach (champions c in Client.Champions) { string Source = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", c.iconPath); c.icon = Client.GetImage(Source); Champions.InsertExtraChampData(c); if (Properties.Settings.Default.FavouriteChamps.Contains(c.id)) { c.IsFavourite = true; } } Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table <championSkins>() orderby s.name select s).ToList(); Client.SearchTags = (from s in Client.SQLiteDatabase.Table <championSearchTags>() orderby s.id select s).ToList(); Client.Keybinds = (from s in Client.SQLiteDatabase.Table <keybindingEvents>() orderby s.id select s).ToList(); Client.Items = Items.PopulateItems(); Client.Masteries = Masteries.PopulateMasteries(); Client.Runes = Runes.PopulateRunes(); //Retrieve latest client version SWFReader reader = new SWFReader("ClientLibCommon.dat"); foreach (Tag tag in reader.Tags) { if (tag is DoABC) { DoABC abcTag = (DoABC)tag; if (abcTag.Name.Contains("riotgames/platform/gameclient/application/Version")) { var str = System.Text.Encoding.Default.GetString(abcTag.ABCData); //Ugly hack ahead - turn back now! (http://pastebin.com/yz1X4HBg) string[] firstSplit = str.Split((char)6); string[] secondSplit = firstSplit[0].Split((char)19); Client.Version = secondSplit[1]; } } } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedUsername)) { RememberUsernameCheckbox.IsChecked = true; LoginUsernameBox.Text = Properties.Settings.Default.SavedUsername; } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword)) { RememberPasswordCheckbox.IsChecked = true; LoginPasswordBox.Password = Properties.Settings.Default.SavedPassword; } if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.Region)) { RegionComboBox.SelectedValue = Properties.Settings.Default.Region; } champions champ = champions.GetChampion(Client.LatestChamp); string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champ.splashPath); LoginImage.Source = Client.GetImage(uriSource); if (!String.IsNullOrWhiteSpace(Properties.Settings.Default.SavedPassword) && !String.IsNullOrWhiteSpace(Properties.Settings.Default.Region) && Properties.Settings.Default.AutoLogin) { AutoLoginCheckBox.IsChecked = true; LoginButton_Click(null, null); } }
public override void doABC(DoABC tag) { if (tag.code == flash.swf.TagValues_Fields.stagDoABC2) { encodeTagHeader(tag.code, 4 + tag.name.Length + 1 + tag.abc.Length, false); writer.write32(tag.flag); writer.writeString(tag.name); } else { encodeTagHeader(tag.code, tag.abc.Length, false); } writer.write(tag.abc); }
public void AssembleIfNecessary(DoABC codeTag, bool insertDebugCodes, string mainClassName, StringBuilder writeLog) { this.InsertDebugCodes = insertDebugCodes; #if DEBUG this.writeLog = writeLog; if (this.writeLog == null) { /* Bit of a kludge. If we passed null for this, we don't want a log. We'd rather not * put null tests everywhere though, so we create this string builder and log stuff * to it knowing full well it will be discarded and is a waste of time. It's convenient, * and it's only the debug build, so we don't really care about the waste. */ this.writeLog = new StringBuilder(); } #endif /* Firstly, if any methods are altered, we need to decompile all of them since the * table references will all be wrong. Check all the methods for tampering... */ AbcCode code = codeTag.Code; if (!code.IsTampered) { return; } /* At this point, all we know is that at least one piece of code * needs re-assembly. IsTampered doesn't meant everything is necessarily * tampered, although it probably is. */ /* We've established that we actually do need to do some work */ MemoryStream buffer = new MemoryStream(); ABCDataTypeWriter writer = new ABCDataTypeWriter(buffer); /* Ok, someone tampered with a method. Now we need to decompile them all and * re-build them... */ foreach (Method m in code.Methods) { if (!m.Tampered) { m.Tampered = true; /* Dissassembles the code and forces re-assembly. */ } } /* Another side-effect of such meddling is the need to re-build the tables... */ this.ReBuildTables(code, mainClassName); /* At this point, we will have a set of clean-built or untampered tables, and * calls to Method.Bytes will either return pre-built bytecode, or assemble it * on-demand for us. In other words, everything can just be dumped into a file. */ writer.WriteUI16(AbcFileValues.MinorVersion); writer.WriteUI16(AbcFileValues.MajorVersion); byte[] methodInfoBytes = this.GenerateMethodInfo(); byte[] metadataBytes = this.GenerateMetadata(code); byte[] classInfo = this.GenerateClassInfo(); byte[] scriptInfo = this.GenerateScriptInfo(code); /* When we write out the constant pool, the constants are fixed in the code object with * those values. In other words at this point we'd better be damn sure we've added all the * constants to the pools. */ this.WriteConstantPool(writer, code); writer.Write(methodInfoBytes, 0, methodInfoBytes.Length); writer.Write(metadataBytes, 0, metadataBytes.Length); writer.Write(classInfo, 0, classInfo.Length); writer.Write(scriptInfo, 0, scriptInfo.Length); this.WriteMethodBodies(writer); writer.Close(); /* Also closes buffer. */ codeTag.Bytecode = buffer.ToArray(); }
/// <summary> /// Adds a script. /// </summary> /// <param name="abc">The abc code.</param> public void AddScript(DoABC abc) { this.scripts.Add(abc); }
public override void doABC(DoABC tag) { if (abc) { open(tag); end(); AbcPrinter abcPrinter = new AbcPrinter(tag.abc, out_Renamed, showOffset, indent_Renamed_Field); abcPrinter.print(); close(tag); } else if (showActions) { open(tag); if (tag.code == flash.swf.TagValues_Fields.stagDoABC2) out_Renamed.Write(" name='" + tag.name + "'"); end(); ContextStatics contextStatics = new ContextStatics(); contextStatics.use_static_semantics = true; contextStatics.dialect = 9; //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'" Debug.Assert(swfVersion != null, "header should have been parsed already, but wasn't"); contextStatics.setAbcVersion(ContextStatics.getTargetAVM(swfVersion)); contextStatics.use_namespaces.addAll(ContextStatics.getRequiredUseNamespaces(swfVersion)); Context context = new Context(contextStatics); context.setHandler(new CompilerHandler()); AbcParser abcParser = new AbcParser(context, tag.abc); context.setEmitter(new ActionBlockEmitter(context, tag.name, new StringPrintWriter(), new StringPrintWriter(), false, false, false, false)); ProgramNode programNode = abcParser.parseAbc(); if (programNode == null) { //UPGRADE_TODO: Method 'java.io.PrintWriter.println' was converted to 'System.IO.TextWriter.WriteLine' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioPrintWriterprintln_javalangString'" out_Renamed.WriteLine("<!-- Error: could not parse abc -->"); } else if (decompile) { // PrettyPrinter prettyPrinter = new PrettyPrinter(out); // programNode.evaluate(context, prettyPrinter); } else { SyntaxTreeDumper syntaxTreeDumper = new SyntaxTreeDumper(out_Renamed, indent_Renamed_Field); programNode.evaluate(context, syntaxTreeDumper); } close(tag); } else { open(tag); close(); } }
public virtual void doABC(DoABC tag) { }