If you want to disable 64-bit file system redirection,
you call the
Wow64DisableWow64FsRedirection
function.
This function gives you a cookie.
When you are finished, you call
Wow64RevertWow64FsRedirection
,
passing the cookie you received from the previous call.
Like this:
void* cookie; if (Wow64DisableWow64FsRedirection(&cookie)) { ... do stuff ... Wow64RevertWow64FsRedirection(cookie); }
The unfortunate thing is that the data type for the cookie
is an untyped pointer: void*
.
This means that the following mistake goes undetected:
// Remember: Code in italics is wrong. void* cookie; if (Wow64DisableWow64FsRedirection(&cookie)) { ... do stuff ... Wow64RevertWow64FsRedirection(&cookie); }
The erroneous parameter to
Wow64RevertWow64FsRedirection
goes undetected because void**
is implicitly
convertible to void*
.
Because any pointer is implicitly convertible to
void*
,
because
void*
is a generic pointer.
In retrospect, the type of the cookie used by the file system
redirection functions should have been something other than
void*
.
It could have used DECLARE_HANDLE
,
which declares a pointer to a dummy structure with a unique name.
Or it could have been a pointer to a uniquely-named incomplete
type.