Code Gem

Code Gem

Knowledge was arriving in dribs and drabs

Code Gem RSS Feed
 
 
 
 

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

Share/Save/Bookmark

One Response to “GENERIC_READ? FILE_GENERIC_READ?”

  1. 1
    global warming swindle:

    Good topic for making an effective dissertation. . . . . .

Leave a Reply

September 2010
M T W T F S S
« Feb «-»  
 12345
6789101112
13141516171819
20212223242526
27282930  

Blogroll