ReactOS 0.4.16-dev-2332-g4cba65d
storage32.c File Reference
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
#include "wine/debug.h"
#include "ole2.h"
#include "winreg.h"
#include "wine/wingdi16.h"
Include dependency graph for storage32.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Enumerations

enum  stream_1ole_flags { OleStream_LinkedObject = 0x00000001 , OleStream_Convert = 0x00000004 , OleStream_LinkedObject = 0x00000001 , OleStream_Convert = 0x00000004 }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (storage)
 
HRESULT WINAPI WriteClassStg (IStorage *pStg, REFCLSID rclsid)
 
HRESULT WINAPI ReadClassStg (IStorage *pstg, CLSID *pclsid)
 
HRESULT WINAPI WriteClassStm (IStream *pStm, REFCLSID rclsid)
 
HRESULT WINAPI ReadClassStm (IStream *pStm, CLSID *pclsid)
 
HRESULT WINAPI GetConvertStg (IStorage *stg)
 
HRESULT WINAPI StgIsStorageILockBytes (ILockBytes *plkbyt)
 
HRESULT WINAPI StgIsStorageFile (LPCOLESTR fn)
 
HRESULT WINAPI StgCreatePropSetStg (IStorage *pstg, DWORD reserved, IPropertySetStorage **propset)
 

Variables

static const BYTE STORAGE_magic [8] ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1}
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 39 of file storage32.c.

Enumeration Type Documentation

◆ stream_1ole_flags

Enumerator
OleStream_LinkedObject 
OleStream_Convert 
OleStream_LinkedObject 
OleStream_Convert 

Definition at line 133 of file storage32.c.

133 {
134 OleStream_LinkedObject = 0x00000001,
135 OleStream_Convert = 0x00000004
136};
@ OleStream_Convert
Definition: storage32.c:135
@ OleStream_LinkedObject
Definition: storage32.c:134

Function Documentation

◆ GetConvertStg()

HRESULT WINAPI GetConvertStg ( IStorage stg)

Definition at line 141 of file storage32.c.

142{
143 static const DWORD version_magic = 0x02000001;
144 DWORD header[2];
146 HRESULT hr;
147
148 TRACE("%p\n", stg);
149
150 if (!stg) return E_INVALIDARG;
151
152 hr = IStorage_OpenStream(stg, L"\1Ole", NULL, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
153 if (FAILED(hr)) return hr;
154
155 hr = IStream_Read(stream, header, sizeof(header), NULL);
156 IStream_Release(stream);
157 if (FAILED(hr)) return hr;
158
159 if (header[0] != version_magic)
160 {
161 ERR("got wrong version magic for 1Ole stream, %#lx.\n", header[0]);
162 return E_FAIL;
163 }
164
165 return header[1] & OleStream_Convert ? S_OK : S_FALSE;
166}
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define L(x)
Definition: resources.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:940
#define STGM_READ
Definition: objbase.h:934
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
Definition: parse.h:23
#define S_FALSE
Definition: winerror.h:3451

Referenced by test_convert().

◆ ReadClassStg()

HRESULT WINAPI ReadClassStg ( IStorage pstg,
CLSID pclsid 
)

Definition at line 72 of file storage32.c.

73{
74 STATSTG pstatstg;
75 HRESULT hRes;
76
77 TRACE("(%p, %p)\n", pstg, pclsid);
78
79 if (!pstg || !pclsid)
80 return E_INVALIDARG;
81
82 /*
83 * read a STATSTG structure (contains the clsid) from the storage
84 */
85 hRes = IStorage_Stat(pstg, &pstatstg, STATFLAG_NONAME);
86
87 if (SUCCEEDED(hRes))
88 *pclsid = pstatstg.clsid;
89
90 return hRes;
91}
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by DataCache_InitNew(), DataCache_Load(), GetClassFile(), render_embed_source_hack(), and test_writeclassstg().

◆ ReadClassStm()

HRESULT WINAPI ReadClassStm ( IStream pStm,
CLSID pclsid 
)

Definition at line 109 of file storage32.c.

110{
111 ULONG nbByte;
112 HRESULT res;
113
114 TRACE("(%p,%p)\n", pStm, pclsid);
115
116 if (!pStm || !pclsid)
117 return E_INVALIDARG;
118
119 /* clear the output args */
120 *pclsid = CLSID_NULL;
121
122 res = IStream_Read(pStm, pclsid, sizeof(CLSID), &nbByte);
123
124 if (FAILED(res))
125 return res;
126
127 if (nbByte != sizeof(CLSID))
128 return STG_E_READFAULT;
129 else
130 return S_OK;
131}
GLuint res
Definition: glext.h:9613
#define CLSID_NULL
Definition: guiddef.h:99
uint32_t ULONG
Definition: typedefs.h:59
#define STG_E_READFAULT
Definition: winerror.h:3671

Referenced by OleLoadFromStream(), ReadFmtUserTypeStg(), and test_ReadClassStm().

◆ StgCreatePropSetStg()

HRESULT WINAPI StgCreatePropSetStg ( IStorage pstg,
DWORD  reserved,
IPropertySetStorage **  propset 
)

Definition at line 233 of file storage32.c.

234{
235 TRACE("%p, %#lx, %p.\n", pstg, reserved, propset);
236 if (reserved)
238
239 return IStorage_QueryInterface(pstg, &IID_IPropertySetStorage, (void**)propset);
240}
r reserved
Definition: btrfs.c:3006
#define STG_E_INVALIDPARAMETER
Definition: winerror.h:3675

Referenced by test_propertyset_storage_enum(), testCodepage(), and testPropsHelper().

◆ StgIsStorageFile()

HRESULT WINAPI StgIsStorageFile ( LPCOLESTR  fn)

Definition at line 191 of file storage32.c.

192{
193 HANDLE hf;
194 BYTE magic[8];
195 DWORD bytes_read;
196
197 TRACE("%s\n", debugstr_w(fn));
201
202 if (hf == INVALID_HANDLE_VALUE)
203 return STG_E_FILENOTFOUND;
204
205 if (!ReadFile(hf, magic, 8, &bytes_read, NULL))
206 {
207 WARN(" unable to read file\n");
208 CloseHandle(hf);
209 return S_FALSE;
210 }
211
212 CloseHandle(hf);
213
214 if (bytes_read != 8)
215 {
216 TRACE(" too short\n");
217 return S_FALSE;
218 }
219
220 if (!memcmp(magic, STORAGE_magic, 8))
221 {
222 TRACE(" -> YES\n");
223 return S_OK;
224 }
225
226 TRACE(" -> Invalid header.\n");
227 return S_FALSE;
228}
#define WARN(fmt,...)
Definition: precomp.h:61
static const BYTE STORAGE_magic[8]
Definition: storage32.c:53
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
#define debugstr_w
Definition: kernel32.h:32
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define STG_E_FILENOTFOUND
Definition: winerror.h:3660
unsigned char BYTE
Definition: xxhash.c:193

Referenced by GetClassFile().

◆ StgIsStorageILockBytes()

HRESULT WINAPI StgIsStorageILockBytes ( ILockBytes plkbyt)

Definition at line 171 of file storage32.c.

172{
173 BYTE sig[sizeof(STORAGE_magic)];
175 ULONG read = 0;
176
177 offset.HighPart = 0;
178 offset.LowPart = 0;
179
180 ILockBytes_ReadAt(plkbyt, offset, sig, sizeof(sig), &read);
181
182 if (read == sizeof(sig) && memcmp(sig, STORAGE_magic, sizeof(sig)) == 0)
183 return S_OK;
184
185 return S_FALSE;
186}
#define read
Definition: acwin.h:96
GLintptr offset
Definition: glext.h:5920

Referenced by get_stgmed_for_storage(), and test_hglobal_storage_stat().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( storage  )

◆ WriteClassStg()

HRESULT WINAPI WriteClassStg ( IStorage pStg,
REFCLSID  rclsid 
)

Definition at line 58 of file storage32.c.

59{
60 if (!pStg)
61 return E_INVALIDARG;
62
63 if (!rclsid)
65
66 return IStorage_SetClass(pStg, rclsid);
67}
#define STG_E_INVALIDPOINTER
Definition: winerror.h:3666

Referenced by OleCreateStaticFromData(), OleSave(), test_hglobal_storage_stat(), test_overwrite(), test_storage_refcount(), test_streamenum(), test_transacted_shared(), and test_writeclassstg().

◆ WriteClassStm()

HRESULT WINAPI WriteClassStm ( IStream pStm,
REFCLSID  rclsid 
)

Definition at line 96 of file storage32.c.

97{
98 TRACE("(%p,%p)\n", pStm, rclsid);
99
100 if (!pStm || !rclsid)
101 return E_INVALIDARG;
102
103 return IStream_Write(pStm, rclsid, sizeof(CLSID), NULL);
104}

Referenced by OLECONVERT_CreateCompObjStream(), OleSaveToStream(), STORAGE_WriteCompObj(), and test_ReadClassStm().

Variable Documentation

◆ STORAGE_magic

const BYTE STORAGE_magic[8] ={0xd0,0xcf,0x11,0xe0,0xa1,0xb1,0x1a,0xe1}
static