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.

321 lines
9.7 KiB

  1. //+--------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1996.
  5. //
  6. // File: wrap.hxx
  7. //
  8. // Contents: Interface wrappers for test
  9. //
  10. // Classes: WStorage, WStream, WLockBytes, WEnmSTATSTG
  11. //
  12. //
  13. // Notes: These wrappers function in legitimate cases only,
  14. // they are not intended for testing illegitimate
  15. // calls.
  16. // QueryInterface does not return wrapped objects.
  17. //
  18. //---------------------------------------------------------------
  19. #ifndef __WRAP_HXX__
  20. #define __WRAP_HXX__
  21. /* Storage instantiation modes */
  22. #define WSTG_DIRECT 0x00000000L
  23. #define WSTG_TRANSACTED 0x00010000L
  24. #define WSTG_READ 0x00000000L
  25. #define WSTG_WRITE 0x00000001L
  26. #define WSTG_READWRITE 0x00000002L
  27. #define WSTG_SHARE_DENY_NONE 0x00000040L
  28. #define WSTG_SHARE_DENY_READ 0x00000030L
  29. #define WSTG_SHARE_DENY_WRITE 0x00000020L
  30. #define WSTG_SHARE_EXCLUSIVE 0x00000010L
  31. #define WSTG_PRIORITY 0x00040000L
  32. #define WSTG_DELETEONRELEASE 0x04000000L
  33. #define WSTG_CREATE 0x00001000L
  34. #define WSTG_CONVERT 0x00020000L
  35. #define WSTG_FAILIFTHERE 0x00000000L
  36. /* Storage commit types */
  37. typedef enum
  38. {
  39. WSTGC_OVERWRITE = 1,
  40. WSTGC_ONLYIFCURRENT = 2
  41. } WSTGC;
  42. typedef enum
  43. {
  44. WSTM_SEEK_SET = 0,
  45. WSTM_SEEK_CUR = 1,
  46. WSTM_SEEK_END = 2
  47. } WSTMS;
  48. typedef enum
  49. {
  50. WLOCK_WRITE = 1,
  51. WLOCK_EXCLUSIVE = 2,
  52. WLOCK_ONLYONCE = 3
  53. } WLOCKTYPE;
  54. //+--------------------------------------------------------------
  55. //
  56. // Class: WUnknown
  57. //
  58. // Purpose: Replacement for IUnknown
  59. //
  60. //---------------------------------------------------------------
  61. interface WUnknown
  62. {
  63. public:
  64. virtual HRESULT QueryInterface(REFIID riid, LPVOID * ppvObj) = 0;
  65. virtual ULONG AddRef(void) = 0;
  66. virtual ULONG Release(void) = 0;
  67. };
  68. //+--------------------------------------------------------------
  69. //
  70. // Class: WEnumSTATSTG
  71. //
  72. // Purpose: Wrapper for IEnumSTATSTG
  73. //
  74. //---------------------------------------------------------------
  75. interface WEnumSTATSTG : public WUnknown
  76. {
  77. public:
  78. WEnumSTATSTG(IEnumSTATSTG *penm);
  79. ~WEnumSTATSTG(void);
  80. IEnumSTATSTG *GetI(void) { return _penm; }
  81. static WEnumSTATSTG *Wrap(IEnumSTATSTG *penm);
  82. void Unwrap(void);
  83. virtual HRESULT QueryInterface(REFIID riid, LPVOID * ppvObj);
  84. virtual ULONG AddRef(void);
  85. virtual ULONG Release(void);
  86. HRESULT Next(ULONG celt, STATSTG rgelt[], ULONG *pceltFetched);
  87. HRESULT Skip(ULONG celt);
  88. HRESULT Reset(void);
  89. HRESULT Clone(WEnumSTATSTG **ppenm);
  90. private:
  91. IEnumSTATSTG *_penm;
  92. };
  93. //+--------------------------------------------------------------
  94. //
  95. // Class: WMarshal
  96. //
  97. // Purpose: Wrapper for IMarshal
  98. //
  99. //---------------------------------------------------------------
  100. interface WStream;
  101. #ifdef _MARSHAL_IMPL
  102. interface WMarshal : public WUnknown
  103. {
  104. public:
  105. WMarshal(IMarshal *pmsh);
  106. ~WMarshal(void);
  107. IMarshal *GetI(void) { return _pmsh; }
  108. static WMarshal *Wrap(IMarshal *pmsh);
  109. void Unwrap(void);
  110. virtual HRESULT QueryInterface(REFIID riid, LPVOID * ppvObj);
  111. virtual ULONG AddRef(void);
  112. virtual ULONG Release(void);
  113. HRESULT GetUnmarshalClass(REFIID riid,
  114. LPVOID pv,
  115. DWORD dwDestContext,
  116. LPVOID pvDestContext,
  117. DWORD mshlflags,
  118. CLSID * pCid);
  119. HRESULT GetMarshalSizeMax(REFIID riid,
  120. LPVOID pv,
  121. DWORD dwDestContext,
  122. LPVOID pvDestContext,
  123. DWORD mshlflags,
  124. DWORD * pSize);
  125. HRESULT MarshalInterface(WStream * pStm,
  126. REFIID riid,
  127. LPVOID pv,
  128. DWORD dwDestContext,
  129. LPVOID pvDestContext,
  130. DWORD mshlflags);
  131. HRESULT UnmarshalInterface(WStream * pStm,
  132. REFIID riid,
  133. LPVOID * ppv);
  134. HRESULT ReleaseMarshalData(WStream * pStm);
  135. HRESULT DisconnectObject(DWORD dwReserved);
  136. private:
  137. IMarshal *_pmsh;
  138. };
  139. #endif
  140. //+--------------------------------------------------------------
  141. //
  142. // Class: WStream
  143. //
  144. // Purpose: Wrapper for IStream
  145. //
  146. //---------------------------------------------------------------
  147. interface WStream : public WUnknown
  148. {
  149. public:
  150. WStream(IStream *pstm);
  151. ~WStream(void);
  152. IStream *GetI(void) { return _pstm; }
  153. static WStream *Wrap(IStream *pstm);
  154. void Unwrap(void);
  155. virtual HRESULT QueryInterface(REFIID riid, LPVOID * ppvObj);
  156. virtual ULONG AddRef(void);
  157. virtual ULONG Release(void);
  158. HRESULT Read(VOID *pv, ULONG cb, ULONG *pcbRead);
  159. HRESULT Write(VOID *pv,
  160. ULONG cb,
  161. ULONG *pcbWritten);
  162. HRESULT Seek(LONG dlibMove,
  163. DWORD dwOrigin,
  164. ULONG *plibNewPosition);
  165. HRESULT SetSize(ULONG libNewSize);
  166. HRESULT CopyTo(WStream *pstm,
  167. ULONG cb,
  168. ULONG *pcbRead,
  169. ULONG *pcbWritten);
  170. HRESULT Commit(const DWORD grfCommitFlags);
  171. HRESULT Revert(void);
  172. HRESULT LockRegion(ULONG libOffset,
  173. ULONG cb,
  174. const DWORD dwLockType);
  175. HRESULT UnlockRegion(ULONG libOffset,
  176. ULONG cb,
  177. const DWORD dwLockType);
  178. HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  179. HRESULT Clone(WStream * *ppstm);
  180. private:
  181. IStream *_pstm;
  182. };
  183. //+--------------------------------------------------------------
  184. //
  185. // Class: WStorage
  186. //
  187. // Purpose: Wrapper for IStorage
  188. //
  189. //---------------------------------------------------------------
  190. interface WStorage : public WUnknown
  191. {
  192. public:
  193. WStorage(IStorage *pstg);
  194. ~WStorage(void);
  195. IStorage *GetI(void) { return _pstg; }
  196. static WStorage *Wrap(IStorage *pstg);
  197. void Unwrap(void);
  198. virtual HRESULT QueryInterface(REFIID riid, LPVOID * ppvObj);
  199. virtual ULONG AddRef(void);
  200. virtual ULONG Release(void);
  201. HRESULT CreateStream(const OLECHAR * pwcsName,
  202. const DWORD grfMode,
  203. DWORD reserved1,
  204. DWORD reserved2,
  205. WStream **ppstm);
  206. HRESULT OpenStream(const OLECHAR * pwcsName,
  207. void *reserved1,
  208. const DWORD grfMode,
  209. DWORD reserved2,
  210. WStream **ppstm);
  211. HRESULT CreateStorage(const OLECHAR * pwcsName,
  212. const DWORD grfMode,
  213. DWORD reserved1,
  214. DWORD reserved2,
  215. WStorage **ppstg);
  216. HRESULT OpenStorage(const OLECHAR * pwcsName,
  217. WStorage *pstgPriority,
  218. const DWORD grfMode,
  219. SNB snbExclude,
  220. DWORD reserved,
  221. WStorage **ppstg);
  222. HRESULT CopyTo(DWORD ciidExclude,
  223. IID *rgiidExclude,
  224. SNB snbExclude,
  225. WStorage *pstgDest);
  226. HRESULT MoveElementTo(OLECHAR const FAR* lpszName,
  227. WStorage FAR *pstgDest,
  228. OLECHAR const FAR* lpszNewName,
  229. DWORD grfFlags);
  230. HRESULT Commit(const DWORD grfCommitFlags);
  231. HRESULT Revert(void);
  232. HRESULT EnumElements(DWORD reserved1,
  233. void *reserved2,
  234. DWORD reserved3,
  235. WEnumSTATSTG **ppenm);
  236. HRESULT DestroyElement(const OLECHAR * pwcsName);
  237. HRESULT RenameElement(const OLECHAR * pwcsOldName,
  238. const OLECHAR * pwcsNewName);
  239. HRESULT SetElementTimes(const OLECHAR *lpszName,
  240. FILETIME const *pctime,
  241. FILETIME const *patime,
  242. FILETIME const *pmtime);
  243. HRESULT SetClass(REFCLSID clsid);
  244. HRESULT SetStateBits(DWORD grfStateBits, DWORD grfMask);
  245. HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  246. private:
  247. IStorage *_pstg;
  248. };
  249. /****** Storage API Prototypes ********************************************/
  250. HRESULT WStgCreateDocfile(const OLECHAR * pwcsName,
  251. const DWORD grfMode,
  252. DWORD reserved,
  253. WStorage * *ppstgOpen);
  254. HRESULT WStgCreateDocfileOnILockBytes(ILockBytes *plkbyt,
  255. const DWORD grfMode,
  256. DWORD reserved,
  257. WStorage * *ppstgOpen);
  258. HRESULT WStgOpenStorage(const OLECHAR * pwcsName,
  259. WStorage *pstgPriority,
  260. const DWORD grfMode,
  261. SNB snbExclude,
  262. DWORD reserved,
  263. WStorage * *ppstgOpen);
  264. HRESULT WStgOpenStorageOnILockBytes(ILockBytes *plkbyt,
  265. WStorage *pstgPriority,
  266. const DWORD grfMode,
  267. SNB snbExclude,
  268. DWORD reserved,
  269. WStorage * *ppstgOpen);
  270. HRESULT WStgIsStorageFile(const OLECHAR * pwcsName);
  271. HRESULT WStgIsStorageILockBytes(ILockBytes * plkbyt);
  272. HRESULT WCoMarshalInterface(WStream *pStm,
  273. REFIID iid,
  274. IUnknown *pUnk,
  275. DWORD dwDestContext,
  276. LPVOID pvDestContext,
  277. DWORD mshlflags);
  278. HRESULT WCoUnmarshalInterface(WStream *pStm,
  279. REFIID riid,
  280. LPVOID *ppv);
  281. #endif // #ifndef __WRAP_HXX__