static HRESULT WINAPI IDataObject_fnQueryInterface(IDataObject* iface, REFIID riid, LPVOID *ppvObj) { HlinkImpl *This = impl_from_IDataObject(iface); TRACE("%p\n", This); return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj); }
static HRESULT WINAPI IPersistStream_fnQueryInterface(IPersistStream* iface, REFIID riid, LPVOID *ppvObj) { HlinkImpl *This = impl_from_IPersistStream(iface); TRACE("(%p)\n", This); return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj); }
static void test_persist_save_data(const char *testname, IHlink *lnk, const unsigned char *expected_data, unsigned int expected_data_size, const unsigned char *expected_data_alt, unsigned int expected_data_alt_size) { HRESULT hr; IStream *stream; IPersistStream *ps; HGLOBAL hglobal; DWORD data_size; const unsigned char *data; DWORD i; BOOL same; unsigned int expected_data_win9x_size = 0; hr = IHlink_QueryInterface(lnk, &IID_IPersistStream, (void **)&ps); ok(hr == S_OK, "IHlink_QueryInterface failed with error 0x%08x\n", hr); hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok(hr == S_OK, "CreateStreamOnHGlobal failed with error 0x%08x\n", hr); hr = IPersistStream_Save(ps, stream, TRUE); ok(hr == S_OK, "IPersistStream_Save failed with error 0x%08x\n", hr); hr = GetHGlobalFromStream(stream, &hglobal); ok(hr == S_OK, "GetHGlobalFromStream failed with error 0x%08x\n", hr); data_size = GlobalSize(hglobal); data = GlobalLock(hglobal); if (expected_data_size % 4) expected_data_win9x_size = 4 * ((expected_data_size / 4) + 1); /* first check we have the right amount of data */ ok((data_size == expected_data_size) || (data_size == expected_data_alt_size) || broken(data_size == expected_data_win9x_size), /* Win9x and WinMe */ "%s: Size of saved data differs (expected %d or %d, actual %d)\n", testname, expected_data_size, expected_data_alt_size, data_size); same = TRUE; /* then do a byte-by-byte comparison */ for (i = 0; i < min(data_size, expected_data_size); i++) { if ((expected_data[i] != data[i]) && (((expected_data != expected_hlink_data2) && (expected_data != expected_hlink_data3)) || ((i < 52 || i >= 56) && (i < 80 || i >= 84)))) { same = FALSE; break; } } if (!same && (expected_data_alt != expected_data)) { /* then try the alternate data */ same = TRUE; for (i = 0; i < min(data_size, expected_data_alt_size); i++) { if ((expected_data_alt[i] != data[i]) && (((expected_data_alt != expected_hlink_data2) && (expected_data_alt != expected_hlink_data3)) || ((i < 52 || i >= 56) && (i < 80 || i >= 84)))) { same = FALSE; break; } } } ok(same, "%s: Saved data differs\n", testname); if (!same) { for (i = 0; i < data_size; i++) { if (i % 8 == 0) printf(" "); printf("0x%02x,", data[i]); if (i % 8 == 7) printf("\n"); } printf("\n"); } GlobalUnlock(hglobal); IStream_Release(stream); IPersistStream_Release(ps); }