private static void ReadBuffer(IntPtr ProcessHandle, IntPtr Offset, ref Byte[] buffer, int Length)
{
IntPtr bytesRead = IntPtr.Zero;
if (!ReadProcessMemory(ProcessHandle, Offset, buffer, new IntPtr(Length), ref bytesRead))
throw new ApplicationException("ReadProcessMemory returned false. Offset: [" + Offset.ToString("X8") + "], Length: [" + Length.ToString() + "].");
if (bytesRead != (IntPtr)Length)
throw new ApplicationException("ReadProcessMemory returned incorrect byte count. Expected: [" + Length.ToString() + "]. Actual: [" + bytesRead.ToString() + "].");
}