public void askChat(CSteamID steamID, byte mode, string text) { // Set the variables bool cancel = false; UnturnedPlayer player = UnturnedPlayer.Get(steamID); // Run methods ChatEvents.RunChatted(ref player, ref mode, ref text, ref cancel); // Do checks if (player?.SteamID == null || player.SteamID == CSteamID.Nil) { return; } if (string.IsNullOrEmpty(text)) { return; } if (cancel) { return; } // Restore original DetourManager.CallOriginal(typeof(CM).GetMethod("askChat", BindingFlags.Public | BindingFlags.Instance), CM.instance, player.SteamID, mode, text); }
/// <summary> /// Creates a new instance of the <see cref="Magic"/> class. /// </summary> public Magic() { Process.EnterDebugMode(); _win32 = new Win32(IntPtr.Zero); _detours = new DetourManager(_win32); _patches = new PatchManager(_win32); _patterns = new PatternManager(_win32); }
/// <summary> /// Creates a new instance of the <see cref="ProcessInject"/> class. /// </summary> public ProcessInject(uint dwDesiredAccess, int dwProcessId) { Process.EnterDebugMode(); mWin32 = new Win32(dwDesiredAccess, dwProcessId); mDetours = new DetourManager(mWin32); mPatches = new PatchManager(mWin32); mPatterns = new PatternManager(mWin32); mInstance = this; }
public Onyx(Process _targetProcess) { if (_targetProcess == null) { throw new ArgumentNullException(nameof(_targetProcess)); } m_targetProcess = _targetProcess; m_memory = new OnyxMemory(_targetProcess.Id); m_detours = new DetourManager(); }
public static void askRepair(this Barricade barricade, ushort amount) { // Set the variables bool cancel = false; // Run the events BarricadeEvents.RunBarricadeRepair(UnturnedBarricade.FindBarricade(barricade), ref amount, ref cancel); // Run the original function if (!cancel) { DetourManager.CallOriginal(typeof(Barricade).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), barricade, amount); } }
public static void askRepair(this Structure stru, ushort amount) { // Set the events bool cancel = false; // Run the events StructureEvents.RunRepairStructure(UnturnedStructure.FindStructure(stru), ref amount, ref cancel); // Run the original function if (!cancel) { DetourManager.CallOriginal(typeof(Structure).GetMethod("askRepair", BindingFlags.Instance | BindingFlags.Public), stru, amount); } }
public static void askRepair(this InteractableVehicle Vehicle, ushort amount) { if (amount == 0 || Vehicle.isExploded) { return; } UnturnedVehicle vehicle = UnturnedServer.Vehicles.FirstOrDefault(v => v.InstanceID == Vehicle.instanceID); VehicleEvents.RunVehicleRepair(vehicle, amount); DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("askRepair", BindingFlags.Public | BindingFlags.Instance), Vehicle, amount); }
public void tellVehicleDestroy(CSteamID steamID, uint instanceID) { if (VehicleManager.instance.channel.checkServer(steamID)) { InteractableVehicle vehicle = VehicleManager.vehicles.FirstOrDefault(a => a.instanceID == instanceID); if (vehicle == null) { return; } ServerEvents.RunVehicleRemoved(vehicle); } DetourManager.CallOriginal(typeof(VehicleManager).GetMethod("tellVehicleDestroy", BindingFlags.Instance | BindingFlags.Public), VehicleManager.instance, steamID, instanceID); }
public void askSalvageBarricade(CSteamID steamID, byte x, byte y, ushort plant, ushort index) { BarricadeRegion barricadeRegion; bool cancel = false; if (BarricadeManager.tryGetRegion(x, y, plant, out barricadeRegion)) { BarricadeData data = barricadeRegion.barricades[(int)index]; BarricadeEvents.RunBarricadeSalvage(UnturnedBarricade.Create(data), ref cancel); } if (!cancel) { DetourManager.CallOriginal(typeof(BarricadeManager).GetMethod("askSalvageBarricade", BindingFlags.Public | BindingFlags.Instance), BarricadeManager.instance, steamID, x, y, plant, index); } }
public void askSalvageStructure(CSteamID steamID, byte x, byte y, ushort index) { StructureRegion structureRegion; bool cancel = false; if (StructureManager.tryGetRegion(x, y, out structureRegion)) { StructureData data = structureRegion.structures[(int)index]; StructureEvents.RunSalvageStructure(UnturnedStructure.Create(data), ref cancel); } if (!cancel) { DetourManager.CallOriginal(typeof(StructureManager).GetMethod("askSalvageStructure", BindingFlags.Instance | BindingFlags.Public), StructureManager.instance, steamID, x, y, index); } }
public static void askDamageTire(this InteractableVehicle Vehicle, int index) { if (index < 0) { return; } if (Vehicle.asset != null && !Vehicle.asset.canTiresBeDamaged) { return; } UnturnedVehicle UVehicle = UnturnedServer.Vehicles.FirstOrDefault(vehicle => vehicle.InstanceID == Vehicle.instanceID); VehicleEvents.RunVehicleTireDamage(UVehicle, index); DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("askDamageTire", BindingFlags.Public | BindingFlags.Instance), Vehicle, index); }
private static void doDamage(this PlayerLife life, byte amount, Vector3 newRagdoll, EDeathCause newCause, ELimb newLimb, CSteamID newKiller, out EPlayerKill kill) { UnturnedPlayer ply = UnturnedPlayer.Get(newKiller); bool cancel = false; kill = EPlayerKill.NONE; PlayerEvents.RunPlayerHurt(life.channel.owner, ref amount, ref newCause, ref newLimb, ref ply, ref cancel); if (cancel) { return; } object[] paramaters = new object[] { amount, newRagdoll, newCause, newLimb, newKiller, null }; DetourManager.CallOriginal(typeof(PlayerLife).GetMethod("doDamage", BindingFlags.NonPublic | BindingFlags.Instance), life, paramaters); kill = (EPlayerKill)paramaters[5]; }
public static void tellSkill(this PlayerSkills Skills, CSteamID steamID, byte speciality, byte index, byte level) { if (!Skills.channel.checkServer(steamID)) { return; } if (index >= Skills.skills[speciality].Length) { return; } UnturnedPlayer Player = UnturnedPlayer.Get(Skills.player); PlayerEvents.RunPlayerSkillUpgrade(Player, speciality, index, level); DetourManager.CallOriginal(typeof(PlayerSkills).GetMethod("tellSkill", BindingFlags.Instance | BindingFlags.Public), Skills, steamID, speciality, index, level); }
private void Start() { foreach (Type _class in Assembly.GetExecutingAssembly().GetTypes()) { if (!_class.IsClass) { continue; } // Service and menu checks if (MenuManager.IsMenu(_class)) { MenuManager.LoadClass(_class); } else if (ServiceManager.IsService(_class)) { IService service = ServiceManager.LoadClass(_class); ServiceManager.Start(service); } // Detour checks foreach (MethodInfo method in _class.GetMethods(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { DetourAttribute detour = (DetourAttribute)Attribute.GetCustomAttribute(method, typeof(DetourAttribute)); if (detour != null) { if (detour.Modified == null) { detour.Modified = method; } DetourManager.Detour(detour.Original, detour.Modified); } } } _ticker = new Thread(new ThreadStart(Tick)); _ticker.Start(); }
public void tellExitVehicle(CSteamID steamID, uint instanceID, byte seat, Vector3 point, byte angle, bool forceUpdate) { if (!VehicleManager.instance.channel.checkServer(steamID)) { return; } for (int i = 0; i < VehicleManager.vehicles.Count; i++) { if (VehicleManager.vehicles[i].instanceID != instanceID) { continue; } UnturnedVehicle Vehicle = UnturnedServer.Vehicles.FirstOrDefault(vehicle => vehicle.InstanceID == instanceID); VehicleEvents.RunVehicleExit(Vehicle, seat, point, angle, forceUpdate); break; } DetourManager.CallOriginal(typeof(VehicleManager).GetMethod("tellExitVehicle", BindingFlags.Public | BindingFlags.Instance), VehicleManager.instance, steamID, instanceID, seat, point, angle, forceUpdate); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryPlus" /> class. /// </summary> /// <param name="proc">The process.</param> /// <remarks> /// Created 2012-02-15 /// </remarks> public MemoryPlus(Process proc) : base(proc) { Factories.Add(Detours = new DetourManager(this)); Factories.Add(Hooks = new HookManager()); }
public static void init(this InteractableVehicle vehicle) { ServerEvents.RunVehicleCreated(vehicle); DetourManager.CallOriginal(typeof(InteractableVehicle).GetMethod("init"), vehicle, new object[0]); }