A
Ashutosh
Hi,
I have some code which was written around 8-10 years back and I really I
don't have much idea what it does (no one in my team has either) other
than that it connects to some other other service over the network. This
code is in a VC++ DLL which is being used by a VB Application. We are
planning to create a new application in C# which does all the work done
by them. I tried searching the web, it shows some RPC NDR related to DCOM.
Is it somewhere related to custom marshaling or in DCOM? Also, is it
possible to achieve the same result somehow in .Net?
A part of the code is
int getConfig(
/* [ref][out][in] */ struct rpcConfig __RPC_FAR *r)
{
RPC_BINDING_HANDLE _Handle = 0;
int _RetVal;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&chrpc_StubDesc,
10);
_Handle = hCHrpc;
_StubMsg.BufferLength = 0U;
NdrSimpleStructBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR *)r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156] );
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg,
_StubMsg.BufferLength, _Handle );
NdrSimpleStructMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
(unsigned char __RPC_FAR *)r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156] );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char
__RPC_FAR *) _StubMsg.Buffer );
if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) !=
NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING)
&__MIDL_ProcFormatString.Format[38] );
NdrSimpleStructUnmarshall( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR * __RPC_FAR
*)&r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156],
(unsigned char)0 );
_RetVal = *(( int __RPC_FAR * )_StubMsg.Buffer)++;
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
return _RetVal;
}
Thanks & Regards,
Ashutosh
I have some code which was written around 8-10 years back and I really I
don't have much idea what it does (no one in my team has either) other
than that it connects to some other other service over the network. This
code is in a VC++ DLL which is being used by a VB Application. We are
planning to create a new application in C# which does all the work done
by them. I tried searching the web, it shows some RPC NDR related to DCOM.
Is it somewhere related to custom marshaling or in DCOM? Also, is it
possible to achieve the same result somehow in .Net?
A part of the code is
int getConfig(
/* [ref][out][in] */ struct rpcConfig __RPC_FAR *r)
{
RPC_BINDING_HANDLE _Handle = 0;
int _RetVal;
RPC_MESSAGE _RpcMessage;
MIDL_STUB_MESSAGE _StubMsg;
RpcTryFinally
{
NdrClientInitializeNew(
( PRPC_MESSAGE )&_RpcMessage,
( PMIDL_STUB_MESSAGE )&_StubMsg,
( PMIDL_STUB_DESC )&chrpc_StubDesc,
10);
_Handle = hCHrpc;
_StubMsg.BufferLength = 0U;
NdrSimpleStructBufferSize( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR *)r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156] );
NdrGetBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg,
_StubMsg.BufferLength, _Handle );
NdrSimpleStructMarshall( (PMIDL_STUB_MESSAGE)& _StubMsg,
(unsigned char __RPC_FAR *)r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156] );
NdrSendReceive( (PMIDL_STUB_MESSAGE) &_StubMsg, (unsigned char
__RPC_FAR *) _StubMsg.Buffer );
if ( (_RpcMessage.DataRepresentation & 0X0000FFFFUL) !=
NDR_LOCAL_DATA_REPRESENTATION )
NdrConvert( (PMIDL_STUB_MESSAGE) &_StubMsg, (PFORMAT_STRING)
&__MIDL_ProcFormatString.Format[38] );
NdrSimpleStructUnmarshall( (PMIDL_STUB_MESSAGE) &_StubMsg,
(unsigned char __RPC_FAR * __RPC_FAR
*)&r,
(PFORMAT_STRING)
&__MIDL_TypeFormatString.Format[156],
(unsigned char)0 );
_RetVal = *(( int __RPC_FAR * )_StubMsg.Buffer)++;
}
RpcFinally
{
NdrFreeBuffer( (PMIDL_STUB_MESSAGE) &_StubMsg );
}
RpcEndFinally
return _RetVal;
}
Thanks & Regards,
Ashutosh