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.

473 lines
17 KiB

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