CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2003
    Posts
    938

    Vista and NT exports

    Hey.
    I am accessing exported function from NTDLL.DLL directing using the following code:
    Code:
    	if( !(CreateKey = (NtCreateKey) GetProcAddress( GetModuleHandle(L"ntdll.dll"),
    			"NtCreateKey" )) ) {
    
    		printf("Could not find NtCreateKey entry point in NTDLL.DLL\n");
    		exit(1);
    	}
    	if( !(DeleteKey = (NtDeleteKey) GetProcAddress( GetModuleHandle(L"ntdll.dll"),
    			"NtDeleteKey" )) ) {
    
    		printf("Could not find NtDeleteKey entry point in NTDLL.DLL\n");
    		exit(1);
    	}
    	if( !(SetValueKey = (NtSetValueKey) GetProcAddress( GetModuleHandle(L"ntdll.dll"),
    			"NtSetValueKey" )) ) {
    
    		printf("Could not find NtSetValueKey entry point in NTDLL.DLL\n");
    		exit(1);
    	}
    	if(!(QueryValueKey = (NtQueryValueKey) GetProcAddress(GetModuleHandle(L"ntdll.dll"),"NtSetValueKey")))
    	{
    		printf("Could not find NtQueryValueKey entry point in NTDLL.DLL\n");
    		exit(1);
    	}
    This code work fine on 2000/xp/vista. However when i try to call the function on vista, i dont; get an error, but
    the function does nothing. Any ideas why?
    Code:
    	Status = CreateKey( &SoftwareKeyHandle, KEY_ALL_ACCESS,&ObjectAttributes, 0,  NULL, REG_OPTION_NON_VOLATILE,&Disposition );
    This is a piece of code that works ifne on 2k/xp but vista return success but the code doesn;t actually create the key.
    Any ideas why this might be?
    Thx in advance.

  2. #2
    Join Date
    Feb 2003
    Location
    California
    Posts
    334

    Re: Vista and NT exports

    The key is probably created, but not where you think it's created. Vista uses virtualization, so that if you write to protected areas, such as under the HKLM registry root, or the Program Files directory, your app thinks it's doing it, but the actual runtime location is changed. Usually the location can be found under the user profile area (files in "C:\Documents and Settings\[user name]," reg keys under HKCU).
    Henri Hein
    Principal Engineer, Propel
    Do not credit Propel with my views or opinions.

  3. #3
    Join Date
    Aug 2003
    Posts
    938

    Re: Vista and NT exports

    Thx, ill check that out, but i was wondering if there are any good articles that explain extent of virtualization on vista? i read some on msdn but most were rather basic.
    [EDIT]
    Okey, i just tested this on another vista box and it worked fine. Wouldn;t the vrtualization be taken into account when i use regedit to browse the registry?
    [EDIT 2]
    Thx, works.
    Last edited by Quell; March 20th, 2007 at 07:38 AM.

  4. #4
    Join Date
    Feb 2003
    Location
    California
    Posts
    334

    Re: Vista and NT exports

    Quell,

    Regedit will give you the 'true' view of the registry, although it probably depends on the account you are running as.

    A good Vista compatibility overview can be found here: http://msdn2.microsoft.com/en-us/win.../aa904987.aspx
    Henri Hein
    Principal Engineer, Propel
    Do not credit Propel with my views or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured