private void CboxLastIdol_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Diag.WriteLine("LAST IDOL SET!");
            var idol = cboxLastIdol.SelectedItem.ToString().Idol();

            if (idol == null)
            {
                return;
            }
            var idolId = idol.Id;

            var remoteProc = RemoteProc.Instance();

            if (remoteProc == null)
            {
                return;
            }

            var pointer = Defs.PointerByName("LastCommutedIdol");

            if (pointer == null || pointer.BasePtr() == IntPtr.Zero)
            {
                return;
            }
            remoteProc.Write(pointer.GetAddress(remoteProc), idolId);
        }
 private void FlagToggle()
 {
     foreach (var item in flagToggleList.Items)
     {
         Diag.WriteLine(item.ToString());
     }
 }
Ejemplo n.º 3
0
        private void BtnSaveSpider_Click(object sender, EventArgs e)
        {
            if (!_spiderInitialized)
            {
                MetroMessageBox.Show(this, "You should spider something first!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
                return;
            }

            try {
                var remoteProc = RemoteProc.Instance();
                if (remoteProc == null)
                {
                    return;
                }

                var address = Defs.PointerByName("inventory").GetAddress(remoteProc);
                foreach (var item in _inventory)
                {
                    remoteProc.Write(address, item.SekiroItem);
                    address += 16;
                }
            } catch (Exception ex) {
                Diag.WriteLine(ex.Message);
                MessageBox.Show($"Failed to save inventory :( \n{ex.Message}", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            MetroMessageBox.Show(this,
                                 "Inventory saved! Do something that forces the game to reparse your inventory such as warping or saving and loading",
                                 ":o", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void BtnTeleportToCoordinates_Click(object sender, EventArgs e)
        {
            var sekiro = Utils.Sekiro();

            if (sekiro == null)
            {
                return;
            }


            var cx = BitConverter.GetBytes(float.Parse(coordX.Text));
            var cy = BitConverter.GetBytes(float.Parse(coordY.Text));
            var cz = BitConverter.GetBytes(float.Parse(coordZ.Text));

            var full = new byte[cx.Length + cy.Length + cz.Length];

            Buffer.BlockCopy(cx, 0, full, 0, cx.Length);
            Buffer.BlockCopy(cy, 0, full, cx.Length, cy.Length);
            Buffer.BlockCopy(cz, 0, full, cx.Length + cy.Length,
                             cx.Length);


            var remoteProc = new RemoteProcess(sekiro);
            var offsets    = new byte[] { 0x48, 0x28, 0x80 };
            var addr       = new IntPtr(0x143B67DF0);

            addr = offsets.Aggregate(addr, (current, offset) => remoteProc.Read <IntPtr>(current) + offset);
            //remoteProc.Write<byte[]>(addr, full);
            remoteProc.WriteBytes(addr, full);

            Diag.WriteLine(BitConverter.ToString(full).Replace("-", ""));
        }
        private void BtnInventorySpider_Click(object sender, EventArgs e)
        {
            var sekiro = Utils.Sekiro();

            if (sekiro == null)
            {
                return;
            }

            using (var remoteProc = new RemoteProcess(sekiro)) {
                var address = remoteProc.Read <IntPtr>(new IntPtr(0x143B49D10)) + 0x2E30;

                var items = new List <byte[]>();

                while (remoteProc.Read <byte>(address) != (byte)0x0)
                {
                    var item = remoteProc.ReadBytes(address, 16);
                    items.Add(item);
                    address += 0x10;
                }
                Diag.WriteLine($"Spidered {items.Count} items");

                new InvSpider(items).Show();
            }
        }
 public static void Add(string name, EventHandler <GlobalEventArgs> handler)
 {
     Diag.WriteLine($"[GlobalEvents Add] {name}");
     if (_events.ContainsKey(name))
     {
         return;
     }
     _events.Add(name, handler);
 }
 public static void Unsubscribe(string name, EventHandler <GlobalEventArgs> handler)
 {
     Diag.WriteLine($"[GlobalEvents Unsubscribe] {name}");
     if (!_events.ContainsKey(name))
     {
         return;
     }
     _events[name] -= handler;
 }
Ejemplo n.º 8
0
        public AddItem(Item item, int quantity)
        {
            if (item.Consumable)
            {
                _asm = GenerateConsumableAsm(item.ShortId(), quantity);
                return;
            }

            Diag.WriteLine(((int)item.Id2).ToString("X"));
            _asm = GenerateProsteticAsm((int)item.Id2);
        }
        private void CboxIdolTeleport_SelectedIndexChanged(object sender, EventArgs e)
        {
            var idol = cboxIdolTeleport.SelectedItem.ToString().Idol();

            if (idol == null)
            {
                Diag.WriteLine($"Invalid Idol {cboxIdolTeleport.SelectedItem}");
                return;
            }
            new IdolTeleport(idol).Execute();
        }
Ejemplo n.º 10
0
        private void InjectItems_Click(object sender, EventArgs e)
        {
            var items = new List <Item>();

            for (var i = 0; i < injectorGrid.RowCount; i++)
            {
                var cbox = (DataGridViewComboBoxCell)injectorGrid.Rows[i].Cells[0];
                if (cbox.Value == null)
                {
                    continue;
                }
                var item = Defs.ItemByName(cbox.Value.ToString());
                if (item == null)
                {
                    continue;
                }

                var consumable = BitConverter.GetBytes(item.Id2)[3] == 0x40;
                var quantity   = 1;
                if (consumable)
                {
                    try {
                        var quantityString = injectorGrid.Rows[i].Cells[1].Value.ToString();
                        int.TryParse(quantityString, out quantity);
                    } catch {
                        Diag.WriteLine($"[Item Injecter] Invalid quantity for {cbox.Value}");
                    }
                }

                try {
                    new AddItem(new Item {
                        Id1        = item.Id1,
                        Id2        = item.Id2,
                        Consumable = consumable
                    }, quantity).Execute();

                    MetroMessageBox.Show(this, "Items Injected!", ":3", MessageBoxButtons.OK,
                                         MessageBoxIcon.Information);
                } catch (Exception ex) {
                    MetroMessageBox.Show(this, ex.Message, "Failed to inject items :(", MessageBoxButtons.OK,
                                         MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 11
0
        private void SmPseudoReadonlyHandler(object sender, GlobalEventArgs e)
        {
            var value = e.Value;

            if (value.GetType() != typeof(byte))
            {
                return;
            }
            var b = (byte)value;

            if (b == 0)
            {
                if (_smSelfWrite)
                {
                    return;
                }
                _smSelfWrite = true;
                if (_smQuickLoadLastItem == string.Empty || _smQuickLoadLastProfile == string.Empty)
                {
                    return;
                }
                try {
                    var fPath = $@"{ProfileDir(true)}/{_smQuickLoadLastItem}";
                    File.Copy(fPath, $@"{_sekiroDir}/S0000.sl2", true);
                    Diag.WriteLine("Pseudo read-only success");
                } catch (Exception ex) {
                    MetroMessageBox.Show(this,
                                         ex.Message,
                                         "Error",
                                         MessageBoxButtons.OK,
                                         MessageBoxIcon.Error
                                         );
                }
            }
            else
            {
                _smSelfWrite = false;
            }
        }
        public void InitHotkeys()
        {
            Diag.WriteLine("Init Hotkeys");
            mainTabControl.SelectedIndexChanged += (sender, args) => {
                _hotkeysDisabled = mainTabControl.SelectedIndex == 1;
            };
            _keyboardHook = new KeyboardHook();
            _keyboardHook.OnKeyPressed += OnKeyPressed;

            _keyboardHook.Hook();
            FormClosing += (sender, args) => _keyboardHook.Dispose();

            var defaultHotkeys = JsonConvert.DeserializeObject <List <Hotkey> >(File.ReadAllText("hotkeys.json"));

            _hotkeys = defaultHotkeys;
            if (File.Exists($@"{Utils.DataDir()}/hotkeysv2.json"))
            {
                var userHotkeys = JsonConvert.DeserializeObject <Hotkey[]>(File.ReadAllText($@"{Utils.DataDir()}/hotkeysv2.json"));
                foreach (var userHotkey in userHotkeys)
                {
                    var index = HotkeyIndex(userHotkey.Name);
                    if (index < 0)
                    {
                        _hotkeys.Add(userHotkey);
                        continue;
                    }

                    ReplaceHotkey(userHotkey.Name, userHotkey);
                }
            }

            foreach (var hotkey in _hotkeys)
            {
                switch (hotkey.Name)
                {
                case "SaveCurrentCoordinates":
                    hotkeySaveCurrentCoordinates.InvokeIfRequired(() => {
                        hotkeySaveCurrentCoordinates.Text = hotkey.HotkeyString;
                    });
                    break;

                case "TeleportToCoordinates":
                    hotkeyTeleportToCoordinates.InvokeIfRequired(() => {
                        hotkeyTeleportToCoordinates.Text = hotkey.HotkeyString;
                    });
                    break;

                case "LoadSave":
                    hotkeyLoadSave.InvokeIfRequired(() => {
                        hotkeyLoadSave.Text = hotkey.HotkeyString;
                    });
                    break;

                case "BackupSave":
                    hotkeyBackupSave.InvokeIfRequired(() => {
                        hotkeyBackupSave.Text = hotkey.HotkeyString;
                    });
                    break;

                case "LoadLastQuickSave":
                    hotkeyLoadQuick.InvokeIfRequired(() => {
                        hotkeyLoadQuick.Text = hotkey.HotkeyString;
                    });
                    break;

                case "ForceQuit":
                    hotkeyQuit.InvokeIfRequired(() => {
                        hotkeyQuit.Text = hotkey.HotkeyString;
                    });
                    break;
                }
            }

            hotkeySaveCurrentCoordinates.KeyDown += HotkeySaveCurrentCoordinatesOnKeyDown;
            hotkeyTeleportToCoordinates.KeyDown  += HotkeyTeleportToCoordinatesOnKeyDown;
            hotkeyBackupSave.KeyDown             += HotkeyBackupSaveOnKeyDown;
            hotkeyLoadSave.KeyDown  += HotkeyLoadSaveOnKeyDown;
            hotkeyLoadQuick.KeyDown += HotkeyLoadQuickOnKeyDown;
            hotkeyQuit.KeyDown      += HotkeyQuitOnKeyDown;
        }
Ejemplo n.º 13
0
        private void Init()
        {
            Diag.WriteLine("Initializing");
            SetStatus("Initializing", Color.OrangeRed);

            var remoteProc = RemoteProc.Instance();

            if (remoteProc == null)
            {
                MetroMessageBox.Show(this, "Sekiro should be running but was not found..", "Error",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (var flag in Defs.Flags.FastReverse())
            {
                flag.RenderFlag(this);
            }

            GameState = new GameState();
            GameState.Subscribe((sender, e) => {
                var value = e.Value;
                if (value.GetType() != typeof(byte))
                {
                    return;
                }
                var b = (byte)value;

                UpdateCtrl(lblLoading, () => {
                    if (b == 1)
                    {
                        lblLoading.Text = "Loading: no";
                    }
                    else if (b == 0)
                    {
                        lblLoading.Text = "Loading: yes";
                    }
                    else
                    {
                        lblLoading.Text = "Loading: unknown";
                    }
                });
            });
            GameState.Start();

            PlayerPos = new PlayerPos();
            PlayerPos.Subscribe((sender, e) => {
                var pos = (Vector3)e.Value;
                UpdateCtrl(lblPosX, () => lblPosX.Text = $"X: {pos.X}");
                UpdateCtrl(lblPosY, () => lblPosY.Text = $"Y: {pos.Y}");
                UpdateCtrl(lblPosZ, () => lblPosZ.Text = $"Z: {pos.Z}");
            });
            PlayerPos.Start();

            IngameTime = new IngameTime();
            IngameTime.Subscribe((sender, e) => {
                UpdateCtrl(lblIgt, () => lblIgt.Text = $"IGT: {(string)e.Value}");
            });
            IngameTime.Start();

            PlayerStats = new PlayerStats();
            PlayerStats.Subscribe((sender, e) => {
                var player = (Player)e.Value;
                UpdateCtrl(lblHealth, () => lblHealth.Text   = $"Health: {player.CurrentHealth}/{player.MaximumHealth}");
                UpdateCtrl(lblPosture, () => lblPosture.Text = $"Posture: {player.CurrentPosture}/{player.MaximumPosture}");
            });
            PlayerStats.Start();

            LastIdol = new LastIdol();
            LastIdol.Subscribe((sender, e) => {
                var idola = (Idol)e.Value;
                UpdateCtrl(cboxLastIdol, () => cboxLastIdol.SelectedItem = idola.Name);
            });
            LastIdol.Start();

            var lastIdol = remoteProc.Read <int>(Defs.PointerByName("LastCommutedIdol").GetAddress(remoteProc));
            var idol     = Defs.IdolById(lastIdol);

            if (idol == null)
            {
                Diag.WriteLine($"Null Idol? {lastIdol}");
            }
            else
            {
                UpdateCtrl(cboxLastIdol, () => {
                    cboxLastIdol.SelectedItem = idol.Name;
                });
            }

            SetStatus("Ready", Color.LimeGreen);
            Enable();
        }
Ejemplo n.º 14
0
        private void BtnSpider_Click(object sender, EventArgs e)
        {
            if (!_spiderInitialized)
            {
                InitializeSpider();
            }
            _inventory.Clear();
            var sekiro = Utils.Sekiro();

            if (sekiro == null)
            {
                return;
            }


            var emptyItem = new SekiroItem()
            {
                Id1      = 0,
                Id2      = 0xFFFFFFFF,
                Quantity = 0,
                Garbage  = 0
            };

            var    itemCount = 0;
            IntPtr address;

            var remoteProc = RemoteProc.Instance();

            if (remoteProc == null)
            {
                return;
            }

            address = Defs.PointerByName("inventory").GetAddress(remoteProc);
            var invStart = address.ToInt64();
            var invEnd   = invStart + 4800;

            Diag.WriteLine($"Inv Start: {address.ToString("X")}");
            var spiderIndex = 0;

            while (address.ToInt64() < invEnd)
            {
                var sekiroItem = remoteProc.Read <SekiroItem>(address);
                address += 16;
                var item = sekiroItem.ToItem();
                item.SpiderIndex = spiderIndex;
                spiderIndex++;
                _inventory.Add(item);
                if (sekiroItem.Equals(emptyItem))
                {
                    continue;
                }
                itemCount++;
            }

            Diag.WriteLine($"Inv End: {address.ToString("X")}");
            Diag.WriteLine($"Spidered {itemCount} items");

            var currentRow = 0;

            itemGrid.RowCount = itemCount;
            foreach (var item in _inventory)
            {
                if (item.Empty)
                {
                    continue;
                }
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[0];
                itemGrid.CurrentCell.Value = item.SpiderIndex;
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[1];
                var cbox = (DataGridViewComboBoxCell)itemGrid.CurrentCell;
                foreach (var defi in Defs.Items)
                {
                    cbox.Items.Add(defi.Name);
                }
                cbox.Items.Add("Unknown");
                cbox.Value = item.Name;

                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[2];
                itemGrid.CurrentCell.Value = item.SekiroItem.Quantity;
                itemGrid.CurrentCell       = itemGrid.Rows[currentRow].Cells[3];
                itemGrid.CurrentCell.Value = "Not Implemented";
                currentRow++;
            }
        }
Ejemplo n.º 15
0
 public IntPtr GetAddress()
 {
     Diag.WriteLine("Deprecation warning: IntPtrE::GetAddress(). Use IntPtrE::GetAddress(RemoteProcess) instead.");
     return(GetAddress(RemoteProc.Instance()));
 }