1 Answer
1

It's printing rubbish because the data you haven't isn't a C string, it's just raw binary data. In the case of TokenPrivileges, the data is really a TOKEN_PRIVILEGES structure.

So, you should cast the byte buffer into a pointer to a TOKEN_PRIVILEGES structure. Note that it ends with a flexible array member -- the Privileges array will contain a variable number of array elements, which is why you have to query the total size and use a large enough byte buffer instead of just allocating a TOKEN_PRIVILEGES on the stack, which wouldn't be large enough to hold more than one entry.