Support marshalling of 'unique' strings. Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c _____
Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c --- trunk/reactos/lib/rpcrt4/ndr_marshall.c 2005-04-03 19:06:49 UTC (rev 14481) +++ trunk/reactos/lib/rpcrt4/ndr_marshall.c 2005-04-03 19:15:14 UTC (rev 14482) @@ -388,8 +388,13 @@
TRACE("(pStubMsg == ^%p, pszMessage == ^%p, pFormat == ^%p)\n", pStubMsg, pszMessage, pFormat);
assert(pFormat); - if (*pFormat == RPC_FC_C_CSTRING) { + if (pszMessage == NULL) { TRACE("string=%s\n", debugstr_a(pszMessage)); + len = 0; + esize = 0; + } + else if (*pFormat == RPC_FC_C_CSTRING) { + TRACE("string=%s\n", debugstr_a(pszMessage)); len = strlen(pszMessage)+1; esize = 1; } @@ -416,8 +421,10 @@ c += 8; /* offset: 0 */ NDR_LOCAL_UINT32_WRITE(c, len); /* actual length: (same) */ c += 4; - memcpy(c, pszMessage, len*esize); /* the string itself */ - c += len*esize; + if (len != 0) { + memcpy(c, pszMessage, len*esize); /* the string itself */ + c += len*esize; + } pStubMsg->Buffer = c;
STD_OVERFLOW_CHECK(pStubMsg); @@ -435,7 +442,12 @@ TRACE("(pStubMsg == ^%p, pMemory == ^%p, pFormat == ^%p)\n", pStubMsg, pMemory, pFormat);
assert(pFormat); - if (*pFormat == RPC_FC_C_CSTRING) { + if (pMemory == NULL) { + /* we need 12 octets for the [maxlen, offset, len] DWORDS */ + TRACE("string=NULL\n"); + pStubMsg->BufferLength += 12 + BUFFER_PARANOIA; + } + else if (*pFormat == RPC_FC_C_CSTRING) { /* we need 12 octets for the [maxlen, offset, len] DWORDS, + 1 octet for '\0' */ TRACE("string=%s\n", debugstr_a(pMemory)); pStubMsg->BufferLength += strlen(pMemory) + 13 + BUFFER_PARANOIA; @@ -528,6 +540,11 @@ /* for clients, memory should be provided by caller */ }
+ if (len == 0) { + *ppMemory = NULL; + return NULL; + } + pMem = *ppMemory + ofs*esize;
if (pMem != pStubMsg->Buffer) @@ -572,6 +589,8 @@ switch (type) { case RPC_FC_RP: /* ref pointer (always non-null) */ break; + case RPC_FC_UP: /* unique pointer */ + break; default: FIXME("unhandled ptr type=%02x\n", type); } @@ -609,6 +628,8 @@ switch (type) { case RPC_FC_RP: /* ref pointer (always non-null) */ break; + case RPC_FC_UP: /* unique pointer */ + break; default: FIXME("unhandled ptr type=%02x\n", type); } @@ -645,6 +666,8 @@ switch (type) { case RPC_FC_RP: /* ref pointer (always non-null) */ break; + case RPC_FC_UP: /* unique pointer */ + break; default: FIXME("unhandled ptr type=%02x\n", type); }