GENERIC_READ? FILE_GENERIC_READ?
WTF the difference is?!
Today I got a task to refine an application to make it check the file access at more detailed level. I ran into the problem of the difference of GENERIC_READ and FILE_GENERIC_READ. In MSDN the definition of GENERIC_READ is:
GENERIC_READ
- FILE_READ_ATTRIBUTES
- FILE_READ_DATA
- FILE_READ_EA
- STANDARD_RIGHTS_READ
- SYNCHRONIZE
But in WinNT.h it is:
#define GENERIC_READ (0x80000000L)
And there is another definition on WinNT.h:
#define FILE_GENERIC_READ (STANDARD_RIGHTS_READ |\
FILE_READ_DATA |\
FILE_READ_ATTRIBUTES |\
FILE_READ_EA |\
SYNCHRONIZE)
Which one should I use?!! Damn, this is a typical case of unfriendly API, and misguiding document!
Anyway actually I can use either. The FILE_GENERIC_READ is specific to the file kernel object, while the GENERIC_READ can apply to all kinds of kernel objects.
There are a series of great article in CodeProject which explained the topic in very much detail:
The Windows Access Control Model