Ejemplo n.º 1
0
 public static void SetupDirectRelinkMap(XnaToFnaUtil xtf, XnaToFnaMapping mapping, Action <XnaToFnaUtil, TypeDefinition> action)
 {
     foreach (TypeDefinition type in mapping.Module.Types)
     {
         SetupDirectRelinkMapType(xtf, type, action);
     }
 }
Ejemplo n.º 2
0
        public static void SetupGSRelinkMap(XnaToFnaUtil xtf, XnaToFnaMapping mapping)
        {
            // Required for some X360 titles.

            SetupDirectRelinkMap(xtf, mapping, (_, type) => {
                // Fix .GamerServices references pointing to .Game by creating direct type mappings.
                xtf.Modder.RelinkMap[type.FullName] = type;
                // Fix .GamerServices references being in the .Net namespace in our replacement assembly.
                if (type.FullName.Contains(".Net."))
                {
                    xtf.Modder.RelinkMap[type.FullName.Replace(".Net.", ".GamerServices.")] = type;
                }
            });
        }
Ejemplo n.º 3
0
        public static void SetupDirectRelinkMapType(XnaToFnaUtil xtf, TypeDefinition type, Action <XnaToFnaUtil, TypeDefinition> action)
        {
            if (action != null)
            {
                action(xtf, type);
            }
            else
            {
                xtf.Modder.RelinkMap[type.FullName] = type;
            }

            foreach (TypeDefinition nested in type.NestedTypes)
            {
                SetupDirectRelinkMapType(xtf, nested, action);
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            XnaToFnaUtil xtf = new XnaToFnaUtil();

            Console.WriteLine($"XnaToFna {XnaToFnaUtil.Version}");
            Console.WriteLine($"using MonoMod {MonoModder.Version}");

            bool showHelp    = false;
            bool showVersion = false;
            bool relinkOnly  = false;

            OptionSet options = new OptionSet {
                { "h|help", "Show this message and exit.", v => showHelp = v != null },
                { "v|version", "Show the version and exit.", v => showVersion = v != null },
                { "profile=", "Choose between multiple base profiles:\ndefault, minimal, forms", v => {
                      switch (v.ToLowerInvariant())
                      {
                      case "default":
                          xtf.HookCompat          = true;
                          xtf.HookHacks           = true;
                          xtf.HookEntryPoint      = false;
                          xtf.HookLocks           = false;
                          xtf.FixOldMonoXML       = false;
                          xtf.HookBinaryFormatter = true;
                          xtf.HookReflection      = true;
                          break;

                      case "minimal":
                          xtf.HookCompat          = false;
                          xtf.HookHacks           = false;
                          xtf.HookEntryPoint      = false;
                          xtf.HookLocks           = false;
                          xtf.FixOldMonoXML       = false;
                          xtf.HookBinaryFormatter = false;
                          xtf.HookReflection      = false;
                          break;

                      case "forms":
                          xtf.HookCompat          = true;
                          xtf.HookHacks           = false;
                          xtf.HookEntryPoint      = true;
                          xtf.HookLocks           = false;
                          xtf.FixOldMonoXML       = false;
                          xtf.HookBinaryFormatter = false;
                          xtf.HookReflection      = false;
                          break;
                      }
                  } },

                { "relinkonly=", "Only read and write the assemblies listed.", (bool v) => relinkOnly = v },

                { "hook-compat=", "Toggle Forms and P/Invoke compatibility hooks.", (bool v) => xtf.HookCompat = v },
                { "hook-hacks=", "Toggle some hack hooks, f.e.\nXNATOFNA_DISPLAY_FULLSCREEN", (bool v) => xtf.HookEntryPoint = v },
                { "hook-locks=", "Toggle if locks should be \"destroyed\" or not.", (bool v) => xtf.HookLocks = v },
                { "hook-oldmonoxml=", "Toggle basic XML serialization fixes.\nPlease try updating mono first!", (bool v) => xtf.FixOldMonoXML = v },
                { "hook-binaryformatter=", "Toggle BinaryFormatter-related fixes.", (bool v) => xtf.HookBinaryFormatter = v },
                { "hook-reflection=", "Toggle reflection-related fixes.", (bool v) => xtf.HookBinaryFormatter = v },
                { "hook-patharg=", "Hook the given method to receive fixed paths.\nCan be used multiple times.", v => xtf.FixPathsFor.Add(v) },

                { "ilplatform=", "Choose the target IL platform:\nkeep, x86, x64, anycpu, x86pref", v => xtf.PreferredPlatform = ParseEnum(v, ILPlatform.Keep) },
                { "mixeddeps=", "Choose the action performed to mixed dependencies:\nkeep, stub, remove", v => xtf.MixedDeps = ParseEnum(v, MixedDepAction.Keep) },
                { "removepublickeytoken=", "Remove the public key token of a dependency.\nCan be used multiple times.", v => xtf.DestroyPublicKeyTokens.Add(v) },
            };

            void WriteHelp(TextWriter writer)
            {
                writer.WriteLine("Usage: <mono> XnaToFna.exe [options] <--> FileOrDir <FileOrDir> <...>");
                options.WriteOptionDescriptions(writer);
            }

            List <string> extra;

            try {
                extra = options.Parse(args);
            } catch (OptionException e) {
                Console.Error.Write("Command parse error: ");
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine();
                WriteHelp(Console.Error);
                return;
            }

            if (showVersion)
            {
                return;
            }

            if (showHelp)
            {
                WriteHelp(Console.Out);
                return;
            }

            foreach (string arg in extra)
            {
                xtf.ScanPath(arg);
            }

            if (!relinkOnly && !Debugger.IsAttached) // Otherwise catches XnaToFna.vshost.exe
            {
                xtf.ScanPath(Directory.GetCurrentDirectory());
            }

            xtf.OrderModules();

            xtf.RelinkAll();

            xtf.Log("[Main] Done!");

            if (Debugger.IsAttached) // Keep window open when running in IDE
            {
                Console.ReadKey();
            }
        }
Ejemplo n.º 5
0
 public static void SetupDirectRelinkMap(XnaToFnaUtil xtf, XnaToFnaMapping mapping)
 {
     SetupDirectRelinkMap(xtf, mapping, null);
 }
Ejemplo n.º 6
0
 public XnaToFnaModder(XnaToFnaUtil xtf)
 {
     XTF = xtf;
 }