protected virtual void WriteClassHashData(BinaryWriter hashInput, ASClass asClass) { ABCFile abc = asClass.ABC; WriteTraitsHashData(hashInput, asClass); WriteMethodHashData(hashInput, asClass.Constructor, true); WriteTraitsHashData(hashInput, asClass.Instance); WriteMethodHashData(hashInput, asClass.Instance.Constructor, true); string superClassObjName = asClass.Instance.SuperType?.ObjName; if (!string.IsNullOrWhiteSpace(superClassObjName) && superClassObjName != "Object") { ASClass superClass = abc .FindClassByName(superClassObjName); if (superClass != null) { WriteMultinameHashData(hashInput, asClass.Instance.SuperType); WriteClassHashData(hashInput, superClass); } } hashInput.Write((byte)asClass.Instance.ClassInfo); hashInput.Write((byte)asClass.Instance.Type.MultinameType); hashInput.Write((byte)asClass.Instance.ProtectedNamespace.NamespaceType); }
public ASClass GetIncomingParser(ASInstance incomingInstance) { if (_incomingParsersCache.ContainsKey(incomingInstance)) { return(_incomingParsersCache[incomingInstance]); } ASClass parserClass = null; ABCFile abc = incomingInstance.ABC; try { using (var codeOut = new FlashReader( incomingInstance.Constructor.Body.Bytecode)) { while (codeOut.IsDataAvailable) { OPCode op = codeOut.ReadOP(); object[] values = codeOut.ReadValues(op); if (op != OPCode.GetLex) { continue; } var getLexIndex = (int)values[0]; ASMultiname getLexName = abc.Constants.Multinames[getLexIndex]; parserClass = abc.FindClassByName(getLexName.ObjName); if (parserClass != null) { return(parserClass); } break; } } ASInstance incomingSuperInstance = abc.FindInstanceByName( incomingInstance.SuperType.ObjName); ASMultiname parserReturnType = incomingSuperInstance .FindGetter("parser").Method.ReturnType; SlotConstantTrait parserSlot = incomingSuperInstance .FindSlot("*", parserReturnType.ObjName); foreach (ASTrait trait in incomingInstance.Traits) { if (trait.TraitType != TraitType.Method) { continue; } var mgsTrait = (MethodGetterSetterTrait)trait.Data; if (mgsTrait.Method.Parameters.Count != 0) { continue; } using (var codeOut = new FlashReader( mgsTrait.Method.Body.Bytecode)) { while (codeOut.IsDataAvailable) { OPCode op = codeOut.ReadOP(); object[] values = codeOut.ReadValues(op); if (op != OPCode.GetLex) { continue; } var getLexIndex = (int)values[0]; ASMultiname getLexType = abc.Constants.Multinames[getLexIndex]; if (getLexType.ObjName != parserSlot.ObjName) { continue; } parserClass = abc.FindClassByName(mgsTrait.Method.ReturnType.ObjName); if (parserClass != null) { return(parserClass); } break; } } } return(parserClass); } finally { if (parserClass != null) { _incomingParsersCache[incomingInstance] = parserClass; } } }
public bool FindMessageInstances() { if (OutgoingTypes.Count > 0 && IncomingTypes.Count > 0) { return(true); } ABCFile abc = ABCFiles[2]; ASClass habboMessages = abc.FindClassByName("HabboMessages"); if (habboMessages == null || habboMessages.Traits.Count < 2) { return(false); } ASTrait incomingMap = habboMessages.Traits[0]; ASTrait outgoingMap = habboMessages.Traits[1]; using (var mapReader = new FlashReader( habboMessages.Constructor.Body.Bytecode.ToArray())) { while (mapReader.Position != mapReader.Length) { OPCode op = mapReader.ReadOP(); if (op != OPCode.GetLex) { continue; } int mapTypeIndex = mapReader.Read7BitEncodedInt(); bool isOutgoing = (mapTypeIndex == outgoingMap.TypeIndex); bool isIncoming = (mapTypeIndex == incomingMap.TypeIndex); if (!isOutgoing && !isIncoming) { continue; } op = mapReader.ReadOP(); if (op != OPCode.PushShort && op != OPCode.PushByte) { continue; } ushort header = 0; if (op == OPCode.PushByte) { header = mapReader.ReadByte(); } else { header = (ushort)mapReader.Read7BitEncodedInt(); } op = mapReader.ReadOP(); if (op != OPCode.GetLex) { continue; } int messageTypeIndex = mapReader.Read7BitEncodedInt(); ASMultiname messageType = abc.Constants.Multinames[messageTypeIndex]; ASClass messageInstance = abc.FindClassByName(messageType.ObjName); if (isOutgoing) { OutgoingTypes[header] = messageInstance; } else if (isIncoming) { IncomingTypes[header] = messageInstance; } } } return(OutgoingTypes.Count > 0 && IncomingTypes.Count > 0); }