Search code examples
c++cbytefunction-pointersreturn-type

How to get a byte array in c/c++ from a function with unknown return type?


For example, I know the address of the function (lets say its 0x0183ad0), and I would like to get an object from that function which returns an unknown type:

unknownType(*fname)() = (unknownType(*)())0x0183ad0

Is there any global type I can replace unknownType with or any method to get that object as a byte array (I know the sizeof(unknownType))

NOTE:

The function return an object NOT A POINTER


EDIT:

It worked thanks to Botje's answer: Answer


Solution

  • "byte array" would be uint8_t* or unsigned char*.

    If you know the size of unknownType I would create a

    struct unknownType {
        uint8_t stuff[123];
    };
    

    so you can adapt the struct definition as you gain better understanding of its fields.