Source code of Windows XP (NT5)
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.

705 lines
23 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(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. IN ULONG cbName,
  239. OUT NTSTATUS *pstatus) const;
  240. BOOLEAN QueryPropertyNameBuf(
  241. IN PROPID pid,
  242. OUT OLECHAR *aocName,
  243. IN OUT ULONG *pcbName,
  244. OUT NTSTATUS *pstatus);
  245. BOOLEAN QueryPropertyNames(
  246. IN ULONG cprop,
  247. IN PROPID const *apid,
  248. OUT OLECHAR *aposz[],
  249. OUT NTSTATUS *pstatus);
  250. VOID SetPropertyNames(
  251. IN ULONG cprop,
  252. IN PROPID const *apid,
  253. IN OPTIONAL OLECHAR const * const aposz[],
  254. OUT NTSTATUS *pstatus);
  255. VOID QueryPropertySet(OUT STATPROPSETSTG *pspss, OUT NTSTATUS *pstatus) const;
  256. VOID SetClassId(IN GUID const *pclsid, OUT NTSTATUS *pstatus);
  257. HANDLE GetHandle(VOID) const { return(_MSTM(GetHandle)()); }
  258. PMemoryAllocator *GetAllocator(VOID) const { return(_pma); }
  259. VOID ByteSwapHeaders( IN PROPERTYSETHEADER *psh,
  260. IN ULONG cbstm,
  261. OUT NTSTATUS *pstatus );
  262. // Convert a character count to a byte count based on the _CodePage
  263. ULONG CCh2CB( ULONG cch ) const
  264. {
  265. return( _CodePage == CP_WINUNICODE
  266. ? cch * sizeof( WCHAR )
  267. : cch * sizeof( CHAR )
  268. );
  269. }
  270. // Convert a byte count to a character count based on the _CodePage
  271. // If for some reason the given byte-count is odd, the return
  272. // value won't include that last half-character.
  273. ULONG CB2CCh( ULONG cb ) const
  274. {
  275. return( _CodePage == CP_WINUNICODE
  276. ? cb / sizeof( WCHAR )
  277. : cb / sizeof( CHAR )
  278. );
  279. }
  280. private:
  281. // Private methods.
  282. VOID _Create(
  283. IN GUID const *pfmtid,
  284. OPTIONAL IN GUID const *pclsid,
  285. IN ULONG LocaleId,
  286. IN USHORT CodePage,
  287. IN LOADSTATE LoadState,
  288. IN DWORD grfBehavior,
  289. OUT NTSTATUS *pstatus);
  290. BOOLEAN _HasPropHeader(VOID) const { return(TRUE); }
  291. BOOLEAN _CreateUserDefinedSection(
  292. IN LOADSTATE LoadState,
  293. IN ULONG LocaleId,
  294. OUT NTSTATUS *pstatus);
  295. VOID _InitSection(
  296. IN FORMATIDOFFSET *pfo,
  297. IN ULONG LocaleId,
  298. IN BOOL fCreateDictionary );
  299. VOID _FixUnalignedUDPropSet( ULONG *pcbstm,
  300. NTSTATUS *pstatus );
  301. VOID _FixSummaryInformation(IN OUT ULONG *pcbstm, OUT NTSTATUS *pstatus);
  302. VOID _FixPackedPropertySet(OUT NTSTATUS *pstatus);
  303. BOOLEAN _FixDocPartsVector(
  304. IN PATCHOP PatchOp,
  305. IN OUT SERIALIZEDPROPERTYVALUE *pprop,
  306. OUT ULONG *pcbprop);
  307. BOOLEAN _FixDocPartsElements(
  308. IN PATCHOP PatchOp,
  309. IN ULONG cString,
  310. OUT VOID *pvDst,
  311. IN VOID UNALIGNED const *pvSrc,
  312. OUT ULONG *pcbprop);
  313. BOOLEAN _FixHeadingPairVector(
  314. IN PATCHOP PatchOp,
  315. IN OUT SERIALIZEDPROPERTYVALUE *pprop,
  316. OUT ULONG *pcbprop);
  317. BOOLEAN _FixHeadingPairElements(
  318. IN PATCHOP PatchOp,
  319. IN ULONG cPairs,
  320. OUT SERIALIZEDPROPERTYVALUE *ppropDst,
  321. IN SERIALIZEDPROPERTYVALUE UNALIGNED const *ppropSrc,
  322. OUT ULONG *pcbprop);
  323. BOOLEAN _IsMapped(VOID) const { return(_pph != NULL); }
  324. BOOLEAN _IsCaseSensitive(VOID) const { return( (PROPSET_BEHAVIOR_CASE_SENSITIVE & _grfBehavior) ? TRUE : FALSE ); }
  325. BOOLEAN _SupportsLongNames(VOID) const { return( GetFormatVersion() >= PROPSET_WFORMAT_LONG_NAMES ); }
  326. LOADSTATE _LoadHeader(OPTIONAL IN GUID const *pfmtid, IN BYTE Mode,
  327. OUT NTSTATUS *pstatus);
  328. PROPERTYSECTIONHEADER *_LoadPropertyOffsetPointers(
  329. OUT PROPERTYIDOFFSET **pppo,
  330. OUT PROPERTYIDOFFSET **pppoMax,
  331. OUT NTSTATUS *pstatus);
  332. SERIALIZEDPROPERTYVALUE *_LoadProperty(IN PROPID pid, OUT ULONG *pcbprop,
  333. OUT NTSTATUS *pstatus);
  334. PROPERTYSECTIONHEADER *_GetSectionHeader(VOID) const;
  335. VOID _SearchForCodePage( OUT NTSTATUS *pstatus);
  336. PROPERTYSECTIONHEADER *_GetSectionHeader(IN ULONG iSection, OUT NTSTATUS *pstatus);
  337. FORMATIDOFFSET *_GetFormatidOffset(IN ULONG iSection) const;
  338. VOID *_MapOffsetToAddress(IN ULONG oOffset) const;
  339. ULONG _MapAddressToOffset(IN VOID const *pvAddr) const;
  340. VOID *_MapAbsOffsetToAddress(IN ULONG oAbsolute) const;
  341. ULONG _MapAddressToAbsOffset(IN VOID const *pvAddr) const;
  342. ULONG _GetNewOffset(
  343. IN CStreamChunkList const *pscl,
  344. IN ULONG oOld) const;
  345. ULONG _DictionaryEntryLength(
  346. IN ENTRY UNALIGNED const * pent ) const;
  347. ULONG _DictionaryLength(
  348. IN DICTIONARY const *pdy,
  349. IN ULONG cbbuf,
  350. OUT NTSTATUS *pstatus) const;
  351. BOOLEAN _IsLocalizationSettable(
  352. OUT NTSTATUS *pstatus);
  353. ENTRY UNALIGNED
  354. *_NextDictionaryEntry(
  355. IN ENTRY UNALIGNED const * pent ) const;
  356. ULONG _CountFreePropertyOffsets(OUT NTSTATUS *pstatus);
  357. VOID _DeleteMovePropertyOffsets(
  358. IN PROPERTY_INFORMATION const *apinfo,
  359. IN ULONG cprop,
  360. OUT NTSTATUS *pstatus);
  361. VOID _UpdatePropertyOffsets(
  362. IN CStreamChunkList const *pscl,
  363. OUT NTSTATUS *pstatus);
  364. VOID _InsertMovePropertyOffsets(
  365. IN PROPERTY_INFORMATION const *apinfo,
  366. IN ULONG cprop,
  367. IN ULONG oInsert,
  368. IN ULONG cpoReserve,
  369. OUT NTSTATUS *pstatus);
  370. VOID _CompactStream(IN CStreamChunkList const *pscl);
  371. VOID _CompactChunk(
  372. IN CStreamChunk const *pscnk,
  373. IN LONG cbChangeTotal,
  374. IN ULONG oOldNext);
  375. VOID _PatchSectionOffsets(LONG cbChange);
  376. ULONG _ComputeMinimumSize(ULONG cbstm, OUT NTSTATUS *pstatus);
  377. #if DBGPROP
  378. VOID _ValidateStructure(OUT NTSTATUS *pstatus);
  379. VOID _ValidateProperties(OUT NTSTATUS *pstatus) const;
  380. VOID _ValidateDictionary(OUT NTSTATUS *pstatus);
  381. VOID _StatusCorruption(char *szReason, OUT NTSTATUS *pstatus) const;
  382. #else
  383. VOID _StatusCorruption(OUT NTSTATUS *pstatus) const;
  384. #endif
  385. VOID _SetModified(OUT NTSTATUS *pstatus) { _MSTM(SetModified)(pstatus); }
  386. #if DBGPROP
  387. public: // public for fnEntryNameCompare only!
  388. #endif
  389. BOOLEAN _ComparePropertyNames(
  390. IN VOID const *pvName1,
  391. IN VOID const *pvName2,
  392. IN BOOL fSameByteOrder,
  393. IN ULONG cbName,
  394. OUT NTSTATUS *pstatus ) const;
  395. #if DBGPROP
  396. private:
  397. #endif
  398. WORD _PropertyNameLength(
  399. IN VOID const *pvName,
  400. OUT ULONG *pcbName) const;
  401. VOID _MultiByteToWideChar(
  402. IN CHAR const *pch,
  403. IN ULONG cb,
  404. IN USHORT CodePage,
  405. OUT WCHAR **ppwc,
  406. OUT ULONG *pcb,
  407. OUT NTSTATUS *pstatus);
  408. VOID _OLECHARToWideChar(
  409. IN OLECHAR const *poc,
  410. IN ULONG cb,
  411. IN USHORT CodePage,
  412. OUT WCHAR **ppwc,
  413. OUT ULONG *pcb,
  414. OUT NTSTATUS *pstatus)
  415. {
  416. PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );
  417. // Since OLECHAR may be MultiByte or WideChar for this
  418. // compilation, explicitely cast 'poc' to a CHAR* to prevent
  419. // a compilation error.
  420. _MultiByteToWideChar( (CHAR*) poc, cb, CodePage, ppwc, pcb, pstatus );
  421. }
  422. VOID _MultiByteToOLECHAR(
  423. IN CHAR const *pch,
  424. IN ULONG cb,
  425. IN USHORT CodePage,
  426. OUT OLECHAR **ppoc,
  427. OUT ULONG *pcb,
  428. OUT NTSTATUS *pstatus)
  429. {
  430. PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );
  431. // Since OLECHAR may be MultiByte or WideChar for this
  432. // compilation, explicitely cast 'ppoc' to a WCHAR** to prevent
  433. // a compilation error.
  434. _MultiByteToWideChar( pch, cb, CodePage, (WCHAR**)ppoc, pcb, pstatus );
  435. }
  436. VOID _WideCharToMultiByte(
  437. IN WCHAR const *pwc,
  438. IN ULONG cch,
  439. IN USHORT CodePage,
  440. OUT CHAR **ppch,
  441. OUT ULONG *pcb,
  442. OUT NTSTATUS *pstatus);
  443. VOID _OLECHARToMultiByte(
  444. IN OLECHAR const *poc,
  445. IN ULONG cch,
  446. IN USHORT CodePage,
  447. OUT CHAR **ppch,
  448. OUT ULONG *pcb,
  449. OUT NTSTATUS *pstatus)
  450. {
  451. PROPASSERT( sizeof(OLECHAR) == sizeof(WCHAR) );
  452. // Since OLECHAR may be MultiByte or WideChar for this
  453. // compilation, explicitely cast 'poc' to a WCHAR* to prevent
  454. // a compilation error.
  455. _WideCharToMultiByte( (WCHAR*) poc, cch, CodePage, ppch, pcb, pstatus );
  456. }
  457. VOID _WideCharToOLECHAR(
  458. IN WCHAR const *pwc,
  459. IN ULONG cch,
  460. IN USHORT CodePage,
  461. OUT OLECHAR **ppoc,
  462. OUT ULONG *pcb,
  463. OUT NTSTATUS *pstatus)
  464. {
  465. PROPASSERT( sizeof(OLECHAR) == sizeof(CHAR) );
  466. // Since OLECHAR may be MultiByte or WideChar for this
  467. // compilation, explicitely cast 'ppoc' to a CHAR** to prevent
  468. // a compilation error.
  469. _WideCharToMultiByte( pwc, cch, CodePage, (CHAR**) ppoc, pcb, pstatus );
  470. }
  471. PROPERTYSETHEADER *_pph;
  472. ULONG _oSection;
  473. ULONG _cSection;
  474. USHORT _CodePage;
  475. DWORD _Locale;
  476. DWORD _grfBehavior;
  477. BYTE _Flags;
  478. BYTE _State;
  479. ULONG _cbTail;
  480. PMemoryAllocator *_pma;
  481. IMappedStream *_pmstm; // user mode: replacable virtual class
  482. };
  483. #ifdef WINNT
  484. VOID CopyPropertyValue(
  485. IN OPTIONAL SERIALIZEDPROPERTYVALUE const *pprop,
  486. IN ULONG cb,
  487. OUT SERIALIZEDPROPERTYVALUE *ppropDst,
  488. OUT ULONG *pcb);
  489. ULONG PropertyLengthAsVariant(
  490. IN SERIALIZEDPROPERTYVALUE const *pprop,
  491. IN ULONG cbprop,
  492. IN USHORT CodePage,
  493. IN BYTE flags);
  494. ULONG PropertyLengthAsVariantNoEH( // No NT Exception Handling version
  495. IN SERIALIZEDPROPERTYVALUE const *pprop,
  496. IN ULONG cbprop,
  497. IN USHORT CodePage,
  498. IN BYTE flags,
  499. OUT NTSTATUS *pstatus);
  500. EXTERN_C ULONG __stdcall StgPropertyLengthAsVariant(
  501. IN SERIALIZEDPROPERTYVALUE const *pprop,
  502. IN ULONG cbprop,
  503. IN USHORT CodePage,
  504. IN BYTE flags);
  505. EXTERN_C ULONG __stdcall StgPropertyLengthAsVariantNoEH( // No NT Exception Handling version
  506. IN SERIALIZEDPROPERTYVALUE const *pprop,
  507. IN ULONG cbprop,
  508. IN USHORT CodePage,
  509. IN BYTE flags,
  510. OUT NTSTATUS *pstatus);
  511. #endif
  512. ULONG PropertyLength(
  513. IN SERIALIZEDPROPERTYVALUE const *pprop,
  514. IN ULONG cbbuf,
  515. IN BYTE flags);
  516. ULONG PropertyLengthNoEH( // No NT Exception Handling version
  517. IN SERIALIZEDPROPERTYVALUE const *pprop,
  518. IN ULONG cbbuf,
  519. IN BYTE flags,
  520. OUT NTSTATUS *pstatus);
  521. // ------------
  522. // PBS Routines
  523. // ------------
  524. // PBS routines (Property Byte Swap) perform specialized byte-swapping
  525. // in the big-endian build, and do nothing in the little-endian
  526. // build (in which case they are inlined).
  527. #ifdef BIGENDIAN
  528. VOID PBSCopy( OUT VOID *pvDest,
  529. IN VOID const *pvSource,
  530. IN ULONG cbCopy,
  531. IN LONG cbByteSwap );
  532. VOID PBSAllocAndCopy( OUT VOID **ppvDest,
  533. IN VOID const *pvSource,
  534. ULONG cbSize,
  535. LONG cbByteSwap,
  536. OUT NTSTATUS *pstatus);
  537. VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
  538. OUT WCHAR** ppwszBuffer,
  539. OUT NTSTATUS *pstatus );
  540. VOID PBSBuffer( IN OUT VOID *pv,
  541. IN ULONG cbSize,
  542. IN ULONG cbByteSwap );
  543. #else // Little-endian build
  544. inline VOID PBSCopy( OUT VOID *pvDest,
  545. IN VOID const *pvSource,
  546. IN ULONG cbCopy,
  547. IN LONG cbByteSwap )
  548. {
  549. }
  550. inline VOID PBSAllocAndCopy( OUT VOID **ppvDest,
  551. IN VOID const *pvSource,
  552. ULONG cbSize,
  553. LONG cbByteSwap,
  554. OUT NTSTATUS *pstatus)
  555. {
  556. *pstatus = STATUS_SUCCESS;
  557. }
  558. inline VOID PBSInPlaceAlloc( IN OUT WCHAR** ppwszResult,
  559. OUT WCHAR** ppwszBuffer,
  560. OUT NTSTATUS *pstatus )
  561. {
  562. *pstatus = STATUS_SUCCESS;
  563. }
  564. inline VOID PBSBuffer( IN OUT VOID *pv,
  565. IN ULONG cbSize,
  566. IN ULONG cbByteSwap )
  567. {
  568. }
  569. #endif // #ifdef BIGENDIAN ... #else
  570. #endif // _PROPSTM_HXX_