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.

690 lines
21 KiB

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