Sync to Wine-20050930:
Robert Shearman <rob@codeweavers.com>
- Implement most of the details around unmarshalling of an object
  pointer.
- Fix allocation scheme in NdrConformantArrayUnmarshal to allocate if
  *ppMemory is NULL, like complex struct and user type unmarshalling.
- Fix ref-counting rules to match native DCOM Dlls.
Alexandre Julliard <julliard@winehq.org>
- Use a more portable scheme for storing the name of a critical
  section.
- We are no longer generating .dbg.c files.
Mike McCormack <mike@codeweavers.com>
- Fix gcc 4.0 warnings.
Modified: trunk/reactos/lib/rpcrt4/cproxy.c
Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c
Modified: trunk/reactos/lib/rpcrt4/ndr_ole.c
Modified: trunk/reactos/lib/rpcrt4/rpc_binding.c
Modified: trunk/reactos/lib/rpcrt4/rpc_server.c
Modified: trunk/reactos/lib/rpcrt4/rpcrt4.rc
Modified: trunk/reactos/lib/rpcrt4/rpcrt4_main.c

Modified: trunk/reactos/lib/rpcrt4/cproxy.c
--- trunk/reactos/lib/rpcrt4/cproxy.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/cproxy.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -176,8 +176,8 @@
     This->PVtbl = vtbl->Vtbl;
 
   This->lpVtbl = &StdProxy_Vtbl;
-  /* 1 reference for the proxy and 1 for the object */
-  This->RefCount = 2;
+  /* one reference for the proxy */
+  This->RefCount = 1;
   This->stubless = stubless;
   This->piid = vtbl->header.piid;
   This->pUnkOuter = pUnkOuter;
@@ -186,6 +186,7 @@
   This->pChannel = NULL;
   *ppProxy = (LPRPCPROXYBUFFER)&This->lpVtbl;
   *ppvObj = &This->PVtbl;
+  IUnknown_AddRef((IUnknown *)*ppvObj);
   IPSFactoryBuffer_AddRef(pPSFactory);
 
   return S_OK;

Modified: trunk/reactos/lib/rpcrt4/ndr_marshall.c
--- trunk/reactos/lib/rpcrt4/ndr_marshall.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/ndr_marshall.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -738,6 +738,11 @@
     pStubMsg->Buffer += 4;
     break;
   case RPC_FC_OP: /* object pointer - we must free data before overwriting it */
+    pointer_id = NDR_LOCAL_UINT32_READ(pStubMsg->Buffer);
+    pStubMsg->Buffer += 4;
+    if (*pPointer)
+        FIXME("free object pointer %p\n", *pPointer);
+    break;
   case RPC_FC_FP:
   default:
     FIXME("unhandled ptr type=%02x\n", type);
@@ -1865,19 +1870,11 @@
   pFormat = ReadConformance(pStubMsg, pFormat+4);
   size = pStubMsg->MaxCount;
 
-  if (fMustAlloc) {
+  if (fMustAlloc || !*ppMemory)
     *ppMemory = NdrAllocate(pStubMsg, size*esize);
-    memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
-  } else {
-    if (pStubMsg->ReuseBuffer && !*ppMemory)
-      /* for servers, we may just point straight into the RPC buffer, I think
-       * (I guess that's what MS does since MIDL code doesn't try to free) */
-      *ppMemory = pStubMsg->Buffer;
-    else
-      /* for clients, memory should be provided by caller */
-      memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
-  }
 
+  memcpy(*ppMemory, pStubMsg->Buffer, size*esize);
+
   pStubMsg->BufferMark = pStubMsg->Buffer;
   pStubMsg->Buffer += size*esize;
 

Modified: trunk/reactos/lib/rpcrt4/ndr_ole.c
--- trunk/reactos/lib/rpcrt4/ndr_ole.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/ndr_ole.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -113,7 +113,7 @@
   RpcStreamImpl *This = (RpcStreamImpl *)iface;
   if (!--(This->RefCount)) {
     TRACE("size=%ld\n", *This->size);
-    This->pMsg->Buffer = This->data + *This->size;
+    This->pMsg->Buffer = (unsigned char*)This->data + *This->size;
     HeapFree(GetProcessHeap(),0,This);
     return 0;
   }

Modified: trunk/reactos/lib/rpcrt4/rpc_binding.c
--- trunk/reactos/lib/rpcrt4/rpc_binding.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/rpc_binding.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -604,39 +604,39 @@
   LPSTR data;
 
   TRACE( "(%s,%s,%s,%s,%s,%p)\n",
-        debugstr_a( ObjUuid ), debugstr_a( Protseq ),
-        debugstr_a( NetworkAddr ), debugstr_a( Endpoint ),
-        debugstr_a( Options ), StringBinding );
+        debugstr_a( (char*)ObjUuid ), debugstr_a( (char*)Protseq ),
+        debugstr_a( (char*)NetworkAddr ), debugstr_a( (char*)Endpoint ),
+        debugstr_a( (char*)Options ), StringBinding );
 
-  if (ObjUuid && *ObjUuid) len += strlen(ObjUuid) + 1;
-  if (Protseq && *Protseq) len += strlen(Protseq) + 1;
-  if (NetworkAddr && *NetworkAddr) len += strlen(NetworkAddr);
-  if (Endpoint && *Endpoint) len += strlen(Endpoint) + 2;
-  if (Options && *Options) len += strlen(Options) + 2;
+  if (ObjUuid && *ObjUuid) len += strlen((char*)ObjUuid) + 1;
+  if (Protseq && *Protseq) len += strlen((char*)Protseq) + 1;
+  if (NetworkAddr && *NetworkAddr) len += strlen((char*)NetworkAddr);
+  if (Endpoint && *Endpoint) len += strlen((char*)Endpoint) + 2;
+  if (Options && *Options) len += strlen((char*)Options) + 2;
 
   data = HeapAlloc(GetProcessHeap(), 0, len);
-  *StringBinding = data;
+  *StringBinding = (unsigned char*)data;
 
   if (ObjUuid && *ObjUuid) {
-    data += RPCRT4_strcopyA(data, ObjUuid);
+    data += RPCRT4_strcopyA(data, (char*)ObjUuid);
     *data++ = '@';
   }
   if (Protseq && *Protseq) {
-    data += RPCRT4_strcopyA(data, Protseq);
+    data += RPCRT4_strcopyA(data, (char*)Protseq);
     *data++ = ':';
   }
   if (NetworkAddr && *NetworkAddr)
-    data += RPCRT4_strcopyA(data, NetworkAddr);
+    data += RPCRT4_strcopyA(data, (char*)NetworkAddr);
 
   if ((Endpoint && *Endpoint) ||
       (Options && *Options)) {
     *data++ = '[';
     if (Endpoint && *Endpoint) {
-      data += RPCRT4_strcopyA(data, Endpoint);
+      data += RPCRT4_strcopyA(data, (char*)Endpoint);
       if (Options && *Options) *data++ = ',';
     }
     if (Options && *Options) {
-      data += RPCRT4_strcopyA(data, Options);
+      data += RPCRT4_strcopyA(data, (char*)Options);
     }
     *data++ = ']';
   }
@@ -708,7 +708,7 @@
   CHAR *data, *next;
   static const char ep_opt[] = "endpoint=";
 
-  TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_a(StringBinding),
+  TRACE("(%s,%p,%p,%p,%p,%p)\n", debugstr_a((char*)StringBinding),
        ObjUuid, Protseq, NetworkAddr, Endpoint, Options);
 
   if (ObjUuid) *ObjUuid = NULL;
@@ -717,17 +717,17 @@
   if (Endpoint) *Endpoint = NULL;
   if (Options) *Options = NULL;
 
-  data = StringBinding;
+  data = (char*) StringBinding;
 
   next = strchr(data, '@');
   if (next) {
-    if (ObjUuid) *ObjUuid = RPCRT4_strndupA(data, next - data);
+    if (ObjUuid) *ObjUuid = (unsigned char*)RPCRT4_strndupA(data, next - data);
     data = next+1;
   }
 
   next = strchr(data, ':');
   if (next) {
-    if (Protseq) *Protseq = RPCRT4_strndupA(data, next - data);
+    if (Protseq) *Protseq = (unsigned char*)RPCRT4_strndupA(data, next - data);
     data = next+1;
   }
 
@@ -735,7 +735,7 @@
   if (next) {
     CHAR *close, *opt;
 
-    if (NetworkAddr) *NetworkAddr = RPCRT4_strndupA(data, next - data);
+    if (NetworkAddr) *NetworkAddr = (unsigned char*)RPCRT4_strndupA(data, next - data);
     data = next+1;
     close = strchr(data, ']');
     if (!close) goto fail;
@@ -753,21 +753,21 @@
       if (!next) {
         /* not an option, must be an endpoint */
         if (*Endpoint) goto fail;
-        *Endpoint = opt;
+        *Endpoint = (unsigned char*) opt;
       } else {
         if (strncmp(opt, ep_opt, strlen(ep_opt)) == 0) {
           /* endpoint option */
           if (*Endpoint) goto fail;
-          *Endpoint = RPCRT4_strdupA(next+1);
+          *Endpoint = (unsigned char*) RPCRT4_strdupA(next+1);
           HeapFree(GetProcessHeap(), 0, opt);
         } else {
           /* network option */
           if (*Options) {
             /* FIXME: this is kind of inefficient */
-            *Options = RPCRT4_strconcatA(*Options, opt);
+            *Options = (unsigned char*) RPCRT4_strconcatA( (char*)*Options, opt);
             HeapFree(GetProcessHeap(), 0, opt);
           } else 
-	    *Options = opt;
+	    *Options = (unsigned char*) opt;
         }
       }
     }
@@ -776,7 +776,7 @@
     if (*data) goto fail;
   }
   else if (NetworkAddr) 
-    *NetworkAddr = RPCRT4_strdupA(data);
+    *NetworkAddr = (unsigned char*)RPCRT4_strdupA(data);
 
   return RPC_S_OK;
 
@@ -942,7 +942,7 @@
   unsigned char *ObjectUuid, *Protseq, *NetworkAddr, *Endpoint, *Options;
   UUID Uuid;
 
-  TRACE("(%s,%p)\n", debugstr_a(StringBinding), Binding);
+  TRACE("(%s,%p)\n", debugstr_a((char*)StringBinding), Binding);
 
   ret = RpcStringBindingParseA(StringBinding, &ObjectUuid, &Protseq,
                               &NetworkAddr, &Endpoint, &Options);
@@ -951,11 +951,11 @@
   ret = UuidFromStringA(ObjectUuid, &Uuid);
 
   if (ret == RPC_S_OK)
-    ret = RPCRT4_CreateBindingA(&bind, FALSE, Protseq);
+    ret = RPCRT4_CreateBindingA(&bind, FALSE, (char*)Protseq);
   if (ret == RPC_S_OK)
     ret = RPCRT4_SetBindingObject(bind, &Uuid);
   if (ret == RPC_S_OK)
-    ret = RPCRT4_CompleteBindingA(bind, NetworkAddr, Endpoint, Options);
+    ret = RPCRT4_CompleteBindingA(bind, (char*)NetworkAddr, (char*)Endpoint, (char*)Options);
 
   RpcStringFreeA((unsigned char**)&Options);
   RpcStringFreeA((unsigned char**)&Endpoint);
@@ -1024,8 +1024,8 @@
   ret = UuidToStringA(&bind->ObjectUuid, (unsigned char**)&ObjectUuid);
   if (ret != RPC_S_OK) return ret;
 
-  ret = RpcStringBindingComposeA(ObjectUuid, bind->Protseq, bind->NetworkAddr,
-                                 bind->Endpoint, NULL, StringBinding);
+  ret = RpcStringBindingComposeA((unsigned char*) ObjectUuid, (unsigned char*)bind->Protseq, (unsigned char*) bind->NetworkAddr,
+                                 (unsigned char*) bind->Endpoint, NULL, StringBinding);
 
   RpcStringFreeA((unsigned char**)&ObjectUuid);
 
@@ -1041,7 +1041,7 @@
   unsigned char *str = NULL;
   TRACE("(%p,%p)\n", Binding, StringBinding);
   ret = RpcBindingToStringBindingA(Binding, &str);
-  *StringBinding = RPCRT4_strdupAtoW(str);
+  *StringBinding = RPCRT4_strdupAtoW((char*)str);
   RpcStringFreeA((unsigned char**)&str);
   return ret;
 }
@@ -1071,7 +1071,7 @@
 
   if (!protseq) return RPC_S_INVALID_RPC_PROTSEQ; /* ? */
   
-  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, protseq)) {
+  if (RtlCreateUnicodeStringFromAsciiz(&protseqW, (char*)protseq)) {
     RPC_STATUS ret = RpcNetworkIsProtseqValidW(protseqW.Buffer);
     RtlFreeUnicodeString(&protseqW);
     return ret;

Modified: trunk/reactos/lib/rpcrt4/rpc_server.c
--- trunk/reactos/lib/rpcrt4/rpc_server.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/rpc_server.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -78,7 +78,7 @@
 {
     0, 0, &server_cs,
     { &server_cs_debug.ProcessLocksList, &server_cs_debug.ProcessLocksList },
-      0, 0, { 0, (DWORD)(__FILE__ ": server_cs") }
+      0, 0, { (DWORD_PTR)(__FILE__ ": server_cs") }
 };
 static CRITICAL_SECTION server_cs = { &server_cs_debug, -1, 0, 0, 0, 0 };
 
@@ -87,7 +87,7 @@
 {
     0, 0, &listen_cs,
     { &listen_cs_debug.ProcessLocksList, &listen_cs_debug.ProcessLocksList },
-      0, 0, { 0, (DWORD)(__FILE__ ": listen_cs") }
+      0, 0, { (DWORD_PTR)(__FILE__ ": listen_cs") }
 };
 static CRITICAL_SECTION listen_cs = { &listen_cs_debug, -1, 0, 0, 0, 0 };
 
@@ -109,7 +109,7 @@
 {
     0, 0, &spacket_cs,
     { &spacket_cs_debug.ProcessLocksList, &spacket_cs_debug.ProcessLocksList },
-      0, 0, { 0, (DWORD)(__FILE__ ": spacket_cs") }
+      0, 0, { (DWORD_PTR)(__FILE__ ": spacket_cs") }
 };
 static CRITICAL_SECTION spacket_cs = { &spacket_cs_debug, -1, 0, 0, 0, 0 };
 

Modified: trunk/reactos/lib/rpcrt4/rpcrt4.rc
--- trunk/reactos/lib/rpcrt4/rpcrt4.rc	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/rpcrt4.rc	2005-10-08 17:26:40 UTC (rev 18347)
@@ -1,7 +1,7 @@
-#include <windows.h>
-
-#define REACTOS_VERSION_DLL
-#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS RPC server API\0"
-#define REACTOS_STR_INTERNAL_NAME	"rpcrt4\0"
-#define REACTOS_STR_ORIGINAL_FILENAME	"rpcrt4.dll\0"
-#include <reactos/version.rc>
+#include <windows.h>
+
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION	"ReactOS RPC server API\0"
+#define REACTOS_STR_INTERNAL_NAME	"rpcrt4\0"
+#define REACTOS_STR_ORIGINAL_FILENAME	"rpcrt4.dll\0"
+#include <reactos/version.rc>
Property changes on: trunk/reactos/lib/rpcrt4/rpcrt4.rc
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/reactos/lib/rpcrt4/rpcrt4_main.c
--- trunk/reactos/lib/rpcrt4/rpcrt4_main.c	2005-10-08 17:25:32 UTC (rev 18346)
+++ trunk/reactos/lib/rpcrt4/rpcrt4_main.c	2005-10-08 17:26:40 UTC (rev 18347)
@@ -129,7 +129,7 @@
 {
     0, 0, &uuid_cs,
     { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
-      0, 0, { 0, (DWORD)(__FILE__ ": uuid_cs") }
+      0, 0, { (DWORD_PTR)(__FILE__ ": uuid_cs") }
 };
 static CRITICAL_SECTION uuid_cs = { &critsect_debug, -1, 0, 0, 0, 0 };