1/*
2   OpenChange MAPI implementation.
3
4   Copyright (C) Julien Kerihuel 2007.
5
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.
10
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.
15
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/>.
18 */
19
20#include "idl_types.h"
21
22[
23  uuid("a4f1db00-ca47-1067-b31f-00dd010662da"),
24  pointer_default(unique),
25  endpoint("ncacn_np:[\\pipe\\lsass]","ncacn_np:[\\pipe\\protected_storage]","ncacn_ip_tcp:"),
26  version(0.82),
27  helpstring("Exchange 5.5 EMSMDB")
28] interface mapi
29{
30
31#include "mapitags_enum.h"
32#include "mapicodes_enum.h"
33
34	/*****************/
35	/* Function 0x00 */
36
37	typedef struct datablob {
38		uint8 *data;
39		uint8 length;
40	} DATA_BLOB;
41
42	typedef struct {
43		uint32 language;
44		uint32 method;
45	} input_locale;
46
47
48	MAPISTATUS EcDoConnect(
49 		[out]		    policy_handle	*handle,
50                [in,string]	    uint8		name[],
51		[in]		    uint32		unknown1[3],
52                [in]		    uint32		code_page,
53		[in]		    input_locale	input_locale,
54                [in]		    uint32		unknown2,
55                [in]		    uint16		unknown3,
56		[out]		    uint32		unknown4[3],
57                [out]		    uint16		*session_nb,
58                [out,unique,string] uint8		*org_group,
59                [out,unique,string] uint8		*user,
60                [out]		    uint16		store_version[3],
61		[in,out]       	    uint16		emsmdb_client_version[3],
62                [in,out]	    uint32		*alloc_space
63		);
64
65	/*****************/
66	/* Function 0x01 */
67	MAPISTATUS EcDoDisconnect(
68		[in,out]   policy_handle   *handle
69		);
70
71	/*****************/
72	/* Function 0x02 */
73
74	/*
75	  EcDoRpc opnums
76	*/
77
78	typedef [public, enum8bit, flag(NDR_PAHEX)] enum
79		{
80			MAPI_STORE	= 0x1,
81			MAPI_ADDRBOOK	= 0x2,
82			MAPI_FOLDER	= 0x3,
83			MAPI_ABCONT	= 0x4,
84			MAPI_MESSAGE	= 0x5,
85			MAPI_MAILUSER	= 0x6, /* Individual Recipient */
86			MAPI_ATTACH	= 0x7,
87			MAPI_DISTLIST	= 0x8,
88			MAPI_PROFSECT	= 0x9,
89			MAPI_STATUS	= 0xA,
90			MAPI_SESSION	= 0xB,
91			MAPI_FORMINFO	= 0xC
92		} MAPI_OBJTYPE;
93
94	typedef [public, v1_enum, flag(NDR_PAHEX)] enum
95		{
96			RightsNone		= 0x00000000,
97			RightsReadItems		= 0x00000001,
98			RightsCreateItems	= 0x00000002,
99			RightsEditOwn		= 0x00000008,
100			RightsDeleteOwn		= 0x00000010,
101			RightsEditAll		= 0x00000020,
102			RightsDeleteAll		= 0x00000040,
103			RightsCreateSubfolders	= 0x00000080,
104			RightsFolderOwner	= 0x00000100,
105			RightsFolderContact	= 0x00000200,
106			RoleNone		= 0x00000400,
107			RoleReviewer		= 0x00000401,
108			RoleContributor		= 0x00000402,
109			RoleNoneditingAuthor	= 0x00000413,
110			RoleAuthor		= 0x0000041B,
111			RoleEditor		= 0x0000047B,
112			RolePublishAuthor	= 0x0000049B,
113			RolePublishEditor	= 0x000004FB,
114			RightsAll		= 0x000005FB,
115			RoleOwner		= 0x000007FB
116	       	} ACLRIGHTS;
117
118	typedef [public, enum8bit, flag(NDR_PAHEX)] enum
119		{
120			op_MAPI_Release			= 0x1,
121			op_MAPI_OpenFolder		= 0x2,
122			op_MAPI_OpenMessage		= 0x3,
123			op_MAPI_GetHierarchyTable	= 0x4,
124			op_MAPI_GetContentsTable	= 0x5,
125			op_MAPI_CreateMessage		= 0x6,
126			op_MAPI_GetProps		= 0x7,
127			op_MAPI_GetPropsAll		= 0x8,
128			op_MAPI_GetPropList		= 0x9,
129			op_MAPI_SetProps		= 0xa,
130			op_MAPI_DeleteProps		= 0xb,
131			op_MAPI_SaveChangesMessage	= 0xc,
132			op_MAPI_ModifyRecipients	= 0xe,
133			op_MAPI_SetReadFlags		= 0x11,
134			op_MAPI_SetColumns		= 0x12,
135			op_MAPI_SortTable		= 0x13,
136			op_MAPI_Restrict		= 0x14,
137			op_MAPI_QueryRows		= 0x15,
138			op_MAPI_GetRowCount		= 0x17,
139			op_MAPI_SeekRow			= 0x18,
140			op_MAPI_SeekRowBookmark		= 0x19,
141			op_MAPI_SeekRowApprox		= 0x1a,
142			op_MAPI_CreateBookmark		= 0x1b,
143			op_MAPI_CreateFolder		= 0x1c,
144			op_MAPI_DeleteFolder		= 0x1d,
145			op_MAPI_DeleteMessages		= 0x1e,
146			op_MAPI_GetMessageStatus	= 0x1f,
147			op_MAPI_SetMessageStatus	= 0x20,
148			op_MAPI_GetAttachmentTable     	= 0x21,
149			op_MAPI_OpenAttach		= 0x22,
150			op_MAPI_CreateAttach		= 0x23,
151			op_MAPI_DeleteAttach		= 0x24,
152			op_MAPI_SaveChanges		= 0x25,
153			op_MAPI_SetReceiveFolder	= 0x26,
154			op_MAPI_GetReceiveFolder	= 0x27,
155			op_MAPI_Advise			= 0x29,
156			op_MAPI_Notify			= 0x2a,
157			op_MAPI_OpenStream		= 0x2b,
158			op_MAPI_ReadStream		= 0x2c,
159			op_MAPI_WriteStream		= 0x2d,
160			op_MAPI_SetSearchCriteria	= 0x30,
161			op_MAPI_GetSearchCriteria      	= 0x31,
162			op_MAPI_SubmitMessage		= 0x32,
163			op_MAPI_CopyMessages		= 0x33,
164			op_MAPI_QueryColumns		= 0x37,
165			op_MAPI_GetTable		= 0x3e,
166			op_MAPI_ModifyTable		= 0x40,
167			op_MAPI_FindRow			= 0x4f,
168			op_MAPI_AddressTypes		= 0x49,
169			op_MAPI_GetNamesFromIDs		= 0x55,
170			op_MAPI_GetIDsFromNames		= 0x56,
171			op_MAPI_EmptyFolder		= 0x58,
172			op_MAPI_QueryNamesFromIDs	= 0x5f,
173			op_MAPI_GetReceiveFolderTable	= 0x68,
174			op_MAPI_OpenMsgStore		= 0xfe
175		} MAPI_OPNUM;
176
177
178	typedef struct {
179		uint32 dwLowDateTime;
180		uint32 dwHighDateTime;
181	} FILETIME;
182
183// 	typedef [noprint,flag(NDR_NOALIGN)] struct {
184// 		uint16				cb;
185// 		[flag(NDR_BUFFERS)]uint8	lpb[cb];
186// 	} SBinary_short;
187
188	typedef struct {
189		uint32 cValues;
190		uint32 lpl[cValues];
191	} MV_LONG_STRUCT;
192
193	typedef struct {
194		astring lppszA;
195	} LPSTR;
196
197	typedef struct {
198		uint32 cValues;
199		LPSTR strings[cValues];
200	} SLPSTRArray;
201
202// 	typedef struct {
203// 		uint32		cValues;
204// 		SBinary_short	bin[cValues];
205// 	} SBinaryArray;
206
207	typedef struct {
208		uint32		cValues;
209		GUID		lpguid[cValues];
210	} SGuidArray;
211
212	typedef [v1_enum] enum {
213		PT_UNSPECIFIED	= 0x0000,
214		PT_NULL		= 0x0001,
215		PT_I2		= 0x0002,
216		PT_LONG		= 0x0003,
217		PT_R4		= 0x0004,
218		PT_DOUBLE	= 0x0005,
219		PT_CURRENCY	= 0x0006,
220		PT_APPTIME	= 0x0007,
221		PT_ERROR	= 0x000a,	/* means the given attr contains no value */
222		PT_BOOLEAN	= 0x000b,
223		PT_OBJECT	= 0x000d,
224		PT_I8		= 0x0014,
225		PT_STRING8	= 0x001e,
226		PT_UNICODE	= 0x001f,
227		PT_SYSTIME	= 0x0040,
228		PT_CLSID	= 0x0048,
229		PT_BINARY	= 0x0102,
230
231		/* Multi-valued properties */
232
233		PT_MV_I2	= 0x1002,
234		PT_MV_LONG	= 0x1003,
235		PT_MV_R4	= 0x1004,
236		PT_MV_DOUBLE	= 0x1005,
237		PT_MV_CURRENCY	= 0x1006,
238		PT_MV_APPTIME	= 0x1007,
239		PT_MV_I8	= 0x1014,
240		PT_MV_STRING8	= 0x101e,
241//		PT_MV_TSTRING	= 0x101e,
242		PT_MV_UNICODE	= 0x101f,
243		PT_MV_SYSTIME	= 0x1040,
244		PT_MV_CLSID	= 0x1048,
245		PT_MV_BINARY	= 0x1102
246	} property_types;
247
248	typedef [switch_type(property_types),flag(NDR_NOALIGN)] union {
249		[case(PT_I2)]		uint16			i;
250		[case(PT_LONG)]     	uint32			l;
251		[case(PT_DOUBLE)]	dlong			dbl;
252		[case(PT_ERROR)]       	uint32			err;
253		[case(PT_BOOLEAN)]	uint8			b;
254		[case(PT_I8)]		dlong			d;
255		[case(PT_STRING8)]	astring			lpszA;
256		[case(PT_UNICODE)]	nstring			lpszW;
257		[case(PT_SYSTIME)]	FILETIME		ft;
258		[case(PT_CLSID)]	GUID			lpguid;
259//   		[case(PT_BINARY)]	SBinary_short		bin;
260// 		[case(0xFB)]		SBinary_short		bin;
261// 		[case(PT_MV_LONG)]	MV_LONG_STRUCT	MVl;
262// 		[case(PT_MV_STRING8)]	SLPSTRArray	MVszA;
263// 		[case(PT_MV_CLSID)]	SGuidArray		MVguid;
264// 		[case(PT_MV_BINARY)]	SBinaryArray      	MVbin;
265	} SPropValue_CTR;
266
267	typedef [public,flag(NDR_NOALIGN)] struct {
268		MAPITAGS ulPropTag;
269		[switch_is(ulPropTag & 0xFFFF)] SPropValue_CTR value;
270	} SPropValue;
271
272	typedef [flag(NDR_NOALIGN)] struct {
273		uint16					cValues;
274		[flag(NDR_REMAINING)]SPropValue	lpProps[cValues];
275	} SPropValue_array;
276
277	typedef [flag(NDR_NOALIGN)] struct {
278		uint16					cValues;
279		MAPITAGS				aulPropTag[cValues];
280	} SPropTagArray;
281
282	typedef [enum8bit, flag(NDR_PAHEX)] enum {
283		ROW_ADD		=	0x1,
284		ROW_MODIFY	=	0x2,
285		ROW_REMOVE	=	0x4
286	} ulRowFlags;
287
288	typedef [flag(NDR_NOALIGN)] struct {
289		ulRowFlags				ulRowFlags;
290// 		SPropValue_array			lpProps;
291	} SRow;
292
293	typedef [flag(NDR_NOALIGN)] struct {
294		uint8					padding;
295		uint16					cEntries;
296		SRow				aEntries[cEntries];
297	} SRowList;
298
299	/**************************/
300	/* EcDoRpc Function 0x1   */
301	typedef [nopush,nopull,flag(NDR_NOALIGN)] struct {
302	} Release_req;
303
304	typedef [nopush,nopull,flag(NDR_NOALIGN)] struct {
305	} Release_repl;
306
307	/**************************/
308	/* EcDoRpc Function 0x2   */
309	typedef [flag(NDR_NOALIGN)] struct {
310		uint8		handle_idx;
311		hyper		folder_id;
312 		uint8		unknown;
313	} OpenFolder_req;
314
315	typedef [flag(NDR_NOALIGN)] struct {
316		uint16		unknown;
317	} OpenFolder_repl;
318
319	/**************************/
320	/* EcDoRpc Function 0x3   */
321	typedef [flag(NDR_NOALIGN)] struct {
322		uint8		folder_handle_idx;
323		uint16		max_data;
324		hyper		folder_id;
325		uint8		message_permissions;
326		hyper		message_id;
327	} OpenMessage_req;
328
329	typedef [v1_enum, flag(NDR_PAHEX)] enum {
330		CP_USASCII	= 0x04E4,
331		CP_UNICODE	= 0x04B0,
332		CP_JAUTODETECT	= 0xC6F4,
333		CP_KAUTODETECT	= 0xC705,
334		CP_ISO2022JPESC = 0xC42D,
335		CP_ISO2022JPSIO	= 0xC42E
336	} CODEPAGEID;
337
338	typedef [enum8bit, flag(NDR_PAHEX)] enum {
339		MAPI_ORIG		= 0x0,
340		MAPI_TO			= 0x1,
341		MAPI_CC			= 0x2,
342		MAPI_BCC		= 0x3
343	} ulRecipClass;
344
345	/**************** EXPERIMENTAL ******************/
346
347	typedef [enum8bit, flag(NDR_PAHEX)] enum {
348		SINGLE_RECIPIENT	= 0x0,
349		DISTRIBUTION_LIST	= 0x1
350	} addr_type;
351
352	typedef  [flag(NDR_NOALIGN)]struct {
353		uint8		organization_length;
354		addr_type	addr_type;
355	} RecipExchange;
356
357	typedef [flag(NDR_NOALIGN)] struct {
358	} RecipSMTP;
359
360	typedef [enum16bit] enum {
361		EXCHANGE = 0x0,
362		SMTP = 0x1
363	} OM_recipient_type;
364
365	typedef [switch_type(OM_recipient_type),flag(NDR_NOALIGN)] union {
366		[case(0x0)] RecipExchange	EXCHANGE;
367		[case(0xA)] RecipSMTP		SMTP;
368		[default];
369	} recipient_type;
370
371	typedef [enum16bit] enum {
372		DISPLAYNAME = 0x400
373	} OM_recipient_displayname_7bit;
374
375	/* Bit 5: always UTF8 encoded */
376	typedef [switch_type(OM_recipient_displayname_7bit),flag(NDR_NOALIGN)] union {
377		[case(0x400)] astring		lpszA;
378		[default];
379	} recipient_displayname_7bit;
380
381// 	/* Bit 10 */
382// 	typedef [switch_type(recipient_email),flag(NDR_NOALIGN)] union {
383// 		[case(0x20)] astring   	lpszA;
384// 		[case(0x220)] nstring	lpszW;
385// 		[default];
386// 	} recipient_email;
387
388	/* Bit 11 */
389	/* First Name = PR_GIVEN_NAME */
390// 	typedef [switch_type(recipient_firstname),flag(NDR_NOALIGN)] union {
391// 		[case(0x10)] astring   	lpszA;
392// 		[case(0x210)] nstring	lpszW;
393// 		[default];
394// 	} recipient_firstname;
395
396// 	/* Bit 15 */
397// 	typedef [switch_type(recipient_displayname),flag(NDR_NOALIGN)] union {
398// 		[case(0x1)] astring    	lpszA;
399// 		[case(0x201)] nstring	lpszW;
400// 		[default];
401// 	} recipient_displayname;
402
403	typedef [flag(NDR_NOALIGN)] struct {
404		uint16							bitmask;
405 		[switch_is(bitmask & 0xA)]   recipient_type		type;
406		[switch_is(bitmask & 0x400)] recipient_displayname_7bit	username;
407// 		[switch_is(bitmask & 0x210)] recipient_firstname       	firstname;
408// 		[switch_is(bitmask & 0x201)] recipient_displayname	displayname;
409// 		[switch_is(bitmask & 0x220)] recipient_email   		email_address;
410		uint16							prop_count;
411		uint8							layout;
412		[flag(NDR_REMAINING)] DATA_BLOB				prop_values;
413	} recipients_headers;
414
415	/**************** EXPERIMENTAL *****************/
416
417	typedef [flag(NDR_NOALIGN)] struct {
418		ulRecipClass	RecipClass;
419		CODEPAGEID	codepage;
420		[subcontext(2)] recipients_headers recipients_headers;
421	} OpenMessage_recipients;
422
423// 	typedef [public, nodiscriminant]union {
424// 		[case(0x0)];
425// 		[case(0x1)];
426// 		[case(0x3)] astring subject;
427// 	} OpenMessage_repl_UNION;
428
429	typedef [flag(NDR_NOALIGN)] struct {
430		uint8		unknown;
431		uint8		type_prefix;
432// 		[switch_is(type_prefix)] OpenMessage_repl_UNION prefix;
433// 		uint8		type_subject;
434// 		[switch_is(type_subject)] OpenMessage_repl_UNION subject;
435		uint16			recipient_count;
436		SPropTagArray	SPropTagArray;
437// 		uint8			recipient_count_again;
438// 		OpenMessage_recipients	recipients[recipient_count];
439	} OpenMessage_repl;
440
441// 	/**************************/
442// 	/* EcDoRpc Function 0x4   */
443// 	typedef [flag(NDR_NOALIGN)] struct {
444// 		uint8		handle_idx;
445// 		uint8		unknown;
446// 	} GetHierarchyTable_req;
447
448// 	typedef [flag(NDR_NOALIGN)] struct {
449// 		uint16		cn_rows;
450// 		uint16		unknown;
451// 	} GetHierarchyTable_repl;
452
453// 	/**************************/
454// 	/* EcDoRpc Function 0x5   */
455// 	typedef [flag(NDR_NOALIGN)] struct {
456// 		uint8		handle_idx;
457// 		uint8		unknown;
458// 	} GetContentsTable_req;
459
460// 	typedef [flag(NDR_NOALIGN)] struct {
461// 		uint16          cn_rows;
462// 		uint16          unknown;
463// 	} GetContentsTable_repl;
464
465// 	/**************************/
466// 	/* EcDoRpc Function 0x6   */
467// 	typedef [flag(NDR_NOALIGN)] struct {
468// 		uint8		handle_idx;
469// 		uint16		max_data;
470// 		hyper		folder_id;
471// 		uint8		padding;
472// 	} CreateMessage_req;
473
474// 	typedef [flag(NDR_NOALIGN)] struct {
475// 		uint8		padding;
476// 	} CreateMessage_repl;
477
478// 	/*************************/
479// 	/* EcDoRpc Function 0x7  */
480 	typedef [flag(NDR_NOALIGN)] struct {
481 		uint32		unknown;
482 		uint16		prop_count;
483 		MAPITAGS	properties[prop_count];
484 	} GetProps_req;
485
486 	typedef [flag(NDR_NOALIGN)] struct {
487 		uint8		layout;
488 		[flag(NDR_REMAINING)] DATA_BLOB prop_data;
489 	} GetProps_repl;
490
491// 	/*************************/
492// 	/* EcDoRpc Function 0x8  */
493// 	typedef [flag(NDR_NOALIGN)] struct {
494// 		uint16			dwAlignPad;
495// 		uint16			unknown;
496// 	} GetPropsAll_req;
497
498// 	typedef [flag(NDR_NOALIGN)] struct {
499// 		SPropValue_array	properties;
500// 	} GetPropsAll_repl;
501
502// 	/*************************/
503// 	/* EcDoRpc Function 0x9  */
504// 	typedef [flag(NDR_NOALIGN)] struct {
505// 	} GetPropList_req;
506
507// 	typedef [flag(NDR_NOALIGN)] struct {
508// 		uint16		count;
509// 		MAPITAGS	tags[count];
510// 	} GetPropList_repl;
511
512// 	/*************************/
513// 	/* EcDoRpc Function 0xa  */
514
515// 	typedef [flag(NDR_NOALIGN)] struct {
516//  		[subcontext(2)] SPropValue_array values;
517// 	} SetProps_req;
518
519// 	typedef [flag(NDR_NOALIGN)] struct {
520// 		uint16		unknown;
521// 	} SetProps_repl;
522
523// 	/*************************/
524// 	/* EcDoRpc Function 0xb  */
525// 	typedef [flag(NDR_NOALIGN)] struct {
526// 		uint16		count;
527// 		MAPITAGS	tags[count];
528// 	} DeleteProps_req;
529
530// 	typedef [flag(NDR_NOALIGN)] struct {
531// 		uint16		unknown;
532// 	} DeleteProps_repl;
533
534// 	/*************************/
535// 	/* EcDoRpc Function 0xc  */
536// 	typedef [flag(NDR_NOALIGN)] struct {
537// 		uint8		handle_idx;
538// 		uint8		prop_nb;
539// 	} SaveChangesMessage_req;
540
541// 	typedef [flag(NDR_NOALIGN)] struct {
542// 		uint8		unknown;
543// 		hyper		message_id;
544// 	} SaveChangesMessage_repl;
545
546// 	/*************************/
547// 	/* EcDoRpc Function 0xe  */
548
549// 	/*
550// 	 * MODRECIP_NULL and INVALID are not part of the msdn flags
551// 	 * but are added for printing support
552// 	 */
553// 	typedef [enum8bit,flag(NDR_PAHEX)] enum {
554// 		MODRECIP_NULL		= 0x0,
555// 		MODRECIP_INVALID	= 0x1,
556// 		MODRECIP_ADD		= 0x2,
557// 		MODRECIP_MODIFY		= 0x4,
558// 		MODRECIP_REMOVE		= 0x8
559// 	} modrecip;
560
561// 	typedef [flag(NDR_NOALIGN)]struct {
562// 		uint32		idx;
563// 		ulRecipClass	RecipClass;
564// 		[subcontext(2),flag(NDR_REMAINING)] recipients_headers headers;
565// 	} recipients;
566
567// 	typedef [flag(NDR_NOALIGN)] struct {
568//  		uint16				prop_count;
569//  		MAPITAGS			properties[prop_count];
570// 		uint16				cValues;
571// 		recipients			recipient[cValues];
572// 	} ModifyRecipients_req;
573
574// 	typedef [flag(NDR_NOALIGN)] struct {
575
576// 	} ModifyRecipients_repl;
577
578// 	/*************************/
579// 	/* EcDoRpc Function 0x11 */
580
581// 	typedef [bitmap8bit] bitmap {
582// 		SUPPRESS_RECEIPT	= 0x01,
583// 		CLEAR_READ_FLAG		= 0x04,
584// 		MAPI_DEFERRED_ERRORS	= 0x08,
585// 		GENERATE_RECEIPT_ONLY	= 0x10,
586// 		CLEAR_RN_PENDING	= 0x20,
587// 	       	CLEAR_NRN_PENDING	= 0x40
588// 	} MSGFLAG_READ;
589
590// 	typedef [flag(NDR_NOALIGN)] struct {
591// 		uint8		handle_idx;
592// 		MSGFLAG_READ	flags;
593// 	} SetReadFlags_req;
594
595// 	typedef [flag(NDR_NOALIGN)] struct {
596// 		uint8		unknown;
597// 	} SetReadFlags_repl;
598
599// 	/*************************/
600// 	/* EcDoRpc Function 0x12 */
601// 	typedef [flag(NDR_NOALIGN)] struct {
602// 		uint8		unknown;
603// 		uint16		prop_count;
604// 		MAPITAGS	properties[prop_count];
605// 	} SetColumns_req;
606
607// 	typedef [flag(NDR_NOALIGN)] struct {
608// 		uint8		unknown;
609// 	} SetColumns_repl;
610
611// 	/**************************/
612// 	/* EcDoRpc Function 0x13  */
613//         typedef [enum8bit, flag(NDR_PAHEX)] enum {
614//                 TBL_ASYNC = 0x1,
615//                 TBL_BATCH = 0x2
616//         } TBL_FLAGS;
617
618//         typedef [enum8bit, flag(NDR_PAHEX)] enum {
619//                 TABLE_SORT_ASCEND = 0x0,
620//                 TABLE_SORT_COMBINE = 0x1,
621//                 TABLE_SORT_DESCEND = 0x2
622//         } TABLE_SORT;
623
624//         typedef [public, flag(NDR_NOALIGN)] struct _SSortOrder{
625//                 MAPITAGS ulPropTag;
626//                 TABLE_SORT ulOrder;
627//         } SSortOrder;
628
629// 	typedef [public, flag(NDR_NOALIGN)] struct _SSortOrderSet {
630//  		uint16		cSorts;
631//  		uint16		cCategories;
632//  		uint16		cExpanded;
633// 		SSortOrder	aSort[cSorts];
634// 	} SSortOrderSet;
635
636//         typedef [flag(NDR_NOALIGN)]struct {
637// 		uint8		unknown;
638// 		SSortOrderSet	lpSortCriteria;
639//         } SortTable_req;
640
641// 	typedef [flag(NDR_NOALIGN)] struct {
642// 		uint8		unknown;
643// 	} SortTable_repl;
644
645// 	/**************************/
646// 	/* EcDoRpc Function 0x14  */
647// 	typedef [flag(NDR_NOALIGN)] struct {
648// 		uint16			cRes;
649//    		SRestriction_and	res[cRes];
650// 	} SAndRestriction;
651
652// 	typedef [flag(NDR_NOALIGN)] struct {
653// 		uint16	cRes;
654//     		SRestriction_or	res[cRes];
655// 	} SOrRestriction;
656
657// 	typedef [nopull,nopush,noprint,flag(NDR_NOALIGN)] struct {
658// 		SRestriction_not	*res;
659// 	} SNotRestriction;
660
661//  	typedef [noprint, bitmap32bit] bitmap {
662// 		FL_FULLSTRING		= 0x00000,
663// 	       	FL_SUBSTRING		= 0x00001,
664// 		FL_PREFIX		= 0x00002,
665// 		FL_IGNORECASE		= 0x10000,
666// 		FL_IGNORENONSPACE	= 0x20000,
667// 		FL_LOOSE		= 0x40000
668// 	} fuzzyLevel;
669
670// 	typedef [flag(NDR_NOALIGN)] struct {
671// 		fuzzyLevel	fuzzy;
672// 		MAPITAGS	ulPropTag;
673// 		SPropValue	lpProp;
674// 	} SContentRestriction;
675
676// 	typedef [enum8bit, flag(NDR_PAHEX)] enum {
677// 		BMR_EQZ = 0x0,
678// 		BMR_NEZ = 0x1
679// 	} relMBR;
680
681// 	typedef [flag(NDR_NOALIGN)] struct {
682// 		relMBR		relMBR;
683// 		MAPITAGS	ulPropTag;
684// 		uint32		ulMask;
685// 	} SBitmaskRestriction;
686
687// 	typedef [enum8bit, flag(NDR_PAHEX)] enum {
688// 		RELOP_LT = 0x0,		/* <  */
689// 		RELOP_LE = 0x1,		/* <= */
690// 		RELOP_GT = 0x2,		/* >  */
691// 		RELOP_GE = 0x3,		/* >= */
692// 		RELOP_EQ = 0x4,		/* == */
693// 		RELOP_NE = 0x5,		/* != */
694// 		RELOP_RE = 0x6		/* LIKE (Regular expression) */
695// 	} CompareRelop;
696
697// 	typedef [flag(NDR_NOALIGN)] struct {
698// 		CompareRelop	relop;
699// 		MAPITAGS	ulPropTag;
700// 		uint32		size;
701// 	} SSizeRestriction;
702
703// 	typedef [flag(NDR_NOALIGN)] struct {
704// 		uint8		relop;
705// 		MAPITAGS	ulPropTag;
706// 		SPropValue	lpProp;
707// 	} SPropertyRestriction;
708
709// 	typedef [flag(NDR_NOALIGN)] struct {
710// 		CompareRelop   	relop;
711// 		MAPITAGS	ulPropTag1;
712// 		MAPITAGS	ulPropTag2;
713// 	} SCompareProps;
714
715// 	typedef [flag(NDR_NOALIGN)] struct {
716// 		MAPITAGS	ulPropTag;
717// 	} SExistRestriction;
718
719// 	typedef [flag(NDR_NOALIGN)] struct {
720//  		MAPITAGS	       	ulSubObject;
721//   		SRestriction_sub  	res[ulSubObject - ulSubObject + 1]; /* nasty hack - generates fake pointer */
722// 	} SSubRestriction;
723
724// 	typedef [flag(NDR_NOALIGN)] struct {
725// 		uint8				cValues;
726// 		uint16				cRes;
727// 		uint16				unknown;
728// 		SRestriction_comment	res[cRes];
729// 		SPropValue			lpProp[cValues];
730// 	} SCommentRestriction;
731
732// 	typedef [nodiscriminant] union {
733// 		[case(RES_AND)]			SAndRestriction		resAnd;
734// 		[case(RES_OR)]			SOrRestriction		resOr;
735//  		[case(RES_NOT)]			SNotRestriction		resNot;
736// 		[case(RES_CONTENT)]		SContentRestriction	resContent;
737// 		[case(RES_PROPERTY)]		SPropertyRestriction	resProperty;
738// 		[case(RES_COMPAREPROPS)]	SCompareProps		resCompareProps;
739// 		[case(RES_BITMASK)]		SBitmaskRestriction	resBitmask;
740// 		[case(RES_SIZE)]		SSizeRestriction		resSize;
741// 		[case(RES_EXIST)]		SExistRestriction		resExist;
742// 		[case(RES_SUBRESTRICTION)]	SSubRestriction		resSub;
743// 		[case(RES_COMMENT)]		SCommentRestriction	resComment;
744// 	} SRestriction_CTR;
745
746// 	typedef [flag(NDR_NOALIGN)] struct {
747// 		uint8 rt;
748// 		[switch_is(rt)] SRestriction_CTR res;
749// 	} SRestriction;
750
751// 	typedef [public,flag(NDR_NOALIGN)] struct _SRestriction {
752// 		uint8 rt;
753// 		[switch_is(rt)] SRestriction_CTR res;
754// 	} SRestriction_and;
755
756// 	typedef [public,flag(NDR_NOALIGN)] struct _SRestriction {
757// 		uint8 rt;
758// 		[switch_is(rt)] SRestriction_CTR res;
759// 	} SRestriction_or;
760
761// 	typedef [public,flag(NDR_NOALIGN)] struct _SRestriction {
762// 		uint8 rt;
763// 		[switch_is(rt)] SRestriction_CTR res;
764// 	} SRestriction_not;
765
766// 	typedef [public,flag(NDR_NOALIGN)] struct _SRestriction {
767// 		uint8 rt;
768// 		[switch_is(rt)] SRestriction_CTR res;
769// 	} SRestriction_sub;
770
771// 	typedef [public,flag(NDR_NOALIGN)] struct _SRestriction {
772// 		uint8 rt;
773// 		[switch_is(rt)] SRestriction_CTR res;
774// 	} SRestriction_comment;
775
776// 	typedef [flag(NDR_NOALIGN)] struct {
777// 		uint8 handle_idx;
778// 		[subcontext(2)] SRestriction  restrictions;
779// 	} Restrict_req;
780
781// 	typedef [flag(NDR_NOALIGN)] struct {
782// 		uint8		unknown;
783// 	} Restrict_repl;
784
785// 	/**************************/
786// 	/* EcDoRpc Function 0x15  */
787
788// 	typedef [enum8bit] enum {
789// 		TBL_ADVANCE		= 0x0,
790// 		TBL_NOADVANCE		= 0x1
791// 	} tbl_advance;
792
793// 	typedef [flag(NDR_NOALIGN)] struct {
794// 		tbl_advance	flag_advance;
795// 		uint8		layout;
796// 		uint16		row_count;
797// 	} QueryRows_req;
798
799// 	typedef [nopull,flag(NDR_NOALIGN)] struct {
800// 		uint8		unknown;
801// 		uint16		results_count;
802//  		uint8		layout;
803// 		[flag(NDR_REMAINING)]DATA_BLOB	rows;
804// 	} QueryRows_repl;
805
806// 	/**************************/
807// 	/* EcDoRpc Function 0x17  */
808// 	typedef [flag(NDR_NOALIGN)] struct {
809// 	} GetRowCount_req;
810
811// 	typedef [flag(NDR_NOALIGN)] struct {
812// 		uint32	unknown;
813// 		uint32	count;
814// 	} GetRowCount_repl;
815
816// 	/**************************/
817// 	/* EcDoRpc Function 0x18  */
818// 	typedef [enum8bit] enum {
819// 		BOOKMARK_BEGINNING	= 0x0,
820// 		BOOKMARK_CURRENT	= 0x1,
821// 		BOOKMARK_END		= 0x2,
822// 		BOOKMARK_USER		= 0x3
823// 	} BOOKMARK;
824
825// 	typedef [flag(NDR_NOALIGN)] struct {
826// 		BOOKMARK	origin;
827// 		int32		offset;
828// 		uint8		unknown_1;
829// 	} SeekRow_req;
830
831// 	typedef [flag(NDR_NOALIGN)] struct {
832// 		uint32		row;
833// 		uint8		unknown;
834// 	} SeekRow_repl;
835
836// 	/**************************/
837// 	/* EcDoRpc Function 0x19  */
838// 	typedef [flag(NDR_NOALIGN)] struct {
839// 		SBinary_short	bookmark;
840// 		uint32		offset;
841// 		uint8		unknown;
842// 	} SeekRowBookmark_req;
843
844// 	typedef [flag(NDR_NOALIGN)] struct {
845// 		uint16		unknown;
846// 		uint32		row;
847// 	} SeekRowBookmark_repl;
848
849// 	/**************************/
850// 	/* EcDoRpc Function 0x1a  */
851// 	typedef [flag(NDR_NOALIGN)] struct {
852// 		uint32		ulNumerator;
853// 		uint32		ulDenominator;
854// 	} SeekRowApprox_req;
855
856// 	typedef [flag(NDR_NOALIGN)] struct {
857// 	} SeekRowApprox_repl;
858
859// 	/**************************/
860// 	/* EcDoRpc Function 0x1b  */
861// 	typedef [flag(NDR_NOALIGN)] struct {
862// 	} CreateBookmark_req;
863
864// 	typedef [flag(NDR_NOALIGN)] struct {
865// 		SBinary_short	bookmark;
866// 	} CreateBookmark_repl;
867
868// 	/**************************/
869// 	/* EcDoRpc Function 0x1c  */
870// 	typedef [enum8bit] enum {
871// 		FOLDER_GENERIC	= 0x1,
872// 		FOLDER_SEARCH	= 0x2
873// 	} FOLDER_TYPE;
874
875// 	typedef [enum8bit] enum {
876// 		MAPI_FOLDER_ANSI       	= 0x0,
877// 		MAPI_FOLDER_UNICODE    	= 0x1
878// 	} FOLDER_STRING;
879
880// 	typedef [nodiscriminant, flag(NDR_NOALIGN)] union {
881// 		[case(MAPI_FOLDER_ANSI)] astring       	lpszA;
882// 		[case(MAPI_FOLDER_UNICODE)] nstring	lpszW;
883// 	} LPTSTR;
884
885// 	typedef [enum16bit] enum {
886// 		NONE		= 0x0000,
887// 		OPEN_IF_EXISTS	= 0x0001
888// 	} FOLDER_FLAGS;
889
890// 	typedef [flag(NDR_NOALIGN)] struct {
891// 		uint8				handle_idx;
892// 		FOLDER_TYPE			ulFolderType;
893// 		FOLDER_STRING			ulType;
894// 		FOLDER_FLAGS	       		ulFlags;
895// 		[switch_is(ulType)] LPTSTR	FolderName;
896// 		[switch_is(ulType)] LPTSTR	FolderComment;
897// 	} CreateFolder_req;
898
899// 	typedef [flag(NDR_NOALIGN)] struct {
900// 		hyper		folder_id;
901// 		uint8		unknown;
902// 	} CreateFolder_repl;
903
904// 	/**************************/
905// 	/* EcDoRpc Function 0x1d  */
906// 	typedef [flag(NDR_NOALIGN)] struct {
907// 		uint8		flags;
908// 		hyper		folder_id;
909// 	} DeleteFolder_req;
910
911// 	typedef [flag(NDR_NOALIGN)] struct {
912// 		uint8		unknown;
913// 	} DeleteFolder_repl;
914
915// 	/**************************/
916// 	/* EcDoRpc Function 0x1e  */
917// 	typedef [flag(NDR_NOALIGN)] struct {
918// 		uint16		flags;
919// 		uint16		cn_ids;
920// 		hyper		message_ids[cn_ids];
921// 	} DeleteMessages_req;
922
923// 	typedef [flag(NDR_NOALIGN)] struct {
924// 		uint8		align_pad;
925// 	} DeleteMessages_repl;
926
927// 	/**************************/
928// 	/* EcDoRpc Function 0x1f  */
929// 	typedef [flag(NDR_NOALIGN)] struct {
930// 		hyper		msgid;
931// 	} GetMessageStatus_req;
932
933// 	/**************************/
934// 	/* EcDoRpc Function 0x20  */
935// 	typedef [bitmap32bit] bitmap {
936// 		MSGSTATUS_HIGHLIGHTED		= 0x1,
937// 		MSGSTATUS_TAGGED		= 0x2,
938// 		MSGSTATUS_HIDDEN		= 0x4,
939// 	        MSGSTATUS_DELMARKED		= 0x8,
940// 		MSGSTATUS_REMOTE_DOWNLOAD	= 0x1000,
941// 		MSGSTATUS_REMOTE_DELETE		= 0x2000
942// 	} ulMessageStatus;
943
944
945// 	typedef [flag(NDR_NOALIGN)] struct {
946// 		hyper		msgid;
947// 		uint32		ulNewStatus;
948// 		ulMessageStatus	ulNewStatusMask;
949// 	} SetMessageStatus_req;
950
951// 	typedef [flag(NDR_NOALIGN)] struct {
952// 		ulMessageStatus	ulOldStatus;
953// 	} SetMessageStatus_repl;
954
955// 	/**************************/
956// 	/* EcDoRpc Function 0x21  */
957// 	typedef [flag(NDR_NOALIGN)] struct {
958// 		uint8		handle_idx;
959// 		uint8		unknown;
960// 	} GetAttachmentTable_req;
961
962// 	typedef [flag(NDR_NOALIGN)] struct {
963// 	} GetAttachmentTable_repl;
964
965// 	/*************************/
966// 	/* EcDoRpc Function 0x22 */
967//   	typedef [flag(NDR_NOALIGN)] struct {
968// 		uint8		handle_idx;
969// 		uint8		unknown;
970// 		uint32		num_attach;
971// 	} OpenAttach_req;
972
973// 	typedef [flag(NDR_NOALIGN)] struct {
974// 	} OpenAttach_repl;
975
976// 	/*************************/
977// 	/* EcDoRpc Function 0x23 */
978// 	typedef [flag(NDR_NOALIGN)] struct {
979// 		uint8	handle_idx;
980// 	} CreateAttach_req;
981
982// 	typedef [flag(NDR_NOALIGN)] struct {
983// 		uint32	unknown;
984// 	} CreateAttach_repl;
985
986// 	/*************************/
987// 	/* EcDoRpc Function 0x24 */
988// 	typedef [flag(NDR_NOALIGN)] struct {
989// 		uint32		num_attach;
990// 	} DeleteAttach_req;
991
992
993// 	typedef [flag(NDR_NOALIGN)] struct {
994// 	} DeleteAttach_repl;
995
996// 	/*************************/
997// 	/* EcDoRpc Function 0x25 */
998// 	typedef [flag(NDR_NOALIGN)] struct {
999// 		uint8 handle_idx;
1000// 		uint8 ulFlags;
1001// 	} SaveChanges_req;
1002
1003// 	typedef [flag(NDR_NOALIGN)] struct {
1004// 	} SaveChanges_repl;
1005
1006// 	/*************************/
1007// 	/* EcDoRpc Function 0x26 */
1008// 	typedef [flag(NDR_NOALIGN)] struct {
1009// 		hyper		fid;
1010// 		astring		lpszMessageClass;
1011// 	} SetReceiveFolder_req;
1012
1013// 	typedef [flag(NDR_NOALIGN)] struct {
1014// 	} SetReceiveFolder_repl;
1015
1016// 	/*************************/
1017// 	/* EcDoRpc Function 0x27 */
1018// 	typedef [flag(NDR_NOALIGN)] struct {
1019// 		uint8		unknown;
1020// 	} GetReceiveFolder_req;
1021
1022// 	typedef [flag(NDR_NOALIGN)] struct {
1023// 		hyper		folder_id;
1024// 	} GetReceiveFolder_repl;
1025
1026// 	/*************************/
1027// 	/* EcDoRpc Function 0x29 */
1028	typedef [bitmap16bit] bitmap {
1029		fnevCriticalError	= 0x00000001,
1030	        fnevNewMail		= 0x00000002,
1031	        fnevObjectCreated       = 0x00000004,
1032		fnevObjectDeleted       = 0x00000008,
1033		fnevObjectModified      = 0x00000010,
1034		fnevObjectMoved         = 0x00000020,
1035		fnevObjectCopied        = 0x00000040,
1036		fnevSearchComplete      = 0x00000080,
1037		fnevTableModified       = 0x00000100,
1038		fnevStatusObjectModified= 0x00000200,
1039		fnevReservedForMapi     = 0x40000000,
1040		fnevExtended            = 0x80000000
1041	} ulEventType;
1042
1043// 	typedef struct {
1044// 		hyper	entryid[2];
1045// 	} notif_entryid;
1046
1047// 	typedef [nodiscriminant] union {
1048// 		[case (0x0)] notif_entryid entryids;
1049// 		[case (0x1)];
1050// 	} notification_data;
1051
1052// 	typedef [flag(NDR_NOALIGN)] struct {
1053// 		uint8		handle_idx;
1054// 		ulEventType    	notification_type;
1055// 		uint8		layout;
1056// 		[switch_is(layout)] notification_data	u;
1057// 	} Advise_req;
1058
1059// 	typedef [flag(NDR_NOALIGN)] struct {
1060// 	} Advise_repl;
1061
1062// 	/*************************/
1063// 	/* EcDoRpc Function 0x2a */
1064
1065// 	/******************** EXPERIMENTAL *********************/
1066
1067// 	typedef [bitmap32bit] bitmap {
1068// 		MSGFLAG_READ		= 0x1,
1069// 		MSGFLAG_UNMODIFIED	= 0x2,
1070// 		MSGFLAG_SUBMIT		= 0x4,
1071// 		MSGFLAG_UNSENT		= 0x8,
1072// 		MSGFLAG_HASATTACH	= 0x10,
1073// 		MSGFLAG_FROMME		= 0x20,
1074// 		MSGFLAG_ASSOCIATED	= 0x40,
1075// 		MSGFLAG_RESEND		= 0x80,
1076// 		MSGFLAG_RN_PENDING	= 0x100,
1077// 	        MSGFLAG_NRN_PENDING	= 0x200
1078// 	} MsgFlags;
1079
1080// 	typedef [flag(NDR_NOALIGN)] struct {
1081// 		uint8	       	type;
1082// 		hyper		lpParentID;
1083// 		hyper		lpEntryID;
1084// 		MsgFlags	MsgFlags;
1085// 		uint8		unknown;
1086// 		astring		lpszMessageClass;
1087// 		uint8		unknown2[3];
1088// 	} NEWMAIL_NOTIFICATION;
1089
1090// 	typedef [flag(NDR_NOALIGN)] struct {
1091// 		SPropTagArray	lpPropTagArray;
1092// 		uint32			msg_count;//fixme
1093// 		uint8			unknown[3];
1094// 	} obj_change;
1095
1096// 	typedef [flag(NDR_NOALIGN)] struct {
1097// 		SPropValue_array	properties;
1098// 		uint8			unknown[3];
1099// 	} obj_update;
1100
1101// 	typedef [flag(NDR_NOALIGN)] struct {
1102// 		SPropTagArray	lpPropTagArray;
1103// 		uint32			row_idx;
1104// 		uint32			unread_count;
1105// 	} obj_received;
1106
1107// 	typedef [flag(NDR_NOALIGN)] struct {
1108// 		hyper			lpEntryID;
1109// 		SPropTagArray	lpPropTagArray;
1110// 	} obj_created;
1111
1112// 	typedef [flag(NDR_NOALIGN),nodiscriminant] union {
1113// 		[case(0x0)] obj_change			change;
1114// 		[case(0x10)] obj_change			change;
1115// 		[case(0x20)] obj_update			update;
1116// 		[case(0x30)] obj_received		received;
1117// 		[case(0x80)] obj_created		created;
1118// 		[default] [flag(NDR_REMAINING)]DATA_BLOB blob;
1119// 	} OBJECT_TYPE;
1120
1121// 	typedef [flag(NDR_NOALIGN)] struct {
1122// 		uint8				type;
1123// 		hyper				lpParentID;
1124//  		[switch_is(type)]OBJECT_TYPE   	object_type;
1125// 	} OBJECT_NOTIFICATION;
1126
1127
1128// 	typedef [nodiscriminant] union {
1129// 		[case(fnevNewMail)] NEWMAIL_NOTIFICATION	newmail;
1130// 		[case(fnevObjectCreated)] OBJECT_NOTIFICATION	obj;
1131// 		[default][flag(NDR_REMAINING)] DATA_BLOB data;
1132// 	} NOTIFICATION;
1133
1134// 	/******************** EXPERIMENTAL *********************/
1135
1136// 	typedef [flag(NDR_NOALIGN)] struct {
1137// 		uint8		unknown[5];
1138// 		uint8		ulEventType;
1139//  		[switch_is(ulEventType)]NOTIFICATION	info;
1140// 	} Notify_repl;
1141
1142// 	/*************************/
1143// 	/* EcDoRpc Function 0x2b */
1144// 	typedef [flag(NDR_NOALIGN)] struct {
1145// 		uint8		stream_handle_idx;
1146// 		MAPITAGS	prop;
1147// 		uint8		access_flags;
1148// 	} OpenStream_req;
1149
1150// 	typedef [flag(NDR_NOALIGN)] struct {
1151// 		uint32		length;
1152// 	} OpenStream_repl;
1153
1154// 	/*************************/
1155// 	/* EcDoRpc Function 0x2c */
1156// 	typedef [flag(NDR_NOALIGN)] struct {
1157// 		uint16		size;
1158// 	} ReadStream_req;
1159
1160// 	typedef [flag(NDR_ALIGN2)] struct {
1161// 		[subcontext(2), flag(NDR_REMAINING)] DATA_BLOB data;
1162// 	} ReadStream_repl;
1163
1164// 	/*************************/
1165// 	/* EcDoRpc Function 0x2d */
1166// 	typedef [flag(NDR_NOALIGN)] struct {
1167// 		[subcontext(2), flag(NDR_REMAINING)] DATA_BLOB	data;
1168// 	} WriteStream_req;
1169
1170
1171// 	typedef [flag(NDR_NOALIGN)] struct {
1172// 		uint16		size;
1173// 	} WriteStream_repl;
1174
1175// 	/*************************/
1176// 	/* EcDoRpc Function 0x30 */
1177// 	typedef [bitmap32bit, flag(NDR_PAHEX)] bitmap {
1178// 		STOP_SEARCH		= 0x1,
1179// 		RESTART_SEARCH		= 0x2,
1180// 		RECURSIVE_SEARCH	= 0x4,
1181// 		SHALLOW_SEARCH		= 0x8,
1182// 		FOREGROUND_SEARCH	= 0x10,
1183// 		BACKGROUND_SEARCH	= 0x20
1184// 	} ulSearchFlags;
1185
1186// 	typedef [flag(NDR_NOALIGN)] struct {
1187// 		[subcontext(2)] SRestriction res;
1188// 		uint16		count;
1189// 		hyper		lpContainerList[count];
1190// 		ulSearchFlags	ulSearchFlags;
1191// 	} SetSearchCriteria_req;
1192
1193// 	typedef [flag(NDR_NOALIGN)] struct {
1194// 	} SetSearchCriteria_repl;
1195
1196// 	/*************************/
1197// 	/* EcDoRpc Function 0x31 */
1198// 	typedef [flag(NDR_NOALIGN)] struct {
1199// 		uint8		unknown[3];
1200// 	} GetSearchCriteria_req;
1201
1202// 	typedef [flag(NDR_NOALIGN)] struct {
1203// 		[subcontext(2)] SRestriction	res;
1204// 		uint8		unknown;
1205// 		uint16		count;
1206// 		hyper		lpContainerList[count];
1207// 		ulSearchFlags	ulSearchFlags;
1208// 	} GetSearchCriteria_repl;
1209
1210// 	/*************************/
1211// 	/* EcDoRpc Function 0x32 */
1212// 	typedef [flag(NDR_NOALIGN)] struct {
1213// 		uint8		unknown;
1214// 	} SubmitMessage_req;
1215
1216// 	typedef [flag(NDR_NOALIGN)] struct {
1217// //		uint8		unknown[3];
1218// 	} SubmitMessage_repl;
1219
1220// 	/*************************/
1221// 	/* EcDoRpc Function 0x33 */
1222// 	typedef [flag(NDR_NOALIGN)] struct {
1223//  		uint8		handle_idx;
1224//  		uint16		count;
1225//  		hyper		message_id[count];
1226//  		uint16		row_nb;
1227// 	} CopyMessages_req;
1228
1229// 	typedef [flag(NDR_NOALIGN)] struct {
1230// 		uint8		unknown;
1231// 	} CopyMessages_repl;
1232
1233// 	/*************************/
1234// 	/* EcDoRpc Function 0x37 */
1235// 	typedef [flag(NDR_NOALIGN)] struct {
1236// 	} QueryColumns_req;
1237
1238// 	typedef [flag(NDR_NOALIGN)] struct {
1239// 		uint16		count;
1240// 		MAPITAGS	tags[count];
1241// 	} QueryColumns_repl;
1242
1243// 	/*************************/
1244// 	/* EcDoRpc Function 0x3e */
1245// 	typedef [flag(NDR_NOALIGN)] struct {
1246// 		uint8		handle_idx;
1247// 		uint8		padding;
1248// 	} GetTable_req;
1249
1250// 	typedef [flag(NDR_NOALIGN)] struct {
1251// 	} GetTable_repl;
1252
1253// 	/*************************/
1254// 	/* EcDoRpc Function 0x40 */
1255// 	typedef [flag(NDR_NOALIGN)] struct {
1256//  		SRowList		rowList;
1257// 	} ModifyTable_req;
1258
1259// 	typedef [flag(NDR_NOALIGN)] struct {
1260// 		[flag(NDR_REMAINING)] DATA_BLOB remaining;
1261// 	} ModifyTable_repl;
1262
1263// 	/*************************/
1264// 	/* EcDoRpc Function 0x49 */
1265// 	typedef [flag(NDR_NOALIGN)] struct {
1266// 	} AddressTypes_req;
1267
1268// 	typedef [flag(NDR_NOALIGN)] struct {
1269// 		uint16 		cValues;
1270// 		uint16 		size;
1271// 		LPSTR	transport[cValues];
1272// 	} AddressTypes_repl;
1273
1274// 	/**************************/
1275// 	/* EcDoRpc Function 0x4f  */
1276// 	typedef [enum8bit] enum {
1277// 		DIR_FORWARD  = 0x0,
1278// 		DIR_BACKWARD = 0x1
1279// 	} FindRow_ulFlags;
1280
1281// 	typedef [flag(NDR_NOALIGN)] struct {
1282// 		FindRow_ulFlags	ulFlags;
1283//   		[subcontext(2)] SRestriction res;
1284// 		BOOKMARK	origin;
1285// 		SBinary_short	bookmark;
1286// 	} FindRow_req;
1287
1288// 	typedef [flag(NDR_NOALIGN)] struct {
1289// 		uint16		unknown;
1290// 		uint8		layout;
1291// 		[flag(NDR_NOALIGN)] DATA_BLOB row;
1292// 	} FindRow_repl;
1293
1294// 	/*************************/
1295// 	/* EcDoRpc Function 0x55 */
1296
1297// 	typedef [enum8bit] enum {
1298// 		MNID_ID = 0,
1299// 		MNID_STRING = 1
1300// 	} ulKind;
1301
1302// 	typedef struct {
1303// 		uint8  	length;
1304// 		nstring	lpwstrName;
1305// 	} LPWSTR;
1306
1307// 	typedef [nodiscriminant] union {
1308// 		[case(MNID_ID)] uint32		lid;
1309// 		[case(MNID_STRING)] LPWSTR	lpwstr;
1310// 	} Kind;
1311
1312// 	typedef [flag(NDR_NOALIGN)] struct {
1313// 		ulKind				ulKind;
1314// 		GUID				lpguid;
1315// 		[switch_is(ulKind)] Kind	kind;
1316// 	} MAPINAMEID;
1317
1318// 	typedef [flag(NDR_NOALIGN)] struct {
1319// 		MAPITAGS	ulPropTag;
1320// 	} GetNamesFromIDs_req;
1321
1322// 	typedef [flag(NDR_NOALIGN)] struct {
1323// 		uint16		count;
1324// 		MAPINAMEID	nameid[count];
1325// 	} GetNamesFromIDs_repl;
1326
1327// 	/*************************/
1328// 	/* EcDoRpc Function 0x56 */
1329// 	typedef [flag(NDR_NOALIGN)] struct {
1330// 		uint8		ulFlags;
1331// 		uint16		count;
1332// 		MAPINAMEID	nameid[count];
1333// 	} GetIDsFromNames_req;
1334
1335// 	typedef [flag(NDR_NOALIGN)] struct {
1336// 		uint16		count;
1337// 		uint16		propID[count];
1338// 	} GetIDsFromNames_repl;
1339
1340// 	/*************************/
1341// 	/* EcDoRpc Function 0x58 */
1342// 	typedef [flag(NDR_NOALIGN)] struct {
1343// 		uint16		unknown;
1344// 	} EmptyFolder_req;
1345
1346// 	typedef [flag(NDR_NOALIGN)] struct {
1347// 		uint8		unknown;
1348// 	} EmptyFolder_repl;
1349
1350// 	/*************************/
1351// 	/* EcDoRpc Function 0x5f */
1352// 	typedef [flag(NDR_NOALIGN)] struct {
1353// 		uint16		propID;
1354// 	} QueryNamesFromIDs_req;
1355
1356// 	typedef [flag(NDR_NOALIGN)] struct {
1357// 		uint16		count;
1358// 		uint16		propID[count];
1359// 		MAPINAMEID	nameid[count];
1360// 	} QueryNamesFromIDs_repl;
1361
1362// 	/*************************/
1363// 	/* EcDoRpc Function 0x68 */
1364// 	typedef [flag(NDR_NOALIGN)] struct {
1365// 		uint8		unknown;
1366// 		hyper		fid;
1367// 		astring		lpszMessageClass;
1368// 		FILETIME	modiftime;
1369// 	} ReceiveFolder;
1370
1371// 	typedef [flag(NDR_NOALIGN)] struct {
1372// 	} GetReceiveFolderTable_req;
1373
1374// 	typedef [flag(NDR_NOALIGN)] struct {
1375// 		uint32		cValues;
1376// 		ReceiveFolder	entries[cValues];
1377// 	} GetReceiveFolderTable_repl;
1378
1379	/*************************/
1380	/* EcDoRpc Function 0xFE */
1381	typedef [flag(NDR_NOALIGN)] struct {
1382		uint32	codepage;
1383		uint32	padding;
1384		uint8	row;
1385		uint16	mailbox_str_size;
1386		[string,charset(DOS)] uint8	*mailbox;
1387	} OpenMsgStore_req;
1388
1389	/*
1390	** MAPIUID explanation:
1391	** http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mapi/html/c42065c2-b1f5-4930-84a6-6ef90c6162d0.asp
1392	*/
1393
1394// 	typedef struct _MAPIUID{
1395// 		uint8 ab[16];
1396// 	} MAPIUID;
1397
1398//  	typedef [flag(NDR_NOALIGN)] struct {
1399// 		hyper		folder_id[13];
1400// 		uint16		unknown;
1401// 		MAPIUID		entryid;
1402// 		MAPIUID		msgstore;
1403// 	} store_pf;
1404
1405// 	typedef [flag(NDR_NOALIGN)] struct {
1406//  		hyper		folder_id[13];
1407// 		uint8		unknown3;
1408// 		MAPIUID		entryid;
1409// 		uint16		default_store;
1410// 		MAPIUID		msgstore;
1411// 		FILETIME	ts_access;
1412// 		astring		creation_date;
1413// 		uint8		terminator;
1414// 		uint16		unknown4;
1415// 	} store_mailbox;
1416
1417// 	typedef [switch_type(uint8)] union {
1418// 		[case(0x0)] store_pf store_pf;
1419// 		[case(0x1)] store_mailbox store_mailbox;
1420// 	} store_type;
1421
1422// 	typedef [enum8bit,flag(NDR_NOALIGN)] enum {
1423// 		PROVIDER_TYPE_PF = 0x0,
1424// 		PROVIDER_TYPE_MAILBOX = 0x1
1425// 	} PROVIDER_TYPE;
1426
1427
1428
1429// 	typedef [flag(NDR_NOALIGN)] struct {
1430// 		PROVIDER_TYPE	PR_OBJECT_TYPE;
1431// 		[switch_is(PR_OBJECT_TYPE)] store_type type;
1432// 	} OpenMsgStore_repl;
1433
1434 	typedef [switch_type(MAPI_OPNUM)] union {
1435		[case(op_MAPI_Release)] Release_req mapi_Release;
1436 		[case(op_MAPI_OpenFolder)] OpenFolder_req mapi_OpenFolder;
1437// 		[case(op_MAPI_OpenMessage)] OpenMessage_req mapi_OpenMessage;
1438// 		[case(op_MAPI_GetHierarchyTable)] GetHierarchyTable_req mapi_GetHierarchyTable;
1439// 		[case(op_MAPI_GetContentsTable)] GetContentsTable_req mapi_GetContentsTable;
1440// 		[case(op_MAPI_CreateMessage)] CreateMessage_req mapi_CreateMessage;
1441 		[case(op_MAPI_GetProps)] GetProps_req mapi_GetProps;
1442// 		[case(op_MAPI_GetPropsAll)] GetPropsAll_req mapi_GetPropsAll;
1443// 		[case(op_MAPI_GetPropList)] GetPropList_req mapi_GetPropList;
1444// 		[case(op_MAPI_SetProps)] SetProps_req mapi_SetProps;
1445// 		[case(op_MAPI_DeleteProps)] DeleteProps_req mapi_DeleteProps;
1446// 		[case(op_MAPI_SaveChangesMessage)] SaveChangesMessage_req mapi_SaveChangesMessage;
1447// 		[case(op_MAPI_SetReadFlags)] SetReadFlags_req mapi_SetReadFlags;
1448// 		[case(op_MAPI_SetColumns)] SetColumns_req mapi_SetColumns;
1449// 		[case(op_MAPI_SortTable)] SortTable_req mapi_SortTable;
1450// 		[case(op_MAPI_Restrict)] Restrict_req mapi_Restrict;
1451// 		[case(op_MAPI_ModifyRecipients)] ModifyRecipients_req mapi_ModifyRecipients;
1452// 		[case(op_MAPI_QueryRows)] QueryRows_req mapi_QueryRows;
1453// 		[case(op_MAPI_GetRowCount)] GetRowCount_req mapi_GetRowCount;
1454// 		[case(op_MAPI_SeekRow)] SeekRow_req mapi_SeekRow;
1455// 		[case(op_MAPI_SeekRowBookmark)] SeekRowBookmark_req mapi_SeekRowBookmark;
1456// 		[case(op_MAPI_SeekRowApprox)] SeekRowApprox_req mapi_SeekRowApprox;
1457// 		[case(op_MAPI_CreateBookmark)] CreateBookmark_req mapi_CreateBookmark;
1458// 		[case(op_MAPI_CreateFolder)] CreateFolder_req mapi_CreateFolder;
1459// 		[case(op_MAPI_DeleteFolder)] DeleteFolder_req mapi_DeleteFolder;
1460// 		[case(op_MAPI_DeleteMessages)] DeleteMessages_req mapi_DeleteMessages;
1461// 		[case(op_MAPI_GetMessageStatus)] GetMessageStatus_req mapi_GetMessageStatus;
1462// 		[case(op_MAPI_SetMessageStatus)] SetMessageStatus_req mapi_SetMessageStatus;
1463// 		[case(op_MAPI_GetAttachmentTable)] GetAttachmentTable_req mapi_GetAttachmentTable;
1464// 		[case(op_MAPI_OpenAttach)] OpenAttach_req mapi_OpenAttach;
1465// 		[case(op_MAPI_CreateAttach)] CreateAttach_req mapi_CreateAttach;
1466// 		[case(op_MAPI_DeleteAttach)] DeleteAttach_req mapi_DeleteAttach;
1467// 		[case(op_MAPI_SaveChanges)] SaveChanges_req mapi_SaveChanges;
1468// 		[case(op_MAPI_SetReceiveFolder)] SetReceiveFolder_req mapi_SetReceiveFolder;
1469// 		[case(op_MAPI_GetReceiveFolder)] GetReceiveFolder_req mapi_GetReceiveFolder;
1470// 		[case(op_MAPI_Advise)] Advise_req mapi_Advise;
1471// 		[case(op_MAPI_OpenStream)] OpenStream_req mapi_OpenStream;
1472// 		[case(op_MAPI_ReadStream)] ReadStream_req mapi_ReadStream;
1473// 		[case(op_MAPI_WriteStream)] WriteStream_req mapi_WriteStream;
1474// 		[case(op_MAPI_SetSearchCriteria)] SetSearchCriteria_req mapi_SetSearchCriteria;
1475// 		[case(op_MAPI_GetSearchCriteria)] GetSearchCriteria_req mapi_GetSearchCriteria;
1476// 		[case(op_MAPI_SubmitMessage)] SubmitMessage_req mapi_SubmitMessage;
1477// 		[case(op_MAPI_CopyMessages)] CopyMessages_req mapi_CopyMessages;
1478// 		[case(op_MAPI_QueryColumns)] QueryColumns_req mapi_QueryColumns;
1479// 		[case(op_MAPI_GetTable)] GetTable_req mapi_GetTable;
1480// 		[case(op_MAPI_ModifyTable)] ModifyTable_req mapi_ModifyTable;
1481// 		[case(op_MAPI_AddressTypes)] AddressTypes_req mapi_AddressTypes;
1482// 		[case(op_MAPI_FindRow)] FindRow_req mapi_FindRow;
1483// 		[case(op_MAPI_GetNamesFromIDs)] GetNamesFromIDs_req mapi_GetNamesFromIDs;
1484// 		[case(op_MAPI_GetIDsFromNames)] GetIDsFromNames_req mapi_GetIDsFromNames;
1485// 		[case(op_MAPI_EmptyFolder)] EmptyFolder_req mapi_EmptyFolder;
1486// 		[case(op_MAPI_QueryNamesFromIDs)] QueryNamesFromIDs_req mapi_QueryNamesFromIDs;
1487// 		[case(op_MAPI_GetReceiveFolderTable)] GetReceiveFolderTable_req mapi_GetReceiveFolderTable;
1488 		[case(op_MAPI_OpenMsgStore)] OpenMsgStore_req mapi_OpenMsgStore;
1489	} EcDoRpc_MAPI_REQ_UNION;
1490
1491	typedef [public, switch_type(MAPI_OPNUM)] union {
1492 		[case(op_MAPI_Release)] Release_repl mapi_Release;
1493 		[case(op_MAPI_OpenFolder)] OpenFolder_repl mapi_OpenFolder;
1494// 		[case(op_MAPI_OpenMessage)] OpenMessage_repl mapi_OpenMessage;
1495// 		[case(op_MAPI_GetHierarchyTable)] GetHierarchyTable_repl mapi_GetHierarchyTable;
1496// 		[case(op_MAPI_GetContentsTable)] GetContentsTable_repl mapi_GetContentsTable;
1497// 		[case(op_MAPI_CreateMessage)] CreateMessage_repl mapi_CreateMessage;
1498 		[case(op_MAPI_GetProps)] GetProps_repl mapi_GetProps;
1499// 		[case(op_MAPI_GetPropsAll)] GetPropsAll_repl mapi_GetPropsAll;
1500// 		[case(op_MAPI_GetPropList)] GetPropList_repl mapi_GetPropList;
1501// 		[case(op_MAPI_SetProps)] SetProps_repl mapi_SetProps;
1502// 		[case(op_MAPI_DeleteProps)] DeleteProps_repl mapi_DeleteProps;
1503// 		[case(op_MAPI_SaveChangesMessage)] SaveChangesMessage_repl mapi_SaveChangesMessage;
1504// 		[case(op_MAPI_ModifyRecipients)] ModifyRecipients_repl mapi_ModifyRecipients;
1505// 		[case(op_MAPI_SetReadFlags)] SetReadFlags_repl mapi_SetReadFlags;
1506// 		[case(op_MAPI_SetColumns)] SetColumns_repl mapi_SetColumns;
1507// 		[case(op_MAPI_SortTable)] SortTable_repl mapi_SortTable;
1508// 		[case(op_MAPI_Restrict)] Restrict_repl mapi_Restrict;
1509// 		[case(op_MAPI_QueryRows)] QueryRows_repl mapi_QueryRows;
1510// 		[case(op_MAPI_GetRowCount)] GetRowCount_repl mapi_GetRowCount;
1511// 		[case(op_MAPI_SeekRow)] SeekRow_repl mapi_SeekRow;
1512// 		[case(op_MAPI_SeekRowBookmark)] SeekRowBookmark_repl mapi_SeekRowBookmark;
1513// 		[case(op_MAPI_SeekRowApprox)] SeekRowApprox_repl mapi_SeekRowApprox;
1514// 		[case(op_MAPI_CreateBookmark)] CreateBookmark_repl mapi_CreateBookmark;
1515// 		[case(op_MAPI_CreateFolder)] CreateFolder_repl mapi_CreateFolder;
1516// 		[case(op_MAPI_DeleteFolder)] DeleteFolder_repl mapi_DeleteFolder;
1517// 		[case(op_MAPI_DeleteMessages)] DeleteMessages_repl mapi_DeleteMessages;
1518// 		[case(op_MAPI_SetMessageStatus)] SetMessageStatus_repl mapi_SetMessageStatus;
1519// 		[case(op_MAPI_GetAttachmentTable)] GetAttachmentTable_repl mapi_GetAttachmentTable;
1520// 		[case(op_MAPI_OpenAttach)] OpenAttach_repl mapi_OpenAttach;
1521// 		[case(op_MAPI_CreateAttach)] CreateAttach_repl mapi_CreateAttach;
1522// 		[case(op_MAPI_DeleteAttach)] DeleteAttach_repl mapi_DeleteAttach;
1523// 		[case(op_MAPI_SaveChanges)] SaveChanges_repl mapi_SaveChanges;
1524// 		[case(op_MAPI_SetReceiveFolder)] SetReceiveFolder_repl mapi_SetReceiveFolder;
1525// 		[case(op_MAPI_GetReceiveFolder)] GetReceiveFolder_repl mapi_GetReceiveFolder;
1526// 		[case(op_MAPI_Advise)] Advise_repl mapi_Advise;
1527// 		[case(op_MAPI_Notify)] Notify_repl mapi_Notify;
1528// 		[case(op_MAPI_OpenStream)] OpenStream_repl mapi_OpenStream;
1529// 		[case(op_MAPI_ReadStream)] ReadStream_repl mapi_ReadStream;
1530// 		[case(op_MAPI_WriteStream)] WriteStream_repl mapi_WriteStream;
1531// 		[case(op_MAPI_SetSearchCriteria)] SetSearchCriteria_repl mapi_SetSearchCriteria;
1532// 		[case(op_MAPI_GetSearchCriteria)] GetSearchCriteria_repl mapi_GetSearchCriteria;
1533// 		[case(op_MAPI_SubmitMessage)] SubmitMessage_repl mapi_SubmitMessage;
1534// 		[case(op_MAPI_CopyMessages)] CopyMessages_repl mapi_CopyMessages;
1535// 		[case(op_MAPI_QueryColumns)] QueryColumns_repl mapi_QueryColumns;
1536// 		[case(op_MAPI_GetTable)] GetTable_repl mapi_GetTable;
1537// 		[case(op_MAPI_ModifyTable)] ModifyTable_repl mapi_ModifyTable;
1538// 		[case(op_MAPI_AddressTypes)] AddressTypes_repl mapi_AddressTypes;
1539// 		[case(op_MAPI_FindRow)] FindRow_repl mapi_FindRow;
1540// 		[case(op_MAPI_GetNamesFromIDs)] GetNamesFromIDs_repl mapi_GetNamesFromIDs;
1541// 		[case(op_MAPI_GetIDsFromNames)] GetIDsFromNames_repl mapi_GetIDsFromNames;
1542// 		[case(op_MAPI_EmptyFolder)] EmptyFolder_repl mapi_EmptyFolder;
1543// 		[case(op_MAPI_QueryNamesFromIDs)] QueryNamesFromIDs_repl mapi_QueryNamesFromIDs;
1544// 		[case(op_MAPI_GetReceiveFolderTable)] GetReceiveFolderTable_repl mapi_GetReceiveFolderTable;
1545// 		[case(op_MAPI_OpenMsgStore)] OpenMsgStore_repl mapi_OpenMsgStore;
1546	} EcDoRpc_MAPI_REPL_UNION;
1547
1548	typedef [public,flag(NDR_NOALIGN)] struct {
1549		uint8		opnum;
1550		uint8		mapi_flags;
1551		uint8		handle_idx;
1552		[switch_is(opnum)] EcDoRpc_MAPI_REQ_UNION u;
1553	} EcDoRpc_MAPI_REQ;
1554
1555	typedef [public,nopull,noprint,flag(NDR_NOALIGN)] struct {
1556		uint8     	opnum;
1557		uint8		handle_idx;
1558		MAPISTATUS	error_code;
1559		[switch_is(opnum)] EcDoRpc_MAPI_REPL_UNION u;
1560	} EcDoRpc_MAPI_REPL;
1561
1562
1563 	/*
1564 	  Abstract way to represent MAPI content
1565 	*/
1566
1567  	typedef [public,nopull,nopush,noprint] struct {
1568		uint32			mapi_len;	/* whole mapi_data length */
1569		uint16			length;		/* content length */
1570 		EcDoRpc_MAPI_REQ	*mapi_req;
1571 		uint32			*handles;	/* handles id array */
1572	} mapi_request;
1573
1574	typedef [public,nopull,nopush,noprint] struct {
1575		uint32			mapi_len;
1576		uint16			length;
1577		EcDoRpc_MAPI_REPL	*mapi_repl;
1578		uint32			*handles;
1579	} mapi_response;
1580
1581
1582	[public] MAPISTATUS  EcDoRpc(
1583		[in,out]	policy_handle	*handle,
1584		[in,out]	uint32 size,
1585		[in,out]	uint32 offset,
1586 	  	[in][subcontext(4),flag(NDR_REMAINING|NDR_NOALIGN)] mapi_request  *mapi_request,
1587 		[out][subcontext(4),flag(NDR_REMAINING|NDR_NOALIGN)] mapi_response *mapi_response,
1588		[in,out]	uint16		*length,
1589		[in]		uint16		max_data
1590		);
1591
1592// 	/*****************/
1593// 	/* Function 0x03 */
1594 	void EcGetMoreRpc();
1595
1596	/*****************/
1597	/* Function 0x04 */
1598
1599	/*
1600	  we could directly use a NOTIFKEY structure rather than
1601	  a uint8 array, but this makes the IDL more robust
1602
1603	  sockaddr array is made of:
1604	   - family (unsigned short in) sa_family_t
1605	   - address data sa_data[14];
1606	 */
1607
1608	typedef struct {
1609		uint16		cb;
1610		uint8		ab[cb];
1611	} NOTIFKEY;
1612
1613	MAPISTATUS EcRRegisterPushNotification(
1614               [in,out] policy_handle	*handle,
1615               [in] ulEventType ulEventMask,
1616	       [in, size_is(notif_len)] uint8 notifkey[*],
1617               [in] uint16 notif_len,
1618	       [in] uint32 unknown2,
1619	       [in, size_is(sockaddr_len)] uint8 sockaddr[*],
1620	       [in] uint16 sockaddr_len,
1621	       [out,ref] uint32	*retval
1622		);
1623
1624	/*****************/
1625	/* Function 0x05 */
1626	MAPISTATUS EcRUnregisterPushNotification(
1627		[in,out]	policy_handle		*handle,
1628		[in]		uint32			unknown[2]
1629		);
1630
1631	/*****************/
1632	/* Function 0x06 */
1633	void EcDummyRpc();
1634
1635	/*****************/
1636	/* Function 0x07 */
1637	void EcRGetDCName();
1638
1639	/*****************/
1640	/* Function 0x08 */
1641	void EcRNetGetDCName();
1642
1643	/*****************/
1644	/* Function 0x09 */
1645	void EcDoRpcExt();
1646}
1647
1648