Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi,
 
I have a COM dll with a class in it.
 
I have an app with a UAC level of asInvoker. This app creates a COM object as administrator.
 
Everything works fine running as administrator, and even logged in as standard user, right->click runas administrator.
 
However, when I log in as standard user and double-click, I see the UAC elevation prompt when my class gets invoked. I enter in the correct password, and the COM object creation passes, but I get an access denied error (0x80070005).
 
Anybody have any clues? Also, do you know of any great debuggers that I may use to solve this?
 

More Info:
 
I am building it in VS 2008, but it is using visual studio version 2.0 with MFC setting to 'using standard windows libraries' and Use of ATL set to 'Dynamic Link to ATL'
 
In the rgs file for the class whose object I am creating, I add the following:
NoRemove CLSID
{
  ForceRemove {<class-guid>} = s 'CDCRegistryWriter Class'
  {
    ProgID = s <ClassName>.1'
    VersionIndependentProgID = s '<className>'
    ForceRemove 'Programmable'
    InprocServer32 = s '%MODULE%'
    {
      val ThreadingModel = s 'Apartment'
    }
    val AppID = s '%APPID%'
    'TypeLib' = s '<library-guid>'
    Elevation
    {
        val Enabled = d 1
        val IconReference = s 'applicationIcon'
    }
    val LocalizedString = s '@%MODULE%,-100'
  }
}
The above settings, set the following keys:
 
HKLM\Software\Classes\CLSID\My ClassID (found in ClassName.rgs)\AppID (a string set to My AppGuid)
HKLM\Software\Classes\CLSID\My ClassID\LocalizedString (an expanding string set to @dllPath.dll,-100(where 100 is a string
in the string table)).
 
HKLM\Software\Classes\CLSID\My ClassID\Elevation\Enabled (a DWORD set to 1)
 
HKLM\Software\Classes\CLSID\My ClassID\Elevation\IconReference (An expanding string set to 'applicationIcon')
 
I add the following to the rgs file for the dll
HKCR
{
  NoRemove AppID
  {
    '%APPID%' = s '<AppName>'
    {
      val DllSurrogate = s ''
      val ROTFlags = s '1'
    }
    'CDCElevatedCOM.DLL'
    {
      val AppID = s '%APPID%'
    }
  }
}
The above code adds the following keys to the registry:
HKLM\Software\Clas
ses\AppID\My AppGuid(found in dllMain.h)>\ROTFlags(a string set to "1")
HKLM\Software\Classes\AppID\My AppGuid\DllSurrogate(a string set to empty)
 
Also, my calling code uses the standard old
 
HRESULT CallingClass::CoCreateInstanceAsAdmin(HWND hwnd,REFCLSID rClsid, REFIID rIid, void** ppv)
{
  try
  {
 
    HRESULT     hr;
    BIND_OPTS3	bo;
    WCHAR		wszCLSID[255];
    WCHAR		wszMonikerName[300];
 
    StringFromGUID2(rClsid,wszCLSID,sizeof(wszCLSID)/sizeof(wszCLSID[0])); 
 
    hr = StringCchPrintf(
       wszMonikerName,sizeof
       (wszMonikerName)/
       sizeof(wszMonikerName[0]),   
       L"Elevation:Administrator!new:%s", 
       wszCLSID);
 
    if(FAILED(hr))
    {
      . . .ShowMyDebugMessage		
      return hr;
    }
 
    memset(&bo, 0, sizeof(bo));
    bo.cbStruct	= sizeof(bo);
    bo.hwnd	= hwnd;
    bo.dwClassContext = CLSCTX_LOCAL_SERVER;
    return CoGetObject(wszMonikerName, 
        &bo, rIid, ppv );
  }
  catch(...)
  {
    . . .Show my debug message
    return E_FAIL;
  }
 
  return S_OK;
 
}
Posted 26-Jan-12 4:14am
Edited 31-Jan-12 8:06am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 Kamal Rocks 184
2 PIEBALDconsult 150
3 BillWoodruff 148
4 Jochen Arndt 135
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 31 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100