4 Copyright (C) Stefan Metzmacher 2008
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "midltests.h"
25 #define MIN(a,b) ((a)<(b)?(a):(b))
26 static void print_asc(const unsigned char *buf
,int len
)
30 printf("%c", isprint(buf
[i
])?buf
[i
]:'.');
33 static void dump_data(const unsigned char *buf1
,int len
)
35 const unsigned char *buf
= (const unsigned char *)buf1
;
41 printf("%02X ",(int)buf
[i
]);
43 if (i
%8 == 0) printf(" ");
45 print_asc(&buf
[i
-16],8); printf(" ");
46 print_asc(&buf
[i
-8],8); printf("\n");
47 if (i
<len
) printf("[%03X] ",i
);
55 while (n
--) printf(" ");
57 print_asc(&buf
[i
-(i
%16)],n
); printf( " " );
59 if (n
>0) print_asc(&buf
[i
-n
],n
);
64 void NdrGetBufferMarshall(PMIDL_STUB_MESSAGE stubmsg
, unsigned long len
, RPC_BINDING_HANDLE hnd
)
66 stubmsg
->RpcMsg
->Buffer
= HeapAlloc(GetProcessHeap(), 0, len
);
67 memset(stubmsg
->RpcMsg
->Buffer
, 0xef, len
);
68 stubmsg
->RpcMsg
->BufferLength
= len
;
69 stubmsg
->Buffer
= stubmsg
->RpcMsg
->Buffer
;
70 stubmsg
->BufferLength
= stubmsg
->RpcMsg
->BufferLength
;
71 stubmsg
->fBufferValid
= TRUE
;
74 void __RPC_STUB
midltests_midltests_fn(PRPC_MESSAGE _pRpcMessage
);
76 void NdrSendReceiveMarshall(PMIDL_STUB_MESSAGE StubMsg
, unsigned char *buffer
)
78 unsigned long DataRepresentation
;
80 StubMsg
->RpcMsg
->BufferLength
= buffer
- (unsigned char *)StubMsg
->RpcMsg
->Buffer
;
82 printf("[in] Buffer[%d/%d]\n",
83 StubMsg
->RpcMsg
->BufferLength
, StubMsg
->BufferLength
);
84 dump_data(StubMsg
->RpcMsg
->Buffer
, StubMsg
->RpcMsg
->BufferLength
);
86 DataRepresentation
= StubMsg
->RpcMsg
->DataRepresentation
;
87 StubMsg
->RpcMsg
->DataRepresentation
= NDR_LOCAL_DATA_REPRESENTATION
;
88 midltests_midltests_fn(StubMsg
->RpcMsg
);
89 StubMsg
->RpcMsg
->DataRepresentation
= DataRepresentation
;
91 StubMsg
->BufferLength
= StubMsg
->RpcMsg
->BufferLength
;
92 StubMsg
->BufferStart
= StubMsg
->RpcMsg
->Buffer
;
93 StubMsg
->BufferEnd
= StubMsg
->BufferStart
+ StubMsg
->BufferLength
;
94 StubMsg
->Buffer
= StubMsg
->BufferStart
;
96 printf("[out] Buffer[%d]\n",
97 StubMsg
->RpcMsg
->BufferLength
);
98 dump_data(StubMsg
->RpcMsg
->Buffer
, StubMsg
->RpcMsg
->BufferLength
);
101 void NdrServerInitializeNewMarshall(PRPC_MESSAGE pRpcMsg
,
102 PMIDL_STUB_MESSAGE pStubMsg
,
103 PMIDL_STUB_DESC pStubDesc
)
105 memset(pStubMsg
, 0, sizeof(*pStubMsg
));
106 pStubMsg
->RpcMsg
= pRpcMsg
;
107 pStubMsg
->Buffer
= pStubMsg
->BufferStart
= pRpcMsg
->Buffer
;
108 pStubMsg
->BufferEnd
= pStubMsg
->Buffer
+ pRpcMsg
->BufferLength
;
109 pStubMsg
->BufferLength
= pRpcMsg
->BufferLength
;
110 pStubMsg
->pfnAllocate
= pStubDesc
->pfnAllocate
;
111 pStubMsg
->pfnFree
= pStubDesc
->pfnFree
;
112 pStubMsg
->StubDesc
= pStubDesc
;
113 pStubMsg
->dwDestContext
= MSHCTX_DIFFERENTMACHINE
;
116 RPC_STATUS WINAPI
I_RpcGetBufferMarshall(PRPC_MESSAGE RpcMsg
)
118 RpcMsg
->Buffer
= HeapAlloc(GetProcessHeap(), 0, RpcMsg
->BufferLength
);
119 memset(RpcMsg
->Buffer
, 0xcd, RpcMsg
->BufferLength
);