Ejemplo n.º 1
0
        public static void FishOnlyCrates_D(GameContext Context)
        {
            int a = AobscanHelper.Aobscan(
                Context.HContext.Handle,
                "90 90 90 90 90 90 0F B6");
            var bs = AobscanHelper.GetHexCodeFromString("0F 84 C0 03 00 00");

            NativeFunctions.WriteProcessMemory(Context.HContext.Handle, a, bs, bs.Length, 0);
        }
Ejemplo n.º 2
0
        public static void FishOnlyCrates_D(GameContext Context)
        {
            int a = AobscanHelper.Aobscan(
                Context.HContext.Handle,
                "90 90 90 90 90 90 8B 45 A8 0B 45 A4");
            var bs = AobscanHelper.GetHexCodeFromString("0f 8d 4F 01 00 00 8b 45");

            NativeFunctions.WriteProcessMemory(Context.HContext.Handle, a, bs, bs.Length, 0);
        }
Ejemplo n.º 3
0
        public static void AobReplace(GameContext Context, string srcHex, string targetHex, int offset = 0, bool matching = false)
        {
            int addr = 0;

            while ((addr = AobscanHelper.Aobscan(Context.HContext.Handle, srcHex, matching)) != -1)
            {
                byte[] code = AobscanHelper.GetHexCodeFromString(targetHex);
                NativeFunctions.WriteProcessMemory(Context.HContext.Handle, addr + offset, code, code.Length, 0);
            }
        }
Ejemplo n.º 4
0
        public static void AobReplace(GameContext Context, string srcHex, string targetHex)
        {
            var addrs = AobscanHelper.Aobscan(Context.HContext.Handle, srcHex);

            byte[] code = AobscanHelper.GetHexCodeFromString(targetHex);
            foreach (var addr in addrs)
            {
                Context.HContext.DataAccess.WriteBytes(addr, code);
            }
        }
Ejemplo n.º 5
0
        public static void ImmuneDebuffs_D(GameContext Context)
        {
            int a = Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Player", "AddBuff");

            byte[] j = new byte[1];
            NativeFunctions.ReadProcessMemory(Context.HContext.Handle, a, j, 1, 0);
            if (j[0] == 0xE9)
            {
                int y = 0;
                NativeFunctions.ReadProcessMemory(Context.HContext.Handle, a + 1, ref y, 4, 0);
                y += a + 5;
                byte[] b = AobscanHelper.GetHexCodeFromString("55 8B EC 57 56");
                NativeFunctions.WriteProcessMemory(Context.HContext.Handle, a, b, b.Length, 0);
                InlineHook.FreeHook(Context.HContext, y);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ID"></param>
        /// <returns>未初始化或数据未定义返回-1</returns>
        public static int GetSign(string ID)
        {
            if (SignHead == 0)
            {
                return(-1);
            }
            byte[] content = new byte[1024 * 8];
            NativeFunctions.ReadProcessMemory(GameContext.HContext.Handle, SignHead, content, SignSize - 20, 0);            //去掉头部的20个位置,这20个位置最后四个是数量(int)
            byte[] h = AobscanHelper.GetHexCodeFromString(ID);
            int    j = AobscanHelper.Memmem(content, content.Length, h, h.Length);

            if (j == -1)
            {
                return(-1);
            }
            return(BitConverter.ToInt32(content, j + 16));
        }
Ejemplo n.º 7
0
        public static void InitSign()
        {
            int s = AobscanHelper.Aobscan(GameContext.HContext.Handle, SignHeadAob);

            SignHead = s + 20;
            if (s != -1)
            {
                return;
            }
            int t = NativeFunctions.VirtualAllocEx(
                GameContext.HContext.Handle, 0, SignSize,
                NativeFunctions.AllocationType.Commit,
                NativeFunctions.MemoryProtection.ExecuteReadWrite);

            NativeFunctions.WriteProcessMemory(GameContext.HContext.Handle, t, AobscanHelper.GetHexCodeFromString(SignHeadAob), 16, 0);
            SignHead = t + 20;
        }
Ejemplo n.º 8
0
        public static void SetSign(string ID, int v)
        {
            if (SignHead == 0)
            {
                return;
            }
            byte[] content = new byte[1024 * 8];
            NativeFunctions.ReadProcessMemory(GameContext.HContext.Handle, SignHead, content, SignSize - 20, 0);            //去掉头部的20个位置,这20个位置最后四个是数量(int)
            byte[] h = AobscanHelper.GetHexCodeFromString(ID);
            int    j = AobscanHelper.Memmem(content, content.Length, h, h.Length);

            if (j != -1)            //-1说明没找到
            {
                NativeFunctions.WriteProcessMemory(GameContext.HContext.Handle, SignHead + j + 16, ref v, 4, 0);
            }
            else
            {
                int u = GetSignNumber();
                NativeFunctions.WriteProcessMemory(GameContext.HContext.Handle, SignHead + u * 20, h, 16, 0);              //写入标记
                NativeFunctions.WriteProcessMemory(GameContext.HContext.Handle, SignHead + u * 20 + 16, ref v, 4, 0);      //写入数据
                u++;
                NativeFunctions.WriteProcessMemory(GameContext.HContext.Handle, SignHead - 4, ref u, 4, 0);                //长度+1
            }
        }