Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("\n3. Access modifiers: public, protected, internal, private, protected internal\n------------------------------------");
            Modder aMod = new Modder();

            aMod.setProps(6, 4, 2, 10, "red");
            Console.WriteLine("\nProperties are: " + aMod.getProps() + "\n");
        }
Esempio n. 2
0
        /// <summary>
        /// Rebuilds the given instance's minecraft.jar
        /// </summary>
        private Modder RebuildMCJar(Instance inst)
        {
            if (!File.Exists(inst.MCJar))
            {
                MessageDialog.Show(MainWindow,
                                   "You must run the " +
                                   "instance at least " +
                                   "once before installing mods.",
                                   "Error");
                return(null);
            }

            string instVersion = inst.Version;

            Console.WriteLine("Checking mod versions for minecraft {0} instance.",
                              instVersion);
            foreach (Mod mod in inst.InstMods)
            {
                string modVersion = null;
                if (mod.MCVersion != null)
                {
                    modVersion = MCVersionMap.VersionMap[mod.MCVersion];
                }

                if (string.IsNullOrEmpty(modVersion))
                {
                    if (!string.IsNullOrEmpty(mod.MCVersion))
                    {
                        Console.WriteLine("Unknown Minecraft version: {0}", mod.MCVersion);
                    }

                    continue;
                }
                else if (modVersion != instVersion)
                {
                    DialogResponse response = MessageDialog.Show(MainWindow,
                                                                 string.Format("One of your mods ({0} for Minecraft {1}) " +
                                                                               "is not compatible with " +
                                                                               "this version of minecraft.\n" +
                                                                               "Continue installing it?",
                                                                               mod.Name, mod.MCVersion),
                                                                 "Warning", MessageButtons.OkCancel);

                    if (response == DialogResponse.Cancel)
                    {
                        return(null);
                    }
                }
            }

            Modder modder = new Modder(inst);

            modder.Completed += (sender, e) => inst.NeedsRebuild = false;
            StartTask(modder);
            return(modder);
        }
Esempio n. 3
0
            public ForeignClassModifier()
            {
                var pr = new Modder();

                if (!Modder.Default.TryGet <ForeignClass, string>(e => e.ChangeMe, out var property))
                {
                    throw new ArgumentException("Can't modify the property.");
                }

                _backer = property;
            }
        private void Write_Click(object sender, RoutedEventArgs e)
        {
            Mod = new Modder();

            //Test some hardcoded pointers first because its faster
            if (ReturnedAddress != Mod.TestAddress(ReturnedAddress, "global function GetPilotLoadoutForCurrentMapSP"))
            {
                ReturnedAddress = Mod.TestPointers(new Pointer[]
                {
                    Mod.BoomTown,
                    Mod.BoomTownStart,
                    Mod.BoomTownEnd,
                    Mod.Sewers,
                    Mod.BT_7274,
                    Mod.TimeShiftStart,
                    Mod.TimeShift,
                    Mod.TimeShiftEnd,
                    Mod.TheBeaconStart,
                    Mod.TheBeacon,
                    Mod.TheBeaconEnd,
                    Mod.TrialOfFire,
                    Mod.TheArk,
                    Mod.TheFoldWeapon
                }, "global function GetPilotLoadoutForCurrentMapSP");
            }

            if (ReturnedAddress == -1)
            {
                ReturnedAddress = Mod.findAddress(Encoding.ASCII.GetBytes("global function GetPilotLoadoutForCurrentMapSP"));
            }


            //Ask for the address
            while (ReturnedAddress == -1)
            {
                ReturnedAddress = InsertAddressBox.Show();
            }

            //Replace strings so it fits the new value
            string Finished = Loadout.Replace("%PilotLoadoutPrimary%", Primary.Text)
                              .Replace("%PilotLoadoutSecondary%", Secondary.Text)
                              .Replace("%PilotLoadoutOrdnance%", Ordnance.Text)
                              .Replace("%PilotLoadoutMelee%", Melee.Text)
                              .Replace("%PilotLoadoutSpecial%", Special.Text);


            List <byte> Data = new List <byte>(Encoding.ASCII.GetBytes(Finished));

            Data.Add(0);
            Mod.WriteMemory(ReturnedAddress, Data.ToArray());
        }
Esempio n. 5
0
 private async void Load_Click(object sender, RoutedEventArgs e)
 {
     ModLoader = new Modder();
     //Dll injection test. crude i know
     //ModLoader.InjectDll();
     Load.IsEnabled = false;
     foreach (var item in CheckBoxes)
     {
         if (item.IsChecked.Value)
         {
             await Task.Factory.StartNew(() => WriteMod(Mods[item]));
         }
     }
     Load.IsEnabled = true;
     System.Windows.Forms.MessageBox.Show("Finished loading");
 }
Esempio n. 6
0
        public void Stub(ModuleDefinition mod)
        {
            Log($"[Stub] Stubbing {mod.Assembly.Name.Name}");
            Modder.Module = mod;

            ApplyCommonChanges(mod, "Stub");

            // MonoMod needs to relink some types (f.e. XnaToFnaHelper) via FindType, which requires a dependency map.
            Log("[Stub] Mapping dependencies for MonoMod");
            Modder.MapDependencies(mod);

            Log($"[Stub] Stubbing");
            foreach (TypeDefinition type in mod.Types)
            {
                StubType(type);
            }

            Log($"[Stub] Pre-processing");
            foreach (TypeDefinition type in mod.Types)
            {
                PreProcessType(type);
            }

            Log($"[Stub] Relinking (MonoMod PatchRefs pass)");
            Modder.PatchRefs();

            Log($"[Stub] Post-processing");
            foreach (TypeDefinition type in mod.Types)
            {
                PostProcessType(type);
            }

            Log($"[Stub] Rewriting and disposing module\n");
#if !CECIL0_9
            Modder.Module.Write(Modder.WriterParameters);
#else
            Modder.Module.Write(ModulePaths[Modder.Module], Modder.WriterParameters);
#endif
            // Dispose the module so other modules can read it as a dependency again.
#if !CECIL0_9
            Modder.Module.Dispose();
#endif
            Modder.Module = null;
            Modder.ClearCaches(moduleSpecific: true);
        }
        public void DestroyMonitorLock(MethodDefinition method, int instri)
        {
            Instruction instr = method.Body.Instructions[instri];

            // Replace the Enter call.
            instr.Operand = Modder.Module.ImportReference(
                Modder.FindTypeDeep("XnaToFna.FakeMonitor").Resolve().FindMethod("System.Void Enter(System.Object,System.Boolean&)")
                );

            // Now find the matching Exit call...
            int depth = 1;

            for (; instri < method.Body.Instructions.Count && depth > 0; instri++)
            {
                instr = method.Body.Instructions[instri];
                if (instr.OpCode == OpCodes.Call)
                {
                    string id = ((MethodReference)instr.Operand).GetFindableID();
                    if (id == "System.Void System.Threading.Monitor::Enter(System.Object,System.Boolean&)")
                    {
                        // Found another Enter
                        depth++;
                        continue;
                    }
                    else if (id == "System.Void System.Threading.Monitor::Exit(System.Object)")
                    {
                        depth--;
                        continue;
                    }
                }
            }
            if (depth != 0)
            {
                return; // Whoops!... Let's just leave.
            }
            // Replace the Exit call.
            instr.Operand = Modder.Module.ImportReference(
                Modder.FindTypeDeep("XnaToFna.FakeMonitor").Resolve().FindMethod("System.Void Exit(System.Object)")
                );
        }
Esempio n. 8
0
        private void LoginComplete(LoginInfo info, Instance inst)
        {
            string mainGameUrl = "minecraft.jar";

            if (!info.Cancelled)
            {
                Console.WriteLine("Version: {0}", info.LatestVersion);

                GameUpdater updater =
                    new GameUpdater(inst,
                                    info.LatestVersion,
                                    mainGameUrl,
                                    info.ForceUpdate);

                EventHandler startDelegate = new EventHandler((e, args) =>
                {
                    if (!DirectLaunch)
                    {
                        MainWindow.Visible = false;
                    }

                    inst.Launch(info.Username, info.SessionID);

                    IConsoleWindow cwin = GUIManager.Main.ConsoleWindow(inst);

                    cwin.DefaultPosition = DefWindowPosition.CenterScreen;

                    cwin.ConsoleClosed += (e2, args2) =>
                    {
                        if (DirectLaunch)
                        {
                            Environment.Exit(0);
                        }
                        else
                        {
                            MainWindow.Invoke((e3, args3) =>
                                              MainWindow.Visible = true);
                        }
                    };

                    cwin.Show();
                });

                updater.Completed += (sender, e) =>
                {
                    if (inst.NeedsRebuild)
                    {
                        MainWindow.Invoke((sender2, e2) =>
                        {
                            Modder modder = RebuildMCJar(inst);

                            if (modder == null)
                            {
                                MainWindow.Invoke(startDelegate);
                            }
                            else
                            {
                                modder.Completed += (sender3, e3) =>
                                                    MainWindow.Invoke(startDelegate);
                            }
                        });
                    }
                    else
                    {
                        MainWindow.Invoke(startDelegate);
                    }
                };

                if (!string.IsNullOrEmpty(info.SessionID))
                {
                    MainWindow.Invoke((o2, args2) =>
                                      StartModalTask(updater));
                }
                else
                {
                    MainWindow.Invoke(startDelegate);
                }
            }
        }