Note that there are some explanatory texts on larger screens.

plurals
  1. POCross session activation. Session moniker ignored
    primarykey
    data
    text
    <p>There are two accounts on my windows pc: \A1 and \SYSTEM. My test project consists of three applications: </p> <ol> <li>Server.exe - out-of-proc com server. implements object <strong>Q</strong></li> <li>Service.exe - out-of proc com service. implements object <strong>T</strong></li> <li>Client.exe - a client applications</li> </ol> <p>My workflow is shown below:</p> <ol> <li>I logged in the \A1. I launch 'Client.exe'.</li> <li>Client creates an instance of the object 'T' </li> <li>Client calls some method, say 'T.ActivateQ', which instantiates 'Q'. </li> </ol> <p>My intention is to make Service.exe to create an instance of 'Q' in the account \A1, even though Service.exe resides under the \SYSTEM account.</p> <p>As stated in <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa383255%28v=vs.85%29.aspx" rel="nofollow">this</a> article, Windows has built in functionality to do this kind of activation called 'Session-to-Session activation'. It is implemented by means of Session Moniker ("Session:!clsid:").</p> <p>Given that, I've configured 'Server.exe' to run as 'Interactive user' via dcomcnfg. Then I've implemented the function 'CoGetClassObjectInSession':</p> <pre><code>void CoGetClassObjectInSession(DWORD sessionId, Guid const&amp; clsid, void *pvReserved, Guid const&amp; riid, void **ppv) { ATL::CComQIPtr&lt;IBindCtx&gt; bindCtxInst; COMCHK(CreateBindCtx(NULL, &amp;bindCtxInst)); CComQIPtr&lt;IMoniker&gt; classMonikerInst; COMCHK(::CreateClassMoniker(clsid, &amp;classMonikerInst)); std::wstringstream ss; ss &lt;&lt; L"Session:" &lt;&lt; std::dec &lt;&lt; sessionId; ULONG parsed; ATL::CComQIPtr&lt;IMoniker&gt; sessionMonikerInst; COMCHK(::MkParseDisplayNameEx(bindCtxInst, ss.str().c_str(), &amp;parsed, &amp;sessionMonikerInst)); ATL::CComQIPtr&lt;IMoniker&gt; classObjectMoniker; COMCHK(sessionMonikerInst-&gt;ComposeWith(classMonikerInst, FALSE, &amp;classObjectMoniker)); ATL::CComPtr&lt;IClassFactory&gt; sessionFactoryInst; COMCHK(classObjectMoniker-&gt;BindToObject(bindCtxInst, NULL, riid, ppv)); } </code></pre> <p>and I use it in the service:</p> <pre><code>HRESULT CMyActivator::Activate() { try { // Impersonate the client CComQIPtr&lt;IServerSecurity&gt; ss; COMCHK(::CoGetCallContext(__uuidof(IServerSecurity), reinterpret_cast&lt;void**&gt;(&amp;ss))); callctx_impersonation_handle _handle(ss); ImpersonationScope _imp_scope(_handle); CComQIPtr&lt;IClassFactory&gt; ppv; CoGetClassObjectInSession(/*session id for \\A1*/ 1, Guid(__uuidof(Q)), nullptr, Guid(__uuidof(IClassFactory)), reinterpret_cast&lt;void**&gt;(&amp;ppv)); ENSURE(NULL != ppv, "'ppv' should not be null"); return S_OK; } catch(std::exception const&amp; ex) { return E_FAIL; } catch(...) { return E_FAIL; } } </code></pre> <p>But nothing happens. I mean the service always launches the server in the session 0 which corresponds to the \SYSTEM account.</p> <p>Client's security settings:</p> <pre><code>COMCHK(::CoSetProxyBlanket( activatorQ , RPC_C_AUTHN_DEFAULT , RPC_C_AUTHZ_DEFAULT , NULL , RPC_C_AUTHN_LEVEL_DEFAULT , RPC_C_IMP_LEVEL_DELEGATE , NULL , EOAC_DYNAMIC_CLOAKING)); </code></pre> <p>Server.rgs file:</p> <pre><code>HKLM { NoRemove Software { NoRemove Classes { NoRemove AppID { ForceRemove '%APPID%' = s 'Test Server' { val RunAs = s 'Interactive User' } } } } } </code></pre> <p>Am I doing something wrong? </p> <p><strong>UPDATE</strong> I've finally found a solution. The registration script for the class 'Q' was missing the AppID field:</p> <pre><code>HKCR { NoRemove CLSID { ForceRemove {6FDE856C-F1B2-4466-8435-20F4AEF2C2E1} = s 'SMonClass Class' { ForceRemove Programmable LocalServer32 = s '%MODULE%' { val ServerExecutable = s '%MODULE_RAW%' } TypeLib = s '{4FA39B0F-5B24-43C6-A5B1-11D8F34277B7}' Version = s '1.0' --&gt; val AppID = s '%APPID%'** &lt;-- This line } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload