static void test_CLSIDFromString(void) { CLSID clsid; HRESULT hr = CLSIDFromString((LPOLESTR)wszCLSID_CDeviceMoniker, &clsid); ok_ole_success(hr, "CLSIDFromString"); ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n"); }
static void test_freed_hglobal(void) { static const char teststring[] = "this is a test string"; HRESULT hr; IStream *pStream; HGLOBAL hglobal; char *p; char buffer[sizeof(teststring) + 8]; ULARGE_INTEGER ull; ULONG read, written; hglobal = GlobalAlloc(GMEM_DDESHARE|GMEM_NODISCARD|GMEM_MOVEABLE, strlen(teststring) + 1); ok(hglobal != NULL, "GlobalAlloc failed with error %d\n", GetLastError()); p = GlobalLock(hglobal); strcpy(p, teststring); GlobalUnlock(hglobal); hr = CreateStreamOnHGlobal(hglobal, FALSE, &pStream); ok_ole_success(hr, "CreateStreamOnHGlobal"); hr = IStream_Read(pStream, buffer, sizeof(buffer), &read); ok_ole_success(hr, "IStream_Read"); ok(!strcmp(buffer, teststring), "buffer data %s differs\n", buffer); ok(read == sizeof(teststring) || broken(read == ((sizeof(teststring) + 3) & ~3)), /* win9x rounds the size */ "read should be sizeof(teststring) instead of %d\n", read); GlobalFree(hglobal); memset(buffer, 0, sizeof(buffer)); read = -1; hr = IStream_Read(pStream, buffer, sizeof(buffer), &read); ok_ole_success(hr, "IStream_Read"); ok(buffer[0] == 0, "buffer data should be untouched\n"); ok(read == 0, "read should be 0 instead of %d\n", read); ull.QuadPart = sizeof(buffer); hr = IStream_SetSize(pStream, ull); ok(hr == E_OUTOFMEMORY, "IStream_SetSize with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr); hr = IStream_Write(pStream, buffer, sizeof(buffer), &written); ok(hr == E_OUTOFMEMORY, "IStream_Write with invalid HGLOBAL should return E_OUTOFMEMORY instead of 0x%08x\n", hr); ok(written == 0, "written should be 0 instead of %d\n", written); IStream_Release(pStream); }
static void test_copyto(void) { IStream *pStream, *pStream2; HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream); static const char szHello[] = "Hello"; ULARGE_INTEGER cb; static const char *methods_copyto[] = { "TestStream_Write", NULL }; ULONG written; ULARGE_INTEGER ullRead; ULARGE_INTEGER ullWritten; ULARGE_INTEGER libNewPosition; static const LARGE_INTEGER llZero; char buffer[15]; ok_ole_success(hr, "CreateStreamOnHGlobal"); expected_method_list = methods_copyto; hr = IStream_Write(pStream, szHello, sizeof(szHello), &written); ok_ole_success(hr, "IStream_Write"); ok(written == sizeof(szHello), "only %d bytes written\n", written); hr = IStream_Seek(pStream, llZero, STREAM_SEEK_SET, NULL); ok_ole_success(hr, "IStream_Seek"); cb.QuadPart = sizeof(szHello); hr = IStream_CopyTo(pStream, &Test_Stream, cb, &ullRead, &ullWritten); ok(ullWritten.QuadPart == 5, "ullWritten was %d instead\n", (ULONG)ullWritten.QuadPart); ok(ullRead.QuadPart == sizeof(szHello), "only %d bytes read\n", (ULONG)ullRead.QuadPart); ok_ole_success(hr, "IStream_CopyTo"); ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); hr = IStream_Clone(pStream, &pStream2); ok_ole_success(hr, "IStream_Clone"); hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_CUR, &libNewPosition); ok_ole_success(hr, "IStream_Seek"); ok(libNewPosition.QuadPart == sizeof(szHello), "libNewPosition wasn't set correctly for the cloned stream\n"); hr = IStream_Seek(pStream2, llZero, STREAM_SEEK_SET, NULL); ok_ole_success(hr, "IStream_Seek"); hr = IStream_Read(pStream2, buffer, sizeof(buffer), NULL); ok_ole_success(hr, "IStream_Read"); ok(!strcmp(buffer, szHello), "read data \"%s\" didn't match originally written data\n", buffer); IStream_Release(pStream2); IStream_Release(pStream); }
static DWORD CALLBACK host_object_proc(LPVOID p) { struct host_object_data *data = p; HRESULT hr; MSG msg; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (data->filter) { IMessageFilter * prev_filter = NULL; hr = CoRegisterMessageFilter(data->filter, &prev_filter); if (prev_filter) IMessageFilter_Release(prev_filter); ok_ole_success(hr, CoRegisterMessageFilter); } hr = CoMarshalInterface(data->stream, &data->iid, data->object, MSHCTX_INPROC, NULL, data->marshal_flags); ok_ole_success(hr, CoMarshalInterface); /* force the message queue to be created before signaling parent thread */ PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); SetEvent(data->marshal_event); while (GetMessage(&msg, NULL, 0, 0)) { if (msg.hwnd == NULL && msg.message == RELEASEMARSHALDATA) { trace("releasing marshal data\n"); CoReleaseMarshalData(data->stream); SetEvent((HANDLE)msg.lParam); } else DispatchMessage(&msg); } HeapFree(GetProcessHeap(), 0, data); CoUninitialize(); return hr; }
static void test_CLSIDFromProgID(void) { CLSID clsid; HRESULT hr = CLSIDFromProgID(devicedotone, &clsid); ok(hr == S_OK, "CLSIDFromProgID failed with error 0x%08lx\n", hr); ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n"); hr = CLSIDFromString((LPOLESTR)devicedotone, &clsid); ok_ole_success(hr, "CLSIDFromString"); ok(IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker), "clsid wasn't equal to CLSID_CDeviceMoniker\n"); }
static void test_ole_menu(void) { HWND hwndFrame; HRESULT hr; hwndFrame = CreateWindow(MAKEINTATOM(register_dummy_class()), "Test", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); hr = OleSetMenuDescriptor(NULL, hwndFrame, NULL, NULL, NULL); todo_wine ok_ole_success(hr, "OleSetMenuDescriptor"); DestroyWindow(hwndFrame); }
static void test_CoRegisterPSClsid(void) { HRESULT hr; DWORD dwRegistrationKey; IStream *stream; CLSID clsid; hr = CoRegisterPSClsid(&IID_IWineTest, &CLSID_WineTestPSFactoryBuffer); ok(hr == CO_E_NOTINITIALIZED, "CoRegisterPSClsid should have returened CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr); pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = CoRegisterClassObject(&CLSID_WineTestPSFactoryBuffer, (IUnknown *)&PSFactoryBuffer, CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE, &dwRegistrationKey); ok_ole_success(hr, "CoRegisterClassObject"); hr = CoRegisterPSClsid(&IID_IWineTest, &CLSID_WineTestPSFactoryBuffer); ok_ole_success(hr, "CoRegisterPSClsid"); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok_ole_success(hr, "CreateStreamOnHGlobal"); hr = CoMarshalInterface(stream, &IID_IWineTest, (IUnknown *)&Test_Unknown, MSHCTX_INPROC, NULL, MSHLFLAGS_NORMAL); ok(hr == E_NOTIMPL, "CoMarshalInterface should have returned E_NOTIMPL instead of 0x%08lx\n", hr); IStream_Release(stream); hr = CoRevokeClassObject(dwRegistrationKey); ok_ole_success(hr, "CoRevokeClassObject"); CoUninitialize(); pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = CoGetPSClsid(&IID_IWineTest, &clsid); ok(hr == REGDB_E_IIDNOTREG, "CoGetPSClsid should have returned REGDB_E_IIDNOTREG instead of 0x%08lx\n", hr); CoUninitialize(); }
static void test_CoRegisterMessageFilter(void) { HRESULT hr; IMessageFilter *prev_filter; #if 0 /* crashes without an apartment! */ hr = CoRegisterMessageFilter(&MessageFilter, &prev_filter); #endif pCoInitializeEx(NULL, COINIT_MULTITHREADED); prev_filter = (IMessageFilter *)0xdeadbeef; hr = CoRegisterMessageFilter(&MessageFilter, &prev_filter); ok(hr == CO_E_NOT_SUPPORTED, "CoRegisterMessageFilter should have failed with CO_E_NOT_SUPPORTED instead of 0x%08lx\n", hr); ok(prev_filter == (IMessageFilter *)0xdeadbeef, "prev_filter should have been set to %p\n", prev_filter); CoUninitialize(); pCoInitializeEx(NULL, COINIT_APARTMENTTHREADED); hr = CoRegisterMessageFilter(NULL, NULL); ok_ole_success(hr, "CoRegisterMessageFilter"); prev_filter = (IMessageFilter *)0xdeadbeef; hr = CoRegisterMessageFilter(NULL, &prev_filter); ok_ole_success(hr, "CoRegisterMessageFilter"); ok(prev_filter == NULL, "prev_filter should have been set to NULL instead of %p\n", prev_filter); hr = CoRegisterMessageFilter(&MessageFilter, &prev_filter); ok_ole_success(hr, "CoRegisterMessageFilter"); ok(prev_filter == NULL, "prev_filter should have been set to NULL instead of %p\n", prev_filter); hr = CoRegisterMessageFilter(NULL, NULL); ok_ole_success(hr, "CoRegisterMessageFilter"); CoUninitialize(); }
static void test_CoCreateInstance(void) { REFCLSID rclsid = &CLSID_MyComputer; IUnknown *pUnk = (IUnknown *)0xdeadbeef; HRESULT hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr); ok(pUnk == NULL, "CoCreateInstance should have changed the passed in pointer to NULL, instead of %p\n", pUnk); OleInitialize(NULL); hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); ok_ole_success(hr, "CoCreateInstance"); IUnknown_Release(pUnk); OleUninitialize(); hr = CoCreateInstance(rclsid, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&pUnk); ok(hr == CO_E_NOTINITIALIZED, "CoCreateInstance should have returned CO_E_NOTINITIALIZED instead of 0x%08lx\n", hr); }
static void test_error_info(void) { HRESULT hr; ICreateErrorInfo *pCreateErrorInfo; IErrorInfo *pErrorInfo; static WCHAR wszDescription[] = {'F','a','i','l','e','d',' ','S','p','r','o','c','k','e','t',0}; static WCHAR wszHelpFile[] = {'s','p','r','o','c','k','e','t','.','h','l','p',0}; static WCHAR wszSource[] = {'s','p','r','o','c','k','e','t',0}; IUnknown *unk; hr = CreateErrorInfo(&pCreateErrorInfo); ok_ole_success(hr, "CreateErrorInfo"); hr = ICreateErrorInfo_QueryInterface(pCreateErrorInfo, &IID_IUnknown, (void**)&unk); ok_ole_success(hr, "QI"); IUnknown_Release(unk); hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, NULL); ok_ole_success(hr, "ICreateErrorInfo_SetDescription"); hr = ICreateErrorInfo_SetDescription(pCreateErrorInfo, wszDescription); ok_ole_success(hr, "ICreateErrorInfo_SetDescription"); hr = ICreateErrorInfo_SetGUID(pCreateErrorInfo, &CLSID_WineTest); ok_ole_success(hr, "ICreateErrorInfo_SetGUID"); hr = ICreateErrorInfo_SetHelpContext(pCreateErrorInfo, 0xdeadbeef); ok_ole_success(hr, "ICreateErrorInfo_SetHelpContext"); hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, NULL); ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile"); hr = ICreateErrorInfo_SetHelpFile(pCreateErrorInfo, wszHelpFile); ok_ole_success(hr, "ICreateErrorInfo_SetHelpFile"); hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, NULL); ok_ole_success(hr, "ICreateErrorInfo_SetSource"); hr = ICreateErrorInfo_SetSource(pCreateErrorInfo, wszSource); ok_ole_success(hr, "ICreateErrorInfo_SetSource"); hr = ICreateErrorInfo_QueryInterface(pCreateErrorInfo, &IID_IErrorInfo, (void **)&pErrorInfo); ok_ole_success(hr, "ICreateErrorInfo_QueryInterface"); hr = IErrorInfo_QueryInterface(pErrorInfo, &IID_IUnknown, (void**)&unk); ok_ole_success(hr, "QI"); IUnknown_Release(unk); ICreateErrorInfo_Release(pCreateErrorInfo); hr = SetErrorInfo(0, pErrorInfo); ok_ole_success(hr, "SetErrorInfo"); IErrorInfo_Release(pErrorInfo); pErrorInfo = NULL; hr = GetErrorInfo(0, &pErrorInfo); ok_ole_success(hr, "GetErrorInfo"); IErrorInfo_Release(pErrorInfo); hr = GetErrorInfo(0, &pErrorInfo); ok(hr == S_FALSE, "GetErrorInfo should have returned S_FALSE instead of 0x%08x\n", hr); ok(!pErrorInfo, "pErrorInfo should be set to NULL\n"); hr = SetErrorInfo(0, NULL); ok_ole_success(hr, "SetErrorInfo"); hr = GetErrorInfo(0xdeadbeef, &pErrorInfo); ok(hr == E_INVALIDARG, "GetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr); hr = SetErrorInfo(0xdeadbeef, NULL); ok(hr == E_INVALIDARG, "SetErrorInfo should have returned E_INVALIDARG instead of 0x%08x\n", hr); }
static void test_Register_Revoke(void) { HANDLE prop; HRESULT hr; HWND hwnd; hwnd = CreateWindowA("WineOleTestClass", "Test", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); hr = RegisterDragDrop(hwnd, &DropTarget); ok(hr == E_OUTOFMEMORY || broken(hr == CO_E_NOTINITIALIZED), /* NT4 */ "RegisterDragDrop without OLE initialized should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr); OleInitialize(NULL); hr = RegisterDragDrop(hwnd, NULL); ok(hr == E_INVALIDARG, "RegisterDragDrop with NULL IDropTarget * should return E_INVALIDARG instead of 0x%08x\n", hr); hr = RegisterDragDrop(NULL, &DropTarget); ok(hr == DRAGDROP_E_INVALIDHWND, "RegisterDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr); hr = RegisterDragDrop((HWND)0xdeadbeef, &DropTarget); ok(hr == DRAGDROP_E_INVALIDHWND, "RegisterDragDrop with garbage hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr); ok(droptarget_refs == 0, "DropTarget refs should be zero not %d\n", droptarget_refs); hr = RegisterDragDrop(hwnd, &DropTarget); ok_ole_success(hr, "RegisterDragDrop"); ok(droptarget_refs >= 1, "DropTarget refs should be at least one\n"); prop = GetPropA(hwnd, "OleDropTargetInterface"); ok(prop == &DropTarget, "expected IDropTarget pointer %p, got %p\n", &DropTarget, prop); hr = RegisterDragDrop(hwnd, &DropTarget); ok(hr == DRAGDROP_E_ALREADYREGISTERED, "RegisterDragDrop with already registered hwnd should return DRAGDROP_E_ALREADYREGISTERED instead of 0x%08x\n", hr); ok(droptarget_refs >= 1, "DropTarget refs should be at least one\n"); OleUninitialize(); /* Win 8 releases the ref in OleUninitialize() */ if (droptarget_refs >= 1) { hr = RevokeDragDrop(hwnd); ok_ole_success(hr, "RevokeDragDrop"); ok(droptarget_refs == 0 || broken(droptarget_refs == 1), /* NT4 */ "DropTarget refs should be zero not %d\n", droptarget_refs); } hr = RevokeDragDrop(NULL); ok(hr == DRAGDROP_E_INVALIDHWND, "RevokeDragDrop with NULL hwnd should return DRAGDROP_E_INVALIDHWND instead of 0x%08x\n", hr); DestroyWindow(hwnd); /* try to revoke with already destroyed window */ OleInitialize(NULL); hwnd = CreateWindowA("WineOleTestClass", "Test", 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL); hr = RegisterDragDrop(hwnd, &DropTarget); ok(hr == S_OK, "got 0x%08x\n", hr); DestroyWindow(hwnd); hr = RevokeDragDrop(hwnd); ok(hr == DRAGDROP_E_INVALIDHWND, "got 0x%08x\n", hr); OleUninitialize(); }
static void test_TypeComp(void) { ITypeLib *pTypeLib; ITypeComp *pTypeComp; HRESULT hr; ULONG ulHash; DESCKIND desckind; BINDPTR bindptr; ITypeInfo *pTypeInfo; ITypeInfo *pFontTypeInfo; static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0}; static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0}; static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0}; static WCHAR wszUnchecked[] = {'U','n','c','h','e','c','k','e','d',0}; static WCHAR wszIUnknown[] = {'I','U','n','k','n','o','w','n',0}; static WCHAR wszFont[] = {'F','o','n','t',0}; static WCHAR wszGUID[] = {'G','U','I','D',0}; static WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0}; static WCHAR wszOLE_COLOR[] = {'O','L','E','_','C','O','L','O','R',0}; static WCHAR wszClone[] = {'C','l','o','n','e',0}; static WCHAR wszclone[] = {'c','l','o','n','e',0}; hr = LoadTypeLib(wszStdOle2, &pTypeLib); ok_ole_success(hr, LoadTypeLib); hr = ITypeLib_GetTypeComp(pTypeLib, &pTypeComp); ok_ole_success(hr, ITypeLib_GetTypeComp); /* test getting a TKIND_MODULE */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions); hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_TYPECOMP, "desckind should have been DESCKIND_TYPECOMP instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ITypeComp_Release(bindptr.lptcomp); /* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions); hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_TYPECOMP, "desckind should have been DESCKIND_TYPECOMP instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ITypeComp_Release(bindptr.lptcomp); /* test getting a function within a TKIND_MODULE */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture); hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC instead of %d\n", desckind); ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n"); ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc); ITypeInfo_Release(pTypeInfo); /* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture); hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr); todo_wine ok(hr == TYPE_E_TYPEMISMATCH, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* test getting a TKIND_ENUM */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_TRISTATE); hr = ITypeComp_Bind(pTypeComp, wszOLE_TRISTATE, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_TYPECOMP, "desckind should have been DESCKIND_TYPECOMP instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ITypeComp_Release(bindptr.lptcomp); /* test getting a value within a TKIND_ENUM */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszUnchecked); hr = ITypeComp_Bind(pTypeComp, wszUnchecked, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_VARDESC, "desckind should have been DESCKIND_VARDESC instead of %d\n", desckind); ITypeInfo_ReleaseVarDesc(pTypeInfo, bindptr.lpvardesc); ITypeInfo_Release(pTypeInfo); /* test getting a TKIND_INTERFACE */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszIUnknown); hr = ITypeComp_Bind(pTypeComp, wszIUnknown, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* test getting a TKIND_DISPATCH */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszFont); hr = ITypeComp_Bind(pTypeComp, wszFont, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* test getting a TKIND_RECORD/TKIND_ALIAS */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID); hr = ITypeComp_Bind(pTypeComp, wszGUID, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* test getting a TKIND_ALIAS */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_COLOR); hr = ITypeComp_Bind(pTypeComp, wszOLE_COLOR, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* test getting a TKIND_COCLASS */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdPicture); hr = ITypeComp_Bind(pTypeComp, wszStdPicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); ITypeComp_Release(pTypeComp); /* tests for ITypeComp on an interface */ hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pFontTypeInfo); ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid); hr = ITypeInfo_GetTypeComp(pFontTypeInfo, &pTypeComp); ok_ole_success(hr, ITypeLib_GetTypeComp); ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone); hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC instead of %d\n", desckind); ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n"); ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc); ITypeInfo_Release(pTypeInfo); ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone); hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr); ok(hr == TYPE_E_TYPEMISMATCH, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr); ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE instead of %d\n", desckind); ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n"); ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n"); /* tests that the compare is case-insensitive */ ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszclone); hr = ITypeComp_Bind(pTypeComp, wszclone, ulHash, 0, &pTypeInfo, &desckind, &bindptr); ok_ole_success(hr, ITypeComp_Bind); ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC instead of %d\n", desckind); ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n"); ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc); ITypeInfo_Release(pTypeInfo); ITypeComp_Release(pTypeComp); ITypeInfo_Release(pFontTypeInfo); ITypeLib_Release(pTypeLib); }
static void test_TypeInfo(void) { ITypeLib *pTypeLib; ITypeInfo *pTypeInfo; HRESULT hr; static WCHAR wszBogus[] = { 'b','o','g','u','s',0 }; static WCHAR wszGetTypeInfo[] = { 'G','e','t','T','y','p','e','I','n','f','o',0 }; static WCHAR wszClone[] = {'C','l','o','n','e',0}; OLECHAR* bogus = wszBogus; OLECHAR* pwszGetTypeInfo = wszGetTypeInfo; OLECHAR* pwszClone = wszClone; DISPID dispidMember; DISPPARAMS dispparams; hr = LoadTypeLib(wszStdOle2, &pTypeLib); ok_ole_success(hr, LoadTypeLib); hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pTypeInfo); ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid); /* test nonexistent method name */ hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &bogus, 1, &dispidMember); ok(hr == DISP_E_UNKNOWNNAME, "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n", hr); /* test invalid memberid */ dispparams.cNamedArgs = 0; dispparams.cArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.rgvarg = NULL; hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszClone, 1, &dispidMember); ok_ole_success(hr, ITypeInfo_GetIDsOfNames); /* test correct memberid, but wrong flags */ hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); /* test NULL dispparams */ hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); /* test dispparams->cNamedArgs being bigger than dispparams->cArgs */ dispparams.cNamedArgs = 1; hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); ITypeInfo_Release(pTypeInfo); hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IDispatch, &pTypeInfo); ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid); hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszGetTypeInfo, 1, &dispidMember); ok_ole_success(hr, ITypeInfo_GetIDsOfNames); /* test invoking a method with a [restricted] keyword */ hr = ITypeInfo_Invoke(pTypeInfo, NULL, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); todo_wine { ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); } ITypeInfo_Release(pTypeInfo); ITypeLib_Release(pTypeLib); }
static void do_enum(void) { HRESULT hr; REFCLSID rclsid = &CLSID_StdComponentCategoriesMgr; ICatInformation *pICat = (ICatInformation*)0xdeadbeef; GUID the_guid[1]; GUID the_cat[1]; GUID wanted_guid; ULONG fetched = -1; static WCHAR szCatID[] = { '{', 'd','e','a','d','c','a','f','e', '-','0','0','0','0','-','0','0','0','0', '-','0','0','0','0', '-','0','0','0','0','0','0','0','0','0','0','0','0', '}',0 }; static WCHAR szGuid[] = { '{', 'd','e','a','d','c','a','f','e','-', 'b','e','e','d','-', 'b','e','a','d','-', 'd','e','a','d','-', 'c','a','f','e','b','e','a','d','d','e','a','d', '}',0 }; IEnumCLSID *pIEnum =(IEnumCLSID*)0xdeadcafe; CLSIDFromString(szCatID,the_cat); CLSIDFromString(szGuid,&wanted_guid); OleInitialize(NULL); hr = CoCreateInstance(rclsid,NULL,CLSCTX_INPROC_SERVER, &IID_ICatInformation, (void **)&pICat); ok_ole_success(hr, "CoCreateInstance"); hr = ICatInformation_EnumClassesOfCategories(pICat, -1, NULL, -1, NULL, &pIEnum); ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories"); IEnumGUID_Release(pIEnum); hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL, &pIEnum); ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories"); hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched); ok (fetched == 0,"Fetched wrong number of guids %u\n",fetched); IEnumGUID_Release(pIEnum); if (register_testentry()) { hr = ICatInformation_EnumClassesOfCategories(pICat, 1, the_cat, -1, NULL, &pIEnum); ok_ole_success(hr,"ICatInformation_EnumClassesOfCategories"); hr = IEnumGUID_Next(pIEnum,1,the_guid, &fetched); ok (fetched == 1,"Fetched wrong number of guids %u\n",fetched); ok (IsEqualGUID(the_guid,&wanted_guid),"Guids do not match\n"); IEnumGUID_Release(pIEnum); unregister_testentry(); } else skip( "Could not register the test category\n" ); ICatInformation_Release(pICat); OleUninitialize(); }
static void test_Invoke(void) { IPictureDisp *picdisp; HRESULT hr; VARIANTARG vararg; DISPPARAMS dispparams; VARIANT varresult; IStream *stream; HGLOBAL hglob; void *data; hglob = GlobalAlloc (0, sizeof(gifimage)); data = GlobalLock(hglob); memcpy(data, gifimage, sizeof(gifimage)); GlobalUnlock(hglob); hr = CreateStreamOnHGlobal (hglob, FALSE, &stream); ok_ole_success(hr, "CreateStreamOnHGlobal"); hr = pOleLoadPicture(stream, sizeof(gifimage), TRUE, &IID_IPictureDisp, (void **)&picdisp); IStream_Release(stream); ok_ole_success(hr, "OleLoadPicture"); V_VT(&vararg) = VT_BOOL; V_BOOL(&vararg) = VARIANT_FALSE; dispparams.cNamedArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IPictureDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_IUnknown, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_UNKNOWNNAME, "IPictureDisp_Invoke should have returned DISP_E_UNKNOWNNAME instead of 0x%08lx\n", hr); dispparams.cArgs = 0; dispparams.rgvarg = NULL; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL); ok(hr == DISP_E_PARAMNOTOPTIONAL, "IPictureDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok_ole_success(hr, "IPictureDisp_Invoke"); ok(V_VT(&varresult) == VT_I4, "V_VT(&varresult) should have been VT_UINT instead of %d\n", V_VT(&varresult)); hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_METHOD, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr); hr = IPictureDisp_Invoke(picdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "IPictureDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08lx\n", hr); dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); dispparams.cArgs = 1; dispparams.rgvarg = &vararg; hr = IPictureDisp_Invoke(picdisp, DISPID_PICT_HPAL, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL); ok(hr == DISP_E_BADPARAMCOUNT, "IPictureDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08lx\n", hr); IPictureDisp_Release(picdisp); }
static void test_streamonhglobal(IStream *pStream) { const char data[] = "Test String"; ULARGE_INTEGER ull; LARGE_INTEGER ll; char buffer[128]; ULONG read; STATSTG statstg; HRESULT hr; ull.QuadPart = sizeof(data); hr = IStream_SetSize(pStream, ull); ok_ole_success(hr, "IStream_SetSize"); hr = IStream_Write(pStream, data, sizeof(data), NULL); ok_ole_success(hr, "IStream_Write"); ll.QuadPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, NULL); ok_ole_success(hr, "IStream_Seek"); /* should return S_OK, not S_FALSE */ hr = IStream_Read(pStream, buffer, sizeof(buffer), &read); ok_ole_success(hr, "IStream_Read"); ok(read == sizeof(data), "IStream_Read returned read %d\n", read); /* ignores HighPart */ ull.u.HighPart = -1; ull.u.LowPart = 0; hr = IStream_SetSize(pStream, ull); ok_ole_success(hr, "IStream_SetSize"); /* IStream_Seek -- NULL position argument */ ll.u.HighPart = 0; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, NULL); ok_ole_success(hr, "IStream_Seek"); /* IStream_Seek -- valid position argument (seek from current position) */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- invalid seek argument */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 123; hr = IStream_Seek(pStream, ll, STREAM_SEEK_END+1, &ull); ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should not have changed HighPart, got %d\n", ull.u.HighPart); /* IStream_Seek -- valid position argument (seek to beginning) */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- valid position argument (seek to end) */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_END, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- ignore HighPart in the move value (seek from current position) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = -1; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- ignore HighPart in the move value (seek to beginning) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = -1; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- invalid LowPart value (seek before start of stream) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x80000000; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- valid LowPart value (seek to start of stream) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = -(DWORD)sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0, "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- invalid LowPart value (seek to start of stream-1) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = -(DWORD)sizeof(data)-1; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- valid LowPart value (seek forward to 0x80000000) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x80000000 - sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0x80000000, "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- invalid LowPart value (seek to beginning) */ ll.u.HighPart = 0; ll.u.LowPart = sizeof(data); hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x80000000; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr); ok(ull.u.LowPart == sizeof(data), "LowPart set to %d\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- valid LowPart value (seek to beginning) */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x7FFFFFFF; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- valid LowPart value (seek from current position) */ ll.u.HighPart = 0; ll.u.LowPart = 0; hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull); ok_ole_success(hr, "IStream_Seek"); ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x7FFFFFFF; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0x7FFFFFFF, "should have set LowPart to 0x7FFFFFFF instead of %08x\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- second seek allows you to go past 0x7FFFFFFF size */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 9; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0x80000008, "should have set LowPart to 0x80000008 instead of %08x\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); /* IStream_Seek -- seek wraps position/size on integer overflow */ ull.u.HighPart = 0xCAFECAFE; ull.u.LowPart = 0xCAFECAFE; ll.u.HighPart = 0; ll.u.LowPart = 0x7FFFFFFF; hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull); ok_ole_success(hr, "IStream_Seek"); ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart); ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart); hr = IStream_Commit(pStream, STGC_DEFAULT); ok_ole_success(hr, "IStream_Commit"); hr = IStream_Revert(pStream); ok_ole_success(hr, "IStream_Revert"); hr = IStream_LockRegion(pStream, ull, ull, LOCK_WRITE); ok(hr == STG_E_INVALIDFUNCTION, "IStream_LockRegion should have returned STG_E_INVALIDFUNCTION instead of 0x%08x\n", hr); hr = IStream_Stat(pStream, &statstg, STATFLAG_DEFAULT); ok_ole_success(hr, "IStream_Stat"); ok(statstg.type == STGTY_STREAM, "statstg.type should have been STGTY_STREAM instead of %d\n", statstg.type); /* test OOM condition */ ull.u.HighPart = -1; ull.u.LowPart = -1; hr = IStream_SetSize(pStream, ull); ok(hr == E_OUTOFMEMORY || broken(hr == S_OK), /* win9x */ "IStream_SetSize with large size should have returned E_OUTOFMEMORY instead of 0x%08x\n", hr); }