Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

706 lines
24 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (c) Microsoft Corporation. All rights reserved.
  5. //
  6. // File: propstm.hxx
  7. //
  8. // Contents: property set definitions
  9. //
  10. // History: 15-Jul-94 brianb created
  11. // 15-Aug-94 SethuR revised
  12. // 22-Feb-96 MikeHill Added several new member functions.
  13. // 29-Feb-96 MikeHill Removed include of propmac.hxx
  14. // Moved 2 inlines to propstm.cxx
  15. // 09-May-96 MikeHill Update _InitSection & _FixSummaryInformation
  16. // prototypes.
  17. // 22-May-96 MikeHill Update prototypes for new OSVersion parameter,
  18. // and for callee-allocated property name buffers.
  19. // 01-Jul-96 MikeHill - Modified to allow removal of Win32 SEH.
  20. // - Added byte-swapping support.
  21. // 07-Feb-97 Danl - Changed CMappedStream to IMappedStream.
  22. //
  23. //
  24. // Notes: This implementation of property streams has no notion of
  25. // sections in a property set.
  26. //
  27. //---------------------------------------------------------------------------
  28. #ifndef _PROPSTM_HXX_
  29. #define _PROPSTM_HXX_
  30. #include <stgvarb.hxx> // CBaseStorageVariant declarations
  31. #include <propset.h> // Appendix B Property set structure definitions
  32. #ifndef _MAC_NODOC
  33. #include <ddeml.h> // For CP_WINUNICODE
  34. #include <objidl.h>
  35. #endif
  36. #include <propvar.h>
  37. #include <byteordr.hxx>
  38. typedef enum _PROPOP
  39. {
  40. PROPOP_IGNORE = 1,
  41. PROPOP_DELETE = 2,
  42. PROPOP_INSERT = 3,
  43. PROPOP_MOVE = 4,
  44. PROPOP_UPDATE = 5,
  45. } PROPOP;
  46. typedef struct tagPROPERTY_INFORMATION // pinfo
  47. {
  48. PROPID pid;
  49. #ifdef KERNEL
  50. SERIALIZEDPROPERTYVALUE *pprop; // Only the Kernel serializes to temp buf
  51. #endif
  52. ULONG cbprop;
  53. PROPOP operation;
  54. } PROPERTY_INFORMATION;
  55. #define VT_DICTIONARY (VT_VECTOR | VT_ILLEGALMASKED)
  56. // Default the endian-ness to Little
  57. #if !defined(BIGENDIAN) && !defined(LITTLEENDIAN)
  58. #define LITTLEENDIAN 1
  59. #endif
  60. //+-------------------------------------------------------------------------
  61. // Class: IMappedStream
  62. //
  63. // Purpose: defines the interface for a mapped Stream. This enables us to
  64. // have multiple implementations of the stream (one kernel mode
  65. // and multiple user mode implementations) without virtual methods
  66. // in kernel mode, and just one implementation for parsing the
  67. // contents of the stream (CPropertySetStream)
  68. //--------------------------------------------------------------------------
  69. //+-------------------------------------------------------------------------
  70. // Class: IMappedStream (user mode implementation)
  71. //
  72. // Note: Implemented in CNtMappedStream for native property sets
  73. // Implemented in CDfMappedStream for DocFile property sets
  74. //--------------------------------------------------------------------------
  75. class IMappedStream : public IUnknown
  76. {
  77. public:
  78. virtual STDMETHODIMP_(VOID) Open(IN NTPROP np, OUT LONG *phr) = 0;
  79. virtual STDMETHODIMP_(VOID) Close(OUT LONG *phr) = 0;
  80. virtual STDMETHODIMP_(VOID) ReOpen(IN OUT VOID **ppv, OUT LONG *phr) = 0;
  81. virtual STDMETHODIMP_(VOID) Quiesce(VOID) = 0;
  82. virtual STDMETHODIMP_(VOID) Map(IN BOOLEAN fCreate, OUT VOID **ppv) = 0;
  83. virtual STDMETHODIMP_(VOID) Unmap(IN BOOLEAN fFlush, IN OUT VOID **ppv) = 0;
  84. virtual STDMETHODIMP_(VOID) Flush(OUT LONG *phr) = 0;
  85. virtual STDMETHODIMP_(ULONG) GetSize(OUT LONG *phr) = 0;
  86. virtual STDMETHODIMP_(VOID) SetSize(IN ULONG cb, IN BOOLEAN fPersistent, IN OUT VOID **ppv, OUT LONG *phr) = 0;
  87. virtual STDMETHODIMP_(NTSTATUS) Lock(IN BOOLEAN fExclusive) = 0;
  88. virtual STDMETHODIMP_(NTSTATUS) Unlock(VOID) = 0;
  89. virtual STDMETHODIMP_(VOID) QueryTimeStamps(OUT STATPROPSETSTG *pspss, BOOLEAN fNonSimple) const = 0;
  90. virtual STDMETHODIMP_(BOOLEAN) QueryModifyTime(OUT LONGLONG *pll) const = 0;
  91. virtual STDMETHODIMP_(BOOLEAN) QuerySecurity(OUT ULONG *pul) const = 0;
  92. virtual STDMETHODIMP_(BOOLEAN) IsWriteable(VOID) const = 0;
  93. virtual STDMETHODIMP_(BOOLEAN) IsModified(VOID) const = 0;
  94. virtual STDMETHODIMP_(VOID) SetModified(OUT LONG *phr) = 0;
  95. virtual STDMETHODIMP_(HANDLE) GetHandle(VOID) const = 0;
  96. #if DBGPROP
  97. virtual STDMETHODIMP_(BOOLEAN) SetChangePending(BOOLEAN fChangePending) = 0;
  98. virtual STDMETHODIMP_(BOOLEAN) IsNtMappedStream(VOID) const = 0;
  99. #endif
  100. };
  101. //+-------------------------------------------------------------------------
  102. // Class: CStreamChunkList
  103. //
  104. // Purpose: Used to support efficient in-place compaction/expansion of
  105. // property set streams for CPropertySetStorage.
  106. //--------------------------------------------------------------------------
  107. struct CStreamChunk // scnk
  108. {
  109. ULONG oOld;
  110. LONG cbChange;
  111. };
  112. class CStreamChunkList // scl
  113. {
  114. public:
  115. CStreamChunkList(ULONG cMaxChunks, CStreamChunk *ascnk);
  116. CStreamChunk *GetFreeChunk(OUT NTSTATUS *pstatus);
  117. CStreamChunk const *GetChunk(ULONG i) const;
  118. ULONG Count(VOID) const;
  119. VOID SortByStartAddress(VOID);
  120. VOID Delete(VOID);
  121. #if DBGPROP
  122. VOID AssertCbChangeTotal(
  123. CStreamChunk const *pscnk,
  124. ULONG cbChangeTotal) const;
  125. #endif
  126. private:
  127. ULONG _cMaxChunks; // elements in _ascnk
  128. ULONG _cChunks; // elements allocated from _ascnk
  129. CStreamChunk *_ascnk;
  130. BOOLEAN _fDelete; // TRUE if _ascnk allocated from heap
  131. };
  132. //+-------------------------------------------------------------------------
  133. // Class: CPropertySetStream
  134. //
  135. // Purpose: class for parsing the contents of a property set stream.
  136. //--------------------------------------------------------------------------
  137. #ifdef KERNEL
  138. #define _MSTM(fn) _mstm.fn
  139. #else
  140. #define _MSTM(fn) _pmstm->fn
  141. #endif
  142. #ifdef KERNEL
  143. #define CPSS_PROPHEADER 0x01 // has property header
  144. #endif
  145. #define CPSS_DOWNLEVEL 0x02 // Downlevel property set.
  146. #define CPSS_PACKEDPROPERTIES 0x04 // Packed property values
  147. #define CPSS_DOCUMENTSUMMARYINFO 0x08 // DocumentSummaryInfo propset
  148. #define CPSS_USERDEFINEDPROPERTIES 0x10 // DocumentSummaryInfo: second section
  149. #define CPSS_MULTIPLESECTIONS 0x20 // Multiple property sections
  150. #define CPSS_USERDEFINEDDELETED 0x40 // second section deleted
  151. #define CPSS_VARIANTVECTOR 0x80 // Only for recursion
  152. typedef enum tagLOADSTATE
  153. {
  154. LOADSTATE_FAIL = 0, // load failed
  155. LOADSTATE_DONE = 1, // load succeeded
  156. LOADSTATE_BADFMTID = 2, // fmtid mismatch
  157. LOADSTATE_USERDEFINEDNOTFOUND = 3, // user defined section missing
  158. LOADSTATE_USERDEFINEDDELETE = 4, // delete user defined section
  159. } LOADSTATE;
  160. typedef enum tagPATCHOP
  161. {
  162. PATCHOP_COMPUTESIZE = 0, // just compute expanded size
  163. PATCHOP_ALIGNLENGTHS = 1, // just align string lengths
  164. PATCHOP_EXPAND = 2, // expand property in-place
  165. } PATCHOP;
  166. // Create a macro that tells us the type
  167. // of OLECHARs.
  168. #ifdef OLE2ANSI
  169. #define OLECHAR_IS_UNICODE FALSE
  170. #else
  171. #define OLECHAR_IS_UNICODE TRUE
  172. #endif
  173. // IsOLECHARString calls IsUnicodeString or IsAnsiString,
  174. // whichever is appropriate for this compilation.
  175. #if DBGPROP
  176. inline BOOLEAN IsOLECHARString( OLECHAR const *posz, ULONG cb )
  177. {
  178. #if OLECHAR_IS_UNICODE
  179. return( IsUnicodeString( posz, cb ));
  180. #else
  181. return( IsAnsiString( posz, cb ));
  182. #endif
  183. }
  184. #endif
  185. class CPropertySetStream
  186. {
  187. public:
  188. CPropertySetStream(
  189. IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
  190. IN IMappedStream *pmstm, // mapped stream implementation
  191. IN PMemoryAllocator *pma // caller's memory allocator
  192. );
  193. VOID Close(OUT NTSTATUS *pstatus);
  194. VOID SetValue(
  195. IN ULONG cprop,
  196. OPTIONAL IN OUT INDIRECTPROPERTY **ppip,
  197. IN PROPVARIANT const avar[],
  198. IN PROPERTY_INFORMATION *ppinfo,
  199. OUT OPTIONAL USHORT *pCodePage,
  200. OUT NTSTATUS *pstatus);
  201. SERIALIZEDPROPERTYVALUE const *GetValue(IN PROPID pid, OUT ULONG *pcbprop,
  202. OUT NTSTATUS *pstatus);
  203. PROPID QueryPropid(IN OLECHAR const *poszName, OUT NTSTATUS *pstatus);
  204. USHORT GetCodePage(VOID) const { return(_CodePage); }
  205. DWORD GetBehavior(VOID) const{ return(_grfBehavior); }
  206. WORD GetFormatVersion() const{ PROPASSERT(_IsMapped()); return(WORD) (NULL == _pph ? PROPSET_WFORMAT_ORIGINAL : _pph->wFormat ); }
  207. #if DBGPROP
  208. VOID Validate(OUT NTSTATUS *pstatus);
  209. #else
  210. VOID Validate(OUT NTSTATUS *pstatus) const { *pstatus = STATUS_SUCCESS; }
  211. #endif
  212. BOOLEAN IsModified(VOID) const { return(_MSTM(IsModified)()); }
  213. NTSTATUS Lock(IN BOOLEAN fExclusive) { return(_MSTM(Lock)(fExclusive)); }
  214. NTSTATUS Unlock(VOID) { return(_MSTM(Unlock)()); }
  215. VOID Flush(OUT NTSTATUS *pstatus)
  216. {
  217. PROPASSERT(PROPSET_BYTEORDER == _pph->wByteOrder);
  218. _MSTM(Flush)(pstatus);
  219. PROPASSERT(PROPSET_BYTEORDER == _pph->wByteOrder);
  220. }
  221. VOID Open(
  222. OPTIONAL IN GUID const *pfmtid, // property set fmtid (create or Word95)
  223. OPTIONAL IN GUID const *pclsid, // CLASSID of propset code (create only)
  224. IN ULONG LocaleId, // Locale Id (create only)
  225. OPTIONAL OUT ULONG *pOSVersion, // OS Version field in the propset header
  226. IN USHORT CodePage, // CodePage of propset (create only)
  227. IN DWORD grfBehavior, // PROPSET_BEHAVIOR_*
  228. OUT NTSTATUS *pstatus); // Return code.
  229. ULONG ReOpen(OUT NTSTATUS *pstatus);
  230. // Property Dictionary Lookup and Manipulation.
  231. BOOLEAN EnumeratePropids(
  232. IN OUT ULONG *pkey,
  233. IN OUT ULONG *pcprop,
  234. OUT PROPID *apid,
  235. OUT NTSTATUS *pstatus);
  236. OLECHAR *DuplicatePropertyName(
  237. IN OLECHAR const *poszName,
  238. OUT NTSTATUS *pstatus) const;
  239. #if 0
  240. BOOLEAN QueryPropertyNameBuf(
  241. IN PROPID pid,
  242. OUT OLECHAR *aocName,
  243. IN OUT ULONG *pcbName,
  244. OUT NTSTATUS *pstatus);
  245. #endif
  246. BOOLEAN QueryPropertyNames(
  247. IN ULONG cprop,
  248. IN PROPID const *apid,
  249. OUT OLECHAR *aposz[],
  250. OUT NTSTATUS *pstatus);
  251. VOID SetPropertyNames(
  252. IN ULONG cprop,
  253. IN PROPID const *apid,
  254. IN OPTIONAL OLECHAR const * const aposz[],
  255. OUT NTSTATUS *pstatus);
  256. VOID QueryPropertySet(OUT STATPROPSETSTG *pspss, OUT NTSTATUS *pstatus) const;
  257. VOID SetClassId(IN GUID const *pclsid, OUT NTSTATUS *pstatus);
  258. HANDLE GetHandle(VOID) const { return(_MSTM(GetHandle)()); }
  259. PMemoryAllocator *GetAllocator(VOID) const { return(_pma); }
  260. VOID ByteSwapHeaders( IN PROPERTYSETHEADER *psh,
  261. IN ULONG cbstm,
  262. OUT NTSTATUS *pstatus );
  263. // Convert a character count to a byte count based on the _CodePage
  264. ULONG CCh2CB( ULONG cch ) const
  265. {
  266. return( _CodePage == CP_WINUNICODE
  267. ? cch * sizeof( WCHAR )
  268. : cch * sizeof( CHAR )
  269. );
  270. }
  271. // Convert a byte count to a character count based on the _CodePage
  272. // If for some reason the given byte-count is odd, the return
  273. // value won't include that last half-character.
  274. ULONG CB2CCh( ULONG cb ) const
  275. {
  276. return( _CodePage == CP_WINUNICODE
  277. ? cb / sizeof( WCHAR )
  278. : cb / sizeof( CHAR )
  279. );
  280. }
  281. private:
  282. // Private methods.
  283. VOID _Create(
  284. IN GUID const *pfmtid,
  285. OPTIONAL IN GUID const *pclsid,
  286. IN ULONG LocaleId,
  287. IN USHORT CodePage,
  288. IN LOADSTATE LoadState,
  289. IN DWORD grfBehavior,
  290. OUT NTSTATUS *pstatus);
  291. BOOLEAN _HasPropHeader(VOID) const { return(TRUE); }
  292. BOOLEAN _CreateUserDefinedSection(
  293. IN LOADSTATE LoadState,
  294. IN ULONG LocaleId,
  295. OUT NTSTATUS *pstatus);
  296. VOID _InitSection(
  297. IN FORMATIDOFFSET *pfo,
  298. IN ULONG LocaleId,
  299. IN BOOL fCreateDictionary );
  300. VOID _FixUnalignedUDPropSet( ULONG *pcbstm,
  301. NTSTATUS *pstatus );
  302. VOID _FixSummaryInformation(IN OUT ULONG *pcbstm, OUT NTSTATUS *pstatus);
  303. VOID _FixPackedPropertySet(OUT NTSTATUS *pstatus);
  304. BOOLEAN _FixDocPartsVector(
  305. IN PATCHOP PatchOp,
  306. IN OUT SERIALIZEDPROPERTYVALUE *pprop,
  307. IN OUT ULONG *pcbprop);
  308. BOOLEAN _FixDocPartsElements(
  309. IN PATCHOP PatchOp,
  310. IN ULONG cString,
  311. OUT VOID *pvDst,
  312. IN VOID UNALIGNED const *pvSrc,
  313. IN OUT ULONG *pcbprop);
  314. BOOLEAN _FixHeadingPairVector(
  315. IN PATCHOP PatchOp,
  316. IN OUT SERIALIZEDPROPERTYVALUE *pprop,
  317. IN OUT ULONG *pcbprop);
  318. BOOLEAN _FixHeadingPairElements(
  319. IN PATCHOP PatchOp,
  320. IN ULONG cPairs,
  321. OUT SERIALIZEDPROPERTYVALUE *ppropDst,
  322. IN SERIALIZEDPROPERTYVALUE UNALIGNED const *ppropSrc,
  323. IN OUT ULONG *pcbprop);
  324. BOOLEAN _IsMapped(VOID) const { return(_pph != NULL); }
  325. BOOLEAN _IsCaseSensitive(VOID) const { return( (BOOLEAN) ((PROPSET_BEHAVIOR_CASE_SENSITIVE & _grfBehavior) ? TRUE : FALSE )); }
  326. BOOLEAN _SupportsLongNames(VOID) const { return( GetFormatVersion() >= PROPSET_WFORMAT_LONG_NAMES ); }
  327. LOADSTATE _LoadHeader(OPTIONAL IN GUID const *pfmtid, IN BYTE Mode,
  328. OUT NTSTATUS *pstatus);
  329. PROPERTYSECTIONHEADER *_LoadPropertyOffsetPointers(
  330. OUT PROPERTYIDOFFSET **pppo,
  331. OUT PROPERTYIDOFFSET **pppoMax,
  332. OUT NTSTATUS *pstatus);
  333. SERIALIZEDPROPERTYVALUE *_LoadProperty(IN PROPID pid, OUT ULONG *pcbprop,
  334. OUT NTSTATUS *pstatus);
  335. PROPERTYSECTIONHEADER *_GetSectionHeader(VOID) const;
  336. VOID _SearchForCodePage( OUT NTSTATUS *pstatus);
  337. PROPERTYSECTIONHEADER *_GetSectionHeader(IN ULONG iSection, OUT NTSTATUS *pstatus);
  338. FORMATIDOFFSET *_GetFormatidOffset(IN ULONG iSection) const;
  339. VOID *_MapOffsetToAddress(IN ULONG oOffset) const;
  340. ULONG _MapAddressToOffset(IN VOID const *pvAddr) const;
  341. VOID *_MapAbsOffsetToAddress(IN ULONG oAbsolute) const;
  342. ULONG _MapAddressToAbsOffset(IN VOID const *pvAddr) const;
  343. ULONG _GetNewOffset(
  344. IN CStreamChunkList const *pscl,
  345. IN ULONG oOld) const;
  346. ULONG _DictionaryEntryLength(
  347. IN ENTRY UNALIGNED const * pent ) const;
  348. ULONG _DictionaryLength(
  349. IN DICTIONARY const *pdy,
  350. IN ULONG cbbuf,
  351. OUT NTSTATUS *pstatus) const;
  352. BOOLEAN _IsLocalizationSettable(
  353. OUT NTSTATUS *pstatus);
  354. ENTRY UNALIGNED
  355. *_NextDictionaryEntry(
  356. IN ENTRY UNALIGNED const * pent ) const;
  357. ULONG _CountFreePropertyOffsets(OUT NTSTATUS *pstatus);
  358. VOID _DeleteMovePropertyOffsets(
  359. IN PROPERTY_INFORMATION const *apinfo,
  360. IN ULONG cprop,
  361. OUT NTSTATUS *pstatus);
  362. VOID _UpdatePropertyOffsets(
  363. IN CStreamChunkList const *pscl,
  364. OUT NTSTATUS *pstatus);
  365. VOID _InsertMovePropertyOffsets(
  366. IN PROPERTY_INFORMATION const *apinfo,
  367. IN ULONG cprop,
  368. IN ULONG oInsert,
  369. IN ULONG cpoReserve,
  370. OUT NTSTATUS *pstatus);
  371. VOID _CompactStream(IN CStreamChunkList const *pscl);
  372. VOID _CompactChunk(
  373. IN CStreamChunk const *pscnk,
  374. IN LONG cbChangeTotal,
  375. IN ULONG oOldNext);
  376. VOID _PatchSectionOffsets(LONG cbChange);
  377. ULONG _ComputeMinimumSize(ULONG cbstm, OUT NTSTATUS *pstatus);
  378. #if DBGPROP
  379. VOID _ValidateStructure(OUT NTSTATUS *pstatus);
  380. VOID _ValidateProperties(OUT NTSTATUS *pstatus) const;
  381. VOID _ValidateDictionary(OUT NTSTATUS *pstatus);
  382. VOID _StatusCorruption(char *szReason, OUT NTSTATUS *pstatus) const;
  383. #else
  384. VOID _StatusCorruption(OUT NTSTATUS *pstatus) const;
  385. #endif
  386. VOID _SetModified(OUT NTSTATUS *pstatus) { _MSTM(SetModified)(pstatus); }
  387. #if DBGPROP
  388. public: // public for fnEntryNameCompare only!
  389. #endif
  390. BOOLEAN _ComparePropertyNames(
  391. IN VOID const *pvName1,
  392. IN VOID const *pvName2,
  393. IN BOOL fSameByteOrder,
  394. IN ULONG cbName,
  395. OUT NTSTATUS *pstatus ) const;
  396. #if DBGPROP
  397. private:
  398. #endif
  399. WORD _PropertyNameLength(
  400. IN VOID const *pvName,
  401. OUT ULONG *pcbName) const;
  402. VOID _MultiByteToWideChar(
  403. IN CHAR const *pch,
  404. IN ULONG cb,
  405. IN USHORT CodePage,
  406. OUT WCHAR **ppwc,
  407. OUT ULONG *pcb,
  408. OUT NTSTATUS *pstatus);
  409. VOID _OLECHARToWideChar(
  410. IN OLECHAR const *poc,
  411. IN ULONG cb,
  412. IN USHORT CodePage,
  413. OUT WCHAR **ppwc,
  414. OUT ULONG *pcb,
  415. OUT NTSTATUS *pstatus)
  416. {
  417. PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );
  418. // Since OLECHAR may be MultiByte or WideChar for this
  419. // compilation, explicitely cast 'poc' to a CHAR* to prevent
  420. // a compilation error.
  421. _MultiByteToWideChar( (CHAR*) poc, cb, CodePage, ppwc, pcb, pstatus );
  422. }
  423. VOID _MultiByteToOLECHAR(
  424. IN CHAR const *pch,
  425. IN ULONG cb,
  426. IN USHORT CodePage,
  427. OUT OLECHAR **ppoc,
  428. OUT ULONG *pcb,
  429. OUT NTSTATUS *pstatus)
  430. {
  431. PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );
  432. // Since OLECHAR may be MultiByte or WideChar for this
  433. // compilation, explicitely cast 'ppoc' to a WCHAR** to prevent
  434. // a compilation error.
  435. _MultiByteToWideChar( pch, cb, CodePage, (WCHAR**)ppoc, pcb, pstatus );
  436. }
  437. VOID _WideCharToMultiByte(
  438. IN WCHAR const *pwc,
  439. IN ULONG cch,
  440. IN USHORT CodePage,
  441. OUT CHAR **ppch,
  442. OUT ULONG *pcb,
  443. OUT NTSTATUS *pstatus);
  444. VOID _OLECHARToMultiByte(
  445. IN OLECHAR const *poc,
  446. IN ULONG cch,
  447. IN USHORT CodePage,
  448. OUT CHAR **ppch,
  449. OUT ULONG *pcb,
  450. OUT NTSTATUS *pstatus)
  451. {
  452. PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );
  453. // Since OLECHAR may be MultiByte or WideChar for this
  454. // compilation, explicitely cast 'poc' to a WCHAR* to prevent
  455. // a compilation error.
  456. _WideCharToMultiByte( (WCHAR*) poc, cch, CodePage, ppch, pcb, pstatus );
  457. }
  458. VOID _WideCharToOLECHAR(
  459. IN WCHAR const *pwc,
  460. IN ULONG cch,
  461. IN USHORT CodePage,
  462. OUT OLECHAR **ppoc,
  463. OUT ULONG *pcb,
  464. OUT NTSTATUS *pstatus)
  465. {
  466. PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );
  467. // Since OLECHAR may be MultiByte or WideChar for this
  468. // compilation, explicitely cast 'ppoc' to a CHAR** to prevent
  469. // a compilation error.
  470. _WideCharToMultiByte( pwc, cch, CodePage, (CHAR**) ppoc, pcb, pstatus );
  471. }
  472. PROPERTYSETHEADER *_pph;
  473. ULONG _oSection;
  474. ULONG _cSection;
  475. USHORT _CodePage;
  476. DWORD _Locale;
  477. DWORD _grfBehavior;
  478. BYTE _Flags;
  479. BYTE _State;
  480. ULONG _cbTail;
  481. PMemoryAllocator *_pma;
  482. IMappedStream *_pmstm; // user mode: replacable virtual class
  483. };
  484. #ifdef WINNT
  485. VOID CopyPropertyValue(
  486. IN OPTIONAL SERIALIZEDPROPERTYVALUE const *pprop,
  487. IN ULONG cb,
  488. OUT SERIALIZEDPROPERTYVALUE *ppropDst,
  489. OUT ULONG *pcb);
  490. ULONG PropertyLengthAsVariant(
  491. IN SERIALIZEDPROPERTYVALUE const *pprop,
  492. IN ULONG cbprop,
  493. IN USHORT CodePage,
  494. IN BYTE flags);
  495. ULONG PropertyLengthAsVariantNoEH( // No NT Exception Handling version
  496. IN SERIALIZEDPROPERTYVALUE const *pprop,
  497. IN ULONG cbprop,
  498. IN USHORT CodePage,
  499. IN BYTE flags,
  500. OUT NTSTATUS *pstatus);
  501. EXTERN_C ULONG __stdcall StgPropertyLengthAsVariant(
  502. IN SERIALIZEDPROPERTYVALUE const *pprop,
  503. IN ULONG cbprop,
  504. IN USHORT CodePage,
  505. IN BYTE flags);
  506. EXTERN_C ULONG __stdcall StgPropertyLengthAsVariantNoEH( // No NT Exception Handling version
  507. IN SERIALIZEDPROPERTYVALUE const *pprop,
  508. IN ULONG cbprop,
  509. IN USHORT CodePage,
  510. IN BYTE flags,
  511. OUT NTSTATUS *pstatus);
  512. #endif
  513. ULONG PropertyLength(
  514. IN SERIALIZEDPROPERTYVALUE const *pprop,
  515. IN ULONG cbbuf,
  516. IN BYTE flags);
  517. ULONG PropertyLengthNoEH( // No NT Exception Handling version
  518. IN SERIALIZEDPROPERTYVALUE const *pprop,
  519. IN ULONG cbbuf,
  520. IN BYTE flags,
  521. OUT NTSTATUS *pstatus);
  522. // ------------
  523. // PBS Routines
  524. // ------------
  525. // PBS routines (Property Byte Swap) perform specialized byte-swapping
  526. // in the big-endian build, and do nothing in the little-endian
  527. // build (in which case they are inlined).
  528. #ifdef BIGENDIAN
  529. VOID PBSCopy( OUT VOID *pvDest,
  530. IN VOID const *pvSource,
  531. IN ULONG cbCopy,
  532. IN LONG cbByteSwap );
  533. VOID PBSAllocAndCopy( OUT VOID **ppvDest,
  534. IN VOID const *pvSource,
  535. ULONG cbSize,
  536. LONG cbByteSwap,
  537. OUT NTSTATUS *pstatus);
  538. VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
  539. OUT WCHAR** ppwszBuffer,
  540. OUT NTSTATUS *pstatus );
  541. VOID PBSBuffer( IN OUT VOID *pv,
  542. IN ULONG cbSize,
  543. IN ULONG cbByteSwap );
  544. #else // Little-endian build
  545. inline VOID PBSCopy( OUT VOID *pvDest,
  546. IN VOID const *pvSource,
  547. IN ULONG cbCopy,
  548. IN LONG cbByteSwap )
  549. {
  550. }
  551. inline VOID PBSAllocAndCopy( OUT VOID **ppvDest,
  552. IN VOID const *pvSource,
  553. ULONG cbSize,
  554. LONG cbByteSwap,
  555. OUT NTSTATUS *pstatus)
  556. {
  557. *pstatus = STATUS_SUCCESS;
  558. }
  559. inline VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
  560. OUT WCHAR** ppwszBuffer,
  561. OUT NTSTATUS *pstatus )
  562. {
  563. *pstatus = STATUS_SUCCESS;
  564. }
  565. inline VOID PBSBuffer( IN OUT VOID *pv,
  566. IN ULONG cbSize,
  567. IN ULONG cbByteSwap )
  568. {
  569. }
  570. #endif // #ifdef BIGENDIAN ... #else
  571. #endif // _PROPSTM_HXX_