2

I'm trying to read a float using the VAMemory library, and I have the base offset and the offsets to be added to the pointer from CE, and I know they reference the value correctly (have been changing values accordingly in CE)

Here are the offsets as shown by CE: (According to previous questions on this topic, they should be applied from bottom to top as they appear in CE)

1

I've tried multiple implementations of "dereferencing" the pointers on each iteration, as the offsets have to be added one after the other, I'm not sure if I'm getting the base address correctly, if I should iterate through the modules of the process instead and match it with the name as I've seen done in other questions. I'm now trying to use an implementation that was shown in a similar question however the value I'm getting returned is always 0

private static float GetPointerValue(IntPtr baseAddress, int[] offsetArr)
{

VAMemory vam = new VAMemory("amtrucks");

//Adding original offset to base address
IntPtr pointer = IntPtr.Add((IntPtr)vam.ReadInt32(baseAddress + 0x014BC410), offsetArr[0]);
for (int i = 1; i < offsetArr.Length; i++)
{
   pointer = IntPtr.Add((IntPtr)vam.ReadInt32(pointer), offsetArr[i]);
}
return vam.ReadFloat(pointer);
}
public void SetCam(float height)
{
Process GameProcess = Process.GetProcessesByName("amtrucks").FirstOrDefault();
IntPtr BaseAddress = GameProcess.MainModule.BaseAddress;


//Offsets in reverse order
var offsetArr = new int[] { 0x18, 0x40, 0x0, 0x3C8, 0x48};

Console.WriteLine("value:" + GetPointerValue(BaseAddress, offsetArr));
}

It doesn't throw any exceptions or error message, but the value is always 0 (actual value is around 43)

0

1 Answer 1

2
public static IntPtr FindDMAAddy(IntPtr hProc, IntPtr ptr, int[] offsets)
{
    var buffer = new byte[IntPtr.Size];
    foreach (int i in offsets)
    {
        ReadProcessMemory(hProc, ptr, buffer, buffer.Length, out var read);

        ptr = (IntPtr.Size == 4)
        ? IntPtr.Add(new IntPtr(BitConverter.ToInt32(buffer, 0)), i)
        : ptr = IntPtr.Add(new IntPtr(BitConverter.ToInt64(buffer, 0)), i);
    }
    return ptr;
}

public static IntPtr GetModuleBaseAddress(Process proc, string modName)
{
    IntPtr addr = IntPtr.Zero;

    foreach (ProcessModule m in proc.Modules)
    {
        if (m.ModuleName == modName)
        {
            addr = m.BaseAddress;
            break;
        }
    }
    return addr;
}

Process proc = Process.GetProcessesByName("whatever")[0];

var modBase = GetModuleBaseAddress(proc, "whatever.exe");

var freecamheight = FindDMAAddy(hProc, (IntPtr)(modBase + 0x14bc410), new int[] { 0x18, 0x40, 0, 0x3c8, 0x48});

Then use VAMemory to read the float at address "freecamheight"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.