I need to return the string data from the RPC function that i am calling. String will be very dynamic so i am interested in using stl string inside the idl.
I tried dynamic arrays but i am unable to persist the pointer from heap corruption... e.g. here is my idl code
unsigned char *ms = NULL;
//i have tried even initialized pointer by sending it to the server but it also gave me heap corruption , also i have used address of pointer but same result
RpcTryExcept
{
RPC_GetGroupStatusEx(&ms);
}
RpcExcept(1)
{
int a = RpcExceptionCode();
std::cerr << "Runtime reported exception " << RpcExceptionCode()
<< std::endl;
}
RpcEndExcept
it always crash at the server side code after leaving that function , one more thing is RPC server is on the different machine. Every other functions with data types works fine except string.
Please guide me what i am doing wrong in the code? How can i use stl string inside the idl file ?
Regards
Last edited by Wolvorine; February 4th, 2011 at 12:24 AM.
HRESULT Proc7(
[out] long * pSize,
[out, size_is( , *pSize)] my_type ** ppMyType); /* Specifies a pointer
to a sized pointer,
which points to a block
of my_types, whose size is
unknown when the stub
calls the server. */
But at the end of my function inside server i see this error
Code:
HEAP CORRUPTION DETECTED: after Normal block (#4165) at 0x0081F710.
CRT detected that the application wrote to memory after end of heap buffer.
both of the style of server function gives heap error , first one raised right after the end of the function while the second one gives in after the end of function and then in middle of another statement.
my server and client both are unicode but my interface is non-unicode and i am communicating things with using char instead of wchar. So basically when i call the rpc function i provides non-unicode character pointers.
Your buffer allocation seems missing space for a zero terminator. Besides, I'm not sure about the way you allocate that (actually, I'm sure new doesn't belong here). You definitely need some reading about RPC out parameters, what side and how allocates that.
Last edited by Igor Vartanov; February 5th, 2011 at 02:40 PM.
Bookmarks