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.

489 lines
17 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992-1999.
  5. //
  6. // File: propapi.h
  7. //
  8. // Contents: Stuff needed to make properties build for Nashville and
  9. // NT... definitions of Nt property api.
  10. //
  11. //
  12. // History: 07-Aug-95 BillMo Created.
  13. // 22-Feb-96 MikeHill Fixed the non-WINNT version of
  14. // PROPASSERTMSG.
  15. // 09-May-96 MikeHill Update define to allow PropSet names
  16. // to be 255 characters (from 127).
  17. // 31-May-96 MikeHill Add OSVersion to RtlCreatePropSet.
  18. // 18-Jun-96 MikeHill Add OleAut32 wrappers to Unicode callouts.
  19. // 15-Jul-96 MikeHill - Remvd Win32 SEH exception-related code.
  20. // - WCHAR=>OLECHAR where applicable.
  21. // - Added RtlOnMappedStreamEvent
  22. // - Added Mac versions of PROPASSERT
  23. //
  24. //--------------------------------------------------------------------------
  25. #ifndef _PROPAPI_H_
  26. #define _PROPAPI_H_
  27. #if _MSC_VER > 1000
  28. #pragma once
  29. #endif
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. //
  34. // typedef the function prototypes necessary
  35. // for the UNICODECALLOUTS structure.
  36. //
  37. typedef UINT (WINAPI FNGETACP)(VOID);
  38. typedef int (WINAPI FNMULTIBYTETOWIDECHAR)(
  39. IN UINT CodePage,
  40. IN DWORD dwFlags,
  41. IN LPCSTR lpMultiByteStr,
  42. IN int cchMultiByte,
  43. OUT LPWSTR lpWideCharStr,
  44. IN int cchWideChar);
  45. typedef int (WINAPI FNWIDECHARTOMULTIBYTE)(
  46. IN UINT CodePage,
  47. IN DWORD dwFlags,
  48. IN LPCWSTR lpWideCharStr,
  49. IN int cchWideChar,
  50. OUT LPSTR lpMultiByteStr,
  51. IN int cchMultiByte,
  52. IN LPCSTR lpDefaultChar,
  53. IN LPBOOL lpUsedDefaultChar);
  54. typedef BSTR FNSYSALLOCSTRING(
  55. OLECHAR FAR* pwsz);
  56. typedef VOID FNSYSFREESTRING(
  57. BSTR pwsz);
  58. //
  59. // The UNICODECALLOUTS structure holds function
  60. // pointers for routines needed by the property
  61. // set routines in NTDLL.
  62. //
  63. typedef struct _UNICODECALLOUTS
  64. {
  65. FNGETACP *pfnGetACP;
  66. FNMULTIBYTETOWIDECHAR *pfnMultiByteToWideChar;
  67. FNWIDECHARTOMULTIBYTE *pfnWideCharToMultiByte;
  68. FNSYSALLOCSTRING *pfnSysAllocString;
  69. FNSYSFREESTRING *pfnSysFreeString;
  70. } UNICODECALLOUTS;
  71. //
  72. // Define the default UNICODECALLOUTS
  73. // values.
  74. //
  75. STDAPI_(BSTR)
  76. PropSysAllocString(OLECHAR FAR* pwsz);
  77. STDAPI_(VOID)
  78. PropSysFreeString(BSTR bstr);
  79. #define WIN32_UNICODECALLOUTS \
  80. GetACP, \
  81. MultiByteToWideChar, \
  82. WideCharToMultiByte, \
  83. PropSysAllocString, \
  84. PropSysFreeString
  85. // Is this pure NT (the IProp DLL needs to run on Win95)?
  86. #if defined(WINNT) && !defined(IPROPERTY_DLL)
  87. // Set the function modifiers
  88. # define PROPSYSAPI NTSYSAPI
  89. # define PROPAPI NTAPI
  90. // How do we free mem allocated in the low-level propset routines?
  91. # define PropFreeHeap(h, z, p) RtlFreeHeap(h, z, p)
  92. // Assert implementations
  93. # define PROPASSERT ASSERT
  94. # define PROPASSERTMSG ASSERTMSG
  95. // Generate the default non-simple property stream/storage name
  96. # define PROPGENPROPERTYNAME_SIZEOF ( (sizeof("prop")+10+1) * sizeof(WCHAR) )
  97. # define PROPGENPROPERTYNAME_CB(s,cb,n) StringCbPrintf( (s), cb, L"prop%lu", (n) )
  98. // Ansi sprintf implementations
  99. # define PropSprintfA StringCbPrintfA
  100. # define PropVsprintfA vsprintf
  101. // Otherwise this is either the IProp DLL (NT, Win95, Mac),
  102. // or it's the Win95 OLE32build.
  103. #else // #if defined(WINNT) && !defined(IPROPERTY_DLL)
  104. // Set the function modifiers
  105. # define PROPSYSAPI
  106. # define PROPAPI
  107. // How do we free mem allocated in low-level propset routines?
  108. # define PropFreeHeap(h, z, p) CoTaskMemFree(p)
  109. // Assert implementations
  110. # if DBG==1
  111. # ifdef _MAC_NODOC
  112. # define PROPASSERT(f) { if (!(f)) FnAssert(#f, NULL, __FILE__, __LINE__); }
  113. # define PROPASSERTMSG(szReason, f) { if (!(f)) FnAssert(#f, szReason, __FILE__, __LINE__); }
  114. # else
  115. # define PROPASSERT(f) PROPASSERTMSG(NULL,f)
  116. # define PROPASSERTMSG(szReason,f) { if(!(f)) PropAssertFailed(#f,__FILE__,__LINE__,szReason); }
  117. # endif
  118. # else
  119. # define PROPASSERT(f)
  120. # define PROPASSERTMSG(szReason, f)
  121. # endif // #if DBG==1
  122. // Generate the default non-simple property stream/storage name
  123. # define PROPGENPROPERTYNAME(s,n) \
  124. { \
  125. memcpy ((s), OLESTR("prop"), sizeof (OLESTR("prop"))); \
  126. ULTOO ((n), &(s)[sizeof("prop") - 1], 10); \
  127. }
  128. // Ansi sprintf implementations
  129. # ifdef IPROPERTY_DLL
  130. # define PropSprintfA sprintf
  131. # define PropVsprintfA vsprintf
  132. # else
  133. # define PropSprintfA wsprintfA
  134. # define PropVsprintfA wvsprintfA
  135. # endif // #ifdef _MAC_NODOC
  136. #endif // #if defined(WINNT) && !defined(IPROPERTY_DLL) ... #else
  137. #define WC_PROPSET0 ((WCHAR) 0x0005) //(L'#'))
  138. #define OC_PROPSET0 ((OLECHAR) 0x0005) //OLESTR('#'))
  139. #define CBIT_BYTE 8
  140. #define CBIT_GUID (CBIT_BYTE * sizeof(GUID))
  141. #define CBIT_CHARMASK 5
  142. // The wFormat field in the header indicates what features
  143. // are supported.
  144. #define PROPSET_WFORMAT_ORIGINAL 0
  145. #define PROPSET_WFORMAT_VERSTREAM 1
  146. #define PROPSET_WFORMAT_CASE_SENSITIVE 1
  147. #define PROPSET_WFORMAT_BEHAVIOR 1
  148. #define PROPSET_WFORMAT_LONG_NAMES 1
  149. #define PROPSET_WFORMAT_EXPANDED_VTS 1
  150. // Allow for OC_PROPSET0 and a GUID mapped to a 32 character alphabet
  151. #define CCH_PROPSET (1 + (CBIT_GUID + CBIT_CHARMASK-1)/CBIT_CHARMASK)
  152. #define CCH_PROPSETSZ (CCH_PROPSET + 1) // allow null
  153. #define CCH_PROPSETCOLONSZ (1 + CCH_PROPSET + 1) // allow colon and null
  154. // Define the max property name in units of characters
  155. // (and synonomously in wchars).
  156. #define CCH_MAXPROPNAME 255 // Matches Shell & Office
  157. #define CCH_MAXPROPNAMESZ (CCH_MAXPROPNAME + 1) // allow null
  158. #define CWC_MAXPROPNAME CCH_MAXPROPNAME
  159. #define CWC_MAXPROPNAMESZ CCH_MAXPROPNAMESZ
  160. #define MAX_DOCFILE_ENTRY_NAME 31
  161. //+--------------------------------------------------------------------------
  162. // Property Access APIs:
  163. //---------------------------------------------------------------------------
  164. typedef VOID *NTPROP;
  165. typedef VOID *NTMAPPEDSTREAM;
  166. typedef VOID *NTMEMORYALLOCATOR;
  167. VOID PROPSYSAPI PROPAPI
  168. RtlSetUnicodeCallouts(
  169. IN UNICODECALLOUTS *pUnicodeCallouts);
  170. ULONG PROPSYSAPI PROPAPI
  171. RtlGuidToPropertySetName(
  172. IN GUID const *pguid,
  173. OUT OLECHAR aocname[]);
  174. NTSTATUS PROPSYSAPI PROPAPI
  175. RtlPropertySetNameToGuid(
  176. IN ULONG cwcname,
  177. IN OLECHAR const aocname[],
  178. OUT GUID *pguid);
  179. VOID
  180. PrSetUnicodeCallouts(
  181. IN UNICODECALLOUTS *pUnicodeCallouts);
  182. ULONG
  183. PrGuidToPropertySetName(
  184. IN GUID const *pguid,
  185. OUT OLECHAR aocname[]);
  186. NTSTATUS
  187. PrPropertySetNameToGuid(
  188. IN ULONG cwcname,
  189. IN OLECHAR const aocname[],
  190. OUT GUID *pguid);
  191. // RtlCreatePropertySet Flags:
  192. #define CREATEPROP_READ 0x0000 // request read access (must exist)
  193. #define CREATEPROP_WRITE 0x0001 // request write access (must exist)
  194. #define CREATEPROP_CREATE 0x0002 // create (overwrite if exists)
  195. #define CREATEPROP_CREATEIF 0x0003 // create (open existing if exists)
  196. #define CREATEPROP_DELETE 0x0004 // delete
  197. #define CREATEPROP_UNKNOWN 0x0008 // read/write state is unknown
  198. #define CREATEPROP_MODEMASK 0x000f // open mode mask
  199. #define CREATEPROP_NONSIMPLE 0x0010 // Is non-simple propset (in a storage)
  200. // RtlCreateMappedStream Flags:
  201. #define CMS_READONLY 0x00000000 // Opened for read-only
  202. #define CMS_WRITE 0x00000001 // Opened for write access
  203. #define CMS_TRANSACTED 0x00000002 // Is transacted
  204. NTSTATUS PROPSYSAPI PROPAPI
  205. RtlCreatePropertySet(
  206. IN NTMAPPEDSTREAM ms, // Nt mapped stream
  207. IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
  208. OPTIONAL IN GUID const *pguid, // property set guid (create only)
  209. OPTIONAL IN GUID const *pclsid,// CLASSID of propset code (create only)
  210. IN NTMEMORYALLOCATOR ma, // caller's memory allocator
  211. IN ULONG LocaleId, // Locale Id (create only)
  212. OPTIONAL OUT ULONG *pOSVersion,// OS Version field in header.
  213. IN OUT USHORT *pCodePage, // IN: CodePage of property set (create only)
  214. // OUT: CodePage of property set (always)
  215. OUT NTPROP *pnp); // Nt property set context
  216. NTSTATUS PROPSYSAPI PROPAPI
  217. RtlClosePropertySet(
  218. IN NTPROP np); // property set context
  219. NTSTATUS
  220. PrCreatePropertySet(
  221. IN NTMAPPEDSTREAM ms, // Nt mapped stream
  222. IN USHORT Flags, // NONSIMPLE|*1* of READ/WRITE/CREATE/CREATEIF/DELETE
  223. OPTIONAL IN GUID const *pguid, // property set guid (create only)
  224. OPTIONAL IN GUID const *pclsid,// CLASSID of propset code (create only)
  225. IN NTMEMORYALLOCATOR ma, // caller's memory allocator
  226. IN ULONG LocaleId, // Locale Id (create only)
  227. OPTIONAL OUT ULONG *pOSVersion,// OS Version field in header.
  228. IN OUT USHORT *pCodePage, // IN: CodePage of property set (create only)
  229. // OUT: CodePage of property set (always)
  230. IN OUT DWORD *pgrfBehavior, // IN: Behavior of property set (create only)
  231. // OUT: Behavior of property set (always)
  232. OUT NTPROP *pnp); // Nt property set context
  233. NTSTATUS
  234. PrClosePropertySet(
  235. IN NTPROP np); // property set context
  236. // *NOTE* RtlOnMappedStreamEvent assumes that the caller has
  237. // already taken the CPropertySetStream::Lock.
  238. #define CBSTM_UNKNOWN ((ULONG) -1)
  239. NTSTATUS PROPSYSAPI PROPAPI
  240. RtlOnMappedStreamEvent(
  241. IN VOID *pv, // property set context (NTPROP)
  242. IN VOID *pbuf, // property set buffer
  243. IN ULONG cbstm ); // size of underlying stream, or CBSTM_UNKNOWN
  244. NTSTATUS
  245. PrOnMappedStreamEvent(
  246. IN VOID *pv, // property set context (NTPROP)
  247. IN VOID *pbuf, // property set buffer
  248. IN ULONG cbstm ); // size of underlying stream, or CBSTM_UNKNOWN
  249. NTSTATUS PROPSYSAPI PROPAPI
  250. RtlFlushPropertySet(
  251. IN NTPROP np); // property set context
  252. NTSTATUS
  253. PrFlushPropertySet(
  254. IN NTPROP np); // property set context
  255. typedef struct _INDIRECTPROPERTY // ip
  256. {
  257. ULONG Index; // Index into Variant and PropId arrays
  258. LPOLESTR poszName; // Old indirect name, RtlSetProperties() only
  259. } INDIRECTPROPERTY;
  260. NTSTATUS PROPSYSAPI PROPAPI
  261. RtlSetProperties(
  262. IN NTPROP np, // property set context
  263. IN ULONG cprop, // property count
  264. IN PROPID pidNameFirst, // first PROPID for new named properties
  265. IN PROPSPEC const aprs[], // array of property specifiers
  266. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  267. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  268. // MAXULONG terminated array of Indirect
  269. // properties w/indexes into aprs & avar
  270. OPTIONAL IN PROPVARIANT const avar[]);// array of properties with values
  271. NTSTATUS
  272. PrSetProperties(
  273. IN NTPROP np, // property set context
  274. IN ULONG cprop, // property count
  275. IN PROPID pidNameFirst, // first PROPID for new named properties
  276. IN PROPSPEC const aprs[], // array of property specifiers
  277. OUT USHORT *pCodePage, // updated code page
  278. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  279. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  280. // MAXULONG terminated array of Indirect
  281. // properties w/indexes into aprs & avar
  282. OPTIONAL IN PROPVARIANT const avar[]);// array of properties with values
  283. NTSTATUS PROPSYSAPI PROPAPI
  284. RtlQueryProperties(
  285. IN NTPROP np, // property set context
  286. IN ULONG cprop, // property count
  287. IN PROPSPEC const aprs[], // array of property specifiers
  288. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  289. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  290. // MAXULONG terminated array of Indirect
  291. // properties w/indexes into aprs & avar
  292. IN OUT PROPVARIANT *avar, // IN: array of uninitialized PROPVARIANTs,
  293. // OUT: may contain pointers to alloc'd memory
  294. OUT ULONG *pcpropFound); // count of property values retrieved
  295. NTSTATUS
  296. PrQueryProperties(
  297. IN NTPROP np, // property set context
  298. IN ULONG cprop, // property count
  299. IN PROPSPEC const aprs[], // array of property specifiers
  300. OPTIONAL OUT PROPID apid[], // buffer for array of propids
  301. OPTIONAL OUT INDIRECTPROPERTY **ppip, // pointer to returned pointer to
  302. // MAXULONG terminated array of Indirect
  303. // properties w/indexes into aprs & avar
  304. IN OUT PROPVARIANT *avar, // IN: array of uninitialized PROPVARIANTs,
  305. // OUT: may contain pointers to alloc'd memory
  306. OUT ULONG *pcpropFound); // count of property values retrieved
  307. #define ENUMPROP_NONAMES 0x00000001 // return property IDs only
  308. NTSTATUS PROPSYSAPI PROPAPI
  309. RtlEnumerateProperties(
  310. IN NTPROP np, // property set context
  311. IN ULONG Flags, // flags: No Names (propids only), etc.
  312. IN OUT ULONG *pkey, // bookmark; caller set to 0 before 1st call
  313. IN OUT ULONG *pcprop, // pointer to property count
  314. OPTIONAL OUT PROPSPEC aprs[],// IN: array of uninitialized PROPSPECs
  315. // OUT: may contain pointers to alloc'd strings
  316. OPTIONAL OUT STATPROPSTG asps[]);
  317. // IN: array of uninitialized STATPROPSTGs
  318. // OUT: may contain pointers to alloc'd strings
  319. NTSTATUS PROPSYSAPI PROPAPI
  320. RtlQueryPropertyNames(
  321. IN NTPROP np, // property set context
  322. IN ULONG cprop, // property count
  323. IN PROPID const *apid, // PROPID array
  324. OUT OLECHAR *aposz[] // OUT pointers to allocated strings
  325. );
  326. NTSTATUS PROPSYSAPI PROPAPI
  327. RtlSetPropertyNames(
  328. IN NTPROP np, // property set context
  329. IN ULONG cprop, // property count
  330. IN PROPID const *apid, // PROPID array
  331. IN OLECHAR const * const aposz[] // pointers to property names
  332. );
  333. NTSTATUS PROPSYSAPI PROPAPI
  334. RtlSetPropertySetClassId(
  335. IN NTPROP np, // property set context
  336. IN GUID const *pclsid // new CLASSID of propset code
  337. );
  338. NTSTATUS PROPSYSAPI PROPAPI
  339. RtlQueryPropertySet(
  340. IN NTPROP np, // property set context
  341. OUT STATPROPSETSTG *pspss // buffer for property set stat information
  342. );
  343. NTSTATUS PROPSYSAPI PROPAPI
  344. RtlEnumeratePropertySets(
  345. IN HANDLE hstg, // structured storage handle
  346. IN BOOLEAN fRestart, // restart scan
  347. IN OUT ULONG *pcspss, // pointer to count of STATPROPSETSTGs
  348. IN OUT GUID *pkey, // bookmark
  349. OUT STATPROPSETSTG *pspss // array of STATPROPSETSTGs
  350. );
  351. NTSTATUS
  352. PrEnumerateProperties(
  353. IN NTPROP np, // property set context
  354. IN ULONG Flags, // flags: No Names (propids only), etc.
  355. IN OUT ULONG *pkey, // bookmark; caller set to 0 before 1st call
  356. IN OUT ULONG *pcprop, // pointer to property count
  357. OPTIONAL OUT PROPSPEC aprs[],// IN: array of uninitialized PROPSPECs
  358. // OUT: may contain pointers to alloc'd strings
  359. OPTIONAL OUT STATPROPSTG asps[]);
  360. // IN: array of uninitialized STATPROPSTGs
  361. // OUT: may contain pointers to alloc'd strings
  362. NTSTATUS
  363. PrQueryPropertyNames(
  364. IN NTPROP np, // property set context
  365. IN ULONG cprop, // property count
  366. IN PROPID const *apid, // PROPID array
  367. OUT OLECHAR *aposz[] // OUT pointers to allocated strings
  368. );
  369. NTSTATUS
  370. PrSetPropertyNames(
  371. IN NTPROP np, // property set context
  372. IN ULONG cprop, // property count
  373. IN PROPID const *apid, // PROPID array
  374. IN OLECHAR const * const aposz[] // pointers to property names
  375. );
  376. NTSTATUS
  377. PrSetPropertySetClassId(
  378. IN NTPROP np, // property set context
  379. IN GUID const *pclsid // new CLASSID of propset code
  380. );
  381. NTSTATUS
  382. PrQueryPropertySet(
  383. IN NTPROP np, // property set context
  384. OUT STATPROPSETSTG *pspss // buffer for property set stat information
  385. );
  386. NTSTATUS
  387. PrEnumeratePropertySets(
  388. IN HANDLE hstg, // structured storage handle
  389. IN BOOLEAN fRestart, // restart scan
  390. IN OUT ULONG *pcspss, // pointer to count of STATPROPSETSTGs
  391. IN OUT GUID *pkey, // bookmark
  392. OUT STATPROPSETSTG *pspss // array of STATPROPSETSTGs
  393. );
  394. #ifdef __cplusplus
  395. }
  396. #endif
  397. #endif // ifndef _PROPAPI_H_