By looking at this answer: https://stackoverflow.com/a/4671482/1770034 I can use dlsym to get a global variable in C. Is it possible to get a member from a struct.
I'm guessing that if I had the following code in a shared object:
header.h
struct myStruct
{
int a;
int b;
};
imp.c
struct myStruct structure = { 123, 456 };
I could include the same header.h file and cast the whole pointer to a struct myStruct*. struct myStruct * capturedStructure = (struct myStruct*) dlsym(handle, "structure");
However, is there a way to get the address to member directly. I'm guessing I'm unable to do something like: int* c = (int*) dlsym(handle, "structure.b");
Since dlsym allows a person to grab a function or global by itself (without a header), I'm hoping that I can also grab a member without requiring a header.