Ejemplo n.º 1
0
        public AppletStateMgr(Horizon system)
        {
            Messages     = new ConcurrentQueue <AppletMessage>();
            MessageEvent = new KEvent(system.KernelContext);

            AppletResourceUserIds = new IdDictionary();
        }
 public MethodParameterToIDTypeBinding(string fullyQualifiedMethodName, string fullMethodWithParameters, string[] parameterNames, int parameterIndex, string idType, IdDictionary idDictionary, tModLoaderVersion appliesToVersion = tModLoaderVersion.tModLoader_1_3_Or_1_4)
 {
     this.fullyQualifiedMethodName = fullyQualifiedMethodName;
     this.methodName = fullyQualifiedMethodName.Substring(fullyQualifiedMethodName.LastIndexOf(".") + 1);
     this.fullMethodWithParameters = fullMethodWithParameters;
     this.parameterNames           = parameterNames;
     this.parameterIndex           = parameterIndex;
     this.idType           = idType;
     this.idDictionary     = idDictionary;
     this.appliesToVersion = appliesToVersion;
 }
 public FieldToIDTypeBinding(string fullName, string field, string idType, IdDictionary idDictionary, tModLoaderVersion appliesToVersion = tModLoaderVersion.tModLoader_1_3_Or_1_4)
 {
     this.fullyQualifiedClassName = fullName;
     this.className        = fullName.Substring(fullName.LastIndexOf(".") + 1);
     this.field            = field;
     this.idType           = idType;
     this.idDictionary     = idDictionary;
     this.appliesToVersion = appliesToVersion;
     //if (idType == "TileID")
     //    idDictionary = TileID.Search;
     //if (idType == "ItemID")
     //    idDictionary = ItemID.Search;
 }
Ejemplo n.º 4
0
        public IpcService()
        {
            Commands = Assembly.GetExecutingAssembly().GetTypes()
                       .Where(type => type == GetType())
                       .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public))
                       .SelectMany(methodInfo => methodInfo.GetCustomAttributes(typeof(CommandAttribute))
                                   .Select(command => (((CommandAttribute)command).Id, methodInfo)))
                       .ToDictionary(command => command.Id, command => command.methodInfo);

            _domainObjects = new IdDictionary();

            _selfId = -1;
        }
Ejemplo n.º 5
0
        private static int AddNvMap(ServiceCtx Context, NvMapHandle Map)
        {
            IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) =>
            {
                IdDictionary NewDict = new IdDictionary();

                NewDict.Add(0, new NvMapHandle());

                return(NewDict);
            });

            return(Dict.Add(Map));
        }
Ejemplo n.º 6
0
        private static int AddNvMap(ServiceCtx context, NvMapHandle map)
        {
            IdDictionary dict = _maps.GetOrAdd(context.Process, (key) =>
            {
                IdDictionary newDict = new IdDictionary();

                newDict.Add(0, new NvMapHandle());

                return(newDict);
            });

            return(dict.Add(map));
        }
Ejemplo n.º 7
0
        private int CreateHandleFromMap(NvMapHandle map)
        {
            IdDictionary dict = _maps.GetOrAdd(Owner, (key) =>
            {
                IdDictionary newDict = new IdDictionary();

                newDict.Add(0, new NvMapHandle());

                return(newDict);
            });

            return(dict.Add(map));
        }
Ejemplo n.º 8
0
        public IApplicationDisplayService()
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 100, GetRelayService },
                { 101, GetSystemDisplayService },
                { 102, GetManagerDisplayService },
                { 103, GetIndirectDisplayTransactionService },
                { 1010, OpenDisplay },
                { 1020, CloseDisplay },
                { 2020, OpenLayer },
                { 2021, CloseLayer },
                { 2030, CreateStrayLayer },
                { 2031, DestroyStrayLayer },
                { 2101, SetLayerScalingMode },
                { 5202, GetDisplayVSyncEvent }
            };

            Displays = new IdDictionary();
        }
Ejemplo n.º 9
0
        public NvMapDeviceFile(ServiceCtx context) : base(context)
        {
            IdDictionary dict = _maps.GetOrAdd(Owner, (key) => new IdDictionary());

            dict.Add(0, new NvMapHandle());
        }
Ejemplo n.º 10
0
        public IpcService()
        {
            DomainObjects = new IdDictionary();

            SelfId = -1;
        }
Ejemplo n.º 11
0
        public static void InitializeNvMap(ServiceCtx Context)
        {
            IdDictionary Dict = Maps.GetOrAdd(Context.Process, (Key) => new IdDictionary());

            Dict.Add(0, new NvMapHandle());
        }
Ejemplo n.º 12
0
        public static void InitializeNvMap(ServiceCtx context)
        {
            IdDictionary dict = _maps.GetOrAdd(context.Process, (key) => new IdDictionary());

            dict.Add(0, new NvMapHandle());
        }
 public IApplicationDisplayService()
 {
     _displays = new IdDictionary();
 }
Ejemplo n.º 14
0
        public NvMapDeviceFile(ServiceCtx context, IVirtualMemoryManager memory, long owner) : base(context, owner)
        {
            IdDictionary dict = _maps.GetOrAdd(Owner, (key) => new IdDictionary());

            dict.Add(0, new NvMapHandle());
        }
Ejemplo n.º 15
0
 public KProcessHandleTable()
 {
     Handles = new IdDictionary();
 }
Ejemplo n.º 16
0
        private int CreateHandleFromMap(NvMapHandle map)
        {
            IdDictionary dict = _maps.GetOrAdd(Owner, (key) => new IdDictionary());

            return(dict.Add(map));
        }
        public override void Initialize(AnalysisContext context)
        {
            // TODO: Consider registering other actions that act on syntax instead of or in addition to symbols
            // See https://github.com/dotnet/roslyn/blob/master/docs/analyzers/Analyzer%20Actions%20Semantics.md for more information

            FieldToIDTypeBindings = new List <FieldToIDTypeBinding>();
            SameFieldSeparateSearch("Terraria.Item", "createTile", "TileID", Terraria.ID_1_3.TileID.Search, Terraria.ID_1_4.TileID.Search);
            SameFieldSeparateSearch("Terraria.Item", "type", "ItemID", Terraria.ID_1_3.ItemID.Search, Terraria.ID_1_4.ItemID.Search);
            SameFieldSeparateSearch("Terraria.Item", "shoot", "ProjectileID", Terraria.ID_1_3.ProjectileID.Search, Terraria.ID_1_4.ProjectileID.Search);
            SameFieldSeparateSearch("Terraria.Item", "useStyle", "ItemUseStyleID", IdDictionary.Create(typeof(Terraria.ID_1_3.ItemUseStyleID), typeof(int)), IdDictionary.Create(typeof(Terraria.ID_1_4.ItemUseStyleID), typeof(int)));
            SameFieldSeparateSearch("Terraria.Item", "rare", "ItemRarityID", IdDictionary.Create(typeof(Terraria.ID_1_3.ItemRarityID), typeof(int)), IdDictionary.Create(typeof(Terraria.ID_1_4.ItemRarityID), typeof(int)));
            SameFieldSeparateSearch("Terraria.NPC", "type", "NPCID", Terraria.ID_1_3.NPCID.Search, Terraria.ID_1_4.NPCID.Search);
            FieldToIDTypeBindings.Add(new FieldToIDTypeBinding("Terraria.Main", "netMode", "NetmodeID", IdDictionary.Create(typeof(Terraria.ID.NetmodeID), typeof(int))));
            SeparateFieldSeparateSearch("Terraria.ModLoader.ModTile", "soundType", "SoundType", "SoundID", Terraria.ID_1_3.SoundID.Search, Terraria.ID_1_4.SoundID.Search);
            SeparateFieldSeparateSearch("Terraria.ModLoader.ModTile", "dustType", "DustType", "DustID", Terraria.ID_1_3.DustID.Search, Terraria.ID_1_4.DustID.Search);
            SeparateFieldSeparateSearch("Terraria.ModLoader.ModWall", "dustType", "DustType", "DustID", Terraria.ID_1_3.DustID.Search, Terraria.ID_1_4.DustID.Search);

            // Helper methods for handling slight 1.4 and 1.3 differences
            void SameFieldSeparateSearch(string fullName, string field, string idType, IdDictionary idDictionary, IdDictionary idDictionary_1_4)
            {
                FieldToIDTypeBindings.Add(new FieldToIDTypeBinding(fullName, field, idType, idDictionary, tModLoaderVersion.tModLoader_1_3));
                FieldToIDTypeBindings.Add(new FieldToIDTypeBinding(fullName, field, idType, idDictionary_1_4, tModLoaderVersion.tModLoader_1_4));
            }

            void SeparateFieldSeparateSearch(string fullName, string field, string field_1_4, string idType, IdDictionary idDictionary, IdDictionary idDictionary_1_4)
            {
                FieldToIDTypeBindings.Add(new FieldToIDTypeBinding(fullName, field, idType, idDictionary, tModLoaderVersion.tModLoader_1_3));
                FieldToIDTypeBindings.Add(new FieldToIDTypeBinding(fullName, field_1_4, idType, idDictionary_1_4, tModLoaderVersion.tModLoader_1_4));
            }

            // Could check parameter name, or check parameter list and index.
            MethodParameterToIDTypeBindings = new List <MethodParameterToIDTypeBinding>();
            SameMethodSeparateSearch("Terraria.Item.CloneDefaults", "Terraria.Item.CloneDefaults(int)", new string[] { "Int32" }, 0, "ItemID", Terraria.ID_1_3.ItemID.Search, Terraria.ID_1_4.ItemID.Search);
            SameMethodSeparateSearch("Terraria.NetMessage.SendData", "Terraria.NetMessage.SendData(int, int, int, Terraria.Localization.NetworkText, int, float, float, float, int, int, int)", new string[] { "Int32", "Int32", "Int32", "NetworkText", "Int32", "Single", "Single", "Single", "Int32", "Int32", "Int32" }, 0, "MessageID", IdDictionary.Create(typeof(Terraria.ID_1_3.MessageID), typeof(byte)), IdDictionary.Create(typeof(Terraria.ID_1_4.MessageID), typeof(byte)));
            SameMethodSeparateSearch("Terraria.Dust.NewDust", "Terraria.Dust.NewDust(Microsoft.Xna.Framework.Vector2, int, int, int, float, float, int, Microsoft.Xna.Framework.Color, float)", new string[] { "Vector2", "Int32", "Int32", "Int32", "Single", "Single", "Int32", "Color", "Single" }, 3, "DustID", Terraria.ID_1_3.DustID.Search, Terraria.ID_1_4.DustID.Search);
            SameMethodSeparateSearch("Terraria.Dust.NewDustDirect", "Terraria.Dust.NewDustDirect(Microsoft.Xna.Framework.Vector2, int, int, int, float, float, int, Microsoft.Xna.Framework.Color, float)", new string[] { "Vector2", "Int32", "Int32", "Int32", "Single", "Single", "Int32", "Color", "Single" }, 3, "DustID", Terraria.ID_1_3.DustID.Search, Terraria.ID_1_4.DustID.Search);

            // 1.3 only
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.ModLoader.ModRecipe.AddTile", "Terraria.ModLoader.ModRecipe.AddTile(int)", new string[] { "Int32" }, 0, "TileID", Terraria.ID_1_3.TileID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.ModLoader.ModRecipe.AddIngredient", "Terraria.ModLoader.ModRecipe.AddIngredient(int, int)", new string[] { "Int32", "Int32" }, 0, "ItemID", Terraria.ID_1_3.ItemID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.ModLoader.ModRecipe.SetResult", "Terraria.ModLoader.ModRecipe.SetResult(int, int)", new string[] { "Int32", "Int32" }, 0, "ItemID", Terraria.ID_1_3.ItemID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Main.PlaySound", "Terraria.Main.PlaySound(int, Microsoft.Xna.Framework.Vector2, int)", new string[] { "Int32", "Vector2", "Int32" }, 0, "SoundID", Terraria.ID_1_3.SoundID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Main.PlaySound", "Terraria.Main.PlaySound(int, int, int, int, float, float)", new string[] { "Int32", "Int32", "Int32", "Int32", "Single", "Single" }, 0, "SoundID", Terraria.ID_1_3.SoundID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectile", "Terraria.Projectile.NewProjectile(Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2, int, int, float, int, float, float)", new string[] { "Vector2", "Vector2", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 2, "ProjectileID", Terraria.ID_1_3.ProjectileID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectile", "Terraria.Projectile.NewProjectile(float, float, float, float, int, int, float, int, float, float)", new string[] { "Single", "Single", "Single", "Single", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 4, "ProjectileID", Terraria.ID_1_3.ProjectileID.Search, tModLoaderVersion.tModLoader_1_3));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectileDirect", "Terraria.Projectile.NewProjectileDirect(Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2, int, int, float, int, float, float)", new string[] { "Vector2", "Vector2", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 2, "ProjectileID", Terraria.ID_1_3.ProjectileID.Search, tModLoaderVersion.tModLoader_1_3));
            //MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Dust.NewDustPerfect", "Terraria.Dust.NewDustPerfect(Microsoft.Xna.Framework.Vector2, int, Microsoft.Xna.Framework.Vector2?, int, Microsoft.Xna.Framework.Color, float)", new string[] { "Vector2", "Int32", "Vector2?", "Int32", "Color", "Single" }, 1, "DustID", DustID.Search));

            // 1.4 only
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Recipe.AddTile", "Terraria.Recipe.AddTile(int)", new string[] { "Int32" }, 0, "TileID", Terraria.ID_1_4.TileID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Recipe.AddIngredient", "Terraria.Recipe.AddIngredient(int, int)", new string[] { "Int32", "Int32" }, 0, "ItemID", Terraria.ID_1_4.ItemID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.ModLoader.Mod.CreateRecipe", "Terraria.ModLoader.Mod.CreateRecipe(int, int)", new string[] { "Int32", "Int32" }, 0, "ItemID", Terraria.ID_1_4.ItemID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Audio.SoundEngine.PlaySound", "Terraria.Audio.SoundEngine.PlaySound(int, Microsoft.Xna.Framework.Vector2, int)", new string[] { "Int32", "Vector2", "Int32" }, 0, "SoundID", Terraria.ID_1_4.SoundID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Audio.SoundEngine.PlaySound", "Terraria.Audio.SoundEngine.PlaySound(int, int, int, int, float, float)", new string[] { "Int32", "Int32", "Int32", "Int32", "Single", "Single" }, 0, "SoundID", Terraria.ID_1_4.SoundID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectile", "Terraria.Projectile.NewProjectile(Terraria.DataStructures.IEntitySource, Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2, int, int, float, int, float, float)", new string[] { "IEntitySource", "Vector2", "Vector2", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 3, "ProjectileID", Terraria.ID_1_4.ProjectileID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectile", "Terraria.Projectile.NewProjectile(Terraria.DataStructures.IEntitySource, float, float, float, float, int, int, float, int, float, float)", new string[] { "IEntitySource", "Single", "Single", "Single", "Single", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 5, "ProjectileID", Terraria.ID_1_4.ProjectileID.Search, tModLoaderVersion.tModLoader_1_4));
            MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding("Terraria.Projectile.NewProjectileDirect", "Terraria.Projectile.NewProjectileDirect(Terraria.DataStructures.IEntitySource, Microsoft.Xna.Framework.Vector2, Microsoft.Xna.Framework.Vector2, int, int, float, int, float, float)", new string[] { "IEntitySource", "Vector2", "Vector2", "Int32", "Int32", "Single", "Int32", "Single", "Single" }, 3, "ProjectileID", Terraria.ID_1_4.ProjectileID.Search, tModLoaderVersion.tModLoader_1_4));

            void SameMethodSeparateSearch(string fullyQualifiedMethodName, string fullMethodWithParameters, string[] parameterNames, int parameterIndex, string idType, IdDictionary idDictionary, IdDictionary idDictionary_1_4)
            {
                MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding(fullyQualifiedMethodName, fullMethodWithParameters, parameterNames, parameterIndex, idType, idDictionary, tModLoaderVersion.tModLoader_1_3));
                MethodParameterToIDTypeBindings.Add(new MethodParameterToIDTypeBinding(fullyQualifiedMethodName, fullMethodWithParameters, parameterNames, parameterIndex, idType, idDictionary_1_4, tModLoaderVersion.tModLoader_1_4));
            }

            // Main.rand.Next(x) == 0 => Main.rand.NextBool(x)

            // modTile.drop, modTile.dustType
            // using static ModContent
            // Detect bad AddTile AddIngredient
            // Main.player[Main.myPlayer] => Main.LocalPlayer
            // new Vector2(player.position.X + player.width / 2, player.position.Y + player.height / 2) => player.Center

            context.EnableConcurrentExecution();

            context.RegisterSyntaxNodeAction(AnalyzeMagicNumberAssignmentExpressions, SyntaxKind.SimpleAssignmentExpression);

            context.RegisterSyntaxNodeAction(AnalyzeRandNextEqualsExpressions, SyntaxKind.EqualsExpression, SyntaxKind.NotEqualsExpression);

            context.RegisterSyntaxNodeAction(AnalyzeMagicNumberEqualsExpressions, SyntaxKind.EqualsExpression,
                                             SyntaxKind.NotEqualsExpression,
                                             SyntaxKind.GreaterThanExpression,
                                             SyntaxKind.GreaterThanOrEqualExpression,
                                             SyntaxKind.LessThanExpression,
                                             SyntaxKind.LessThanOrEqualExpression);

            context.RegisterSyntaxNodeAction(AnalyzeMagicNumberInvocationExpressions, SyntaxKind.InvocationExpression);

            // context.RegisterSyntaxNodeAction(AnalyzeIncorrectParameterInvocationExpressions, SyntaxKind.InvocationExpression);

            context.RegisterCompilationAction(AnalyzeCompilation);

            context.RegisterCompilationStartAction(AnalyzeCompilationStart);
        }
Ejemplo n.º 18
0
        public IpcService()
        {
            _domainObjects = new IdDictionary();

            _selfId = -1;
        }
Ejemplo n.º 19
0
 public void CreateEmptyIdDictionary()
 {
     iIdDictionary = new IdDictionary<string, string>();
 }