Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

VesMem - Klasa do zabawy z pamięcią procesu.


Vesim

Rekomendowane odpowiedzi

Opublikowano

Taka tam pisana na szybko:

using System;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace VesMem
{
    class VesMem
    {
        #region FLAGS
        [Flags]
        enum ProcessAccessFlags : uint
        {
            All = 0x001F0FFF,
            Terminate = 0x00000001,
            CreateThread = 0x00000002,
            Operation = 0x00000008,
            Read = 0x00000010,
            Write = 0x00000020,
            DupHandle = 0x00000040,
            SetInformation = 0x00000200,
            QueryInformation = 0x00000400,
            Synchronize = 0x00100000,
            ReadControl = 0x00020000
        }
        #endregion
        #region IMPORTS
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, int bInheritHandle, uint dwProcessId);
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern int ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, uint size, out IntPtr lpNumberOfBytesRead);
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern int WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] byte[] buffer, uint size, out IntPtr lpNumberOfBytesWritten);
        [DllImport("kernel32.dll", SetLastError = true)]
        private static extern Int32 CloseHandle(IntPtr hProcess);
        #endregion
        #region VARIABLES
        private int Handle;
        private static IntPtr Zero = IntPtr.Zero;
        private bool Debug;
        private Process Proc;
        #endregion
        #region BASICS
        public VesMem             (bool Debug = false)
        {
            this.Debug = Debug;
            Proc = null;
        }
        public uint BaseAddress
        {
            get 
            { 
                if(Proc == null) return 0; 
                return (uint)Proc.MainModule.BaseAddress;
            }
        }
        public bool OpenProcess   (Process proc)
        {
            if ((this.Handle = (int)OpenProcess(ProcessAccessFlags.Write | ProcessAccessFlags.Operation | ProcessAccessFlags.Read, 1, (uint)proc.Id)) != 0)
            {
                Proc = proc;
                return true;
            }
            return false;
        }
        public bool OpenProcess   (uint pid)
        {
            foreach (Process proc in Process.GetProcesses())
                if (proc.Id == pid)
                {
                    OpenProcess(proc);
                }
            return false;
        }
        public bool OpenProcess   (string name)
        {
            foreach (Process proc in Process.GetProcesses())
                if (proc.ProcessName == name)
                {
                    return OpenProcess(proc);
                }
            return false;
        }
        public bool CloseProcess  ()
        {
            if (CloseHandle((IntPtr)Handle) != 0)
            {
                if(Proc != null)
                    Proc.Close();
                return true;
            }
            return false;
        }
        public uint GetModuleBase (string name)
        {
            foreach (ProcessModule mod in Proc.Modules)
            {
                if (mod.ModuleName.ToLower() == name.ToLower())
                    return (uint)mod.BaseAddress;
            }
            return 0;
        }

        public bool Write         (uint address, byte[] value, int length = -1)
        {
            if (length == -1)
                length = value.Length;

            if (WriteProcessMemory((IntPtr)Handle, (IntPtr)address, value, (UInt32)length, out Zero) != 0)
                return true; 

            return false;
        }
        public bool Read          (uint address, out byte[] value, int length)
        {
            if (length < 1)
            {
                value = new byte[0];
                return false;
            }

            value = new byte[length];
            if (ReadProcessMemory((IntPtr)Handle, (IntPtr)address, value, (UInt32)length, out Zero) != 0)
                return true;

            return false;
        }
        #endregion
        #region WRITE_STUFF
        public bool WriteByte     (uint address, byte value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteInt      (uint address, int value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteUInt     (uint address, uint value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteInt64    (uint address, Int64 value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteUInt64   (uint address, UInt64 value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }

        public bool WriteShort    (uint address, short value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteUShort   (uint address, ushort value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }

        public bool WriteFloat    (uint address, float value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }
        public bool WriteDouble   (uint address, double value)
        {
            return Write(address, BitConverter.GetBytes(value));
        }

        public bool WriteStringA  (uint address, string value)
        {
            return Write(address, System.Text.Encoding.UTF8.GetBytes(value + '\0'), value.Length + 1);
        }
        public bool WriteStringW  (uint address, string value)
        {
            return Write(address, System.Text.Encoding.Unicode.GetBytes(value + '\0'), (value.Length + 1) * 2);
        }
        public bool WriteString   (uint address, string value)
        {
            if (System.Text.Encoding.Default == System.Text.Encoding.Unicode)
            {
                return WriteStringW(address, value);
            }
            else
            {
                return WriteStringA(address, value);
            }
        }
        #endregion
        #region READ_STUFF
        public bool ReadByte      (uint address, out byte value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 1))
                return false;
            value = buff[0];
            return false;
        }
        public bool ReadInt       (uint address, out int value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 4))
                return false;
            value = BitConverter.ToInt32(buff, 0); 
            return false;
        }
        public bool ReadUInt      (uint address, out uint value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 4))
                return false;
            value = BitConverter.ToUInt32(buff, 4);
            return false;
        }
        public bool ReadInt64     (uint address, out Int64 value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 8))
                return false;
            value = BitConverter.ToInt64(buff, 0);
            return false;
        }
        public bool ReadUInt64    (uint address, out UInt64 value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 8))
                return false;
            value = BitConverter.ToUInt64(buff, 4);
            return false;
        }

        public bool ReadShort     (uint address, out short value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 2))
                return false;
            value = BitConverter.ToInt16(buff, 0);
            return false;
        }
        public bool ReadUShort    (uint address, out ushort value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 2))
                return false;
            value = BitConverter.ToUInt16(buff, 0);
            return false;
        }

        public bool ReadFloat     (uint address, out float value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 4))
                return false;
            value = BitConverter.ToSingle(buff, 0);
            return false;
        }
        public bool ReadDouble    (uint address, out double value)
        {
            byte[] buff;
            value = 0;
            if (!Read(address, out buff, 8))
                return false;
            value = BitConverter.ToDouble(buff, 0);
            return false;
        }

        public bool ReadStringA   (uint address, out string value, uint length)
        {
            byte[] buff;
            value = "";
            if (!Read(address, out buff, (int)length))
                return false;
            value = System.Text.Encoding.UTF8.GetString(buff);
            return false;
        }
        public bool ReadStringW   (uint address, out string value, uint length)
        {
            byte[] buff;
            value = "";
            if (!Read(address, out buff, (int)length * 2))
                return false;
            value = System.Text.Encoding.Unicode.GetString(buff);
            return false;
        }
        public bool ReadString    (uint address, out string value, uint length)
        {
            if (System.Text.Encoding.Default == System.Text.Encoding.Unicode)
            {
                return ReadStringW(address, out value, length);
            }
            else
            {
                return ReadStringA(address, out value, length);
            }
        }
        #endregion
    }
}

Nie pomagam na PW, od tego macie forum!!!

 

#PHP-things

 

 

08FMpDu.png

 

Opublikowano

Chyba się nie obrazisz jak dodam moją hardkorowszą wersję ? xD

 

 

    public class WinApi
    {
        #region Dll Imports
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool CreateProcess(String imageName,
        String cmdLine,
        IntPtr lpProcessAttributes,
        IntPtr lpThreadAttributes,
        bool boolInheritHandles,
        uint dwCreationFlags,
        IntPtr lpEnvironment,
        String lpszCurrentDir,
        ref STARTUPINFO si,
        out PROCESS_INFORMATION pi);
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize,
        MemoryProtection flNewProtect, out MemoryProtection lpflOldProtect);
        [DllImport("user32.dll")]
        public static extern void ReleaseDC(IntPtr dc);
        [DllImport("Shell32.dll")]
        public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern int GetTickCount();
        [DllImport("user32.dll")]
        public static extern int SetCursorPos(int x, int y);
        [DllImport("wininet.dll")]
        public static extern bool InternetGetConnectedState(out int Description, int ReservedValue);
        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
        public static extern bool ReleaseCapture();
        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool IsIconic(IntPtr hWnd);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int MapVirtualKey(int uCode, int uMapType);
        [DllImport("user32.dll",
        CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
        public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr GetForegroundWindow();
        [DllImport("user32.dll")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);
        [DllImport("user32.dll")]
        public static extern void SetWindowText(IntPtr hWnd, string str);
        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern IntPtr SetCapture(IntPtr hwnd);
        [DllImport("user32.dll")]
        public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int count);
        [DllImport("user32.dll")]
        public static extern bool IsZoomed(IntPtr hWnd);
        [DllImport("user32.dll")]
        public static extern bool FlashWindow(IntPtr hWnd, bool invert);
        [DllImport("user32.dll")]
        public static extern bool SetWindowPos(IntPtr hWnd, uint hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
        [DllImport("user32.dll")]
        public static extern bool ShowWindow(IntPtr hWnd, int nCmd);
        [DllImport("user32.dll")]
        public static extern IntPtr GetWindowRect(IntPtr hWnd, ref RECT rect);
        [DllImport("user32.dll")]
        public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
        [DllImport("user32.dll")]
        public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
        [DllImport("user32.dll")]
        public static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, uint lParam);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int GetClassName(IntPtr hWnd, StringBuilder className, int maxCharCount);
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern Int32 WaitForSingleObject(IntPtr Handle, UInt32 Wait);
        [DllImport("kernel32.dll")]
        public static extern uint ResumeThread(IntPtr hThread);
        [DllImport("user32.dll")]
        public static extern bool InvalidateRect(IntPtr hWnd, IntPtr lpRect, bool bErase);
        [DllImport("kernel32.dll")]
        public static extern IntPtr OpenProcess(UInt32 dwDesiredAccess, Int32 bInheritHandle, UInt32 dwProcessId);
        [DllImport("kernel32.dll")]
        public static extern Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
        [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesRead);
 
        [DllImport("kernel32.dll", SetLastError = true)]
        public static extern bool VirtualProtectEx(IntPtr hProcess, IntPtr lpAddress,
        IntPtr dwSize, MemoryProtection flNewProtect, ref MemoryProtection lpflOldProtect);
 
        [DllImport("kernel32.dll")]
        public static extern Int32 WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress,
        [In, Out] byte[] buffer, UInt32 size, out IntPtr lpNumberOfBytesWritten);
        [DllImport("kernel32.dll")]
        public static extern Int32 CloseHandle(IntPtr hObject);
        [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
        public static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress,
        uint dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
        [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
        public static extern bool VirtualFreeEx(IntPtr hProcess, IntPtr lpAddress,
        uint dwSize, AllocationType dwFreeType);
        [DllImport("user32.dll")]
        public static extern IntPtr GetDC(IntPtr hWnd);
        [DllImport("user32.dll")]
        public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);
        [DllImport("gdi32.dll")]
        public static extern int GetPixel(IntPtr hDC, int x, int y);
        [DllImport("gdi32.dll")]
        public static extern int SetPixel(IntPtr hDC, int x, int y, int color);
        [DllImport("kernel32.dll")]
        public static extern IntPtr CreateRemoteThread(IntPtr hProcess,
        IntPtr lpThreadAttributes, uint dwStackSize, IntPtr
        lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
        [DllImport("kernel32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
        public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetModuleHandle(string lpModuleName);
        #endregion
        #region Variables and structs
        public const uint PROCESS_ALL_ACCESS = 0x1F0FFF;
        public const uint PROCESS_VM_READ = 0x0010;
        public const uint PROCESS_VM_WRITE = 0x0020;
        public const uint PROCESS_VM_OPERATION = 0x0008;
        public const uint MEM_COMMIT = 0x1000;
        public const uint MEM_RESERVE = 0x2000;
        public const uint MEM_RELEASE = 0x8000;
        public const uint SWP_NOMOVE = 0x2;
        public const uint SWP_NOSIZE = 0x1;
        public const uint HWND_TOPMOST = 0xFFFFFFFF;
        public const uint HWND_NOTOPMOST = 0xFFFFFFFE;
        public const int SW_HIDE = 0;
        public const int SW_SHOWNORMAL = 1;
        public const int SW_SHOWMINIMIZED = 2;
        public const int SW_SHOWMAXIMIZED = 3;
        public const int SW_SHOWNOACTIVATE = 4;
        public const int SW_SHOW = 5;
        public const int SW_MINIMIZE = 6;
        public const int SW_SHOWMINNOACTIVE = 7;
        public const int SW_SHOWNA = 8;
        public const int SW_RESTORE = 9;
        public const int SW_SHOWDEFAULT = 10;
        public const uint WM_LBUTTONDOWN = 0x201;
        public const uint WM_LBUTTONUP = 0x202;
        public const uint CREATE_SUSPENDED = 0x00000004;
 
        public struct PROCESS_INFORMATION
        {
            public IntPtr hProcess;
            public IntPtr hThread;
            public uint dwProcessId;
            public uint dwThreadId;
        }
 
        public struct STARTUPINFO
        {
            public uint cb;
            public string lpReserved;
            public string lpDesktop;
            public string lpTitle;
            public uint dwX;
            public uint dwY;
            public uint dwXSize;
            public uint dwYSize;
            public uint dwXCountChars;
            public uint dwYCountChars;
            public uint dwFillAttribute;
            public uint dwFlags;
            public short wShowWindow;
            public short cbReserved2;
            public IntPtr lpReserved2;
            public IntPtr hStdInput;
            public IntPtr hStdOutput;
            public IntPtr hStdError;
        }
 
        public struct SECURITY_ATTRIBUTES
        {
            public int length;
            public IntPtr lpSecurityDescriptor;
            public bool bInheritHandle;
        }
 
        [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {
            public int left;
            public int top;
            public int right;
            public int bottom;
        }
 
        [Flags]
        public enum AllocationType
        {
            Commit = 0x1000,
            Reserve = 0x2000,
            Decommit = 0x4000,
            Release = 0x8000,
            Reset = 0x80000,
            Physical = 0x400000,
            TopDown = 0x100000,
            WriteWatch = 0x200000,
            LargePages = 0x20000000
        }
 
        [Flags]
        public enum MemoryProtection
        {
            Execute = 0x10,
            ExecuteRead = 0x20,
            ExecuteReadWrite = 0x40,
            ExecuteWriteCopy = 0x80,
            NoAccess = 0x01,
            ReadOnly = 0x02,
            ReadWrite = 0x04,
            WriteCopy = 0x08,
            GuardModifierflag = 0x100,
            NoCacheModifierflag = 0x200,
            WriteCombineModifierflag = 0x400
        }
        #endregion
        #region Memory
        #region Read Memory Functions
        public static Byte LoByte(Int16 nValue)
        {
            return (Byte)(nValue & 0xFF);
        }
        public static Byte HiByte(Int16 nValue)
        {
            return (Byte)(nValue >> 8);
        }
        public static byte LongtoByte(int numer, int nbytes)
        {
            if (nbytes == 1) return (byte)(numer >> 8);
            if (nbytes == 2) return (byte)(numer >> 16);
            if (nbytes == 3) return (byte)(numer >> 24);
            if (nbytes == 4) return (byte)(numer >> 32);
            return 0;
        }
        public static byte[] ReadBytes(IntPtr handle, long address, uint bytesToRead)
        {
            IntPtr ptrBytesRead;
            byte[] buffer = new byte[bytesToRead];
            WinApi.ReadProcessMemory(handle, new IntPtr(address), buffer, bytesToRead, out ptrBytesRead);
            return buffer;
        }
        public static byte ReadByte(IntPtr handle, long address)
        {
            return ReadBytes(handle, address, 1)[0];
        }
        public static short ReadInt16(IntPtr handle, long address)
        {
            return BitConverter.ToInt16(ReadBytes(handle, address, 2), 0);
        }
        public static ushort ReadUInt16(IntPtr handle, long address)
        {
            return BitConverter.ToUInt16(ReadBytes(handle, address, 2), 0);
        }
        [Obsolete("Please use ReadInt16")]
        public static short ReadShort(IntPtr handle, long address)
        {
            return BitConverter.ToInt16(ReadBytes(handle, address, 2), 0);
        }
        public static int ReadInt32(IntPtr handle, long address)
        {
            return BitConverter.ToInt32(ReadBytes(handle, address, 4), 0);
        }
        public static uint ReadUInt32(IntPtr handle, long address)
        {
            return BitConverter.ToUInt32(ReadBytes(handle, address, 4), 0);
        }
        public static ulong ReadUInt64(IntPtr handle, long address)
        {
            return BitConverter.ToUInt64(ReadBytes(handle, address, 8), 0);
        }
        [Obsolete("Please use ReadInt32.")]
        public static int ReadInt(IntPtr handle, long address)
        {
            return BitConverter.ToInt32(ReadBytes(handle, address, 4), 0);
        }
        public static double ReadDouble(IntPtr handle, long address)
        {
            return BitConverter.ToDouble(ReadBytes(handle, address, 8), 0);
        }
        public static string ReadString(IntPtr handle, long address)
        {
            return ReadString(handle, address, 0);
        }
        public static string ReadString(IntPtr handle, long address, uint length)
        {
            if (length > 0)
            {
                byte[] buffer;
                buffer = ReadBytes(handle, address, length);
                return System.Text.ASCIIEncoding.Default.GetString(buffer).Split(new Char())[0];
            }
            else
            {
                string s = "";
                byte temp = ReadByte(handle, address++);
                while (temp != 0)
                {
                    s += (char)temp;
                    temp = ReadByte(handle, address++);
                }
                return s;
            }
        }
        #endregion
        #region Write Memory Functions
        public static bool WriteBytes(IntPtr handle, long address, byte[] bytes, uint length)
        {
            IntPtr bytesWritten;
            int result = WinApi.WriteProcessMemory(handle, new IntPtr(address), bytes, length, out bytesWritten);
            return result != 0;
        }
        public static bool WriteInt32(IntPtr handle, long address, int value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value), 4);
        }
        public static bool WriteUInt32(IntPtr handle, long address, uint value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value), 4);
        }
        public static bool WriteUInt64(IntPtr handle, long address, ulong value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value), 8);
        }
        public static bool WriteInt16(IntPtr handle, long address, short value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value), 2);
        }
        public static bool WriteUInt16(IntPtr handle, long address, ushort value)
        {
            return WriteBytes(handle, address, BitConverter.GetBytes(value), 2);
        }
        [Obsolete("Please use WriteInt32.")]
        public static bool WriteInt(IntPtr handle, long address, int value)
        {
            byte[] bytes = BitConverter.GetBytes(value);
            return WriteBytes(handle, address, bytes, 4);
        }
        public static bool WriteDouble(IntPtr handle, long address, double value)
        {
            byte[] bytes = BitConverter.GetBytes(value);
            return WriteBytes(handle, address, bytes, 8);
        }
        public static bool WriteByte(IntPtr handle, long address, byte value)
        {
            return WriteBytes(handle, address, new byte[] { value }, 1);
        }
        public static bool WriteString(IntPtr handle, long address, string str)
        {
            str += '\0';
            byte[] bytes = System.Text.ASCIIEncoding.Default.GetBytes(str);
            return WriteBytes(handle, address, bytes, (uint)bytes.Length);
        }
        public static bool WriteRSA(IntPtr handle, long address, string newKey)
        {
            IntPtr bytesWritten;
            int result;
            WinApi.MemoryProtection oldProtection = 0;
            System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
            byte[] bytes = enc.GetBytes(newKey);
            WinApi.VirtualProtectEx(handle, new IntPtr(address), new IntPtr(bytes.Length), WinApi.MemoryProtection.ExecuteReadWrite, ref oldProtection);
            result = WinApi.WriteProcessMemory(handle, new IntPtr(address), bytes, (uint)bytes.Length, out bytesWritten);
            WinApi.VirtualProtectEx(handle, new IntPtr(address), new IntPtr(bytes.Length), oldProtection, ref oldProtection);
            return (result != 0);
        }
        #endregion
        #endregion
        #region Functions
        public static IEnumerable<string> SplitString(string incomingString, int numberToCut)
        {
            int nombreDeCaractere = incomingString.Length;
            List<string> result = new List<string>();
            string temp = string.Empty;
            int curseur = 0;
            do
            {
                for (int i = 0; i < numberToCut - 1; i++)
                {
                    temp += incomingString.Substring(i + curseur, 1);
                }
 
                result.Add(temp);
                temp = string.Empty;
                curseur += numberToCut;
            } while (nombreDeCaractere >= curseur + numberToCut);
 
            temp = string.Empty;
            for (int i = curseur; i < nombreDeCaractere; i++)
            {
                temp += incomingString.Substring(i, 1);
            }
 
            result.Add(temp);
 
            return result;
        }
 
        public static int RandomNumber(int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }
        public static int MakeLParam(int LoWord, int HiWord) { return ((HiWord << 16) | (LoWord & 0xffff)); }
        public static int MakeWParam(int LoWord, int HiWord) { return ((HiWord << 16) | (LoWord & 0xffff)); }
        #endregion
        #region VKeys
        public enum VKeys : int
        {
            VK_LBUTTON = 0x01,   //Left mouse button
            VK_RBUTTON = 0x02,   //Right mouse button
            VK_CANCEL = 0x03,   //Control-break processing
            VK_MBUTTON = 0x04,   //Middle mouse button (three-button mouse)
            VK_BACK = 0x08,   //BACKSPACE key
            VK_TAB = 0x09,   //TAB key
            VK_CLEAR = 0x0C,   //CLEAR key
            VK_RETURN = 0x0D,   //ENTER key
            VK_SHIFT = 0x10,   //SHIFT key
            VK_CONTROL = 0x11,   //CTRL key
            VK_MENU = 0x12,   //ALT key
            VK_PAUSE = 0x13,   //PAUSE key
            VK_CAPITAL = 0x14,   //CAPS LOCK key
            VK_ESCAPE = 0x1B,   //ESC key
            VK_SPACE = 0x20,   //SPACEBAR
            VK_PRIOR = 0x21,   //PAGE UP key
            VK_NEXT = 0x22,   //PAGE DOWN key
            VK_END = 0x23,   //END key
            VK_HOME = 0x24,   //HOME key
            VK_LEFT = 0x25,   //LEFT ARROW key
            VK_UP = 0x26,   //UP ARROW key
            VK_RIGHT = 0x27,   //RIGHT ARROW key
            VK_DOWN = 0x28,   //DOWN ARROW key
            VK_SELECT = 0x29,   //SELECT key
            VK_PRINT = 0x2A,   //PRINT key
            VK_EXECUTE = 0x2B,   //EXECUTE key
            VK_SNAPSHOT = 0x2C,   //PRINT SCREEN key
            VK_INSERT = 0x2D,   //INS key
            VK_DELETE = 0x2E,   //DEL key
            VK_HELP = 0x2F,   //HELP key
            VK_0 = 0x30,   //0 key
            VK_1 = 0x31,   //1 key
            VK_2 = 0x32,   //2 key
            VK_3 = 0x33,   //3 key
            VK_4 = 0x34,   //4 key
            VK_5 = 0x35,   //5 key
            VK_6 = 0x36,    //6 key
            VK_7 = 0x37,    //7 key
            VK_8 = 0x38,   //8 key
            VK_9 = 0x39,    //9 key
            VK_A = 0x41,   //A key
            VK_B = 0x42,   //B key
            VK_C = 0x43,   //C key
            VK_D = 0x44,   //D key
            VK_E = 0x45,   //E key
            VK_F = 0x46,   //F key
            VK_G = 0x47,   //G key
            VK_H = 0x48,   //H key
            VK_I = 0x49,    //I key
            VK_J = 0x4A,   //J key
            VK_K = 0x4B,   //K key
            VK_L = 0x4C,   //L key
            VK_M = 0x4D,   //M key
            VK_N = 0x4E,    //N key
            VK_O = 0x4F,   //O key
            VK_P = 0x50,    //P key
            VK_Q = 0x51,   //Q key
            VK_R = 0x52,   //R key
            VK_S = 0x53,   //S key
            VK_T = 0x54,   //T key
            VK_U = 0x55,   //U key
            VK_V = 0x56,   //V key
            VK_W = 0x57,   //W key
            VK_X = 0x58,   //X key
            VK_Y = 0x59,   //Y key
            VK_Z = 0x5A,    //Z key
            VK_NUMPAD0 = 0x60,   //Numeric keypad 0 key
            VK_NUMPAD1 = 0x61,   //Numeric keypad 1 key
            VK_NUMPAD2 = 0x62,   //Numeric keypad 2 key
            VK_NUMPAD3 = 0x63,   //Numeric keypad 3 key
            VK_NUMPAD4 = 0x64,   //Numeric keypad 4 key
            VK_NUMPAD5 = 0x65,   //Numeric keypad 5 key
            VK_NUMPAD6 = 0x66,   //Numeric keypad 6 key
            VK_NUMPAD7 = 0x67,   //Numeric keypad 7 key
            VK_NUMPAD8 = 0x68,   //Numeric keypad 8 key
            VK_NUMPAD9 = 0x69,   //Numeric keypad 9 key
            VK_SEPARATOR = 0x6C,   //Separator key
            VK_SUBTRACT = 0x6D,   //Subtract key
            VK_DECIMAL = 0x6E,   //Decimal key
            VK_DIVIDE = 0x6F,   //Divide key
            VK_F1 = 0x70,   //F1 key
            VK_F2 = 0x71,   //F2 key
            VK_F3 = 0x72,   //F3 key
            VK_F4 = 0x73,   //F4 key
            VK_F5 = 0x74,   //F5 key
            VK_F6 = 0x75,   //F6 key
            VK_F7 = 0x76,   //F7 key
            VK_F8 = 0x77,   //F8 key
            VK_F9 = 0x78,   //F9 key
            VK_F10 = 0x79,   //F10 key
            VK_F11 = 0x7A,   //F11 key
            VK_F12 = 0x7B,   //F12 key
            VK_SCROLL = 0x91,   //SCROLL LOCK key
            VK_LSHIFT = 0xA0,   //Left SHIFT key
            VK_RSHIFT = 0xA1,   //Right SHIFT key
            VK_LCONTROL = 0xA2,   //Left CONTROL key
            VK_RCONTROL = 0xA3,    //Right CONTROL key
            VK_LMENU = 0xA4,      //Left MENU key
            VK_RMENU = 0xA5,   //Right MENU key
            VK_PLAY = 0xFA,   //Play key
            VK_ZOOM = 0xFB, //Zoom key
        }
        #endregion
    }
  • 2 miesiące temu...

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...