Advertisement
Guest User

Untitled

a guest
Jan 21st, 2012
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.31 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.Runtime.InteropServices;
  4. using System.Threading;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. using System.Windows;
  13. using System.Globalization;
  14.  
  15. namespace Mw3_ingame_trainer_V1._0
  16. {
  17.  
  18.     public partial class Form1 : Form
  19.     {
  20.  
  21.  
  22.  
  23.         #region fields
  24.         public static int MOD_ALT = 0x1;
  25.         public static int MOD_CONTROL = 0x2;
  26.         public static int MOD_SHIFT = 0x4;
  27.         public static int MOD_WIN = 0x8;
  28.         public static int WM_HOTKEY = 0x312;
  29.         #endregion
  30.  
  31.         public int ammo = 0;
  32.         public int health = 0;
  33.         public int explo = 0;
  34.         public int cur = 1;
  35.         public uint maddy1 = 0x012AA910;
  36.         public uint maddy2 = 0x012AA898;
  37.         public uint maddy3 = 0x012AA91C;
  38.         public uint maddy4 = 0x012AA8A0;
  39.         public uint xaddy1 = 0x012AA928;
  40.         public uint xaddy2 = 0x012AA934;
  41.         public uint xaddy3 = 0x023AA940;
  42.         public uint xaddy4 = 0x012AA94C;
  43.         public uint haddy = 0x010C0428;
  44.         public int maddy1v = 999;
  45.         public int maddy2v = 999;
  46.         public int maddy3v = 999;
  47.         public int maddy4v = 999;
  48.         public int xaddy1v = 5;
  49.         public int xaddy2v = 5;
  50.         public int xaddy3v = 5;
  51.         public int xaddy4v = 5;
  52.         public int haddyv = 999999;
  53.  
  54.         [DllImport("kernel32.dll")]
  55.         static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  56.  
  57.         [DllImport("kernel32.dll")]
  58.         private static unsafe extern Boolean WriteProcessMemory(IntPtr hProcess, uint lpBaseAddress, byte[] lpBuffer, int nSize, void* lpNumberOfBytesWritten);
  59.  
  60.         [DllImport("kernel32.dll")]
  61.         public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
  62.  
  63.         [DllImport("kernel32.dll")]
  64.         public static extern Int32 CloseHandle(IntPtr hObject);
  65.  
  66.         [DllImport("kernel32.dll")]
  67.         public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
  68.  
  69.         [DllImport("kernel32.dll")]
  70.         public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
  71.  
  72.         static public IntPtr MemoryOpen(int ProcessID)
  73.         {
  74.             IntPtr hProcess = OpenProcess(0x1F0FFF, false, ProcessID);
  75.             return hProcess;
  76.         }
  77.         unsafe public void Write(uint mAddress, byte[] Buffer, int ProcessID)
  78.         {
  79.             if (MemoryOpen(ProcessID) == (IntPtr)0x00000000)
  80.             {
  81.                 MessageBox.Show("Mw3 Was Cosed!");
  82.             }
  83.             if (!WriteProcessMemory(MemoryOpen(ProcessID), mAddress, Buffer, Buffer.Length, null))
  84.             {
  85.                 MessageBox.Show("Couldnt Write Mw3 Memory!");
  86.             }
  87.         }
  88.  
  89.         Process[] pid = Process.GetProcessesByName("iw5sp");
  90.  
  91.         public Form1()
  92.         {
  93.             InitializeComponent();
  94.         }
  95.        
  96.         private void Form1_Load(object sender, EventArgs e)
  97.         {
  98.             timer1.Start();
  99.             timer2.Start();
  100.             timer3.Start();
  101.             label8.Text = DateTime.Now.ToString("h:MM tt dd/MM/yyyy");
  102.         }
  103.  
  104.         private void Form1_Closing(object sender, EventArgs e)
  105.         {
  106.             CloseHandle(MemoryOpen(pid[0].Id));
  107.         }
  108.  
  109.         public void timer1_Tick(object sender, EventArgs e)
  110.         {
  111.             if(this.Opacity < 0.80)
  112.             {
  113.                 this.Opacity += 0.01;
  114.             }
  115.             System.Diagnostics.Process[] myprocesses = System.Diagnostics.Process.GetProcessesByName("iw5sp");
  116.             if (myprocesses.Length != 0)
  117.             {
  118.                 button1.Enabled = true;
  119.                 button2.Enabled = true;
  120.                 button3.Enabled = true;
  121.             }
  122.             else if (myprocesses.Length == 0)
  123.             {
  124.                 button1.Enabled = false;
  125.                 button2.Enabled = false;
  126.                 button3.Enabled = false;
  127.                 ammo = 0;
  128.                 explo = 0;
  129.                 health = 0;
  130.                 label5.Text = "Off";
  131.                 label5.ForeColor = Color.Blue;
  132.                 label6.Text = "Off";
  133.                 label6.ForeColor = Color.Blue;
  134.                 label7.Text = "Off";
  135.                 label7.ForeColor = Color.Blue;
  136.             }
  137.  
  138.         }
  139.  
  140.         private void timer2_Tick(object sender, EventArgs e)
  141.         {
  142.             label8.Text = DateTime.Now.ToString("h:mm:s tt dd/MM/yyyy");
  143.         }
  144.  
  145.         private void timer3_Tick(object sender, EventArgs e)
  146.         {
  147.             if (ammo == 1)
  148.             {
  149.                 byte[] Buffer1 = BitConverter.GetBytes(maddy1v);
  150.                 byte[] Buffer2 = BitConverter.GetBytes(maddy2v);
  151.                 byte[] Buffer3 = BitConverter.GetBytes(maddy3v);
  152.                 byte[] Buffer4 = BitConverter.GetBytes(maddy4v);
  153.                 Write(maddy1, Buffer1, pid[0].Id);
  154.                 Write(maddy2, Buffer2, pid[0].Id);
  155.                 Write(maddy3, Buffer3, pid[0].Id);
  156.                 Write(maddy4, Buffer4, pid[0].Id);
  157.             }
  158.             if (health == 1)
  159.             {
  160.                 byte[] Buffer1 = BitConverter.GetBytes(haddyv);
  161.                 Write(haddy, Buffer1, pid[0].Id);
  162.             }
  163.             if (explo == 1)
  164.             {
  165.                 byte[] Buffer1 = BitConverter.GetBytes(xaddy1v);
  166.                 byte[] Buffer2 = BitConverter.GetBytes(xaddy2v);
  167.                 byte[] Buffer3 = BitConverter.GetBytes(xaddy3v);
  168.                 byte[] Buffer4 = BitConverter.GetBytes(xaddy4v);
  169.                 Write(xaddy1, Buffer1, pid[0].Id);
  170.                 Write(xaddy2, Buffer2, pid[0].Id);
  171.                 Write(xaddy3, Buffer3, pid[0].Id);
  172.                 Write(xaddy4, Buffer4, pid[0].Id);
  173.             }
  174.         }
  175.  
  176.         private void button1_Click(object sender, EventArgs e)
  177.         {
  178.             if (ammo == 0)
  179.             {
  180.                 ammo = 1;
  181.                 label5.Text = "On";
  182.                 label5.ForeColor = Color.Red;
  183.             }
  184.             else
  185.             {
  186.                 ammo = 0;
  187.                 label5.Text = "Off";
  188.                 label5.ForeColor = Color.Blue;
  189.             }
  190.         }
  191.  
  192.         private void button2_Click(object sender, EventArgs e)
  193.         {
  194.             if (explo == 0)
  195.             {
  196.                 explo = 1;
  197.                 label6.Text = "On";
  198.                 label6.ForeColor = Color.Red;
  199.             }
  200.             else
  201.             {
  202.                 explo = 0;
  203.                 label6.Text = "Off";
  204.                 label6.ForeColor = Color.Blue;
  205.             }
  206.         }
  207.  
  208.         private void button3_Click(object sender, EventArgs e)
  209.         {
  210.             if (health == 0)
  211.             {
  212.                 health = 1;
  213.                 label7.Text = "On";
  214.                 label7.ForeColor = Color.Red;
  215.             }
  216.             else
  217.             {
  218.                 health = 0;
  219.                 label7.Text = "Off";
  220.                 label7.ForeColor = Color.Blue;
  221.             }
  222.         }
  223.     }
  224.  
  225.  
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement