in reply to Win32 Tieregistry issue

Without duplicating it (I'm unable to), I would say the problem has to do with the data that you're unpacking.

Are you sure that $SubAuthorityCount contains the correct number?