1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright <c> 1993 Microsoft Corporation
Module Name :
ndrp.h
Abtract :
Contains private definitions for Ndr files in this directory. This
file is included by all source files in this directory.
Author :
David Kays dkays October 1993
Revision History :
--------------------------------------------------------------------*/
#ifndef _NDRP_
#define _NDRP_
#include <sysinc.h>
#if defined(_MPPC_)
#ifndef RPC_NO_WINDOWS_H
#include <windows.h>
#endif // RPC_NO_WINDOWS_H
#endif
#include "rpc.h"
#include "rpcndr.h"
#include "ndrtypes.h"
#if defined(WIN32) || defined(_MPPC_)
// NT and Chicago and PowerMac but not 16bit nor Mac.
#define NDR_SERVER_SUPPORT 1
#endif
#if defined(_MPPC_)
#define _int64 double
#endif
//
// The MIDL version is contained in the stub descriptor starting with
// MIDL version 2.00.96 (pre NT 3.51 Beta 2, 2/95) and can be used for a finer
// granularity of compatability checking. The MIDL version was zero before
// MIDL version 2.00.96. The MIDL version number is converted into
// an integer long using the following expression :
// ((Major << 24) | (Minor << 16) | Revision)
//
#define MIDL_NT_3_51 ((2UL << 24) | (0UL << 16) | 102UL)
#define MIDL_VERSION_3_0_39 ((3UL << 24) | (0UL << 16) | 39UL)
// Shortcut typedefs.
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned int uint;
#include "mrshlp.h"
#include "unmrshlp.h"
#include "bufsizep.h"
#include "memsizep.h"
#include "freep.h"
#include "endianp.h"
#include "fullptr.h"
#ifdef NEWNDR_INTERNAL
#include <assert.h>
#include <stdio.h>
#define NDR_ASSERT( Expr, S ) assert( (Expr) || ! (S) )
#else
#define NDR_ASSERT( Expr, S ) ASSERT( (Expr) || ! (S) )
#endif
uchar *
NdrpMemoryIncrement(
PMIDL_STUB_MESSAGE pStubMsg,
uchar * pMemory,
PFORMAT_STRING pFormat
);
long
NdrpArrayDimensions(
PFORMAT_STRING pFormat,
BOOL fIgnoreStringArrays
);
long
NdrpArrayElements(
PMIDL_STUB_MESSAGE pStubMsg,
uchar * pMemory,
PFORMAT_STRING pFormat
);
void
NdrpArrayVariance(
PMIDL_STUB_MESSAGE pStubMsg,
uchar * pMemory,
PFORMAT_STRING pFormat,
long * pOffset,
long * pLength
);
PFORMAT_STRING
NdrpSkipPointerLayout(
PFORMAT_STRING pFormat
);
long
NdrpStringStructLen(
uchar * pMemory,
long ElementSize
);
void
NdrpCheckBound(
ulong Bound,
int Type
);
#define CHECK_BOUND( Bound, Type ) NdrpCheckBound( Bound, (int)(Type) )
#define NdrpComputeSwitchIs( pStubMsg, pMemory, pFormat ) \
NdrpComputeConformance( pStubMsg, \
pMemory, \
pFormat )
#define NdrpComputeIIDPointer( pStubMsg, pMemory, pFormat ) \
NdrpComputeConformance( pStubMsg, \
pMemory, \
pFormat )
//
// Defined in global.c
//
extern const unsigned char SimpleTypeAlignment[];
extern const unsigned char SimpleTypeBufferSize[];
extern const unsigned char SimpleTypeMemorySize[];
extern const unsigned long NdrTypeFlags[];
#define PTR_MEM_SIZE sizeof( void * )
#define IGNORED(Param)
//
// Proc info flags macros.
//
#define IS_OLE_INTERFACE(Flags) ((Flags) & Oi_OBJECT_PROC)
#define HAS_RPCFLAGS(Flags) ((Flags) & Oi_HAS_RPCFLAGS)
#define DONT_HANDLE_EXCEPTION(Flags) \
((Flags) & Oi_IGNORE_OBJECT_EXCEPTION_HANDLING)
//
// Alignment macros.
//
#define ALIGN( pStuff, cAlign ) \
pStuff = (uchar *)((ulong)((pStuff) + (cAlign)) & ~ (cAlign))
#define LENGTH_ALIGN( Length, cAlign ) \
Length = (((Length) + (cAlign)) & ~ (cAlign))
//
// Routine index macro.
//
#define ROUTINE_INDEX(FC) ((FC) & 0x7f)
//
// Simple type alignment and size lookup macros.
//
#define SIMPLE_TYPE_ALIGNMENT(FormatChar) SimpleTypeAlignment[FormatChar]
#define SIMPLE_TYPE_BUFSIZE(FormatChar) SimpleTypeBufferSize[FormatChar]
#define SIMPLE_TYPE_MEMSIZE(FormatChar) SimpleTypeMemorySize[FormatChar]
//
// Format character attribute bits used in global NdrTypesFlags defined in
// global.c.
//
#define _SIMPLE_TYPE_ 0x0001L
#define _POINTER_ 0x0002L
#define _STRUCT_ 0x0004L
#define _ARRAY_ 0x0008L
#define _STRING_ 0x0010L
#define _UNION_ 0x0020L
#define _XMIT_AS_ 0x0040L
#define _BY_VALUE_ 0x0080L
#define _HANDLE_ 0x0100L
#define _BASIC_POINTER_ 0x0200L
//
// Format character query macros.
//
#define IS_SIMPLE_TYPE(FC) (NdrTypeFlags[(FC)] & _SIMPLE_TYPE_)
#define IS_POINTER_TYPE(FC) (NdrTypeFlags[(FC)] & _POINTER_)
#define IS_BASIC_POINTER(FC) (NdrTypeFlags[(FC)] & _BASIC_POINTER_)
#define IS_ARRAY(FC) (NdrTypeFlags[(FC)] & _ARRAY_)
#define IS_STRUCT(FC) (NdrTypeFlags[(FC)] & _STRUCT_)
#define IS_UNION(FC) (NdrTypeFlags[(FC)] & _UNION_)
#define IS_STRING(FC) (NdrTypeFlags[(FC)] & _STRING_)
#define IS_ARRAY_OR_STRING(FC) (NdrTypeFlags[(FC)] & (_STRING_ | _ARRAY_))
#define IS_XMIT_AS(FC) (NdrTypeFlags[(FC)] & _XMIT_AS_)
#define IS_BY_VALUE(FC) (NdrTypeFlags[(FC)] & _BY_VALUE_)
#define IS_HANDLE(FC) (NdrTypeFlags[(FC)] & _HANDLE_)
//
// Pointer attribute extraction and querying macros.
//
#define ALLOCATE_ALL_NODES( FC ) ((FC) & FC_ALLOCATE_ALL_NODES)
#define DONT_FREE( FC ) ((FC) & FC_DONT_FREE)
#define ALLOCED_ON_STACK( FC ) ((FC) & FC_ALLOCED_ON_STACK)
#define SIMPLE_POINTER( FC ) ((FC) & FC_SIMPLE_POINTER)
#define POINTER_DEREF( FC ) ((FC) & FC_POINTER_DEREF)
//
// Handle query macros.
//
#define IS_HANDLE_PTR( FC ) ((FC) & HANDLE_PARAM_IS_VIA_PTR)
#define IS_HANDLE_IN( FC ) ((FC) & HANDLE_PARAM_IS_IN)
#define IS_HANDLE_OUT( FC ) ((FC) & HANDLE_PARAM_IS_OUT)
#define IS_HANDLE_RETURN( FC ) ((FC) & HANDLE_PARAM_IS_RETURN)
//
// Union hack helper. (used to be MAGIC_UNION_BYTE 0x80)
//
#define IS_MAGIC_UNION_BYTE(pFmt) \
((*(unsigned short *)pFmt & (unsigned short)0xff00) == MAGIC_UNION_SHORT)
// User marshal marker on wire.
#define USER_MARSHAL_MARKER 0x72657355
//
// Environment dependent macros
//
#if !defined(__RPC_DOS__) && !defined(__RPC_WIN16__) && !defined(__RPC_MAC__)
#define SIMPLE_TYPE_BUF_INCREMENT(Len, FC) Len += 16
#define EXCEPTION_FLAG \
( (!(RpcFlags & RPCFLG_ASYNCHRONOUS)) && \
(!InterpreterFlags.IgnoreObjectException) && \
(StubMsg.dwStubPhase != PROXY_SENDRECEIVE) )
#else
#define SIMPLE_TYPE_BUF_INCREMENT(Len, FC) \
LENGTH_ALIGN(Len, SIMPLE_TYPE_ALIGNMENT(FC)); \
Len += SIMPLE_TYPE_BUFSIZE(FC)
#ifndef TRUE
#define TRUE (1)
#define FALSE (0)
typedef unsigned short BOOL;
#endif
#define EXCEPTION_FLAG 1
#if ! defined( UNALIGNED )
#define UNALIGNED
#endif
#endif
#endif
|