コード例 #1
0
ファイル: ScrollsPost.cs プロジェクト: noHero123/ScrollsPost
        public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
        {
            try {
                return new MethodDefinition[] {
                    scrollsTypes["Communicator"].Methods.GetMethod("sendRequest", new Type[]{ typeof(Message) }),
                    scrollsTypes["TradeSystem"].Methods.GetMethod("StartTrade", new Type[]{ typeof( List<Card>), typeof( List<Card>) ,typeof( string), typeof( string ), typeof( int) }),
                    scrollsTypes["TradeSystem"].Methods.GetMethod("CloseTrade")[0],
                    scrollsTypes["TradeSystem"].Methods.GetMethod("UpdateView", new Type[]{typeof(bool), typeof(TradeInfo), typeof(TradeInfo)}),
                    scrollsTypes["CardView"].Methods.GetMethod("updateGraphics",new Type[]{typeof(Card)}),

                    scrollsTypes["AnimPlayer"].Methods.GetMethod("UpdateOnly")[0],

                    scrollsTypes["EndGameScreen"].Methods.GetMethod("GoToLobby")[0],

                    scrollsTypes["BattleMode"].Methods.GetMethod("addDelay",new Type[]{typeof(float)}),
                    scrollsTypes["iTween"].Methods.GetMethod("Launch",new Type[]{typeof(GameObject),typeof(Hashtable)}),
                    scrollsTypes["BattleMode"].Methods.GetMethod("OnGUI")[0],
                    scrollsTypes["BattleModeUI"].Methods.GetMethod("ShowEndTurn",new Type[]{typeof(bool)}),
                    scrollsTypes["GUIBattleModeMenu"].Methods.GetMethod("toggleMenu")[0],

                    scrollsTypes["DeckBuilder2"].Methods.GetMethod("OnGUI")[0],

                    scrollsTypes["GameSocket"].Methods.GetMethod("Init", new Type[]{ typeof(ISocketListener) }),
                    //scrollsTypes["ProfileMenu"].Methods.GetMethod("Start")[0],
                };
            } catch( Exception ex ) {
                Console.WriteLine("****** HOOK FAILURE {0}", ex.ToString());
                return new MethodDefinition[] { };
            }
        }
コード例 #2
0
 public PatchModsMenu(TypeDefinitionCollection types, ModLoader loader)
     : base(types)
 {
     this.loader = loader;
     this.modManager = this.loader.modManager;
     this.repoManager = modManager.repoManager;
 }
コード例 #3
0
ファイル: ScrollsPost.cs プロジェクト: Tomseibert/ScrollsPost
        public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
        {
            try {
                return new MethodDefinition[] {
                    scrollsTypes["Communicator"].Methods.GetMethod("sendRequest", new Type[]{ typeof(Message) }),
                    scrollsTypes["TradeSystem"].Methods.GetMethod("StartTrade")[0],
                    scrollsTypes["TradeSystem"].Methods.GetMethod("CloseTrade")[0],
                    scrollsTypes["TradeSystem"].Methods.GetMethod("UpdateView")[0],
                    scrollsTypes["CardView"].Methods.GetMethod("updateGraphics")[0],

                    scrollsTypes["AnimPlayer"].Methods.GetMethod("UpdateOnly")[0],

                    scrollsTypes["Communicator"].Methods.GetMethod("handleNextMessage")[0],
                    scrollsTypes["Communicator"].Methods.GetMethod("Update")[0],

                    scrollsTypes["EndGameScreen"].Methods.GetMethod("GoToLobby")[0],

                    scrollsTypes["BattleMode"].Methods.GetMethod("addDelay")[0],
                    scrollsTypes["BattleMode"].Methods.GetMethod("effectDone")[0],
                    scrollsTypes["iTween"].Methods.GetMethod("Launch")[0],
                    scrollsTypes["BattleMode"].Methods.GetMethod("OnGUI")[0],
                    scrollsTypes["BattleModeUI"].Methods.GetMethod("ShowEndTurn")[0],
                    scrollsTypes["GUIBattleModeMenu"].Methods.GetMethod("toggleMenu")[0],

                    scrollsTypes["DeckBuilder2"].Methods.GetMethod("OnGUI")[0]

                    //scrollsTypes["ProfileMenu"].Methods.GetMethod("Start")[0],
                };
            } catch( Exception ex ) {
                Console.WriteLine("****** HOOK FAILURE {0}", ex.ToString());
                return new MethodDefinition[] { };
            }
        }
コード例 #4
0
ファイル: Patch.cs プロジェクト: svgorbunov/ScrollsModLoader
 public Patch(TypeDefinitionCollection scrolls)
 {
     assembly = scrolls;
     foreach (MethodDefinition def in this.patchedMethods()) {
         ScrollsFilter.AddHook (def);
     }
 }
コード例 #5
0
ファイル: ChatCommands.cs プロジェクト: kbasten/ChatCommands
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try {
         return new MethodDefinition[] {
             scrollsTypes["ChatRooms"].Methods.GetMethod("ChatMessage", new Type[]{typeof(RoomChatMessageMessage)}),
             scrollsTypes["Communicator"].Methods.GetMethod("sendRequest", new Type[]{typeof(Message)})
         };
     } catch {
         return new MethodDefinition[] { };
     }
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: kevinskyba/ScrollsModLoader
 public static MethodDefinition[] GetPlayerHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     return new MethodDefinition[] { scrollsTypes["Communicator"].Methods.GetMethod("readNextMessage")[0],
                                     scrollsTypes["GUIBattleModeMenu"].Methods.GetMethod("toggleMenu")[0],
                                     scrollsTypes["BattleMode"].Methods.GetMethod("OnGUI")[0],
                                     scrollsTypes["BattleModeUI"].Methods.GetMethod("Start")[0],
                                     scrollsTypes["BattleModeUI"].Methods.GetMethod("Init")[0],
                                     scrollsTypes["BattleModeUI"].Methods.GetMethod("Raycast")[0],
                                     scrollsTypes["BattleModeUI"].Methods.GetMethod("ShowEndTurn")[0]
                                    };
 }
コード例 #7
0
ファイル: Mod.cs プロジェクト: jsbannis/AnimationControl
 //only return MethodDefinitions you obtained through the scrollsTypes object
 //safety first! surround with try/catch and return an empty array in case it fails
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     return new MethodDefinition[]
     {
         // unit speedup logic
         scrollsTypes["iTween"].Methods.GetMethod("Launch")[0],
         scrollsTypes["AnimPlayer"].Methods.GetMethod("UpdateOnly")[0],
         // configuration
         scrollsTypes["SettingsMenu"].Methods.GetMethod("OnGUI")[0],
         scrollsTypes["SceneLoader"].Methods.GetMethod("loadScene")[0],
     };
 }
コード例 #8
0
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try
     {
         return new MethodDefinition[] {
                 scrollsTypes["DeckBuilder2"].Methods.GetMethod("OnGUI")[0] // to draw gui buttons on the deckbuilder screen
         };
     }
     catch
     {
         return new MethodDefinition[] { };
     }
 }
コード例 #9
0
		public TypeReference GetTypeDefinition (TypeDefinitionCollection members, TypeReference member)
		{
			foreach (TypeReference mr in members) {
				if ((mr.FullName == member.FullName)
				    && ((mr.DeclaringType == null && member.DeclaringType == null)
				        || (mr.DeclaringType != null && member.DeclaringType != null
				            && mr.DeclaringType.FullName == member.DeclaringType.FullName
				           )
				       )
					)
					return mr;
			}
			return null;
		}
コード例 #10
0
ファイル: PlayerInfo.cs プロジェクト: kbasten/PlayerInfo
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try
     {
         return new MethodDefinition[] {
             // hook handleMessage in battlemode for the GameInfo message for getting the opponent name
             scrollsTypes["BattleMode"].Methods.GetMethod("handleMessage", new Type[]{typeof(Message)}),
         };
     }
     catch
     {
         return new MethodDefinition[] { };
     }
 }
コード例 #11
0
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try
     {
         return new MethodDefinition[] {
             scrollsTypes["MainMenu"].Methods.GetMethod("Start")[0],
             scrollsTypes["Communicator"].Methods.GetMethod("sendRequest", new Type[]{typeof(Message)}),
             scrollsTypes["ArenaChat"].Methods.GetMethod("RoomEnter")[0],
         };
     }
     catch
     {
         return new MethodDefinition[] { };
     }
 }
コード例 #12
0
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try
     {
         return new MethodDefinition[] {
             scrollsTypes["Login"].Methods.GetMethod("loadSettings")[0],
             scrollsTypes["Login"].Methods.GetMethod("saveSettings")[0],
             scrollsTypes["ApplicationController"].Methods.GetMethod("compareVersions", new Type[] { typeof(int) })
         };
     }
     catch
     {
         return new MethodDefinition[] {};
     }
 }
コード例 #13
0
 public IAssembly CreateMockAssembly(params Type[] include)
 {
     IAssembly assembly = _mocks.DynamicMock<IAssembly>();
       TypeDefinitionCollection mockTypes = new TypeDefinitionCollection(TestingAssembly.MainModule);
       foreach (TypeDefinition type in TestingAssembly.MainModule.Types)
       {
     foreach (Type reflected in include)
     {
       if (reflected.FullName == type.FullName)
       {
     mockTypes.Add(type.Clone());
       }
     }
       }
       SetupResult.For(assembly.Types).Return(mockTypes);
       return assembly;
 }
コード例 #14
0
        public PatchModsMenu(TypeDefinitionCollection types)
            : base(types)
        {
            //get mod list

            //add mods
            repositories.Add (new Repo("ScrollsGuide", "http://Scrollsguide.com/repo"));

            downloadableMods.Add (new Mod("GameRecorder", "Record Games!", "v1.0"));
            downloadableMods.Add (new Mod("DeckSync", "Export/Import Decks!", "v1.0"));
            for (int i=0; i < 30; i++)
                downloadableMods.Add (new Mod("TestMod", "Fill that List!", "v2.0!"));

            installedMods.Add(new Mod("Logger", "Debug Network logging", "v0.1"));

            //downloadableMods.Add (new Mod("DeckSync"));
        }
コード例 #15
0
 public static MethodDefinition[] GetHooks(TypeDefinitionCollection scrollsTypes, int version)
 {
     try {
         return new MethodDefinition[] {
             scrollsTypes["BattleMode"].Methods.GetMethod("handleInput")[0],
             scrollsTypes["BattleMode"].Methods.GetMethod("OnGUI")[0],
             scrollsTypes["EndGameScreen"].Methods.GetMethod("OnGUI")[0],
             scrollsTypes["LobbyMenu"].Methods.GetMethod("Update")[0],
             scrollsTypes["LobbyMenu"].Methods.GetMethod("OnGUI")[0],
             scrollsTypes["LobbyMenu"].Methods.GetMethod("fadeOutScene")[0],
             scrollsTypes["Login"].Methods.GetMethod("OnGUI")[0],
             scrollsTypes["Popups"].Methods.GetMethod("OnGUI")[0],
             scrollsTypes["SettingsMenu"].Methods.GetMethod("OnGUI")[0],
             //scrollsTypes["Tile"].Methods.GetMethod("FixedUpdate")[0],
         };
     }
     catch {
         return new MethodDefinition[] { };
     }
 }
コード例 #16
0
        internal ModuleDefinition(string name, AssemblyDefinition asm, StructureReader reader, bool main) : base(name)
        {
            if (asm == null)
            {
                throw new ArgumentNullException("asm");
            }
            if (name == null || name.Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            m_asm  = asm;
            m_main = main;
#if !CF_1_0
            m_mvid = Guid.NewGuid();
#endif
            if (reader != null)
            {
                m_image        = reader.Image;
                m_imgReader    = reader.ImageReader;
                m_manifestOnly = reader.ManifestOnly;
            }
            else
            {
                m_image = Image.CreateImage();
            }

            m_modRefs = new ModuleReferenceCollection(this);
            m_asmRefs = new AssemblyNameReferenceCollection(this);
            m_res     = new ResourceCollection(this);
            m_types   = new TypeDefinitionCollection(this);
            m_types.OnTypeDefinitionAdded   += new TypeDefinitionEventHandler(OnTypeDefinitionAdded);
            m_types.OnTypeDefinitionRemoved += new TypeDefinitionEventHandler(OnTypeDefinitionRemoved);
            m_refs = new TypeReferenceCollection(this);
            m_refs.OnTypeReferenceAdded   += new TypeReferenceEventHandler(OnTypeReferenceAdded);
            m_refs.OnTypeReferenceRemoved += new TypeReferenceEventHandler(OnTypeReferenceRemoved);
            m_members = new MemberReferenceCollection(this);

            m_controller = new ReflectionController(this);
        }
コード例 #17
0
        public override void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
        {
            base.VisitTypeDefinitionCollection(types);

            ReadGenericParameterConstraints();
            ReadClassLayoutInfos();
            ReadFieldLayoutInfos();
            ReadPInvokeInfos();
            ReadProperties();
            ReadEvents();
            ReadSemantics();
            ReadInterfaces();
            ReadOverrides();
            ReadSecurityDeclarations();
            ReadCustomAttributes();
            ReadConstants();
            ReadExternTypes();
            ReadMarshalSpecs();
            ReadInitialValues();

            m_events     = null;
            m_properties = null;
            m_parameters = null;
        }
コード例 #18
0
		public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
		{
			base.VisitTypeDefinitionCollection (types);

			ReadGenericParameterConstraints ();
			ReadClassLayoutInfos ();
			ReadFieldLayoutInfos ();
			ReadPInvokeInfos ();
			ReadProperties ();
			ReadEvents ();
			ReadSemantics ();
			ReadInterfaces ();
			ReadOverrides ();
			ReadSecurityDeclarations ();
			ReadCustomAttributes ();
			ReadConstants ();
			ReadExternTypes ();
			ReadMarshalSpecs ();
			ReadInitialValues ();

			m_events = null;
			m_properties = null;
			m_parameters = null;
		}
コード例 #19
0
			public CecilProjectContent(string fullName, string fileName, AssemblyName[] referencedAssemblies,
			                           TypeDefinitionCollection types, ProjectContentRegistry registry)
				: base(fullName, fileName, referencedAssemblies, registry)
			{
				foreach (TypeDefinition td in types) {
					if ((td.Attributes & TypeAttributes.Public) == TypeAttributes.Public) {
						if ((td.Attributes & TypeAttributes.NestedAssembly) == TypeAttributes.NestedAssembly
						    || (td.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate
						    || (td.Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem)
						{
							continue;
						}
						string name = td.FullName;
						if (name.Length == 0 || name[0] == '<')
							continue;
						if (name.Length > 2 && name[name.Length - 2] == '`')
							name = name.Substring(0, name.Length - 2);
						AddClassToNamespaceListInternal(new CecilClass(this.AssemblyCompilationUnit, null, td, name));
					}
				}
				InitializeSpecialClasses();
			}
コード例 #20
0
		public override void VisitTypeDefinitionCollection (TypeDefinitionCollection types)
		{
			VisitCollection (types);
		}
コード例 #21
0
 public virtual void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
 {
     foreach (TypeDefinition typeDef in types)
     {
         VisitTypeDefinition(typeDef);
     }
 }
コード例 #22
0
        /*public void handleMessage(Message msg)
        {

            if (msg is RoomInfoMessage)
            {

                JsonReader jsonReader = new JsonReader();
                Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText());
                Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["profiles"];
                string tmpid = "";
                string tmpname = "";
                for (int i = 0; i < d.GetLength(0); i++)
                {
                    tmpid=d[i]["id"].ToString();
                    tmpname = d[i]["name"].ToString();
                    playerinfo tmpplayer = new playerinfo();
                    tmpplayer.name = tmpname;
                    tmpplayer.ID = tmpid;

                    if (!liplayerinfo.Contains(tmpplayer)) { liplayerinfo.Add(tmpplayer); }
                }

                

            }
            
            return;
        }

        public void onReconnect()
        {
            return; // don't care
        }*/

       

		//only return MethodDefinitions you obtained through the scrollsTypes object
		//safety first! surround with try/catch and return an empty array in case it fails
		public static MethodDefinition[] GetHooks (TypeDefinitionCollection scrollsTypes, int version)
		{
            try
            {
                return new MethodDefinition[] {
                    scrollsTypes["BattleMode"].Methods.GetMethod("sendBattleRequest", new Type[]{typeof(Message)}),
                    scrollsTypes["BattleMode"].Methods.GetMethod("OnGUI")[0],
                    scrollsTypes["BattleMode"].Methods.GetMethod("Update")[0],

                    scrollsTypes["BattleMode"].Methods.GetMethod("tileOver", new Type[]{typeof(TilePosition)} ),
                    scrollsTypes["BattleMode"].Methods.GetMethod("tileOut", new Type[]{typeof(GameObject),typeof(int),typeof(int)} ),
                    scrollsTypes["BattleMode"].Methods.GetMethod("toggleUnitStats")[0],

                    scrollsTypes["Unit"].Methods.GetMethod("renderUnit")[0],

                    scrollsTypes["BattleMode"].Methods.GetMethod("markMoveTile", new Type[]{typeof(TilePosition),typeof(TilePosition)} ),
                    scrollsTypes["Tile"].Methods.GetMethod("markInternal", new Type[]{typeof(Tile.SelectionType),typeof(float)} ),

                    scrollsTypes["BattleMode"].Methods.GetMethod("forceRunEffect", new Type[]{typeof(EffectMessage)}),
                    
                    // scrollsTypes["BattlemodeUI"].Methods.GetMethod("Update")[0],
                    //scrollsTypes["Tile"].Methods.GetMethod("updateMoveAnim")[0],
                   //scrollsTypes["ChatUI"].Methods.GetMethod("OnGUI")[0],

             };
            }
            catch
            {
                return new MethodDefinition[] { };
            }
		}
コード例 #23
0
 public void loadModsStatic(TypeDefinitionCollection types)
 {
     //get Mods
     foreach (LocalMod mod in modManager.installedMods) {
         if (mod.enabled) {
             if (this.loadModStatic (mod.installPath) == null) {
                 modManager.disableMod(mod, false);
                 modOrder.Remove (mod.localId);
             }
         }
     }
 }
コード例 #24
0
        public virtual void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
        {

        }
コード例 #25
0
 public void loadModStatic(TypeDefinitionCollection types, String filepath)
 {
     this._loadModStatic (types, filepath);
 }
コード例 #26
0
        public void loadPatches(TypeDefinitionCollection types)
        {
            //get Patches
            patches.Add (new PatchUpdater (types));
            patches.Add (new PatchPopups (types));
            //patches.Add(new PatchOffline(types));

            PatchSettingsMenu settingsMenuHook = new PatchSettingsMenu (types);
            publicAPI.setSceneCallback (settingsMenuHook);
            patches.Add (settingsMenuHook);

            PatchModsMenu modMenuHook = new PatchModsMenu (types, this);
            modMenuHook.Initialize (publicAPI);
            patches.Add (modMenuHook);

            //add Hooks
            addPatchHooks ();
        }
コード例 #27
0
        internal ModuleDefinition(string name, AssemblyDefinition asm, StructureReader reader, bool main)
            : base(name)
        {
            if (asm == null)
                throw new ArgumentNullException ("asm");
            if (name == null || name.Length == 0)
                throw new ArgumentNullException ("name");

            m_asm = asm;
            m_main = main;
            #if !CF_1_0
            m_mvid = Guid.NewGuid ();
            #endif
            if (reader != null) {
                m_image = reader.Image;
                m_imgReader = reader.ImageReader;
                m_manifestOnly = reader.ManifestOnly;
            } else
                m_image = Image.CreateImage ();

            m_modRefs = new ModuleReferenceCollection (this);
            m_asmRefs = new AssemblyNameReferenceCollection (this);
            m_res = new ResourceCollection (this);
            m_types = new TypeDefinitionCollection (this);
            m_types.OnTypeDefinitionAdded += new TypeDefinitionEventHandler (OnTypeDefinitionAdded);
            m_types.OnTypeDefinitionRemoved += new TypeDefinitionEventHandler (OnTypeDefinitionRemoved);
            m_refs = new TypeReferenceCollection (this);
            m_refs.OnTypeReferenceAdded += new TypeReferenceEventHandler (OnTypeReferenceAdded);
            m_refs.OnTypeReferenceRemoved += new TypeReferenceEventHandler (OnTypeReferenceRemoved);
            m_members = new MemberReferenceCollection (this);

            m_controller = new ReflectionController (this);
        }
コード例 #28
0
 public PatchPopups(TypeDefinitionCollection types)
     : base(types)
 {
     instance = this;
 }
コード例 #29
0
        public override void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
        {
            // type def reading
            TypeDefTable typesTable = m_tableReader.GetTypeDefTable();

            m_typeDefs = new TypeDefinition [typesTable.Rows.Count];
            for (int i = 0; i < typesTable.Rows.Count; i++)
            {
                TypeDefRow     type = typesTable [i];
                TypeDefinition t    = new TypeDefinition(
                    m_root.Streams.StringsHeap [type.Name],
                    m_root.Streams.StringsHeap [type.Namespace],
                    type.Flags);
                t.MetadataToken = MetadataToken.FromMetadataRow(TokenType.TypeDef, i);

                m_typeDefs [i] = t;
            }

            // nested types
            if (m_tHeap.HasTable(NestedClassTable.RId))
            {
                NestedClassTable nested = m_tableReader.GetNestedClassTable();
                for (int i = 0; i < nested.Rows.Count; i++)
                {
                    NestedClassRow row = nested [i];

                    TypeDefinition parent = GetTypeDefAt(row.EnclosingClass);
                    TypeDefinition child  = GetTypeDefAt(row.NestedClass);

                    parent.NestedTypes.Add(child);
                }
            }

            foreach (TypeDefinition type in m_typeDefs)
            {
                types.Add(type);
            }

            // type ref reading
            if (m_tHeap.HasTable(TypeRefTable.RId))
            {
                TypeRefTable typesRef = m_tableReader.GetTypeRefTable();

                m_typeRefs = new TypeReference [typesRef.Rows.Count];

                for (int i = 0; i < typesRef.Rows.Count; i++)
                {
                    AddTypeRef(typesRef, i);
                }
            }
            else
            {
                m_typeRefs = new TypeReference [0];
            }

            ReadTypeSpecs();
            ReadMethodSpecs();

            ReadMethods();
            ReadGenericParameters();

            // set base types
            for (int i = 0; i < typesTable.Rows.Count; i++)
            {
                TypeDefRow     type  = typesTable [i];
                TypeDefinition child = m_typeDefs [i];
                child.BaseType = GetTypeDefOrRef(type.Extends, new GenericContext(child));
            }

            CompleteMethods();
            ReadAllFields();
            ReadMemberReferences();
        }
コード例 #30
0
ファイル: ReflectionReader.cs プロジェクト: contra/DotNOS
        public override void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
        {
            // type def reading
            TypeDefTable typesTable = m_tableReader.GetTypeDefTable ();
            m_typeDefs = new TypeDefinition [typesTable.Rows.Count];
            for (int i = 0; i < typesTable.Rows.Count; i++) {
                TypeDefRow type = typesTable [i];
                TypeDefinition t = new TypeDefinition (
                    m_root.Streams.StringsHeap [type.Name],
                    m_root.Streams.StringsHeap [type.Namespace],
                    type.Flags);
                t.MetadataToken = MetadataToken.FromMetadataRow (TokenType.TypeDef, i);

                m_typeDefs [i] = t;
            }

            // nested types
            if (m_tHeap.HasTable (NestedClassTable.RId)) {
                NestedClassTable nested = m_tableReader.GetNestedClassTable ();
                for (int i = 0; i < nested.Rows.Count; i++) {
                    NestedClassRow row = nested [i];

                    TypeDefinition parent = GetTypeDefAt (row.EnclosingClass);
                    TypeDefinition child = GetTypeDefAt (row.NestedClass);

                    if (!IsDeleted (child))
                        parent.NestedTypes.Add (child);
                }
            }

            foreach (TypeDefinition type in m_typeDefs)
                if (!IsDeleted (type))
                    types.Add (type);

            // type ref reading
            if (m_tHeap.HasTable (TypeRefTable.RId)) {
                TypeRefTable typesRef = m_tableReader.GetTypeRefTable ();

                m_typeRefs = new TypeReference [typesRef.Rows.Count];

                for (int i = 0; i < typesRef.Rows.Count; i++)
                    AddTypeRef (typesRef, i);
            } else
                m_typeRefs = new TypeReference [0];

            ReadTypeSpecs ();
            ReadMethodSpecs ();

            ReadMethods ();
            ReadGenericParameters ();

            // set base types
            for (int i = 0; i < typesTable.Rows.Count; i++) {
                TypeDefRow type = typesTable [i];
                TypeDefinition child = m_typeDefs [i];
                child.BaseType = GetTypeDefOrRef (type.Extends, new GenericContext (child));
            }

            CompleteMethods ();
            ReadAllFields ();
            ReadMemberReferences ();
        }
コード例 #31
0
 public virtual void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
 {
 }
コード例 #32
0
        public override void VisitTypeDefinitionCollection(TypeDefinitionCollection types)
        {
            TypeDefTable tdTable = m_tableWriter.GetTypeDefTable ();

            if (types [Constants.ModuleType] == null)
                types.Add (new TypeDefinition (
                        Constants.ModuleType, string.Empty, TypeAttributes.NotPublic));

            foreach (TypeDefinition t in types)
                m_typeDefStack.Add (t);

            (m_typeDefStack as ArrayList).Sort (TableComparers.TypeDef.Instance);

            for (int i = 0; i < m_typeDefStack.Count; i++) {
                TypeDefinition t = (TypeDefinition) m_typeDefStack [i];
                if (t.Module.Assembly != m_mod.Assembly)
                    throw new ReflectionException ("A type as not been correctly imported");

                t.MetadataToken = new MetadataToken (TokenType.TypeDef, (uint) (i + 1));
            }

            foreach (TypeDefinition t in m_typeDefStack) {
                TypeDefRow tdRow = m_rowWriter.CreateTypeDefRow (
                    t.Attributes,
                    m_mdWriter.AddString (t.Name),
                    m_mdWriter.AddString (t.Namespace),
                    GetTypeDefOrRefToken (t.BaseType),
                    0,
                    0);

                tdTable.Rows.Add (tdRow);
            }
        }
コード例 #33
0
ファイル: guildchat.cs プロジェクト: noHero123/guildchat.mod
		//only return MethodDefinitions you obtained through the scrollsTypes object
		//safety first! surround with try/catch and return an empty array in case it fails
		public static MethodDefinition[] GetHooks (TypeDefinitionCollection scrollsTypes, int version)
		{
            try
            {
                return new MethodDefinition[] {
                    scrollsTypes["BattleMode"].Methods.GetMethod("sendBattleRequest", new Type[]{typeof(Message)}),
                    scrollsTypes["ChatUI"].Methods.GetMethod("Initiate")[0],
                    scrollsTypes["ChatUI"].Methods.GetMethod("Awake")[0],
                    scrollsTypes["ChatUI"].Methods.GetMethod("OnGUI")[0],
                    scrollsTypes["ChatUI"].Methods.GetMethod("Show", new Type[]{typeof(bool)}),
                    scrollsTypes["ArenaChat"].Methods.GetMethod("handleMessage", new Type[]{typeof(Message)}),
                    scrollsTypes["Communicator"].Methods.GetMethod("sendRequest", new Type[]{typeof(Message)}), 
                    scrollsTypes["ChatUI"].Methods.GetMethod("OnSendMessage",new Type[]{typeof(Room), typeof(string)}),
                    scrollsTypes["MainMenu"].Methods.GetMethod("OnGUI")[0],
                    scrollsTypes["GameSocket"].Methods.GetMethod("OnDestroy")[0],
             };
            }
            catch
            {
                return new MethodDefinition[] { };
            }
		}
コード例 #34
0
        private Mod _loadModStatic(TypeDefinitionCollection types, String filepath)
        {
            ResolveEventHandler resolver = new ResolveEventHandler(CurrentDomainOnAssemblyResolve);
            AppDomain.CurrentDomain.AssemblyResolve += resolver;

            Assembly modAsm = null;
            try {
                modAsm = Assembly.LoadFile(filepath);
            } catch (BadImageFormatException) {
                AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                return null;
            }
            Type modClass = (from _modClass in modAsm.GetTypes ()
                             where _modClass.InheritsFrom (typeof(ScrollsModLoader.Interfaces.BaseMod))
                             select _modClass).First();

            //no mod classes??
            if (modClass == null) {
                AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                return null;
            }

            //get hooks
            MethodDefinition[] hooks = null;
            try {
                hooks =(MethodDefinition[]) modClass.GetMethod ("GetHooks").Invoke (null, new object[] {
                    types,
                    SharedConstants.getExeVersionInt ()
                });
            } catch (Exception e) {
                Console.WriteLine ("Error executing GetHooks for mod: " + filepath);
                Console.WriteLine (e);
                AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                return null;
            }

            TypeDefinition[] typeDefs = new TypeDefinition[types.Count];
            types.CopyTo(typeDefs, 0);

            //check hooks
            foreach (MethodDefinition hook in hooks) {
                //type/method does not exists
                if (hook == null) {
                    Console.WriteLine ("ERROR: GetHooks contains 'null'! ");
                    Console.WriteLine ("=> Disabling " + filepath);
                    AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                    return null;
                }
                if ((from type in typeDefs
                     where type.Equals(hook.DeclaringType) //Code above avoids NullReferenceException when hook is null.
                     select type).Count() == 0) {
                    //disable mod
                    Console.WriteLine ("ERROR: Mod hooks unexistant method! " + filepath);
                    AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                    return null;
                }
            }

            //add hooks
            foreach (MethodDefinition hook in hooks) {
                ScrollsFilter.AddHook (hook);
            }

            //mod object for local mods on ModManager
            Mod mod = new Mod();
            try {
                mod.id = "00000000000000000000000000000000";
                mod.name = (String)modClass.GetMethod("GetName").Invoke(null, null);
                mod.version = (int)modClass.GetMethod("GetVersion").Invoke(null, null);
                mod.versionCode = ""+mod.version;
                mod.description = "";
            } catch (Exception e){
                Console.WriteLine ("Error getting Name or Version: ");
                Console.WriteLine (e);
                AppDomain.CurrentDomain.AssemblyResolve -= resolver;
                return null;
            }

            AppDomain.CurrentDomain.AssemblyResolve -= resolver;
            return mod;
        }