packager: Add loading support for Ole10Native storage objects.

This commit is contained in:
Andrew Eikum 2014-06-17 11:43:39 -05:00 committed by Alexandre Julliard
parent b456eb5213
commit d03c1cfc17
6 changed files with 684 additions and 2 deletions

1
configure vendored
View File

@ -17102,6 +17102,7 @@ wine_fn_config_dll opencl enable_opencl
wine_fn_config_dll opengl32 enable_opengl32 implib
wine_fn_config_test dlls/opengl32/tests opengl32_test
wine_fn_config_dll packager enable_packager clean
wine_fn_config_test dlls/packager/tests packager_test
wine_fn_config_dll pdh enable_pdh implib
wine_fn_config_test dlls/pdh/tests pdh_test
wine_fn_config_dll photometadatahandler enable_photometadatahandler

View File

@ -3076,6 +3076,7 @@ WINE_CONFIG_DLL(opencl)
WINE_CONFIG_DLL(opengl32,,[implib])
WINE_CONFIG_TEST(dlls/opengl32/tests)
WINE_CONFIG_DLL(packager,,[clean])
WINE_CONFIG_TEST(dlls/packager/tests)
WINE_CONFIG_DLL(pdh,,[implib])
WINE_CONFIG_TEST(dlls/pdh/tests)
WINE_CONFIG_DLL(photometadatahandler)

View File

@ -1,5 +1,5 @@
MODULE = packager.dll
IMPORTS = uuid
IMPORTS = uuid shell32 shlwapi user32
C_SRCS = \
packager_main.c

View File

@ -26,6 +26,9 @@
#include "winbase.h"
#include "ole2.h"
#include "rpcproxy.h"
#include "shellapi.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "packager_classes.h"
@ -36,8 +39,11 @@ static HINSTANCE g_instance;
struct Package {
IOleObject IOleObject_iface;
IPersistStorage IPersistStorage_iface;
LONG ref;
WCHAR filename[MAX_PATH];
};
static inline struct Package *impl_from_IOleObject(IOleObject *iface)
@ -45,6 +51,11 @@ static inline struct Package *impl_from_IOleObject(IOleObject *iface)
return CONTAINING_RECORD(iface, struct Package, IOleObject_iface);
}
static inline struct Package *impl_from_IPersistStorage(IPersistStorage *iface)
{
return CONTAINING_RECORD(iface, struct Package, IPersistStorage_iface);
}
static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, void **obj)
{
struct Package *This = impl_from_IOleObject(iface);
@ -53,6 +64,9 @@ static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, v
IsEqualGUID(riid, &IID_IOleObject)) {
TRACE("(%p)->(IID_IOleObject, %p)\n", This, obj);
*obj = &This->IOleObject_iface;
}else if(IsEqualGUID(riid, &IID_IPersistStorage)){
TRACE("(%p)->(IID_IPersistStorage, %p)\n", This, obj);
*obj = &This->IPersistStorage_iface;
}else {
FIXME("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
*obj = NULL;
@ -80,8 +94,12 @@ static ULONG WINAPI OleObject_Release(IOleObject *iface)
TRACE("(%p) ref=%d\n", This, ref);
if(!ref)
if(!ref){
if(*This->filename)
DeleteFileW(This->filename);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
@ -262,6 +280,262 @@ static const IOleObjectVtbl OleObject_Vtbl = {
OleObject_SetColorScheme
};
static HRESULT WINAPI PersistStorage_QueryInterface(IPersistStorage* iface,
REFIID riid, void **ppvObject)
{
struct Package *This = impl_from_IPersistStorage(iface);
return OleObject_QueryInterface(&This->IOleObject_iface, riid, ppvObject);
}
static ULONG WINAPI PersistStorage_AddRef(IPersistStorage* iface)
{
struct Package *This = impl_from_IPersistStorage(iface);
return OleObject_AddRef(&This->IOleObject_iface);
}
static ULONG WINAPI PersistStorage_Release(IPersistStorage* iface)
{
struct Package *This = impl_from_IPersistStorage(iface);
return OleObject_Release(&This->IOleObject_iface);
}
static HRESULT WINAPI PersistStorage_GetClassID(IPersistStorage* iface,
CLSID *pClassID)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)->(%p)\n", This, pClassID);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistStorage_IsDirty(IPersistStorage* iface)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistStorage_InitNew(IPersistStorage* iface,
IStorage *pStg)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)->(%p)\n", This, pStg);
return E_NOTIMPL;
}
static HRESULT discard_string(struct Package *This, IStream *stream)
{
ULONG nbytes;
HRESULT hr;
char chr = 0;
do{
hr = IStream_Read(stream, &chr, 1, &nbytes);
if(FAILED(hr) || !nbytes){
TRACE("Unexpected end of stream or Read failed with %08x\n", hr);
return (hr == S_OK || hr == S_FALSE) ? E_FAIL : hr;
}
}while(chr);
return S_OK;
}
static HRESULT WINAPI PersistStorage_Load(IPersistStorage* iface,
IStorage *pStg)
{
struct Package *This = impl_from_IPersistStorage(iface);
IStream *stream;
DWORD payload_size, len, stream_filename_len, filenameA_len, i, bytes_read;
ULARGE_INTEGER payload_pos;
LARGE_INTEGER seek;
HRESULT hr;
HANDLE file = INVALID_HANDLE_VALUE;
WCHAR filenameW[MAX_PATH];
char filenameA[MAX_PATH];
WCHAR *stream_filename;
WCHAR *base_end, extension[MAX_PATH];
static const WCHAR ole10nativeW[] = {0x0001,'O','l','e','1','0','N','a','t','i','v','e',0};
TRACE("(%p)->(%p)\n", This, pStg);
hr = IStorage_OpenStream(pStg, ole10nativeW, NULL,
STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &stream);
if(FAILED(hr)){
TRACE("OpenStream gave: %08x\n", hr);
return hr;
}
/* skip stream size & two unknown bytes */
seek.QuadPart = 6;
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
if(FAILED(hr))
goto exit;
/* read and discard label */
hr = discard_string(This, stream);
if(FAILED(hr))
goto exit;
/* read and discard filename */
hr = discard_string(This, stream);
if(FAILED(hr))
goto exit;
/* skip more unknown data */
seek.QuadPart = 4;
hr = IStream_Seek(stream, seek, STREAM_SEEK_CUR, NULL);
if(FAILED(hr))
goto exit;
/* ASCIIZ filename */
hr = IStream_Read(stream, &filenameA_len, 4, NULL);
if(FAILED(hr))
goto exit;
hr = IStream_Read(stream, filenameA, filenameA_len, NULL);
if(FAILED(hr))
goto exit;
/* skip payload for now */
hr = IStream_Read(stream, &payload_size, 4, NULL);
if(FAILED(hr))
goto exit;
seek.QuadPart = 0;
hr = IStream_Seek(stream, seek, STREAM_SEEK_CUR, &payload_pos);
if(FAILED(hr))
goto exit;
seek.QuadPart = payload_size;
hr = IStream_Seek(stream, seek, STREAM_SEEK_CUR, NULL);
if(FAILED(hr))
goto exit;
/* read WCHAR filename, if present */
hr = IStream_Read(stream, &len, 4, &bytes_read);
if(SUCCEEDED(hr) && bytes_read == 4 && len > 0){
hr = IStream_Read(stream, filenameW, len * sizeof(WCHAR), NULL);
if(FAILED(hr))
goto exit;
}else{
len = MultiByteToWideChar(CP_ACP, 0, filenameA, filenameA_len,
filenameW, sizeof(filenameW) / sizeof(*filenameW));
}
stream_filename = filenameW + len - 1;
while(stream_filename != filenameW &&
*stream_filename != '\\')
--stream_filename;
if(*stream_filename == '\\')
++stream_filename;
stream_filename_len = len - (stream_filename - filenameW);
len = GetTempPathW(sizeof(This->filename), This->filename);
memcpy(This->filename + len, stream_filename, stream_filename_len * sizeof(WCHAR));
This->filename[len + stream_filename_len] = 0;
/* read & write payload */
memcpy(&seek, &payload_pos, sizeof(seek)); /* STREAM_SEEK_SET treats as ULARGE_INTEGER */
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
if(FAILED(hr))
goto exit;
base_end = PathFindExtensionW(This->filename);
lstrcpyW(extension, base_end);
i = 1;
file = CreateFileW(This->filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
while(file == INVALID_HANDLE_VALUE){
static const WCHAR fmtW[] = {' ','(','%','u',')',0};
if(GetLastError() != ERROR_FILE_EXISTS){
WARN("CreateFile failed: %u\n", GetLastError());
hr = E_FAIL;
goto exit;
}
/* file exists, so increment file name and try again */
++i;
wsprintfW(base_end, fmtW, i);
lstrcatW(base_end, extension);
file = CreateFileW(This->filename, GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
}
TRACE("Final filename: %s\n", wine_dbgstr_w(This->filename));
while(payload_size){
ULONG nbytes;
BYTE data[4096];
DWORD written;
hr = IStream_Read(stream, data, min(sizeof(data), payload_size), &nbytes);
if(FAILED(hr) || nbytes == 0){
TRACE("Unexpected end of file, or Read failed with %08x\n", hr);
if(hr == S_OK || hr == S_FALSE)
hr = E_FAIL;
goto exit;
}
payload_size -= nbytes;
WriteFile(file, data, nbytes, &written, NULL);
}
hr = S_OK;
exit:
if(file != INVALID_HANDLE_VALUE){
CloseHandle(file);
if(FAILED(hr))
DeleteFileW(This->filename);
}
IStream_Release(stream);
TRACE("Returning: %08x\n", hr);
return hr;
}
static HRESULT WINAPI PersistStorage_Save(IPersistStorage* iface,
IStorage *pStgSave, BOOL fSameAsLoad)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)->(%p, %u)\n", This, pStgSave, fSameAsLoad);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistStorage_SaveCompleted(IPersistStorage* iface,
IStorage *pStgNew)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)->(%p)\n", This, pStgNew);
return E_NOTIMPL;
}
static HRESULT WINAPI PersistStorage_HandsOffStorage(IPersistStorage* iface)
{
struct Package *This = impl_from_IPersistStorage(iface);
FIXME("(%p)\n", This);
return E_NOTIMPL;
}
static IPersistStorageVtbl PersistStorage_Vtbl = {
PersistStorage_QueryInterface,
PersistStorage_AddRef,
PersistStorage_Release,
PersistStorage_GetClassID,
PersistStorage_IsDirty,
PersistStorage_InitNew,
PersistStorage_Load,
PersistStorage_Save,
PersistStorage_SaveCompleted,
PersistStorage_HandsOffStorage
};
static HRESULT WINAPI PackageCF_QueryInterface(IClassFactory *iface, REFIID riid, void **obj)
{
TRACE("(static)->(%s, %p)\n", debugstr_guid(riid), obj);
@ -305,6 +579,7 @@ static HRESULT WINAPI PackageCF_CreateInstance(IClassFactory *iface, IUnknown *o
return E_OUTOFMEMORY;
package->IOleObject_iface.lpVtbl = &OleObject_Vtbl;
package->IPersistStorage_iface.lpVtbl = &PersistStorage_Vtbl;
return IOleObject_QueryInterface(&package->IOleObject_iface, iid, obj);
}

View File

@ -0,0 +1,5 @@
TESTDLL = packager.dll
IMPORTS = ole32
C_SRCS = \
oleobj.c

View File

@ -0,0 +1,400 @@
/*
* Copyright 2014 Andrew Eikum for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <initguid.h>
#include <olectl.h>
#include "wine/test.h"
DEFINE_GUID(CLSID_Package, 0xf20da720, 0xc02f, 0x11ce, 0x92,0x7b, 0x08,0x00,0x09,0x5a,0xe3,0x40);
DEFINE_GUID(CLSID_Package_Alt, 0x0003000C, 0x0000, 0x0000, 0xC0,0x00, 0x00,0x00,0x00,0x00,0x00,0x46);
static HRESULT WINAPI ole10native_stream_QueryInterface(IStream* This, REFIID riid,
void **ppvObject)
{
ok(0, "queryinterface\n");
return E_NOTIMPL;
}
static ULONG WINAPI ole10native_stream_AddRef(IStream* This)
{
return 2;
}
static ULONG WINAPI ole10native_stream_Release(IStream* This)
{
return 1;
}
static UINT offs = 0;
static HRESULT WINAPI ole10native_stream_Read(IStream* This, void *pv, ULONG cb,
ULONG *pcbRead)
{
ULONG to_read;
static BYTE data[] = {
0xa5, 0x00, 0x00, 0x00, /* total size */
0x02, 0x00, /* ?? */
'l','a','b','e','l','.','t','x','t',0, /* label? */
'f','i','l','e','n','a','m','e','.','t','x','t',0, /* original filename? */
0x00, 0x00, /* ?? */
0x03, 0x00, /* ?? */
0x10, 0x00, 0x00, 0x00, /* ASCIIZ filename size */
'C',':','\\','f','i','l','e','n','a','m','e','2','.','t','x','t', /* ASCIIZ filename */
0x0a, 0x00, 0x00, 0x00, /* payload size */
's','o','m','e',' ','t','e','x','t','\n', /* payload */
0x10, 0x00, 0x00, 0x00, /* WCHAR filename size */
'C',0,':',0,'\\',0,'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'3',0,'.',0,'t',0,'x',0,'t',0, /* WCHAR filename */
0x0d, 0x00, 0x00, 0x00, /* another filename size */
'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'4',0,'.',0,'t',0,'x',0,'t',0, /* another filename */
0x10, 0x00, 0x00, 0x00, /* another filename size */
'C',0,':',0,'\\',0,'f',0,'i',0,'l',0,'e',0,'n',0,'a',0,'m',0,'e',0,'5',0,'.',0,'t',0,'x',0,'t',0, /* another filename */
};
to_read = min(sizeof(data) - offs, cb);
memcpy(pv, data + offs, to_read);
if(pcbRead)
*pcbRead = to_read;
offs += to_read;
return cb == to_read ? S_OK : S_FALSE;
}
static HRESULT WINAPI ole10native_stream_Write(IStream* This, const void *pv,
ULONG cb, ULONG *pcbWritten)
{
ok(0, "write\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_Seek(IStream* This, LARGE_INTEGER dlibMove,
DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
{
if(dwOrigin == STREAM_SEEK_CUR)
offs += dlibMove.u.LowPart;
else if(dwOrigin == STREAM_SEEK_SET)
offs = dlibMove.u.LowPart;
if(plibNewPosition){
plibNewPosition->u.HighPart = 0;
plibNewPosition->u.LowPart = offs;
}
return S_OK;
}
static HRESULT WINAPI ole10native_stream_SetSize(IStream* This,
ULARGE_INTEGER libNewSize)
{
ok(0, "setsize\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_CopyTo(IStream* This, IStream *pstm,
ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
{
ok(0, "copyto\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_Commit(IStream* This, DWORD grfCommitFlags)
{
ok(0, "commit\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_Revert(IStream* This)
{
ok(0, "revert\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_LockRegion(IStream* This,
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
{
ok(0, "lockregion\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_UnlockRegion(IStream* This,
ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
{
ok(0, "unlockregion\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_Stat(IStream* This, STATSTG *pstatstg,
DWORD grfStatFlag)
{
ok(0, "stat\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ole10native_stream_Clone(IStream* This, IStream **ppstm)
{
ok(0, "clone\n");
return E_NOTIMPL;
}
static IStreamVtbl ole10native_stream_vtbl = {
ole10native_stream_QueryInterface,
ole10native_stream_AddRef,
ole10native_stream_Release,
ole10native_stream_Read,
ole10native_stream_Write,
ole10native_stream_Seek,
ole10native_stream_SetSize,
ole10native_stream_CopyTo,
ole10native_stream_Commit,
ole10native_stream_Revert,
ole10native_stream_LockRegion,
ole10native_stream_UnlockRegion,
ole10native_stream_Stat,
ole10native_stream_Clone
};
static IStream ole10native_stream = {
&ole10native_stream_vtbl
};
HRESULT WINAPI stg_QueryInterface(IStorage* This, REFIID riid,
void **ppvObject)
{
ok(0, "queryinterface: %s\n", wine_dbgstr_guid(riid));
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IStorage)){
*ppvObject = This;
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG WINAPI stg_AddRef(IStorage* This)
{
return 2;
}
static ULONG WINAPI stg_Release(IStorage* This)
{
return 1;
}
static HRESULT WINAPI stg_CreateStream(IStorage* This, LPCOLESTR pwcsName,
DWORD grfMode, DWORD reserved1, DWORD reserved2, IStream **ppstm)
{
return E_NOTIMPL;
}
HRESULT WINAPI stg_OpenStream(IStorage* This, LPCOLESTR pwcsName,
void *reserved1, DWORD grfMode, DWORD reserved2, IStream **ppstm)
{
static const WCHAR ole10NativeW[] = {1,'O','l','e','1','0','N','a','t','i','v','e',0};
if(lstrcmpW(pwcsName, ole10NativeW))
return STG_E_FILENOTFOUND;
*ppstm = &ole10native_stream;
return S_OK;
}
HRESULT WINAPI stg_CreateStorage(IStorage* This, LPCOLESTR pwcsName,
DWORD grfMode, DWORD dwStgFmt, DWORD reserved2, IStorage **ppstg)
{
ok(0, "createstorage\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_OpenStorage(IStorage* This, LPCOLESTR pwcsName,
IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved,
IStorage **ppstg)
{
ok(0, "openstorage: %s\n", wine_dbgstr_w(pwcsName));
return E_NOTIMPL;
}
HRESULT WINAPI stg_CopyTo(IStorage* This, DWORD ciidExclude,
const IID *rgiidExclude, SNB snbExclude, IStorage *pstgDest)
{
ok(0, "copyto\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_MoveElementTo(IStorage* This, LPCOLESTR pwcsName,
IStorage *pstgDest, LPCOLESTR pwcsNewName, DWORD grfFlags)
{
ok(0, "moveelem\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_Commit(IStorage* This, DWORD grfCommitFlags)
{
ok(0, "commit\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_Revert(IStorage* This)
{
ok(0, "revert\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_EnumElements(IStorage* This, DWORD reserved1,
void *reserved2, DWORD reserved3, IEnumSTATSTG **ppenum)
{
ok(0, "enumelem\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_DestroyElement(IStorage* This, LPCOLESTR pwcsName)
{
ok(0, "destroyelem\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_RenameElement(IStorage* This, LPCOLESTR pwcsOldName,
LPCOLESTR pwcsNewName)
{
ok(0, "renamelem\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_SetElementTimes(IStorage* This, LPCOLESTR pwcsName,
const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
{
ok(0, "setelem\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_SetClass(IStorage* This, REFCLSID clsid)
{
ok(0, "setclass\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_SetStateBits(IStorage* This, DWORD grfStateBits,
DWORD grfMask)
{
ok(0, "setstate\n");
return E_NOTIMPL;
}
HRESULT WINAPI stg_Stat(IStorage* This, STATSTG *pstatstg, DWORD grfStatFlag)
{
memset(pstatstg, 0, sizeof(*pstatstg));
pstatstg->clsid = CLSID_Package;
pstatstg->type = STGTY_STORAGE;
return S_OK;
}
static IStorageVtbl stg_vtbl = {
stg_QueryInterface,
stg_AddRef,
stg_Release,
stg_CreateStream,
stg_OpenStream,
stg_CreateStorage,
stg_OpenStorage,
stg_CopyTo,
stg_MoveElementTo,
stg_Commit,
stg_Revert,
stg_EnumElements,
stg_DestroyElement,
stg_RenameElement,
stg_SetElementTimes,
stg_SetClass,
stg_SetStateBits,
stg_Stat,
};
static IStorage stg = {
&stg_vtbl
};
static void test_packager(void)
{
IOleObject *oleobj;
IPersistStorage *persist;
DWORD len, bytes_read;
HRESULT hr;
HANDLE file;
WCHAR filename[MAX_PATH];
char contents[11];
BOOL br, extended = FALSE;
static const WCHAR filename3W[] = {'f','i','l','e','n','a','m','e','3','.','t','x','t',0};
hr = CoCreateInstance(&CLSID_Package, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
&IID_IOleObject, (void**)&oleobj);
ok(hr == S_OK ||
hr == REGDB_E_CLASSNOTREG, "CoCreateInstance(CLSID_Package) failed: %08x\n", hr);
if(hr == S_OK){
IOleObject_Release(oleobj);
/* older OSes store temporary files in obscure locations, so don't run
* the full tests on them */
extended = TRUE;
}else
win_skip("Older OS doesn't support modern packager\n");
hr = CoCreateInstance(&CLSID_Package_Alt, NULL, CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER,
&IID_IOleObject, (void**)&oleobj);
ok(hr == S_OK, "CoCreateInstance(CLSID_Package_Alt) failed: %08x\n", hr);
hr = IOleObject_QueryInterface(oleobj, &IID_IPersistStorage, (void**)&persist);
ok(hr == S_OK, "QueryInterface(IPersistStorage) failed: %08x\n", hr);
hr = IPersistStorage_Load(persist, &stg);
ok(hr == S_OK, "Load failed: %08x\n", hr);
if(extended){
len = GetTempPathW(sizeof(filename) / sizeof(*filename), filename);
lstrcpyW(filename + len, filename3W);
file = CreateFileW(filename, GENERIC_READ, 0, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
ok(file != INVALID_HANDLE_VALUE, "Couldn't find temporary file %s: %u\n",
wine_dbgstr_w(filename), GetLastError());
br = ReadFile(file, contents, sizeof(contents), &bytes_read, NULL);
ok(br == TRUE, "ReadFile failed\n");
ok(bytes_read == 10, "Got wrong file size: %u\n", bytes_read);
ok(!memcmp(contents, "some text\n", 10), "Got wrong file contents\n");
CloseHandle(file);
}
IPersistStorage_Release(persist);
IOleObject_Release(oleobj);
}
START_TEST(oleobj)
{
CoInitialize(NULL);
test_packager();
CoUninitialize();
}