Say, I did
HANDLE h = CreateFileA ("foobar", GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_ALWAYS, 0, NULL);
Now handle h has GENERIC_READ | GENERIC_WRITE access (if the call succeeded).
Question: What function should i call on h to get back its access mode (that is, GENERIC_READ | GENERIC_WRITE)?
Example: GetStdHandle (STD_INPUT_HANDLE) returns some handle that somehow ended up being your stdin. You don’t know if it’s a file, or a pipe, or something else (there are ways to get handle type, but that’s not the point here). And it might have any access (CreateProcess does not check handles you give it in STARTUPINFO). Is there a way to get its access mask (other than trying appropriate calls on it)?
Call
NtQueryObjectpassingObjectBasicInformation.