Originally Posted by
Floppixx
I know but I can´t read it as float xD My result to read it as float are error´s
It´s not a horror. It is easy to understand ( i am a beginner) okay .... it is much work
A snippet from my Memory class..
Code:
/// <summary>
/// Reads memory of the Initialized Process
/// </summary>
/// <param name="address">Address to read memory from</param>
/// <param name="size">Size to read</param>
/// <param name="ret">Buffer Array</param>
/// <returns>Status of the Read if successful</returns>
public bool ReadMemory(uint address, int size, ref byte[] ret)
{
if (!Initialized)
throw new Exception("Memory not initialized.");
return ReadProcessMemory(Process.Handle, address, ret, size, 0);
}
/// <summary>
/// Reads memory of the Initialized Process to the specified Type
/// </summary>
/// <typeparam name="type">Type to return</typeparam>
/// <param name="address">Address to read memory from</param>
/// <returns>Bytes read returned as Type</returns>
public type Read<type>(uint address) where type : class
{
// Make sure we're not trying to handle a string
if (typeof(type) == typeof(string))
throw new Exception("Cannot read type string, use an Ascii or Unicode handler");
// Declare our return and HGlobal
type Return;
int Size = Marshal.SizeOf(typeof(type));
IntPtr HGlobal = Marshal.AllocHGlobal(Size);
// Copy our bytes and free our HGlobal
Marshal.Copy(ReadMemory(address, Size), 0, HGlobal, Size);
Return = Marshal.PtrToStructure(HGlobal, typeof(type)) as type;
Marshal.FreeHGlobal(HGlobal);
return Return;
}
ReadMemory is just my function to make sure my Memory class is initialized and calls RPM, Read can be called as..
Code:
Memory.Read<float>(0xDEADBEEF);
Alternatively you could define it so it doesn't return, but instead sets an out type. Something like..
Code:
public void Read<type>(uint address, out type output) where type : class
{
}
...
float ReadFloat;
Memory.Read<float>(0xDEADBEEF, out ReadFloat);