Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3026

access denied in client

$
0
0
I followed the MSDN tutorial on RPC programs:
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

but when i run the client i get access denied.
Code:

void main()
{
    RPC_STATUS status;
    unsigned char * pszUuid            = NULL;
    unsigned char * pszProtocolSequence = (unsigned char *)"ncacn_ip_tcp";
    unsigned char * pszNetworkAddress  = (unsigned char *)"127.0.0.1";
    unsigned char * pszEndpoint        = (unsigned char *)"2048";
    unsigned char * pszOptions          = NULL;
    unsigned char * pszStringBinding    = NULL;
    unsigned char * pszString          = (unsigned char *)"hello, world";
    unsigned long ulCode;

    status = RpcStringBindingCompose(pszUuid,
                                    pszProtocolSequence,
                                    pszNetworkAddress,
                                    pszEndpoint,
                                    pszOptions,
                                    &pszStringBinding);
        ShowRpcStatus(status);
        if (status)
        {
                exit(status);
        }

    status = RpcBindingFromStringBinding(pszStringBinding, &hello_IfHandle);
        ShowRpcStatus(status);
        if (status)
        {
                exit(status);
        }

    RpcTryExcept
    {
        HelloProc(pszString);
        Shutdown();
    }
    RpcExcept(1)
    {
        ulCode = RpcExceptionCode();
        printf("Runtime reported exception 0x%lx = %ld\n", ulCode, ulCode);
                ShowRpcStatus(ulCode);
    }
    RpcEndExcept

    status = RpcStringFree(&pszStringBinding);
        ShowRpcStatus(status);
        if (status)
        {
                exit(status);
        }

    status = RpcBindingFree(&hello_IfHandle);
        ShowRpcStatus(status);
        if (status)
        {
                exit(status);
        }

    exit(0);
}

/******************************************************/
/*        MIDL allocate and free                    */
/******************************************************/

void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len)
{
    return(malloc(len));
}

void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
    free(ptr);
}

i debugged the code and it executes the line HelloProc(pszString); in the RpcTryExceptfunction but then it jumps out and executes the code in RpcExcept(1)

Viewing all articles
Browse latest Browse all 3026

Trending Articles