server: Add the logon SID to the default admin token's groups.
[wine/gsoc_dplay.git] / dlls / rpcrt4 / ndr_clientserver.c
blobfe424a63cc0a97e535867f44a42b96ac632240f5
1 /*
2 * MIDL proxy/stub stuff
4 * Copyright 2002 Ove Kåven, TransGaming Technologies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * TODO:
21 * - figure out whether we *really* got this right
22 * - check for errors and throw exceptions
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <string.h>
28 #include <assert.h>
30 #define COBJMACROS
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
36 #include "objbase.h"
38 #include "rpcproxy.h"
40 #include "wine/debug.h"
42 #include "ndr_misc.h"
43 #include "rpcndr.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
47 /************************************************************************
48 * NdrClientInitializeNew [RPCRT4.@]
50 void WINAPI NdrClientInitializeNew( PRPC_MESSAGE pRpcMessage, PMIDL_STUB_MESSAGE pStubMsg,
51 PMIDL_STUB_DESC pStubDesc, unsigned int ProcNum )
53 TRACE("(pRpcMessage == ^%p, pStubMsg == ^%p, pStubDesc == ^%p, ProcNum == %d)\n",
54 pRpcMessage, pStubMsg, pStubDesc, ProcNum);
56 assert( pRpcMessage && pStubMsg && pStubDesc );
58 pRpcMessage->Handle = NULL;
59 pRpcMessage->ProcNum = ProcNum;
60 pRpcMessage->RpcInterfaceInformation = pStubDesc->RpcInterfaceInformation;
61 pRpcMessage->RpcFlags = 0;
62 pRpcMessage->DataRepresentation = NDR_LOCAL_DATA_REPRESENTATION;
64 pStubMsg->RpcMsg = pRpcMessage;
65 pStubMsg->BufferStart = NULL;
66 pStubMsg->BufferEnd = NULL;
67 pStubMsg->BufferLength = 0;
68 pStubMsg->IsClient = TRUE;
69 pStubMsg->ReuseBuffer = FALSE;
70 pStubMsg->pAllocAllNodesContext = NULL;
71 pStubMsg->pPointerQueueState = NULL;
72 pStubMsg->IgnoreEmbeddedPointers = 0;
73 pStubMsg->PointerBufferMark = NULL;
74 pStubMsg->fBufferValid = 0;
75 pStubMsg->uFlags = 0;
76 pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
77 pStubMsg->pfnFree = pStubDesc->pfnFree;
78 pStubMsg->StackTop = NULL;
79 pStubMsg->StubDesc = pStubDesc;
80 pStubMsg->FullPtrRefId = 0;
81 pStubMsg->PointerLength = 0;
82 pStubMsg->fInDontFree = 0;
83 pStubMsg->fDontCallFreeInst = 0;
84 pStubMsg->fInOnlyParam = 0;
85 pStubMsg->fHasReturn = 0;
86 pStubMsg->fHasExtensions = 0;
87 pStubMsg->fHasNewCorrDesc = 0;
88 pStubMsg->fUnused = 0;
89 pStubMsg->dwDestContext = MSHCTX_DIFFERENTMACHINE;
90 pStubMsg->pvDestContext = NULL;
91 pStubMsg->pRpcChannelBuffer = NULL;
92 pStubMsg->pArrayInfo = NULL;
93 pStubMsg->dwStubPhase = 0;
94 /* FIXME: LowStackMark */
95 pStubMsg->pAsyncMsg = NULL;
96 pStubMsg->pCorrInfo = NULL;
97 pStubMsg->pCorrMemory = NULL;
98 pStubMsg->pMemoryList = NULL;
101 /***********************************************************************
102 * NdrServerInitializeNew [RPCRT4.@]
104 unsigned char* WINAPI NdrServerInitializeNew( PRPC_MESSAGE pRpcMsg, PMIDL_STUB_MESSAGE pStubMsg,
105 PMIDL_STUB_DESC pStubDesc )
107 TRACE("(pRpcMsg == ^%p, pStubMsg == ^%p, pStubDesc == ^%p)\n", pRpcMsg, pStubMsg, pStubDesc);
109 assert( pRpcMsg && pStubMsg && pStubDesc );
111 /* not everyone allocates stack space for w2kReserved */
112 memset(pStubMsg, 0, FIELD_OFFSET(MIDL_STUB_MESSAGE,pCSInfo));
114 pStubMsg->ReuseBuffer = TRUE;
115 pStubMsg->IsClient = FALSE;
116 pStubMsg->StubDesc = pStubDesc;
117 pStubMsg->pfnAllocate = pStubDesc->pfnAllocate;
118 pStubMsg->pfnFree = pStubDesc->pfnFree;
119 pStubMsg->RpcMsg = pRpcMsg;
120 pStubMsg->Buffer = pStubMsg->BufferStart = pRpcMsg->Buffer;
121 pStubMsg->BufferLength = pRpcMsg->BufferLength;
122 pStubMsg->BufferEnd = pStubMsg->Buffer + pStubMsg->BufferLength;
124 /* FIXME: determine the proper return value */
125 return NULL;
128 /***********************************************************************
129 * NdrGetBuffer [RPCRT4.@]
131 unsigned char *WINAPI NdrGetBuffer(PMIDL_STUB_MESSAGE stubmsg, ULONG buflen, RPC_BINDING_HANDLE handle)
133 TRACE("(stubmsg == ^%p, buflen == %u, handle == %p): wild guess.\n", stubmsg, buflen, handle);
135 assert( stubmsg && stubmsg->RpcMsg );
137 /* I guess this is our chance to put the binding handle into the RPC_MESSAGE */
138 stubmsg->RpcMsg->Handle = handle;
140 stubmsg->RpcMsg->BufferLength = buflen;
141 if (I_RpcGetBuffer(stubmsg->RpcMsg) != S_OK)
142 return NULL;
144 stubmsg->Buffer = stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
145 stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
146 stubmsg->BufferEnd = stubmsg->Buffer + stubmsg->BufferLength;
147 return (stubmsg->Buffer = (unsigned char *)stubmsg->RpcMsg->Buffer);
149 /***********************************************************************
150 * NdrFreeBuffer [RPCRT4.@]
152 void WINAPI NdrFreeBuffer(PMIDL_STUB_MESSAGE pStubMsg)
154 TRACE("(pStubMsg == ^%p): wild guess.\n", pStubMsg);
155 I_RpcFreeBuffer(pStubMsg->RpcMsg);
156 pStubMsg->BufferLength = 0;
157 pStubMsg->Buffer = pStubMsg->BufferEnd = (unsigned char *)(pStubMsg->RpcMsg->Buffer = NULL);
160 /************************************************************************
161 * NdrSendReceive [RPCRT4.@]
163 unsigned char *WINAPI NdrSendReceive( PMIDL_STUB_MESSAGE stubmsg, unsigned char *buffer )
165 RPC_STATUS status;
167 TRACE("(stubmsg == ^%p, buffer == ^%p)\n", stubmsg, buffer);
169 /* FIXME: how to handle errors? (raise exception?) */
170 if (!stubmsg) {
171 ERR("NULL stub message. No action taken.\n");
172 return NULL;
174 if (!stubmsg->RpcMsg) {
175 ERR("RPC Message not present in stub message. No action taken.\n");
176 return NULL;
179 stubmsg->RpcMsg->BufferLength = buffer - (unsigned char *)stubmsg->RpcMsg->Buffer;
180 status = I_RpcSendReceive(stubmsg->RpcMsg);
181 if (status != RPC_S_OK)
182 RpcRaiseException(status);
184 stubmsg->BufferLength = stubmsg->RpcMsg->BufferLength;
185 stubmsg->BufferStart = stubmsg->RpcMsg->Buffer;
186 stubmsg->BufferEnd = stubmsg->BufferStart + stubmsg->BufferLength;
187 stubmsg->Buffer = stubmsg->BufferStart;
189 /* FIXME: is this the right return value? */
190 return NULL;
193 /************************************************************************
194 * NdrMapCommAndFaultStatus [RPCRT4.@]
196 RPC_STATUS RPC_ENTRY NdrMapCommAndFaultStatus( PMIDL_STUB_MESSAGE pStubMsg,
197 ULONG *pCommStatus,
198 ULONG *pFaultStatus,
199 RPC_STATUS Status )
201 FIXME("(%p, %p, %p, %ld): stub\n", pStubMsg, pCommStatus, pFaultStatus, Status);
203 *pCommStatus = 0;
204 *pFaultStatus = 0;
206 return RPC_S_OK;