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.

377 lines
12 KiB

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