What is the purpose of the m_samWOW64 public data member of ATL::CRegKey?

Viewed 42

The ATL::CRegKey class has a public data member named m_samWOW64 of type REGSAM.

This data member is usually initialized to 0, but in some CRegKey methods, like CRegKey::Create, it is set like this:

    ...
    m_hKey = hKey;
#if WINVER >= 0x0501
    m_samWOW64 = samDesired & (KEY_WOW64_32KEY | KEY_WOW64_64KEY);
#endif

So, what is the purpose of this public data member?

From the code above, it seems to me that m_samWOW64 is used to keep track of the WOW64 access specified in CRegKey::Create.

However, if a raw HKEY is attached to a CRegKey instance via CRegKey::Attach, this data member is set to zero.

Reading the CRegKey implementation code, there are some methods that set that data member as shown above for CRegKey::Create, and other methods that simply set it to 0. In other words, this data member cannot always be trusted as storing the WOW64 access of the associated key.

Moreover, there is no reference to this m_samWOW64 public data member in the MSDN documentation of ATL::CRegKey.

So, should the m_samWOW64 public data member simply be ignored in C++ client code that uses ATL::CRegKey?

Is it a leftover from the past? Or is there a documentation bug and MSDN is wrongly missing information about this data member?

0 Answers
Related