Ejemplo n.º 1
0
        public void writeResultToFile(string path)
        {
            try
            {
                System.IO.FileStream fileStream = new System.IO.FileStream(path, System.IO.FileMode.Create, System.IO.FileAccess.Write);
                StreamWriter         sw         = new StreamWriter(fileStream);


                System.IO.Stream stream = new System.IO.MemoryStream(this.endOfGameStatsBytes);
                using (AMFReader aMFReader = new AMFReader(stream))
                {
                    try
                    {
                        ASObject aSObject = (ASObject)aMFReader.ReadAMF3Data();
                        sw.Write(JsonConvert.SerializeObject(aSObject));
                    }
                    catch { }
                }


                sw.Close();
                fileStream.Close();
            }
            catch { }
        }
Ejemplo n.º 2
0
		public static DsoAmfBody Read(AMFReader reader, bool isAmf3) {
			reader.Reset();

			ushort targetUriLen = reader.ReadUInt16();
			string targetUri = reader.ReadUTF(targetUriLen); // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
			ushort responseUriLen = reader.ReadUInt16();
			string responseUri = reader.ReadUTF(responseUriLen); // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.

			long dataLen = reader.ReadUInt32();
			if (dataLen >= 2147483648) {
				dataLen = -4294967296;
			}

			object bodyObj;
			// Check for AMF3 kAvmPlusObjectType object type
			if (isAmf3) {
				byte typeMarker = reader.ReadByte();
				if (typeMarker == 17) {
					bodyObj = reader.ReadAMF3Data();
				} else {
					bodyObj = reader.ReadData();
				}
			} else {
				bodyObj = reader.ReadData();
			}


			DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);
			return body;
		}
Ejemplo n.º 3
0
        public Boolean DecodeData()
        {
            if (_decoded)
            {
                return(!Broken);
            }
            _decoded = true;
            Stream input = new MemoryStream(_rawData);

            using (var amf = new AMFReader(input))
            {
                try
                {
                    originalAMFObject = (ASObject)amf.ReadAMF3Data();
                    Ranked            = (Boolean)originalAMFObject["ranked"];
                    GameType          = originalAMFObject["gameType"] as String;
                    GameLength        = UInt32.Parse(originalAMFObject["gameLength"].ToString());
                    GameMode          = originalAMFObject["gameMode"] as String;
                    GameId            = UInt64.Parse(originalAMFObject["gameId"].ToString());

                    ArrayCollection blueTeam   = originalAMFObject["teamPlayerParticipantStats"] as ArrayCollection;
                    ArrayCollection purpleTeam = originalAMFObject["otherTeamPlayerParticipantStats"] as ArrayCollection;
                    BlueTeamPlayerCount = blueTeam.Count;
                    int playerCount = blueTeam.Count + purpleTeam.Count;
                    Players = new List <PlayerStats>();
                    for (int i = 0; i < blueTeam.Count; i++)
                    {
                        Players.Add(new PlayerStats(blueTeam[i] as ASObject));
                    }

                    for (int i = 0; i < purpleTeam.Count; i++)
                    {
                        Players.Add(new PlayerStats(purpleTeam[i] as ASObject));
                    }

                    if (OriginalAMFObject["myTeamInfo"] != null)
                    {
                        ASObject teamInfo = originalAMFObject["myTeamInfo"] as ASObject;
                        BlueTeamInfo   = String.Format("[{0}]{1}", teamInfo["tag"], teamInfo["name"]);
                        teamInfo       = originalAMFObject["otherTeamInfo"] as ASObject;
                        PurpleTeamInfo = String.Format("[{0}]{1}", teamInfo["tag"], teamInfo["name"]);
                    }
                    InitWardAndTurretInfo();
                }
                catch (Exception e)
                {
                    Logger.Instance.WriteLog("EndOfGameStatas decode failed");
                    Logger.Instance.WriteLog(e.Message);
                    _broken = true;
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
		public object ReadData(AMFReader reader, ClassDefinition classDefinition) {
			ASObject aso = new ASObject(_typeIdentifier);
			reader.AddAMF3ObjectReference(aso);
			string key = reader.ReadAMF3String();
			aso.TypeName = _typeIdentifier;
			while (key != string.Empty) {
				object value = reader.ReadAMF3Data();
				aso.Add(key, value);
				key = reader.ReadAMF3String();
			}
			return aso;
		}
Ejemplo n.º 5
0
        /// <summary>
        /// Reads an object from the byte stream or byte array, encoded in AMF serialized format.
        /// </summary>
        /// <returns></returns>
        public object ReadObject()
        {
            object obj = null;

            if (_objectEncoding == ObjectEncoding.AMF0)
            {
                obj = _amfReader.ReadData();
            }
            if (_objectEncoding == ObjectEncoding.AMF3)
            {
                obj = _amfReader.ReadAMF3Data();
            }
            return(obj);
        }
Ejemplo n.º 6
0
        public object ReadData(AMFReader reader, ClassDefinition classDefinition)
        {
            ASObject aso = new ASObject(_typeIdentifier);

            reader.AddAMF3ObjectReference(aso);
            string key = reader.ReadAMF3String();

            aso.TypeName = _typeIdentifier;
            while (key != string.Empty)
            {
                object value = reader.ReadAMF3Data();
                aso.Add(key, value);
                key = reader.ReadAMF3String();
            }
            return(aso);
        }
        public object ReadData(AMFReader reader, ClassDefinition classDefinition)
        {
            ASObject instance = new ASObject(this._typeIdentifier);

            reader.AddAMF3ObjectReference(instance);
            string key = reader.ReadAMF3String();

            instance.TypeName = this._typeIdentifier;
            while (key != string.Empty)
            {
                object obj3 = reader.ReadAMF3Data();
                instance.Add(key, obj3);
                key = reader.ReadAMF3String();
            }
            return(instance);
        }
Ejemplo n.º 8
0
 public bool DecodeData()
 {
     if (this._decoded)
     {
         return(!this.Broken);
     }
     this._decoded = true;
     System.IO.Stream stream = new System.IO.MemoryStream(this._rawData);
     using (AMFReader aMFReader = new AMFReader(stream))
     {
         try
         {
             ASObject aSObject = (ASObject)aMFReader.ReadAMF3Data();
             this.Ranked     = (bool)aSObject["ranked"];
             this.GameType   = (aSObject["gameType"] as string);
             this.GameLength = uint.Parse(aSObject["gameLength"].ToString());
             this.GameMode   = (aSObject["gameMode"] as string);
             this.GameId     = ulong.Parse(aSObject["gameId"].ToString());
             ArrayCollection arrayCollection  = aSObject["teamPlayerParticipantStats"] as ArrayCollection;
             ArrayCollection arrayCollection2 = aSObject["otherTeamPlayerParticipantStats"] as ArrayCollection;
             int             arg_DB_0         = arrayCollection.Count;
             int             arg_E3_0         = arrayCollection2.Count;
             this.Players = new System.Collections.Generic.List <PlayerStats>();
             for (int i = 0; i < arrayCollection.Count; i++)
             {
                 this.Players.Add(new PlayerStats(arrayCollection[i] as ASObject));
             }
             for (int j = 0; j < arrayCollection2.Count; j++)
             {
                 this.Players.Add(new PlayerStats(arrayCollection2[j] as ASObject));
             }
             if (aSObject["myTeamInfo"] != null)
             {
                 ASObject aSObject2 = aSObject["myTeamInfo"] as ASObject;
                 this.BlueTeamInfo   = string.Format("[{0}]{1}", aSObject2["tag"], aSObject2["name"]);
                 aSObject2           = (aSObject["otherTeamInfo"] as ASObject);
                 this.PurpleTeamInfo = string.Format("[{0}]{1}", aSObject2["tag"], aSObject2["name"]);
             }
         }
         catch (System.Exception)
         {
             this._broken = true;
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 9
0
        public static DsoAmfBody Read(AMFReader reader, bool isAmf3)
        {
            reader.Reset();

            ushort targetUriLen   = reader.ReadUInt16();
            string targetUri      = reader.ReadUTF(targetUriLen);        // When the message holds a response from a remote endpoint, the target URI specifies which method on the local client (i.e. reader request originator) should be invoked to handle the response.
            ushort responseUriLen = reader.ReadUInt16();
            string responseUri    = reader.ReadUTF(responseUriLen);      // The response's target URI is set to the request's response URI with an '/onResult' suffix to denote a success or an '/onStatus' suffix to denote a failure.

            long dataLen = reader.ReadUInt32();

            if (dataLen >= 2147483648)
            {
                dataLen = -4294967296;
            }

            object bodyObj;

            // Check for AMF3 kAvmPlusObjectType object type
            if (isAmf3)
            {
                byte typeMarker = reader.ReadByte();
                if (typeMarker == 17)
                {
                    bodyObj = reader.ReadAMF3Data();
                }
                else
                {
                    bodyObj = reader.ReadData();
                }
            }
            else
            {
                bodyObj = reader.ReadData();
            }


            DsoAmfBody body = new DsoAmfBody(targetUri, responseUri, bodyObj);

            return(body);
        }
Ejemplo n.º 10
0
        protected virtual ReadDataInvoker CreateReadDataMethod(Type type, AMFReader reader, object instance)
        {
            bool            skipVisibility  = SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
            DynamicMethod   method          = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(AMFReader), typeof(ClassDefinition) }, base.GetType(), skipVisibility);
            ILGenerator     iLGenerator     = method.GetILGenerator();
            LocalBuilder    builder         = iLGenerator.DeclareLocal(type);
            LocalBuilder    builder2        = iLGenerator.DeclareLocal(typeof(byte));
            LocalBuilder    builder3        = iLGenerator.DeclareLocal(typeof(string));
            LocalBuilder    builder4        = iLGenerator.DeclareLocal(typeof(object));
            LocalBuilder    builder5        = iLGenerator.DeclareLocal(typeof(int));
            LocalBuilder    builder6        = iLGenerator.DeclareLocal(typeof(int));
            LocalBuilder    builder7        = iLGenerator.DeclareLocal(typeof(object));
            LocalBuilder    builder8        = iLGenerator.DeclareLocal(typeof(Type));
            EmitHelper      emit            = new EmitHelper(iLGenerator);
            ConstructorInfo constructorInfo = type.GetConstructor(EmitHelper.AnyVisibilityInstance, null, CallingConventions.HasThis, Type.EmptyTypes, null);
            MethodInfo      methodInfo      = typeof(AMFReader).GetMethod("AddAMF3ObjectReference");
            MethodInfo      info3           = typeof(AMFReader).GetMethod("ReadByte");

            emit.newobj(constructorInfo).stloc_0.ldarg_0.ldloc_0.callvirt(methodInfo).ldc_i4_0.stloc_1.ldnull.stloc_2.end();
            for (int i = 0; i < this._classDefinition.MemberCount; i++)
            {
                string name       = this._classDefinition.Members[i].Name;
                byte   typeMarker = reader.ReadByte();
                object obj2       = reader.ReadAMF3Data(typeMarker);
                reader.SetMember(instance, name, obj2);
                emit.ldarg_0.callvirt(info3).stloc_1.end();
                MemberInfo[] member = type.GetMember(name);
                if ((member == null) || (member.Length <= 0))
                {
                    throw new MissingMemberException(type.FullName, name);
                }
                this.GeneratePropertySet(emit, typeMarker, member[0]);
            }
            Label loc = emit.DefineLabel();

            emit.MarkLabel(loc).ldloc_0.ret();
            return((ReadDataInvoker)method.CreateDelegate(typeof(ReadDataInvoker)));
        }
        protected virtual ReadDataInvoker CreateReadDataMethod(Type type, AMFReader reader, object instance)
        {
#if !(MONO) && !(NET_2_0) && !(NET_3_5) && !(SILVERLIGHT)
            bool canSkipChecks = _ps.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
#else
            bool canSkipChecks = SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
#endif
            DynamicMethod method = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(AMFReader), typeof(ClassDefinition) }, this.GetType(), canSkipChecks);
            ILGenerator il = method.GetILGenerator();

            LocalBuilder instanceLocal = il.DeclareLocal(type);//[0] instance
            LocalBuilder typeCodeLocal = il.DeclareLocal(typeof(byte));//[1] uint8 typeCode
            LocalBuilder keyLocal = il.DeclareLocal(typeof(string));//[2] string key
            LocalBuilder objTmp = il.DeclareLocal(typeof(object));//[3] temp object store
            LocalBuilder intTmp1 = il.DeclareLocal(typeof(int));//[4] temp int store, length
            LocalBuilder intTmp2 = il.DeclareLocal(typeof(int));//[5] temp int store, index
            LocalBuilder objTmp2 = il.DeclareLocal(typeof(object));//[6] temp object store
            LocalBuilder typeTmp = il.DeclareLocal(typeof(Type));//[7] temp Type store

            EmitHelper emit = new EmitHelper(il);
            ConstructorInfo typeConstructor = type.GetConstructor(EmitHelper.AnyVisibilityInstance, null, CallingConventions.HasThis, System.Type.EmptyTypes, null);
            MethodInfo miAddReference = typeof(AMFReader).GetMethod("AddAMF3ObjectReference");
            MethodInfo miReadByte = typeof(AMFReader).GetMethod("ReadByte");
            emit
                //object instance = new object();
                .newobj(typeConstructor) //Create the new instance and push the object reference onto the evaluation stack
                .stloc_0 //Pop from the top of the evaluation stack and store it in a the local variable list at index 0
                //reader.AddReference(instance);
                .ldarg_0 //Push the argument indexed at 1 onto the evaluation stack 'reader'
                .ldloc_0 //Loads the local variable at index 0 onto the evaluation stack 'instance'
                .callvirt(miAddReference) //Arguments are popped from the stack, the method call is performed, return value is pushed onto the stack
                //typeCode = 0;
                .ldc_i4_0 //Push the integer value of 0 onto the evaluation stack as an int32
                .stloc_1 //Pop and store it in a the local variable list at index 1
                //string key = null;
                .ldnull //Push a null reference onto the evaluation stack
                .stloc_2 //Pop and store it in a the local variable list at index 2 'key'
                .end()
            ;

            for (int i = 0; i < _classDefinition.MemberCount; i++)
            {
                string key = _classDefinition.Members[i].Name;
                byte typeCode = reader.ReadByte();
                object value = reader.ReadAMF3Data(typeCode);
                reader.SetMember(instance, key, value);

                emit
                    //.ldarg_1
                    //.callvirt(typeof(ClassDefinition).GetMethod("get_Members"))
                    //.ldc_i4(i)
                    //.conv_ovf_i
                    //.ldelem_ref
                    //.stloc_2
                    .ldarg_0
                    .callvirt(miReadByte)
                    .stloc_1
                    .end()
                ;
                
                MemberInfo[] memberInfos = type.GetMember(key);
                if (memberInfos != null && memberInfos.Length > 0)
                    GeneratePropertySet(emit, typeCode, memberInfos[0]);
                else
                {
                    //Log this error (do not throw exception), otherwise our current AMF stream becomes unreliable
                    log.Warn(__Res.GetString(__Res.Optimizer_Warning));
                    string msg = __Res.GetString(__Res.Reflection_MemberNotFound, string.Format("{0}.{1}", type.FullName, key));
                    log.Warn(msg);
                    //reader.ReadAMF3Data(typeCode);
                    emit
                        .ldarg_0 //Push 'reader'
                        .ldloc_1 //Push 'typeCode'
                        .callvirt(typeof(AMFReader).GetMethod("ReadAMF3Data", new Type[] { typeof(byte) }))
                        .pop
                        .end()
                    ;
                }
            }
            Label labelExit = emit.DefineLabel();
            emit
                .MarkLabel(labelExit)
                //return instance;
                .ldloc_0 //Load the local variable at index 0 onto the evaluation stack
                .ret() //Return
            ;

            return (ReadDataInvoker)method.CreateDelegate(typeof(ReadDataInvoker));
        }
Ejemplo n.º 12
0
        protected virtual ReadDataInvoker CreateReadDataMethod(Type type, AMFReader reader, object instance)
        {
#if !(MONO) && !(NET_2_0) && !(NET_3_5) && !(SILVERLIGHT)
            bool canSkipChecks = _ps.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
#else
            bool canSkipChecks = SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
#endif
            DynamicMethod method = new DynamicMethod(string.Empty, typeof(object), new Type[] { typeof(AMFReader), typeof(ClassDefinition) }, this.GetType(), canSkipChecks);
            ILGenerator   il     = method.GetILGenerator();

            LocalBuilder instanceLocal = il.DeclareLocal(type);           //[0] instance
            LocalBuilder typeCodeLocal = il.DeclareLocal(typeof(byte));   //[1] uint8 typeCode
            LocalBuilder keyLocal      = il.DeclareLocal(typeof(string)); //[2] string key
            LocalBuilder objTmp        = il.DeclareLocal(typeof(object)); //[3] temp object store
            LocalBuilder intTmp1       = il.DeclareLocal(typeof(int));    //[4] temp int store, length
            LocalBuilder intTmp2       = il.DeclareLocal(typeof(int));    //[5] temp int store, index
            LocalBuilder objTmp2       = il.DeclareLocal(typeof(object)); //[6] temp object store
            LocalBuilder typeTmp       = il.DeclareLocal(typeof(Type));   //[7] temp Type store

            EmitHelper      emit            = new EmitHelper(il);
            ConstructorInfo typeConstructor = type.GetConstructor(EmitHelper.AnyVisibilityInstance, null, CallingConventions.HasThis, System.Type.EmptyTypes, null);
            MethodInfo      miAddReference  = typeof(AMFReader).GetMethod("AddAMF3ObjectReference");
            MethodInfo      miReadByte      = typeof(AMFReader).GetMethod("ReadByte");
            emit
            //object instance = new object();
            .newobj(typeConstructor)  //Create the new instance and push the object reference onto the evaluation stack
            .stloc_0                  //Pop from the top of the evaluation stack and store it in a the local variable list at index 0
            //reader.AddReference(instance);
            .ldarg_0                  //Push the argument indexed at 1 onto the evaluation stack 'reader'
            .ldloc_0                  //Loads the local variable at index 0 onto the evaluation stack 'instance'
            .callvirt(miAddReference) //Arguments are popped from the stack, the method call is performed, return value is pushed onto the stack
            //typeCode = 0;
            .ldc_i4_0                 //Push the integer value of 0 onto the evaluation stack as an int32
            .stloc_1                  //Pop and store it in a the local variable list at index 1
            //string key = null;
            .ldnull                   //Push a null reference onto the evaluation stack
            .stloc_2                  //Pop and store it in a the local variable list at index 2 'key'
            .end()
            ;

            for (int i = 0; i < _classDefinition.MemberCount; i++)
            {
                string key      = _classDefinition.Members[i].Name;
                byte   typeCode = reader.ReadByte();
                object value    = reader.ReadAMF3Data(typeCode);
                reader.SetMember(instance, key, value);

                emit
                //.ldarg_1
                //.callvirt(typeof(ClassDefinition).GetMethod("get_Members"))
                //.ldc_i4(i)
                //.conv_ovf_i
                //.ldelem_ref
                //.stloc_2
                .ldarg_0
                .callvirt(miReadByte)
                .stloc_1
                .end()
                ;

                MemberInfo[] memberInfos = type.GetMember(key);
                if (memberInfos != null && memberInfos.Length > 0)
                {
                    GeneratePropertySet(emit, typeCode, memberInfos[0]);
                }
                else
                {
                    //Log this error (do not throw exception), otherwise our current AMF stream becomes unreliable
                    log.Warn(__Res.GetString(__Res.Optimizer_Warning));
                    string msg = __Res.GetString(__Res.Reflection_MemberNotFound, string.Format("{0}.{1}", type.FullName, key));
                    log.Warn(msg);
                    //reader.ReadAMF3Data(typeCode);
                    emit
                    .ldarg_0     //Push 'reader'
                    .ldloc_1     //Push 'typeCode'
                    .callvirt(typeof(AMFReader).GetMethod("ReadAMF3Data", new Type[] { typeof(byte) }))
                    .pop
                    .end()
                    ;
                }
            }
            Label labelExit = emit.DefineLabel();
            emit
            .MarkLabel(labelExit)
            //return instance;
            .ldloc_0   //Load the local variable at index 0 onto the evaluation stack
            .ret()     //Return
            ;

            return((ReadDataInvoker)method.CreateDelegate(typeof(ReadDataInvoker)));
        }
		public object ReadData(AMFReader reader)
		{
			return reader.ReadAMF3Data();
		}
Ejemplo n.º 14
0
 public object ReadData(AMFReader reader)
 {
     return(reader.ReadAMF3Data());
 }
Ejemplo n.º 15
0
        void launcher_ProcessFound(object sender, ProcessMonitor.ProcessEventArgs e)
        {
            try
            {
                if (!Settings.DeleteLeaveBuster)
                {
                    return;
                }

                var dir = Path.GetDirectoryName(e.Process.MainModule.FileName);
                if (dir == null)
                {
                    StaticLogger.Warning("Launcher module not found");
                    return;
                }

                var needle = "\\RADS\\";
                var i      = dir.LastIndexOf(needle, StringComparison.InvariantCulture);
                if (i == -1)
                {
                    StaticLogger.Warning("Launcher Rads not found");
                    return;
                }

                dir = dir.Remove(i + needle.Length);
                dir = Path.Combine(dir, "projects\\lol_air_client\\releases");

                if (!Directory.Exists(dir))
                {
                    StaticLogger.Warning("lol_air_client directory not found");
                    return;
                }

                foreach (var ver in new DirectoryInfo(dir).GetDirectories())
                {
                    var filename = Path.Combine(ver.FullName, "deploy\\preferences\\global\\global.properties");
                    if (!File.Exists(filename))
                    {
                        StaticLogger.Warning(filename + " not found");
                        continue;
                    }

                    ASObject obj = null;
                    using (var amf = new AMFReader(File.OpenRead(filename)))
                    {
                        try
                        {
                            obj = amf.ReadAMF3Data() as ASObject;
                            if (obj == null)
                            {
                                StaticLogger.Warning("Failed to read " + filename);
                                continue;
                            }
                        }
                        catch (Exception ex)
                        {
                            StaticLogger.Warning("LeaverBuster: Unable to read global.properties '" + filename + "'");
                            continue;
                        }
                    }
                    object leaver;
                    object locale;
                    if ((obj.TryGetValue("leaverData", out leaver) && leaver != null) ||
                        (obj.TryGetValue("localeData", out locale) && locale != null))
                    {
                        obj["leaverData"] = null;
                        obj["localeData"] = null;
                        using (var amf = new AMFWriter(File.Open(filename, FileMode.Create, FileAccess.Write)))
                        {
                            try
                            {
                                amf.WriteAMF3Data(obj);
                                StaticLogger.Info("Removed leaverData/localeData from global.properties");
                            }
                            catch (Exception ex)
                            {
                                StaticLogger.Warning("LeaverBuster: Unable to write global.properties '" + filename + "'");
                                continue;
                            }
                        }
                    }
                    else
                    {
                        StaticLogger.Info("leaverData/localeData already removed from global.properties");
                    }
                }
            }
            catch (Exception ex)
            {
                StaticLogger.Error(ex);
            }
        }