i followed this tutorial about creating a server and client program using RPC and downloaded the source code from it http://www.aspfree.com/c/a/net/introduction-to-rpc-on-windows-part-i/
but when i ran the code "Runtime exception occured: 5" displayed which i know means access denied.
i debugged the program and found that the problem was with the line
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
here is the full show function:
void Show(
const unsigned char __RPC_FAR *szMsg)
{
RPC_BINDING_HANDLE _Handle = 0;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
if(!szMsg)
{
RpcRaiseException(RPC_X_NULL_REF_POINTER);
}
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&DoRPC_StubDesc,
0);
_Handle = hDoRPCBinding;
_StubMsg.BufferLength = 12U;
NdrConformantStringBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR *)szMsg,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg, _StubMsg.BufferLength, _Handle );
NdrConformantStringMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
(unsigned char __RPC_FAR *)szMsg,
(PFORMAT_STRING) &__MIDL_TypeFormatString.Format[4] );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char __RPC_FAR *) _StubMsg.Buffer );
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
}
and here's some code from main:
RpcTryExcept
{
const unsigned char szMsg[] = "Client: I Can RPC Now!";
Show(szMsg);
}
RpcExcept(1)
{
printf("Runtime exception occured: %d\n",RpcExceptionCode());
}
RpcEndExcept
so when debugging it jumped to the RpcExcept line when it reached NdrSendReceive
please help i have no idea how to fix this problem