mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
sync ole32_winetest with wine 1.14
svn path=/trunk/; revision=39474
This commit is contained in:
@@ -68,7 +68,7 @@ static HRESULT WINAPI EnumFormatImpl_QueryInterface(IEnumFORMATETC *iface, REFII
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IEnumFORMATETC)) {
|
||||
IEnumFORMATETC_AddRef(iface);
|
||||
*ppvObj = (LPVOID)This;
|
||||
*ppvObj = This;
|
||||
return S_OK;
|
||||
}
|
||||
*ppvObj = NULL;
|
||||
@@ -165,7 +165,7 @@ static HRESULT WINAPI DataObjectImpl_QueryInterface(IDataObject *iface, REFIID r
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IDataObject)) {
|
||||
IDataObject_AddRef(iface);
|
||||
*ppvObj = (LPVOID)This;
|
||||
*ppvObj = This;
|
||||
return S_OK;
|
||||
}
|
||||
*ppvObj = NULL;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
/* functions that are not present on all versions of Windows */
|
||||
HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit);
|
||||
HRESULT (WINAPI * pCoGetObjectContext)(REFIID riid, LPVOID *ppv);
|
||||
HRESULT (WINAPI * pCoSwitchCallContext)(IUnknown *pObject, IUnknown **ppOldObject);
|
||||
|
||||
#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)
|
||||
@@ -88,7 +89,7 @@ static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -286,7 +287,7 @@ static HRESULT WINAPI MessageFilter_QueryInterface(IMessageFilter *iface, REFIID
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IMessageFilter_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -397,7 +398,7 @@ static HRESULT WINAPI Test_IUnknown_QueryInterface(
|
||||
if (IsEqualIID(riid, &IID_IUnknown) ||
|
||||
IsEqualIID(riid, &IID_IWineTest))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -512,7 +513,7 @@ static void test_CoRegisterPSClsid(void)
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream);
|
||||
ok_ole_success(hr, "CreateStreamOnHGlobal");
|
||||
|
||||
hr = CoMarshalInterface(stream, &IID_IWineTest, (IUnknown *)&Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
hr = CoMarshalInterface(stream, &IID_IWineTest, &Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
ok(hr == E_NOTIMPL, "CoMarshalInterface should have returned E_NOTIMPL instead of 0x%08x\n", hr);
|
||||
IStream_Release(stream);
|
||||
|
||||
@@ -938,6 +939,7 @@ static void test_CoFreeUnusedLibraries(void)
|
||||
if (hr == REGDB_E_CLASSNOTREG)
|
||||
{
|
||||
trace("IE not installed so can't run CoFreeUnusedLibraries test\n");
|
||||
CoUninitialize();
|
||||
return;
|
||||
}
|
||||
ok_ole_success(hr, "CoCreateInstance");
|
||||
@@ -1039,6 +1041,106 @@ static void test_CoGetObjectContext(void)
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const IUnknownVtbl *lpVtbl;
|
||||
LONG refs;
|
||||
} Test_CallContext;
|
||||
|
||||
static HRESULT WINAPI Test_CallContext_QueryInterface(
|
||||
IUnknown *iface,
|
||||
REFIID riid,
|
||||
LPVOID *ppvObj)
|
||||
{
|
||||
if (ppvObj == NULL) return E_POINTER;
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
*ppvObj = iface;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObj = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI Test_CallContext_AddRef(IUnknown *iface)
|
||||
{
|
||||
Test_CallContext *This = (Test_CallContext*)iface;
|
||||
return InterlockedIncrement(&This->refs);
|
||||
}
|
||||
|
||||
static ULONG WINAPI Test_CallContext_Release(IUnknown *iface)
|
||||
{
|
||||
Test_CallContext *This = (Test_CallContext*)iface;
|
||||
ULONG refs = InterlockedDecrement(&This->refs);
|
||||
if (!refs)
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return refs;
|
||||
}
|
||||
|
||||
static const IUnknownVtbl TestCallContext_Vtbl =
|
||||
{
|
||||
Test_CallContext_QueryInterface,
|
||||
Test_CallContext_AddRef,
|
||||
Test_CallContext_Release
|
||||
};
|
||||
|
||||
static void test_CoGetCallContext(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
ULONG refs;
|
||||
IUnknown *pUnk;
|
||||
IUnknown *test_object;
|
||||
|
||||
if (!pCoSwitchCallContext)
|
||||
{
|
||||
skip("CoSwitchCallContext not present\n");
|
||||
return;
|
||||
}
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
test_object = HeapAlloc(GetProcessHeap(), 0, sizeof(Test_CallContext));
|
||||
((Test_CallContext*)test_object)->lpVtbl = &TestCallContext_Vtbl;
|
||||
((Test_CallContext*)test_object)->refs = 1;
|
||||
|
||||
hr = CoGetCallContext(&IID_IUnknown, (void**)&pUnk);
|
||||
ok(hr == RPC_E_CALL_COMPLETE, "Expected RPC_E_CALL_COMPLETE, got 0x%08x\n", hr);
|
||||
|
||||
pUnk = (IUnknown*)0xdeadbeef;
|
||||
hr = pCoSwitchCallContext(test_object, &pUnk);
|
||||
ok_ole_success(hr, "CoSwitchCallContext");
|
||||
ok(pUnk == NULL, "expected NULL, got %p\n", pUnk);
|
||||
refs = IUnknown_AddRef(test_object);
|
||||
ok(refs == 2, "Expected refcount 2, got %d\n", refs);
|
||||
IUnknown_Release(test_object);
|
||||
|
||||
pUnk = (IUnknown*)0xdeadbeef;
|
||||
hr = CoGetCallContext(&IID_IUnknown, (void**)&pUnk);
|
||||
ok_ole_success(hr, "CoGetCallContext");
|
||||
ok(pUnk == test_object, "expected %p, got %p\n", test_object, pUnk);
|
||||
refs = IUnknown_AddRef(test_object);
|
||||
ok(refs == 3, "Expected refcount 3, got %d\n", refs);
|
||||
IUnknown_Release(test_object);
|
||||
IUnknown_Release(pUnk);
|
||||
|
||||
pUnk = (IUnknown*)0xdeadbeef;
|
||||
hr = pCoSwitchCallContext(NULL, &pUnk);
|
||||
ok_ole_success(hr, "CoSwitchCallContext");
|
||||
ok(pUnk == test_object, "expected %p, got %p\n", test_object, pUnk);
|
||||
refs = IUnknown_AddRef(test_object);
|
||||
ok(refs == 2, "Expected refcount 2, got %d\n", refs);
|
||||
IUnknown_Release(test_object);
|
||||
|
||||
hr = CoGetCallContext(&IID_IUnknown, (void**)&pUnk);
|
||||
ok(hr == RPC_E_CALL_COMPLETE, "Expected RPC_E_CALL_COMPLETE, got 0x%08x\n", hr);
|
||||
|
||||
IUnknown_Release(test_object);
|
||||
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
static void test_CoInitializeEx(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
@@ -1064,6 +1166,7 @@ START_TEST(compobj)
|
||||
{
|
||||
HMODULE hOle32 = GetModuleHandle("ole32");
|
||||
pCoGetObjectContext = (void*)GetProcAddress(hOle32, "CoGetObjectContext");
|
||||
pCoSwitchCallContext = (void*)GetProcAddress(hOle32, "CoSwitchCallContext");
|
||||
if (!(pCoInitializeEx = (void*)GetProcAddress(hOle32, "CoInitializeEx")))
|
||||
{
|
||||
trace("You need DCOM95 installed to run this test\n");
|
||||
@@ -1088,5 +1191,6 @@ START_TEST(compobj)
|
||||
test_registered_object_thread_affinity();
|
||||
test_CoFreeUnusedLibraries();
|
||||
test_CoGetObjectContext();
|
||||
test_CoGetCallContext();
|
||||
test_CoInitializeEx();
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ static HRESULT WINAPI Test_IUnknown_QueryInterface(
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||
/* the only other interface Wine is currently able to marshal (for testing two proxies) */
|
||||
IsEqualGUID(riid, &IID_IRemUnknown))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -220,7 +220,7 @@ struct host_object_data
|
||||
|
||||
static DWORD CALLBACK host_object_proc(LPVOID p)
|
||||
{
|
||||
struct host_object_data *data = (struct host_object_data *)p;
|
||||
struct host_object_data *data = p;
|
||||
HRESULT hr;
|
||||
MSG msg;
|
||||
|
||||
@@ -833,7 +833,7 @@ struct ncu_params
|
||||
/* helper for test_no_couninitialize_server */
|
||||
static DWORD CALLBACK no_couninitialize_server_proc(LPVOID p)
|
||||
{
|
||||
struct ncu_params *ncu_params = (struct ncu_params *)p;
|
||||
struct ncu_params *ncu_params = p;
|
||||
HRESULT hr;
|
||||
|
||||
pCoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
@@ -899,7 +899,7 @@ static void test_no_couninitialize_server(void)
|
||||
/* STA -> STA call during DLL_THREAD_DETACH */
|
||||
static DWORD CALLBACK no_couninitialize_client_proc(LPVOID p)
|
||||
{
|
||||
struct ncu_params *ncu_params = (struct ncu_params *)p;
|
||||
struct ncu_params *ncu_params = p;
|
||||
HRESULT hr;
|
||||
IUnknown *pProxy = NULL;
|
||||
|
||||
@@ -1370,7 +1370,7 @@ static void test_hresult_marshaling(void)
|
||||
/* helper for test_proxy_used_in_wrong_thread */
|
||||
static DWORD CALLBACK bad_thread_proc(LPVOID p)
|
||||
{
|
||||
IClassFactory * cf = (IClassFactory *)p;
|
||||
IClassFactory * cf = p;
|
||||
HRESULT hr;
|
||||
IUnknown * proxy = NULL;
|
||||
|
||||
@@ -1447,7 +1447,7 @@ static void test_proxy_used_in_wrong_thread(void)
|
||||
IClassFactory_QueryInterface(pProxy, &IID_IStream, (LPVOID *)&pStream);
|
||||
|
||||
/* create a thread that we can misbehave in */
|
||||
thread = CreateThread(NULL, 0, bad_thread_proc, (LPVOID)pProxy, 0, &tid2);
|
||||
thread = CreateThread(NULL, 0, bad_thread_proc, pProxy, 0, &tid2);
|
||||
|
||||
WaitForSingleObject(thread, INFINITE);
|
||||
CloseHandle(thread);
|
||||
@@ -1468,7 +1468,7 @@ static HRESULT WINAPI MessageFilter_QueryInterface(IMessageFilter *iface, REFIID
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -1679,7 +1679,7 @@ static HRESULT WINAPI HeapUnknown_QueryInterface(IUnknown *iface, REFIID riid, v
|
||||
if (IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
*ppv = (LPVOID)iface;
|
||||
*ppv = iface;
|
||||
return S_OK;
|
||||
}
|
||||
*ppv = NULL;
|
||||
@@ -2040,6 +2040,19 @@ static void test_WM_QUIT_handling(void)
|
||||
}
|
||||
}
|
||||
|
||||
static SIZE_T round_heap_size(SIZE_T size)
|
||||
{
|
||||
static SIZE_T heap_size_alignment = -1;
|
||||
if (heap_size_alignment == -1)
|
||||
{
|
||||
void *p = HeapAlloc(GetProcessHeap(), 0, 1);
|
||||
heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
|
||||
HeapFree(GetProcessHeap(), 0, p);
|
||||
}
|
||||
|
||||
return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
|
||||
}
|
||||
|
||||
static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
|
||||
{
|
||||
HGLOBAL hglobal;
|
||||
@@ -2056,7 +2069,7 @@ static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *
|
||||
|
||||
if (mshctx == MSHCTX_INPROC)
|
||||
{
|
||||
DWORD expected_size = 3*sizeof(DWORD) + sizeof(GUID);
|
||||
DWORD expected_size = round_heap_size(3*sizeof(DWORD) + sizeof(GUID));
|
||||
ok(size == expected_size, "size should have been %d instead of %d\n", expected_size, size);
|
||||
|
||||
ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
|
||||
@@ -2105,7 +2118,7 @@ static void test_freethreadedmarshaler(void)
|
||||
/* inproc normal marshaling */
|
||||
|
||||
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
||||
(IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
ok_ole_success(hr, IMarshal_MarshalInterface);
|
||||
|
||||
ok_more_than_one_lock();
|
||||
@@ -2127,7 +2140,7 @@ static void test_freethreadedmarshaler(void)
|
||||
/* local normal marshaling */
|
||||
|
||||
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
||||
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory, (IUnknown*)&Test_ClassFactory, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
|
||||
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory, &Test_ClassFactory, MSHCTX_LOCAL, NULL, MSHLFLAGS_NORMAL);
|
||||
ok_ole_success(hr, IMarshal_MarshalInterface);
|
||||
|
||||
ok_more_than_one_lock();
|
||||
@@ -2193,7 +2206,7 @@ static void test_freethreadedmarshaler(void)
|
||||
|
||||
IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL);
|
||||
hr = IMarshal_MarshalInterface(pFTMarshal, pStream, &IID_IClassFactory,
|
||||
(IUnknown*)&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
&Test_ClassFactory, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL);
|
||||
ok_ole_success(hr, IMarshal_MarshalInterface);
|
||||
|
||||
ok_more_than_one_lock();
|
||||
@@ -2222,11 +2235,9 @@ static void test_freethreadedmarshaler(void)
|
||||
IMarshal_Release(pFTMarshal);
|
||||
}
|
||||
|
||||
static void test_inproc_handler(void)
|
||||
static void reg_unreg_wine_test_class(BOOL Register)
|
||||
{
|
||||
HRESULT hr;
|
||||
IUnknown *pObject;
|
||||
IUnknown *pObject2;
|
||||
char buffer[256];
|
||||
LPOLESTR pszClsid;
|
||||
HKEY hkey;
|
||||
@@ -2239,11 +2250,29 @@ static void test_inproc_handler(void)
|
||||
WideCharToMultiByte(CP_ACP, 0, pszClsid, -1, buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), NULL, NULL);
|
||||
CoTaskMemFree(pszClsid);
|
||||
strcat(buffer, "\\InprocHandler32");
|
||||
error = RegCreateKeyEx(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
|
||||
ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
|
||||
error = RegSetValueEx(hkey, NULL, 0, REG_SZ, (const unsigned char *)"ole32.dll", strlen("ole32.dll") + 1);
|
||||
ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
|
||||
RegCloseKey(hkey);
|
||||
if (Register)
|
||||
{
|
||||
error = RegCreateKeyEx(HKEY_CLASSES_ROOT, buffer, 0, NULL, 0, KEY_SET_VALUE, NULL, &hkey, &dwDisposition);
|
||||
ok(error == ERROR_SUCCESS, "RegCreateKeyEx failed with error %d\n", error);
|
||||
error = RegSetValueEx(hkey, NULL, 0, REG_SZ, (const unsigned char *)"ole32.dll", strlen("ole32.dll") + 1);
|
||||
ok(error == ERROR_SUCCESS, "RegSetValueEx failed with error %d\n", error);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
else
|
||||
{
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, buffer);
|
||||
*strrchr(buffer, '\\') = '\0';
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_inproc_handler(void)
|
||||
{
|
||||
HRESULT hr;
|
||||
IUnknown *pObject;
|
||||
IUnknown *pObject2;
|
||||
|
||||
reg_unreg_wine_test_class(TRUE);
|
||||
|
||||
hr = CoCreateInstance(&CLSID_WineTest, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&pObject);
|
||||
todo_wine
|
||||
@@ -2262,9 +2291,7 @@ static void test_inproc_handler(void)
|
||||
IUnknown_Release(pObject);
|
||||
}
|
||||
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, buffer);
|
||||
*strrchr(buffer, '\\') = '\0';
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, buffer);
|
||||
reg_unreg_wine_test_class(FALSE);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI Test_SMI_QueryInterface(
|
||||
@@ -2277,7 +2304,7 @@ static HRESULT WINAPI Test_SMI_QueryInterface(
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IStdMarshalInfo))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -2327,6 +2354,7 @@ static void test_handler_marshaling(void)
|
||||
HANDLE thread;
|
||||
static const LARGE_INTEGER ullZero;
|
||||
|
||||
reg_unreg_wine_test_class(TRUE);
|
||||
cLocks = 0;
|
||||
|
||||
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
|
||||
@@ -2359,6 +2387,7 @@ static void test_handler_marshaling(void)
|
||||
}
|
||||
|
||||
end_host_object(tid, thread);
|
||||
reg_unreg_wine_test_class(FALSE);
|
||||
|
||||
/* FIXME: test IPersist interface has the same effect as IStdMarshalInfo */
|
||||
}
|
||||
@@ -2437,7 +2466,7 @@ static void test_client_security(void)
|
||||
|
||||
CoTaskMemFree(pServerPrincName);
|
||||
|
||||
hr = IClientSecurity_QueryBlanket(pCliSec, (IUnknown *)pUnknown1, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
|
||||
hr = IClientSecurity_QueryBlanket(pCliSec, pUnknown1, &dwAuthnSvc, &dwAuthzSvc, &pServerPrincName, &dwAuthnLevel, &dwImpLevel, &pAuthInfo, &dwCapabilities);
|
||||
todo_wine ok_ole_success(hr, "IClientSecurity_QueryBlanket(IUnknown)");
|
||||
|
||||
CoTaskMemFree(pServerPrincName);
|
||||
@@ -2479,7 +2508,7 @@ static HRESULT WINAPI TestOOP_IClassFactory_QueryInterface(
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -2694,14 +2723,17 @@ struct git_params
|
||||
static DWORD CALLBACK get_global_interface_proc(LPVOID pv)
|
||||
{
|
||||
HRESULT hr;
|
||||
struct git_params *params = (struct git_params *)pv;
|
||||
struct git_params *params = pv;
|
||||
IClassFactory *cf;
|
||||
|
||||
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
|
||||
ok(hr == CO_E_NOTINITIALIZED ||
|
||||
hr == E_UNEXPECTED, /* win2k */
|
||||
broken(hr == E_UNEXPECTED) /* win2k */ ||
|
||||
broken(hr == S_OK) /* NT 4 */,
|
||||
"IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
|
||||
hr);
|
||||
if (hr == S_OK)
|
||||
IClassFactory_Release(cf);
|
||||
|
||||
CoInitialize(NULL);
|
||||
|
||||
|
||||
@@ -82,6 +82,19 @@ static void UnlockModule(void)
|
||||
InterlockedDecrement(&cLocks);
|
||||
}
|
||||
|
||||
static SIZE_T round_heap_size(SIZE_T size)
|
||||
{
|
||||
static SIZE_T heap_size_alignment = -1;
|
||||
if (heap_size_alignment == -1)
|
||||
{
|
||||
void *p = HeapAlloc(GetProcessHeap(), 0, 1);
|
||||
heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
|
||||
HeapFree(GetProcessHeap(), 0, p);
|
||||
}
|
||||
|
||||
return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
|
||||
}
|
||||
|
||||
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||
LPCLASSFACTORY iface,
|
||||
REFIID riid,
|
||||
@@ -92,7 +105,7 @@ static HRESULT WINAPI Test_IClassFactory_QueryInterface(
|
||||
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
||||
IsEqualGUID(riid, &IID_IClassFactory))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IClassFactory_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -151,7 +164,7 @@ static HRESULT WINAPI HeapUnknown_QueryInterface(IUnknown *iface, REFIID riid, v
|
||||
if (IsEqualIID(riid, &IID_IUnknown))
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
*ppv = (LPVOID)iface;
|
||||
*ppv = iface;
|
||||
return S_OK;
|
||||
}
|
||||
*ppv = NULL;
|
||||
@@ -1204,12 +1217,12 @@ static void test_moniker(
|
||||
moniker_data = GlobalLock(hglobal);
|
||||
|
||||
/* first check we have the right amount of data */
|
||||
ok(moniker_size == sizeof_expected_moniker_saved_data,
|
||||
ok(moniker_size == round_heap_size(sizeof_expected_moniker_saved_data),
|
||||
"%s: Size of saved data differs (expected %d, actual %d)\n",
|
||||
testname, sizeof_expected_moniker_saved_data, moniker_size);
|
||||
testname, (DWORD)round_heap_size(sizeof_expected_moniker_saved_data), moniker_size);
|
||||
|
||||
/* then do a byte-by-byte comparison */
|
||||
for (i = 0; i < min(moniker_size, sizeof_expected_moniker_saved_data); i++)
|
||||
for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_saved_data)); i++)
|
||||
{
|
||||
if (expected_moniker_saved_data[i] != moniker_data[i])
|
||||
{
|
||||
@@ -1250,14 +1263,14 @@ static void test_moniker(
|
||||
moniker_data = GlobalLock(hglobal);
|
||||
|
||||
/* first check we have the right amount of data */
|
||||
ok(moniker_size == sizeof_expected_moniker_marshal_data,
|
||||
ok(moniker_size == round_heap_size(sizeof_expected_moniker_marshal_data),
|
||||
"%s: Size of marshaled data differs (expected %d, actual %d)\n",
|
||||
testname, sizeof_expected_moniker_marshal_data, moniker_size);
|
||||
testname, (DWORD)round_heap_size(sizeof_expected_moniker_marshal_data), moniker_size);
|
||||
|
||||
/* then do a byte-by-byte comparison */
|
||||
if (expected_moniker_marshal_data)
|
||||
{
|
||||
for (i = 0; i < min(moniker_size, sizeof_expected_moniker_marshal_data); i++)
|
||||
for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_marshal_data)); i++)
|
||||
{
|
||||
if (expected_moniker_marshal_data[i] != moniker_data[i])
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ static HRESULT WINAPI OleObject_QueryInterface(IOleObject *iface, REFIID riid, v
|
||||
*ppv = NULL;
|
||||
|
||||
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IOleObject))
|
||||
*ppv = (void *)iface;
|
||||
*ppv = iface;
|
||||
else if (IsEqualIID(riid, &IID_IPersistStorage))
|
||||
*ppv = &OleObjectPersistStg;
|
||||
else if (IsEqualIID(riid, &IID_IOleCache))
|
||||
@@ -1497,7 +1497,7 @@ static void test_runnable(void)
|
||||
NULL
|
||||
};
|
||||
|
||||
IOleObject *object = (IOleObject *)&OleObject;
|
||||
IOleObject *object = &OleObject;
|
||||
|
||||
expected_method_list = methods_query_runnable;
|
||||
ok(OleIsRunning(object), "Object should be running\n");
|
||||
|
||||
@@ -100,7 +100,7 @@ static void testProps(void)
|
||||
|
||||
/* test setting one by name with an invalid propidNameFirst */
|
||||
spec.ulKind = PRSPEC_LPWSTR;
|
||||
U(spec).lpwstr = (LPOLESTR)propName;
|
||||
U(spec).lpwstr = propName;
|
||||
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
|
||||
PID_DICTIONARY);
|
||||
ok(hr == STG_E_INVALIDPARAMETER,
|
||||
@@ -123,7 +123,7 @@ static void testProps(void)
|
||||
|
||||
/* set one by name */
|
||||
spec.ulKind = PRSPEC_LPWSTR;
|
||||
U(spec).lpwstr = (LPOLESTR)propName;
|
||||
U(spec).lpwstr = propName;
|
||||
U(var).lVal = 2;
|
||||
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var,
|
||||
PID_FIRST_USABLE);
|
||||
@@ -164,7 +164,7 @@ static void testProps(void)
|
||||
var.vt, U(var).lVal);
|
||||
/* read by name */
|
||||
spec.ulKind = PRSPEC_LPWSTR;
|
||||
U(spec).lpwstr = (LPOLESTR)propName;
|
||||
U(spec).lpwstr = propName;
|
||||
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
||||
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
||||
ok(var.vt == VT_I4 && U(var).lVal == 2,
|
||||
@@ -237,7 +237,7 @@ static void testProps(void)
|
||||
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
||||
/* set it to a string value */
|
||||
var.vt = VT_LPSTR;
|
||||
U(var).pszVal = (LPSTR)val;
|
||||
U(var).pszVal = val;
|
||||
hr = IPropertyStorage_WriteMultiple(propertyStorage, 1, &spec, &var, 0);
|
||||
ok(hr == S_OK, "WriteMultiple failed: 0x%08x\n", hr);
|
||||
/* revert it */
|
||||
@@ -269,7 +269,7 @@ static void testProps(void)
|
||||
|
||||
/* check properties again */
|
||||
spec.ulKind = PRSPEC_LPWSTR;
|
||||
U(spec).lpwstr = (LPOLESTR)propName;
|
||||
U(spec).lpwstr = propName;
|
||||
hr = IPropertyStorage_ReadMultiple(propertyStorage, 1, &spec, &var);
|
||||
ok(hr == S_OK, "ReadMultiple failed: 0x%08x\n", hr);
|
||||
ok(var.vt == VT_I4 && U(var).lVal == 2,
|
||||
|
||||
@@ -386,7 +386,7 @@ static HRESULT WINAPI Test_IUnknown_QueryInterface(
|
||||
|
||||
if (IsEqualGUID(riid, &IID_IUnknown))
|
||||
{
|
||||
*ppvObj = (LPVOID)iface;
|
||||
*ppvObj = iface;
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user