mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[OLE32_WINETEST]
* Sync with Wine 1.7.1. CORE-7469 svn path=/trunk/; revision=60355
This commit is contained in:
parent
01f85a4410
commit
4fddbeb50b
9 changed files with 1116 additions and 74 deletions
|
@ -1,6 +1,4 @@
|
||||||
|
|
||||||
add_definitions(-D__ROS_LONG64__)
|
|
||||||
|
|
||||||
list(APPEND SOURCE
|
list(APPEND SOURCE
|
||||||
clipboard.c
|
clipboard.c
|
||||||
compobj.c
|
compobj.c
|
||||||
|
@ -11,6 +9,7 @@ list(APPEND SOURCE
|
||||||
marshal.c
|
marshal.c
|
||||||
moniker.c
|
moniker.c
|
||||||
ole2.c
|
ole2.c
|
||||||
|
ole_server.c
|
||||||
propvariant.c
|
propvariant.c
|
||||||
stg_prop.c
|
stg_prop.c
|
||||||
storage32.c
|
storage32.c
|
||||||
|
@ -18,7 +17,7 @@ list(APPEND SOURCE
|
||||||
testlist.c)
|
testlist.c)
|
||||||
|
|
||||||
add_executable(ole32_winetest ${SOURCE})
|
add_executable(ole32_winetest ${SOURCE})
|
||||||
target_link_libraries(ole32_winetest wine uuid)
|
target_link_libraries(ole32_winetest uuid)
|
||||||
set_module_type(ole32_winetest win32cui)
|
set_module_type(ole32_winetest win32cui)
|
||||||
add_importlibs(ole32_winetest oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel32 ntdll)
|
add_importlibs(ole32_winetest oleaut32 ole32 user32 gdi32 advapi32 msvcrt kernel32)
|
||||||
add_cd_file(TARGET ole32_winetest DESTINATION reactos/bin FOR all)
|
add_cd_file(TARGET ole32_winetest DESTINATION reactos/bin FOR all)
|
||||||
|
|
|
@ -748,8 +748,8 @@ static void test_cf_dataobject(IDataObject *data)
|
||||||
cfs_seen[count] = fmt.cfFormat;
|
cfs_seen[count] = fmt.cfFormat;
|
||||||
ok(fmt_ptr->first_use_of_cf != seen_cf, "got %08x expected %08x\n",
|
ok(fmt_ptr->first_use_of_cf != seen_cf, "got %08x expected %08x\n",
|
||||||
fmt_ptr->first_use_of_cf, !seen_cf);
|
fmt_ptr->first_use_of_cf, !seen_cf);
|
||||||
ok(fmt_ptr->res[0] == 0, "got %08x\n", fmt_ptr->res[1]);
|
ok(fmt_ptr->res[0] == 0, "got %08x\n", fmt_ptr->res[0]);
|
||||||
ok(fmt_ptr->res[1] == 0, "got %08x\n", fmt_ptr->res[2]);
|
ok(fmt_ptr->res[1] == 0, "got %08x\n", fmt_ptr->res[1]);
|
||||||
if(fmt.ptd)
|
if(fmt.ptd)
|
||||||
{
|
{
|
||||||
DVTARGETDEVICE *target;
|
DVTARGETDEVICE *target;
|
||||||
|
|
|
@ -26,12 +26,14 @@
|
||||||
#define CONST_VTABLE
|
#define CONST_VTABLE
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
|
#include <winnls.h>
|
||||||
#include <winreg.h>
|
#include <winreg.h>
|
||||||
#define USE_COM_CONTEXT_DEF
|
#define USE_COM_CONTEXT_DEF
|
||||||
//#include "initguid.h"
|
#include <initguid.h>
|
||||||
//#include "objbase.h"
|
//#include "objbase.h"
|
||||||
//#include "shlguid.h"
|
//#include "shlguid.h"
|
||||||
#include <ole2.h>
|
#include <ole2.h>
|
||||||
|
@ -51,12 +53,23 @@ static HRESULT (WINAPI * pCoGetTreatAsClass)(REFCLSID clsidOld, LPCLSID pClsidNe
|
||||||
static HRESULT (WINAPI * pCoGetContextToken)(ULONG_PTR *token);
|
static HRESULT (WINAPI * pCoGetContextToken)(ULONG_PTR *token);
|
||||||
static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override);
|
static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override);
|
||||||
|
|
||||||
|
static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
|
||||||
|
static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
|
||||||
|
static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
|
||||||
|
static void (WINAPI *pReleaseActCtx)(HANDLE);
|
||||||
|
|
||||||
#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
|
#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
|
||||||
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
|
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
|
||||||
#define ok_no_locks() ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)
|
#define ok_no_locks() ok(cLocks == 0, "Number of locks should be 0, but actually is %d\n", cLocks)
|
||||||
|
|
||||||
static const CLSID CLSID_non_existent = { 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
static const CLSID CLSID_non_existent = { 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
||||||
static const CLSID CLSID_StdFont = { 0x0be35203, 0x8f91, 0x11ce, { 0x9d, 0xe3, 0x00, 0xaa, 0x00, 0x4b, 0xb8, 0x51 } };
|
static const CLSID CLSID_StdFont = { 0x0be35203, 0x8f91, 0x11ce, { 0x9d, 0xe3, 0x00, 0xaa, 0x00, 0x4b, 0xb8, 0x51 } };
|
||||||
|
static const GUID IID_Testiface = { 0x22222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
||||||
|
static const GUID IID_Testiface2 = { 0x32222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
||||||
|
static const GUID IID_Testiface3 = { 0x42222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
||||||
|
static const GUID IID_Testiface4 = { 0x52222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
|
||||||
|
static const GUID IID_TestPS = { 0x66666666, 0x8888, 0x7777, { 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 } };
|
||||||
|
|
||||||
static WCHAR stdfont[] = {'S','t','d','F','o','n','t',0};
|
static WCHAR stdfont[] = {'S','t','d','F','o','n','t',0};
|
||||||
static const WCHAR wszNonExistent[] = {'N','o','n','E','x','i','s','t','e','n','t',0};
|
static const WCHAR wszNonExistent[] = {'N','o','n','E','x','i','s','t','e','n','t',0};
|
||||||
static WCHAR wszCLSID_StdFont[] =
|
static WCHAR wszCLSID_StdFont[] =
|
||||||
|
@ -64,20 +77,22 @@ static WCHAR wszCLSID_StdFont[] =
|
||||||
'{','0','b','e','3','5','2','0','3','-','8','f','9','1','-','1','1','c','e','-',
|
'{','0','b','e','3','5','2','0','3','-','8','f','9','1','-','1','1','c','e','-',
|
||||||
'9','d','e','3','-','0','0','a','a','0','0','4','b','b','8','5','1','}',0
|
'9','d','e','3','-','0','0','a','a','0','0','4','b','b','8','5','1','}',0
|
||||||
};
|
};
|
||||||
|
static const WCHAR progidW[] = {'P','r','o','g','I','d','.','P','r','o','g','I','d',0};
|
||||||
|
|
||||||
static const IID IID_IWineTest =
|
DEFINE_GUID(IID_IWineTest, 0x5201163f, 0x8164, 0x4fd0, 0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd);
|
||||||
|
DEFINE_GUID(CLSID_WineOOPTest, 0x5201163f, 0x8164, 0x4fd0, 0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd);
|
||||||
|
|
||||||
|
static const char *debugstr_guid(REFIID riid)
|
||||||
{
|
{
|
||||||
0x5201163f,
|
static char buf[50];
|
||||||
0x8164,
|
|
||||||
0x4fd0,
|
sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||||
{0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd}
|
riid->Data1, riid->Data2, riid->Data3, riid->Data4[0],
|
||||||
}; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
|
riid->Data4[1], riid->Data4[2], riid->Data4[3], riid->Data4[4],
|
||||||
static const CLSID CLSID_WineOOPTest = {
|
riid->Data4[5], riid->Data4[6], riid->Data4[7]);
|
||||||
0x5201163f,
|
|
||||||
0x8164,
|
return buf;
|
||||||
0x4fd0,
|
}
|
||||||
{0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd}
|
|
||||||
}; /* 5201163f-8164-4fd0-a1a2-5d5a3654d3bd */
|
|
||||||
|
|
||||||
static LONG cLocks;
|
static LONG cLocks;
|
||||||
|
|
||||||
|
@ -151,10 +166,117 @@ static const IClassFactoryVtbl TestClassFactory_Vtbl =
|
||||||
|
|
||||||
static IClassFactory Test_ClassFactory = { &TestClassFactory_Vtbl };
|
static IClassFactory Test_ClassFactory = { &TestClassFactory_Vtbl };
|
||||||
|
|
||||||
|
static WCHAR manifest_path[MAX_PATH];
|
||||||
|
|
||||||
|
static BOOL create_manifest_file(const char *filename, const char *manifest)
|
||||||
|
{
|
||||||
|
int manifest_len;
|
||||||
|
DWORD size;
|
||||||
|
HANDLE file;
|
||||||
|
WCHAR path[MAX_PATH];
|
||||||
|
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, filename, -1, path, MAX_PATH );
|
||||||
|
GetFullPathNameW(path, sizeof(manifest_path)/sizeof(WCHAR), manifest_path, NULL);
|
||||||
|
|
||||||
|
manifest_len = strlen(manifest);
|
||||||
|
file = CreateFileW(path, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
||||||
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
|
||||||
|
if(file == INVALID_HANDLE_VALUE)
|
||||||
|
return FALSE;
|
||||||
|
WriteFile(file, manifest, manifest_len, &size, NULL);
|
||||||
|
CloseHandle(file);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
|
||||||
|
{
|
||||||
|
WCHAR path[MAX_PATH];
|
||||||
|
ACTCTXW actctx;
|
||||||
|
HANDLE handle;
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
if (!pCreateActCtxW) return NULL;
|
||||||
|
|
||||||
|
create_manifest_file("file.manifest", manifest);
|
||||||
|
|
||||||
|
MultiByteToWideChar( CP_ACP, 0, "file.manifest", -1, path, MAX_PATH );
|
||||||
|
memset(&actctx, 0, sizeof(ACTCTXW));
|
||||||
|
actctx.cbSize = sizeof(ACTCTXW);
|
||||||
|
actctx.lpSource = path;
|
||||||
|
|
||||||
|
handle = pCreateActCtxW(&actctx);
|
||||||
|
ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
|
||||||
|
|
||||||
|
ok(actctx.cbSize == sizeof(ACTCTXW), "actctx.cbSize=%d\n", actctx.cbSize);
|
||||||
|
ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
|
||||||
|
ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
|
||||||
|
ok(actctx.wProcessorArchitecture == 0, "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
|
||||||
|
ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
|
||||||
|
ok(actctx.lpAssemblyDirectory == NULL, "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
|
||||||
|
ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
|
||||||
|
ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n", actctx.lpApplicationName);
|
||||||
|
ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
|
||||||
|
|
||||||
|
DeleteFileA("file.manifest");
|
||||||
|
|
||||||
|
ret = pActivateActCtx(handle, cookie);
|
||||||
|
ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
|
||||||
|
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char actctx_manifest[] =
|
||||||
|
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
|
||||||
|
"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
|
||||||
|
" publicKeyToken=\"6595b6414666f1df\" />"
|
||||||
|
"<file name=\"testlib.dll\">"
|
||||||
|
" <comClass description=\"Test com class\""
|
||||||
|
" clsid=\"{12345678-1234-1234-1234-56789abcdef0}\""
|
||||||
|
" progid=\"ProgId.ProgId\""
|
||||||
|
" miscStatusIcon=\"recomposeonresize\""
|
||||||
|
" />"
|
||||||
|
" <comClass clsid=\"{0be35203-8f91-11ce-9de3-00aa004bb851}\""
|
||||||
|
" progid=\"CustomFont\""
|
||||||
|
" miscStatusIcon=\"recomposeonresize\""
|
||||||
|
" miscStatusContent=\"insideout\""
|
||||||
|
" />"
|
||||||
|
" <comClass clsid=\"{0be35203-8f91-11ce-9de3-00aa004bb852}\""
|
||||||
|
" progid=\"StdFont\""
|
||||||
|
" />"
|
||||||
|
" <comInterfaceProxyStub "
|
||||||
|
" name=\"Iifaceps\""
|
||||||
|
" iid=\"{22222222-1234-1234-1234-56789abcdef0}\""
|
||||||
|
" proxyStubClsid32=\"{66666666-8888-7777-6666-555555555555}\""
|
||||||
|
" />"
|
||||||
|
"</file>"
|
||||||
|
" <comInterfaceExternalProxyStub "
|
||||||
|
" name=\"Iifaceps2\""
|
||||||
|
" iid=\"{32222222-1234-1234-1234-56789abcdef0}\""
|
||||||
|
" />"
|
||||||
|
" <comInterfaceExternalProxyStub "
|
||||||
|
" name=\"Iifaceps3\""
|
||||||
|
" iid=\"{42222222-1234-1234-1234-56789abcdef0}\""
|
||||||
|
" proxyStubClsid32=\"{66666666-8888-7777-6666-555555555555}\""
|
||||||
|
" />"
|
||||||
|
" <comInterfaceExternalProxyStub "
|
||||||
|
" name=\"Iifaceps4\""
|
||||||
|
" iid=\"{52222222-1234-1234-1234-56789abcdef0}\""
|
||||||
|
" proxyStubClsid32=\"{00000000-0000-0000-0000-000000000000}\""
|
||||||
|
" />"
|
||||||
|
"</assembly>";
|
||||||
|
|
||||||
|
DEFINE_GUID(CLSID_Testclass, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0);
|
||||||
|
|
||||||
static void test_ProgIDFromCLSID(void)
|
static void test_ProgIDFromCLSID(void)
|
||||||
{
|
{
|
||||||
|
ULONG_PTR cookie = 0;
|
||||||
LPWSTR progid;
|
LPWSTR progid;
|
||||||
HRESULT hr = ProgIDFromCLSID(&CLSID_StdFont, &progid);
|
HANDLE handle;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = ProgIDFromCLSID(&CLSID_StdFont, &progid);
|
||||||
ok(hr == S_OK, "ProgIDFromCLSID failed with error 0x%08x\n", hr);
|
ok(hr == S_OK, "ProgIDFromCLSID failed with error 0x%08x\n", hr);
|
||||||
if (hr == S_OK)
|
if (hr == S_OK)
|
||||||
{
|
{
|
||||||
|
@ -169,10 +291,37 @@ static void test_ProgIDFromCLSID(void)
|
||||||
|
|
||||||
hr = ProgIDFromCLSID(&CLSID_StdFont, NULL);
|
hr = ProgIDFromCLSID(&CLSID_StdFont, NULL);
|
||||||
ok(hr == E_INVALIDARG, "ProgIDFromCLSID should return E_INVALIDARG instead of 0x%08x\n", hr);
|
ok(hr == E_INVALIDARG, "ProgIDFromCLSID should return E_INVALIDARG instead of 0x%08x\n", hr);
|
||||||
|
|
||||||
|
if ((handle = activate_context(actctx_manifest, &cookie)))
|
||||||
|
{
|
||||||
|
static const WCHAR customfontW[] = {'C','u','s','t','o','m','F','o','n','t',0};
|
||||||
|
|
||||||
|
hr = ProgIDFromCLSID(&CLSID_non_existent, &progid);
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
ok(!lstrcmpiW(progid, progidW), "got %s\n", wine_dbgstr_w(progid));
|
||||||
|
CoTaskMemFree(progid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* try something registered and redirected */
|
||||||
|
progid = NULL;
|
||||||
|
hr = ProgIDFromCLSID(&CLSID_StdFont, &progid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
todo_wine
|
||||||
|
ok(!lstrcmpiW(progid, customfontW), "got wrong progid %s\n", wine_dbgstr_w(progid));
|
||||||
|
CoTaskMemFree(progid);
|
||||||
|
|
||||||
|
pDeactivateActCtx(0, cookie);
|
||||||
|
pReleaseActCtx(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_CLSIDFromProgID(void)
|
static void test_CLSIDFromProgID(void)
|
||||||
{
|
{
|
||||||
|
ULONG_PTR cookie = 0;
|
||||||
|
HANDLE handle;
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
HRESULT hr = CLSIDFromProgID(stdfont, &clsid);
|
HRESULT hr = CLSIDFromProgID(stdfont, &clsid);
|
||||||
ok(hr == S_OK, "CLSIDFromProgID failed with error 0x%08x\n", hr);
|
ok(hr == S_OK, "CLSIDFromProgID failed with error 0x%08x\n", hr);
|
||||||
|
@ -194,6 +343,40 @@ static void test_CLSIDFromProgID(void)
|
||||||
hr = CLSIDFromProgID(wszNonExistent, &clsid);
|
hr = CLSIDFromProgID(wszNonExistent, &clsid);
|
||||||
ok(hr == CO_E_CLASSSTRING, "CLSIDFromProgID on nonexistent ProgID should have returned CO_E_CLASSSTRING instead of 0x%08x\n", hr);
|
ok(hr == CO_E_CLASSSTRING, "CLSIDFromProgID on nonexistent ProgID should have returned CO_E_CLASSSTRING instead of 0x%08x\n", hr);
|
||||||
ok(IsEqualCLSID(&clsid, &CLSID_NULL), "CLSIDFromProgID should have set clsid to all-zeros on failure\n");
|
ok(IsEqualCLSID(&clsid, &CLSID_NULL), "CLSIDFromProgID should have set clsid to all-zeros on failure\n");
|
||||||
|
|
||||||
|
/* fails without proper context */
|
||||||
|
memset(&clsid, 0xcc, sizeof(clsid));
|
||||||
|
hr = CLSIDFromProgID(progidW, &clsid);
|
||||||
|
ok(hr == CO_E_CLASSSTRING, "got 0x%08x\n", hr);
|
||||||
|
ok(IsEqualCLSID(&clsid, &CLSID_NULL), "wrong clsid\n");
|
||||||
|
|
||||||
|
if ((handle = activate_context(actctx_manifest, &cookie)))
|
||||||
|
{
|
||||||
|
GUID clsid1;
|
||||||
|
|
||||||
|
clsid = CLSID_NULL;
|
||||||
|
hr = CLSIDFromProgID(progidW, &clsid);
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
if (hr == S_OK)
|
||||||
|
/* it returns generated CLSID here */
|
||||||
|
ok(!IsEqualCLSID(&clsid, &CLSID_non_existent) && !IsEqualCLSID(&clsid, &CLSID_NULL),
|
||||||
|
"got wrong clsid %s\n", debugstr_guid(&clsid));
|
||||||
|
|
||||||
|
/* duplicate progid present in context - returns generated guid here too */
|
||||||
|
clsid = CLSID_NULL;
|
||||||
|
hr = CLSIDFromProgID(stdfont, &clsid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
clsid1 = CLSID_StdFont;
|
||||||
|
/* that's where it differs from StdFont */
|
||||||
|
clsid1.Data4[7] = 0x52;
|
||||||
|
todo_wine
|
||||||
|
ok(!IsEqualCLSID(&clsid, &CLSID_StdFont) && !IsEqualCLSID(&clsid, &CLSID_NULL) && !IsEqualCLSID(&clsid, &clsid1),
|
||||||
|
"got %s\n", debugstr_guid(&clsid));
|
||||||
|
|
||||||
|
pDeactivateActCtx(0, cookie);
|
||||||
|
pReleaseActCtx(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_CLSIDFromString(void)
|
static void test_CLSIDFromString(void)
|
||||||
|
@ -439,6 +622,12 @@ static void test_CoGetClassObject(void)
|
||||||
CloseHandle(info.wait);
|
CloseHandle(info.wait);
|
||||||
CloseHandle(info.stop);
|
CloseHandle(info.stop);
|
||||||
|
|
||||||
|
if (!pRegOverridePredefKey)
|
||||||
|
{
|
||||||
|
win_skip("RegOverridePredefKey not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
|
|
||||||
hr = CoGetClassObject(rclsid, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
|
hr = CoGetClassObject(rclsid, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
|
||||||
|
@ -446,8 +635,9 @@ static void test_CoGetClassObject(void)
|
||||||
{
|
{
|
||||||
IUnknown_Release(pUnk);
|
IUnknown_Release(pUnk);
|
||||||
|
|
||||||
res = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &hkey);
|
res = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, NULL, 0,
|
||||||
ok(!res, "RegOpenKeyExA returned %d\n", res);
|
KEY_ALL_ACCESS, NULL, &hkey, NULL);
|
||||||
|
ok(!res, "RegCreateKeyEx returned %d\n", res);
|
||||||
|
|
||||||
res = pRegOverridePredefKey(HKEY_CLASSES_ROOT, hkey);
|
res = pRegOverridePredefKey(HKEY_CLASSES_ROOT, hkey);
|
||||||
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
||||||
|
@ -748,6 +938,8 @@ static void test_CoRegisterPSClsid(void)
|
||||||
|
|
||||||
static void test_CoGetPSClsid(void)
|
static void test_CoGetPSClsid(void)
|
||||||
{
|
{
|
||||||
|
ULONG_PTR cookie;
|
||||||
|
HANDLE handle;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
CLSID clsid;
|
CLSID clsid;
|
||||||
HKEY hkey;
|
HKEY hkey;
|
||||||
|
@ -782,8 +974,9 @@ static void test_CoGetPSClsid(void)
|
||||||
hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
|
hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
|
||||||
ok_ole_success(hr, "CoGetPSClsid");
|
ok_ole_success(hr, "CoGetPSClsid");
|
||||||
|
|
||||||
res = RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &hkey);
|
res = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, NULL, 0,
|
||||||
ok(!res, "RegOpenKeyExA returned %d\n", res);
|
KEY_ALL_ACCESS, NULL, &hkey, NULL);
|
||||||
|
ok(!res, "RegCreateKeyEx returned %d\n", res);
|
||||||
|
|
||||||
res = pRegOverridePredefKey(HKEY_CLASSES_ROOT, hkey);
|
res = pRegOverridePredefKey(HKEY_CLASSES_ROOT, hkey);
|
||||||
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
||||||
|
@ -795,6 +988,38 @@ static void test_CoGetPSClsid(void)
|
||||||
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
ok(!res, "RegOverridePredefKey returned %d\n", res);
|
||||||
|
|
||||||
RegCloseKey(hkey);
|
RegCloseKey(hkey);
|
||||||
|
|
||||||
|
/* not registered CLSID */
|
||||||
|
hr = CoGetPSClsid(&IID_Testiface, &clsid);
|
||||||
|
ok(hr == REGDB_E_IIDNOTREG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
if ((handle = activate_context(actctx_manifest, &cookie)))
|
||||||
|
{
|
||||||
|
todo_wine {
|
||||||
|
memset(&clsid, 0, sizeof(clsid));
|
||||||
|
hr = CoGetPSClsid(&IID_Testiface, &clsid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(IsEqualGUID(&clsid, &IID_Testiface), "got clsid %s\n", debugstr_guid(&clsid));
|
||||||
|
|
||||||
|
memset(&clsid, 0, sizeof(clsid));
|
||||||
|
hr = CoGetPSClsid(&IID_Testiface2, &clsid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(IsEqualGUID(&clsid, &IID_Testiface2), "got clsid %s\n", debugstr_guid(&clsid));
|
||||||
|
|
||||||
|
memset(&clsid, 0, sizeof(clsid));
|
||||||
|
hr = CoGetPSClsid(&IID_Testiface3, &clsid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(IsEqualGUID(&clsid, &IID_TestPS), "got clsid %s\n", debugstr_guid(&clsid));
|
||||||
|
|
||||||
|
memset(&clsid, 0xaa, sizeof(clsid));
|
||||||
|
hr = CoGetPSClsid(&IID_Testiface4, &clsid);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(IsEqualGUID(&clsid, &GUID_NULL), "got clsid %s\n", debugstr_guid(&clsid));
|
||||||
|
}
|
||||||
|
pDeactivateActCtx(0, cookie);
|
||||||
|
pReleaseActCtx(handle);
|
||||||
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1568,16 +1793,77 @@ static void test_CoInitializeEx(void)
|
||||||
OleUninitialize();
|
OleUninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(compobj)
|
static void test_OleRegGetMiscStatus(void)
|
||||||
{
|
{
|
||||||
HMODULE hOle32 = GetModuleHandle("ole32");
|
ULONG_PTR cookie;
|
||||||
HMODULE hAdvapi32 = GetModuleHandle("advapi32");
|
HANDLE handle;
|
||||||
|
DWORD status;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_Testclass, DVASPECT_ICON, NULL);
|
||||||
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
status = 0xdeadbeef;
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_Testclass, DVASPECT_ICON, &status);
|
||||||
|
ok(hr == REGDB_E_CLASSNOTREG, "got 0x%08x\n", hr);
|
||||||
|
ok(status == 0, "got 0x%08x\n", status);
|
||||||
|
|
||||||
|
status = -1;
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_StdFont, DVASPECT_ICON, &status);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(status == 0, "got 0x%08x\n", status);
|
||||||
|
|
||||||
|
if ((handle = activate_context(actctx_manifest, &cookie)))
|
||||||
|
{
|
||||||
|
status = 0;
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_Testclass, DVASPECT_ICON, &status);
|
||||||
|
todo_wine {
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(status == OLEMISC_RECOMPOSEONRESIZE, "got 0x%08x\n", status);
|
||||||
|
}
|
||||||
|
/* context data takes precedence over registration info */
|
||||||
|
status = 0;
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_StdFont, DVASPECT_ICON, &status);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
todo_wine
|
||||||
|
ok(status == OLEMISC_RECOMPOSEONRESIZE, "got 0x%08x\n", status);
|
||||||
|
|
||||||
|
/* there's no such attribute in context */
|
||||||
|
status = -1;
|
||||||
|
hr = OleRegGetMiscStatus(&CLSID_Testclass, DVASPECT_DOCPRINT, &status);
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
ok(status == 0, "got 0x%08x\n", status);
|
||||||
|
|
||||||
|
pDeactivateActCtx(0, cookie);
|
||||||
|
pReleaseActCtx(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void init_funcs(void)
|
||||||
|
{
|
||||||
|
HMODULE hOle32 = GetModuleHandleA("ole32");
|
||||||
|
HMODULE hAdvapi32 = GetModuleHandleA("advapi32");
|
||||||
|
HMODULE hkernel32 = GetModuleHandleA("kernel32");
|
||||||
|
|
||||||
pCoGetObjectContext = (void*)GetProcAddress(hOle32, "CoGetObjectContext");
|
pCoGetObjectContext = (void*)GetProcAddress(hOle32, "CoGetObjectContext");
|
||||||
pCoSwitchCallContext = (void*)GetProcAddress(hOle32, "CoSwitchCallContext");
|
pCoSwitchCallContext = (void*)GetProcAddress(hOle32, "CoSwitchCallContext");
|
||||||
pCoGetTreatAsClass = (void*)GetProcAddress(hOle32,"CoGetTreatAsClass");
|
pCoGetTreatAsClass = (void*)GetProcAddress(hOle32,"CoGetTreatAsClass");
|
||||||
pCoGetContextToken = (void*)GetProcAddress(hOle32, "CoGetContextToken");
|
pCoGetContextToken = (void*)GetProcAddress(hOle32, "CoGetContextToken");
|
||||||
pRegOverridePredefKey = (void*)GetProcAddress(hAdvapi32, "RegOverridePredefKey");
|
pRegOverridePredefKey = (void*)GetProcAddress(hAdvapi32, "RegOverridePredefKey");
|
||||||
if (!(pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx")))
|
pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
|
||||||
|
|
||||||
|
pActivateActCtx = (void*)GetProcAddress(hkernel32, "ActivateActCtx");
|
||||||
|
pCreateActCtxW = (void*)GetProcAddress(hkernel32, "CreateActCtxW");
|
||||||
|
pDeactivateActCtx = (void*)GetProcAddress(hkernel32, "DeactivateActCtx");
|
||||||
|
pReleaseActCtx = (void*)GetProcAddress(hkernel32, "ReleaseActCtx");
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(compobj)
|
||||||
|
{
|
||||||
|
init_funcs();
|
||||||
|
|
||||||
|
if (!pCoInitializeEx)
|
||||||
{
|
{
|
||||||
trace("You need DCOM95 installed to run this test\n");
|
trace("You need DCOM95 installed to run this test\n");
|
||||||
return;
|
return;
|
||||||
|
@ -1605,4 +1891,5 @@ START_TEST(compobj)
|
||||||
test_CoGetContextToken();
|
test_CoGetContextToken();
|
||||||
test_CoGetTreatAsClass();
|
test_CoGetTreatAsClass();
|
||||||
test_CoInitializeEx();
|
test_CoInitializeEx();
|
||||||
|
test_OleRegGetMiscStatus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,15 @@
|
||||||
expect_ ## func = called_ ## func = FALSE; \
|
expect_ ## func = called_ ## func = FALSE; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
#define CHECK_NOT_CALLED(func) \
|
||||||
|
do { \
|
||||||
|
ok(!called_ ## func, "unexpected " #func "\n"); \
|
||||||
|
expect_ ## func = called_ ## func = FALSE; \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
DEFINE_EXPECT(CF_QueryInterface_ClassFactory);
|
DEFINE_EXPECT(CF_QueryInterface_ClassFactory);
|
||||||
DEFINE_EXPECT(CF_CreateInstance);
|
DEFINE_EXPECT(CF_CreateInstance);
|
||||||
|
DEFINE_EXPECT(CF_QueryInterface_IMarshal);
|
||||||
|
|
||||||
static const char *debugstr_guid(REFIID riid)
|
static const char *debugstr_guid(REFIID riid)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +176,7 @@ static ULONG WINAPI test_class_Release(IUnknown *iface)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IUnknownVtbl test_class_vtbl = {
|
static const IUnknownVtbl test_class_vtbl = {
|
||||||
test_class_QueryInterface,
|
test_class_QueryInterface,
|
||||||
test_class_AddRef,
|
test_class_AddRef,
|
||||||
test_class_Release,
|
test_class_Release,
|
||||||
|
@ -183,6 +190,7 @@ static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID r
|
||||||
*ppv = iface;
|
*ppv = iface;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}else if(IsEqualGUID(riid, &IID_IMarshal)) {
|
}else if(IsEqualGUID(riid, &IID_IMarshal)) {
|
||||||
|
CHECK_EXPECT(CF_QueryInterface_IMarshal);
|
||||||
*ppv = NULL;
|
*ppv = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}else if(IsEqualGUID(riid, &IID_IClassFactory)) {
|
}else if(IsEqualGUID(riid, &IID_IClassFactory)) {
|
||||||
|
@ -228,7 +236,7 @@ static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
|
||||||
return E_NOTIMPL;
|
return E_NOTIMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IClassFactoryVtbl ClassFactoryVtbl = {
|
static const IClassFactoryVtbl ClassFactoryVtbl = {
|
||||||
ClassFactory_QueryInterface,
|
ClassFactory_QueryInterface,
|
||||||
ClassFactory_AddRef,
|
ClassFactory_AddRef,
|
||||||
ClassFactory_Release,
|
ClassFactory_Release,
|
||||||
|
@ -244,6 +252,8 @@ static void test_default_handler_run(void)
|
||||||
|
|
||||||
IUnknown *unk;
|
IUnknown *unk;
|
||||||
IRunnableObject *ro;
|
IRunnableObject *ro;
|
||||||
|
IOleObject *oleobj;
|
||||||
|
IPersistStorage *persist;
|
||||||
DWORD class_reg;
|
DWORD class_reg;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
|
|
||||||
|
@ -267,7 +277,9 @@ static void test_default_handler_run(void)
|
||||||
ok(hres == REGDB_E_CLASSNOTREG, "Run returned: %x, expected REGDB_E_CLASSNOTREG\n", hres);
|
ok(hres == REGDB_E_CLASSNOTREG, "Run returned: %x, expected REGDB_E_CLASSNOTREG\n", hres);
|
||||||
IRunnableObject_Release(ro);
|
IRunnableObject_Release(ro);
|
||||||
|
|
||||||
|
SET_EXPECT(CF_QueryInterface_IMarshal);
|
||||||
CoRevokeClassObject(class_reg);
|
CoRevokeClassObject(class_reg);
|
||||||
|
todo_wine CHECK_CALLED(CF_QueryInterface_IMarshal);
|
||||||
|
|
||||||
hres = CoRegisterClassObject(&test_server_clsid, (IUnknown*)&ClassFactory,
|
hres = CoRegisterClassObject(&test_server_clsid, (IUnknown*)&ClassFactory,
|
||||||
CLSCTX_LOCAL_SERVER, 0, &class_reg);
|
CLSCTX_LOCAL_SERVER, 0, &class_reg);
|
||||||
|
@ -276,6 +288,14 @@ static void test_default_handler_run(void)
|
||||||
hres = OleCreateDefaultHandler(&test_server_clsid, NULL, &IID_IUnknown, (void**)&unk);
|
hres = OleCreateDefaultHandler(&test_server_clsid, NULL, &IID_IUnknown, (void**)&unk);
|
||||||
ok(hres == S_OK, "OleCreateDefaultHandler failed: %x\n", hres);
|
ok(hres == S_OK, "OleCreateDefaultHandler failed: %x\n", hres);
|
||||||
|
|
||||||
|
hres = IUnknown_QueryInterface(unk, &IID_IOleObject, (void**)&oleobj);
|
||||||
|
ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %x\n", hres);
|
||||||
|
|
||||||
|
hres = IOleObject_QueryInterface(oleobj, &IID_IPersistStorage, (void**)&persist);
|
||||||
|
ok(hres == S_OK, "QueryInterface(IID_IPersistStorage) failed: %x\n", hres);
|
||||||
|
IPersistStorage_Release(persist);
|
||||||
|
IOleObject_Release(oleobj);
|
||||||
|
|
||||||
hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&ro);
|
hres = IUnknown_QueryInterface(unk, &IID_IRunnableObject, (void**)&ro);
|
||||||
ok(hres == S_OK, "QueryInterface(IRunnableObject) failed: %x\n", hres);
|
ok(hres == S_OK, "QueryInterface(IRunnableObject) failed: %x\n", hres);
|
||||||
IUnknown_Release(unk);
|
IUnknown_Release(unk);
|
||||||
|
@ -283,12 +303,26 @@ static void test_default_handler_run(void)
|
||||||
SET_EXPECT(CF_QueryInterface_ClassFactory);
|
SET_EXPECT(CF_QueryInterface_ClassFactory);
|
||||||
SET_EXPECT(CF_CreateInstance);
|
SET_EXPECT(CF_CreateInstance);
|
||||||
hres = IRunnableObject_Run(ro, NULL);
|
hres = IRunnableObject_Run(ro, NULL);
|
||||||
todo_wine ok(hres == S_OK, "Run failed: %x\n", hres);
|
todo_wine
|
||||||
|
ok(hres == S_OK, "Run failed: %x\n", hres);
|
||||||
CHECK_CALLED(CF_QueryInterface_ClassFactory);
|
CHECK_CALLED(CF_QueryInterface_ClassFactory);
|
||||||
CHECK_CALLED(CF_CreateInstance);
|
CHECK_CALLED(CF_CreateInstance);
|
||||||
IRunnableObject_Release(ro);
|
IRunnableObject_Release(ro);
|
||||||
|
|
||||||
|
SET_EXPECT(CF_QueryInterface_ClassFactory);
|
||||||
|
SET_EXPECT(CF_CreateInstance);
|
||||||
|
hres = CoCreateInstance(&test_server_clsid, NULL, CLSCTX_LOCAL_SERVER,
|
||||||
|
&IID_IOleObject, (void**)&oleobj);
|
||||||
|
todo_wine
|
||||||
|
ok(hres == REGDB_E_CLASSNOTREG, "expected REGDB_E_CLASSNOTREG, got %x\n", hres);
|
||||||
|
todo_wine
|
||||||
|
CHECK_NOT_CALLED(CF_QueryInterface_ClassFactory);
|
||||||
|
todo_wine
|
||||||
|
CHECK_NOT_CALLED(CF_CreateInstance);
|
||||||
|
|
||||||
|
SET_EXPECT(CF_QueryInterface_IMarshal);
|
||||||
CoRevokeClassObject(class_reg);
|
CoRevokeClassObject(class_reg);
|
||||||
|
todo_wine CHECK_CALLED(CF_QueryInterface_IMarshal);
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(defaulthandler)
|
START_TEST(defaulthandler)
|
||||||
|
|
|
@ -47,6 +47,7 @@ DEFINE_GUID(CLSID_ManualResetEvent, 0x0000032c,0x0000,0x0000,0xc0,0x00,0x0
|
||||||
|
|
||||||
/* functions that are not present on all versions of Windows */
|
/* functions that are not present on all versions of Windows */
|
||||||
static HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
|
static HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
|
||||||
|
static HRESULT (WINAPI *pDllGetClassObject)(REFCLSID,REFIID,LPVOID);
|
||||||
|
|
||||||
/* helper macros to make tests a bit leaner */
|
/* helper macros to make tests a bit leaner */
|
||||||
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
|
#define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
|
||||||
|
@ -2811,13 +2812,33 @@ static void test_globalinterfacetable(void)
|
||||||
struct git_params params;
|
struct git_params params;
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
IUnknown *object;
|
IUnknown *object;
|
||||||
|
IClassFactory *cf;
|
||||||
|
ULONG ref;
|
||||||
|
|
||||||
trace("test_globalinterfacetable\n");
|
trace("test_globalinterfacetable\n");
|
||||||
cLocks = 0;
|
cLocks = 0;
|
||||||
|
|
||||||
|
hr = pDllGetClassObject(&CLSID_StdGlobalInterfaceTable, &IID_IClassFactory, (void**)&cf);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = IClassFactory_QueryInterface(cf, &IID_IGlobalInterfaceTable, (void**)&object);
|
||||||
|
ok(hr == E_NOINTERFACE, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
IClassFactory_Release(cf);
|
||||||
|
|
||||||
hr = CoCreateInstance(&CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, &IID_IGlobalInterfaceTable, (void **)&git);
|
hr = CoCreateInstance(&CLSID_StdGlobalInterfaceTable, NULL, CLSCTX_INPROC_SERVER, &IID_IGlobalInterfaceTable, (void **)&git);
|
||||||
ok_ole_success(hr, CoCreateInstance);
|
ok_ole_success(hr, CoCreateInstance);
|
||||||
|
|
||||||
|
ref = IGlobalInterfaceTable_AddRef(git);
|
||||||
|
ok(ref == 1, "ref=%d\n", ref);
|
||||||
|
ref = IGlobalInterfaceTable_AddRef(git);
|
||||||
|
ok(ref == 1, "ref=%d\n", ref);
|
||||||
|
|
||||||
|
ref = IGlobalInterfaceTable_Release(git);
|
||||||
|
ok(ref == 1, "ref=%d\n", ref);
|
||||||
|
ref = IGlobalInterfaceTable_Release(git);
|
||||||
|
ok(ref == 1, "ref=%d\n", ref);
|
||||||
|
|
||||||
hr = IGlobalInterfaceTable_RegisterInterfaceInGlobal(git, (IUnknown *)&Test_ClassFactory, &IID_IClassFactory, &cookie);
|
hr = IGlobalInterfaceTable_RegisterInterfaceInGlobal(git, (IUnknown *)&Test_ClassFactory, &IID_IClassFactory, &cookie);
|
||||||
ok_ole_success(hr, IGlobalInterfaceTable_RegisterInterfaceInGlobal);
|
ok_ole_success(hr, IGlobalInterfaceTable_RegisterInterfaceInGlobal);
|
||||||
|
|
||||||
|
@ -3156,6 +3177,7 @@ START_TEST(marshal)
|
||||||
}
|
}
|
||||||
|
|
||||||
pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
|
pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx");
|
||||||
|
pDllGetClassObject = (void*)GetProcAddress(hOle32, "DllGetClassObject");
|
||||||
|
|
||||||
argc = winetest_get_mainargs( &argv );
|
argc = winetest_get_mainargs( &argv );
|
||||||
if (argc > 2 && (!strcmp(argv[2], "-Embedding")))
|
if (argc > 2 && (!strcmp(argv[2], "-Embedding")))
|
||||||
|
|
|
@ -103,6 +103,55 @@ static SIZE_T round_global_size(SIZE_T size)
|
||||||
return ((size + global_size_alignment - 1) & ~(global_size_alignment - 1));
|
return ((size + global_size_alignment - 1) & ~(global_size_alignment - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD external_connections;
|
||||||
|
|
||||||
|
static HRESULT WINAPI ExternalConnection_QueryInterface(IExternalConnection *iface, REFIID riid, void **ppv)
|
||||||
|
{
|
||||||
|
ok(0, "unxpected call\n");
|
||||||
|
*ppv = NULL;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI ExternalConnection_AddRef(IExternalConnection *iface)
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI ExternalConnection_Release(IExternalConnection *iface)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI ExternalConnection_AddConnection(IExternalConnection *iface, DWORD extconn, DWORD reserved)
|
||||||
|
{
|
||||||
|
trace("add connection\n");
|
||||||
|
|
||||||
|
ok(extconn == EXTCONN_STRONG, "extconn = %d\n", extconn);
|
||||||
|
ok(!reserved, "reserved = %x\n", reserved);
|
||||||
|
return ++external_connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD WINAPI ExternalConnection_ReleaseConnection(IExternalConnection *iface, DWORD extconn,
|
||||||
|
DWORD reserved, BOOL fLastReleaseCloses)
|
||||||
|
{
|
||||||
|
trace("release connection\n");
|
||||||
|
|
||||||
|
ok(extconn == EXTCONN_STRONG, "extconn = %d\n", extconn);
|
||||||
|
ok(!reserved, "reserved = %x\n", reserved);
|
||||||
|
|
||||||
|
return --external_connections;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const IExternalConnectionVtbl ExternalConnectionVtbl = {
|
||||||
|
ExternalConnection_QueryInterface,
|
||||||
|
ExternalConnection_AddRef,
|
||||||
|
ExternalConnection_Release,
|
||||||
|
ExternalConnection_AddConnection,
|
||||||
|
ExternalConnection_ReleaseConnection
|
||||||
|
};
|
||||||
|
|
||||||
|
static IExternalConnection ExternalConnection = { &ExternalConnectionVtbl };
|
||||||
|
|
||||||
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||||
LPCLASSFACTORY iface,
|
LPCLASSFACTORY iface,
|
||||||
REFIID riid,
|
REFIID riid,
|
||||||
|
@ -118,6 +167,11 @@ static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(IsEqualGUID(riid, &IID_IExternalConnection)) {
|
||||||
|
*ppvObj = &ExternalConnection;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
*ppvObj = NULL;
|
*ppvObj = NULL;
|
||||||
return E_NOINTERFACE;
|
return E_NOINTERFACE;
|
||||||
}
|
}
|
||||||
|
@ -594,11 +648,13 @@ static void test_ROT(void)
|
||||||
ok_ole_success(hr, GetRunningObjectTable);
|
ok_ole_success(hr, GetRunningObjectTable);
|
||||||
|
|
||||||
expected_method_list = methods_register_no_ROTData;
|
expected_method_list = methods_register_no_ROTData;
|
||||||
|
external_connections = 0;
|
||||||
/* try with our own moniker that doesn't support IROTData */
|
/* try with our own moniker that doesn't support IROTData */
|
||||||
hr = IRunningObjectTable_Register(pROT, ROTFLAGS_REGISTRATIONKEEPSALIVE,
|
hr = IRunningObjectTable_Register(pROT, ROTFLAGS_REGISTRATIONKEEPSALIVE,
|
||||||
(IUnknown*)&Test_ClassFactory, &MonikerNoROTData, &dwCookie);
|
(IUnknown*)&Test_ClassFactory, &MonikerNoROTData, &dwCookie);
|
||||||
ok_ole_success(hr, IRunningObjectTable_Register);
|
ok_ole_success(hr, IRunningObjectTable_Register);
|
||||||
ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list);
|
ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list);
|
||||||
|
ok(external_connections == 1, "external_connections = %d\n", external_connections);
|
||||||
|
|
||||||
ok_more_than_one_lock();
|
ok_more_than_one_lock();
|
||||||
|
|
||||||
|
@ -609,6 +665,7 @@ static void test_ROT(void)
|
||||||
|
|
||||||
hr = IRunningObjectTable_Revoke(pROT, dwCookie);
|
hr = IRunningObjectTable_Revoke(pROT, dwCookie);
|
||||||
ok_ole_success(hr, IRunningObjectTable_Revoke);
|
ok_ole_success(hr, IRunningObjectTable_Revoke);
|
||||||
|
ok(external_connections == 0, "external_connections = %d\n", external_connections);
|
||||||
|
|
||||||
ok_no_locks();
|
ok_no_locks();
|
||||||
|
|
||||||
|
@ -635,9 +692,11 @@ static void test_ROT(void)
|
||||||
ok_ole_success(hr, CreateClassMoniker);
|
ok_ole_success(hr, CreateClassMoniker);
|
||||||
|
|
||||||
/* test flags: 0 */
|
/* test flags: 0 */
|
||||||
|
external_connections = 0;
|
||||||
hr = IRunningObjectTable_Register(pROT, 0, (IUnknown*)&Test_ClassFactory,
|
hr = IRunningObjectTable_Register(pROT, 0, (IUnknown*)&Test_ClassFactory,
|
||||||
pMoniker, &dwCookie);
|
pMoniker, &dwCookie);
|
||||||
ok_ole_success(hr, IRunningObjectTable_Register);
|
ok_ole_success(hr, IRunningObjectTable_Register);
|
||||||
|
ok(external_connections == 0, "external_connections = %d\n", external_connections);
|
||||||
|
|
||||||
ok_more_than_one_lock();
|
ok_more_than_one_lock();
|
||||||
|
|
||||||
|
|
571
rostests/winetests/ole32/ole_server.c
Normal file
571
rostests/winetests/ole32/ole_server.c
Normal file
|
@ -0,0 +1,571 @@
|
||||||
|
/*
|
||||||
|
* OLE client/server test suite
|
||||||
|
*
|
||||||
|
* Copyright 2013 Dmitry Timoshkov
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
#define CONST_VTABLE
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <exdisp.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "wine/test.h"
|
||||||
|
|
||||||
|
#include <initguid.h>
|
||||||
|
DEFINE_GUID(CLSID_WineTestObject, 0xdeadbeef,0xdead,0xbeef,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef);
|
||||||
|
#ifndef CLSID_IdentityUnmarshal
|
||||||
|
DEFINE_GUID(CLSID_IdentityUnmarshal,0x0000001b,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46);
|
||||||
|
#endif
|
||||||
|
DEFINE_GUID(CLSID_UnknownUnmarshal,0x4c1e39e1,0xe3e3,0x4296,0xaa,0x86,0xec,0x93,0x8d,0x89,0x6e,0x92);
|
||||||
|
|
||||||
|
struct winetest_info
|
||||||
|
{
|
||||||
|
LONG child_failures;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const GUID *guid;
|
||||||
|
const char *name;
|
||||||
|
} guid_name[] =
|
||||||
|
{
|
||||||
|
#define GUID_NAME(guid) \
|
||||||
|
{ &IID_##guid, #guid }
|
||||||
|
GUID_NAME(IUnknown),
|
||||||
|
GUID_NAME(IClassFactory),
|
||||||
|
GUID_NAME(IOleObject),
|
||||||
|
GUID_NAME(IMarshal),
|
||||||
|
GUID_NAME(IStdMarshalInfo),
|
||||||
|
GUID_NAME(IExternalConnection),
|
||||||
|
GUID_NAME(IRunnableObject),
|
||||||
|
GUID_NAME(ICallFactory),
|
||||||
|
{ &CLSID_IdentityUnmarshal, "CLSID_IdentityUnmarshal" },
|
||||||
|
{ &CLSID_UnknownUnmarshal, "CLSID_UnknownUnmarshal" },
|
||||||
|
#undef GUID_NAME
|
||||||
|
};
|
||||||
|
|
||||||
|
static LONG obj_ref, class_ref, server_locks;
|
||||||
|
|
||||||
|
static const char *debugstr_guid(const GUID *guid)
|
||||||
|
{
|
||||||
|
static char buf[50];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!guid) return "(null)";
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(guid_name)/sizeof(guid_name[0]); i++)
|
||||||
|
{
|
||||||
|
if (IsEqualIID(guid, guid_name[i].guid))
|
||||||
|
return guid_name[i].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
||||||
|
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
|
||||||
|
guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
|
||||||
|
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************* OLE server *******************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
IUnknown IUnknown_iface;
|
||||||
|
LONG ref;
|
||||||
|
} UnknownImpl;
|
||||||
|
|
||||||
|
static inline UnknownImpl *impl_from_IUnknown(IUnknown *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, UnknownImpl, IUnknown_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI UnknownImpl_QueryInterface(IUnknown *iface,
|
||||||
|
REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
UnknownImpl *This = impl_from_IUnknown(iface);
|
||||||
|
|
||||||
|
trace("server: unknown_QueryInterface: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
|
||||||
|
|
||||||
|
if (!ppv) return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (IsEqualIID(&IID_IUnknown, iid))
|
||||||
|
{
|
||||||
|
*ppv = &This->IUnknown_iface;
|
||||||
|
IUnknown_AddRef(&This->IUnknown_iface);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppv = NULL;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI UnknownImpl_AddRef(IUnknown *iface)
|
||||||
|
{
|
||||||
|
UnknownImpl *This = impl_from_IUnknown(iface);
|
||||||
|
ULONG ref = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
|
InterlockedIncrement(&obj_ref);
|
||||||
|
|
||||||
|
trace("server: unknown_AddRef: %p, ref %u\n", iface, ref);
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI UnknownImpl_Release(IUnknown *iface)
|
||||||
|
{
|
||||||
|
UnknownImpl *This = impl_from_IUnknown(iface);
|
||||||
|
ULONG ref = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
|
InterlockedDecrement(&obj_ref);
|
||||||
|
|
||||||
|
trace("server: unknown_Release: %p, ref %u\n", iface, ref);
|
||||||
|
if (ref == 0) HeapFree(GetProcessHeap(), 0, This);
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const IUnknownVtbl UnknownImpl_Vtbl =
|
||||||
|
{
|
||||||
|
UnknownImpl_QueryInterface,
|
||||||
|
UnknownImpl_AddRef,
|
||||||
|
UnknownImpl_Release,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
IClassFactory IClassFactory_iface;
|
||||||
|
LONG ref;
|
||||||
|
} ClassFactoryImpl;
|
||||||
|
|
||||||
|
static inline ClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
||||||
|
{
|
||||||
|
return CONTAINING_RECORD(iface, ClassFactoryImpl, IClassFactory_iface);
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI ClassFactoryImpl_QueryInterface(IClassFactory *iface,
|
||||||
|
REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
ClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
||||||
|
|
||||||
|
trace("server: factory_QueryInterface: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
|
||||||
|
|
||||||
|
if (!ppv) return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (IsEqualIID(&IID_IUnknown, iid) ||
|
||||||
|
IsEqualIID(&IID_IClassFactory, iid))
|
||||||
|
{
|
||||||
|
IClassFactory_AddRef(&This->IClassFactory_iface);
|
||||||
|
*ppv = &This->IClassFactory_iface;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppv = NULL;
|
||||||
|
return E_NOINTERFACE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI ClassFactoryImpl_AddRef(IClassFactory *iface)
|
||||||
|
{
|
||||||
|
ClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
||||||
|
ULONG ref = InterlockedIncrement(&This->ref);
|
||||||
|
|
||||||
|
InterlockedIncrement(&class_ref);
|
||||||
|
|
||||||
|
trace("server: factory_AddRef: %p, ref %u\n", iface, ref);
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ULONG WINAPI ClassFactoryImpl_Release(IClassFactory *iface)
|
||||||
|
{
|
||||||
|
ClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
||||||
|
ULONG ref = InterlockedDecrement(&This->ref);
|
||||||
|
|
||||||
|
InterlockedDecrement(&class_ref);
|
||||||
|
|
||||||
|
trace("server: factory_Release: %p, ref %u\n", iface, ref);
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI ClassFactoryImpl_CreateInstance(IClassFactory *iface,
|
||||||
|
IUnknown *punkouter, REFIID iid, void **ppv)
|
||||||
|
{
|
||||||
|
UnknownImpl *unknown;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
trace("server: factory_CreateInstance: %p,%s,%p\n", iface, debugstr_guid(iid), ppv);
|
||||||
|
|
||||||
|
if (punkouter) return CLASS_E_NOAGGREGATION;
|
||||||
|
|
||||||
|
unknown = HeapAlloc(GetProcessHeap(), 0, sizeof(*unknown));
|
||||||
|
if (!unknown) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
|
unknown->IUnknown_iface.lpVtbl = &UnknownImpl_Vtbl;
|
||||||
|
unknown->ref = 0;
|
||||||
|
IUnknown_AddRef(&unknown->IUnknown_iface);
|
||||||
|
|
||||||
|
hr = IUnknown_QueryInterface(&unknown->IUnknown_iface, iid, ppv);
|
||||||
|
IUnknown_Release(&unknown->IUnknown_iface);
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT WINAPI ClassFactoryImpl_LockServer(IClassFactory *iface, BOOL lock)
|
||||||
|
{
|
||||||
|
ULONG ref = lock ? InterlockedIncrement(&server_locks) : InterlockedDecrement(&server_locks);
|
||||||
|
|
||||||
|
trace("server: factory_LockServer: %p,%d, ref %u\n", iface, lock, ref);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const IClassFactoryVtbl ClassFactoryImpl_Vtbl =
|
||||||
|
{
|
||||||
|
ClassFactoryImpl_QueryInterface,
|
||||||
|
ClassFactoryImpl_AddRef,
|
||||||
|
ClassFactoryImpl_Release,
|
||||||
|
ClassFactoryImpl_CreateInstance,
|
||||||
|
ClassFactoryImpl_LockServer
|
||||||
|
};
|
||||||
|
|
||||||
|
static ClassFactoryImpl factory = { { &ClassFactoryImpl_Vtbl }, 0 };
|
||||||
|
|
||||||
|
static void ole_server(void)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
DWORD key;
|
||||||
|
|
||||||
|
trace("server: starting %u\n", GetCurrentProcessId());
|
||||||
|
|
||||||
|
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
trace("server: registering class object\n");
|
||||||
|
hr = CoRegisterClassObject(&CLSID_WineTestObject, (IUnknown *)&factory,
|
||||||
|
CLSCTX_SERVER, REGCLS_MULTIPLEUSE, &key);
|
||||||
|
if (hr == S_OK)
|
||||||
|
{
|
||||||
|
HANDLE done_event, init_done_event;
|
||||||
|
|
||||||
|
done_event = OpenEvent(SYNCHRONIZE, FALSE, "ole_server_done_event");
|
||||||
|
ok(done_event != 0, "server: OpenEvent error %d\n", GetLastError());
|
||||||
|
init_done_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, "ole_server_init_done_event");
|
||||||
|
ok(init_done_event != 0, "server: OpenEvent error %d\n", GetLastError());
|
||||||
|
|
||||||
|
SetEvent(init_done_event);
|
||||||
|
|
||||||
|
trace("server: waiting for requests\n");
|
||||||
|
WaitForSingleObject(done_event, INFINITE);
|
||||||
|
|
||||||
|
/* 1 remainining class ref is supposed to be cleared by CoRevokeClassObject */
|
||||||
|
ok(class_ref == 1, "expected 1 class refs, got %d\n", class_ref);
|
||||||
|
ok(!obj_ref, "expected 0 object refs, got %d\n", obj_ref);
|
||||||
|
ok(!server_locks, "expected 0 server locks, got %d\n", server_locks);
|
||||||
|
|
||||||
|
CloseHandle(done_event);
|
||||||
|
CloseHandle(init_done_event);
|
||||||
|
if (0)
|
||||||
|
{
|
||||||
|
/* calling CoRevokeClassObject terminates process under Win7 */
|
||||||
|
trace("call CoRevokeClassObject\n");
|
||||||
|
CoRevokeClassObject(key);
|
||||||
|
trace("ret CoRevokeClassObject\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trace("server: call CoUninitialize\n");
|
||||||
|
CoUninitialize();
|
||||||
|
trace("server: ret CoUninitialize\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("server: exiting %u\n", GetCurrentProcessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************* OLE client *******************************/
|
||||||
|
static BOOL register_server(const char *server, BOOL inproc_handler)
|
||||||
|
{
|
||||||
|
static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
|
||||||
|
DWORD ret;
|
||||||
|
HKEY root;
|
||||||
|
WCHAR buf[39 + 6];
|
||||||
|
char server_path[MAX_PATH];
|
||||||
|
|
||||||
|
lstrcpy(server_path, server);
|
||||||
|
lstrcat(server_path, " ole_server");
|
||||||
|
|
||||||
|
lstrcpyW(buf, clsidW);
|
||||||
|
StringFromGUID2(&CLSID_WineTestObject, buf + 6, 39);
|
||||||
|
|
||||||
|
ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, buf, 0, NULL, 0,
|
||||||
|
KEY_READ | KEY_WRITE | KEY_CREATE_SUB_KEY, NULL, &root, NULL);
|
||||||
|
if (ret == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
ret = RegSetValue(root, "LocalServer32", REG_SZ, server_path, strlen(server_path));
|
||||||
|
ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
|
||||||
|
|
||||||
|
if (inproc_handler)
|
||||||
|
{
|
||||||
|
ret = RegSetValue(root, "InprocHandler32", REG_SZ, "ole32.dll", 9);
|
||||||
|
ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret == ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unregister_server(void)
|
||||||
|
{
|
||||||
|
static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
|
||||||
|
DWORD ret;
|
||||||
|
HKEY root;
|
||||||
|
WCHAR buf[39 + 6];
|
||||||
|
|
||||||
|
lstrcpyW(buf, clsidW);
|
||||||
|
StringFromGUID2(&CLSID_WineTestObject, buf + 6, 39);
|
||||||
|
|
||||||
|
ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, buf, 0, NULL, 0,
|
||||||
|
DELETE, NULL, &root, NULL);
|
||||||
|
if (ret == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
ret = RegDeleteKey(root, "InprocHandler32");
|
||||||
|
ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
|
||||||
|
ret = RegDeleteKey(root, "LocalServer32");
|
||||||
|
ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
|
||||||
|
ret = RegDeleteKey(root, "");
|
||||||
|
ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
|
||||||
|
RegCloseKey(root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static HANDLE start_server(const char *argv0)
|
||||||
|
{
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
STARTUPINFO si;
|
||||||
|
SECURITY_ATTRIBUTES sa;
|
||||||
|
char cmdline[MAX_PATH * 2];
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
memset(&si, 0, sizeof(si));
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
si.dwFlags = STARTF_USESTDHANDLES;
|
||||||
|
si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
si.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
si.hStdError = si.hStdOutput;
|
||||||
|
|
||||||
|
sa.nLength = sizeof(sa);
|
||||||
|
sa.lpSecurityDescriptor = NULL;
|
||||||
|
sa.bInheritHandle = TRUE;
|
||||||
|
|
||||||
|
sprintf(cmdline, "\"%s\" ole_server -server", argv0);
|
||||||
|
ret = CreateProcess(argv0, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi);
|
||||||
|
ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError());
|
||||||
|
if (!ret) return 0;
|
||||||
|
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
return pi.hProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(ole_server)
|
||||||
|
{
|
||||||
|
CLSID clsid = CLSID_WineTestObject;
|
||||||
|
HRESULT hr;
|
||||||
|
IClassFactory *factory;
|
||||||
|
IUnknown *unknown;
|
||||||
|
IOleObject *oleobj;
|
||||||
|
IRunnableObject *runobj;
|
||||||
|
DWORD ret;
|
||||||
|
HANDLE mapping, done_event, init_done_event, process;
|
||||||
|
struct winetest_info *info;
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
|
||||||
|
mapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, "winetest_ole_server");
|
||||||
|
ok(mapping != 0, "CreateFileMapping failed\n");
|
||||||
|
info = MapViewOfFile(mapping, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 4096);
|
||||||
|
|
||||||
|
argc = winetest_get_mainargs(&argv);
|
||||||
|
|
||||||
|
done_event = CreateEvent(NULL, TRUE, FALSE, "ole_server_done_event");
|
||||||
|
ok(done_event != 0, "CreateEvent error %d\n", GetLastError());
|
||||||
|
init_done_event = CreateEvent(NULL, TRUE, FALSE, "ole_server_init_done_event");
|
||||||
|
ok(init_done_event != 0, "CreateEvent error %d\n", GetLastError());
|
||||||
|
|
||||||
|
if (argc > 2)
|
||||||
|
{
|
||||||
|
if (!lstrcmpi(argv[2], "-Embedding"))
|
||||||
|
{
|
||||||
|
trace("server: Refusing to be run by ole32\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!lstrcmpi(argv[2], "-server"))
|
||||||
|
{
|
||||||
|
info->child_failures = 0;
|
||||||
|
ole_server();
|
||||||
|
info->child_failures = winetest_get_failures();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("server: Unknown parameter: %s\n", argv[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!register_server(argv[0], FALSE))
|
||||||
|
{
|
||||||
|
win_skip("not enough permissions to create a server CLSID key\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(process = start_server(argv[0])))
|
||||||
|
{
|
||||||
|
unregister_server();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
WaitForSingleObject(init_done_event, 5000);
|
||||||
|
|
||||||
|
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
|
ok(hr == S_OK, "OleInitialize error %#x\n", hr);
|
||||||
|
|
||||||
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
|
||||||
|
ok(hr == REGDB_E_CLASSNOTREG, "expected REGDB_E_CLASSNOTREG, got %#x\n", hr);
|
||||||
|
|
||||||
|
if (!register_server(argv[0], TRUE))
|
||||||
|
{
|
||||||
|
win_skip("not enough permissions to create a server CLSID key\n");
|
||||||
|
unregister_server();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("call CoCreateInstance(&IID_NULL)\n");
|
||||||
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_NULL, (void **)&unknown);
|
||||||
|
trace("ret CoCreateInstance(&IID_NULL)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
/* in-process handler supports IID_IUnknown starting from Vista */
|
||||||
|
trace("call CoCreateInstance(&IID_IUnknown)\n");
|
||||||
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
|
||||||
|
trace("ret CoCreateInstance(&IID_IUnknown)\n");
|
||||||
|
ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /* XP,win2000 and earlier */, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
|
||||||
|
if (hr != S_OK)
|
||||||
|
{
|
||||||
|
win_skip("In-process handler doesn't support IID_IUnknown on this platform\n");
|
||||||
|
goto test_local_server;
|
||||||
|
}
|
||||||
|
|
||||||
|
trace("call CoCreateInstance(&IID_IOleObject)\n");
|
||||||
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IOleObject, (void **)&oleobj);
|
||||||
|
trace("ret CoCreateInstance(&IID_IOleObject)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
|
||||||
|
hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
|
||||||
|
trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
|
||||||
|
ok(hr == S_OK, "QueryInterface(&IID_IRunnableObject) error %#x\n", hr);
|
||||||
|
|
||||||
|
ret = IRunnableObject_IsRunning(runobj);
|
||||||
|
ok(!ret, "expected 0, got %d\n", ret);
|
||||||
|
|
||||||
|
trace("call OleRun\n");
|
||||||
|
hr = OleRun(unknown);
|
||||||
|
trace("ret OleRun\n");
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "OleRun error %#x\n", hr);
|
||||||
|
|
||||||
|
ret = IRunnableObject_IsRunning(runobj);
|
||||||
|
todo_wine
|
||||||
|
ok(ret == 1, "expected 1, got %d\n", ret);
|
||||||
|
|
||||||
|
trace("call IRunnableObject_Release\n");
|
||||||
|
ret = IRunnableObject_Release(runobj);
|
||||||
|
trace("ret IRunnableObject_Release\n");
|
||||||
|
ok(ret == 1, "expected ref 1, got %u\n", ret);
|
||||||
|
|
||||||
|
trace("call IUnknown_QueryInterface(&IID_IOleObject)\n");
|
||||||
|
hr = IUnknown_QueryInterface(unknown, &IID_IOleObject, (void **)&oleobj);
|
||||||
|
trace("ret IUnknown_QueryInterface(&IID_IOleObject)\n");
|
||||||
|
ok(hr == S_OK, "QueryInterface(&IID_IOleObject) error %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IOleObject_Release\n");
|
||||||
|
ret = IOleObject_Release(oleobj);
|
||||||
|
trace("ret IOleObject_Release\n");
|
||||||
|
ok(ret == 1, "expected ref 1, got %u\n", ret);
|
||||||
|
|
||||||
|
trace("call IUnknown_Release\n");
|
||||||
|
ret = IUnknown_Release(unknown);
|
||||||
|
trace("ret IUnknown_Release\n");
|
||||||
|
ok(!ret, "expected ref 0, got %u\n", ret);
|
||||||
|
|
||||||
|
test_local_server:
|
||||||
|
/* local server supports IID_IUnknown */
|
||||||
|
trace("call CoCreateInstance(&IID_IUnknown)\n");
|
||||||
|
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IUnknown, (void **)&unknown);
|
||||||
|
trace("ret CoCreateInstance(&IID_IUnknown)\n");
|
||||||
|
ok(hr == S_OK, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
|
||||||
|
hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
|
||||||
|
trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call OleRun\n");
|
||||||
|
hr = OleRun(unknown);
|
||||||
|
trace("ret OleRun\n");
|
||||||
|
ok(hr == S_OK, "OleRun error %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IUnknown_QueryInterface(&IID_IOleObject)\n");
|
||||||
|
hr = IUnknown_QueryInterface(unknown, &IID_IOleObject, (void **)&oleobj);
|
||||||
|
trace("ret IUnknown_QueryInterface(&IID_IOleObject)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IUnknown_Release\n");
|
||||||
|
ret = IUnknown_Release(unknown);
|
||||||
|
trace("ret IUnknown_Release\n");
|
||||||
|
ok(!ret, "expected ref 0, got %u\n", ret);
|
||||||
|
|
||||||
|
trace("call CoGetClassObject(&IID_IClassFactory)\n");
|
||||||
|
hr = CoGetClassObject(&clsid, CLSCTX_LOCAL_SERVER, NULL, &IID_IClassFactory, (void **)&factory);
|
||||||
|
trace("ret CoGetClassObject(&IID_IClassFactory)\n");
|
||||||
|
ok(hr == S_OK, "CoGetClassObject error %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IClassFactory_CreateInstance(&IID_NULL)\n");
|
||||||
|
hr = IClassFactory_CreateInstance(factory, NULL, &IID_NULL, (void **)&oleobj);
|
||||||
|
trace("ret IClassFactory_CreateInstance(&IID_NULL)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IClassFactory_CreateInstance(&IID_IOleObject)\n");
|
||||||
|
hr = IClassFactory_CreateInstance(factory, NULL, &IID_IOleObject, (void **)&oleobj);
|
||||||
|
trace("ret IClassFactory_CreateInstance(&IID_IOleObject)\n");
|
||||||
|
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
|
||||||
|
|
||||||
|
trace("call IClassFactory_Release\n");
|
||||||
|
ret = IClassFactory_Release(factory);
|
||||||
|
trace("ret IClassFactory_Release\n");
|
||||||
|
ok(!ret, "expected ref 0, got %u\n", ret);
|
||||||
|
|
||||||
|
trace("signalling termination\n");
|
||||||
|
SetEvent(done_event);
|
||||||
|
ret = WaitForSingleObject(process, 10000);
|
||||||
|
ok(ret == WAIT_OBJECT_0, "server failed to terminate\n");
|
||||||
|
|
||||||
|
OleUninitialize();
|
||||||
|
|
||||||
|
unregister_server();
|
||||||
|
|
||||||
|
if (info->child_failures)
|
||||||
|
{
|
||||||
|
trace("%d failures in child process\n", info->child_failures);
|
||||||
|
winetest_add_failures(info->child_failures);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1812,32 +1812,36 @@ static const struct access_res create_close[16] =
|
||||||
{ TRUE, ERROR_SUCCESS }
|
{ TRUE, ERROR_SUCCESS }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const DWORD access_modes[4] = {
|
||||||
|
0,
|
||||||
|
GENERIC_READ,
|
||||||
|
GENERIC_WRITE,
|
||||||
|
GENERIC_READ | GENERIC_WRITE
|
||||||
|
};
|
||||||
|
|
||||||
|
static const DWORD share_modes[4] = {
|
||||||
|
0,
|
||||||
|
FILE_SHARE_READ,
|
||||||
|
FILE_SHARE_WRITE,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE
|
||||||
|
};
|
||||||
|
|
||||||
static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
|
static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
|
||||||
{
|
{
|
||||||
DWORD access = 0, share = 0;
|
|
||||||
DWORD lasterr;
|
|
||||||
HANDLE hfile;
|
|
||||||
int i, j, idx = 0;
|
int i, j, idx = 0;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < sizeof(access_modes)/sizeof(access_modes[0]); i++)
|
||||||
{
|
{
|
||||||
if (i == 0) access = 0;
|
for (j = 0; j < sizeof(share_modes)/sizeof(share_modes[0]); j++)
|
||||||
if (i == 1) access = GENERIC_READ;
|
|
||||||
if (i == 2) access = GENERIC_WRITE;
|
|
||||||
if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
|
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
|
||||||
{
|
{
|
||||||
|
DWORD lasterr;
|
||||||
|
HANDLE hfile;
|
||||||
|
|
||||||
if (ares[idx].ignore)
|
if (ares[idx].ignore)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (j == 0) share = 0;
|
|
||||||
if (j == 1) share = FILE_SHARE_READ;
|
|
||||||
if (j == 2) share = FILE_SHARE_WRITE;
|
|
||||||
if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
|
hfile = CreateFileA(file, access_modes[i], share_modes[j], NULL, OPEN_EXISTING,
|
||||||
FILE_ATTRIBUTE_NORMAL, 0);
|
FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
lasterr = GetLastError();
|
lasterr = GetLastError();
|
||||||
|
|
||||||
|
@ -1861,105 +1865,117 @@ static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD
|
||||||
|
|
||||||
static void test_access(void)
|
static void test_access(void)
|
||||||
{
|
{
|
||||||
|
static const WCHAR fileW[] = {'w','i','n','e','t','e','s','t',0};
|
||||||
|
static const char fileA[] = "winetest";
|
||||||
IStorage *stg;
|
IStorage *stg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
static const WCHAR fileW[] = {'w','i','n','e','t','e','s','t',0};
|
|
||||||
|
|
||||||
/* STGM_TRANSACTED */
|
/* STGM_TRANSACTED */
|
||||||
|
|
||||||
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
||||||
STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, 0, &stg);
|
STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, 0, &stg);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create);
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create_commit);
|
test_file_access(fileA, create_commit);
|
||||||
|
|
||||||
IStorage_Release(stg);
|
IStorage_Release(stg);
|
||||||
|
|
||||||
test_file_access("winetest", create_close);
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
DeleteFileA("winetest");
|
DeleteFileA(fileA);
|
||||||
|
|
||||||
/* STGM_DIRECT */
|
/* STGM_DIRECT */
|
||||||
|
|
||||||
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
||||||
STGM_SHARE_EXCLUSIVE | STGM_DIRECT, 0, &stg);
|
STGM_SHARE_EXCLUSIVE | STGM_DIRECT, 0, &stg);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create);
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create_commit);
|
test_file_access(fileA, create_commit);
|
||||||
|
|
||||||
IStorage_Release(stg);
|
IStorage_Release(stg);
|
||||||
|
|
||||||
test_file_access("winetest", create_close);
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
DeleteFileA("winetest");
|
DeleteFileA(fileA);
|
||||||
|
|
||||||
/* STGM_SHARE_DENY_NONE */
|
/* STGM_SHARE_DENY_NONE */
|
||||||
|
|
||||||
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
||||||
STGM_SHARE_DENY_NONE | STGM_TRANSACTED, 0, &stg);
|
STGM_SHARE_DENY_NONE | STGM_TRANSACTED, 0, &stg);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create);
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create_commit);
|
test_file_access(fileA, create_commit);
|
||||||
|
|
||||||
IStorage_Release(stg);
|
IStorage_Release(stg);
|
||||||
|
|
||||||
test_file_access("winetest", create_close);
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
DeleteFileA("winetest");
|
DeleteFileA(fileA);
|
||||||
|
|
||||||
/* STGM_SHARE_DENY_READ */
|
/* STGM_SHARE_DENY_READ */
|
||||||
|
|
||||||
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
||||||
STGM_SHARE_DENY_READ | STGM_TRANSACTED, 0, &stg);
|
STGM_SHARE_DENY_READ | STGM_TRANSACTED, 0, &stg);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create);
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create_commit);
|
test_file_access(fileA, create_commit);
|
||||||
|
|
||||||
IStorage_Release(stg);
|
IStorage_Release(stg);
|
||||||
|
|
||||||
test_file_access("winetest", create_close);
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
DeleteFileA("winetest");
|
DeleteFileA(fileA);
|
||||||
|
|
||||||
/* STGM_SHARE_DENY_WRITE */
|
/* STGM_SHARE_DENY_WRITE */
|
||||||
|
|
||||||
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
|
||||||
STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg);
|
STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create);
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
hr = IStorage_Commit(stg, STGC_DEFAULT);
|
||||||
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
|
||||||
|
|
||||||
test_file_access("winetest", create_commit);
|
test_file_access(fileA, create_commit);
|
||||||
|
|
||||||
IStorage_Release(stg);
|
IStorage_Release(stg);
|
||||||
|
|
||||||
test_file_access("winetest", create_close);
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
DeleteFileA("winetest");
|
DeleteFileA(fileA);
|
||||||
|
|
||||||
|
/* STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE - reader mode for direct SWMR mode */
|
||||||
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
|
||||||
|
hr = StgOpenStorage(fileW, NULL, STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE, NULL, 0, &stg);
|
||||||
|
ok(hr == S_OK || broken(hr == STG_E_INVALIDFLAG), "got %08x\n", hr);
|
||||||
|
if(hr != S_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
test_file_access(fileA, create);
|
||||||
|
|
||||||
|
IStorage_Release(stg);
|
||||||
|
test_file_access(fileA, create_close);
|
||||||
|
|
||||||
|
DeleteFileA(fileA);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_readonly(void)
|
static void test_readonly(void)
|
||||||
|
@ -3036,6 +3052,57 @@ static void test_convert(void)
|
||||||
DeleteFileW(filename);
|
DeleteFileW(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_direct_swmr(void)
|
||||||
|
{
|
||||||
|
static const WCHAR fileW[] = {'w','i','n','e','t','e','s','t',0};
|
||||||
|
IDirectWriterLock *dwlock;
|
||||||
|
ULONG ref, ref2;
|
||||||
|
IStorage *stg;
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
/* it's possible to create in writer mode */
|
||||||
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_DIRECT_SWMR, 0, &stg);
|
||||||
|
todo_wine
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
if (hr == S_OK) {
|
||||||
|
IStorage_Release(stg);
|
||||||
|
DeleteFileW(fileW);
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
|
||||||
|
/* reader mode */
|
||||||
|
hr = StgOpenStorage(fileW, NULL, STGM_DIRECT_SWMR | STGM_READ | STGM_SHARE_DENY_NONE, NULL, 0, &stg);
|
||||||
|
ok(hr == S_OK || broken(hr == STG_E_INVALIDFLAG), "got %08x\n", hr);
|
||||||
|
if(hr == S_OK)
|
||||||
|
{
|
||||||
|
hr = IStorage_QueryInterface(stg, &IID_IDirectWriterLock, (void**)&dwlock);
|
||||||
|
ok(hr == E_NOINTERFACE, "got %08x\n", hr);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* writer mode */
|
||||||
|
hr = StgOpenStorage(fileW, NULL, STGM_DIRECT_SWMR | STGM_READWRITE | STGM_SHARE_DENY_WRITE, NULL, 0, &stg);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
|
||||||
|
ref = IStorage_AddRef(stg);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
|
||||||
|
hr = IStorage_QueryInterface(stg, &IID_IDirectWriterLock, (void**)&dwlock);
|
||||||
|
ok(hr == S_OK, "got %08x\n", hr);
|
||||||
|
|
||||||
|
ref2 = IStorage_AddRef(stg);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
ok(ref2 == ref + 1, "got %u\n", ref2);
|
||||||
|
|
||||||
|
IDirectWriterLock_Release(dwlock);
|
||||||
|
IStorage_Release(stg);
|
||||||
|
|
||||||
|
DeleteFileW(fileW);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(storage32)
|
START_TEST(storage32)
|
||||||
{
|
{
|
||||||
CHAR temp[MAX_PATH];
|
CHAR temp[MAX_PATH];
|
||||||
|
@ -3080,4 +3147,5 @@ START_TEST(storage32)
|
||||||
test_copyto_recursive();
|
test_copyto_recursive();
|
||||||
test_hglobal_storage_creation();
|
test_hglobal_storage_creation();
|
||||||
test_convert();
|
test_convert();
|
||||||
|
test_direct_swmr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ extern void func_hglobalstream(void);
|
||||||
extern void func_marshal(void);
|
extern void func_marshal(void);
|
||||||
extern void func_moniker(void);
|
extern void func_moniker(void);
|
||||||
extern void func_ole2(void);
|
extern void func_ole2(void);
|
||||||
|
extern void func_ole_server(void);
|
||||||
extern void func_propvariant(void);
|
extern void func_propvariant(void);
|
||||||
extern void func_stg_prop(void);
|
extern void func_stg_prop(void);
|
||||||
extern void func_storage32(void);
|
extern void func_storage32(void);
|
||||||
|
@ -28,6 +29,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "marshal", func_marshal },
|
{ "marshal", func_marshal },
|
||||||
{ "moniker", func_moniker },
|
{ "moniker", func_moniker },
|
||||||
{ "ole2", func_ole2 },
|
{ "ole2", func_ole2 },
|
||||||
|
{ "ole_server", func_ole_server },
|
||||||
{ "propvariant", func_propvariant },
|
{ "propvariant", func_propvariant },
|
||||||
{ "stg_prop", func_stg_prop },
|
{ "stg_prop", func_stg_prop },
|
||||||
{ "storage32", func_storage32 },
|
{ "storage32", func_storage32 },
|
||||||
|
|
Loading…
Reference in a new issue