summaryrefslogtreecommitdiffstats
path: root/public/sdk/inc/propstm.hxx
blob: e97ac516b71b95485043850e4d24f069ce08e8e1 (plain) (blame)
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
//+--------------------------------------------------------------------------
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1993
//
// File:        propstm.hxx
//
// Contents:    property set definitions
//
// History:     15-Jul-94       brianb  created
//              15-Aug-94       SethuR  revised
//              22-Feb-96      MikeHill Added several new member functions.
//              29-Feb-96      MikeHill Removed include of propmac.hxx
//                                      Moved 2 inlines to propstm.cxx
//              09-May-96      MikeHill Update _InitSection & _FixSummaryInformation
//                                      prototypes.
//              22-May-96      MikeHill Update prototypes for new OSVersion parameter,
//                                      and for callee-allocated property name buffers.
//              01-Jul-96      MikeHill - Modified to allow removal of Win32 SEH.
//                                      - Added byte-swapping support.
//              08-Nov-96      MikeHill Restore NT4 export signatures.
//
//
// Notes:       This implementation of property streams has no notion of
//              sections in a property set.
//
//---------------------------------------------------------------------------

#ifndef _PROPSTM_HXX_
#define _PROPSTM_HXX_

#include <stgvarb.hxx>  // CBaseStorageVariant declarations
#include <propset.h>    // Appendix B Property set structure definitions

#ifndef _MAC_NODOC
#include <ddeml.h>      // For CP_WINUNICODE
#include <objidl.h>
#endif

#include <propvar.h>
#include <byteordr.hxx>

typedef enum _PROPOP
{
    PROPOP_IGNORE = 1,
    PROPOP_DELETE = 2,
    PROPOP_INSERT = 3,
    PROPOP_MOVE   = 4,
    PROPOP_UPDATE = 5,
} PROPOP;

typedef struct tagPROPERTY_INFORMATION  // pinfo
{
    PROPID                   pid;

#ifdef KERNEL
    SERIALIZEDPROPERTYVALUE *pprop; // Only the Kernel serializes to temp buf
#endif

    ULONG                    cbprop;
    PROPOP                   operation;

} PROPERTY_INFORMATION;

#define VT_DICTIONARY	(VT_VECTOR | VT_ILLEGALMASKED)



// Validate the endian flags.  Either BIGENDIAN or LITTLEENDIAN, but not
// both, must be defined as 1.

#if !defined(BIGENDIAN) && !defined(LITTLEENDIAN)
#define LITTLEENDIAN 1
#endif



//+-------------------------------------------------------------------------
// Class:       CMappedStream
//
// Purpose:     defines the interface for a mapped Stream. This enables us to
//              have multiple implementations of the stream (one kernel mode
//              and multiple user mode implementations) without virtual methods
//              in kernel mode, and just one implementation for parsing the
//              contents of the stream (CPropertySetStream)
//--------------------------------------------------------------------------



//+-------------------------------------------------------------------------
// Class:       CMappedStream (user mode implementation)
//
// Note:        Implemented in CNtMappedStream for native property sets
//              Implemented in CDfMappedStream for DocFile property sets
//--------------------------------------------------------------------------

class CMappedStream
{
public:
    virtual VOID Open(IN NTPROP np, OUT LONG *phr) = 0;
    virtual VOID Close(OUT LONG *phr) = 0;
    virtual VOID ReOpen(IN OUT VOID **ppv, OUT LONG *phr) = 0;
    virtual VOID Quiesce(VOID) = 0;
    virtual VOID Map(IN BOOLEAN fCreate, OUT VOID **ppv) = 0;
    virtual VOID Unmap(IN BOOLEAN fFlush, IN OUT VOID **ppv) = 0;
    virtual VOID Flush(OUT LONG *phr) = 0;

    virtual ULONG GetSize(OUT LONG *phr) = 0;
    virtual VOID SetSize(IN ULONG cb, IN BOOLEAN fPersistent, IN OUT VOID **ppv, OUT LONG *phr) = 0;
    virtual NTSTATUS Lock(IN BOOLEAN fExclusive) = 0;
    virtual NTSTATUS Unlock(VOID) = 0;
    virtual VOID QueryTimeStamps(OUT STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const = 0;
    virtual BOOLEAN QueryModifyTime(OUT LONGLONG *pll) const = 0;
    virtual BOOLEAN QuerySecurity(OUT ULONG *pul) const = 0;

    virtual BOOLEAN IsWriteable(VOID) const = 0;
    virtual BOOLEAN IsModified(VOID) const = 0;
    virtual VOID SetModified(VOID) = 0;
    virtual HANDLE GetHandle(VOID) const = 0;
#if DBGPROP
    virtual BOOLEAN SetChangePending(BOOLEAN fChangePending) = 0;
    virtual BOOLEAN IsNtMappedStream(VOID) const = 0;
#endif
};


//+-------------------------------------------------------------------------
// Class:       CStreamChunkList
//
// Purpose:     Used to support efficient in-place compaction/expansion of
//              property set streams for CPropertySetStorage.
//--------------------------------------------------------------------------

struct CStreamChunk             // scnk
{
    ULONG       oOld;
    LONG        cbChange;
};

class CStreamChunkList          // scl
{
public:
    CStreamChunkList(ULONG cMaxChunks, CStreamChunk *ascnk);

    CStreamChunk *GetFreeChunk(OUT NTSTATUS *pstatus);
    CStreamChunk const *GetChunk(ULONG i) const;
    ULONG Count(VOID) const;
    VOID SortByStartAddress(VOID);
    VOID Delete(VOID);

#if DBGPROP
    VOID AssertCbChangeTotal(
            CStreamChunk const *pscnk,
            ULONG cbChangeTotal) const;
#endif

private:
    ULONG         _cMaxChunks;  // elements in _ascnk
    ULONG         _cChunks;     // elements allocated from _ascnk
    CStreamChunk *_ascnk;
    BOOLEAN       _fDelete;     // TRUE if _ascnk allocated from heap
};


//+-------------------------------------------------------------------------
// Class:       CPropertySetStream
//
// Purpose:     class for parsing the contents of a property set stream.
//--------------------------------------------------------------------------

#ifdef KERNEL
#define _MSTM(fn) _mstm.fn
#else
#define _MSTM(fn) _pmstm->fn
#endif

#ifdef KERNEL
#define CPSS_PROPHEADER             0x01  // has property header
#endif

#define CPSS_DOWNLEVEL              0x02  // Downlevel property set.
#define CPSS_PACKEDPROPERTIES       0x04  // Packed property values
#define CPSS_DOCUMENTSUMMARYINFO    0x08  // DocumentSummaryInfo propset
#define CPSS_USERDEFINEDPROPERTIES  0x10  // DocumentSummaryInfo: second section
#define CPSS_MULTIPLESECTIONS       0x20  // Multiple property sections
#define CPSS_USERDEFINEDDELETED	    0x40  // second section deleted
#define CPSS_VARIANTVECTOR          0x80  // Only for recursion


typedef enum tagLOADSTATE
{
    LOADSTATE_FAIL			= 0,	// load failed
    LOADSTATE_DONE			= 1,	// load succeeded
    LOADSTATE_BADFMTID			= 2,	// fmtid mismatch
    LOADSTATE_USERDEFINEDNOTFOUND	= 3,	// user defined section missing
    LOADSTATE_USERDEFINEDDELETE		= 4,	// delete user defined section
} LOADSTATE;


typedef enum tagPATCHOP
{
    PATCHOP_COMPUTESIZE			= 0,	// just compute expanded size
    PATCHOP_ALIGNLENGTHS		= 1,	// just align string lengths
    PATCHOP_EXPAND			= 2,	// expand property in-place
} PATCHOP;


// Create a macro that tells us the type
// of OLECHARs.
 
#ifdef OLE2ANSI
#define OLECHAR_IS_UNICODE FALSE
#else
#define OLECHAR_IS_UNICODE TRUE
#endif

// IsOLECHARString calls IsUnicodeString or IsAnsiString,
// whichever is appropriate for this compilation.

#if DBGPROP
    inline BOOLEAN IsOLECHARString( OLECHAR const *posz, ULONG cb )
    {
    #if OLECHAR_IS_UNICODE
        return( IsUnicodeString( posz, cb ));
    #else
        return( IsAnsiString( posz, cb ));
    #endif
    }
#endif


class CPropertySetStream
{
public:
    CPropertySetStream(
        IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
        IN CMappedStream *pmstm,    // mapped stream implementation
        IN PMemoryAllocator *pma    // caller's memory allocator
        );


    VOID Close(OUT NTSTATUS *pstatus);
    VOID SetValue(
                IN ULONG cprop,
                OPTIONAL IN OUT INDIRECTPROPERTY **ppip,
                IN PROPVARIANT const avar[],
                IN PROPERTY_INFORMATION *ppinfo,
                OUT NTSTATUS *pstatus);

    SERIALIZEDPROPERTYVALUE const *GetValue(IN PROPID pid, OUT ULONG *pcbprop,
                                            OUT NTSTATUS *pstatus);

    PROPID QueryPropid(IN OLECHAR const *poszName, OUT NTSTATUS *pstatus);
    USHORT GetCodePage(VOID) const { return(_CodePage); }

#if DBGPROP
    VOID Validate(OUT NTSTATUS *pstatus);
#else
    VOID Validate(OUT NTSTATUS *pstatus) const { *pstatus = STATUS_SUCCESS; }
#endif

    BOOLEAN IsModified(VOID) const { return(_MSTM(IsModified)()); }
    NTSTATUS Lock(IN BOOLEAN fExclusive) { return(_MSTM(Lock)(fExclusive)); }
    NTSTATUS Unlock(VOID) { return(_MSTM(Unlock)()); }
    VOID Flush(OUT NTSTATUS *pstatus)
    {
        PROPASSERT(PROPSET_BYTEORDER == _pph->wByteOrder);
        _MSTM(Flush)(pstatus);
        PROPASSERT(PROPSET_BYTEORDER == _pph->wByteOrder);
    }


    VOID Open(
        OPTIONAL IN GUID const *pfmtid,	// property set fmtid (create or Word95)
        OPTIONAL IN GUID const *pclsid, // CLASSID of propset code (create only)
	IN ULONG LocaleId,		// Locale Id (create only)
        OPTIONAL OUT ULONG *pOSVersion, // OS Version field in the propset header
        IN USHORT CodePage,             // CodePage of propset (create only)
        OUT NTSTATUS *pstatus);         // Return code.
    ULONG ReOpen(OUT NTSTATUS *pstatus);

    // Property Dictionary Lookup and Manipulation.
    BOOLEAN EnumeratePropids(
                IN OUT ULONG *pkey,
                IN OUT ULONG *pcprop,
                OUT PROPID *apid,
                OUT NTSTATUS *pstatus);

    OLECHAR *DuplicatePropertyName(
                IN OLECHAR const *poszName,
                IN ULONG cbName,
                OUT NTSTATUS *pstatus) const;

    BOOLEAN QueryPropertyNameBuf(
                IN PROPID pid,
                OUT OLECHAR *aocName,
                IN OUT ULONG *pcbName,
                OUT NTSTATUS *pstatus);

    BOOLEAN QueryPropertyNames(
                IN ULONG cprop,
                IN PROPID const *apid,
                OUT OLECHAR *aposz[],
                OUT NTSTATUS *pstatus);

    VOID SetPropertyNames(
                IN ULONG cprop,
                IN PROPID const *apid,
                IN OPTIONAL OLECHAR const * const aposz[],
                OUT NTSTATUS *pstatus);

    VOID QueryPropertySet(OUT STATPROPSETSTG *pspss, OUT NTSTATUS *pstatus) const;
    VOID SetClassId(IN GUID const *pclsid, OUT NTSTATUS *pstatus);
    HANDLE GetHandle(VOID) const { return(_MSTM(GetHandle)()); }
    PMemoryAllocator *GetAllocator(VOID) const { return(_pma); }

    VOID ByteSwapHeaders( IN PROPERTYSETHEADER *psh,
                          IN ULONG cbstm,
                          OUT NTSTATUS *pstatus );

    // Convert a character count to a byte count based on the _CodePage

    ULONG     CCh2CB( ULONG cch ) const
                {
                    return( _CodePage == CP_WINUNICODE
                            ? cch * sizeof( WCHAR )
                            : cch * sizeof( CHAR )
                          );
                }

    // Convert a byte count to a character count based on the _CodePage
    // If for some reason the given byte-count is odd, the return
    // value won't include that last half-character.

    ULONG     CB2CCh( ULONG cb ) const
                {
                    return( _CodePage == CP_WINUNICODE
                            ? cb / sizeof( WCHAR )
                            : cb / sizeof( CHAR )
                          );
                }


private:

    // Private methods.

    VOID      _Create(
                    IN GUID const *pfmtid,
                    OPTIONAL IN GUID const *pclsid,
		    IN ULONG LocaleId,
                    IN USHORT CodePage,
		    IN LOADSTATE LoadState,
                    OUT NTSTATUS *pstatus);
    BOOLEAN   _HasPropHeader(VOID) const { return(TRUE); }
    BOOLEAN   _CreateUserDefinedSection(
		    IN LOADSTATE LoadState,
		    IN ULONG LocaleId,
                    OUT NTSTATUS *pstatus);
    VOID      _InitSection(
		    IN FORMATIDOFFSET *pfo,
		    IN ULONG LocaleId,
                    IN BOOL  fCreateDictionary );
    VOID      _FixSummaryInformation(IN OUT ULONG *pcbstm, OUT NTSTATUS *pstatus);
    VOID      _FixPackedPropertySet(OUT NTSTATUS *pstatus);

    BOOLEAN   _FixDocPartsVector(
		    IN PATCHOP PatchOp,
		    IN OUT SERIALIZEDPROPERTYVALUE *pprop,
		    OUT ULONG *pcbprop);
    BOOLEAN   _FixDocPartsElements(
		    IN PATCHOP PatchOp,
		    IN ULONG cString,
		    OUT VOID *pvDst,
		    IN VOID UNALIGNED const *pvSrc,
		    OUT ULONG *pcbprop);

    BOOLEAN   _FixHeadingPairVector(
		    IN PATCHOP PatchOp,
		    IN OUT SERIALIZEDPROPERTYVALUE *pprop,
		    OUT ULONG *pcbprop);
    BOOLEAN   _FixHeadingPairElements(
		    IN PATCHOP PatchOp,
		    IN ULONG cPairs,
		    OUT SERIALIZEDPROPERTYVALUE *ppropDst,
		    IN SERIALIZEDPROPERTYVALUE UNALIGNED const *ppropSrc,
		    OUT ULONG *pcbprop);

    BOOLEAN   _IsMapped(VOID) const { return(_pph != NULL); }
    LOADSTATE _LoadHeader(OPTIONAL IN GUID const *pfmtid, IN BYTE Mode,
                          OUT NTSTATUS *pstatus);

    PROPERTYSECTIONHEADER *_LoadPropertyOffsetPointers(
                    OUT PROPERTYIDOFFSET **pppo,
                    OUT PROPERTYIDOFFSET **pppoMax,
                    OUT NTSTATUS *pstatus);

    SERIALIZEDPROPERTYVALUE *_LoadProperty(IN PROPID pid, OUT ULONG *pcbprop,
                                           OUT NTSTATUS *pstatus);
    PROPERTYSECTIONHEADER *_GetSectionHeader(VOID) const;
    VOID _SearchForCodePage( OUT NTSTATUS *pstatus);
    PROPERTYSECTIONHEADER *_GetSectionHeader(IN ULONG iSection, OUT NTSTATUS *pstatus);
    FORMATIDOFFSET *_GetFormatidOffset(IN ULONG iSection) const;

    VOID     *_MapOffsetToAddress(IN ULONG oOffset) const;
    ULONG     _MapAddressToOffset(IN VOID const *pvAddr) const;

    VOID     *_MapAbsOffsetToAddress(IN ULONG oAbsolute) const;
    ULONG     _MapAddressToAbsOffset(IN VOID const *pvAddr) const;

    ULONG     _GetNewOffset(
                    IN CStreamChunkList const *pscl,
                    IN ULONG oOld) const;

    ULONG     _DictionaryEntryLength(
                    IN ENTRY UNALIGNED const * pent ) const;


    ULONG     _DictionaryLength(
                    IN DICTIONARY const *pdy,
                    IN ULONG cbbuf,
                    OUT NTSTATUS *pstatus) const;

    ENTRY UNALIGNED
             *_NextDictionaryEntry(
                    IN ENTRY UNALIGNED const * pent ) const;

    ULONG     _CountFreePropertyOffsets(OUT NTSTATUS *pstatus);

    VOID      _DeleteMovePropertyOffsets(
                    IN PROPERTY_INFORMATION const *apinfo,
                    IN ULONG cprop,
                    OUT NTSTATUS *pstatus);

    VOID      _UpdatePropertyOffsets(
                    IN CStreamChunkList const *pscl,
                    OUT NTSTATUS *pstatus);

    VOID      _InsertMovePropertyOffsets(
                    IN PROPERTY_INFORMATION const *apinfo,
                    IN ULONG cprop,
                    IN ULONG oInsert,
                    IN ULONG cpoReserve,
                    OUT NTSTATUS *pstatus);

    VOID      _CompactStream(IN CStreamChunkList const *pscl);

    VOID      _CompactChunk(
                    IN CStreamChunk const *pscnk,
                    IN LONG cbChangeTotal,
                    IN ULONG oOldNext);

    VOID      _PatchSectionOffsets(LONG cbChange);

    ULONG     _ComputeMinimumSize(ULONG cbstm, OUT NTSTATUS *pstatus);
#if DBGPROP
    VOID      _ValidateStructure(OUT NTSTATUS *pstatus);
    VOID      _ValidateProperties(OUT NTSTATUS *pstatus) const;
    VOID      _ValidateDictionary(OUT NTSTATUS *pstatus);
    VOID      _StatusCorruption(char *szReason, OUT NTSTATUS *pstatus) const;
#else
    VOID      _StatusCorruption(OUT NTSTATUS *pstatus) const;
#endif
    VOID      _SetModified(VOID) { _MSTM(SetModified)(); }

#if DBGPROP
public:		// public for fnEntryNameCompare only!
#endif
    BOOLEAN   _ComparePropertyNames(
		    IN VOID const *pvName1,
		    IN VOID const *pvName2,
                    IN BOOL fSameByteOrder,
		    IN ULONG cbName) const;
#if DBGPROP
private:
#endif

    BOOLEAN   _PropertyNameLength(
                    IN VOID const *pvName,
                    OUT ULONG *pcbName) const;


    VOID      _MultiByteToWideChar(
                    IN CHAR const *pch,
                    IN ULONG cb,
                    IN USHORT CodePage,
                    OUT WCHAR **ppwc,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus);

    VOID      _OLECHARToWideChar(
                    IN OLECHAR const *poc,
                    IN ULONG cb,
                    IN USHORT CodePage,
                    OUT WCHAR **ppwc,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus)
    {
        PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );

        // Since OLECHAR may be MultiByte or WideChar for this
        // compilation, explicitely cast 'poc' to a CHAR* to prevent
        // a compilation error.

        _MultiByteToWideChar( (CHAR*) poc, cb, CodePage, ppwc, pcb, pstatus );
    }

    VOID      _MultiByteToOLECHAR(
                    IN CHAR const *pch,
                    IN ULONG cb,
                    IN USHORT CodePage,
                    OUT OLECHAR **ppoc,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus)
    {
        PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );

        // Since OLECHAR may be MultiByte or WideChar for this
        // compilation, explicitely cast 'ppoc' to a WCHAR** to prevent
        // a compilation error.

        _MultiByteToWideChar( pch, cb, CodePage, (WCHAR**)ppoc, pcb, pstatus );
    }

    VOID      _WideCharToMultiByte(
                    IN WCHAR const *pwc,
                    IN ULONG cch,
                    IN USHORT CodePage,
                    OUT CHAR **ppch,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus);

    VOID      _OLECHARToMultiByte(
                    IN OLECHAR const *poc,
                    IN ULONG cch,
                    IN USHORT CodePage,
                    OUT CHAR **ppch,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus)
    {
        PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );

        // Since OLECHAR may be MultiByte or WideChar for this
        // compilation, explicitely cast 'poc' to a WCHAR* to prevent
        // a compilation error.

        _WideCharToMultiByte( (WCHAR*) poc, cch, CodePage, ppch, pcb, pstatus );
    }

    VOID      _WideCharToOLECHAR(
                    IN WCHAR const *pwc,
                    IN ULONG cch,
                    IN USHORT CodePage,
                    OUT OLECHAR **ppoc,
                    OUT ULONG *pcb,
                    OUT NTSTATUS *pstatus)
    {
        PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );

        // Since OLECHAR may be MultiByte or WideChar for this
        // compilation, explicitely cast 'ppoc' to a CHAR** to prevent
        // a compilation error.

        _WideCharToMultiByte( pwc, cch, CodePage, (CHAR**) ppoc, pcb, pstatus );
    }


    PROPERTYSETHEADER     *_pph;
    ULONG                  _oSection;
    ULONG                  _cSection;
    USHORT                 _CodePage;
    BYTE                   _Flags;
    BYTE                   _State;
    ULONG		   _cbTail;
    PMemoryAllocator      *_pma;
    CMappedStream         *_pmstm;        // user mode: replacable virtual class
};


#ifdef WINNT
VOID CopyPropertyValue(
        IN OPTIONAL SERIALIZEDPROPERTYVALUE const *pprop,
        IN ULONG cb,
        OUT SERIALIZEDPROPERTYVALUE *ppropDst,
        OUT ULONG *pcb);

ULONG PropertyLengthAsVariant(
        IN SERIALIZEDPROPERTYVALUE const *pprop,
        IN ULONG cbprop,
	IN USHORT CodePage,
        IN BYTE flags);

ULONG PropertyLengthAsVariantNoEH(	// No NT Exception Handling version
        IN SERIALIZEDPROPERTYVALUE const *pprop,
        IN ULONG cbprop,
	IN USHORT CodePage,
        IN BYTE flags,
        OUT NTSTATUS *pstatus);

#endif

ULONG PropertyLength(
        IN SERIALIZEDPROPERTYVALUE const *pprop,
        IN ULONG cbbuf,
        IN BYTE flags);

ULONG PropertyLengthNoEH(            // No NT Exception Handling version
        IN SERIALIZEDPROPERTYVALUE const *pprop,
        IN ULONG cbbuf,
        IN BYTE flags,
        OUT NTSTATUS *pstatus);



//  ------------
//  PBS Routines
//  ------------

// PBS routines (Property Byte Swap) perform specialized byte-swapping
// in the big-endian build, and do nothing in the little-endian
// build (in which case they are inlined).

#ifdef BIGENDIAN

VOID PBSCopy( OUT VOID *pvDest,
              IN VOID const *pvSource,
              IN ULONG cbCopy,
              IN LONG cbByteSwap );

VOID PBSAllocAndCopy( OUT VOID **ppvDest,
                      IN VOID const *pvSource,
                      ULONG cbSize,
                      LONG cbByteSwap,
                      OUT NTSTATUS *pstatus);

VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
                      OUT WCHAR** ppwszBuffer,
                      OUT NTSTATUS *pstatus );

VOID PBSBuffer( IN OUT VOID *pv,
                IN ULONG cbSize,
                IN ULONG cbByteSwap );

#else // Little-endian build

inline VOID PBSCopy( OUT VOID *pvDest,
                     IN VOID const *pvSource,
                     IN ULONG cbCopy,
                     IN LONG cbByteSwap )
{
}

inline VOID PBSAllocAndCopy( OUT VOID **ppvDest,
                             IN VOID const *pvSource,
                             ULONG cbSize,
                             LONG cbByteSwap,
                             OUT NTSTATUS *pstatus)
{
    *pstatus = STATUS_SUCCESS;
}

inline VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
                             OUT WCHAR** ppwszBuffer,
                             OUT NTSTATUS *pstatus )
{
    *pstatus = STATUS_SUCCESS;
}

inline VOID PBSBuffer( IN OUT VOID *pv,
                       IN ULONG cbSize,
                       IN ULONG cbByteSwap )
{
}

#endif // #ifdef BIGENDIAN ... #else


#endif // _PROPSTM_HXX_