Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Management.Instrumentation;
- namespace Memory
- {
- public partial class Form1 : Form
- {
- #region Basic Stuff
- [DllImport("kernel32.dll")]
- private static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
- [DllImport("kernel32.dll")]
- private static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
- IntPtr pHandel;
- public bool Process_Handle(string ProcessName)
- {
- try
- {
- Process[] ProcList = Process.GetProcessesByName(ProcessName);
- if (ProcList.Length == 0)
- return false;
- else
- {
- pHandel = ProcList[0].Handle;
- return true;
- }
- }
- catch (Exception ex)
- { Console.Beep(); Console.WriteLine("Process_Handle - " + ex.Message); return false; }
- }
- private byte[] Read(int Address, int Length)
- {
- byte[] Buffer = new byte[Length];
- IntPtr Zero = IntPtr.Zero;
- ReadProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
- return Buffer;
- }
- private void Write(int Address, int Value)
- {
- byte[] Buffer = BitConverter.GetBytes(Value);
- IntPtr Zero = IntPtr.Zero;
- WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
- }
- private void Write2(int Address, float Value)
- {
- byte[] Buffer = BitConverter.GetBytes(Value);
- IntPtr Zero = IntPtr.Zero;
- WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
- }
- public void WriteFloat(int Address, float Value)
- {
- Write2(Address, Value);
- }
- #endregion
- //This is the part you want to edit
- #region Write Functions (Integer & String)
- public void WriteInteger(int Address, int Value)
- {
- Write(Address, Value);
- }
- public void WriteString(int Address, string Text)
- {
- byte[] Buffer = new ASCIIEncoding().GetBytes(Text);
- IntPtr Zero = IntPtr.Zero;
- WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
- }
- public void WriteBytes(int Address, byte[] Bytes)
- {
- IntPtr Zero = IntPtr.Zero;
- WriteProcessMemory(pHandel, (IntPtr)Address, Bytes, (uint)Bytes.Length, out Zero);
- }
- public void WriteNOP(int Address)
- {
- byte[] Buffer = new byte[] { 0x90, 0x90, 0x90, 0x90, 0x90 };
- IntPtr Zero = IntPtr.Zero;
- WriteProcessMemory(pHandel, (IntPtr)Address, Buffer, (UInt32)Buffer.Length, out Zero);
- }
- #endregion
- #region Read Functions (Integer & String)
- public int ReadInteger(int Address, int Length = 4)
- {
- return BitConverter.ToInt32(Read(Address, Length), 0);
- }
- public float ReadFloat(int Address, int Length = 8)
- {
- return BitConverter.ToSingle(Read(Address, Length), 0);
- }
- public string ReadString(int Address, int Length = 4)
- {
- return new ASCIIEncoding().GetString(Read(Address, Length));
- }
- public byte[] ReadBytes(int Address, int Length)
- {
- return Read(Address, Length);
- }
- #endregion
- [DllImport("kernel32.dll")]
- static extern bool VirtualProtectEx(IntPtr hProcess, int lpAddress,
- UIntPtr dwSize, uint flNewProtect, out uint lpflOldProtect);
- public enum Protection : uint
- {
- PAGE_NOACCESS = 0x01,
- PAGE_READONLY = 0x02,
- PAGE_READWRITE = 0x04,
- PAGE_WRITECOPY = 0x08,
- PAGE_EXECUTE = 0x10,
- PAGE_EXECUTE_READ = 0x20,
- PAGE_EXECUTE_READWRITE = 0x40,
- PAGE_EXECUTE_WRITECOPY = 0x80,
- PAGE_GUARD = 0x100,
- PAGE_NOCACHE = 0x200,
- PAGE_WRITECOMBINE = 0x400
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- System.Management.ManagementObjectSearcher Processes = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Process Where Name ='gta_sa.exe' ");
- string user = Environment.UserName;
- foreach (System.Management.ManagementObject process in Processes.Get())
- {
- if (process["ExecutablePath"] != null)
- {
- string[] OwnerInfo = new string[2];
- process.InvokeMethod("GetOwner", (object[])OwnerInfo);
- if (OwnerInfo[0] == user)
- {
- uint processId = (uint)process["ProcessId"];
- Process pro = Process.GetProcessById((int)processId);
- pHandel = pro.Handle;
- }
- }
- }
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- if (listBox1.SelectedIndex == -1)
- MessageBox.Show("Noob, you didn't selected any weather.", "Newbie eror 404");
- else
- {
- #region luam gta in useru asta
- System.Management.ManagementObjectSearcher Processes = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Process Where Name ='gta_sa.exe' ");
- string user = Environment.UserName;
- foreach (System.Management.ManagementObject process in Processes.Get())
- {
- if (process["ExecutablePath"] != null)
- {
- string[] OwnerInfo = new string[2];
- process.InvokeMethod("GetOwner", (object[])OwnerInfo);
- if (OwnerInfo[0] == user)
- {
- uint processId = (uint)process["ProcessId"];
- Process pro = Process.GetProcessById((int)processId);
- pHandel = pro.Handle;
- }
- }
- }
- #endregion
- WriteInteger(0xC81320, listBox1.SelectedIndex);
- }
- }
- private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
- {
- System.Diagnostics.Process.Start("http://ugbase.eu/");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement