Windows RPC Register in Windows 8

If your application runs in Windows App store, you will meet RPC the old   RpcServerRegisterIf is not work. 

When you send from Windows App container, you will get error code: 5 when you are create RPC context.


Problem Describe:

A : Application in windows App Container.

B:  Application in windows

A - RPC -> B (not allow)

Mainly in Windows App Container is the lowest Integrity, even the low integrity application B can not receive RPC message.


The original RPC register in B:


{{{

RPC_STATUS status = RpcServerRegisterIf(interfaceHandle, NULL, NULL);

if (status!=RPC_S_OK)   {
        return FALSE;
}

status = RpcServerUseProtseqEpW(
        (RPC_WSTR)L"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
          L"BApplicationRPCEndPointName", NULL);

if (status)    {
      return FALSE;
}

status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 1);

if (status)    {
      return FALSE;
}
}}}

to solve the problem, you need to use:

RPC_STATUS RPC_ENTRY RpcServerRegisterIf3(
  _In_      RPC_IF_HANDLE IfSpec,
  _In_opt_  UUID *MgrTypeUuid,
  _In_opt_  RPC_MGR_EPV *MgrEpv,
  _In_      unsigned int Flags,
  _In_      unsigned int MaxCalls,
  _In_      unsigned int MaxRpcSize,
  _In_opt_  RPC_IF_CALLBACK_FN *IfCallbackFn,
  _In_opt_  void *SecurityDescriptor
);

http://msdn.microsoft.com/en-us/library/windows/desktop/jj552974%28v=vs.85%29.aspx

example:

{{{

PSECURITY_DESCRIPTOR psd=NULL;
ULONG size;

if(!ConvertStringSecurityDescriptorToSecurityDescriptor(
                  L"D:(A;;GA;;;AU)(A;;GA;;;AC)",SDDL_REVISION_1,&psd,&size))
{
    return false;
}

if(!psd) return false;

 RPC_STATUS status =
RpcServerRegisterIf3(interfaceHandle, NULL, NULL,
                                    RPC_IF_ALLOW_CALLBACKS_WITH_NO_AUTH, 
                                    RPC_C_LISTEN_MAX_CALLS_DEFAULT, -1, NULL, pSD);

if (status!=RPC_S_OK)   {

        return FALSE;

}

status = RpcServerUseProtseqEpW(
        (RPC_WSTR)L"ncalrpc", RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
          L"BApplicationRPCEndPointName", pSD);

if (status)    {

      return FALSE;

}

status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, 1);

if (status)    {

      return FALSE;
}

}}}

Description:

1. You need to know what is Security Descriptor.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa379563%28v=vs.85%29.aspx

Get the high security descriptor

2. use RpcServerRegisterIf3

3. in RpcServerUseProtseqEpW instead of NULL use Security Descriptor.


Now you can connect your application in Windows app Container to your application.

some information is from
http://lists.nvaccess.org/pipermail/nvda-dev/2012-April/025428.html 
http://lists.nvaccess.org/pipermail/nvda-dev/2012-April/025429.html

留言

這個網誌中的熱門文章

上海的五險一金

公積金提領歷險記

中國上海養老保險個人帳戶終止、醫療保險清算