Exemple #1
0
        public override void Enable()
        {
            if (Enabled)
            {
                return;
            }

            config = LoadConfig <Configs>() ?? new Configs();

            changeAddress = Common.Scanner.ScanText("41 80 7E 2F 06 75 1E 48 8D 0D");
            if (SafeMemory.ReadBytes(changeAddress, 5, out originalBytes))
            {
                if (SafeMemory.WriteBytes(changeAddress, new byte[] { 0x41, 0xF6, 0x46, 0x36, 0x10 })) // cmp byte ptr [r14+2Fh], 6 -> test byte ptr [r14+36h], 10
                {
                    base.Enable();
                }
                else
                {
                    SimpleLog.Error("Failed to write new instruction");
                }
            }
            else
            {
                SimpleLog.Error("Failed to read original instruction");
            }

            if (config.FixCones)
            {
                ModifyCones(true);
            }
        }
Exemple #2
0
 void EnableNaturalTimeFlow()
 {
     if (*FirstByteTimeStopPtr == TimeStopOn[0])
     {
         SafeMemory.WriteBytes(TimeStopPtr, TimeStopOff);
         WriteLog("Time flow reenabled");
     }
 }
Exemple #3
0
 void DisableNaturalTimeFlow()
 {
     if (*FirstByteTimeStopPtr == TimeStopOff[0])
     {
         SafeMemory.WriteBytes(TimeStopPtr, TimeStopOn);
         WriteLog("Time flow stopped");
     }
 }
Exemple #4
0
 public void Disable()
 {
     if (!IsValid)
     {
         return;
     }
     SafeMemory.WriteBytes(Address, oldBytes);
     IsEnabled = false;
 }
Exemple #5
0
 public void Enable()
 {
     if (!IsValid)
     {
         return;
     }
     SafeMemory.WriteBytes(Address, newBytes);
     IsEnabled = true;
 }
Exemple #6
0
            public Replacer(IntPtr addr, byte[] bytes)
            {
                if (addr == IntPtr.Zero)
                {
                    return;
                }

                Address  = addr;
                newBytes = bytes;
                SafeMemory.ReadBytes(addr, bytes.Length, out oldBytes);
                createdReplacers.Add(this);
            }
Exemple #7
0
 /// <summary>
 /// Read memory from an offset and hexdump them via Serilog.
 /// </summary>
 /// <param name="offset">The offset to read from.</param>
 /// <param name="len">The length to read.</param>
 public static void DumpMemory(IntPtr offset, int len = 512)
 {
     try
     {
         SafeMemory.ReadBytes(offset, len, out var data);
         Log.Information(ByteArrayToHex(data));
     }
     catch (Exception ex)
     {
         Log.Error(ex, "Read failed");
     }
 }
Exemple #8
0
 public override void Disable()
 {
     if (!Enabled)
     {
         return;
     }
     if (!SafeMemory.WriteBytes(changeAddress, originalBytes))
     {
         SimpleLog.Error("Failed to write original instruction");
     }
     base.Disable();
 }
Exemple #9
0
        /// <summary>
        /// Disable the anti-debugging by reverting the overwritten code in memory.
        /// </summary>
        public void Disable()
        {
            if (this.debugCheckAddress != IntPtr.Zero && this.original != null)
            {
                Log.Information($"Reverting debug check at 0x{this.debugCheckAddress.ToInt64():X}");
                SafeMemory.WriteBytes(this.debugCheckAddress, this.original);
            }
            else
            {
                Log.Information("Debug check was not overwritten?");
            }

            this.IsEnabled = false;
        }
Exemple #10
0
        /// <summary>
        /// Enables the anti-debugging by overwriting code in memory.
        /// </summary>
        public void Enable()
        {
            this.original = new byte[this.nop.Length];
            if (this.debugCheckAddress != IntPtr.Zero && !this.IsEnabled)
            {
                Log.Information($"Overwriting debug check at 0x{this.debugCheckAddress.ToInt64():X}");
                SafeMemory.ReadBytes(this.debugCheckAddress, this.nop.Length, out this.original);
                SafeMemory.WriteBytes(this.debugCheckAddress, this.nop);
            }
            else
            {
                Log.Information("Debug check already overwritten?");
            }

            this.IsEnabled = true;
        }
Exemple #11
0
            public Replacer(string sig, byte[] bytes)
            {
                var addr = IntPtr.Zero;

                try { addr = Fractionality.Interface.TargetModuleScanner.ScanModule(sig); }
                catch { }
                if (addr == IntPtr.Zero)
                {
                    return;
                }

                Address  = addr;
                newBytes = bytes;
                SafeMemory.ReadBytes(addr, bytes.Length, out oldBytes);
                createdReplacers.Add(this);
            }
Exemple #12
0
            public Replacer(IntPtr addr, byte[] bytes, bool startEnabled = false)
            {
                if (addr == IntPtr.Zero)
                {
                    return;
                }

                Address  = addr;
                newBytes = bytes;
                SafeMemory.ReadBytes(addr, bytes.Length, out oldBytes);
                createdReplacers.Add(this);

                if (startEnabled)
                {
                    Enable();
                }
            }
 public void SetEnabled(bool isEnable)
 {
     if (Address.Offset1 == IntPtr.Zero || Address.Offset2 == IntPtr.Zero)
     {
         return;
     }
     if (isEnable)
     {
         SafeMemory.Write <short>(Address.Offset1, -28528);
         SafeMemory.Write <short>(Address.Offset2, -28528);
     }
     else
     {
         SafeMemory.Write <short>(Address.Offset1, 13173);
         SafeMemory.Write <short>(Address.Offset2, 6260);
     }
 }
Exemple #14
0
        public override void Disable()
        {
            if (!Enabled)
            {
                return;
            }
            if (changeAddress == IntPtr.Zero)
            {
                return;
            }

            var writeOriginalSuccess = SafeMemory.WriteBytes(changeAddress, originalBytes);

            if (!writeOriginalSuccess)
            {
                SimpleLog.Error("Failed to write original instruction");
            }
            base.Disable();
        }
Exemple #15
0
        public override void Enable()
        {
            if (Enabled)
            {
                return;
            }
            try {
                changeAddress = Common.Scanner.ScanText("0F 86 ?? ?? ?? ?? 48 8B 4D 77");
                SimpleLog.Verbose($"Found Signature: {changeAddress.ToInt64():X}");
            } catch {
                SimpleLog.Error("Failed to find Signature");
                return;
            }
            if (changeAddress == IntPtr.Zero)
            {
                return;
            }

            originalBytes = new byte[6];
            var readOriginalSuccess = SafeMemory.ReadBytes(changeAddress, 6, out originalBytes);

            if (readOriginalSuccess)
            {
                var relAddr         = BitConverter.ToInt32(originalBytes, 2) + 1;
                var relAddrBytes    = BitConverter.GetBytes(relAddr);
                var writeNewSuccess = SafeMemory.WriteBytes(changeAddress, new byte[6] {
                    0xE9, relAddrBytes[0], relAddrBytes[1], relAddrBytes[2], relAddrBytes[3], 0x90
                });
                if (writeNewSuccess)
                {
                    base.Enable();
                }
                else
                {
                    SimpleLog.Error("Failed to write new instruction");
                }
            }
            else
            {
                originalBytes = new byte[0];
                SimpleLog.Error("Failed to read original instruction");
            }
        }
Exemple #16
0
        public override void Disable()
        {
            if (!Enabled)
            {
                return;
            }

            SaveConfig(config);

            if (!SafeMemory.WriteBytes(changeAddress, originalBytes))
            {
                SimpleLog.Error("Failed to write original instruction");
            }

            if (config.FixCones)
            {
                ModifyCones(false);
            }

            base.Disable();
        }
Exemple #17
0
            public Replacer(string sig, byte[] bytes, bool startEnabled = false)
            {
                var addr = IntPtr.Zero;

                try { addr = DalamudApi.SigScanner.ScanModule(sig); }
                catch { PluginLog.LogError($"Failed to find signature {sig}"); }
                if (addr == IntPtr.Zero)
                {
                    return;
                }

                Address  = addr;
                newBytes = bytes;
                SafeMemory.ReadBytes(addr, bytes.Length, out oldBytes);
                createdReplacers.Add(this);

                if (startEnabled)
                {
                    Enable();
                }
            }
Exemple #18
0
 public override void Enable()
 {
     if (Enabled)
     {
         return;
     }
     changeAddress = Common.Scanner.ScanText("E8 ?? ?? ?? ?? 44 0F B6 F0 41 8B ED");
     if (SafeMemory.ReadBytes(changeAddress, 7, out originalBytes))
     {
         if (SafeMemory.WriteBytes(changeAddress, new byte[] { 0xB8, numGearSets, 0x00, 0x00, 0x00, 0x90, 0x90 }))
         {
             base.Enable();
         }
         else
         {
             SimpleLog.Error("Failed to write new instruction");
         }
     }
     else
     {
         SimpleLog.Error("Failed to read original instruction");
     }
 }
        private int PrintIconPathDetour(IntPtr pathPtr, int iconId, int hq, int lang)
        {
            var r = this.printIconHook.Original(pathPtr, iconId, hq, lang);

            var terriRegion = this.terris.FirstOrDefault(x => x.PlaceNameRegionIcon == iconId);

            if (terriRegion != null)
            {
                PluginLog.Information($"LoadIcon: {iconId} detected for r:{terriRegion.RowId} with toLoadingTerri:{this.toLoadingTerri}");

                try
                {
                    if (this.toLoadingTerri == -1)
                    {
                        PluginLog.Information($"toLoadingImage not set!");
                        this.hasLoading = false;
                        return(r);
                    }

                    if (this.cfcs.Any(x => x.ContentLinkType == 1 && x.TerritoryType.Row == this.toLoadingTerri))
                    {
                        PluginLog.Information("Is InstanceContent zone!");
                        this.hasLoading = false;
                        return(r);
                    }

                    var terriZone = this.terris.FirstOrDefault(x => x.RowId == this.toLoadingTerri);

                    if (terriZone == null)
                    {
                        PluginLog.Information($"terriZone null!");
                        this.hasLoading = false;
                        return(r);
                    }

                    if (terriZone.PlaceNameRegionIcon != terriRegion.PlaceNameRegionIcon)
                    {
                        PluginLog.Information($"Mismatch: {terriZone.RowId} {terriRegion.RowId}");
                        this.hasLoading = false;
                        return(r);
                    }

                    var loading = this.loadings.FirstOrDefault(x => x.RowId == terriZone.LoadingImage);

                    if (loading == null)
                    {
                        PluginLog.Information($"LoadingImage null!");
                        this.hasLoading = false;
                        return(r);
                    }

                    SafeMemory.WriteString(pathPtr, $"ui/loadingimage/{loading.Name}_hr1.tex");
                    PluginLog.Information($"Replacing icon for territory {terriRegion.RowId}");

                    this.hasLoading = true;
                }
                catch (Exception ex)
                {
                    PluginLog.Error(ex, "Could not replace loading image.");
                }
            }

            return(r);
        }
Exemple #20
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            _pi         = pluginInterface;
            TimePtr     = (long *)(_pi.Framework.Address.BaseAddress + 0x1608);
            TimeStopPtr = _pi.TargetModuleScanner.ScanText("48 89 ?? 08 16 00 00 48 69"); //yeeted from cmtool https://github.com/imchillin/CMTool
            if (!SafeMemory.ReadBytes(TimeStopPtr, 7, out TimeStopOff))
            {
                throw new Exception("Could not read memory");
            }
            CurrentWeatherPtr = (byte *)(*(IntPtr *)_pi.TargetModuleScanner.GetStaticAddressFromSig("48 8B 05 ?? ?? ?? ?? 0F B6 EA 48 8B F9 41 8B DE 48 8B 70 08 48 85 F6 0F 84 ?? ?? ?? ??") + 0x27); //thanks daemitus
            //CurrentWeatherPtr = (byte*)(*(IntPtr*)(Process.GetCurrentProcess().MainModule.BaseAddress + 0x1D682B8) + 0x27); //yeeted from cmtool yet again
            FirstByteTimeStopPtr = (byte *)TimeStopPtr;
            zones        = pluginInterface.Data.GetExcelSheet <TerritoryType>().ToDictionary(row => (ushort)row.RowId, row => row);
            weathers     = pluginInterface.Data.GetExcelSheet <Weather>().ToDictionary(row => (byte)row.RowId, row => row.Name.ToString());
            weatherRates = _pi.Data.GetExcelSheet <WeatherRate>();
            ZoneSettings = new Dictionary <ushort, ZoneSettings>();
            foreach (var z in zones)
            {
                var s = new ZoneSettings();
                s.ZoneId   = z.Key;
                s.ZoneName = z.Value.PlaceName.Value.Name;
                s.terr     = z.Value;
                s.Init(this);
                ZoneSettings.Add(s.ZoneId, s);
            }
            configuration = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            configuration.Initialize(this);
            var normalweathers = new HashSet <byte>();

            foreach (var z in ZoneSettings)
            {
                foreach (var a in z.Value.SupportedWeathers)
                {
                    if (a.IsNormal)
                    {
                        normalweathers.Add(a.Id);
                    }
                }
            }
            var tempdict = new Dictionary <byte, bool>(configuration.BlacklistedWeathers);

            foreach (var i in tempdict)
            {
                if (!normalweathers.Contains(i.Key))
                {
                    configuration.BlacklistedWeathers.Remove(i.Key);
                }
            }
            foreach (var i in normalweathers)
            {
                if (!configuration.BlacklistedWeathers.ContainsKey(i))
                {
                    configuration.BlacklistedWeathers.Add(i, false);
                }
            }
            WeatherSvc = new FFXIVWeatherLuminaService(_pi.Data);
            _pi.Framework.OnUpdateEvent += HandleFrameworkUpdate;
            ConfigGui = new Gui(this);
            _pi.UiBuilder.OnBuildUi          += ConfigGui.Draw;
            _pi.UiBuilder.OnOpenConfigUi     += delegate { ConfigGui.configOpen = true; };
            _pi.ClientState.TerritoryChanged += HandleZoneChange;
            if (_pi.ClientState != null)
            {
                ApplyWeatherChanges(_pi.ClientState.TerritoryType);
            }
            _pi.CommandManager.AddHandler("/weatherman", new Dalamud.Game.Command.CommandInfo(delegate { ConfigGui.configOpen = true; })
            {
            });
            _pi.Framework.Gui.Chat.OnChatMessage += HandleChatMessage;
        }