예제 #1
0
        public static void HarpToTP_E(GameContext Context)
        {
            int a = AobscanHelper.Aobscan(
                Context.HContext,
                "8B 8D E4 F9 FF FF FF 15") - 5;

            byte[] j = new byte[1];
            NativeFunctions.ReadProcessMemory(Context.HContext.Handle, a, j, 1, 0);
            if (j[0] != 0xE9)
            {
                var player = Context.MyPlayer;
                InlineHook.Inject(Context.HContext,
                                  AssemblySnippet.FromCode(
                                      new AssemblyCode[] {
                    (Instruction)$"pushad",
                    AssemblySnippet.FromDotNetCall(
                        Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "get_LocalPlayer"),
                        null, false),
                    (Instruction)$"mov ebx,eax",
                    (Instruction)$"push 16",
                    (Instruction)$"fild dword ptr [{Context.TileTargetX_Address}]",
                    (Instruction)$"fild dword ptr [esp]",
                    (Instruction)$"fmul",
                    (Instruction)$"fstp dword ptr [ebx+{Entity.OFFSET_Position}]",

                    (Instruction)$"fild dword ptr [{Context.TileTargetY_Address}]",
                    (Instruction)$"fild dword ptr [esp]",
                    (Instruction)$"fmul",
                    (Instruction)$"fstp dword ptr [ebx+{Entity.OFFSET_Position + 0x4}]",
                    (Instruction)$"add esp,4",
                    (Instruction)$"popad",
                }),
                                  a, false);
            }
        }
예제 #2
0
파일: Utils.cs 프로젝트: radtek/QTRHacker
        public static void SendChat(GameContext Context, string Text)
        {
            byte[] bs     = Encoding.Unicode.GetBytes(Text);
            int    strEnd = 0;
            int    strMem = NativeFunctions.VirtualAllocEx(Context.HContext.Handle, 0, Text.Length + 10,
                                                           NativeFunctions.AllocationType.Commit, NativeFunctions.MemoryProtection.ExecuteReadWrite);

            NativeFunctions.WriteProcessMemory(Context.HContext.Handle, strMem, bs, bs.Length, 0);
            NativeFunctions.WriteProcessMemory(Context.HContext.Handle, strMem + bs.Length, ref strEnd, 4, 0);

            var             mscorlib_AddrHelper = Context.HContext.CreateFunctionAddressHelper("mscorlib.dll");
            int             ctor = mscorlib_AddrHelper.GetFunctionAddress("System.String", "CtorCharPtr");
            AssemblySnippet asm  = AssemblySnippet.FromCode(
                new AssemblyCode[] {
                (Instruction)"push ecx",
                (Instruction)"push edx",
                AssemblySnippet.FromDotNetCall(ctor, Context.HContext.MainAddressHelper.GetStaticFieldAddress("Terraria.Main", "chatText"), false, 0, strMem),
                (Instruction)$"mov byte ptr [{Context.HContext.MainAddressHelper.GetStaticFieldAddress("Terraria.Main", "drawingPlayerChat")}],1",
                (Instruction)$"mov byte ptr [{Context.HContext.MainAddressHelper.GetStaticFieldAddress("Terraria.Main", "inputTextEnter")}],1",
                (Instruction)$"mov byte ptr [{Context.HContext.MainAddressHelper.GetStaticFieldAddress("Terraria.Main", "chatRelease")}],1",
                (Instruction)"pop edx",
                (Instruction)"pop ecx"
            });

            InlineHook.InjectAndWait(Context.HContext, asm, Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
            NativeFunctions.VirtualFreeEx(Context.HContext.Handle, strMem, 0);
        }
예제 #3
0
 public static AssemblySnippet GetSnippet_Call_NewProjectile(GameContext Context, int?ret, bool regProtection, object X, object Y, object SpeedX, object SpeedY, object Type, object Damage, object KnockBack, object Owner, object ai0, object ai1)
 {
     return(AssemblySnippet.FromDotNetCall(
                Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Projectile", "NewProjectile"),
                ret,
                regProtection,
                Type, Damage, Y, X, SpeedY, SpeedX, KnockBack, Owner, ai0, ai1));
 }
예제 #4
0
        public static void SendWater(GameContext Context, int x, int y)
        {
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.AddressHelper.GetFunctionAddress("Terraria.NetMessage", "sendWater"),
                null,
                true,
                x, y);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
        }
예제 #5
0
        public static void SquareTileFrame(GameContext Context, int i, int j, bool resetFrame = true)
        {
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.WorldGen", "SquareTileFrame"),
                null,
                true,
                i, j, true);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
        }
예제 #6
0
        public void AddBuff(int type, int time, bool quiet = false)
        {
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.NPC", "AddBuff"),
                null,
                true,
                BaseAddress, type, time, quiet);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
        }
예제 #7
0
        public static void NewNPC(GameContext Context, int x, int y, int type, int start = 0, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, float ai3 = 0f, int target = 255)
        {
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.NPC", "NewNPC"),
                null,
                true,
                x, y, type, start, ai0, ai1, ai2, ai3, target);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.MainAddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
        }
예제 #8
0
        public static void SendData(GameContext Context, int msgType, int remoteClient = -1, int ignoreClient = -1,
                                    int text    = 0, int number  = 0, float number2 = 0f, float number3 = 0f, float number4 = 0f,
                                    int number5 = 0, int number6 = 0, int number7   = 0)
        {
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.AddressHelper.GetFunctionAddress("Terraria.NetMessage", "SendData"),
                null,
                true,
                msgType, remoteClient, ignoreClient, text, number, number2, number3, number4, number5, number6, number7);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
        }
예제 #9
0
파일: WorldMap.cs 프로젝트: 3rwr3/QTRHacker
        public bool UpdateLighting(int x, int y, byte light)
        {
            int             ret     = NativeFunctions.VirtualAllocEx(Context.HContext.Handle, 0, 4, NativeFunctions.AllocationType.Commit, NativeFunctions.MemoryProtection.ExecuteReadWrite);
            AssemblySnippet snippet = AssemblySnippet.FromDotNetCall(
                Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Map.WorldMap", "UpdateLighting"),
                ret,
                true,
                BaseAddress, x, y, light);

            InlineHook.InjectAndWait(Context.HContext, snippet, Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
            bool rv = false;

            NativeFunctions.ReadProcessMemory(Context.HContext.Handle, ret, ref rv, 1, 0);
            NativeFunctions.VirtualFreeEx(Context.HContext.Handle, ret, 0);
            return(rv);
        }
예제 #10
0
        public static void RevealMap(GameContext Context)
        {
            AssemblySnippet asm = AssemblySnippet.FromEmpty();

            asm.Content.Add(Instruction.Create("push ecx"));
            asm.Content.Add(Instruction.Create("push edx"));
            asm.Content.Add(
                AssemblySnippet.Loop(
                    AssemblySnippet.Loop(
                        AssemblySnippet.FromDotNetCall(
                            Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Map.WorldMap", "UpdateLighting"), null, false,
                            Context.Map.BaseAddress, "[esp+4]", "[esp]", 255),
                        Context.MaxTilesY, false),
                    Context.MaxTilesX, false));
            asm.Content.Add(Instruction.Create("pop edx"));
            asm.Content.Add(Instruction.Create("pop ecx"));

            InlineHook.InjectAndWait(Context.HContext, asm,
                                     Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "Update"), true);
            Context.RefreshMap = true;
        }
예제 #11
0
        public static void RightClickToTP(GameContext Context)
        {
            byte[] s = new byte[1];
            NativeFunctions.ReadProcessMemory(Context.HContext.Handle,
                                              Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "DoUpdate"), s, 1, 0);
            if (s[0] != 0x55)            //已经被修改,不能再hook
            {
                return;
            }
            var ass = AssemblySnippet.FromCode(
                new AssemblyCode[] {
                Instruction.Create("pushad"),
                Instruction.Create($"cmp byte ptr [{Context.MapFullScreen_Address}],0"),
                Instruction.Create("je _rwualfna"),
                Instruction.Create($"cmp byte ptr [{Context.MouseRight_Address}],0"),
                Instruction.Create("je _rwualfna"),
                Instruction.Create($"cmp byte ptr [{Context.MouseRightRelease_Address}],0"),
                Instruction.Create("je _rwualfna"),
                AssemblySnippet.FromCode(
                    new AssemblyCode[] {
                    Instruction.Create($"mov byte ptr [{Context.MapFullScreen_Address}],0"),
                    Instruction.Create($"mov byte ptr [{Context.MouseRightRelease_Address}],0"),
                    AssemblySnippet.FromDotNetCall(
                        Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "get_LocalPlayer"), null, false),
                    Instruction.Create("mov ebx,eax"),
                    Instruction.Create("push eax"),
                    Instruction.Create("mov dword ptr [esp],2"),
                    Instruction.Create($"fild dword ptr [{Context.ScreenWidth_Address}]"),
                    Instruction.Create("fild dword ptr [esp]"),
                    Instruction.Create("fdivp"),
                    Instruction.Create($"fild dword ptr [{Context.MouseX_Address}]"),
                    Instruction.Create("fsubp"),
                    Instruction.Create($"fld dword ptr [{Context.MapFullScreenScale_Address}]"),
                    Instruction.Create("fdivp"),
                    Instruction.Create($"fld dword ptr [{Context.MapFullscreenPos_Address + 4}]"),
                    Instruction.Create("fsubrp"),
                    Instruction.Create("mov dword ptr [esp],16"),
                    Instruction.Create("fild dword ptr [esp]"),
                    Instruction.Create("fmulp"),
                    Instruction.Create($"fstp dword ptr [ebx+{Entity.OFFSET_Position}]"),
                    Instruction.Create("mov dword ptr [esp],2"),
                    Instruction.Create($"fild dword ptr [{Context.ScreenHeight_Address}]"),
                    Instruction.Create("fild dword ptr [esp]"),
                    Instruction.Create("fdivp"),
                    Instruction.Create($"fild dword ptr [{Context.MouseY_Address}]"),
                    Instruction.Create("fsubp"),
                    Instruction.Create($"fld dword ptr [{Context.MapFullScreenScale_Address}]"),
                    Instruction.Create("fdivp"),
                    Instruction.Create($"fld dword ptr [{Context.MapFullscreenPos_Address + 8}]"),
                    Instruction.Create("fsubrp"),
                    Instruction.Create("mov dword ptr [esp],16"),
                    Instruction.Create("fild dword ptr [esp]"),
                    Instruction.Create("fmulp"),
                    Instruction.Create($"fstp dword ptr [ebx+{Entity.OFFSET_Position + 0x4}]"),

                    Instruction.Create("pop eax"),
                }),
                Instruction.Create("_rwualfna:"),
                Instruction.Create("popad")
            });

            InlineHook.Inject(Context.HContext, ass,
                              Context.HContext.AddressHelper.GetFunctionAddress("Terraria.Main", "DoUpdate"), false);
        }