How do I see inside opaque data types?

455 Views Asked by At

I know this kind of goes against the whole point of opaque data types, but for the purpose of reverse engineering, how do people go about looking into opaque data types?

2

There are 2 best solutions below

0
On BEST ANSWER

Unless you already have the source, there is no feasible way to "hack inside" an opaque type without having a clue of the underlying representation on a specific system. Hacking it would involve following each access to the opaque pointer in run-time and see where it goes, then start guessing from there.

Instead, you could Google for example the glibc source at Github. In stdio.h there is a conditional typedef which points either at __fpos_t or __fpos64_t in internal headers:

__fpos_t.h

typedef struct _G_fpos_t
{
  __off_t __pos;
  __mbstate_t __state;
} __fpos_t;

__fpos64_t.h

typedef struct _G_fpos64_t
{
  __off64_t __pos;
  __mbstate_t __state;
} __fpos64_t;

Not very exciting, but you can continue to trace those various types at Github from there and see what they boil down to in the end. Integers and enums, most likely.

1
On

In VC++ it is defined as

 typedef __int64 fpos_t;

which in turn is

typedef long long fpos_t;

If you want to know how it looks in assembly code, then just write a sample program, run it in debug mode, and, while debugging, open the Disassembly Window to watch the code behind.