コード例 #1
0
        public void Emit(GameContext context, MPointF Location)
        {
            int data = NativeFunctions.VirtualAllocEx(context.HContext.Handle, 0, (int)(32 * Projs.Count), NativeFunctions.AllocationType.Commit, NativeFunctions.MemoryProtection.ExecuteReadWrite);

            NativeFunctions.WriteProcessMemory(context.HContext.Handle, data, BitConverter.GetBytes(Projs.Count), 4, 0);
            for (int i = 0; i < Projs.Count; i++)
            {
                int t = data + 8 + i * 32;
                NativeFunctions.WriteProcessMemory(context.HContext.Handle, t, BitConverter.GetBytes(Projs[i].ProjType), 4, 0);
                NativeFunctions.WriteProcessMemory(context.HContext.Handle, t + 4, BitConverter.GetBytes(Location.X + Projs[i].Location.X), 4, 0);
                NativeFunctions.WriteProcessMemory(context.HContext.Handle, t + 8, BitConverter.GetBytes(Location.Y + Projs[i].Location.Y), 4, 0);
                NativeFunctions.WriteProcessMemory(context.HContext.Handle, t + 12, BitConverter.GetBytes(Projs[i].Speed.X), 4, 0);
                NativeFunctions.WriteProcessMemory(context.HContext.Handle, t + 16, BitConverter.GetBytes(Projs[i].Speed.Y), 4, 0);
            }
            AssemblySnippet snippet = AssemblySnippet.FromCode(
                new AssemblyCode[] {
                (Instruction)$"pushad",
                (Instruction)$"mov ebx,{data}",
            });

            snippet.Content.Add(AssemblySnippet.Loop(
                                    AssemblySnippet.FromCode(
                                        new AssemblyCode[] {
                (Instruction)$"mov eax,[esp]",                                        //i
                (Instruction)$"shl eax,5",
                (Instruction)$"lea eax,[ebx+8+eax]",
                Projectile.GetSnippet_Call_NewProjectile(context, null, false,
                                                         "[eax+4]", "[eax+8]", "[eax+12]", "[eax+16]", "[eax]", 0, 0f, context.MyPlayerIndex, 0f, 0f),
            }),
                                    (int)Projs.Count, true));
            snippet.Content.Add((Instruction)"popad");
            InlineHook.InjectAndWait(context.HContext, snippet,
                                     context.HContext.MainAddressHelper["Terraria.Main", "DoUpdate"], true);
            NativeFunctions.VirtualFreeEx(context.HContext.Handle, data, 0);
        }
コード例 #2
0
 public void DrawImage(ProjImage image, MPointF location)
 {
     foreach (var proj in image.Projs)
     {
         var newImg = proj;
         newImg.Location += location;
         Projs.Add(newImg);
     }
 }
コード例 #3
0
 public Proj(int projType, MPointF speed, MPointF location)
 {
     ProjType = projType;
     Speed    = speed;
     Location = location;
 }