Exemplo n.º 1
0
        public static Matrix ReadMatrix(long _lpBaseAddress)
        {
            Matrix tmp = new Matrix();

            byte[] Buffer = new byte[64];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 64, out ByteRead);

            tmp.M11 = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.M12 = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.M13 = BitConverter.ToSingle(Buffer, (2 * 4));
            tmp.M14 = BitConverter.ToSingle(Buffer, (3 * 4));

            tmp.M21 = BitConverter.ToSingle(Buffer, (4 * 4));
            tmp.M22 = BitConverter.ToSingle(Buffer, (5 * 4));
            tmp.M23 = BitConverter.ToSingle(Buffer, (6 * 4));
            tmp.M24 = BitConverter.ToSingle(Buffer, (7 * 4));

            tmp.M31 = BitConverter.ToSingle(Buffer, (8 * 4));
            tmp.M32 = BitConverter.ToSingle(Buffer, (9 * 4));
            tmp.M33 = BitConverter.ToSingle(Buffer, (10 * 4));
            tmp.M34 = BitConverter.ToSingle(Buffer, (11 * 4));

            tmp.M41 = BitConverter.ToSingle(Buffer, (12 * 4));
            tmp.M42 = BitConverter.ToSingle(Buffer, (13 * 4));
            tmp.M43 = BitConverter.ToSingle(Buffer, (14 * 4));
            tmp.M44 = BitConverter.ToSingle(Buffer, (15 * 4));
            return(tmp);
        }
Exemplo n.º 2
0
 // Update Thread
 private void Update(object sender)
 {
     while (true)
     {
         if (keys.Count > 0)
         {
             List <Key> keysData = new List <Key>(keys.Values);
             if (keysData != null && keysData.Count > 0)
             {
                 foreach (Key key in keysData)
                 {
                     if (Convert.ToBoolean(Managed.GetKeyState(key.Id) & Managed.KEY_PRESSED))
                     {
                         if (!key.IsKeyDown)
                         {
                             key.IsKeyDown = true;
                             OnKeyDown(key.Id, key.Name);
                         }
                     }
                     else
                     {
                         if (key.IsKeyDown)
                         {
                             key.IsKeyDown = false;
                             OnKeyUp(key.Id, key.Name);
                         }
                     }
                 }
             }
         }
         Thread.Sleep(interval);
     }
 }
Exemplo n.º 3
0
        public static byte ReadByte(long _lpBaseAddress)
        {
            byte[] Buffer = new byte[sizeof(byte)];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, sizeof(byte), out ByteRead);
            return(Buffer[0]);
        }
Exemplo n.º 4
0
        public static float ReadFloat(long _lpBaseAddress)
        {
            byte[] Buffer = new byte[sizeof(float)];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, sizeof(float), out ByteRead);
            return(BitConverter.ToSingle(Buffer, 0));
        }
Exemplo n.º 5
0
        public static Int32 ReadInt32(long _lpBaseAddress)
        {
            byte[] Buffer = new byte[4];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 4, out ByteRead);
            return(BitConverter.ToInt32(Buffer, 0));
        }
Exemplo n.º 6
0
        public static string ReadString2(long _lpBaseAddress, UInt64 _Size)
        {
            byte[] buffer = new byte[_Size];
            IntPtr BytesRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, buffer, _Size, out BytesRead);
            return(Encoding.ASCII.GetString(buffer));
        }
Exemplo n.º 7
0
        public static bool WriteMemory(long MemoryAddress, byte[] Buffer)
        {
            uint oldProtect;

            Managed.VirtualProtectEx(pHandle, (IntPtr)MemoryAddress, (uint)Buffer.Length, Managed.PAGE_READWRITE, out oldProtect);
            IntPtr ptrBytesWritten;

            return(Managed.WriteProcessMemory(pHandle, MemoryAddress, Buffer, (uint)Buffer.Length, out ptrBytesWritten));
        }
Exemplo n.º 8
0
        public static Vector2 ReadVector2(long _lpBaseAddress)
        {
            Vector2 tmp = new Vector2();

            byte[] Buffer = new byte[8];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 8, out ByteRead);
            tmp.X = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.Y = BitConverter.ToSingle(Buffer, (1 * 4));
            return(tmp);
        }
Exemplo n.º 9
0
        public static AxisAlignedBox ReadAABB(long _lpBaseAddress)
        {
            AxisAlignedBox tmp = new AxisAlignedBox();

            byte[] Buffer = new byte[32];
            IntPtr ByteRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, Buffer, 32, out ByteRead);
            tmp.Min.X = BitConverter.ToSingle(Buffer, (0 * 4));
            tmp.Min.Y = BitConverter.ToSingle(Buffer, (1 * 4));
            tmp.Min.Z = BitConverter.ToSingle(Buffer, (2 * 4));
            tmp.Max.X = BitConverter.ToSingle(Buffer, (4 * 4));
            tmp.Max.Y = BitConverter.ToSingle(Buffer, (5 * 4));
            tmp.Max.Z = BitConverter.ToSingle(Buffer, (6 * 4));
            return(tmp);
        }
Exemplo n.º 10
0
        public static string ReadString(long _lpBaseAddress, UInt64 _Size)
        {
            byte[] buffer = new byte[_Size];
            IntPtr BytesRead;

            Managed.ReadProcessMemory(pHandle, _lpBaseAddress, buffer, _Size, out BytesRead);

            for (int i = 0; i < buffer.Length; i++)
            {
                if (buffer[i] == 0)
                {
                    byte[] _buffer = new byte[i];
                    Buffer.BlockCopy(buffer, 0, _buffer, 0, i);
                    return(Encoding.ASCII.GetString(_buffer));
                }
            }
            return(Encoding.ASCII.GetString(buffer));
        }
Exemplo n.º 11
0
        public static bool WriteNop(long MemoryAddress, byte[] Buffer)
        {
            IntPtr ptrBytesWritten;

            return(Managed.WriteProcessMemory(pHandle, MemoryAddress, Buffer, (uint)Buffer.Length, out ptrBytesWritten));
        }
Exemplo n.º 12
0
 public static void CloseProcess()
 {
     Managed.CloseHandle(pHandle);
 }
Exemplo n.º 13
0
 public static IntPtr OpenProcess(int pId)
 {
     pHandle = Managed.OpenProcess(Managed.PROCESS_VM_READ | Managed.PROCESS_VM_WRITE | Managed.PROCESS_VM_OPERATION, false, pId);
     return(pHandle);
 }