Patch 1/5 is difficult to read, because it moves things and changes them at the same time. Modifying the string processing variables (i.e. "pos" / "i" -> "name") generally isn't that hard to understand, although it probably could be possible to do that iteratively. I have a harder time figuring out, though, where the force_wow32 logic goes, or what's preventing us from opening a wow6432node key twice.
Also: it shouldn't be necessary to change the signature of open_key(), should it? "root" is already just "attr->RootDirectory".