Help! Hook Array Field Offset [+1]

imls01245

Platinian
How to Hook This:

C#:
public Boards[] boards; // 0x54

I found the Reference but this time it is Field Offset


Here is struct

C++:
template <typename T>
struct monoArray
{
    void* klass;
    void* monitor;
    void* bounds;
    int max_length;
    void* vector [1];
    int getLength()
    {
        return max_length;
    }
    T getPointer()
    {
        return (T)vector;
    }
};

Here is my Hook but It wont work

C++:
void (*_casMenuUpdate)(void *ins);
void casMenuUpdate(void *ins) {
    if (ins != NULL) {
        monoArray<void> *boards = *(monoArray<void>**)((uint64_t) ins + 0x54);
        if (boards != NULL) {
            for (int i = 0; i < boards->getLength(); i++) {
                auto board = (*void) boards->getPointer();
                board[i] = 0; 
            }
        }
    }
}
 
Update: still dont know how to hook this field array


Here is the struct Related to Boards

C#:
public struct Boards // TypeDefIndex: 4262
{
	// Fields
	public string description; // 0x0
	public string boardTex; // 0x4
	public int coinCost; // 0x8
	public int sodaCost; // 0xC
	public bool isAvailableToPlayers; // 0x10
	public PerkType perkType; // 0x14
	public float perkAmount; // 0x18
}
 
Update: Here is my Hook but it crashes the game

C#:
void (*_CasUpdate)(void *ins);

void CasUpdate(void *ins) {
    if (ins != NULL) {
        // Access the monoArray<void**> at offset 0x54 within the instance
        monoArray<void**>* boards = *(monoArray<void**>**)((uint64_t) ins + 0x54);

        if (boards != NULL) {
            // Loop through the array of boards
            for (int i = 0; i < boards->getLength(); i++) {
                // Access the i-th board from the array
                void* board = boards->getPointer()[i];

                // Ensure the board is not NULL
                if (board != NULL) {
                    // Modify the field at offset 0x8 (which is an int)
                    // Cast `board` to `uint8_t*` to safely perform pointer arithmetic
                    *(int*)((uint64_t) board + 0x8) = 0;
                }
            }
        }
    }
}
 
Back
Top Bottom