I'm delving deep into the Windows security systems and I've hit a bit of a brick wall. It's made me realize that my knowledge is quite lacking in some areas. My first problem is using the sizeof() function to get the size of an array or structure pointed to by a pointer. Eg:
Of course, this didn't work, and why should it? The size of tc is 4, which is appropriate for a pointer. But is there any way to find out the size of the array? Ie, I need a function that will return 256 when I input tc.
char *tc=new char;
cout << sizeof(tc) << endl;
My second problem is with arbitrary sized arrays. For example, here is the structure of TOKEN_PRIVILEGES:
I'm using this structure in conjunction with the function GetTokenInformation(). The problem is, in the context that I am using it, it needs a TOKEN_PRIVILEGES structure of size 220 bytes. How do I manipulate the structure to achieve this? This is my code:
typedef struct _TOKEN_PRIVILEGES
} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
I'm sure you get the idea. Basically, I create the empiric structure, pass it to the function, then repeat if necessary with the appropriate sized array. Except, I need to know how to make the TOKEN_PRIVILEGES structure the size returned in rl. Any help, please?
DWORD soti; //sizeof(ti)
DWORD rl; //Returns the required length of the array
int rCode; //Return code