Prev Previous Post   Next Post Next

Vista registry virtualization

Posted: 08-02-2007, 12:59 AM
Vista "virtualizes" the registry so the attempts to access values under HKLM
get redirected to HKCU\Software\Classes\VirtualStore\Machine but I've run
into a problem because it also appears to work the opposite way as well.

I have an app that needs to scan the entire HKCU hive and it works great
except that when I get to the VirtualStore key it picks up all the keys and
values from HKLM as well. I'm running with UAC enabled and am logged on as
a user without admin rights and the code below gives me a whole long list of
keys. The odd thing is that when I run regedit.exe without elevation I see
just a few keys so there must be a way to turn off virtualization when
reading these keys.

I've tried using ImpersonateLoggedOnUser which the MS web page says disables
virtualization and that seems to work for a user that has admin rights
(running elevated or not) but not for a regular user. What am I missing?



Private Const KEY_READ = &H20019
Private Const HKEY_USERS = &H80000003
Private Const HKEY_CURRENT_USER = &H80000001
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, _
phkResult As Long) As Long
Private Declare Function RegEnumKey Lib "advapi32.dll" _
Alias "RegEnumKeyA" (ByVal hKey As Long, ByVal dwIndex As Long, _
ByVal lpName As String, ByVal cbName As Long) As Long

x = RegOpenKey(HKEY_CURRENT_USER,
"Software\Classes\VirtualStore\Machine\Softwar e", hKey)
If x = 0 Then
k = 0
Do
sKey = String$(1024, 0)
lSize = Len(sKey)
x = RegEnumKey(hKey, k, sKey, lSize)
If x Then Exit Do
Me.Print k; " "; Left$(sKey, InStr(1, sKey, vbNullChar) - 1)
k = k + 1
Loop
x = RegCloseKey(hKey)
End If

Reply With Quote

Responses to "Vista registry virtualization"

 
LinkBack Thread Tools Display Modes
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Virtualization/LUA Sandeep Windows Vista Security 3 07-19-2007 06:24 PM
Data File Virtualization Question John Windows Vista Security 1 07-12-2007 08:36 PM
How Does Virtualization Tie in with Software Installations, if at all?? Superfreak3 Windows Vista Security 2 07-10-2007 07:47 PM
File Locations to Avoid Virtualization Wayne Hartell Windows Vista File Management 6 01-28-2007 01:30 AM
Virtualization Feature Jimmy Brush Windows Vista Security 4 12-12-2006 11:10 PM