1 /*
2 * ITypeLib and ITypeInfo test
3 *
4 * Copyright 2004 Jacek Caban
5 * Copyright 2006,2015 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22 #define NONAMELESSSTRUCT
23 #define NONAMELESSUNION
24
25 #define COBJMACROS
26 #define CONST_VTABLE
27
28 #include <wine/test.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <assert.h>
32
33 #include "windef.h"
34 #include "winbase.h"
35 #include "objbase.h"
36 #include "oleauto.h"
37 #include "ocidl.h"
38 #include "shlwapi.h"
39 #include "tmarshal.h"
40 #include "olectl.h"
41
42 #include "test_reg.h"
43 #include "test_tlb.h"
44
45 #define expect_eq(expr, value, type, format) { type _ret = (expr); ok((value) == _ret, #expr " expected " format " got " format "\n", value, _ret); }
46 #define expect_int(expr, value) expect_eq(expr, (int)(value), int, "%d")
47 #define expect_hex(expr, value) expect_eq(expr, (int)(value), int, "0x%x")
48 #define expect_null(expr) expect_eq(expr, NULL, const void *, "%p")
49 #define expect_guid(expected, guid) { ok(IsEqualGUID(expected, guid), "got wrong guid %s\n", wine_dbgstr_guid(guid)); }
50
51 #define expect_wstr_acpval(expr, value) \
52 { \
53 CHAR buf[260]; \
54 expect_eq(!WideCharToMultiByte(CP_ACP, 0, (expr), -1, buf, 260, NULL, NULL), 0, int, "%d"); \
55 ok(strcmp(value, buf) == 0, #expr " expected \"%s\" got \"%s\"\n", value, buf); \
56 }
57
58 #define ole_expect(expr, expect) { \
59 HRESULT r = expr; \
60 ok(r == (expect), #expr " returned %x, expected %s (%x)\n", r, #expect, expect); \
61 }
62
63 #define ole_check(expr) ole_expect(expr, S_OK);
64
65 #define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08x\n", hr)
66
67 #ifdef __i386__
68 #define ARCH "x86"
69 #elif defined __x86_64__
70 #define ARCH "amd64"
71 #elif defined __arm__
72 #define ARCH "arm"
73 #elif defined __aarch64__
74 #define ARCH "arm64"
75 #else
76 #define ARCH "none"
77 #endif
78
79 static HRESULT (WINAPI *pRegisterTypeLibForUser)(ITypeLib*,OLECHAR*,OLECHAR*);
80 static HRESULT (WINAPI *pUnRegisterTypeLibForUser)(REFGUID,WORD,WORD,LCID,SYSKIND);
81
82 static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
83 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
84 static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
85 static VOID (WINAPI *pReleaseActCtx)(HANDLE);
86 static BOOL (WINAPI *pIsWow64Process)(HANDLE,LPBOOL);
87 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY,LPCWSTR,REGSAM,DWORD);
88
89 static const WCHAR wszStdOle2[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
90 static WCHAR wszGUID[] = {'G','U','I','D',0};
91 static WCHAR wszguid[] = {'g','u','i','d',0};
92
93 static const BOOL is_win64 = sizeof(void *) > sizeof(int);
94
95 #ifdef __i386__
96 static const BOOL abi_supports_stdcall = TRUE;
97 #else
98 static const BOOL abi_supports_stdcall = FALSE;
99 #endif
100
collection_QueryInterface(ICollection * iface,REFIID riid,void ** ret)101 static HRESULT WINAPI collection_QueryInterface(ICollection *iface, REFIID riid, void **ret)
102 {
103 if (IsEqualIID(riid, &IID_IUnknown) ||
104 IsEqualIID(riid, &IID_IDispatch) ||
105 IsEqualIID(riid, &IID_ICollection))
106 {
107 *ret = iface;
108 return S_OK;
109 }
110
111 return E_NOINTERFACE;
112 }
113
collection_AddRef(ICollection * iface)114 static ULONG WINAPI collection_AddRef(ICollection *iface)
115 {
116 return 2;
117 }
118
collection_Release(ICollection * iface)119 static ULONG WINAPI collection_Release(ICollection *iface)
120 {
121 return 1;
122 }
123
collection_GetTypeInfoCount(ICollection * iface,UINT * cnt)124 static HRESULT WINAPI collection_GetTypeInfoCount(ICollection *iface, UINT *cnt)
125 {
126 ok(0, "unexpected call\n");
127 *cnt = 0;
128 return E_NOTIMPL;
129 }
130
collection_GetTypeInfo(ICollection * iface,UINT index,LCID lcid,ITypeInfo ** ti)131 static HRESULT WINAPI collection_GetTypeInfo(ICollection *iface, UINT index, LCID lcid, ITypeInfo **ti)
132 {
133 ok(0, "unexpected call\n");
134 return E_NOTIMPL;
135 }
136
collection_GetIDsOfNames(ICollection * iface,REFIID riid,LPOLESTR * names,UINT cnt,LCID lcid,DISPID * dispid)137 static HRESULT WINAPI collection_GetIDsOfNames(ICollection *iface, REFIID riid, LPOLESTR *names,
138 UINT cnt, LCID lcid, DISPID *dispid)
139 {
140 ok(0, "unexpected call\n");
141 return E_NOTIMPL;
142 }
143
collection_Invoke(ICollection * iface,DISPID dispid,REFIID riid,LCID lcid,WORD flags,DISPPARAMS * dispparams,VARIANT * res,EXCEPINFO * ei,UINT * argerr)144 static HRESULT WINAPI collection_Invoke(ICollection *iface, DISPID dispid, REFIID riid,
145 LCID lcid, WORD flags, DISPPARAMS *dispparams, VARIANT *res, EXCEPINFO *ei, UINT *argerr)
146 {
147 if(dispid != DISPID_VALUE) {
148 ok(0, "unexpected call\n");
149 return E_NOTIMPL;
150 }
151
152 ok(flags == (DISPATCH_METHOD|DISPATCH_PROPERTYGET), "flags = %x\n", flags);
153 ok(dispparams != NULL, "dispparams == NULL\n");
154 ok(!dispparams->rgdispidNamedArgs, "dispparams->rgdispidNamedArgs != NULL\n");
155 ok(dispparams->cArgs == 1, "dispparams->cArgs = %d\n", dispparams->cArgs);
156 ok(!dispparams->cNamedArgs, "dispparams->cNamedArgs = %d\n", dispparams->cNamedArgs);
157 ok(V_VT(dispparams->rgvarg) == VT_I4, "V_VT(dispparams->rgvarg) = %d\n", V_VT(dispparams->rgvarg));
158 ok(V_I4(dispparams->rgvarg) == 7, "V_I4(dispparams->rgvarg) = %d\n", V_I4(dispparams->rgvarg));
159 ok(res != NULL, "res == NULL\n");
160 ok(V_VT(res) == VT_EMPTY, "V_VT(res) = %d\n", V_VT(res));
161
162 V_VT(res) = VT_I4;
163 V_I4(res) = 15;
164 return S_OK;
165 }
166
collection_Item(ICollection * iface,int i,int * p)167 static HRESULT WINAPI collection_Item(ICollection *iface, int i, int *p)
168 {
169 ok(0, "unexpected call\n");
170 return E_NOTIMPL;
171 }
172
173 static const ICollectionVtbl collectionvtbl = {
174 collection_QueryInterface,
175 collection_AddRef,
176 collection_Release,
177 collection_GetTypeInfoCount,
178 collection_GetTypeInfo,
179 collection_GetIDsOfNames,
180 collection_Invoke,
181 collection_Item
182 };
183
184 static ICollection collection = { &collectionvtbl };
185
invoketest_QueryInterface(IInvokeTest * iface,REFIID riid,void ** ret)186 static HRESULT WINAPI invoketest_QueryInterface(IInvokeTest *iface, REFIID riid, void **ret)
187 {
188 if (IsEqualIID(riid, &IID_IUnknown) ||
189 IsEqualIID(riid, &IID_IDispatch) ||
190 IsEqualIID(riid, &IID_IInvokeTest))
191 {
192 *ret = iface;
193 return S_OK;
194 }
195
196 return E_NOINTERFACE;
197 }
198
invoketest_AddRef(IInvokeTest * iface)199 static ULONG WINAPI invoketest_AddRef(IInvokeTest *iface)
200 {
201 return 2;
202 }
203
invoketest_Release(IInvokeTest * iface)204 static ULONG WINAPI invoketest_Release(IInvokeTest *iface)
205 {
206 return 1;
207 }
208
invoketest_GetTypeInfoCount(IInvokeTest * iface,UINT * cnt)209 static HRESULT WINAPI invoketest_GetTypeInfoCount(IInvokeTest *iface, UINT *cnt)
210 {
211 ok(0, "unexpected call\n");
212 *cnt = 0;
213 return E_NOTIMPL;
214 }
215
invoketest_GetTypeInfo(IInvokeTest * iface,UINT index,LCID lcid,ITypeInfo ** ti)216 static HRESULT WINAPI invoketest_GetTypeInfo(IInvokeTest *iface, UINT index, LCID lcid, ITypeInfo **ti)
217 {
218 ok(0, "unexpected call\n");
219 return E_NOTIMPL;
220 }
221
invoketest_GetIDsOfNames(IInvokeTest * iface,REFIID riid,LPOLESTR * names,UINT cnt,LCID lcid,DISPID * dispid)222 static HRESULT WINAPI invoketest_GetIDsOfNames(IInvokeTest *iface, REFIID riid, LPOLESTR *names,
223 UINT cnt, LCID lcid, DISPID *dispid)
224 {
225 ok(0, "unexpected call\n");
226 return E_NOTIMPL;
227 }
228
invoketest_Invoke(IInvokeTest * iface,DISPID dispid,REFIID riid,LCID lcid,WORD flags,DISPPARAMS * dispparams,VARIANT * res,EXCEPINFO * ei,UINT * argerr)229 static HRESULT WINAPI invoketest_Invoke(IInvokeTest *iface, DISPID dispid, REFIID riid,
230 LCID lcid, WORD flags, DISPPARAMS *dispparams, VARIANT *res, EXCEPINFO *ei, UINT *argerr)
231 {
232 ok(0, "unexpected call\n");
233 return E_NOTIMPL;
234 }
235
invoketest_get_test(IInvokeTest * iface,LONG i)236 static LONG WINAPI invoketest_get_test(IInvokeTest *iface, LONG i)
237 {
238 return i+1;
239 }
240
invoketest_putref_testprop(IInvokeTest * iface,LONG * i)241 static LONG WINAPI invoketest_putref_testprop(IInvokeTest *iface, LONG *i)
242 {
243 return *i+2;
244 }
245
invoketest_putref_testprop2(IInvokeTest * iface,IUnknown * i)246 static LONG WINAPI invoketest_putref_testprop2(IInvokeTest *iface, IUnknown *i)
247 {
248 return 6;
249 }
250
invoketest_testfunc(IInvokeTest * iface,int i,int * p)251 static HRESULT WINAPI invoketest_testfunc(IInvokeTest *iface, int i, int *p)
252 {
253 *p = i+1;
254 return S_OK;
255 }
256
invoketest_testget(IInvokeTest * iface,ICollection ** p)257 static HRESULT WINAPI invoketest_testget(IInvokeTest *iface, ICollection **p)
258 {
259 *p = &collection;
260 ICollection_AddRef(&collection);
261 return S_OK;
262 }
263
264 static const IInvokeTestVtbl invoketestvtbl = {
265 invoketest_QueryInterface,
266 invoketest_AddRef,
267 invoketest_Release,
268 invoketest_GetTypeInfoCount,
269 invoketest_GetTypeInfo,
270 invoketest_GetIDsOfNames,
271 invoketest_Invoke,
272 invoketest_get_test,
273 invoketest_putref_testprop,
274 invoketest_putref_testprop2,
275 invoketest_testfunc,
276 invoketest_testget
277 };
278
279 static IInvokeTest invoketest = { &invoketestvtbl };
280
init_function_pointers(void)281 static void init_function_pointers(void)
282 {
283 HMODULE hmod = GetModuleHandleA("oleaut32.dll");
284 HMODULE hk32 = GetModuleHandleA("kernel32.dll");
285 HMODULE hadv = GetModuleHandleA("advapi32.dll");
286
287 pRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "RegisterTypeLibForUser");
288 pUnRegisterTypeLibForUser = (void *)GetProcAddress(hmod, "UnRegisterTypeLibForUser");
289 pActivateActCtx = (void *)GetProcAddress(hk32, "ActivateActCtx");
290 pCreateActCtxW = (void *)GetProcAddress(hk32, "CreateActCtxW");
291 pDeactivateActCtx = (void *)GetProcAddress(hk32, "DeactivateActCtx");
292 pReleaseActCtx = (void *)GetProcAddress(hk32, "ReleaseActCtx");
293 pIsWow64Process = (void *)GetProcAddress(hk32, "IsWow64Process");
294 pRegDeleteKeyExW = (void*)GetProcAddress(hadv, "RegDeleteKeyExW");
295 }
296
ref_count_test(LPCWSTR type_lib)297 static void ref_count_test(LPCWSTR type_lib)
298 {
299 ITypeLib *iface;
300 ITypeInfo *iti1, *iti2;
301 HRESULT hRes;
302 int ref_count;
303
304 trace("Loading type library\n");
305 hRes = LoadTypeLib(type_lib, &iface);
306 ok(hRes == S_OK, "Could not load type library\n");
307 if(hRes != S_OK)
308 return;
309
310 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti1);
311 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
312 ref_count = ITypeLib_Release(iface);
313 ok(ref_count > 0, "ITypeLib destroyed while ITypeInfo has back pointer\n");
314 if(!ref_count)
315 return;
316
317 hRes = ITypeLib_GetTypeInfo(iface, 1, &iti2);
318 ok(hRes == S_OK, "ITypeLib_GetTypeInfo failed on index = 1\n");
319 ok(iti1 == iti2, "ITypeLib_GetTypeInfo returned different pointers for same indexes\n");
320
321 ITypeLib_AddRef(iface);
322 ITypeInfo_Release(iti2);
323 ITypeInfo_Release(iti1);
324 ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
325 }
326
test_TypeComp(void)327 static void test_TypeComp(void)
328 {
329 ITypeComp *pTypeComp, *tcomp, *pTypeComp_tmp;
330 ITypeInfo *pTypeInfo, *ti, *pFontTypeInfo;
331 ITypeLib *pTypeLib;
332 HRESULT hr;
333 ULONG ulHash;
334 DESCKIND desckind;
335 BINDPTR bindptr;
336 static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
337 static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
338 static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
339 static WCHAR wszUnchecked[] = {'U','n','c','h','e','c','k','e','d',0};
340 static WCHAR wszIUnknown[] = {'I','U','n','k','n','o','w','n',0};
341 static WCHAR wszFont[] = {'F','o','n','t',0};
342 static WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
343 static WCHAR wszOLE_COLOR[] = {'O','L','E','_','C','O','L','O','R',0};
344 static WCHAR wszClone[] = {'C','l','o','n','e',0};
345 static WCHAR wszclone[] = {'c','l','o','n','e',0};
346 static WCHAR wszJunk[] = {'J','u','n','k',0};
347 static WCHAR wszAddRef[] = {'A','d','d','R','e','f',0};
348
349 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
350 ok_ole_success(hr, LoadTypeLib);
351
352 hr = ITypeLib_GetTypeComp(pTypeLib, &pTypeComp);
353 ok_ole_success(hr, ITypeLib_GetTypeComp);
354
355 /* test getting a TKIND_MODULE */
356 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
357 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
358 ok_ole_success(hr, ITypeComp_Bind);
359
360 ok(desckind == DESCKIND_TYPECOMP,
361 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
362 desckind);
363 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
364
365 ITypeComp_Release(bindptr.lptcomp);
366
367 /* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */
368 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
369 hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
370 ok_ole_success(hr, ITypeComp_Bind);
371
372 ok(desckind == DESCKIND_TYPECOMP,
373 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
374 desckind);
375 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
376 ITypeComp_Release(bindptr.lptcomp);
377
378 /* test getting a function within a TKIND_MODULE */
379 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
380 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
381 ok_ole_success(hr, ITypeComp_Bind);
382
383 ok(desckind == DESCKIND_FUNCDESC,
384 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
385 desckind);
386 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
387 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
388 ITypeInfo_Release(pTypeInfo);
389
390 /* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */
391 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
392 hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
393 ok(hr == TYPE_E_TYPEMISMATCH,
394 "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n",
395 hr);
396
397 ok(desckind == DESCKIND_NONE,
398 "desckind should have been DESCKIND_NONE instead of %d\n",
399 desckind);
400 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
401 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
402
403 /* test getting a TKIND_ENUM */
404 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_TRISTATE);
405 hr = ITypeComp_Bind(pTypeComp, wszOLE_TRISTATE, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
406 ok_ole_success(hr, ITypeComp_Bind);
407
408 ok(desckind == DESCKIND_TYPECOMP,
409 "desckind should have been DESCKIND_TYPECOMP instead of %d\n",
410 desckind);
411 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
412
413 ITypeComp_Release(bindptr.lptcomp);
414
415 /* test getting a value within a TKIND_ENUM */
416 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszUnchecked);
417 hr = ITypeComp_Bind(pTypeComp, wszUnchecked, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
418 ok_ole_success(hr, ITypeComp_Bind);
419
420 ok(desckind == DESCKIND_VARDESC,
421 "desckind should have been DESCKIND_VARDESC instead of %d\n",
422 desckind);
423 ITypeInfo_ReleaseVarDesc(pTypeInfo, bindptr.lpvardesc);
424 ITypeInfo_Release(pTypeInfo);
425
426 /* test getting a TKIND_INTERFACE */
427 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszIUnknown);
428 hr = ITypeComp_Bind(pTypeComp, wszIUnknown, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
429 ok_ole_success(hr, ITypeComp_Bind);
430
431 ok(desckind == DESCKIND_NONE,
432 "desckind should have been DESCKIND_NONE instead of %d\n",
433 desckind);
434 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
435 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
436
437 /* test getting a TKIND_DISPATCH */
438 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszFont);
439 hr = ITypeComp_Bind(pTypeComp, wszFont, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
440 ok_ole_success(hr, ITypeComp_Bind);
441
442 ok(desckind == DESCKIND_NONE,
443 "desckind should have been DESCKIND_NONE instead of %d\n",
444 desckind);
445 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
446 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
447
448 /* test getting a TKIND_RECORD/TKIND_ALIAS */
449 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
450 hr = ITypeComp_Bind(pTypeComp, wszGUID, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
451 ok_ole_success(hr, ITypeComp_Bind);
452
453 ok(desckind == DESCKIND_NONE,
454 "desckind should have been DESCKIND_NONE instead of %d\n",
455 desckind);
456 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
457 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
458
459 /* test getting a TKIND_ALIAS */
460 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_COLOR);
461 hr = ITypeComp_Bind(pTypeComp, wszOLE_COLOR, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
462 ok_ole_success(hr, ITypeComp_Bind);
463
464 ok(desckind == DESCKIND_NONE,
465 "desckind should have been DESCKIND_NONE instead of %d\n",
466 desckind);
467 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
468 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
469
470 /* test getting a TKIND_COCLASS */
471 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdPicture);
472 hr = ITypeComp_Bind(pTypeComp, wszStdPicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
473 ok_ole_success(hr, ITypeComp_Bind);
474
475 ok(desckind == DESCKIND_NONE,
476 "desckind should have been DESCKIND_NONE instead of %d\n",
477 desckind);
478 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
479 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
480
481 /* test basic BindType argument handling */
482 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
483 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, NULL);
484 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
485
486 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
487 pTypeInfo = (void*)0xdeadbeef;
488 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, NULL);
489 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
490 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
491
492 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
493 pTypeComp_tmp = (void*)0xdeadbeef;
494 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, NULL, &pTypeComp_tmp);
495 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
496 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
497
498 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
499 pTypeComp_tmp = (void*)0xdeadbeef;
500 pTypeInfo = (void*)0xdeadbeef;
501 hr = ITypeComp_BindType(pTypeComp, NULL, ulHash, &pTypeInfo, &pTypeComp_tmp);
502 ok(hr == E_INVALIDARG, "Got %08x\n", hr);
503 ok(pTypeInfo == (void*)0xdeadbeef, "Got %p\n", pTypeInfo);
504 ok(pTypeComp_tmp == (void*)0xdeadbeef, "Got %p\n", pTypeComp_tmp);
505
506 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
507 pTypeComp_tmp = (void*)0xdeadbeef;
508 pTypeInfo = (void*)0xdeadbeef;
509 hr = ITypeComp_BindType(pTypeComp, wszGUID, ulHash, &pTypeInfo, &pTypeComp_tmp);
510 ok_ole_success(hr, ITypeComp_BindType);
511 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
512 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
513 ITypeInfo_Release(pTypeInfo);
514 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
515
516 /* test BindType case-insensitivity */
517 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszguid);
518 pTypeComp_tmp = (void*)0xdeadbeef;
519 pTypeInfo = (void*)0xdeadbeef;
520 hr = ITypeComp_BindType(pTypeComp, wszguid, ulHash, &pTypeInfo, &pTypeComp_tmp);
521 ok_ole_success(hr, ITypeComp_BindType);
522 ok(pTypeInfo != NULL, "Got NULL pTypeInfo\n");
523 todo_wine ok(pTypeComp_tmp == NULL, "Got pTypeComp_tmp %p\n", pTypeComp_tmp);
524 ITypeInfo_Release(pTypeInfo);
525 if(pTypeComp_tmp) ITypeComp_Release(pTypeComp_tmp); /* fixme */
526
527 ITypeComp_Release(pTypeComp);
528
529 /* tests for ITypeComp on an interface */
530 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pFontTypeInfo);
531 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
532
533 hr = ITypeInfo_GetTypeComp(pFontTypeInfo, &pTypeComp);
534 ok_ole_success(hr, ITypeLib_GetTypeComp);
535
536 hr = ITypeInfo_QueryInterface(pFontTypeInfo, &IID_ITypeComp, (void**)&tcomp);
537 ok(hr == S_OK, "got %08x\n", hr);
538 ok(tcomp == pTypeComp, "got %p, was %p\n", tcomp, pTypeComp);
539
540 hr = ITypeComp_QueryInterface(tcomp, &IID_ITypeInfo, (void**)&ti);
541 ok(hr == S_OK, "got %08x\n", hr);
542 ok(ti == pFontTypeInfo, "got %p, was %p\n", ti, pFontTypeInfo);
543 ITypeInfo_Release(ti);
544
545 ITypeComp_Release(tcomp);
546
547 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
548 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
549 ok_ole_success(hr, ITypeComp_Bind);
550
551 ok(desckind == DESCKIND_FUNCDESC,
552 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
553 desckind);
554 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
555 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
556 ITypeInfo_Release(pTypeInfo);
557
558 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszClone);
559 hr = ITypeComp_Bind(pTypeComp, wszClone, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
560 ok(hr == TYPE_E_TYPEMISMATCH, "ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08x\n", hr);
561
562 ok(desckind == DESCKIND_NONE,
563 "desckind should have been DESCKIND_NONE instead of %d\n",
564 desckind);
565 ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
566 ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
567
568 /* tests that the compare is case-insensitive */
569 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszclone);
570 hr = ITypeComp_Bind(pTypeComp, wszclone, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
571 ok_ole_success(hr, ITypeComp_Bind);
572
573 ok(desckind == DESCKIND_FUNCDESC,
574 "desckind should have been DESCKIND_FUNCDESC instead of %d\n",
575 desckind);
576 ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
577 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
578 ITypeInfo_Release(pTypeInfo);
579
580 /* tests nonexistent members */
581 desckind = 0xdeadbeef;
582 bindptr.lptcomp = (ITypeComp*)0xdeadbeef;
583 pTypeInfo = (ITypeInfo*)0xdeadbeef;
584 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszJunk);
585 hr = ITypeComp_Bind(pTypeComp, wszJunk, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
586 ok_ole_success(hr, ITypeComp_Bind);
587 ok(desckind == DESCKIND_NONE, "desckind should have been DESCKIND_NONE, was: %d\n", desckind);
588 ok(pTypeInfo == NULL, "pTypeInfo should have been NULL, was: %p\n", pTypeInfo);
589 ok(bindptr.lptcomp == NULL, "bindptr should have been NULL, was: %p\n", bindptr.lptcomp);
590
591 /* tests inherited members */
592 desckind = 0xdeadbeef;
593 bindptr.lpfuncdesc = NULL;
594 pTypeInfo = NULL;
595 ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszAddRef);
596 hr = ITypeComp_Bind(pTypeComp, wszAddRef, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
597 ok_ole_success(hr, ITypeComp_Bind);
598 ok(desckind == DESCKIND_FUNCDESC, "desckind should have been DESCKIND_FUNCDESC, was: %d\n", desckind);
599 ok(pTypeInfo != NULL, "pTypeInfo should not have been NULL, was: %p\n", pTypeInfo);
600 ok(bindptr.lpfuncdesc != NULL, "bindptr should not have been NULL, was: %p\n", bindptr.lpfuncdesc);
601 ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
602 ITypeInfo_Release(pTypeInfo);
603
604 ITypeComp_Release(pTypeComp);
605 ITypeInfo_Release(pFontTypeInfo);
606 ITypeLib_Release(pTypeLib);
607 }
608
test_CreateDispTypeInfo(void)609 static void test_CreateDispTypeInfo(void)
610 {
611 ITypeInfo *pTypeInfo, *pTI2;
612 HRESULT hr;
613 INTERFACEDATA ifdata;
614 METHODDATA methdata[4];
615 PARAMDATA parms1[2];
616 PARAMDATA parms3[1];
617 TYPEATTR *pTypeAttr;
618 HREFTYPE href;
619 FUNCDESC *pFuncDesc;
620 MEMBERID memid;
621
622 static WCHAR func1[] = {'f','u','n','c','1',0};
623 static const WCHAR func2[] = {'f','u','n','c','2',0};
624 static const WCHAR func3[] = {'f','u','n','c','3',0};
625 static const WCHAR parm1[] = {'p','a','r','m','1',0};
626 static const WCHAR parm2[] = {'p','a','r','m','2',0};
627 OLECHAR *name = func1;
628
629 ifdata.pmethdata = methdata;
630 ifdata.cMembers = ARRAY_SIZE(methdata);
631
632 methdata[0].szName = SysAllocString(func1);
633 methdata[0].ppdata = parms1;
634 methdata[0].dispid = 0x123;
635 methdata[0].iMeth = 0;
636 methdata[0].cc = CC_STDCALL;
637 methdata[0].cArgs = 2;
638 methdata[0].wFlags = DISPATCH_METHOD;
639 methdata[0].vtReturn = VT_HRESULT;
640 parms1[0].szName = SysAllocString(parm1);
641 parms1[0].vt = VT_I4;
642 parms1[1].szName = SysAllocString(parm2);
643 parms1[1].vt = VT_BSTR;
644
645 methdata[1].szName = SysAllocString(func2);
646 methdata[1].ppdata = NULL;
647 methdata[1].dispid = 0x124;
648 methdata[1].iMeth = 1;
649 methdata[1].cc = CC_STDCALL;
650 methdata[1].cArgs = 0;
651 methdata[1].wFlags = DISPATCH_PROPERTYGET;
652 methdata[1].vtReturn = VT_I4;
653
654 methdata[2].szName = SysAllocString(func3);
655 methdata[2].ppdata = parms3;
656 methdata[2].dispid = 0x125;
657 methdata[2].iMeth = 3;
658 methdata[2].cc = CC_STDCALL;
659 methdata[2].cArgs = 1;
660 methdata[2].wFlags = DISPATCH_PROPERTYPUT;
661 methdata[2].vtReturn = VT_HRESULT;
662 parms3[0].szName = SysAllocString(parm1);
663 parms3[0].vt = VT_I4;
664
665 methdata[3].szName = SysAllocString(func3);
666 methdata[3].ppdata = NULL;
667 methdata[3].dispid = 0x125;
668 methdata[3].iMeth = 4;
669 methdata[3].cc = CC_STDCALL;
670 methdata[3].cArgs = 0;
671 methdata[3].wFlags = DISPATCH_PROPERTYGET;
672 methdata[3].vtReturn = VT_I4;
673
674 hr = CreateDispTypeInfo(&ifdata, LOCALE_NEUTRAL, &pTypeInfo);
675 ok(hr == S_OK, "hr %08x\n", hr);
676
677 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &pTypeAttr);
678 ok(hr == S_OK, "hr %08x\n", hr);
679
680 ok(pTypeAttr->typekind == TKIND_COCLASS, "typekind %0x\n", pTypeAttr->typekind);
681 ok(pTypeAttr->cImplTypes == 1, "cImplTypes %d\n", pTypeAttr->cImplTypes);
682 ok(pTypeAttr->cFuncs == 0, "cFuncs %d\n", pTypeAttr->cFuncs);
683 ok(pTypeAttr->wTypeFlags == 0, "wTypeFlags %04x\n", pTypeAttr->cFuncs);
684 ITypeInfo_ReleaseTypeAttr(pTypeInfo, pTypeAttr);
685
686 hr = ITypeInfo_GetRefTypeOfImplType(pTypeInfo, 0, &href);
687 ok(hr == S_OK, "hr %08x\n", hr);
688 ok(href == 0, "href = 0x%x\n", href);
689 hr = ITypeInfo_GetRefTypeInfo(pTypeInfo, href, &pTI2);
690 ok(hr == S_OK, "hr %08x\n", hr);
691 hr = ITypeInfo_GetTypeAttr(pTI2, &pTypeAttr);
692 ok(hr == S_OK, "hr %08x\n", hr);
693 ok(pTypeAttr->typekind == TKIND_INTERFACE, "typekind %0x\n", pTypeAttr->typekind);
694 ok(pTypeAttr->cFuncs == 4, "cFuncs %d\n", pTypeAttr->cFuncs);
695 ok(IsEqualGUID(&pTypeAttr->guid, &GUID_NULL), "guid {%08x-...}\n", pTypeAttr->guid.Data1);
696 ok(pTypeAttr->wTypeFlags == 0, "typeflags %08x\n", pTypeAttr->wTypeFlags);
697
698 ITypeInfo_ReleaseTypeAttr(pTI2, pTypeAttr);
699
700 hr = ITypeInfo_GetFuncDesc(pTI2, 0, &pFuncDesc);
701 ok(hr == S_OK, "hr %08x\n", hr);
702 ok(pFuncDesc->memid == 0x123, "memid %x\n", pFuncDesc->memid);
703 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
704 ok(pFuncDesc->invkind == methdata[0].wFlags, "invkind %d\n", pFuncDesc->invkind);
705 ok(pFuncDesc->callconv == methdata[0].cc, "callconv %d\n", pFuncDesc->callconv);
706 ok(pFuncDesc->cParams == methdata[0].cArgs, "cParams %d\n", pFuncDesc->cParams);
707 ok(pFuncDesc->oVft == 0, "oVft %d\n", pFuncDesc->oVft);
708 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
709 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
710 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
711 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
712
713 ok(pFuncDesc->lprgelemdescParam[1].tdesc.vt == VT_BSTR, "parm 1 vt %x\n", pFuncDesc->lprgelemdescParam[1].tdesc.vt);
714 ok(U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 1 flags %x\n", U(pFuncDesc->lprgelemdescParam[1]).paramdesc.wParamFlags);
715 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
716
717 hr = ITypeInfo_GetFuncDesc(pTI2, 1, &pFuncDesc);
718 ok(hr == S_OK, "hr %08x\n", hr);
719 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
720 ok(pFuncDesc->invkind == methdata[1].wFlags, "invkind %d\n", pFuncDesc->invkind);
721 ok(pFuncDesc->callconv == methdata[1].cc, "callconv %d\n", pFuncDesc->callconv);
722 ok(pFuncDesc->cParams == methdata[1].cArgs, "cParams %d\n", pFuncDesc->cParams);
723 ok(pFuncDesc->oVft == sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
724 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
725 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
726 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
727
728 hr = ITypeInfo_GetFuncDesc(pTI2, 2, &pFuncDesc);
729 ok(hr == S_OK, "hr %08x\n", hr);
730 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
731 ok(pFuncDesc->invkind == methdata[2].wFlags, "invkind %d\n", pFuncDesc->invkind);
732 ok(pFuncDesc->callconv == methdata[2].cc, "callconv %d\n", pFuncDesc->callconv);
733 ok(pFuncDesc->cParams == methdata[2].cArgs, "cParams %d\n", pFuncDesc->cParams);
734 ok(pFuncDesc->oVft == 3 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
735 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
736 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_HRESULT, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
737 ok(pFuncDesc->lprgelemdescParam[0].tdesc.vt == VT_I4, "parm 0 vt %x\n", pFuncDesc->lprgelemdescParam[0].tdesc.vt);
738 ok(U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags == PARAMFLAG_NONE, "parm 0 flags %x\n", U(pFuncDesc->lprgelemdescParam[0]).paramdesc.wParamFlags);
739 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
740
741 hr = ITypeInfo_GetFuncDesc(pTI2, 3, &pFuncDesc);
742 ok(hr == S_OK, "hr %08x\n", hr);
743 ok(pFuncDesc->funckind == FUNC_VIRTUAL, "funckind %d\n", pFuncDesc->funckind);
744 ok(pFuncDesc->invkind == methdata[3].wFlags, "invkind %d\n", pFuncDesc->invkind);
745 ok(pFuncDesc->callconv == methdata[3].cc, "callconv %d\n", pFuncDesc->callconv);
746 ok(pFuncDesc->cParams == methdata[3].cArgs, "cParams %d\n", pFuncDesc->cParams);
747 ok(pFuncDesc->oVft == 4 * sizeof(void *), "oVft %d\n", pFuncDesc->oVft);
748 ok(pFuncDesc->wFuncFlags == 0, "oVft %d\n", pFuncDesc->wFuncFlags);
749 ok(pFuncDesc->elemdescFunc.tdesc.vt == VT_I4, "ret vt %x\n", pFuncDesc->elemdescFunc.tdesc.vt);
750 ITypeInfo_ReleaseFuncDesc(pTI2, pFuncDesc);
751
752 /* test GetIDsOfNames on a coclass to see if it searches its interfaces */
753 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &name, 1, &memid);
754 ok(hr == S_OK, "hr 0x%08x\n", hr);
755 ok(memid == 0x123, "memid 0x%08x\n", memid);
756
757 ITypeInfo_Release(pTI2);
758 ITypeInfo_Release(pTypeInfo);
759
760 SysFreeString(parms1[0].szName);
761 SysFreeString(parms1[1].szName);
762 SysFreeString(parms3[0].szName);
763 SysFreeString(methdata[0].szName);
764 SysFreeString(methdata[1].szName);
765 SysFreeString(methdata[2].szName);
766 SysFreeString(methdata[3].szName);
767 }
768
write_typelib(int res_no,const char * filename)769 static void write_typelib(int res_no, const char *filename)
770 {
771 DWORD written;
772 HANDLE file;
773 HRSRC res;
774 void *ptr;
775
776 file = CreateFileA( filename, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
777 ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
778 if (file == INVALID_HANDLE_VALUE) return;
779 res = FindResourceA( GetModuleHandleA(NULL), (LPCSTR)MAKEINTRESOURCE(res_no), "TYPELIB" );
780 ok( res != 0, "couldn't find resource\n" );
781 ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
782 WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
783 ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
784 CloseHandle( file );
785 }
786
test_invoke_func(ITypeInfo * typeinfo)787 static void test_invoke_func(ITypeInfo *typeinfo)
788 {
789 DISPID named_args[3] = { DISPID_THIS };
790 VARIANT args[3], res;
791 DISPPARAMS dp = {args, named_args, 1, 0};
792 UINT i;
793 HRESULT hres;
794
795 V_VT(args) = VT_INT;
796 V_INT(args) = 3;
797 V_VT(&res) = VT_ERROR;
798 hres = ITypeInfo_Invoke(typeinfo, &invoketest, 3, DISPATCH_METHOD, &dp, &res, NULL, &i);
799 ok(hres == S_OK, "got 0x%08x\n", hres);
800 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
801 ok(V_I4(&res) == 4, "got %d\n", V_I4(&res));
802
803 V_VT(args) = VT_DISPATCH;
804 V_DISPATCH(args) = (IDispatch*)&invoketest;
805 V_VT(args+1) = VT_INT;
806 V_INT(args+1) = 3;
807 V_VT(&res) = VT_ERROR;
808 dp.cNamedArgs = 1;
809 dp.cArgs = 2;
810 hres = ITypeInfo_Invoke(typeinfo, &invoketest, 3, DISPATCH_METHOD, &dp, &res, NULL, &i);
811 ok(hres == DISP_E_BADPARAMCOUNT, "got 0x%08x\n", hres);
812 }
813
create_test_typelib(int res_no)814 static const char *create_test_typelib(int res_no)
815 {
816 static char filename[MAX_PATH];
817
818 GetTempFileNameA( ".", "tlb", 0, filename );
819 write_typelib(res_no, filename);
820 return filename;
821 }
822
test_TypeInfo(void)823 static void test_TypeInfo(void)
824 {
825 ITypeLib *pTypeLib;
826 ITypeInfo *pTypeInfo, *ti;
827 ITypeInfo2 *pTypeInfo2;
828 HRESULT hr;
829 static WCHAR wszBogus[] = { 'b','o','g','u','s',0 };
830 static WCHAR wszGetTypeInfo[] = { 'G','e','t','T','y','p','e','I','n','f','o',0 };
831 static WCHAR wszClone[] = {'C','l','o','n','e',0};
832 OLECHAR* bogus = wszBogus;
833 OLECHAR* pwszGetTypeInfo = wszGetTypeInfo;
834 OLECHAR* pwszClone = wszClone;
835 DISPID dispidMember;
836 DISPPARAMS dispparams;
837 GUID bogusguid = {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
838 VARIANT var, res, args[2];
839 UINT count, i;
840 TYPEKIND kind;
841 const char *filenameA;
842 WCHAR filename[MAX_PATH];
843 TYPEATTR *attr;
844 LONG l;
845
846 hr = LoadTypeLib(wszStdOle2, &pTypeLib);
847 ok_ole_success(hr, LoadTypeLib);
848
849 count = ITypeLib_GetTypeInfoCount(pTypeLib);
850 ok(count > 0, "got %d\n", count);
851
852 /* invalid index */
853 hr = ITypeLib_GetTypeInfo(pTypeLib, count, &pTypeInfo);
854 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
855
856 hr = ITypeLib_GetTypeInfo(pTypeLib, 0, NULL);
857 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
858
859 hr = ITypeLib_GetLibAttr(pTypeLib, NULL);
860 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
861
862 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, &kind);
863 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hr);
864
865 hr = ITypeLib_GetTypeInfoType(pTypeLib, count, NULL);
866 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
867
868 hr = ITypeLib_GetTypeInfoType(pTypeLib, 0, NULL);
869 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
870
871 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IFont, &pTypeInfo);
872 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
873
874 /* test nonexistent method name */
875 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &bogus, 1, &dispidMember);
876 ok(hr == DISP_E_UNKNOWNNAME,
877 "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n",
878 hr);
879
880 dispparams.cArgs = 0;
881 dispparams.rgdispidNamedArgs = NULL;
882 dispparams.rgvarg = NULL;
883
884 /* test dispparams not NULL */
885
886 /* invalid member id -- wrong flags -- cNamedArgs not bigger than cArgs */
887 dispparams.cNamedArgs = 0;
888 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
889 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
890 /* invalid member id -- correct flags -- cNamedArgs not bigger than cArgs */
891 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
892 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
893
894 /* invalid member id -- wrong flags -- cNamedArgs bigger than cArgs */
895 dispparams.cNamedArgs = 1;
896 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
897 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
898 /* invalid member id -- correct flags -- cNamedArgs bigger than cArgs */
899 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
900 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
901
902
903 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszClone, 1, &dispidMember);
904 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
905
906 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
907 dispparams.cNamedArgs = 0;
908 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
909 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
910 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
911 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
912 ok(hr == DISP_E_BADPARAMCOUNT, "ITypeInfo_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
913
914 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
915 dispparams.cNamedArgs = 1;
916 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
917 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
918 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
919 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
920 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
921
922 /* test NULL dispparams */
923
924 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
925 dispparams.cNamedArgs = 0;
926 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
927 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
928 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
929 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
930 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
931
932 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
933 dispparams.cNamedArgs = 1;
934 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
935 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
936 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
937 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
938 ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr);
939
940 ITypeInfo_Release(pTypeInfo);
941
942 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IDispatch, &pTypeInfo);
943 ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
944
945 hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszGetTypeInfo, 1, &dispidMember);
946 ok_ole_success(hr, ITypeInfo_GetIDsOfNames);
947
948 hr = ITypeInfo_QueryInterface(pTypeInfo, &IID_ITypeInfo2, (void**)&pTypeInfo2);
949 ok_ole_success(hr, ITypeInfo_QueryInterface);
950
951 if (SUCCEEDED(hr))
952 {
953 VariantInit(&var);
954
955 V_VT(&var) = VT_I4;
956
957 /* test unknown guid passed to GetCustData */
958 hr = ITypeInfo2_GetCustData(pTypeInfo2, &bogusguid, &var);
959 ok_ole_success(hr, ITypeInfo_GetCustData);
960 ok(V_VT(&var) == VT_EMPTY, "got %i, expected VT_EMPTY\n", V_VT(&var));
961
962 ITypeInfo2_Release(pTypeInfo2);
963
964 VariantClear(&var);
965 }
966
967 /* Check instance size for IDispatch, typelib is loaded using system SYS_WIN* kind so it always matches
968 system bitness. */
969 hr = ITypeInfo_GetTypeAttr(pTypeInfo, &attr);
970 ok(hr == S_OK, "got 0x%08x\n", hr);
971 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
972 ok(attr->typekind == TKIND_INTERFACE, "got typekind %d\n", attr->typekind);
973 ITypeInfo_ReleaseTypeAttr(pTypeInfo, attr);
974
975 /* same size check with some general interface */
976 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IEnumVARIANT, &ti);
977 ok(hr == S_OK, "got 0x%08x\n", hr);
978 hr = ITypeInfo_GetTypeAttr(ti, &attr);
979 ok(hr == S_OK, "got 0x%08x\n", hr);
980 ok(attr->cbSizeInstance == sizeof(void*), "got size %d\n", attr->cbSizeInstance);
981 ITypeInfo_ReleaseTypeAttr(ti, attr);
982 ITypeInfo_Release(ti);
983
984 /* test invoking a method with a [restricted] keyword */
985
986 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
987 dispparams.cNamedArgs = 0;
988 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
989 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
990 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
991 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
992 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
993
994 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
995 dispparams.cNamedArgs = 1;
996 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL);
997 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
998 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
999 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL);
1000 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1001
1002 /* test NULL dispparams */
1003
1004 /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */
1005 dispparams.cNamedArgs = 0;
1006 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
1007 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1008 /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */
1009 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
1010 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1011
1012 /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */
1013 dispparams.cNamedArgs = 1;
1014 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
1015 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1016 /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */
1017 hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL);
1018 ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
1019
1020 ITypeInfo_Release(pTypeInfo);
1021 ITypeLib_Release(pTypeLib);
1022
1023 filenameA = create_test_typelib(3);
1024 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH);
1025 hr = LoadTypeLib(filename, &pTypeLib);
1026 ok(hr == S_OK, "got 0x%08x\n", hr);
1027
1028 hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IInvokeTest, &pTypeInfo);
1029 ok(hr == S_OK, "got 0x%08x\n", hr);
1030
1031 dispparams.cArgs = 1;
1032 dispparams.cNamedArgs = 0;
1033 dispparams.rgdispidNamedArgs = NULL;
1034 dispparams.rgvarg = args;
1035
1036 V_VT(&args[0]) = VT_I4;
1037 V_I4(&args[0]) = 0;
1038
1039 i = 0;
1040 V_VT(&res) = VT_EMPTY;
1041 V_I4(&res) = 0;
1042 /* call propget with DISPATCH_METHOD|DISPATCH_PROPERTYGET flags */
1043 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD|DISPATCH_PROPERTYGET,
1044 &dispparams, &res, NULL, &i);
1045 ok(hr == S_OK, "got 0x%08x\n", hr);
1046 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1047 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
1048
1049 i = 0;
1050 /* call propget with DISPATCH_METHOD flags */
1051 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_METHOD,
1052 &dispparams, &res, NULL, &i);
1053 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1054
1055 i = 0;
1056 V_VT(&res) = VT_EMPTY;
1057 V_I4(&res) = 0;
1058 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, DISPID_VALUE, DISPATCH_PROPERTYGET,
1059 &dispparams, &res, NULL, &i);
1060 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1061 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1062 ok(V_I4(&res) == 1, "got %d\n", V_I4(&res));
1063
1064 /* call propget with DISPATCH_METHOD|DISPATCH_PROPERTYGET flags */
1065 V_VT(&args[0]) = VT_I4;
1066 V_I4(&args[0]) = 7;
1067
1068 dispparams.cArgs = 1;
1069 dispparams.rgvarg = args;
1070
1071 i = 0;
1072 V_VT(&res) = VT_EMPTY;
1073 V_I4(&res) = 0;
1074 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 4, DISPATCH_METHOD|DISPATCH_PROPERTYGET, &dispparams, &res, NULL, &i);
1075 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1076 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1077 ok(V_I4(&res) == 15, "got %d\n", V_I4(&res));
1078
1079
1080 /* DISPATCH_PROPERTYPUTREF */
1081 l = 1;
1082 V_VT(&args[0]) = VT_I4|VT_BYREF;
1083 V_I4REF(&args[0]) = &l;
1084
1085 dispidMember = DISPID_PROPERTYPUT;
1086 dispparams.cArgs = 1;
1087 dispparams.cNamedArgs = 1;
1088 dispparams.rgdispidNamedArgs = &dispidMember;
1089 dispparams.rgvarg = args;
1090
1091 i = 0;
1092 V_VT(&res) = VT_EMPTY;
1093 V_I4(&res) = 0;
1094 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
1095 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1096 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1097 ok(V_I4(&res) == 3, "got %d\n", V_I4(&res));
1098
1099 i = 0;
1100 V_VT(&res) = VT_EMPTY;
1101 V_I4(&res) = 0;
1102 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 1, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
1103 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1104
1105 i = 0;
1106 V_VT(&args[0]) = VT_UNKNOWN;
1107 V_UNKNOWN(&args[0]) = NULL;
1108
1109 V_VT(&res) = VT_EMPTY;
1110 V_I4(&res) = 0;
1111 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUTREF, &dispparams, &res, NULL, &i);
1112 ok(hr == S_OK, "got 0x%08x, %d\n", hr, i);
1113 ok(V_VT(&res) == VT_I4, "got %d\n", V_VT(&res));
1114 ok(V_I4(&res) == 6, "got %d\n", V_I4(&res));
1115
1116 i = 0;
1117 V_VT(&res) = VT_EMPTY;
1118 V_I4(&res) = 0;
1119 hr = ITypeInfo_Invoke(pTypeInfo, &invoketest, 2, DISPATCH_PROPERTYPUT, &dispparams, &res, NULL, &i);
1120 ok(hr == DISP_E_MEMBERNOTFOUND, "got 0x%08x, %d\n", hr, i);
1121
1122 test_invoke_func(pTypeInfo);
1123
1124 ITypeInfo_Release(pTypeInfo);
1125 ITypeLib_Release(pTypeLib);
1126 DeleteFileA(filenameA);
1127 }
1128
int_func(int a0,int a1,int a2,int a3,int a4)1129 static int WINAPI int_func( int a0, int a1, int a2, int a3, int a4 )
1130 {
1131 ok( a0 == 1, "wrong arg0 %x\n", a0 );
1132 ok( a1 == -1, "wrong arg1 %x\n", a1 );
1133 ok( a2 == (0x55550000 | 1234), "wrong arg2 %x\n", a2 );
1134 ok( a3 == 0xdeadbeef, "wrong arg3 %x\n", a3 );
1135 ok( a4 == 0x555555fd, "wrong arg4 %x\n", a4 );
1136 return 4321;
1137 }
1138
double_func(double a0,float a1,double a2,int a3)1139 static double WINAPI double_func( double a0, float a1, double a2, int a3 )
1140 {
1141 ok( a0 == 1.2, "wrong arg0 %f\n", a0 );
1142 ok( a1 == 3.25, "wrong arg1 %f\n", (double)a1 );
1143 ok( a2 == 1.2e12, "wrong arg2 %f\n", a2);
1144 ok( a3 == -4433.0, "wrong arg3 %f\n", (double)a3 );
1145 return 4321;
1146 }
1147
longlong_func(LONGLONG a0,CY a1)1148 static LONGLONG WINAPI longlong_func( LONGLONG a0, CY a1 )
1149 {
1150 ok( a0 == (((ULONGLONG)0xdead << 32) | 0xbeef), "wrong arg0 %08x%08x\n", (DWORD)(a0 >> 32), (DWORD)a0);
1151 ok( a1.int64 == ((ULONGLONG)10000 * 12345678), "wrong arg1 %08x%08x\n",
1152 (DWORD)(a1.int64 >> 32), (DWORD)a1.int64 );
1153 return ((ULONGLONG)4321 << 32) | 8765;
1154 }
1155
variant_func(int a0,BOOL a1,DECIMAL a2,VARIANT a3)1156 static VARIANT WINAPI variant_func( int a0, BOOL a1, DECIMAL a2, VARIANT a3 )
1157 {
1158 VARIANT var;
1159 ok( a0 == 2233, "wrong arg0 %x\n", a0 );
1160 ok( a1 == 1 || broken(a1 == 0x55550001), "wrong arg1 %x\n", a1 );
1161 V_VT(&var) = VT_LPWSTR;
1162 V_UI4(&var) = 0xbabe;
1163 ok( a2.Hi32 == 1122, "wrong arg2.Hi32 %x\n", a2.Hi32 );
1164 ok( U1(a2).Lo64 == 3344, "wrong arg2.Lo64 %08x%08x\n", (DWORD)(U1(a2).Lo64 >> 32), (DWORD)U1(a2).Lo64 );
1165 ok( V_VT(&a3) == VT_EMPTY, "wrong arg3 type %x\n", V_VT(&a3) );
1166 ok( V_UI4(&a3) == 0xdeadbeef, "wrong arg3 value %x\n", V_UI4(&a3) );
1167 return var;
1168 }
1169
void_func(int a0,int a1)1170 static int CDECL void_func( int a0, int a1 )
1171 {
1172 if (is_win64) /* VT_EMPTY is passed as real arg on win64 */
1173 {
1174 ok( a0 == 0x55555555, "wrong arg0 %x\n", a0 );
1175 ok( a1 == 1111, "wrong arg1 %x\n", a1 );
1176 }
1177 else
1178 {
1179 ok( a0 == 1111, "wrong arg0 %x\n", a0 );
1180 ok( a1 == 0, "wrong arg1 %x\n", a1 );
1181 }
1182 return 12;
1183 }
1184
stdcall_func(int a)1185 static int WINAPI stdcall_func( int a )
1186 {
1187 return 0;
1188 }
1189
inst_func(void * inst,int a)1190 static int WINAPI inst_func( void *inst, int a )
1191 {
1192 ok( (*(void ***)inst)[3] == inst_func, "wrong ptr %p\n", inst );
1193 ok( a == 3, "wrong arg %x\n", a );
1194 return a * 2;
1195 }
1196
ret_false_func(void)1197 static HRESULT WINAPI ret_false_func(void)
1198 {
1199 return S_FALSE;
1200 }
1201
1202 static const WCHAR testW[] = { 'T','e','s','t',0 };
1203
variant_func2(VARIANT * ret,VARIANT v1,VARIANT v2)1204 static void WINAPI variant_func2(VARIANT *ret, VARIANT v1, VARIANT v2)
1205 {
1206 ok(V_VT(&v1) == VT_I4, "unexpected %d\n", V_VT(&v1));
1207 ok(V_I4(&v1) == 2, "unexpected %d\n", V_I4(&v1));
1208 ok(V_VT(&v2) == VT_BSTR, "unexpected %d\n", V_VT(&v2));
1209 ok(lstrcmpW(V_BSTR(&v2), testW) == 0, "unexpected %s\n", wine_dbgstr_w(V_BSTR(&v2)));
1210
1211 V_VT(ret) = VT_UI4;
1212 V_I4(ret) = 4321;
1213 }
1214
inst_func2(void * inst,VARIANT * ret,VARIANT v1,VARIANT v2)1215 static void WINAPI inst_func2(void *inst, VARIANT *ret, VARIANT v1, VARIANT v2)
1216 {
1217 ok( (*(void ***)inst)[3] == inst_func2, "wrong ptr %p\n", inst );
1218
1219 ok(V_VT(ret) == VT_I4 || broken(V_VT(ret) == VT_VARIANT) /* win64 */, "unexpected %d\n", V_VT(ret));
1220 ok(V_I4(ret) == 1234, "unexpected %d\n", V_I4(ret));
1221
1222 ok(V_VT(&v1) == VT_I4, "unexpected %d\n", V_VT(&v1));
1223 ok(V_I4(&v1) == 2, "unexpected %d\n", V_I4(&v1));
1224 ok(V_VT(&v2) == VT_BSTR, "unexpected %d\n", V_VT(&v2));
1225 ok(lstrcmpW(V_BSTR(&v2), testW) == 0, "unexpected %s\n", wine_dbgstr_w(V_BSTR(&v2)));
1226
1227 V_VT(ret) = VT_UI4;
1228 V_I4(ret) = 4321;
1229 }
1230
1231 static void *vtable[] = { NULL, NULL, NULL, inst_func };
1232 static void *vtable2[] = { NULL, NULL, NULL, inst_func2 };
1233
test_DispCallFunc(void)1234 static void test_DispCallFunc(void)
1235 {
1236 void **inst;
1237 HRESULT res;
1238 VARIANT result, args[5];
1239 VARIANTARG *pargs[5];
1240 VARTYPE types[5];
1241 int i;
1242
1243 for (i = 0; i < 5; i++) pargs[i] = &args[i];
1244
1245 memset( args, 0x55, sizeof(args) );
1246
1247 types[0] = VT_VARIANT;
1248 V_VT(&args[0]) = VT_I4;
1249 V_I4(&args[0]) = 2;
1250 types[1] = VT_VARIANT;
1251 V_VT(&args[1]) = VT_BSTR;
1252 V_BSTR(&args[1]) = SysAllocString(testW);
1253 memset( &result, 0xcc, sizeof(result) );
1254 res = DispCallFunc(NULL, (ULONG_PTR)variant_func2, CC_STDCALL, VT_VARIANT, 2, types, pargs, &result);
1255 ok(res == S_OK, "DispCallFunc error %#x\n", res);
1256 ok(V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result));
1257 ok(V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result));
1258
1259 V_VT(&result) = VT_I4;
1260 V_UI4(&result) = 1234;
1261 inst = vtable2;
1262 res = DispCallFunc(&inst, 3 * sizeof(void *), CC_STDCALL, VT_VARIANT, 2, types, pargs, &result);
1263 ok(res == S_OK, "DispCallFunc error %#x\n", res);
1264 ok(V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result));
1265 ok(V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result));
1266
1267 VariantClear(&args[1]);
1268
1269 memset( args, 0x55, sizeof(args) );
1270 types[0] = VT_UI4;
1271 V_UI4(&args[0]) = 1;
1272 types[1] = VT_I4;
1273 V_I4(&args[1]) = -1;
1274 types[2] = VT_I2;
1275 V_I2(&args[2]) = 1234;
1276 types[3] = VT_UI4;
1277 V_UI4(&args[3]) = 0xdeadbeef;
1278 types[4] = VT_UI4;
1279 V_I1(&args[4]) = -3;
1280 memset( &result, 0xcc, sizeof(result) );
1281 res = DispCallFunc( NULL, (ULONG_PTR)int_func, CC_STDCALL, VT_UI4, 5, types, pargs, &result );
1282 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1283 ok( V_VT(&result) == VT_UI4, "wrong result type %d\n", V_VT(&result) );
1284 ok( V_UI4(&result) == 4321, "wrong result %u\n", V_UI4(&result) );
1285
1286 /* the function checks the argument sizes for stdcall */
1287 if (abi_supports_stdcall)
1288 {
1289 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 0, types, pargs, &result );
1290 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1291 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 1, types, pargs, &result );
1292 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1293 res = DispCallFunc( NULL, (ULONG_PTR)stdcall_func, CC_STDCALL, VT_UI4, 2, types, pargs, &result );
1294 ok( res == DISP_E_BADCALLEE, "DispCallFunc wrong error %x\n", res );
1295 }
1296
1297 memset( args, 0x55, sizeof(args) );
1298 types[0] = VT_R8;
1299 V_R8(&args[0]) = 1.2;
1300 types[1] = VT_R4;
1301 V_R4(&args[1]) = 3.25;
1302 types[2] = VT_R8;
1303 V_R8(&args[2]) = 1.2e12;
1304 types[3] = VT_I4;
1305 V_I4(&args[3]) = -4433;
1306 memset( &result, 0xcc, sizeof(result) );
1307 res = DispCallFunc( NULL, (ULONG_PTR)double_func, CC_STDCALL, VT_R8, 4, types, pargs, &result );
1308 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1309 ok( V_VT(&result) == VT_R8, "wrong result type %d\n", V_VT(&result) );
1310 ok( V_R8(&result) == 4321, "wrong result %f\n", V_R8(&result) );
1311
1312 memset( args, 0x55, sizeof(args) );
1313 types[0] = VT_I8;
1314 V_I8(&args[0]) = ((ULONGLONG)0xdead << 32) | 0xbeef;
1315 types[1] = VT_CY;
1316 V_CY(&args[1]).int64 = (ULONGLONG)10000 * 12345678;
1317 memset( &result, 0xcc, sizeof(result) );
1318 res = DispCallFunc( NULL, (ULONG_PTR)longlong_func, CC_STDCALL, VT_I8, 2, types, pargs, &result );
1319 ok( res == S_OK || broken(res == E_INVALIDARG), /* longlong not supported on <= win2k */
1320 "DispCallFunc failed %x\n", res );
1321 if (res == S_OK)
1322 {
1323 ok( V_VT(&result) == VT_I8, "wrong result type %d\n", V_VT(&result) );
1324 ok( V_I8(&result) == (((ULONGLONG)4321 << 32) | 8765), "wrong result %08x%08x\n",
1325 (DWORD)(V_I8(&result) >> 32), (DWORD)V_I8(&result) );
1326 }
1327
1328 memset( args, 0x55, sizeof(args) );
1329 types[0] = VT_I4;
1330 V_I4(&args[0]) = 2233;
1331 types[1] = VT_BOOL;
1332 V_BOOL(&args[1]) = 1;
1333 types[2] = VT_DECIMAL;
1334 V_DECIMAL(&args[2]).Hi32 = 1122;
1335 U1(V_DECIMAL(&args[2])).Lo64 = 3344;
1336 types[3] = VT_VARIANT;
1337 V_VT(&args[3]) = VT_EMPTY;
1338 V_UI4(&args[3]) = 0xdeadbeef;
1339 types[4] = VT_EMPTY;
1340 memset( &result, 0xcc, sizeof(result) );
1341 res = DispCallFunc( NULL, (ULONG_PTR)variant_func, CC_STDCALL, VT_VARIANT, 5, types, pargs, &result );
1342 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1343 ok( V_VT(&result) == VT_LPWSTR, "wrong result type %d\n", V_VT(&result) );
1344 ok( V_UI4(&result) == 0xbabe, "wrong result %08x\n", V_UI4(&result) );
1345
1346 memset( args, 0x55, sizeof(args) );
1347 types[0] = VT_EMPTY;
1348 types[1] = VT_I4;
1349 V_I4(&args[1]) = 1111;
1350 types[2] = VT_EMPTY;
1351 types[3] = VT_I4;
1352 V_I4(&args[3]) = 0;
1353 types[4] = VT_EMPTY;
1354 memset( &result, 0xcc, sizeof(result) );
1355 res = DispCallFunc( NULL, (ULONG_PTR)void_func, CC_CDECL, VT_EMPTY, 5, types, pargs, &result );
1356 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1357 ok( V_VT(&result) == VT_EMPTY, "wrong result type %d\n", V_VT(&result) );
1358 if (is_win64)
1359 ok( V_UI4(&result) == 12, "wrong result %08x\n", V_UI4(&result) );
1360 else
1361 ok( V_UI4(&result) == 0xcccccccc, "wrong result %08x\n", V_UI4(&result) );
1362
1363 memset( args, 0x55, sizeof(args) );
1364 types[0] = VT_I4;
1365 V_I4(&args[0]) = 3;
1366 memset( &result, 0xcc, sizeof(result) );
1367 inst = vtable;
1368 res = DispCallFunc( &inst, 3 * sizeof(void*), CC_STDCALL, VT_I4, 1, types, pargs, &result );
1369 ok( res == S_OK, "DispCallFunc failed %x\n", res );
1370 ok( V_VT(&result) == VT_I4, "wrong result type %d\n", V_VT(&result) );
1371 ok( V_I4(&result) == 6, "wrong result %08x\n", V_I4(&result) );
1372
1373 memset( &result, 0xcc, sizeof(result) );
1374 res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_ERROR, 0, NULL, NULL, &result);
1375 ok(res == S_OK, "DispCallFunc failed: %08x\n", res);
1376 ok(V_VT(&result) == VT_ERROR, "V_VT(result) = %u\n", V_VT(&result));
1377 ok(V_ERROR(&result) == S_FALSE, "V_ERROR(result) = %08x\n", V_ERROR(&result));
1378
1379 memset( &result, 0xcc, sizeof(result) );
1380 res = DispCallFunc(NULL, (ULONG_PTR)ret_false_func, CC_STDCALL, VT_HRESULT, 0, NULL, NULL, &result);
1381 ok(res == E_INVALIDARG, "DispCallFunc failed: %08x\n", res);
1382 ok(V_VT(&result) == 0xcccc, "V_VT(result) = %u\n", V_VT(&result));
1383 }
1384
1385 /* RegDeleteTreeW from dlls/advapi32/registry.c, plus additional view flag */
myRegDeleteTreeW(HKEY hKey,LPCWSTR lpszSubKey,REGSAM view)1386 static LSTATUS myRegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM view)
1387 {
1388 LONG ret;
1389 DWORD dwMaxSubkeyLen, dwMaxValueLen;
1390 DWORD dwMaxLen, dwSize;
1391 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
1392 HKEY hSubKey = hKey;
1393 view &= (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
1394
1395 if(lpszSubKey)
1396 {
1397 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ | view, &hSubKey);
1398 if (ret) return ret;
1399 }
1400
1401 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
1402 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
1403 if (ret) goto cleanup;
1404
1405 dwMaxSubkeyLen++;
1406 dwMaxValueLen++;
1407 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
1408 if (dwMaxLen > ARRAY_SIZE(szNameBuf))
1409 {
1410 /* Name too big: alloc a buffer for it */
1411 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
1412 {
1413 ret = ERROR_NOT_ENOUGH_MEMORY;
1414 goto cleanup;
1415 }
1416 }
1417
1418 /* Recursively delete all the subkeys */
1419 while (TRUE)
1420 {
1421 dwSize = dwMaxLen;
1422 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
1423 NULL, NULL, NULL)) break;
1424
1425 ret = myRegDeleteTreeW(hSubKey, lpszName, view);
1426 if (ret) goto cleanup;
1427 }
1428
1429 if (lpszSubKey)
1430 if (pRegDeleteKeyExW && view != 0)
1431 ret = pRegDeleteKeyExW(hKey, lpszSubKey, view, 0);
1432 else
1433 ret = RegDeleteKeyW(hKey, lpszSubKey);
1434 else
1435 while (TRUE)
1436 {
1437 dwSize = dwMaxLen;
1438 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
1439 NULL, NULL, NULL, NULL)) break;
1440
1441 ret = RegDeleteValueW(hKey, lpszName);
1442 if (ret) goto cleanup;
1443 }
1444
1445 cleanup:
1446 if (lpszName != szNameBuf)
1447 HeapFree(GetProcessHeap(), 0, lpszName);
1448 if(lpszSubKey)
1449 RegCloseKey(hSubKey);
1450 return ret;
1451 }
1452
do_typelib_reg_key(GUID * uid,WORD maj,WORD min,DWORD arch,LPCWSTR base,BOOL remove)1453 static BOOL do_typelib_reg_key(GUID *uid, WORD maj, WORD min, DWORD arch, LPCWSTR base, BOOL remove)
1454 {
1455 static const WCHAR typelibW[] = {'T','y','p','e','l','i','b','\\',0};
1456 static const WCHAR formatW[] = {'\\','%','u','.','%','u','\\','0','\\','w','i','n','%','u',0};
1457 static const WCHAR format2W[] = {'%','s','_','%','u','_','%','u','.','d','l','l',0};
1458 WCHAR buf[128];
1459 HKEY hkey;
1460 BOOL ret = TRUE;
1461 DWORD res;
1462
1463 memcpy(buf, typelibW, sizeof(typelibW));
1464 StringFromGUID2(uid, buf + lstrlenW(buf), 40);
1465
1466 if (remove)
1467 {
1468 ok(myRegDeleteTreeW(HKEY_CLASSES_ROOT, buf, 0) == ERROR_SUCCESS, "SHDeleteKey failed\n");
1469 return TRUE;
1470 }
1471
1472 wsprintfW(buf + lstrlenW(buf), formatW, maj, min, arch);
1473
1474 SetLastError(0xdeadbeef);
1475 res = RegCreateKeyExW(HKEY_CLASSES_ROOT, buf, 0, NULL, 0,
1476 KEY_WRITE, NULL, &hkey, NULL);
1477 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
1478 {
1479 win_skip("W-calls are not implemented\n");
1480 return FALSE;
1481 }
1482
1483 if (res != ERROR_SUCCESS)
1484 {
1485 trace("RegCreateKeyExW failed: %u\n", res);
1486 return FALSE;
1487 }
1488
1489 wsprintfW(buf, format2W, base, maj, min);
1490 if (RegSetValueExW(hkey, NULL, 0, REG_SZ,
1491 (BYTE *)buf, (lstrlenW(buf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
1492 {
1493 trace("RegSetValueExW failed\n");
1494 ret = FALSE;
1495 }
1496 RegCloseKey(hkey);
1497 return ret;
1498 }
1499
test_QueryPathOfRegTypeLib(DWORD arch)1500 static void test_QueryPathOfRegTypeLib(DWORD arch)
1501 {
1502 static const struct test_data
1503 {
1504 WORD maj, min;
1505 HRESULT ret;
1506 const WCHAR path[16];
1507 } td[] = {
1508 { 1, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1509 { 3, 0, S_OK, {'f','a','k','e','_','3','_','0','.','d','l','l',0 } },
1510 { 3, 1, S_OK, {'f','a','k','e','_','3','_','1','.','d','l','l',0 } },
1511 { 3, 22, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1512 { 3, 37, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1513 { 3, 40, S_OK, {'f','a','k','e','_','3','_','3','7','.','d','l','l',0 } },
1514 { 0xffff, 0xffff, S_OK, {'f','a','k','e','_','5','_','3','7','.','d','l','l',0 } },
1515 { 0xffff, 0, TYPE_E_LIBNOTREGISTERED, { 0 } },
1516 { 3, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1517 { 5, 0xffff, TYPE_E_LIBNOTREGISTERED, { 0 } },
1518 { 4, 0, TYPE_E_LIBNOTREGISTERED, { 0 } }
1519 };
1520 static const WCHAR base[] = {'f','a','k','e',0};
1521 static const WCHAR wrongW[] = {'w','r','o','n','g',0};
1522 UINT i;
1523 RPC_STATUS status;
1524 GUID uid;
1525 WCHAR uid_str[40];
1526 HRESULT ret;
1527 BSTR path;
1528
1529 status = UuidCreate(&uid);
1530 ok(!status || status == RPC_S_UUID_LOCAL_ONLY, "UuidCreate error %08x\n", status);
1531
1532 StringFromGUID2(&uid, uid_str, 40);
1533 /*trace("GUID: %s\n", wine_dbgstr_w(uid_str));*/
1534
1535 if (!do_typelib_reg_key(&uid, 3, 0, arch, base, FALSE)) return;
1536 if (!do_typelib_reg_key(&uid, 3, 1, arch, base, FALSE)) return;
1537 if (!do_typelib_reg_key(&uid, 3, 37, arch, base, FALSE)) return;
1538 if (!do_typelib_reg_key(&uid, 5, 37, arch, base, FALSE)) return;
1539 if (arch == 64 && !do_typelib_reg_key(&uid, 5, 37, 32, wrongW, FALSE)) return;
1540
1541 for (i = 0; i < ARRAY_SIZE(td); i++)
1542 {
1543 ret = QueryPathOfRegTypeLib(&uid, td[i].maj, td[i].min, LOCALE_NEUTRAL, &path);
1544 ok(ret == td[i].ret, "QueryPathOfRegTypeLib(%u.%u) returned %08x\n", td[i].maj, td[i].min, ret);
1545 if (ret == S_OK)
1546 {
1547 ok(!lstrcmpW(td[i].path, path), "typelib %u.%u path doesn't match\n", td[i].maj, td[i].min);
1548 SysFreeString(path);
1549 }
1550 }
1551
1552 do_typelib_reg_key(&uid, 0, 0, arch, NULL, TRUE);
1553 }
1554
test_inheritance(void)1555 static void test_inheritance(void)
1556 {
1557 HRESULT hr;
1558 ITypeLib *pTL;
1559 ITypeInfo *pTI, *pTI_p;
1560 TYPEATTR *pTA;
1561 HREFTYPE href;
1562 FUNCDESC *pFD;
1563 WCHAR path[MAX_PATH];
1564 CHAR pathA[MAX_PATH];
1565
1566 GetModuleFileNameA(NULL, pathA, MAX_PATH);
1567 MultiByteToWideChar(CP_ACP, 0, pathA, -1, path, MAX_PATH);
1568
1569 hr = LoadTypeLib(path, &pTL);
1570 if(FAILED(hr)) return;
1571
1572
1573 /* ItestIF3 is a syntax 2 dispinterface */
1574 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF3, &pTI);
1575 ok(hr == S_OK, "hr %08x\n", hr);
1576
1577 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1578 ok(hr == S_OK, "hr %08x\n", hr);
1579 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1580 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1581 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1582 ok(pTA->cFuncs == 6, "cfuncs %d\n", pTA->cFuncs);
1583 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1584 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1585
1586 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1587 ok(hr == S_OK, "hr %08x\n", hr);
1588 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1589 ok(hr == S_OK, "hr %08x\n", hr);
1590 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1591 ok(hr == S_OK, "got %08x\n", hr);
1592 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1593 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1594 ITypeInfo_Release(pTI_p);
1595
1596 /* Should have six methods */
1597 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1598 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1599 hr = ITypeInfo_GetFuncDesc(pTI, 5, &pFD);
1600 ok(hr == S_OK, "hr %08x\n", hr);
1601 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1602 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1603 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1604 ITypeInfo_Release(pTI);
1605
1606
1607 /* ItestIF4 is a syntax 1 dispinterface */
1608 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF4, &pTI);
1609 ok(hr == S_OK, "hr %08x\n", hr);
1610
1611 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1612 ok(hr == S_OK, "hr %08x\n", hr);
1613 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1614 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1615 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1616 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1617 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1618 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1619
1620 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1621 ok(hr == S_OK, "hr %08x\n", hr);
1622 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1623 ok(hr == S_OK, "hr %08x\n", hr);
1624 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1625 ok(hr == S_OK, "got %08x\n", hr);
1626 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1627 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1628 ITypeInfo_Release(pTI_p);
1629 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1630 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1631 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1632 ok(hr == S_OK, "hr %08x\n", hr);
1633 ok(pFD->memid == 0x1c, "memid %08x\n", pFD->memid);
1634 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1635 ITypeInfo_Release(pTI);
1636
1637
1638 /* ItestIF5 is dual with inherited ifaces which derive from IUnknown but not IDispatch */
1639 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF5, &pTI);
1640 ok(hr == S_OK, "hr %08x\n", hr);
1641
1642 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1643 ok(hr == S_OK, "hr %08x\n", hr);
1644 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1645 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1646 ok(pTA->wTypeFlags == TYPEFLAG_FDUAL, "typeflags %x\n", pTA->wTypeFlags);
1647 ok(pTA->cFuncs == 8, "cfuncs %d\n", pTA->cFuncs);
1648 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1649 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1650
1651 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1652 ok(hr == S_OK, "hr %08x\n", hr);
1653 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1654 ok(hr == S_OK, "hr %08x\n", hr);
1655 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1656 ok(hr == S_OK, "got %08x\n", hr);
1657 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1658 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1659 ITypeInfo_Release(pTI_p);
1660 hr = ITypeInfo_GetFuncDesc(pTI, 6, &pFD);
1661 ok(hr == S_OK, "hr %08x\n", hr);
1662 ok(pFD->memid == 0x1234, "memid %08x\n", pFD->memid);
1663 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1664 ITypeInfo_Release(pTI);
1665
1666 /* ItestIF7 is dual with inherited ifaces which derive from Dispatch */
1667 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF7, &pTI);
1668 ok(hr == S_OK, "hr %08x\n", hr);
1669
1670 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1671 ok(hr == S_OK, "hr %08x\n", hr);
1672 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1673 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1674 ok(pTA->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "typeflags %x\n", pTA->wTypeFlags);
1675 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1676 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1677 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1678
1679 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1680 ok(hr == S_OK, "hr %08x\n", hr);
1681 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1682 ok(hr == S_OK, "hr %08x\n", hr);
1683 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1684 ok(hr == S_OK, "got %08x\n", hr);
1685 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1686 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1687 ITypeInfo_Release(pTI_p);
1688
1689 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1690 ok(hr == S_OK, "hr %08x\n", hr);
1691 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1692 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1693 ITypeInfo_Release(pTI);
1694
1695 /* ItestIF10 is a syntax 2 dispinterface which doesn't derive from IUnknown */
1696 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF10, &pTI);
1697 ok(hr == S_OK, "hr %08x\n", hr);
1698
1699 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1700 ok(hr == S_OK, "hr %08x\n", hr);
1701 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1702 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1703 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1704 ok(pTA->cFuncs == 3, "cfuncs %d\n", pTA->cFuncs);
1705 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1706 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1707
1708 hr = ITypeInfo_GetRefTypeOfImplType(pTI, -1, &href);
1709 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1710 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1711 ok(hr == S_OK, "hr %08x\n", hr);
1712 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1713 ok(hr == S_OK, "hr %08x\n", hr);
1714 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1715 ok(hr == S_OK, "got %08x\n", hr);
1716 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1717 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1718 ITypeInfo_Release(pTI_p);
1719
1720 /* Should have three methods */
1721 hr = ITypeInfo_GetFuncDesc(pTI, 3, &pFD);
1722 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1723 hr = ITypeInfo_GetFuncDesc(pTI, 2, &pFD);
1724 ok(hr == S_OK, "hr %08x\n", hr);
1725 ok(pFD->memid == 0x60010000, "memid %08x\n", pFD->memid);
1726 ok(pFD->oVft == 2 * sizeof(void *), "oVft %d\n", pFD->oVft);
1727 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1728 ITypeInfo_Release(pTI);
1729
1730 /* ItestIF11 is a syntax 2 dispinterface which derives from IDispatch */
1731 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &DIID_ItestIF11, &pTI);
1732 ok(hr == S_OK, "hr %08x\n", hr);
1733
1734 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1735 ok(hr == S_OK, "hr %08x\n", hr);
1736 ok(pTA->typekind == TKIND_DISPATCH, "kind %04x\n", pTA->typekind);
1737 ok(pTA->cbSizeVft == 7 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1738 ok(pTA->wTypeFlags == TYPEFLAG_FDISPATCHABLE, "typeflags %x\n", pTA->wTypeFlags);
1739 ok(pTA->cFuncs == 10, "cfuncs %d\n", pTA->cFuncs);
1740 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1741 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1742
1743 hr = ITypeInfo_GetRefTypeOfImplType(pTI, 0, &href);
1744 ok(hr == S_OK, "hr %08x\n", hr);
1745 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1746 ok(hr == S_OK, "hr %08x\n", hr);
1747 hr = ITypeInfo_GetTypeAttr(pTI_p, &pTA);
1748 ok(hr == S_OK, "got %08x\n", hr);
1749 ok(IsEqualGUID(&pTA->guid, &IID_IDispatch), "guid {%08x-....\n", pTA->guid.Data1);
1750 ITypeInfo_ReleaseTypeAttr(pTI_p, pTA);
1751 ITypeInfo_Release(pTI_p);
1752
1753 /* Should have ten methods */
1754 hr = ITypeInfo_GetFuncDesc(pTI, 10, &pFD);
1755 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1756 hr = ITypeInfo_GetFuncDesc(pTI, 9, &pFD);
1757 ok(hr == S_OK, "hr %08x\n", hr);
1758 ok(pFD->memid == 0x1236, "memid %08x\n", pFD->memid);
1759 ok(pFD->oVft == 9 * sizeof(void *), "oVft %d\n", pFD->oVft);
1760
1761 /* first argument to 10th function is an HREFTYPE from the impl type */
1762 ok(pFD->cParams == 1, "cParams %i\n", pFD->cParams);
1763 ok(pFD->lprgelemdescParam[0].tdesc.vt == VT_USERDEFINED,
1764 "vt 0x%x\n", pFD->lprgelemdescParam[0].tdesc.vt);
1765 href = U(pFD->lprgelemdescParam[0].tdesc).hreftype;
1766 ok((href & 0xff000000) == 0x04000000, "href 0x%08x\n", href);
1767 hr = ITypeInfo_GetRefTypeInfo(pTI, href, &pTI_p);
1768 ok(hr == S_OK, "hr %08x\n", hr);
1769 if (SUCCEEDED(hr)) ITypeInfo_Release(pTI_p);
1770 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1771 ITypeInfo_Release(pTI);
1772
1773
1774 /* ItestIF2 is an interface which derives from IUnknown */
1775 hr = ITypeLib_GetTypeInfoOfGuid(pTL, &IID_ItestIF2, &pTI);
1776 ok(hr == S_OK, "hr %08x\n", hr);
1777
1778 hr = ITypeInfo_GetTypeAttr(pTI, &pTA);
1779 ok(hr == S_OK, "hr %08x\n", hr);
1780 ok(pTA->typekind == TKIND_INTERFACE, "kind %04x\n", pTA->typekind);
1781 ok(pTA->cbSizeVft == 6 * sizeof(void *), "sizevft %d\n", pTA->cbSizeVft);
1782 ok(pTA->wTypeFlags == 0, "typeflags %x\n", pTA->wTypeFlags);
1783 ok(pTA->cFuncs == 1, "cfuncs %d\n", pTA->cFuncs);
1784 ok(pTA->cImplTypes == 1, "cimpltypes %d\n", pTA->cImplTypes);
1785 ITypeInfo_ReleaseTypeAttr(pTI, pTA);
1786
1787 /* Should have one method */
1788 hr = ITypeInfo_GetFuncDesc(pTI, 1, &pFD);
1789 ok(hr == TYPE_E_ELEMENTNOTFOUND, "hr %08x\n", hr);
1790 hr = ITypeInfo_GetFuncDesc(pTI, 0, &pFD);
1791 ok(hr == S_OK, "hr %08x\n", hr);
1792 ok(pFD->memid == 0x60020000, "memid %08x\n", pFD->memid);
1793 ok(pFD->oVft == 5 * sizeof(void *), "oVft %d\n", pFD->oVft);
1794 ITypeInfo_ReleaseFuncDesc(pTI, pFD);
1795 ITypeInfo_Release(pTI);
1796
1797 ITypeLib_Release(pTL);
1798
1799 return;
1800 }
1801
test_CreateTypeLib(SYSKIND sys)1802 static void test_CreateTypeLib(SYSKIND sys) {
1803 static OLECHAR typelibW[] = {'t','y','p','e','l','i','b',0};
1804 static OLECHAR helpfileW[] = {'C',':','\\','b','o','g','u','s','.','h','l','p',0};
1805 static OLECHAR interface1W[] = {'i','n','t','e','r','f','a','c','e','1',0};
1806 static OLECHAR interface2W[] = {'i','n','t','e','r','f','a','c','e','2',0};
1807 static OLECHAR interface3W[] = {'i','n','t','e','r','f','a','c','e','3',0};
1808 static OLECHAR dualW[] = {'d','u','a','l',0};
1809 static OLECHAR coclassW[] = {'c','o','c','l','a','s','s',0};
1810 static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0x3213,0};
1811 static OLECHAR func1W[] = {'f','u','n','c','1',0};
1812 static OLECHAR func2W[] = {'f','u','n','c','2',0};
1813 static OLECHAR prop1W[] = {'P','r','o','p','1',0};
1814 static OLECHAR param1W[] = {'p','a','r','a','m','1',0};
1815 static OLECHAR param2W[] = {'p','a','r','a','m','2',0};
1816 static OLECHAR asdfW[] = {'A','s','d','f',0};
1817 static OLECHAR aliasW[] = {'a','l','i','a','s',0};
1818 static OLECHAR invokeW[] = {'I','n','v','o','k','e',0};
1819 static OLECHAR *names1[] = {func1W, param1W, param2W};
1820 static OLECHAR *names2[] = {func2W, param1W, param2W};
1821 static OLECHAR *propname[] = {prop1W, param1W};
1822 static const GUID tlcustguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x69}};
1823 static const GUID custguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x70}};
1824 static const GUID bogusguid = {0xbf611abe,0x5b38,0x11df,{0x91,0x5c,0x08,0x02,0x79,0x79,0x94,0x71}};
1825 static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
1826 static const GUID interface2guid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcd}};
1827
1828 char filename[MAX_PATH];
1829 WCHAR filenameW[MAX_PATH];
1830 ICreateTypeLib2 *createtl;
1831 ICreateTypeInfo *createti;
1832 ICreateTypeInfo2 *createti2;
1833 ITypeLib *tl, *stdole;
1834 ITypeLib2 *tl2;
1835 ITypeInfo *interface1, *interface2, *dual, *unknown, *dispatch, *ti;
1836 ITypeInfo *tinfos[2];
1837 ITypeInfo2 *ti2;
1838 ITypeComp *tcomp, *tcomp2;
1839 MEMBERID memids[2];
1840 FUNCDESC funcdesc, *pfuncdesc;
1841 ELEMDESC elemdesc[5], *edesc;
1842 PARAMDESCEX paramdescex;
1843 TYPEDESC typedesc1, typedesc2;
1844 TYPEATTR *typeattr;
1845 TLIBATTR *libattr;
1846 HREFTYPE hreftype;
1847 BSTR name, docstring, helpfile, names[3];
1848 DWORD helpcontext, ptr_size, alignment;
1849 int impltypeflags;
1850 unsigned int cnames;
1851 USHORT found;
1852 VARIANT cust_data;
1853 HRESULT hres;
1854 TYPEKIND kind;
1855 DESCKIND desckind;
1856 BINDPTR bindptr;
1857 char nameA[16];
1858 WCHAR nameW[16];
1859
1860 switch(sys){
1861 case SYS_WIN32:
1862 trace("testing SYS_WIN32\n");
1863 ptr_size = 4;
1864 alignment = sizeof(void*);
1865 break;
1866 case SYS_WIN64:
1867 trace("testing SYS_WIN64\n");
1868 ptr_size = 8;
1869 alignment = 4;
1870 break;
1871 default:
1872 return;
1873 }
1874
1875 trace("CreateTypeLib tests\n");
1876
1877 hres = LoadTypeLib(wszStdOle2, &stdole);
1878 ok(hres == S_OK, "got %08x\n", hres);
1879
1880 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unknown);
1881 ok(hres == S_OK, "got %08x\n", hres);
1882
1883 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
1884 ok(hres == S_OK, "got %08x\n", hres);
1885 ok(typeattr->cbSizeVft == 3 * sizeof(void*), "Got wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
1886 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
1887
1888 hres = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IDispatch, &dispatch);
1889 ok(hres == S_OK, "got %08x\n", hres);
1890
1891 GetTempFileNameA(".", "tlb", 0, filename);
1892 MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH);
1893
1894 hres = CreateTypeLib2(sys, filenameW, &createtl);
1895 ok(hres == S_OK, "got %08x\n", hres);
1896
1897 hres = ICreateTypeLib2_QueryInterface(createtl, &IID_ITypeLib, (void**)&tl);
1898 ok(hres == S_OK, "got %08x\n", hres);
1899
1900 hres = ITypeLib_GetTypeInfo(tl, 0, NULL);
1901 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1902
1903 hres = ITypeLib_GetTypeInfoType(tl, 0, &kind);
1904 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got 0x%08x\n", hres);
1905
1906 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1907 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1908
1909 hres = ITypeLib_GetTypeInfoType(tl, 0, NULL);
1910 ok(hres == E_INVALIDARG, "got 0x%08x\n", hres);
1911
1912 hres = ITypeLib_GetLibAttr(tl, NULL);
1913 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1914
1915 hres = ITypeLib_GetLibAttr(tl, &libattr);
1916 ok(hres == S_OK, "got %08x\n", hres);
1917
1918 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
1919 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
1920 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
1921 ok(libattr->wLibFlags == 0, "wLibFlags = %d\n", libattr->wLibFlags);
1922
1923 ITypeLib_ReleaseTLibAttr(tl, libattr);
1924
1925 name = (BSTR)0xdeadbeef;
1926 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
1927 ok(hres == S_OK, "got %08x\n", hres);
1928 ok(name == NULL, "name != NULL\n");
1929 ok(docstring == NULL, "docstring != NULL\n");
1930 ok(helpcontext == 0, "helpcontext != 0\n");
1931 ok(helpfile == NULL, "helpfile != NULL\n");
1932
1933 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1934 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
1935
1936 hres = ICreateTypeLib2_SetName(createtl, typelibW);
1937 ok(hres == S_OK, "got %08x\n", hres);
1938
1939 hres = ICreateTypeLib2_SetHelpFileName(createtl, helpfileW);
1940 ok(hres == S_OK, "got %08x\n", hres);
1941
1942 hres = ITypeLib_GetDocumentation(tl, -1, NULL, NULL, NULL, NULL);
1943 ok(hres == S_OK, "got %08x\n", hres);
1944
1945 hres = ITypeLib_GetDocumentation(tl, -1, &name, NULL, NULL, &helpfile);
1946 ok(hres == S_OK, "got %08x\n", hres);
1947 ok(!memcmp(name, typelibW, sizeof(typelibW)), "name = %s\n", wine_dbgstr_w(name));
1948 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
1949
1950 SysFreeString(name);
1951 SysFreeString(helpfile);
1952
1953 V_VT(&cust_data) = VT_I4;
1954 V_I4(&cust_data) = 1;
1955 hres = ICreateTypeLib2_SetCustData(createtl, &tlcustguid, &cust_data);
1956 ok(hres == S_OK, "got %08x\n", hres);
1957
1958 hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
1959 ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
1960
1961 V_VT(&cust_data) = VT_EMPTY;
1962 V_I4(&cust_data) = 0;
1963 hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
1964 ok(hres == S_OK, "got %08x\n", hres);
1965 ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
1966 ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
1967
1968 ITypeLib2_Release(tl2);
1969
1970 /* invalid parameters */
1971 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, &createti);
1972 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1973
1974 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, NULL);
1975 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1976
1977 hres = ICreateTypeLib2_CreateTypeInfo(createtl, NULL, TKIND_INTERFACE, NULL);
1978 ok(hres == E_INVALIDARG, "got %08x\n", hres);
1979
1980 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
1981 ok(hres == S_OK, "got %08x\n", hres);
1982
1983 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
1984 ok(hres == S_OK, "got %08x\n", hres);
1985
1986 hres = ITypeLib_GetDocumentation(tl, 0, &name, NULL, NULL, NULL);
1987 ok(hres == S_OK, "got %08x\n", hres);
1988 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1989
1990 SysFreeString(name);
1991
1992 ITypeLib_Release(tl);
1993
1994 name = (BSTR)0xdeadbeef;
1995 helpfile = (BSTR)0xdeadbeef;
1996 hres = ITypeInfo_GetDocumentation(interface1, -1, &name, &docstring, &helpcontext, &helpfile);
1997 ok(hres == S_OK, "got %08x\n", hres);
1998 ok(!memcmp(name, interface1W, sizeof(interface1W)), "name = %s\n", wine_dbgstr_w(name));
1999 ok(docstring == NULL, "docstring != NULL\n");
2000 ok(helpcontext == 0, "helpcontext != 0\n");
2001 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2002
2003 SysFreeString(name);
2004 SysFreeString(helpfile);
2005
2006 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2007 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2008
2009 hres = ITypeInfo_GetRefTypeInfo(interface1, 0, NULL);
2010 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2011
2012
2013 hres = ICreateTypeInfo_LayOut(createti);
2014 ok(hres == S_OK, "got %08x\n", hres);
2015
2016 hres = ICreateTypeInfo_SetGuid(createti, &interfaceguid);
2017 ok(hres == S_OK, "got %08x\n", hres);
2018
2019 hres = ICreateTypeInfo_AddRefTypeInfo(createti, NULL, &hreftype);
2020 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2021
2022 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, NULL);
2023 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2024
2025 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2026 ok(hres == S_OK, "got %08x\n", hres);
2027 if(hres != S_OK) {
2028 skip("Skipping some tests\n");
2029 return;
2030 }
2031
2032 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2033 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2034
2035 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2036 ok(hres == S_OK, "got %08x\n", hres);
2037
2038 hres = ITypeInfo_GetRefTypeOfImplType(interface1, 0, &hreftype);
2039 ok(hres == S_OK, "got %08x\n", hres);
2040 ok(hreftype == 3, "hreftype = %d\n", hreftype);
2041
2042 hres = ITypeInfo_GetRefTypeInfo(interface1, hreftype, &ti);
2043 ok(hres == S_OK, "got %08x\n", hres);
2044
2045 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2046 ok(hres == S_OK, "got %08x\n", hres);
2047 ok(typeattr->cbSizeVft == 3 * ptr_size, "retrieved IUnknown gave wrong cbSizeVft: %u\n", typeattr->cbSizeVft);
2048 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2049
2050 ITypeInfo_Release(ti);
2051
2052 hres = ITypeInfo_GetRefTypeOfImplType(interface1, -1, &hreftype);
2053 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2054
2055 ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo2, (void**)&ti2);
2056
2057 memset(&funcdesc, 0, sizeof(FUNCDESC));
2058 funcdesc.funckind = FUNC_PUREVIRTUAL;
2059 funcdesc.invkind = INVOKE_PROPERTYGET;
2060 funcdesc.callconv = CC_STDCALL;
2061 funcdesc.elemdescFunc.tdesc.vt = VT_BSTR;
2062 U(funcdesc.elemdescFunc).idldesc.wIDLFlags = IDLFLAG_NONE;
2063
2064 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, NULL);
2065 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2066
2067 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2068 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2069
2070 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2071 ok(hres == S_OK, "got %08x\n", hres);
2072
2073 hres = ITypeInfo2_GetFuncDesc(ti2, 0, NULL);
2074 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2075
2076 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2077 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2078
2079 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2080 ok(hres == S_OK, "got %08x\n", hres);
2081
2082 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2083 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2084 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2085 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2086 ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
2087 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2088 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2089 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2090 ok(pfuncdesc->oVft == 3 * ptr_size, "got %d\n", pfuncdesc->oVft);
2091 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2092 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2093 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2094
2095 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2096
2097 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2098 ok(hres == S_OK, "got %08x\n", hres);
2099
2100 funcdesc.invkind = INVOKE_PROPERTYPUT;
2101 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2102 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2103
2104 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2105 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2106 ok(hres == TYPE_E_INCONSISTENTPROPFUNCS, "got %08x\n", hres);
2107
2108 elemdesc[0].tdesc.vt = VT_BSTR;
2109 U(elemdesc[0]).idldesc.dwReserved = 0;
2110 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2111
2112 funcdesc.lprgelemdescParam = elemdesc;
2113 funcdesc.invkind = INVOKE_PROPERTYPUT;
2114 funcdesc.cParams = 1;
2115 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2116
2117 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2118 ok(hres == S_OK, "got %08x\n", hres);
2119
2120 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 1, 0xabcdefab);
2121 ok(hres == S_OK, "got %08x\n", hres);
2122
2123 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 0);
2124 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2125
2126 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, NULL, 1);
2127 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2128
2129 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, propname, 1);
2130 ok(hres == S_OK, "got %08x\n", hres);
2131
2132 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 1);
2133 ok(hres == S_OK, "got %08x\n", hres);
2134
2135 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1, propname, 2);
2136 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2137
2138 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2139 ok(hres == S_OK, "got %08x\n", hres);
2140
2141 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
2142 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2143 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2144 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2145 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
2146 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2147 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2148 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2149 ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2150 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2151 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2152 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2153
2154 edesc = pfuncdesc->lprgelemdescParam;
2155 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2156 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
2157
2158 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2159
2160
2161 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
2162 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2163 ok(hres == S_OK, "got %08x\n", hres);
2164
2165 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0xabcdefab);
2166 ok(hres == S_OK, "got %08x\n", hres);
2167
2168 hres = ICreateTypeInfo_SetFuncHelpContext(createti, 0, 0x201);
2169 ok(hres == S_OK, "got %08x\n", hres);
2170
2171 funcdesc.memid = 1;
2172 funcdesc.lprgelemdescParam = NULL;
2173 funcdesc.invkind = INVOKE_FUNC;
2174 funcdesc.cParams = 0;
2175 funcdesc.cScodes = 1;
2176 funcdesc.lprgscode = NULL;
2177 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2178 ok(hres == S_OK, "got %08x\n", hres);
2179
2180 hres = ITypeInfo2_GetFuncDesc(ti2, 1, &pfuncdesc);
2181 ok(hres == S_OK, "got %08x\n", hres);
2182
2183 ok(pfuncdesc->memid == 1, "got %d\n", pfuncdesc->memid);
2184 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2185 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2186 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2187 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2188 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2189 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
2190 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2191 ok(pfuncdesc->oVft == 4 * ptr_size, "got %d\n", pfuncdesc->oVft);
2192 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2193 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2194 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2195
2196 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2197
2198 funcdesc.memid = MEMBERID_NIL;
2199 hres = ICreateTypeInfo_AddFuncDesc(createti, 1, &funcdesc);
2200 ok(hres == S_OK, "got %08x\n", hres);
2201
2202 elemdesc[0].tdesc.vt = VT_PTR;
2203 U(elemdesc[0].tdesc).lptdesc = &typedesc1;
2204 typedesc1.vt = VT_BSTR;
2205 funcdesc.cParams = 1;
2206 funcdesc.lprgelemdescParam = elemdesc;
2207 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2208 ok(hres == S_OK, "got %08x\n", hres);
2209
2210 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2211 ok(hres == S_OK, "got %08x\n", hres);
2212
2213 ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
2214 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2215 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2216 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2217 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2218 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2219 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2220 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2221 ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2222 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2223 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2224 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2225
2226 edesc = pfuncdesc->lprgelemdescParam;
2227 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2228 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2229 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2230 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2231 ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2232
2233 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2234
2235 U(elemdesc[0].tdesc).lptdesc = &typedesc2;
2236 typedesc2.vt = VT_PTR;
2237 U(typedesc2).lptdesc = &typedesc1;
2238 hres = ICreateTypeInfo_AddFuncDesc(createti, 4, &funcdesc);
2239 ok(hres == S_OK, "got %08x\n", hres);
2240
2241 hres = ITypeInfo2_GetFuncDesc(ti2, 4, &pfuncdesc);
2242 ok(hres == S_OK, "got %08x\n", hres);
2243
2244 ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
2245 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2246 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2247 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2248 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2249 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2250 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2251 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2252 ok(pfuncdesc->oVft == 7 * ptr_size, "got %d\n", pfuncdesc->oVft);
2253 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2254 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2255 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2256
2257 edesc = pfuncdesc->lprgelemdescParam;
2258 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
2259 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2260 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2261 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
2262 ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
2263 ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
2264 ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
2265
2266 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2267
2268 elemdesc[0].tdesc.vt = VT_INT;
2269 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2270 U(elemdesc[0]).paramdesc.pparamdescex = ¶mdescex;
2271 V_VT(¶mdescex.varDefaultValue) = VT_INT;
2272 V_INT(¶mdescex.varDefaultValue) = 0x123;
2273 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2274 ok(hres == S_OK, "got %08x\n", hres);
2275
2276 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2277 ok(hres == S_OK, "got %08x\n", hres);
2278
2279 ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
2280 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2281 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2282 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2283 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2284 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2285 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2286 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2287 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2288 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2289 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2290 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2291
2292 edesc = pfuncdesc->lprgelemdescParam;
2293 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2294 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2295 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2296 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2297 U(*edesc).paramdesc.pparamdescex->cBytes);
2298 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
2299 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2300 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
2301 V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2302
2303 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2304
2305 U(elemdesc[0]).idldesc.dwReserved = 0;
2306 U(elemdesc[0]).idldesc.wIDLFlags = IDLFLAG_FIN;
2307 elemdesc[1].tdesc.vt = VT_UI2;
2308 U(elemdesc[1]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2309 U(elemdesc[1]).paramdesc.pparamdescex = ¶mdescex;
2310 V_VT(¶mdescex.varDefaultValue) = VT_UI2;
2311 V_UI2(¶mdescex.varDefaultValue) = 0xffff;
2312 funcdesc.cParams = 2;
2313 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2314 ok(hres == S_OK, "got %08x\n", hres);
2315
2316 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2317 ok(hres == S_OK, "got %08x\n", hres);
2318
2319 ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
2320 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2321 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2322 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2323 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2324 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2325 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2326 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2327 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2328 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2329 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2330 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2331
2332 edesc = pfuncdesc->lprgelemdescParam;
2333 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
2334 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2335 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2336
2337 edesc = pfuncdesc->lprgelemdescParam + 1;
2338 ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
2339 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2340 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2341 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2342 U(*edesc).paramdesc.pparamdescex->cBytes);
2343 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
2344 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2345 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
2346 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2347
2348 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2349
2350 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2351 U(elemdesc[0]).paramdesc.pparamdescex = ¶mdescex;
2352 elemdesc[1].tdesc.vt = VT_INT;
2353 V_VT(¶mdescex.varDefaultValue) = VT_INT;
2354 V_INT(¶mdescex.varDefaultValue) = 0xffffffff;
2355 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2356 ok(hres == S_OK, "got %08x\n", hres);
2357
2358 elemdesc[0].tdesc.vt = VT_BSTR;
2359 elemdesc[1].tdesc.vt = VT_BSTR;
2360 V_VT(¶mdescex.varDefaultValue) = VT_BSTR;
2361 V_BSTR(¶mdescex.varDefaultValue) = SysAllocString(defaultW);
2362 hres = ICreateTypeInfo_AddFuncDesc(createti, 3, &funcdesc);
2363 ok(hres == S_OK, "got %08x\n", hres);
2364 SysFreeString(V_BSTR(¶mdescex.varDefaultValue));
2365
2366 WideCharToMultiByte(CP_ACP, 0, defaultW, -1, nameA, sizeof(nameA), NULL, NULL);
2367 MultiByteToWideChar(CP_ACP, 0, nameA, -1, nameW, ARRAY_SIZE(nameW));
2368
2369 hres = ITypeInfo2_GetFuncDesc(ti2, 3, &pfuncdesc);
2370 ok(hres == S_OK, "got %08x\n", hres);
2371
2372 ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
2373 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2374 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2375 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2376 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2377 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2378 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
2379 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2380 ok(pfuncdesc->oVft == 6 * ptr_size, "got %d\n", pfuncdesc->oVft);
2381 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2382 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2383 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2384
2385 edesc = pfuncdesc->lprgelemdescParam;
2386 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2387 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2388 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2389 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2390 U(*edesc).paramdesc.pparamdescex->cBytes);
2391 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2392 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2393 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2394 "got: %s\n",
2395 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2396
2397 edesc = pfuncdesc->lprgelemdescParam + 1;
2398 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
2399 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2400 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2401 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
2402 U(*edesc).paramdesc.pparamdescex->cBytes);
2403 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
2404 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2405 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
2406 "got: %s\n",
2407 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
2408
2409 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2410
2411 elemdesc[0].tdesc.vt = VT_USERDEFINED;
2412 U(elemdesc[0].tdesc).hreftype = hreftype;
2413 U(elemdesc[0]).paramdesc.pparamdescex = ¶mdescex;
2414 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2415 V_VT(¶mdescex.varDefaultValue) = VT_INT;
2416 V_INT(¶mdescex.varDefaultValue) = 0x789;
2417
2418 funcdesc.lprgelemdescParam = elemdesc;
2419 funcdesc.invkind = INVOKE_FUNC;
2420 funcdesc.cParams = 1;
2421 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2422
2423 hres = ICreateTypeInfo_AddFuncDesc(createti, 5, &funcdesc);
2424 ok(hres == S_OK, "got %08x\n", hres);
2425
2426 hres = ITypeInfo2_GetFuncDesc(ti2, 5, &pfuncdesc);
2427 ok(hres == S_OK, "got %08x\n", hres);
2428
2429 ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
2430 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2431 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2432 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2433 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2434 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2435 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2436 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2437 ok(pfuncdesc->oVft == 8 * ptr_size, "got %d\n", pfuncdesc->oVft);
2438 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2439 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2440 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2441
2442 edesc = pfuncdesc->lprgelemdescParam;
2443 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2444 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2445 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2446 ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
2447 ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
2448 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2449 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2450 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: %d\n",
2451 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2452
2453 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2454
2455 elemdesc[0].tdesc.vt = VT_VARIANT;
2456 U(elemdesc[0]).paramdesc.pparamdescex = ¶mdescex;
2457 U(elemdesc[0]).paramdesc.wParamFlags = PARAMFLAG_FHASDEFAULT;
2458 V_VT(¶mdescex.varDefaultValue) = VT_INT;
2459 V_INT(¶mdescex.varDefaultValue) = 3;
2460
2461 funcdesc.lprgelemdescParam = elemdesc;
2462 funcdesc.invkind = INVOKE_FUNC;
2463 funcdesc.cParams = 1;
2464 funcdesc.elemdescFunc.tdesc.vt = VT_VARIANT;
2465
2466 hres = ICreateTypeInfo_AddFuncDesc(createti, 6, &funcdesc);
2467 ok(hres == S_OK, "got %08x\n", hres);
2468
2469 hres = ITypeInfo2_GetFuncDesc(ti2, 6, &pfuncdesc);
2470 ok(hres == S_OK, "got %08x\n", hres);
2471
2472 ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
2473 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2474 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2475 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2476 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2477 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2478 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2479 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2480 ok(pfuncdesc->oVft == 9 * ptr_size, "got %d\n", pfuncdesc->oVft);
2481 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2482 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2483 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2484
2485 edesc = pfuncdesc->lprgelemdescParam;
2486 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
2487 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
2488 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
2489 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
2490 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
2491 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2492 ok(V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 3, "got: %d\n",
2493 V_INT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
2494
2495 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2496
2497 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, &docstring, &helpcontext, &helpfile);
2498 ok(hres == S_OK, "got %08x\n", hres);
2499 ok(name == NULL, "name != NULL\n");
2500 ok(docstring == NULL, "docstring != NULL\n");
2501 ok(helpcontext == 0x201, "helpcontext != 0x201\n");
2502 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "helpfile = %s\n", wine_dbgstr_w(helpfile));
2503
2504 SysFreeString(helpfile);
2505
2506 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, NULL, 1);
2507 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2508
2509 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 1000, names1, 1);
2510 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2511
2512 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 2);
2513 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2514
2515 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names2, 1);
2516 ok(hres == S_OK, "got %08x\n", hres);
2517
2518 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 0, names1, 1);
2519 ok(hres == S_OK, "got %08x\n", hres);
2520
2521 hres = ITypeInfo_GetDocumentation(interface1, 0, &name, NULL, NULL, NULL);
2522 ok(hres == S_OK, "got %08x\n", hres);
2523 ok(!memcmp(name, func1W, sizeof(func1W)), "name = %s\n", wine_dbgstr_w(name));
2524
2525 SysFreeString(name);
2526
2527 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names2, 3);
2528 ok(hres == S_OK, "got %08x\n", hres);
2529
2530 hres = ICreateTypeInfo_SetFuncAndParamNames(createti, 3, names1, 3);
2531 ok(hres == TYPE_E_AMBIGUOUSNAME, "got %08x\n", hres);
2532
2533 ITypeInfo2_Release(ti2);
2534 ICreateTypeInfo_Release(createti);
2535
2536 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface1W, TKIND_INTERFACE, &createti);
2537 ok(hres == TYPE_E_NAMECONFLICT, "got %08x\n", hres);
2538
2539 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface2W, TKIND_INTERFACE, &createti);
2540 ok(hres == S_OK, "got %08x\n", hres);
2541
2542 hres = ICreateTypeInfo_SetGuid(createti, &interface2guid);
2543 ok(hres == S_OK, "got %08x\n", hres);
2544
2545 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface2);
2546 ok(hres == S_OK, "got %08x\n", hres);
2547
2548 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2549 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2550
2551 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2552 ok(hres == S_OK, "got %08x\n", hres);
2553
2554 hres = ITypeInfo_GetRefTypeInfo(interface2, 0, &ti);
2555 ok(hres == S_OK, "got %08x\n", hres);
2556 ok(ti == interface1, "Received and added interfaces are different\n");
2557
2558 ITypeInfo_Release(ti);
2559
2560 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2561 ok(hres == S_OK, "got %08x\n", hres);
2562
2563 hres = ITypeInfo_GetRefTypeOfImplType(interface2, 0, &hreftype);
2564 ok(hres == S_OK, "got %08x\n", hres);
2565 ok(hreftype == 2, "hreftype = %d\n", hreftype);
2566
2567 hres = ITypeInfo_GetRefTypeOfImplType(interface2, -1, &hreftype);
2568 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2569
2570 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2571 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2572
2573 hres = ITypeInfo_GetImplTypeFlags(interface2, 0, &impltypeflags);
2574 ok(hres == S_OK, "got %08x\n", hres);
2575 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2576
2577 hres = ITypeInfo_GetImplTypeFlags(interface2, 1, &impltypeflags);
2578 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2579
2580 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
2581 funcdesc.oVft = 0xaaac;
2582 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2583 if(sys == SYS_WIN64){
2584 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2585 funcdesc.oVft = 0xaab0;
2586 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2587 }
2588 ok(hres == S_OK, "got %08x\n", hres);
2589 funcdesc.oVft = 0xaaa8;
2590 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2591 ok(hres == S_OK, "got %08x\n", hres);
2592
2593 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti2);
2594 ok(hres == S_OK, "got %08x\n", hres);
2595
2596 hres = ITypeInfo2_GetFuncDesc(ti2, 0, &pfuncdesc);
2597 ok(hres == S_OK, "got %08x\n", hres);
2598
2599 ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
2600 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
2601 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
2602 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
2603 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
2604 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
2605 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
2606 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
2607 ok(pfuncdesc->oVft == (short)0xaaa8, "got %d\n", pfuncdesc->oVft);
2608 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
2609 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
2610 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
2611
2612 ITypeInfo2_ReleaseFuncDesc(ti2, pfuncdesc);
2613 ITypeInfo2_Release(ti2);
2614
2615 funcdesc.oVft = 0;
2616
2617 ICreateTypeInfo_Release(createti);
2618
2619 VariantInit(&cust_data);
2620
2621 hres = ICreateTypeLib2_CreateTypeInfo(createtl, interface3W, TKIND_INTERFACE, &createti);
2622 ok(hres == S_OK, "got %08x\n", hres);
2623
2624 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ICreateTypeInfo2, (void**)&createti2);
2625 ok(hres == S_OK, "got %08x\n", hres);
2626
2627 hres = ICreateTypeInfo2_QueryInterface(createti2, &IID_ITypeInfo2, (void**)&ti2);
2628 ok(hres == S_OK, "got %08x\n", hres);
2629
2630 hres = ITypeInfo2_GetCustData(ti2, NULL, NULL);
2631 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2632
2633 hres = ITypeInfo2_GetCustData(ti2, &custguid, NULL);
2634 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2635
2636 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2637 ok(hres == S_OK, "got %08x\n", hres);
2638
2639 hres = ICreateTypeInfo2_SetCustData(createti2, NULL, NULL);
2640 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2641
2642 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, NULL);
2643 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2644
2645 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2646 ok(hres == DISP_E_BADVARTYPE, "got %08x\n", hres);
2647
2648 V_VT(&cust_data) = VT_UI4;
2649 V_I4(&cust_data) = 0xdeadbeef;
2650
2651 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2652 ok(hres == S_OK, "got %08x\n", hres);
2653
2654 V_I4(&cust_data) = 0;
2655 V_VT(&cust_data) = VT_EMPTY;
2656
2657 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2658 ok(hres == S_OK, "got %08x\n", hres);
2659
2660 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2661 ok(V_I4(&cust_data) == 0xdeadbeef, "got 0x%08x\n", V_I4(&cust_data));
2662
2663 V_VT(&cust_data) = VT_UI4;
2664 V_I4(&cust_data) = 12345678;
2665
2666 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2667 ok(hres == S_OK, "got %08x\n", hres);
2668
2669 V_I4(&cust_data) = 0;
2670 V_VT(&cust_data) = VT_EMPTY;
2671
2672 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2673 ok(hres == S_OK, "got %08x\n", hres);
2674
2675 ok(V_VT(&cust_data) == VT_UI4, "got %d\n", V_VT(&cust_data));
2676 ok(V_I4(&cust_data) == 12345678, "got 0x%08x\n", V_I4(&cust_data));
2677
2678 V_VT(&cust_data) = VT_BSTR;
2679 V_BSTR(&cust_data) = SysAllocString(asdfW);
2680
2681 hres = ICreateTypeInfo2_SetCustData(createti2, &custguid, &cust_data);
2682 ok(hres == S_OK, "got %08x\n", hres);
2683
2684 SysFreeString(V_BSTR(&cust_data));
2685 V_I4(&cust_data) = 0;
2686 V_VT(&cust_data) = VT_EMPTY;
2687
2688 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
2689 ok(hres == S_OK, "got %08x\n", hres);
2690
2691 ok(V_VT(&cust_data) == VT_BSTR, "got %d\n", V_VT(&cust_data));
2692 ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
2693 SysFreeString(V_BSTR(&cust_data));
2694
2695 V_VT(&cust_data) = VT_UI4;
2696 V_UI4(&cust_data) = 17;
2697
2698 hres = ITypeInfo2_GetCustData(ti2, &bogusguid, &cust_data);
2699 ok(hres == S_OK, "got %08x\n", hres);
2700
2701 ok(V_VT(&cust_data) == VT_EMPTY, "got: %d\n", V_VT(&cust_data));
2702
2703 ITypeInfo2_Release(ti2);
2704 ICreateTypeInfo2_Release(createti2);
2705 ICreateTypeInfo_Release(createti);
2706
2707 hres = ICreateTypeLib2_CreateTypeInfo(createtl, coclassW, TKIND_COCLASS, &createti);
2708 ok(hres == S_OK, "got %08x\n", hres);
2709
2710 hres = ICreateTypeInfo_AddRefTypeInfo(createti, interface1, &hreftype);
2711 ok(hres == S_OK, "got %08x\n", hres);
2712
2713 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2714 ok(hres == S_OK, "got %08x\n", hres);
2715
2716 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2717 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2718
2719 hres = ICreateTypeInfo_AddRefTypeInfo(createti, unknown, &hreftype);
2720 ok(hres == S_OK, "got %08x\n", hres);
2721
2722 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2723 ok(hres == S_OK, "got %08x\n", hres);
2724
2725 hres = ICreateTypeInfo_AddImplType(createti, 1, hreftype);
2726 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2727
2728 hres = ICreateTypeInfo_AddImplType(createti, 2, hreftype);
2729 ok(hres == S_OK, "got %08x\n", hres);
2730
2731 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 0, IMPLTYPEFLAG_FDEFAULT);
2732 ok(hres == S_OK, "got %08x\n", hres);
2733
2734 hres = ICreateTypeInfo_SetImplTypeFlags(createti, 1, IMPLTYPEFLAG_FRESTRICTED);
2735 ok(hres == S_OK, "got %08x\n", hres);
2736
2737 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti);
2738 ok(hres == S_OK, "got %08x\n", hres);
2739
2740 hres = ITypeInfo_GetImplTypeFlags(ti, 0, NULL);
2741 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2742
2743 hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
2744 ok(hres == S_OK, "got %08x\n", hres);
2745 ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "impltypeflags = %x\n", impltypeflags);
2746
2747 hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
2748 ok(hres == S_OK, "got %08x\n", hres);
2749 ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "impltypeflags = %x\n", impltypeflags);
2750
2751 hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
2752 ok(hres == S_OK, "got %08x\n", hres);
2753 ok(impltypeflags == 0, "impltypeflags = %x\n", impltypeflags);
2754
2755 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
2756 ok(hres == S_OK, "got %08x\n", hres);
2757 ok(hreftype == 0, "hreftype = %d\n", hreftype);
2758
2759 hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
2760 ok(hres == S_OK, "got %08x\n", hres);
2761 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2762
2763 hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
2764 ok(hres == S_OK, "got %08x\n", hres);
2765 ok(hreftype == 1, "hreftype = %d\n", hreftype);
2766
2767 hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
2768 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
2769
2770 ITypeInfo_Release(ti);
2771
2772 ICreateTypeInfo_Release(createti);
2773
2774 hres = ICreateTypeLib2_CreateTypeInfo(createtl, dualW, TKIND_INTERFACE, &createti);
2775 ok(hres == S_OK, "got %08x\n", hres);
2776
2777 hres = ICreateTypeInfo_SetTypeFlags(createti, TYPEFLAG_FDUAL);
2778 ok(hres == S_OK, "got %08x\n", hres);
2779
2780 hres = ICreateTypeInfo_AddFuncDesc(createti, 0, &funcdesc);
2781 ok(hres == S_OK, "got %08x\n", hres);
2782
2783 hres = ICreateTypeInfo_AddRefTypeInfo(createti, dispatch, &hreftype);
2784 ok(hres == S_OK, "got %08x\n", hres);
2785
2786 hres = ICreateTypeInfo_AddImplType(createti, 0, hreftype);
2787 ok(hres == S_OK, "got %08x\n", hres);
2788
2789 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&dual);
2790 ok(hres == S_OK, "got %08x\n", hres);
2791
2792 hres = ITypeInfo_GetTypeAttr(dual, &typeattr);
2793 ok(hres == S_OK, "got %08x\n", hres);
2794 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2795 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2796 ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
2797 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2798 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2799 ok(typeattr->cbSizeVft == 8 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2800 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2801 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2802 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2803 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2804
2805 ITypeInfo_ReleaseTypeAttr(dual, typeattr);
2806
2807 hres = ITypeInfo_GetRefTypeOfImplType(dual, -1, &hreftype);
2808 ok(hres == S_OK, "got %08x\n", hres);
2809 ok(hreftype == -2, "got %08x\n", hreftype);
2810
2811 hres = ITypeInfo_GetRefTypeInfo(dual, -2, &ti);
2812 ok(hres == S_OK, "got %08x\n", hres);
2813
2814 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
2815 ok(hres == S_OK, "got %08x\n", hres);
2816 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2817 ok(typeattr->typekind == 4, "typekind = %d\n", typeattr->typekind);
2818 ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
2819 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2820 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2821 ok(typeattr->cbSizeVft == 7 * sizeof(void *), "cbSizeVft = %d\n", typeattr->cbSizeVft);
2822 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2823 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL), "wTypeFlags = %d\n", typeattr->wTypeFlags);
2824 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2825 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2826
2827 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
2828
2829 ITypeInfo_Release(ti);
2830
2831 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2832 ok(hres == TYPE_E_BADMODULEKIND, "got %08x\n", hres);
2833
2834 ICreateTypeInfo_Release(createti);
2835
2836 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2837 ok(hres == S_OK, "got %08x\n", hres);
2838 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2839 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2840 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
2841 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2842 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2843 ok(typeattr->cbSizeVft == 16 * ptr_size, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2844 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2845 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2846 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2847 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2848
2849 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2850
2851 hres = ITypeInfo_GetTypeAttr(interface2, &typeattr);
2852 ok(hres == S_OK, "got %08x\n", hres);
2853 ok(typeattr->cbSizeInstance == ptr_size, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2854 ok(typeattr->typekind == 3, "typekind = %d\n", typeattr->typekind);
2855 ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
2856 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2857 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
2858 ok((sys == SYS_WIN32 && typeattr->cbSizeVft == 0xaab0) ||
2859 (sys == SYS_WIN64 && typeattr->cbSizeVft == 0xaab8),
2860 "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
2861 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2862 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2863 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2864 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2865
2866 ITypeInfo_ReleaseTypeAttr(interface2, typeattr);
2867
2868 ok(ITypeInfo_Release(interface2)==0, "Object should be freed\n");
2869 ok(ITypeInfo_Release(interface1)==0, "Object should be freed\n");
2870 ok(ITypeInfo_Release(dual)==0, "Object should be freed\n");
2871
2872 hres = ICreateTypeLib2_CreateTypeInfo(createtl, aliasW, TKIND_ALIAS, &createti);
2873 ok(hres == S_OK, "got %08x\n", hres);
2874
2875 hres = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&interface1);
2876 ok(hres == S_OK, "got %08x\n", hres);
2877
2878 if(0){
2879 /* windows gives invalid values here, and even breaks the typeinfo permanently
2880 * on winxp. only call GetTypeAttr() on a TKIND_ALIAS after SetTypeDescAlias. */
2881 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2882 ok(hres == S_OK, "got %08x\n", hres);
2883 ok(typeattr->cbSizeInstance == 0xffffffb4, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2884 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2885 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2886 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2887 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2888 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2889 ok(typeattr->cbAlignment == 0, "cbAlignment = %d\n", typeattr->cbAlignment);
2890 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2891 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2892 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2893 ok(typeattr->tdescAlias.vt == VT_EMPTY, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2894 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2895 }
2896
2897 hres = ICreateTypeInfo_SetTypeDescAlias(createti, NULL);
2898 ok(hres == E_INVALIDARG, "got %08x\n", hres);
2899
2900 typedesc1.vt = VT_I1;
2901 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2902 ok(hres == S_OK, "got %08x\n", hres);
2903
2904 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2905 ok(hres == S_OK, "got %08x\n", hres);
2906 ok(typeattr->cbSizeInstance == 1, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2907 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2908 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2909 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2910 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2911 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2912 ok(typeattr->cbAlignment == 1, "cbAlignment = %d\n", typeattr->cbAlignment);
2913 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2914 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2915 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2916 ok(typeattr->tdescAlias.vt == VT_I1, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2917 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2918
2919 typedesc1.vt = VT_R8;
2920 hres = ICreateTypeInfo_SetTypeDescAlias(createti, &typedesc1);
2921 ok(hres == S_OK, "got %08x\n", hres);
2922
2923 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
2924 ok(hres == S_OK, "got %08x\n", hres);
2925 ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
2926 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
2927 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
2928 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
2929 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
2930 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
2931 ok(typeattr->cbAlignment == 4, "cbAlignment = %d\n", typeattr->cbAlignment);
2932 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
2933 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
2934 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
2935 ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
2936 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
2937
2938 ITypeInfo_Release(interface1);
2939 ICreateTypeInfo_Release(createti);
2940
2941 hres = ICreateTypeLib2_SaveAllChanges(createtl);
2942 ok(hres == S_OK, "got %08x\n", hres);
2943
2944 ok(ICreateTypeLib2_Release(createtl)==0, "Object should be freed\n");
2945
2946 ok(ITypeInfo_Release(dispatch)==0, "Object should be freed\n");
2947 ok(ITypeInfo_Release(unknown)==0, "Object should be freed\n");
2948 ok(ITypeLib_Release(stdole)==0, "Object should be freed\n");
2949
2950 hres = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl);
2951 ok(hres == S_OK, "got %08x\n", hres);
2952
2953 hres = ITypeLib_GetLibAttr(tl, &libattr);
2954 ok(hres == S_OK, "got %08x\n", hres);
2955 ok(libattr->syskind == sys, "syskind = %d\n", libattr->syskind);
2956 ok(libattr->wMajorVerNum == 0, "wMajorVer = %d\n", libattr->wMajorVerNum);
2957 ok(libattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", libattr->wMinorVerNum);
2958 ok(libattr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "wLibFlags = %d\n", libattr->wLibFlags);
2959 ITypeLib_ReleaseTLibAttr(tl, libattr);
2960
2961 found = 2;
2962 memset(tinfos, 0, sizeof(tinfos));
2963 memids[0] = 0xdeadbeef;
2964 memids[1] = 0xdeadbeef;
2965 hres = ITypeLib_FindName(tl, param1W, 0, tinfos, memids, &found);
2966 ok(hres == S_OK, "got: %08x\n", hres);
2967 ok(found == 0, "got wrong count: %u\n", found);
2968 ok(tinfos[0] == NULL, "got invalid typeinfo[0]\n");
2969 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2970 ok(memids[0] == 0xdeadbeef, "got invalid memid[0]\n");
2971 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2972
2973 found = 2;
2974 memset(tinfos, 0, sizeof(tinfos));
2975 memids[0] = 0xdeadbeef;
2976 memids[1] = 0xdeadbeef;
2977 hres = ITypeLib_FindName(tl, func1W, 0, tinfos, memids, &found);
2978 ok(hres == S_OK, "got: %08x\n", hres);
2979 ok(found == 1, "got wrong count: %u\n", found);
2980 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2981 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2982 ok(memids[0] == 0, "got invalid memid[0]\n");
2983 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2984 if(tinfos[0])
2985 ITypeInfo_Release(tinfos[0]);
2986
2987 found = 2;
2988 memset(tinfos, 0, sizeof(tinfos));
2989 memids[0] = 0xdeadbeef;
2990 memids[1] = 0xdeadbeef;
2991 hres = ITypeLib_FindName(tl, interface1W, 0, tinfos, memids, &found);
2992 ok(hres == S_OK, "got: %08x\n", hres);
2993 ok(found == 1, "got wrong count: %u\n", found);
2994 ok(tinfos[0] != NULL, "got invalid typeinfo[0]\n");
2995 ok(tinfos[1] == NULL, "got invalid typeinfo[1]\n");
2996 ok(memids[0] == MEMBERID_NIL, "got invalid memid[0]: %x\n", memids[0]);
2997 ok(memids[1] == 0xdeadbeef, "got invalid memid[1]\n");
2998 if(tinfos[0])
2999 ITypeInfo_Release(tinfos[0]);
3000
3001 hres = ITypeLib_GetDocumentation(tl, -1, &name, &docstring, &helpcontext, &helpfile);
3002 ok(hres == S_OK, "got %08x\n", hres);
3003 ok(memcmp(typelibW, name, sizeof(typelibW)) == 0, "got wrong typelib name: %s\n",
3004 wine_dbgstr_w(name));
3005 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3006 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3007 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3008 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3009 SysFreeString(name);
3010 SysFreeString(helpfile);
3011
3012 hres = ITypeLib_GetDocumentation(tl, 0, &name, &docstring, &helpcontext, &helpfile);
3013 ok(hres == S_OK, "got %08x\n", hres);
3014 ok(memcmp(interface1W, name, sizeof(interface1W)) == 0, "got wrong typeinfo name: %s\n",
3015 wine_dbgstr_w(name));
3016 ok(docstring == NULL, "got wrong docstring: %s\n", wine_dbgstr_w(docstring));
3017 ok(helpcontext == 0, "got wrong helpcontext: 0x%x\n", helpcontext);
3018 ok(memcmp(helpfileW, helpfile, sizeof(helpfileW)) == 0,
3019 "got wrong helpfile: %s\n", wine_dbgstr_w(helpfile));
3020 SysFreeString(name);
3021 SysFreeString(helpfile);
3022
3023 hres = ITypeLib_QueryInterface(tl, &IID_ITypeLib2, (void**)&tl2);
3024 ok(hres == S_OK, "no ITypeLib2 interface (%x)\n", hres);
3025 V_VT(&cust_data) = VT_EMPTY;
3026 V_I4(&cust_data) = 0;
3027 hres = ITypeLib2_GetCustData(tl2, &tlcustguid, &cust_data);
3028 ok(hres == S_OK, "got %08x\n", hres);
3029 ok(V_VT(&cust_data) == VT_I4, "V_VT(&cust_data) = %d\n", V_VT(&cust_data));
3030 ok(V_I4(&cust_data) == 1, "V_I4(&cust_data) = %d\n", V_I4(&cust_data));
3031 ITypeLib2_Release(tl2);
3032
3033 hres = ITypeLib_GetTypeInfo(tl, 0, &ti);
3034 ok(hres == S_OK, "got %08x\n", hres);
3035
3036 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3037 ok(hres == S_OK, "got %08x\n", hres);
3038 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3039 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3040 ok(typeattr->cFuncs == 13, "cFuncs = %d\n", typeattr->cFuncs);
3041 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3042 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3043 todo_wine_if(is_win64 && sys == SYS_WIN32)
3044 ok(typeattr->cbSizeVft == 16 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3045 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3046 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3047 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3048 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3049 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3050
3051 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3052 ok(hres == S_OK, "got %08x\n", hres);
3053 ok(hreftype == 3, "hreftype = %d\n", hreftype);
3054
3055 hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &unknown);
3056 ok(hres == S_OK, "got %08x\n", hres);
3057
3058 hres = ITypeInfo_GetTypeAttr(unknown, &typeattr);
3059 ok(hres == S_OK, "got %08x\n", hres);
3060 ok(IsEqualGUID(&typeattr->guid, &IID_IUnknown), "got wrong reftypeinfo\n");
3061 ITypeInfo_ReleaseTypeAttr(unknown, typeattr);
3062
3063 ITypeInfo_Release(unknown);
3064
3065 hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
3066 ok(hres == S_OK, "got %08x\n", hres);
3067 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3068 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3069 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3070 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3071 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUTREF, "got 0x%x\n", pfuncdesc->invkind);
3072 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3073 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3074 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3075 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3076 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3077 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3078 edesc = pfuncdesc->lprgelemdescParam;
3079 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3080 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
3081
3082 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3083 ok(hres == S_OK, "got: %08x\n", hres);
3084 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3085 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3086 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3087 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3088 SysFreeString(name);
3089 SysFreeString(helpfile);
3090
3091 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, NULL, 0, &cnames);
3092 ok(hres == E_INVALIDARG, "got: %08x\n", hres);
3093
3094 cnames = 8;
3095 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, 0, &cnames);
3096 ok(hres == S_OK, "got: %08x\n", hres);
3097 ok(cnames == 0, "got: %u\n", cnames);
3098
3099 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
3100 ok(hres == S_OK, "got: %08x\n", hres);
3101 ok(cnames == 1, "got: %u\n", cnames);
3102 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3103 SysFreeString(names[0]);
3104
3105 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3106
3107 hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
3108 ok(hres == S_OK, "got %08x\n", hres);
3109 ok(pfuncdesc->memid == 0x60010001, "got %x\n", pfuncdesc->memid);
3110 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3111 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3112 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3113 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3114 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3115 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3116 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3117 ok(pfuncdesc->oVft == 4 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3118 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3119 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3120 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3121
3122 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3123 ok(hres == S_OK, "got: %08x\n", hres);
3124 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3125 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3126 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3127 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3128 SysFreeString(helpfile);
3129 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3130
3131 hres = ITypeInfo_GetFuncDesc(ti, 2, &pfuncdesc);
3132 ok(hres == S_OK, "got %08x\n", hres);
3133 ok(pfuncdesc->memid == 0x1, "got %x\n", pfuncdesc->memid);
3134 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3135 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3136 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3137 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3138 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3139 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3140 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3141 ok(pfuncdesc->oVft == 5 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3142 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3143 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3144 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3145
3146 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3147 ok(hres == S_OK, "got: %08x\n", hres);
3148 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3149 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3150 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3151 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3152 SysFreeString(helpfile);
3153 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3154
3155 hres = ITypeInfo_GetFuncDesc(ti, 3, &pfuncdesc);
3156 ok(hres == S_OK, "got %08x\n", hres);
3157 ok(pfuncdesc->memid == 0x6001000b, "got %x\n", pfuncdesc->memid);
3158 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3159 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3160 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3161 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3162 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3163 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3164 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3165 ok(pfuncdesc->oVft == 6 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3166 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3167 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3168 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3169
3170 edesc = pfuncdesc->lprgelemdescParam;
3171 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3172 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3173 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3174 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3175 U(*edesc).paramdesc.pparamdescex->cBytes);
3176 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
3177 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3178 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
3179 "got: %s\n",
3180 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
3181
3182 edesc = pfuncdesc->lprgelemdescParam + 1;
3183 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3184 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3185 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3186 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3187 U(*edesc).paramdesc.pparamdescex->cBytes);
3188 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_BSTR, "got: %d\n",
3189 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3190 ok(!lstrcmpW(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue), nameW),
3191 "got: %s\n",
3192 wine_dbgstr_w(V_BSTR(&U(*edesc).paramdesc.pparamdescex->varDefaultValue)));
3193
3194 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3195 ok(hres == S_OK, "got: %08x\n", hres);
3196 ok(!memcmp(name, func2W, sizeof(func2W)), "got name: %s\n", wine_dbgstr_w(name));
3197 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3198 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3199 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3200 SysFreeString(name);
3201 SysFreeString(helpfile);
3202
3203 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
3204 ok(hres == S_OK, "got: %08x\n", hres);
3205 ok(cnames == 3, "got: %u\n", cnames);
3206 ok(!memcmp(names[0], func2W, sizeof(func2W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3207 ok(!memcmp(names[1], param1W, sizeof(func2W)), "got names[1]: %s\n", wine_dbgstr_w(names[1]));
3208 ok(!memcmp(names[2], param2W, sizeof(func2W)), "got names[2]: %s\n", wine_dbgstr_w(names[2]));
3209 SysFreeString(names[0]);
3210 SysFreeString(names[1]);
3211 SysFreeString(names[2]);
3212 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3213
3214 hres = ITypeInfo_GetFuncDesc(ti, 4, &pfuncdesc);
3215 ok(hres == S_OK, "got %08x\n", hres);
3216 ok(pfuncdesc->memid == 0x6001000c, "got %x\n", pfuncdesc->memid);
3217 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3218 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3219 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3220 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3221 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3222 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3223 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3224 ok(pfuncdesc->oVft == 7 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3225 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3226 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3227 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3228
3229 edesc = pfuncdesc->lprgelemdescParam;
3230 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3231 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3232 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3233 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3234 U(*edesc).paramdesc.pparamdescex->cBytes);
3235 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3236 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3237 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3238 "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3239
3240 edesc = pfuncdesc->lprgelemdescParam + 1;
3241 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3242 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3243 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3244 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3245 U(*edesc).paramdesc.pparamdescex->cBytes);
3246 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3247 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3248 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFFFFFF,
3249 "got: 0x%x\n", V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3250
3251 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3252 ok(hres == S_OK, "got: %08x\n", hres);
3253 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3254 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3255 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3256 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3257 SysFreeString(helpfile);
3258 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3259
3260 hres = ITypeInfo_GetFuncDesc(ti, 5, &pfuncdesc);
3261 ok(hres == S_OK, "got %08x\n", hres);
3262 ok(pfuncdesc->memid == 0x60010005, "got %x\n", pfuncdesc->memid);
3263 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3264 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3265 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3266 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3267 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3268 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3269 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3270 ok(pfuncdesc->oVft == 8 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3271 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3272 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3273 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3274
3275 edesc = pfuncdesc->lprgelemdescParam;
3276 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3277 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3278 U(*edesc).paramdesc.pparamdescex->cBytes);
3279 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3280 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3281 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x789, "got: 0x%x\n",
3282 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3283 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3284 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3285 ok(edesc->tdesc.vt == VT_USERDEFINED, "got: %d\n", edesc->tdesc.vt);
3286 ok(U(edesc->tdesc).hreftype == hreftype, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3287
3288 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3289 ok(hres == S_OK, "got: %08x\n", hres);
3290 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3291 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3292 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3293 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3294 SysFreeString(helpfile);
3295 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3296
3297 hres = ITypeInfo_GetFuncDesc(ti, 6, &pfuncdesc);
3298 ok(hres == S_OK, "got %08x\n", hres);
3299 ok(pfuncdesc->memid == 0x60010006, "got %x\n", pfuncdesc->memid);
3300 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3301 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3302 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3303 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3304 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3305 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3306 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3307 ok(pfuncdesc->oVft == 9 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3308 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3309 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VARIANT, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3310 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3311
3312 edesc = pfuncdesc->lprgelemdescParam;
3313 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3314 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3315 U(*edesc).paramdesc.pparamdescex->cBytes);
3316 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3317 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3318 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3319 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3320 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3321 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3322 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3323 ok(U(edesc->tdesc).hreftype == 0, "got: 0x%x\n", U(edesc->tdesc).hreftype);
3324
3325 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3326 ok(hres == S_OK, "got: %08x\n", hres);
3327 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3328 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3329 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3330 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3331 SysFreeString(helpfile);
3332 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3333
3334 hres = ITypeInfo_GetFuncDesc(ti, 7, &pfuncdesc);
3335 ok(hres == S_OK, "got %08x\n", hres);
3336 ok(pfuncdesc->memid == 0x60010009, "got %x\n", pfuncdesc->memid);
3337 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3338 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3339 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3340 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3341 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3342 ok(pfuncdesc->cParams == 2, "got %d\n", pfuncdesc->cParams);
3343 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3344 ok(pfuncdesc->oVft == 10 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3345 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3346 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3347 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3348
3349 edesc = pfuncdesc->lprgelemdescParam;
3350 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3351 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3352 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3353
3354 edesc = pfuncdesc->lprgelemdescParam + 1;
3355 ok(edesc->tdesc.vt == VT_UI2, "got: %d\n", edesc->tdesc.vt);
3356 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3357 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3358 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3359 U(*edesc).paramdesc.pparamdescex->cBytes);
3360 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_UI2, "got: %d\n",
3361 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3362 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0xFFFF, "got: 0x%x\n",
3363 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3364
3365 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3366 ok(hres == S_OK, "got: %08x\n", hres);
3367 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3368 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3369 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3370 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3371 SysFreeString(helpfile);
3372 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3373
3374 hres = ITypeInfo_GetFuncDesc(ti, 8, &pfuncdesc);
3375 ok(hres == S_OK, "got %08x\n", hres);
3376 ok(pfuncdesc->memid == 0x60010003, "got %x\n", pfuncdesc->memid);
3377 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3378 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3379 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3380 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3381 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3382 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3383 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3384 ok(pfuncdesc->oVft == 11 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3385 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3386 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3387 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3388
3389 edesc = pfuncdesc->lprgelemdescParam;
3390 ok(edesc->tdesc.vt == VT_INT, "got: %d\n", edesc->tdesc.vt);
3391 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3392 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3393 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3394 U(*edesc).paramdesc.pparamdescex->cBytes);
3395 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_I4, "got: %d\n",
3396 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3397 ok(V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x123, "got: 0x%x\n",
3398 V_I4(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3399
3400 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3401 ok(hres == S_OK, "got: %08x\n", hres);
3402 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3403 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3404 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3405 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3406 SysFreeString(helpfile);
3407 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3408
3409 hres = ITypeInfo_GetFuncDesc(ti, 9, &pfuncdesc);
3410 ok(hres == S_OK, "got %08x\n", hres);
3411 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3412 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3413 ok(pfuncdesc->lprgelemdescParam == NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3414 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3415 ok(pfuncdesc->invkind == INVOKE_PROPERTYGET, "got 0x%x\n", pfuncdesc->invkind);
3416 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3417 ok(pfuncdesc->cParams == 0, "got %d\n", pfuncdesc->cParams);
3418 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3419 ok(pfuncdesc->oVft == 12 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3420 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3421 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_BSTR, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3422 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3423
3424 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3425 ok(hres == S_OK, "got: %08x\n", hres);
3426 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3427 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3428 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3429 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3430 SysFreeString(name);
3431 SysFreeString(helpfile);
3432
3433 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
3434 ok(hres == S_OK, "got: %08x\n", hres);
3435 ok(cnames == 1, "got: %u\n", cnames);
3436 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3437 SysFreeString(names[0]);
3438 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3439
3440 hres = ITypeInfo_GetFuncDesc(ti, 10, &pfuncdesc);
3441 ok(hres == S_OK, "got %08x\n", hres);
3442 ok(pfuncdesc->memid == 0x60010007, "got %x\n", pfuncdesc->memid);
3443 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3444 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3445 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3446 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3447 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3448 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3449 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3450 ok(pfuncdesc->oVft == 13 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3451 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3452 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3453 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3454
3455 edesc = pfuncdesc->lprgelemdescParam;
3456 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
3457 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3458 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3459 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3460 ok(U(edesc->tdesc).lptdesc->vt == VT_PTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
3461 ok(U(*U(edesc->tdesc).lptdesc).lptdesc != NULL, "got: %p\n", U(*U(edesc->tdesc).lptdesc).lptdesc);
3462 ok(U(*U(edesc->tdesc).lptdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(*U(edesc->tdesc).lptdesc).lptdesc->vt);
3463
3464 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3465 ok(hres == S_OK, "got: %08x\n", hres);
3466 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3467 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3468 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3469 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3470 SysFreeString(helpfile);
3471 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3472
3473 hres = ITypeInfo_GetFuncDesc(ti, 11, &pfuncdesc);
3474 ok(hres == S_OK, "got %08x\n", hres);
3475 ok(pfuncdesc->memid == 0x60010004, "got %x\n", pfuncdesc->memid);
3476 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3477 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3478 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3479 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3480 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3481 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3482 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3483 ok(pfuncdesc->oVft == 14 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3484 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3485 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3486 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3487
3488 edesc = pfuncdesc->lprgelemdescParam;
3489 ok(edesc->tdesc.vt == VT_PTR, "got: %d\n", edesc->tdesc.vt);
3490 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FIN, "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3491 ok(U(*edesc).paramdesc.pparamdescex == NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3492 ok(U(edesc->tdesc).lptdesc != NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3493 ok(U(edesc->tdesc).lptdesc->vt == VT_BSTR, "got: %d\n", U(edesc->tdesc).lptdesc->vt);
3494
3495 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3496 ok(hres == S_OK, "got: %08x\n", hres);
3497 ok(name == NULL, "got name: %s\n", wine_dbgstr_w(name));
3498 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3499 ok(helpcontext == 0, "got helpcontext: 0x%x\n", helpcontext);
3500 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3501 SysFreeString(helpfile);
3502 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3503
3504 hres = ITypeInfo_GetFuncDesc(ti, 12, &pfuncdesc);
3505 ok(hres == S_OK, "got %08x\n", hres);
3506 ok(pfuncdesc->memid == 0, "got %x\n", pfuncdesc->memid);
3507 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3508 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3509 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3510 ok(pfuncdesc->invkind == INVOKE_PROPERTYPUT, "got 0x%x\n", pfuncdesc->invkind);
3511 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3512 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3513 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3514 ok(pfuncdesc->oVft == 15 * sizeof(void*), "got %d\n", pfuncdesc->oVft);
3515 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3516 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3517 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3518
3519 edesc = pfuncdesc->lprgelemdescParam;
3520 ok(edesc->tdesc.vt == VT_BSTR, "got: %d\n", edesc->tdesc.vt);
3521 ok(U(*edesc).idldesc.wIDLFlags == IDLFLAG_FIN, "got: %x\n", U(*edesc).idldesc.wIDLFlags);
3522
3523 hres = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &name, &docstring, &helpcontext, &helpfile);
3524 ok(hres == S_OK, "got: %08x\n", hres);
3525 ok(!memcmp(name, func1W, sizeof(func1W)), "got name: %s\n", wine_dbgstr_w(name));
3526 ok(docstring == NULL, "got docstring: %s\n", wine_dbgstr_w(docstring));
3527 ok(helpcontext == 0x201, "got helpcontext: 0x%x\n", helpcontext);
3528 ok(!memcmp(helpfile, helpfileW, sizeof(helpfileW)), "got helpfile: %s\n", wine_dbgstr_w(helpfile));
3529 SysFreeString(name);
3530 SysFreeString(helpfile);
3531
3532 hres = ITypeInfo_GetNames(ti, pfuncdesc->memid, names, ARRAY_SIZE(names), &cnames);
3533 ok(hres == S_OK, "got: %08x\n", hres);
3534 ok(cnames == 1, "got: %u\n", cnames);
3535 ok(!memcmp(names[0], func1W, sizeof(func1W)), "got names[0]: %s\n", wine_dbgstr_w(names[0]));
3536 SysFreeString(names[0]);
3537 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3538
3539 hres = ITypeInfo_GetFuncDesc(ti, 13, &pfuncdesc);
3540 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
3541
3542 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3543
3544 hres = ITypeLib_GetTypeInfo(tl, 1, &ti);
3545 ok(hres == S_OK, "got %08x\n", hres);
3546
3547 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3548 ok(hres == S_OK, "got %08x\n", hres);
3549 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3550 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3551 ok(typeattr->cFuncs == 2, "cFuncs = %d\n", typeattr->cFuncs);
3552 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3553 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3554 ok(typeattr->cbSizeVft == 0xaab8 || typeattr->cbSizeVft == 0xaab0 ||
3555 typeattr->cbSizeVft == 0x5560, "cbSizeVft = 0x%x\n", typeattr->cbSizeVft);
3556 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3557 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3558 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3559 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3560 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3561
3562 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3563 ok(hres == S_OK, "got %08x\n", hres);
3564
3565 hres = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
3566 ok(hres == S_OK, "got %08x\n", hres);
3567 ok(pfuncdesc->memid == 0x60020000, "got %x\n", pfuncdesc->memid);
3568 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3569 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3570 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3571 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3572 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3573 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3574 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3575 ok(pfuncdesc->oVft == (short)(0xaaa8 * sizeof(void *) / ptr_size), "got %x\n", pfuncdesc->oVft);
3576 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3577 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3578 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3579
3580 edesc = pfuncdesc->lprgelemdescParam;
3581 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3582 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3583 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3584 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3585 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3586 U(*edesc).paramdesc.pparamdescex->cBytes);
3587 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3588 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3589 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3590 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3591 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3592 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3593 ok(U(edesc->tdesc).lptdesc == NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3594 ok(U(edesc->tdesc).hreftype == 0, "got: %d\n", U(edesc->tdesc).hreftype);
3595 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3596
3597 hres = ITypeInfo_GetFuncDesc(ti, 1, &pfuncdesc);
3598 ok(hres == S_OK, "got %08x\n", hres);
3599 ok(pfuncdesc->memid == 0x60020001, "got %x\n", pfuncdesc->memid);
3600 ok(pfuncdesc->lprgscode == NULL, "got %p\n", pfuncdesc->lprgscode);
3601 ok(pfuncdesc->lprgelemdescParam != NULL, "got %p\n", pfuncdesc->lprgelemdescParam);
3602 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got 0x%x\n", pfuncdesc->funckind);
3603 ok(pfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", pfuncdesc->invkind);
3604 ok(pfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", pfuncdesc->callconv);
3605 ok(pfuncdesc->cParams == 1, "got %d\n", pfuncdesc->cParams);
3606 ok(pfuncdesc->cParamsOpt == 0, "got %d\n", pfuncdesc->cParamsOpt);
3607 ok(pfuncdesc->oVft == (short)((sys == SYS_WIN64 ? 0xaab0 : 0xaaac) * sizeof(void *) / ptr_size), "got %x\n", pfuncdesc->oVft);
3608 ok(pfuncdesc->cScodes == 0, "got %d\n", pfuncdesc->cScodes);
3609 ok(pfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", pfuncdesc->elemdescFunc.tdesc.vt);
3610 ok(pfuncdesc->wFuncFlags == 0, "got 0x%x\n", pfuncdesc->wFuncFlags);
3611
3612 edesc = pfuncdesc->lprgelemdescParam;
3613 ok(edesc->tdesc.vt == VT_VARIANT, "got: %d\n", edesc->tdesc.vt);
3614 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3615 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3616 ok(U(*edesc).paramdesc.pparamdescex != NULL, "got: %p\n", U(*edesc).paramdesc.pparamdescex);
3617 ok(U(*edesc).paramdesc.pparamdescex->cBytes == sizeof(PARAMDESCEX), "got: %d\n",
3618 U(*edesc).paramdesc.pparamdescex->cBytes);
3619 ok(V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == VT_INT, "got: %d\n",
3620 V_VT(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3621 ok(V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue) == 0x3, "got: 0x%x\n",
3622 V_UI2(&U(*edesc).paramdesc.pparamdescex->varDefaultValue));
3623 ok(U(*edesc).paramdesc.wParamFlags == PARAMFLAG_FHASDEFAULT,
3624 "got: 0x%x\n", U(*edesc).paramdesc.wParamFlags);
3625 ok(U(edesc->tdesc).lptdesc == NULL, "got: %p\n", U(edesc->tdesc).lptdesc);
3626 ok(U(edesc->tdesc).hreftype == 0, "got: %d\n", U(edesc->tdesc).hreftype);
3627 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
3628
3629 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3630
3631 hres = ITypeLib_GetTypeInfo(tl, 2, &ti);
3632 ok(hres == S_OK, "got %08x\n", hres);
3633
3634 hres = ITypeInfo_QueryInterface(ti, &IID_ITypeInfo2, (void**)&ti2);
3635 ok(hres == S_OK, "got %08x\n", hres);
3636
3637 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3638 ok(hres == S_OK, "got %08x\n", hres);
3639 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3640 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3641 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3642 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3643 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
3644 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3645 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3646 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3647 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3648 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3649 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3650
3651 VariantClear(&cust_data);
3652 hres = ITypeInfo2_GetCustData(ti2, &custguid, &cust_data);
3653 ok(hres == S_OK, "got %08x\n", hres);
3654 ok(V_VT(&cust_data) == VT_BSTR, "got wrong custdata type: %u\n", V_VT(&cust_data));
3655 ok(!lstrcmpW(V_BSTR(&cust_data), asdfW), "got wrong custdata value: %s\n", wine_dbgstr_w(V_BSTR(&cust_data)));
3656 SysFreeString(V_BSTR(&cust_data));
3657
3658 ITypeInfo2_Release(ti2);
3659 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3660
3661 hres = ITypeLib_GetTypeInfo(tl, 3, &ti);
3662 ok(hres == S_OK, "got %08x\n", hres);
3663
3664 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3665 ok(hres == S_OK, "got %08x\n", hres);
3666 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3667 ok(typeattr->typekind == TKIND_COCLASS, "typekind = %d\n", typeattr->typekind);
3668 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3669 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3670 ok(typeattr->cImplTypes == 3, "cImplTypes = %d\n", typeattr->cImplTypes);
3671 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3672 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3673 ok(typeattr->wTypeFlags == 0, "wTypeFlags = %d\n", typeattr->wTypeFlags);
3674 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3675 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3676 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3677
3678 hres = ITypeInfo_GetRefTypeOfImplType(ti, 0, &hreftype);
3679 ok(hres == S_OK, "got %08x\n", hres);
3680 ok(hreftype == 0, "got wrong hreftype: %x\n", hreftype);
3681
3682 hres = ITypeInfo_GetImplTypeFlags(ti, 0, &impltypeflags);
3683 ok(hres == S_OK, "got %08x\n", hres);
3684 ok(impltypeflags == IMPLTYPEFLAG_FDEFAULT, "got wrong flag: %x\n", impltypeflags);
3685
3686 hres = ITypeInfo_GetRefTypeOfImplType(ti, 1, &hreftype);
3687 ok(hres == S_OK, "got %08x\n", hres);
3688 ok(hreftype == 1, "got wrong hreftype: %x\n", hreftype);
3689
3690 hres = ITypeInfo_GetImplTypeFlags(ti, 1, &impltypeflags);
3691 ok(hres == S_OK, "got %08x\n", hres);
3692 ok(impltypeflags == IMPLTYPEFLAG_FRESTRICTED, "got wrong flag: %x\n", impltypeflags);
3693
3694 hres = ITypeInfo_GetRefTypeOfImplType(ti, 2, &hreftype);
3695 ok(hres == S_OK, "got %08x\n", hres);
3696 ok(hreftype == 1, "got wrong hreftype: %x\n", hreftype);
3697
3698 hres = ITypeInfo_GetImplTypeFlags(ti, 2, &impltypeflags);
3699 ok(hres == S_OK, "got %08x\n", hres);
3700 ok(impltypeflags == 0, "got wrong flag: %x\n", impltypeflags);
3701
3702 hres = ITypeInfo_GetRefTypeOfImplType(ti, 3, &hreftype);
3703 ok(hres == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hres);
3704
3705 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3706
3707 hres = ITypeLib_GetTypeInfo(tl, 4, &ti);
3708 ok(hres == S_OK, "got %08x\n", hres);
3709
3710 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3711 ok(hres == S_OK, "got %08x\n", hres);
3712 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3713 ok(typeattr->typekind == TKIND_DISPATCH, "typekind = %d\n", typeattr->typekind);
3714 ok(typeattr->cFuncs == 8, "cFuncs = %d\n", typeattr->cFuncs);
3715 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3716 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3717 ok(typeattr->cbSizeVft == 7 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3718 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3719 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL), "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3720 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3721 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3722 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3723
3724 hres = ITypeInfo_GetTypeComp(ti, &tcomp);
3725 ok(hres == S_OK, "got %08x\n", hres);
3726
3727 hres = ITypeInfo_QueryInterface(ti, &IID_ITypeComp, (void**)&tcomp2);
3728 ok(hres == S_OK, "got %08x\n", hres);
3729 ok(tcomp == tcomp2, "got %p, was %p\n", tcomp2, tcomp);
3730 ITypeComp_Release(tcomp2);
3731
3732 hres = ITypeComp_Bind(tcomp, invokeW, 0, INVOKE_FUNC, &interface1, &desckind, &bindptr);
3733 ok(hres == S_OK, "got %08x\n", hres);
3734 ok(desckind == DESCKIND_FUNCDESC, "got wrong desckind: 0x%x\n", desckind);
3735 ok(bindptr.lpfuncdesc->memid == 0x60010003, "got %x\n", bindptr.lpfuncdesc->memid);
3736 ok(bindptr.lpfuncdesc->lprgscode == NULL, "got %p\n", bindptr.lpfuncdesc->lprgscode);
3737 ok(bindptr.lpfuncdesc->lprgelemdescParam != NULL, "got %p\n", bindptr.lpfuncdesc->lprgelemdescParam);
3738 ok(bindptr.lpfuncdesc->funckind == FUNC_DISPATCH, "got 0x%x\n", bindptr.lpfuncdesc->funckind);
3739 ok(bindptr.lpfuncdesc->invkind == INVOKE_FUNC, "got 0x%x\n", bindptr.lpfuncdesc->invkind);
3740 ok(bindptr.lpfuncdesc->callconv == CC_STDCALL, "got 0x%x\n", bindptr.lpfuncdesc->callconv);
3741 ok(bindptr.lpfuncdesc->cParams == 8, "got %d\n", bindptr.lpfuncdesc->cParams);
3742 ok(bindptr.lpfuncdesc->cParamsOpt == 0, "got %d\n", bindptr.lpfuncdesc->cParamsOpt);
3743 ok(bindptr.lpfuncdesc->oVft == 6 * sizeof(void*), "got %x\n", bindptr.lpfuncdesc->oVft);
3744 ok(bindptr.lpfuncdesc->cScodes == 0, "got %d\n", bindptr.lpfuncdesc->cScodes);
3745 ok(bindptr.lpfuncdesc->elemdescFunc.tdesc.vt == VT_VOID, "got %d\n", bindptr.lpfuncdesc->elemdescFunc.tdesc.vt);
3746 ok(bindptr.lpfuncdesc->wFuncFlags == FUNCFLAG_FRESTRICTED, "got 0x%x\n", bindptr.lpfuncdesc->wFuncFlags);
3747
3748 ITypeInfo_ReleaseFuncDesc(interface1, bindptr.lpfuncdesc);
3749 ITypeInfo_Release(interface1);
3750 ITypeComp_Release(tcomp);
3751
3752 hres = ITypeInfo_GetRefTypeOfImplType(ti, -1, &hreftype);
3753 ok(hres == S_OK, "got %08x\n", hres);
3754 ok(hreftype == -2, "got wrong hreftype: %x\n", hreftype);
3755
3756 hres = ITypeInfo_GetRefTypeInfo(ti, hreftype, &interface1);
3757 ok(hres == S_OK, "got %08x\n", hres);
3758
3759 hres = ITypeInfo_GetTypeAttr(interface1, &typeattr);
3760 ok(hres == S_OK, "got %08x\n", hres);
3761 ok(typeattr->cbSizeInstance == sizeof(void*), "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3762 ok(typeattr->typekind == TKIND_INTERFACE, "typekind = %d\n", typeattr->typekind);
3763 ok(typeattr->cFuncs == 1, "cFuncs = %d\n", typeattr->cFuncs);
3764 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3765 ok(typeattr->cImplTypes == 1, "cImplTypes = %d\n", typeattr->cImplTypes);
3766 todo_wine_if(is_win64 && sys == SYS_WIN32)
3767 ok(typeattr->cbSizeVft == 8 * sizeof(void*), "cbSizeVft = %d\n", typeattr->cbSizeVft);
3768 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3769 ok(typeattr->wTypeFlags == (TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL), "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3770 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3771 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3772 ITypeInfo_ReleaseTypeAttr(interface1, typeattr);
3773
3774 ITypeInfo_Release(interface1);
3775
3776 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3777
3778 hres = ITypeLib_GetTypeInfo(tl, 5, &ti);
3779 ok(hres == S_OK, "got %08x\n", hres);
3780
3781 hres = ITypeInfo_GetTypeAttr(ti, &typeattr);
3782 ok(hres == S_OK, "got %08x\n", hres);
3783 ok(typeattr->cbSizeInstance == 8, "cbSizeInstance = %d\n", typeattr->cbSizeInstance);
3784 ok(typeattr->typekind == TKIND_ALIAS, "typekind = %d\n", typeattr->typekind);
3785 ok(typeattr->cFuncs == 0, "cFuncs = %d\n", typeattr->cFuncs);
3786 ok(typeattr->cVars == 0, "cVars = %d\n", typeattr->cVars);
3787 ok(typeattr->cImplTypes == 0, "cImplTypes = %d\n", typeattr->cImplTypes);
3788 ok(typeattr->cbSizeVft == 0, "cbSizeVft = %d\n", typeattr->cbSizeVft);
3789 ok(typeattr->cbAlignment == alignment, "cbAlignment = %d\n", typeattr->cbAlignment);
3790 ok(typeattr->wTypeFlags == 0, "wTypeFlags = 0x%x\n", typeattr->wTypeFlags);
3791 ok(typeattr->wMajorVerNum == 0, "wMajorVerNum = %d\n", typeattr->wMajorVerNum);
3792 ok(typeattr->wMinorVerNum == 0, "wMinorVerNum = %d\n", typeattr->wMinorVerNum);
3793 ok(typeattr->tdescAlias.vt == VT_R8, "Got wrong tdescAlias.vt: %u\n", typeattr->tdescAlias.vt);
3794 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
3795
3796 ok(ITypeInfo_Release(ti) == 0, "Object should be freed\n");
3797
3798 ok(ITypeLib_Release(tl)==0, "Object should be freed\n");
3799
3800 DeleteFileA(filename);
3801 }
3802
3803 #if 0 /* use this to generate more tests */
3804
3805 #define OLE_CHECK(x) { HRESULT hr = x; if (FAILED(hr)) { printf(#x "failed - %x\n", hr); return; } }
3806
3807 static char *dump_string(LPWSTR wstr)
3808 {
3809 int size = lstrlenW(wstr)+1;
3810 char *out = CoTaskMemAlloc(size);
3811 WideCharToMultiByte(20127, 0, wstr, -1, out, size, NULL, NULL);
3812 return out;
3813 }
3814
3815 struct map_entry
3816 {
3817 DWORD value;
3818 const char *name;
3819 };
3820
3821 #define MAP_ENTRY(x) { x, #x }
3822 static const struct map_entry tkind_map[] = {
3823 MAP_ENTRY(TKIND_ENUM),
3824 MAP_ENTRY(TKIND_RECORD),
3825 MAP_ENTRY(TKIND_MODULE),
3826 MAP_ENTRY(TKIND_INTERFACE),
3827 MAP_ENTRY(TKIND_DISPATCH),
3828 MAP_ENTRY(TKIND_COCLASS),
3829 MAP_ENTRY(TKIND_ALIAS),
3830 MAP_ENTRY(TKIND_UNION),
3831 MAP_ENTRY(TKIND_MAX),
3832 {0, NULL}
3833 };
3834
3835 static const struct map_entry funckind_map[] = {
3836 MAP_ENTRY(FUNC_VIRTUAL),
3837 MAP_ENTRY(FUNC_PUREVIRTUAL),
3838 MAP_ENTRY(FUNC_NONVIRTUAL),
3839 MAP_ENTRY(FUNC_STATIC),
3840 MAP_ENTRY(FUNC_DISPATCH),
3841 {0, NULL}
3842 };
3843
3844 static const struct map_entry invkind_map[] = {
3845 MAP_ENTRY(INVOKE_FUNC),
3846 MAP_ENTRY(INVOKE_PROPERTYGET),
3847 MAP_ENTRY(INVOKE_PROPERTYPUT),
3848 MAP_ENTRY(INVOKE_PROPERTYPUTREF),
3849 {0, NULL}
3850 };
3851
3852 static const struct map_entry callconv_map[] = {
3853 MAP_ENTRY(CC_FASTCALL),
3854 MAP_ENTRY(CC_CDECL),
3855 MAP_ENTRY(CC_PASCAL),
3856 MAP_ENTRY(CC_MACPASCAL),
3857 MAP_ENTRY(CC_STDCALL),
3858 MAP_ENTRY(CC_FPFASTCALL),
3859 MAP_ENTRY(CC_SYSCALL),
3860 MAP_ENTRY(CC_MPWCDECL),
3861 MAP_ENTRY(CC_MPWPASCAL),
3862 {0, NULL}
3863 };
3864
3865 static const struct map_entry vt_map[] = {
3866 MAP_ENTRY(VT_EMPTY),
3867 MAP_ENTRY(VT_NULL),
3868 MAP_ENTRY(VT_I2),
3869 MAP_ENTRY(VT_I4),
3870 MAP_ENTRY(VT_R4),
3871 MAP_ENTRY(VT_R8),
3872 MAP_ENTRY(VT_CY),
3873 MAP_ENTRY(VT_DATE),
3874 MAP_ENTRY(VT_BSTR),
3875 MAP_ENTRY(VT_DISPATCH),
3876 MAP_ENTRY(VT_ERROR),
3877 MAP_ENTRY(VT_BOOL),
3878 MAP_ENTRY(VT_VARIANT),
3879 MAP_ENTRY(VT_UNKNOWN),
3880 MAP_ENTRY(VT_DECIMAL),
3881 MAP_ENTRY(15),
3882 MAP_ENTRY(VT_I1),
3883 MAP_ENTRY(VT_UI1),
3884 MAP_ENTRY(VT_UI2),
3885 MAP_ENTRY(VT_UI4),
3886 MAP_ENTRY(VT_I8),
3887 MAP_ENTRY(VT_UI8),
3888 MAP_ENTRY(VT_INT),
3889 MAP_ENTRY(VT_UINT),
3890 MAP_ENTRY(VT_VOID),
3891 MAP_ENTRY(VT_HRESULT),
3892 MAP_ENTRY(VT_PTR),
3893 MAP_ENTRY(VT_SAFEARRAY),
3894 MAP_ENTRY(VT_CARRAY),
3895 MAP_ENTRY(VT_USERDEFINED),
3896 MAP_ENTRY(VT_LPSTR),
3897 MAP_ENTRY(VT_LPWSTR),
3898 MAP_ENTRY(VT_RECORD),
3899 MAP_ENTRY(VT_INT_PTR),
3900 MAP_ENTRY(VT_UINT_PTR),
3901 MAP_ENTRY(39),
3902 MAP_ENTRY(40),
3903 MAP_ENTRY(41),
3904 MAP_ENTRY(42),
3905 MAP_ENTRY(43),
3906 MAP_ENTRY(44),
3907 MAP_ENTRY(45),
3908 MAP_ENTRY(46),
3909 MAP_ENTRY(47),
3910 MAP_ENTRY(48),
3911 MAP_ENTRY(49),
3912 MAP_ENTRY(50),
3913 MAP_ENTRY(51),
3914 MAP_ENTRY(52),
3915 MAP_ENTRY(53),
3916 MAP_ENTRY(54),
3917 MAP_ENTRY(55),
3918 MAP_ENTRY(56),
3919 MAP_ENTRY(57),
3920 MAP_ENTRY(58),
3921 MAP_ENTRY(59),
3922 MAP_ENTRY(60),
3923 MAP_ENTRY(61),
3924 MAP_ENTRY(62),
3925 MAP_ENTRY(63),
3926 MAP_ENTRY(VT_FILETIME),
3927 MAP_ENTRY(VT_BLOB),
3928 MAP_ENTRY(VT_STREAM),
3929 MAP_ENTRY(VT_STORAGE),
3930 MAP_ENTRY(VT_STREAMED_OBJECT),
3931 MAP_ENTRY(VT_STORED_OBJECT),
3932 MAP_ENTRY(VT_BLOB_OBJECT),
3933 MAP_ENTRY(VT_CF),
3934 MAP_ENTRY(VT_CLSID),
3935 {0, NULL}
3936 };
3937
3938 #undef MAP_ENTRY
3939
3940 static const char *map_value(int val, const struct map_entry *map)
3941 {
3942 static int map_id;
3943 static char bufs[16][256];
3944 char *buf;
3945
3946 while (map->name)
3947 {
3948 if (map->value == val)
3949 return map->name;
3950 map++;
3951 }
3952
3953 buf = bufs[(map_id++)%16];
3954 sprintf(buf, "%d", val);
3955 return buf;
3956 }
3957
3958 static const char *dump_type_flags(DWORD flags)
3959 {
3960 static char buf[256];
3961
3962 if (!flags) return "0";
3963
3964 buf[0] = 0;
3965
3966 #define ADD_FLAG(x) if (flags & x) { if (buf[0]) strcat(buf, "|"); strcat(buf, #x); flags &= ~x; }
3967 ADD_FLAG(TYPEFLAG_FPROXY)
3968 ADD_FLAG(TYPEFLAG_FREVERSEBIND)
3969 ADD_FLAG(TYPEFLAG_FDISPATCHABLE)
3970 ADD_FLAG(TYPEFLAG_FREPLACEABLE)
3971 ADD_FLAG(TYPEFLAG_FAGGREGATABLE)
3972 ADD_FLAG(TYPEFLAG_FRESTRICTED)
3973 ADD_FLAG(TYPEFLAG_FOLEAUTOMATION)
3974 ADD_FLAG(TYPEFLAG_FNONEXTENSIBLE)
3975 ADD_FLAG(TYPEFLAG_FDUAL)
3976 ADD_FLAG(TYPEFLAG_FCONTROL)
3977 ADD_FLAG(TYPEFLAG_FHIDDEN)
3978 ADD_FLAG(TYPEFLAG_FPREDECLID)
3979 ADD_FLAG(TYPEFLAG_FLICENSED)
3980 ADD_FLAG(TYPEFLAG_FCANCREATE)
3981 ADD_FLAG(TYPEFLAG_FAPPOBJECT)
3982 #undef ADD_FLAG
3983
3984 assert(!flags);
3985 assert(strlen(buf) < sizeof(buf));
3986
3987 return buf;
3988 }
3989
3990 static char *print_size(BSTR name, TYPEATTR *attr)
3991 {
3992 static char buf[256];
3993
3994 switch (attr->typekind)
3995 {
3996 case TKIND_DISPATCH:
3997 case TKIND_INTERFACE:
3998 sprintf(buf, "sizeof(%s*)", dump_string(name));
3999 break;
4000
4001 case TKIND_RECORD:
4002 sprintf(buf, "sizeof(struct %s)", dump_string(name));
4003 break;
4004
4005 case TKIND_UNION:
4006 sprintf(buf, "sizeof(union %s)", dump_string(name));
4007 break;
4008
4009 case TKIND_ALIAS:
4010 sprintf(buf, "sizeof(%s)", dump_string(name));
4011 break;
4012
4013 case TKIND_ENUM:
4014 sprintf(buf, "4");
4015 break;
4016
4017 default:
4018 assert(0);
4019 return NULL;
4020 }
4021
4022 return buf;
4023 }
4024
4025 static char *print_align(BSTR name, TYPEATTR *attr)
4026 {
4027 static char buf[256];
4028
4029 switch (attr->typekind)
4030 {
4031 case TKIND_DISPATCH:
4032 case TKIND_INTERFACE:
4033 sprintf(buf, "TYPE_ALIGNMENT(%s*)", dump_string(name));
4034 break;
4035
4036 case TKIND_RECORD:
4037 sprintf(buf, "TYPE_ALIGNMENT(struct %s)", dump_string(name));
4038 break;
4039
4040 case TKIND_UNION:
4041 sprintf(buf, "TYPE_ALIGNMENT(union %s)", dump_string(name));
4042 break;
4043
4044 case TKIND_ALIAS:
4045 sprintf(buf, "TYPE_ALIGNMENT(%s)", dump_string(name));
4046 break;
4047
4048 case TKIND_ENUM:
4049 sprintf(buf, "4");
4050 break;
4051
4052 default:
4053 assert(0);
4054 return NULL;
4055 }
4056
4057 return buf;
4058 }
4059
4060 static const char *dump_param_flags(DWORD flags)
4061 {
4062 static char buf[256];
4063
4064 if (!flags) return "PARAMFLAG_NONE";
4065
4066 buf[0] = 0;
4067
4068 #define ADD_FLAG(x) if (flags & x) { if (buf[0]) strcat(buf, "|"); strcat(buf, #x); flags &= ~x; }
4069 ADD_FLAG(PARAMFLAG_FIN)
4070 ADD_FLAG(PARAMFLAG_FOUT)
4071 ADD_FLAG(PARAMFLAG_FLCID)
4072 ADD_FLAG(PARAMFLAG_FRETVAL)
4073 ADD_FLAG(PARAMFLAG_FOPT)
4074 ADD_FLAG(PARAMFLAG_FHASDEFAULT)
4075 ADD_FLAG(PARAMFLAG_FHASCUSTDATA)
4076 #undef ADD_FLAG
4077
4078 assert(!flags);
4079 assert(strlen(buf) < sizeof(buf));
4080
4081 return buf;
4082 }
4083
4084 static const char *dump_func_flags(DWORD flags)
4085 {
4086 static char buf[256];
4087
4088 if (!flags) return "0";
4089
4090 buf[0] = 0;
4091
4092 #define ADD_FLAG(x) if (flags & x) { if (buf[0]) strcat(buf, "|"); strcat(buf, #x); flags &= ~x; }
4093 ADD_FLAG(FUNCFLAG_FRESTRICTED)
4094 ADD_FLAG(FUNCFLAG_FSOURCE)
4095 ADD_FLAG(FUNCFLAG_FBINDABLE)
4096 ADD_FLAG(FUNCFLAG_FREQUESTEDIT)
4097 ADD_FLAG(FUNCFLAG_FDISPLAYBIND)
4098 ADD_FLAG(FUNCFLAG_FDEFAULTBIND)
4099 ADD_FLAG(FUNCFLAG_FHIDDEN)
4100 ADD_FLAG(FUNCFLAG_FUSESGETLASTERROR)
4101 ADD_FLAG(FUNCFLAG_FDEFAULTCOLLELEM)
4102 ADD_FLAG(FUNCFLAG_FUIDEFAULT)
4103 ADD_FLAG(FUNCFLAG_FNONBROWSABLE)
4104 ADD_FLAG(FUNCFLAG_FREPLACEABLE)
4105 ADD_FLAG(FUNCFLAG_FIMMEDIATEBIND)
4106 #undef ADD_FLAG
4107
4108 assert(!flags);
4109 assert(strlen(buf) < sizeof(buf));
4110
4111 return buf;
4112 }
4113
4114 static int get_href_type(ITypeInfo *info, TYPEDESC *tdesc)
4115 {
4116 int href_type = -1;
4117
4118 if (tdesc->vt == VT_USERDEFINED)
4119 {
4120 HRESULT hr;
4121 ITypeInfo *param;
4122 TYPEATTR *attr;
4123
4124 hr = ITypeInfo_GetRefTypeInfo(info, U(*tdesc).hreftype, ¶m);
4125 ok(hr == S_OK, "GetRefTypeInfo error %#x\n", hr);
4126 hr = ITypeInfo_GetTypeAttr(param, &attr);
4127 ok(hr == S_OK, "GetTypeAttr error %#x\n", hr);
4128
4129 href_type = attr->typekind;
4130
4131 ITypeInfo_ReleaseTypeAttr(param, attr);
4132 ITypeInfo_Release(param);
4133 }
4134
4135 return href_type;
4136 }
4137
4138 static void test_dump_typelib(const char *name)
4139 {
4140 WCHAR wszString[260];
4141 ITypeInfo *info;
4142 ITypeLib *lib;
4143 int count;
4144 int i;
4145
4146 MultiByteToWideChar(CP_ACP, 0, name, -1, wszString, 260);
4147 OLE_CHECK(LoadTypeLib(wszString, &lib));
4148
4149 printf("/*** Autogenerated data. Do not edit, change the generator above instead. ***/\n");
4150
4151 count = ITypeLib_GetTypeInfoCount(lib);
4152 for (i = 0; i < count; i++)
4153 {
4154 TYPEATTR *attr;
4155 BSTR name;
4156 DWORD help_ctx;
4157 int f = 0;
4158
4159 OLE_CHECK(ITypeLib_GetDocumentation(lib, i, &name, NULL, &help_ctx, NULL));
4160 printf("{\n"
4161 " \"%s\",\n", dump_string(name));
4162
4163 OLE_CHECK(ITypeLib_GetTypeInfo(lib, i, &info));
4164 OLE_CHECK(ITypeInfo_GetTypeAttr(info, &attr));
4165
4166 printf(" \"%s\",\n", wine_dbgstr_guid(&attr->guid));
4167
4168 printf(" /*kind*/ %s, /*flags*/ %s, /*align*/ %s, /*size*/ %s,\n"
4169 " /*helpctx*/ 0x%04x, /*version*/ 0x%08x, /*#vtbl*/ %d, /*#func*/ %d",
4170 map_value(attr->typekind, tkind_map), dump_type_flags(attr->wTypeFlags),
4171 print_align(name, attr), print_size(name, attr),
4172 help_ctx, MAKELONG(attr->wMinorVerNum, attr->wMajorVerNum),
4173 attr->cbSizeVft/sizeof(void*), attr->cFuncs);
4174
4175 if (attr->cFuncs) printf(",\n {\n");
4176 else printf("\n");
4177
4178 while (1)
4179 {
4180 FUNCDESC *desc;
4181 BSTR tab[256];
4182 UINT cNames;
4183 int p;
4184
4185 if (FAILED(ITypeInfo_GetFuncDesc(info, f, &desc)))
4186 break;
4187 printf(" {\n"
4188 " /*id*/ 0x%x, /*func*/ %s, /*inv*/ %s, /*call*/ %s,\n",
4189 desc->memid, map_value(desc->funckind, funckind_map), map_value(desc->invkind, invkind_map),
4190 map_value(desc->callconv, callconv_map));
4191 printf(" /*#param*/ %d, /*#opt*/ %d, /*vtbl*/ %d, /*#scodes*/ %d, /*flags*/ %s,\n",
4192 desc->cParams, desc->cParamsOpt, desc->oVft/sizeof(void*), desc->cScodes, dump_func_flags(desc->wFuncFlags));
4193 printf(" {%s, %s, %s}, /* ret */\n", map_value(desc->elemdescFunc.tdesc.vt, vt_map),
4194 map_value(get_href_type(info, &desc->elemdescFunc.tdesc), tkind_map), dump_param_flags(U(desc->elemdescFunc).paramdesc.wParamFlags));
4195 printf(" { /* params */\n");
4196 for (p = 0; p < desc->cParams; p++)
4197 {
4198 ELEMDESC e = desc->lprgelemdescParam[p];
4199 printf(" {%s, %s, %s},\n", map_value(e.tdesc.vt, vt_map),
4200 map_value(get_href_type(info, &e.tdesc), tkind_map), dump_param_flags(U(e).paramdesc.wParamFlags));
4201 }
4202 printf(" {-1, 0, 0}\n");
4203 printf(" },\n");
4204 printf(" { /* names */\n");
4205 OLE_CHECK(ITypeInfo_GetNames(info, desc->memid, tab, 256, &cNames));
4206 for (p = 0; p < cNames; p++)
4207 {
4208 printf(" \"%s\",\n", dump_string(tab[p]));
4209 SysFreeString(tab[p]);
4210 }
4211 printf(" NULL,\n");
4212 printf(" },\n");
4213 printf(" },\n");
4214 ITypeInfo_ReleaseFuncDesc(info, desc);
4215 f++;
4216 }
4217 if (attr->cFuncs) printf(" }\n");
4218 printf("},\n");
4219 ITypeInfo_ReleaseTypeAttr(info, attr);
4220 ITypeInfo_Release(info);
4221 SysFreeString(name);
4222 }
4223 ITypeLib_Release(lib);
4224 }
4225
4226 #else
4227
4228 typedef struct _element_info
4229 {
4230 VARTYPE vt;
4231 TYPEKIND type;
4232 USHORT wParamFlags;
4233 } element_info;
4234
4235 typedef struct _function_info
4236 {
4237 MEMBERID memid;
4238 FUNCKIND funckind;
4239 INVOKEKIND invkind;
4240 CALLCONV callconv;
4241 short cParams;
4242 short cParamsOpt;
4243 short vtbl_index;
4244 short cScodes;
4245 WORD wFuncFlags;
4246 element_info ret_type;
4247 element_info params[15];
4248 LPCSTR names[15];
4249 } function_info;
4250
4251 typedef struct _type_info
4252 {
4253 LPCSTR name;
4254 LPCSTR uuid;
4255 TYPEKIND type;
4256 WORD wTypeFlags;
4257 USHORT cbAlignment;
4258 USHORT cbSizeInstance;
4259 USHORT help_ctx;
4260 DWORD version;
4261 USHORT cbSizeVft;
4262 USHORT cFuncs;
4263 function_info funcs[20];
4264 } type_info;
4265
4266 static const type_info info[] = {
4267 /*** Autogenerated data. Do not edit, change the generator above instead. ***/
4268 {
4269 "g",
4270 "{b14b6bb5-904e-4ff9-b247-bd361f7a0001}",
4271 /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct g), /*size*/ sizeof(struct g),
4272 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4273 },
4274 {
4275 "test_iface",
4276 "{b14b6bb5-904e-4ff9-b247-bd361f7a0002}",
4277 /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(test_iface*), /*size*/ sizeof(test_iface*),
4278 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
4279 {
4280 {
4281 /*id*/ 0x60010000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4282 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0,
4283 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4284 { /* params */
4285 {VT_PTR, -1, PARAMFLAG_FIN},
4286 {-1, 0, 0}
4287 },
4288 { /* names */
4289 "Test",
4290 "ptr",
4291 NULL,
4292 },
4293 },
4294 }
4295 },
4296 {
4297 "parent_iface",
4298 "{b14b6bb5-904e-4ff9-b247-bd361f7aa001}",
4299 /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(parent_iface*), /*size*/ sizeof(parent_iface*),
4300 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 4, /*#func*/ 1,
4301 {
4302 {
4303 /*id*/ 0x60010000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4304 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ 0,
4305 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4306 { /* params */
4307 {VT_PTR, -1, PARAMFLAG_FOUT|PARAMFLAG_FRETVAL},
4308 {-1, 0, 0}
4309 },
4310 { /* names */
4311 "test1",
4312 "iface",
4313 NULL,
4314 },
4315 },
4316 }
4317 },
4318 {
4319 "child_iface",
4320 "{b14b6bb5-904e-4ff9-b247-bd361f7aa002}",
4321 /*kind*/ TKIND_INTERFACE, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(child_iface*), /*size*/ sizeof(child_iface*),
4322 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 5, /*#func*/ 1,
4323 {
4324 {
4325 /*id*/ 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4326 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ 0,
4327 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4328 { /* params */
4329 {-1, 0, 0}
4330 },
4331 { /* names */
4332 "test2",
4333 NULL,
4334 },
4335 },
4336 }
4337 },
4338 {
4339 "_n",
4340 "{016fe2ec-b2c8-45f8-b23b-39e53a753903}",
4341 /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct _n), /*size*/ sizeof(struct _n),
4342 /*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
4343 },
4344 {
4345 "n",
4346 "{016fe2ec-b2c8-45f8-b23b-39e53a753902}",
4347 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(n), /*size*/ sizeof(n),
4348 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4349 },
4350 {
4351 "nn",
4352 "{00000000-0000-0000-0000-000000000000}",
4353 /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(nn), /*size*/ sizeof(nn),
4354 /*helpctx*/ 0x0003, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
4355 },
4356 {
4357 "_m",
4358 "{016fe2ec-b2c8-45f8-b23b-39e53a753906}",
4359 /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct _m), /*size*/ sizeof(struct _m),
4360 /*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4361 },
4362 {
4363 "m",
4364 "{016fe2ec-b2c8-45f8-b23b-39e53a753905}",
4365 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(m), /*size*/ sizeof(m),
4366 /*helpctx*/ 0x0000, /*version*/ 0x00010002, /*#vtbl*/ 0, /*#func*/ 0
4367 },
4368 {
4369 "mm",
4370 "{00000000-0000-0000-0000-000000000000}",
4371 /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(mm), /*size*/ sizeof(mm),
4372 /*helpctx*/ 0x0003, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4373 },
4374 {
4375 "IDualIface",
4376 "{b14b6bb5-904e-4ff9-b247-bd361f7aaedd}",
4377 /*kind*/ TKIND_DISPATCH, /*flags*/ TYPEFLAG_FDISPATCHABLE|TYPEFLAG_FDUAL, /*align*/ TYPE_ALIGNMENT(IDualIface*), /*size*/ sizeof(IDualIface*),
4378 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 7, /*#func*/ 8,
4379 {
4380 {
4381 /*id*/ 0x60000000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4382 /*#param*/ 2, /*#opt*/ 0, /*vtbl*/ 0, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4383 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4384 { /* params */
4385 {VT_PTR, -1, PARAMFLAG_FIN},
4386 {VT_PTR, -1, PARAMFLAG_FOUT},
4387 {-1, 0, 0}
4388 },
4389 { /* names */
4390 "QueryInterface",
4391 "riid",
4392 "ppvObj",
4393 NULL,
4394 },
4395 },
4396 {
4397 /*id*/ 0x60000001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4398 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 1, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4399 {VT_UI4, -1, PARAMFLAG_NONE}, /* ret */
4400 { /* params */
4401 {-1, 0, 0}
4402 },
4403 { /* names */
4404 "AddRef",
4405 NULL,
4406 },
4407 },
4408 {
4409 /*id*/ 0x60000002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4410 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 2, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4411 {VT_UI4, -1, PARAMFLAG_NONE}, /* ret */
4412 { /* params */
4413 {-1, 0, 0}
4414 },
4415 { /* names */
4416 "Release",
4417 NULL,
4418 },
4419 },
4420 {
4421 /*id*/ 0x60010000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4422 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 3, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4423 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4424 { /* params */
4425 {VT_PTR, -1, PARAMFLAG_FOUT},
4426 {-1, 0, 0}
4427 },
4428 { /* names */
4429 "GetTypeInfoCount",
4430 "pctinfo",
4431 NULL,
4432 },
4433 },
4434 {
4435 /*id*/ 0x60010001, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4436 /*#param*/ 3, /*#opt*/ 0, /*vtbl*/ 4, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4437 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4438 { /* params */
4439 {VT_UINT, -1, PARAMFLAG_FIN},
4440 {VT_UI4, -1, PARAMFLAG_FIN},
4441 {VT_PTR, -1, PARAMFLAG_FOUT},
4442 {-1, 0, 0}
4443 },
4444 { /* names */
4445 "GetTypeInfo",
4446 "itinfo",
4447 "lcid",
4448 "pptinfo",
4449 NULL,
4450 },
4451 },
4452 {
4453 /*id*/ 0x60010002, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4454 /*#param*/ 5, /*#opt*/ 0, /*vtbl*/ 5, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4455 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4456 { /* params */
4457 {VT_PTR, -1, PARAMFLAG_FIN},
4458 {VT_PTR, -1, PARAMFLAG_FIN},
4459 {VT_UINT, -1, PARAMFLAG_FIN},
4460 {VT_UI4, -1, PARAMFLAG_FIN},
4461 {VT_PTR, -1, PARAMFLAG_FOUT},
4462 {-1, 0, 0}
4463 },
4464 { /* names */
4465 "GetIDsOfNames",
4466 "riid",
4467 "rgszNames",
4468 "cNames",
4469 "lcid",
4470 "rgdispid",
4471 NULL,
4472 },
4473 },
4474 {
4475 /*id*/ 0x60010003, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4476 /*#param*/ 8, /*#opt*/ 0, /*vtbl*/ 6, /*#scodes*/ 0, /*flags*/ FUNCFLAG_FRESTRICTED,
4477 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4478 { /* params */
4479 {VT_I4, -1, PARAMFLAG_FIN},
4480 {VT_PTR, -1, PARAMFLAG_FIN},
4481 {VT_UI4, -1, PARAMFLAG_FIN},
4482 {VT_UI2, -1, PARAMFLAG_FIN},
4483 {VT_PTR, -1, PARAMFLAG_FIN},
4484 {VT_PTR, -1, PARAMFLAG_FOUT},
4485 {VT_PTR, -1, PARAMFLAG_FOUT},
4486 {VT_PTR, -1, PARAMFLAG_FOUT},
4487 {-1, 0, 0}
4488 },
4489 { /* names */
4490 "Invoke",
4491 "dispidMember",
4492 "riid",
4493 "lcid",
4494 "wFlags",
4495 "pdispparams",
4496 "pvarResult",
4497 "pexcepinfo",
4498 "puArgErr",
4499 NULL,
4500 },
4501 },
4502 {
4503 /*id*/ 0x60020000, /*func*/ FUNC_DISPATCH, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4504 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0,
4505 {VT_VOID, -1, PARAMFLAG_NONE}, /* ret */
4506 { /* params */
4507 {-1, 0, 0}
4508 },
4509 { /* names */
4510 "Test",
4511 NULL,
4512 },
4513 },
4514 }
4515 },
4516 {
4517 "ISimpleIface",
4518 "{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac009}",
4519 /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ TYPE_ALIGNMENT(ISimpleIface*), /*size*/ sizeof(ISimpleIface*),
4520 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 8, /*#func*/ 1,
4521 {
4522 {
4523 /*id*/ 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4524 /*#param*/ 0, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0,
4525 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4526 { /* params */
4527 {-1, 0, 0}
4528 },
4529 { /* names */
4530 "Test",
4531 NULL,
4532 },
4533 },
4534 }
4535 },
4536 {
4537 "test_struct",
4538 "{4029f190-ca4a-4611-aeb9-673983cb96dd}",
4539 /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct test_struct), /*size*/ sizeof(struct test_struct),
4540 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4541 },
4542 {
4543 "test_struct2",
4544 "{4029f190-ca4a-4611-aeb9-673983cb96de}",
4545 /*kind*/ TKIND_RECORD, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(struct test_struct2), /*size*/ sizeof(struct test_struct2),
4546 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4547 },
4548 {
4549 "t_INT",
4550 "{016fe2ec-b2c8-45f8-b23b-39e53a75396a}",
4551 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED, /*align*/ TYPE_ALIGNMENT(t_INT), /*size*/ sizeof(t_INT),
4552 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4553 },
4554 {
4555 "a",
4556 "{00000000-0000-0000-0000-000000000000}",
4557 /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(a), /*size*/ sizeof(a),
4558 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4559 },
4560 {
4561 "_a",
4562 "{00000000-0000-0000-0000-000000000000}",
4563 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4564 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4565 },
4566 {
4567 "aa",
4568 "{00000000-0000-0000-0000-000000000000}",
4569 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4570 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4571 },
4572 {
4573 "_b",
4574 "{00000000-0000-0000-0000-000000000000}",
4575 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4576 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4577 },
4578 {
4579 "bb",
4580 "{00000000-0000-0000-0000-000000000000}",
4581 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4582 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4583 },
4584 {
4585 "c",
4586 "{016fe2ec-b2c8-45f8-b23b-39e53a75396b}",
4587 /*kind*/ TKIND_ALIAS, /*flags*/ 0, /*align*/ TYPE_ALIGNMENT(c), /*size*/ sizeof(c),
4588 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4589 },
4590 {
4591 "_c",
4592 "{00000000-0000-0000-0000-000000000000}",
4593 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4594 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4595 },
4596 {
4597 "cc",
4598 "{016fe2ec-b2c8-45f8-b23b-39e53a75396c}",
4599 /*kind*/ TKIND_ENUM, /*flags*/ 0, /*align*/ 4, /*size*/ 4,
4600 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4601 },
4602 {
4603 "d",
4604 "{016fe2ec-b2c8-45f8-b23b-39e53a75396d}",
4605 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(d), /*size*/ sizeof(d),
4606 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4607 },
4608 {
4609 "_d",
4610 "{00000000-0000-0000-0000-000000000000}",
4611 /*kind*/ TKIND_ENUM, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
4612 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4613 },
4614 {
4615 "dd",
4616 "{016fe2ec-b2c8-45f8-b23b-39e53a75396e}",
4617 /*kind*/ TKIND_ENUM, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ 4, /*size*/ 4,
4618 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4619 },
4620 {
4621 "e",
4622 "{016fe2ec-b2c8-45f8-b23b-39e53a753970}",
4623 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(e), /*size*/ sizeof(e),
4624 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4625 },
4626 {
4627 "_e",
4628 "{00000000-0000-0000-0000-000000000000}",
4629 /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(struct _e), /*size*/ sizeof(struct _e),
4630 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4631 },
4632 {
4633 "ee",
4634 "{016fe2ec-b2c8-45f8-b23b-39e53a753971}",
4635 /*kind*/ TKIND_RECORD, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(struct ee), /*size*/ sizeof(struct ee),
4636 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4637 },
4638 {
4639 "f",
4640 "{016fe2ec-b2c8-45f8-b23b-39e53a753972}",
4641 /*kind*/ TKIND_ALIAS, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(f), /*size*/ sizeof(f),
4642 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4643 },
4644 {
4645 "_f",
4646 "{00000000-0000-0000-0000-000000000000}",
4647 /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(union _f), /*size*/ sizeof(union _f),
4648 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4649 },
4650 {
4651 "ff",
4652 "{016fe2ec-b2c8-45f8-b23b-39e53a753973}",
4653 /*kind*/ TKIND_UNION, /*flags*/ TYPEFLAG_FRESTRICTED|TYPEFLAG_FHIDDEN, /*align*/ TYPE_ALIGNMENT(union ff), /*size*/ sizeof(union ff),
4654 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 0, /*#func*/ 0
4655 },
4656 {
4657 "ITestIface",
4658 "{ec5dfcd6-eeb0-4cd6-b51e-8030e1dac00a}",
4659 /*kind*/ TKIND_INTERFACE, /*flags*/ TYPEFLAG_FDISPATCHABLE, /*align*/ TYPE_ALIGNMENT(ITestIface*), /*size*/ sizeof(ITestIface*),
4660 /*helpctx*/ 0x0000, /*version*/ 0x00000000, /*#vtbl*/ 13, /*#func*/ 6,
4661 {
4662 {
4663 /*id*/ 0x60020000, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4664 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 7, /*#scodes*/ 0, /*flags*/ 0,
4665 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4666 { /* params */
4667 {VT_USERDEFINED, TKIND_ALIAS, PARAMFLAG_NONE},
4668 {-1, 0, 0}
4669 },
4670 { /* names */
4671 "test1",
4672 "value",
4673 NULL,
4674 },
4675 },
4676 {
4677 /*id*/ 0x60020001, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4678 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 8, /*#scodes*/ 0, /*flags*/ 0,
4679 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4680 { /* params */
4681 {VT_USERDEFINED, TKIND_ENUM, PARAMFLAG_NONE},
4682 {-1, 0, 0}
4683 },
4684 { /* names */
4685 "test2",
4686 "value",
4687 NULL,
4688 },
4689 },
4690 {
4691 /*id*/ 0x60020002, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4692 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 9, /*#scodes*/ 0, /*flags*/ 0,
4693 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4694 { /* params */
4695 {VT_USERDEFINED, TKIND_ALIAS, PARAMFLAG_NONE},
4696 {-1, 0, 0}
4697 },
4698 { /* names */
4699 "test3",
4700 "value",
4701 NULL,
4702 },
4703 },
4704 {
4705 /*id*/ 0x60020003, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4706 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 10, /*#scodes*/ 0, /*flags*/ 0,
4707 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4708 { /* params */
4709 {VT_USERDEFINED, TKIND_ALIAS, PARAMFLAG_NONE},
4710 {-1, 0, 0}
4711 },
4712 { /* names */
4713 "test4",
4714 "value",
4715 NULL,
4716 },
4717 },
4718 {
4719 /*id*/ 0x60020004, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4720 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 11, /*#scodes*/ 0, /*flags*/ 0,
4721 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4722 { /* params */
4723 {VT_USERDEFINED, TKIND_ALIAS, PARAMFLAG_NONE},
4724 {-1, 0, 0}
4725 },
4726 { /* names */
4727 "test5",
4728 "value",
4729 NULL,
4730 },
4731 },
4732 {
4733 /*id*/ 0x60020005, /*func*/ FUNC_PUREVIRTUAL, /*inv*/ INVOKE_FUNC, /*call*/ CC_STDCALL,
4734 /*#param*/ 1, /*#opt*/ 0, /*vtbl*/ 12, /*#scodes*/ 0, /*flags*/ 0,
4735 {VT_HRESULT, -1, PARAMFLAG_NONE}, /* ret */
4736 { /* params */
4737 {VT_USERDEFINED, TKIND_ALIAS, PARAMFLAG_NONE},
4738 {-1, 0, 0}
4739 },
4740 { /* names */
4741 "test6",
4742 "value",
4743 NULL,
4744 },
4745 },
4746 }
4747 }
4748 };
4749
4750 #define check_type(elem, info) { \
4751 expect_int((elem)->tdesc.vt, (info)->vt); \
4752 expect_hex(U(*(elem)).paramdesc.wParamFlags, (info)->wParamFlags); \
4753 }
4754
test_dump_typelib(const char * name)4755 static void test_dump_typelib(const char *name)
4756 {
4757 WCHAR wszName[MAX_PATH];
4758 ITypeLib *typelib;
4759 int ticount = ARRAY_SIZE(info);
4760 int iface, func;
4761
4762 MultiByteToWideChar(CP_ACP, 0, name, -1, wszName, MAX_PATH);
4763 ole_check(LoadTypeLibEx(wszName, REGKIND_NONE, &typelib));
4764 expect_eq(ITypeLib_GetTypeInfoCount(typelib), ticount, UINT, "%d");
4765 for (iface = 0; iface < ticount; iface++)
4766 {
4767 const type_info *ti = &info[iface];
4768 ITypeInfo *typeinfo;
4769 TYPEATTR *typeattr;
4770 BSTR bstrIfName;
4771 DWORD help_ctx;
4772
4773 trace("Interface %s\n", ti->name);
4774 ole_check(ITypeLib_GetTypeInfo(typelib, iface, &typeinfo));
4775 ole_check(ITypeLib_GetDocumentation(typelib, iface, &bstrIfName, NULL, &help_ctx, NULL));
4776 expect_wstr_acpval(bstrIfName, ti->name);
4777 SysFreeString(bstrIfName);
4778
4779 ole_check(ITypeInfo_GetTypeAttr(typeinfo, &typeattr));
4780 expect_int(typeattr->typekind, ti->type);
4781 expect_hex(typeattr->wTypeFlags, ti->wTypeFlags);
4782 expect_int(typeattr->cbAlignment, ti->cbAlignment);
4783 expect_int(typeattr->cbSizeInstance, ti->cbSizeInstance);
4784 expect_int(help_ctx, ti->help_ctx);
4785 expect_int(MAKELONG(typeattr->wMinorVerNum, typeattr->wMajorVerNum), ti->version);
4786 expect_int(typeattr->cbSizeVft, ti->cbSizeVft * sizeof(void*));
4787 expect_int(typeattr->cFuncs, ti->cFuncs);
4788
4789 /* compare type uuid */
4790 if (ti->uuid && *ti->uuid)
4791 {
4792 WCHAR guidW[39];
4793 ITypeInfo *typeinfo2;
4794 HRESULT hr;
4795 GUID guid;
4796
4797 MultiByteToWideChar(CP_ACP, 0, ti->uuid, -1, guidW, ARRAY_SIZE(guidW));
4798 IIDFromString(guidW, &guid);
4799 expect_guid(&guid, &typeattr->guid);
4800
4801 /* check that it's possible to search using this uuid */
4802 typeinfo2 = NULL;
4803 hr = ITypeLib_GetTypeInfoOfGuid(typelib, &guid, &typeinfo2);
4804 ok(hr == S_OK || (IsEqualGUID(&guid, &IID_NULL) && hr == TYPE_E_ELEMENTNOTFOUND), "got 0x%08x\n", hr);
4805 if (hr == S_OK) ITypeInfo_Release(typeinfo2);
4806 }
4807
4808 for (func = 0; func < typeattr->cFuncs; func++)
4809 {
4810 const function_info *fn_info = &ti->funcs[func];
4811 FUNCDESC *desc;
4812 BSTR namesTab[256];
4813 UINT cNames;
4814 int i;
4815
4816 trace("Function %s\n", fn_info->names[0]);
4817 ole_check(ITypeInfo_GetFuncDesc(typeinfo, func, &desc));
4818 expect_int(desc->memid, fn_info->memid);
4819 expect_int(desc->funckind, fn_info->funckind);
4820 expect_int(desc->invkind, fn_info->invkind);
4821 expect_int(desc->callconv, fn_info->callconv);
4822 expect_int(desc->cParams, fn_info->cParams);
4823 expect_int(desc->cParamsOpt, fn_info->cParamsOpt);
4824 expect_int(desc->oVft, fn_info->vtbl_index * sizeof(void*));
4825 expect_int(desc->cScodes, fn_info->cScodes);
4826 expect_int(desc->wFuncFlags, fn_info->wFuncFlags);
4827 ole_check(ITypeInfo_GetNames(typeinfo, desc->memid, namesTab, 256, &cNames));
4828 for (i = 0; i < cNames; i++)
4829 {
4830 expect_wstr_acpval(namesTab[i], fn_info->names[i]);
4831 SysFreeString(namesTab[i]);
4832 }
4833 expect_null(fn_info->names[cNames]);
4834
4835 check_type(&desc->elemdescFunc, &fn_info->ret_type);
4836 for (i = 0 ; i < desc->cParams; i++)
4837 {
4838 check_type(&desc->lprgelemdescParam[i], &fn_info->params[i]);
4839
4840 if (desc->lprgelemdescParam[i].tdesc.vt == VT_USERDEFINED)
4841 {
4842 ITypeInfo *param;
4843 TYPEATTR *var_attr;
4844
4845 ole_check(ITypeInfo_GetRefTypeInfo(typeinfo, U(desc->lprgelemdescParam[i].tdesc).hreftype, ¶m));
4846 ole_check(ITypeInfo_GetTypeAttr(param, &var_attr));
4847
4848 ok(var_attr->typekind == fn_info->params[i].type, "expected %#x, got %#x\n", fn_info->params[i].type, var_attr->typekind);
4849
4850 ITypeInfo_ReleaseTypeAttr(param, var_attr);
4851 ITypeInfo_Release(param);
4852 }
4853 }
4854 expect_int(fn_info->params[desc->cParams].vt, (VARTYPE)-1);
4855
4856 ITypeInfo_ReleaseFuncDesc(typeinfo, desc);
4857 }
4858
4859 ITypeInfo_ReleaseTypeAttr(typeinfo, typeattr);
4860 ITypeInfo_Release(typeinfo);
4861 }
4862 ITypeLib_Release(typelib);
4863 }
4864
4865 #endif
4866
test_create_typelib_lcid(LCID lcid)4867 static void test_create_typelib_lcid(LCID lcid)
4868 {
4869 char filename[MAX_PATH];
4870 WCHAR name[MAX_PATH];
4871 HRESULT hr;
4872 ICreateTypeLib2 *tl;
4873 HANDLE file;
4874 DWORD msft_header[8];
4875 ITypeLib *typelib;
4876 TLIBATTR *attr;
4877 DWORD read;
4878
4879 GetTempFileNameA( ".", "tlb", 0, filename );
4880 MultiByteToWideChar(CP_ACP, 0, filename, -1, name, MAX_PATH);
4881
4882 hr = CreateTypeLib2(SYS_WIN32, name, &tl);
4883 ok(hr == S_OK, "got %08x\n", hr);
4884
4885 hr = ICreateTypeLib2_QueryInterface(tl, &IID_ITypeLib, (void**)&typelib);
4886 ok(hr == S_OK, "got %08x\n", hr);
4887
4888 hr = ITypeLib_GetLibAttr(typelib, &attr);
4889 ok(hr == S_OK, "got %08x\n", hr);
4890 ok(attr->wLibFlags == 0, "flags 0x%x\n", attr->wLibFlags);
4891 ITypeLib_ReleaseTLibAttr(typelib, attr);
4892
4893 hr = ICreateTypeLib2_SetLcid(tl, lcid);
4894 ok(hr == S_OK, "got %08x\n", hr);
4895
4896 hr = ICreateTypeLib2_SetVersion(tl, 3, 4);
4897 ok(hr == S_OK, "got %08x\n", hr);
4898
4899 hr = ICreateTypeLib2_SaveAllChanges(tl);
4900 ok(hr == S_OK, "got %08x\n", hr);
4901
4902 hr = ITypeLib_GetLibAttr(typelib, &attr);
4903 ok(hr == S_OK, "got %08x\n", hr);
4904 ok(attr->wLibFlags == 0, "flags 0x%x\n", attr->wLibFlags);
4905 ITypeLib_ReleaseTLibAttr(typelib, attr);
4906
4907 ITypeLib_Release(typelib);
4908 ICreateTypeLib2_Release(tl);
4909
4910 file = CreateFileA( filename, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
4911 ok( file != INVALID_HANDLE_VALUE, "file creation failed\n" );
4912
4913 ReadFile( file, msft_header, sizeof(msft_header), &read, NULL );
4914 ok(read == sizeof(msft_header), "read %d\n", read);
4915 CloseHandle( file );
4916
4917 ok(msft_header[0] == 0x5446534d, "got %08x\n", msft_header[0]);
4918 ok(msft_header[1] == 0x00010002, "got %08x\n", msft_header[1]);
4919 ok(msft_header[2] == 0xffffffff, "got %08x\n", msft_header[2]);
4920 ok(msft_header[3] == (lcid ? lcid : 0x409), "got %08x (lcid %08x)\n", msft_header[3], lcid);
4921 ok(msft_header[4] == lcid, "got %08x (lcid %08x)\n", msft_header[4], lcid);
4922 ok(msft_header[6] == 0x00040003, "got %08x\n", msft_header[6]);
4923 ok(msft_header[7] == 0, "got %08x\n", msft_header[7]);
4924
4925 /* check flags after loading */
4926 hr = LoadTypeLib(name, &typelib);
4927 ok(hr == S_OK, "got %08x\n", hr);
4928
4929 hr = ITypeLib_GetLibAttr(typelib, &attr);
4930 ok(hr == S_OK, "got %08x\n", hr);
4931 ok(attr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "flags 0x%x\n", attr->wLibFlags);
4932 ITypeLib_ReleaseTLibAttr(typelib, attr);
4933 ITypeLib_Release(typelib);
4934
4935 DeleteFileA(filename);
4936 }
4937
test_create_typelibs(void)4938 static void test_create_typelibs(void)
4939 {
4940 test_create_typelib_lcid(LOCALE_SYSTEM_DEFAULT);
4941 test_create_typelib_lcid(LOCALE_USER_DEFAULT);
4942 test_create_typelib_lcid(LOCALE_NEUTRAL);
4943
4944 test_create_typelib_lcid(0x009);
4945 test_create_typelib_lcid(0x409);
4946 test_create_typelib_lcid(0x809);
4947
4948 test_create_typelib_lcid(0x007);
4949 test_create_typelib_lcid(0x407);
4950 }
4951
4952
test_register_typelib(BOOL system_registration)4953 static void test_register_typelib(BOOL system_registration)
4954 {
4955 HRESULT hr;
4956 WCHAR filename[MAX_PATH];
4957 const char *filenameA;
4958 ITypeLib *typelib;
4959 WCHAR uuidW[40];
4960 char key_name[MAX_PATH], uuid[40];
4961 LONG ret, expect_ret;
4962 UINT count, i;
4963 HKEY hkey;
4964 REGSAM opposite = (sizeof(void*) == 8 ? KEY_WOW64_32KEY : KEY_WOW64_64KEY);
4965 BOOL is_wow64 = FALSE;
4966 LONG size;
4967 struct
4968 {
4969 TYPEKIND kind;
4970 WORD flags;
4971 } attrs[] =
4972 {
4973 { TKIND_INTERFACE, 0 },
4974 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
4975 { TKIND_INTERFACE, TYPEFLAG_FOLEAUTOMATION },
4976 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FOLEAUTOMATION },
4977 { TKIND_DISPATCH, TYPEFLAG_FDUAL },
4978 { TKIND_DISPATCH, TYPEFLAG_FDUAL },
4979 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
4980 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE | TYPEFLAG_FDUAL },
4981 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4982 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4983 { TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
4984 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
4985 { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
4986 { TKIND_RECORD, 0 }
4987 };
4988
4989 trace("Starting %s typelib registration tests\n",
4990 system_registration ? "system" : "user");
4991
4992 if (!system_registration && (!pRegisterTypeLibForUser || !pUnRegisterTypeLibForUser))
4993 {
4994 win_skip("User typelib registration functions are not available\n");
4995 return;
4996 }
4997
4998 if (pIsWow64Process)
4999 pIsWow64Process(GetCurrentProcess(), &is_wow64);
5000
5001 filenameA = create_test_typelib(3);
5002 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filename, MAX_PATH);
5003
5004 hr = LoadTypeLibEx(filename, REGKIND_NONE, &typelib);
5005 ok(hr == S_OK, "got %08x\n", hr);
5006
5007 if (system_registration)
5008 hr = RegisterTypeLib(typelib, filename, NULL);
5009 else
5010 hr = pRegisterTypeLibForUser(typelib, filename, NULL);
5011 if (hr == TYPE_E_REGISTRYACCESS)
5012 {
5013 win_skip("Insufficient privileges to register typelib in the registry\n");
5014 ITypeLib_Release(typelib);
5015 DeleteFileA(filenameA);
5016 return;
5017 }
5018 ok(hr == S_OK, "got %08x\n", hr);
5019
5020 count = ITypeLib_GetTypeInfoCount(typelib);
5021 ok(count == 14, "got %d\n", count);
5022
5023 for(i = 0; i < count; i++)
5024 {
5025 ITypeInfo *typeinfo;
5026 TYPEATTR *attr;
5027
5028 hr = ITypeLib_GetTypeInfo(typelib, i, &typeinfo);
5029 ok(hr == S_OK, "got %08x\n", hr);
5030
5031 hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
5032 ok(hr == S_OK, "got %08x\n", hr);
5033
5034 ok(attr->typekind == attrs[i].kind, "%d: got kind %d\n", i, attr->typekind);
5035 ok(attr->wTypeFlags == attrs[i].flags, "%d: got flags %04x\n", i, attr->wTypeFlags);
5036
5037 if(attr->typekind == TKIND_DISPATCH && (attr->wTypeFlags & TYPEFLAG_FDUAL))
5038 {
5039 HREFTYPE reftype;
5040 ITypeInfo *dual_info;
5041 TYPEATTR *dual_attr;
5042
5043 hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, -1, &reftype);
5044 ok(hr == S_OK, "got %08x\n", hr);
5045
5046 hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &dual_info);
5047 ok(hr == S_OK, "got %08x\n", hr);
5048
5049 hr = ITypeInfo_GetTypeAttr(dual_info, &dual_attr);
5050 ok(hr == S_OK, "got %08x\n", hr);
5051
5052 ok(dual_attr->typekind == TKIND_INTERFACE, "%d: got kind %d\n", i, dual_attr->typekind);
5053 ok(dual_attr->wTypeFlags == (attrs[i].flags | TYPEFLAG_FOLEAUTOMATION),
5054 "%d: got flags %04x\n", i, dual_attr->wTypeFlags);
5055
5056 ITypeInfo_ReleaseTypeAttr(dual_info, dual_attr);
5057 ITypeInfo_Release(dual_info);
5058
5059 }
5060
5061 StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
5062 WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
5063 sprintf(key_name, "Interface\\%s", uuid);
5064
5065 /* All dispinterfaces will be registered (this includes dual interfaces) as well
5066 as oleautomation interfaces */
5067 if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
5068 attr->typekind == TKIND_DISPATCH)
5069 expect_ret = ERROR_SUCCESS;
5070 else
5071 expect_ret = ERROR_FILE_NOT_FOUND;
5072
5073 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ, &hkey);
5074 ok(ret == expect_ret, "%d: got %d\n", i, ret);
5075 if (ret == ERROR_SUCCESS)
5076 {
5077 size = sizeof(uuid);
5078 ret = RegQueryValueA(hkey, "ProxyStubClsid32", uuid, &size);
5079 ok(!ret, "Failed to get proxy GUID, error %u.\n", ret);
5080
5081 if (attrs[i].kind == TKIND_INTERFACE || (attrs[i].flags & TYPEFLAG_FDUAL))
5082 {
5083 ok(!strcasecmp(uuid, "{00020424-0000-0000-c000-000000000046}"),
5084 "Got unexpected proxy CLSID %s.\n", uuid);
5085 }
5086 else
5087 {
5088 ok(!strcasecmp(uuid, "{00020420-0000-0000-c000-000000000046}"),
5089 "Got unexpected proxy CLSID %s.\n", uuid);
5090 }
5091
5092 RegCloseKey(hkey);
5093 }
5094
5095
5096 /* 32-bit typelibs should be registered into both registry bit modes */
5097 if (is_win64 || is_wow64)
5098 {
5099 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ | opposite, &hkey);
5100 ok(ret == expect_ret, "%d: got %d\n", i, ret);
5101 if(ret == ERROR_SUCCESS) RegCloseKey(hkey);
5102 }
5103
5104 ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
5105 ITypeInfo_Release(typeinfo);
5106 }
5107
5108 if (system_registration)
5109 hr = UnRegisterTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, is_win64 ? SYS_WIN64 : SYS_WIN32);
5110 else
5111 hr = pUnRegisterTypeLibForUser(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, is_win64 ? SYS_WIN64 : SYS_WIN32);
5112 ok(hr == S_OK, "got %08x\n", hr);
5113
5114 for(i = 0; i < count; i++)
5115 {
5116 ITypeInfo *typeinfo;
5117 TYPEATTR *attr;
5118
5119 hr = ITypeLib_GetTypeInfo(typelib, i, &typeinfo);
5120 ok(hr == S_OK, "got %08x\n", hr);
5121
5122 hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
5123 ok(hr == S_OK, "got %08x\n", hr);
5124
5125 if((attr->typekind == TKIND_INTERFACE && (attr->wTypeFlags & TYPEFLAG_FOLEAUTOMATION)) ||
5126 attr->typekind == TKIND_DISPATCH)
5127 {
5128 StringFromGUID2(&attr->guid, uuidW, ARRAY_SIZE(uuidW));
5129 WideCharToMultiByte(CP_ACP, 0, uuidW, -1, uuid, sizeof(uuid), NULL, NULL);
5130 sprintf(key_name, "Interface\\%s", uuid);
5131
5132 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ, &hkey);
5133 ok(ret == ERROR_FILE_NOT_FOUND, "Interface registry remains in %s (%d)\n", key_name, i);
5134 if (is_win64 || is_wow64)
5135 {
5136 ret = RegOpenKeyExA(HKEY_CLASSES_ROOT, key_name, 0, KEY_READ | opposite, &hkey);
5137 ok(ret == ERROR_FILE_NOT_FOUND, "Interface registry remains in %s (%d)\n", key_name, i);
5138 }
5139 }
5140 ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
5141 ITypeInfo_Release(typeinfo);
5142 }
5143
5144 ITypeLib_Release(typelib);
5145 DeleteFileA( filenameA );
5146 }
5147
test_LoadTypeLib(void)5148 static void test_LoadTypeLib(void)
5149 {
5150 ITypeLib *tl;
5151 HRESULT hres;
5152
5153 static const WCHAR kernel32_dllW[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
5154
5155 hres = LoadTypeLib(kernel32_dllW, &tl);
5156 ok(hres == TYPE_E_CANTLOADLIBRARY, "LoadTypeLib returned: %08x, expected TYPE_E_CANTLOADLIBRARY\n", hres);
5157
5158 hres = LoadTypeLib(NULL, NULL);
5159 ok(hres == E_INVALIDARG, "Got %#x.\n", hres);
5160
5161 tl = (void *)0xdeadbeef;
5162 hres = LoadTypeLib(NULL, &tl);
5163 ok(hres == E_INVALIDARG, "Got %#x.\n", hres);
5164 ok(tl == (void *)0xdeadbeef, "Got %p.\n", tl);
5165
5166 hres = LoadTypeLibEx(NULL, REGKIND_NONE, NULL);
5167 ok(hres == E_INVALIDARG, "Got %#x.\n", hres);
5168
5169 tl = (void *)0xdeadbeef;
5170 hres = LoadTypeLibEx(NULL, REGKIND_NONE, &tl);
5171 ok(hres == E_INVALIDARG, "Got %#x.\n", hres);
5172 ok(tl == (void *)0xdeadbeef, "Got %p.\n", tl);
5173 }
5174
test_SetVarHelpContext(void)5175 static void test_SetVarHelpContext(void)
5176 {
5177 static OLECHAR nameW[] = {'n','a','m','e',0};
5178 CHAR filenameA[MAX_PATH];
5179 WCHAR filenameW[MAX_PATH];
5180 ICreateTypeLib2 *ctl;
5181 ICreateTypeInfo *cti;
5182 ITypeLib *tl;
5183 ITypeInfo *ti;
5184 VARDESC desc, *pdesc;
5185 HRESULT hr;
5186 DWORD ctx;
5187 VARIANT v;
5188
5189 GetTempFileNameA(".", "tlb", 0, filenameA);
5190 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
5191
5192 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
5193 ok(hr == S_OK, "got %08x\n", hr);
5194
5195 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ENUM, &cti);
5196 ok(hr == S_OK, "got %08x\n", hr);
5197
5198 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 0);
5199 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5200
5201 memset(&desc, 0, sizeof(desc));
5202 desc.memid = MEMBERID_NIL;
5203 desc.elemdescVar.tdesc.vt = VT_INT;
5204 desc.varkind = VAR_CONST;
5205
5206 V_VT(&v) = VT_INT;
5207 V_INT(&v) = 1;
5208 U(desc).lpvarValue = &v;
5209 hr = ICreateTypeInfo_AddVarDesc(cti, 0, &desc);
5210 ok(hr == S_OK, "got %08x\n", hr);
5211
5212 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 0);
5213 ok(hr == S_OK, "got %08x\n", hr);
5214
5215 /* another time */
5216 hr = ICreateTypeInfo_SetVarHelpContext(cti, 0, 1);
5217 ok(hr == S_OK, "got %08x\n", hr);
5218
5219 /* wrong index now */
5220 hr = ICreateTypeInfo_SetVarHelpContext(cti, 1, 0);
5221 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5222
5223 ICreateTypeInfo_Release(cti);
5224
5225 hr = ICreateTypeLib2_SaveAllChanges(ctl);
5226 ok(hr == S_OK, "got: %08x\n", hr);
5227
5228 ICreateTypeLib2_Release(ctl);
5229
5230 hr = LoadTypeLib(filenameW, &tl);
5231 ok(hr == S_OK, "got: %08x\n", hr);
5232
5233 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
5234 ok(hr == S_OK, "got %08x\n", hr);
5235
5236 hr = ITypeInfo_GetVarDesc(ti, 0, &pdesc);
5237 ok(hr == S_OK, "got %08x\n", hr);
5238 ok(pdesc->memid == 0x40000000, "got wrong memid: %x\n", pdesc->memid);
5239 ok(pdesc->elemdescVar.tdesc.vt == VT_INT, "got wrong vardesc type: %u\n", pdesc->elemdescVar.tdesc.vt);
5240 ok(pdesc->varkind == VAR_CONST, "got wrong varkind: %u\n", pdesc->varkind);
5241 ok(V_VT(U(*pdesc).lpvarValue) == VT_INT, "got wrong value type: %u\n", V_VT(U(*pdesc).lpvarValue));
5242 ok(V_INT(U(*pdesc).lpvarValue) == 1, "got wrong value: 0x%x\n", V_INT(U(*pdesc).lpvarValue));
5243
5244 hr = ITypeInfo_GetDocumentation(ti, pdesc->memid, NULL, NULL, &ctx, NULL);
5245 ok(hr == S_OK, "got %08x\n", hr);
5246 ok(ctx == 1, "got wrong help context: 0x%x\n", ctx);
5247
5248 ITypeInfo_ReleaseVarDesc(ti, pdesc);
5249 ITypeInfo_Release(ti);
5250 ITypeLib_Release(tl);
5251
5252 DeleteFileA(filenameA);
5253 }
5254
test_SetFuncAndParamNames(void)5255 static void test_SetFuncAndParamNames(void)
5256 {
5257 static OLECHAR nameW[] = {'n','a','m','e',0};
5258 static OLECHAR name2W[] = {'n','a','m','e','2',0};
5259 static OLECHAR prop[] = {'p','r','o','p',0};
5260 static OLECHAR *propW[] = {prop};
5261 static OLECHAR func[] = {'f','u','n','c',0};
5262 static OLECHAR *funcW[] = {func, NULL};
5263 CHAR filenameA[MAX_PATH];
5264 WCHAR filenameW[MAX_PATH];
5265 ICreateTypeLib2 *ctl;
5266 ICreateTypeInfo *cti;
5267 ITypeLib *tl;
5268 ITypeInfo *infos[3];
5269 MEMBERID memids[3];
5270 FUNCDESC funcdesc;
5271 ELEMDESC edesc;
5272 HRESULT hr;
5273 USHORT found;
5274
5275 GetTempFileNameA(".", "tlb", 0, filenameA);
5276 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
5277
5278 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
5279 ok(hr == S_OK, "got %08x\n", hr);
5280
5281 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_DISPATCH, &cti);
5282 ok(hr == S_OK, "got %08x\n", hr);
5283
5284 /* get method */
5285 memset(&funcdesc, 0, sizeof(FUNCDESC));
5286 funcdesc.funckind = FUNC_DISPATCH;
5287 funcdesc.callconv = CC_STDCALL;
5288 funcdesc.elemdescFunc.tdesc.vt = VT_VOID;
5289 funcdesc.wFuncFlags = FUNCFLAG_FBINDABLE;
5290
5291 /* put method */
5292 memset(&edesc, 0, sizeof(edesc));
5293 edesc.tdesc.vt = VT_BSTR;
5294 U(edesc).idldesc.dwReserved = 0;
5295 U(edesc).idldesc.wIDLFlags = IDLFLAG_FIN;
5296
5297 funcdesc.lprgelemdescParam = &edesc;
5298 funcdesc.invkind = INVOKE_PROPERTYPUT;
5299 funcdesc.cParams = 1;
5300
5301 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
5302 ok(hr == S_OK, "got 0x%08x\n", hr);
5303
5304 /* setter name */
5305 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 0, propW, 1);
5306 ok(hr == S_OK, "got 0x%08x\n", hr);
5307
5308 /* putref method */
5309 funcdesc.invkind = INVOKE_PROPERTYPUTREF;
5310 hr = ICreateTypeInfo_AddFuncDesc(cti, 1, &funcdesc);
5311 ok(hr == S_OK, "got 0x%08x\n", hr);
5312
5313 /* putref name */
5314 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 1, propW, 1);
5315 ok(hr == S_OK, "got 0x%08x\n", hr);
5316
5317 funcdesc.invkind = INVOKE_PROPERTYGET;
5318 funcdesc.cParams = 0;
5319 hr = ICreateTypeInfo_AddFuncDesc(cti, 2, &funcdesc);
5320 ok(hr == S_OK, "got 0x%08x\n", hr);
5321
5322 /* getter name */
5323 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 2, propW, 1);
5324 ok(hr == S_OK, "got 0x%08x\n", hr);
5325
5326 hr = ICreateTypeInfo_AddFuncDesc(cti, 3, &funcdesc);
5327 ok(hr == S_OK, "got 0x%08x\n", hr);
5328
5329 /* getter name again */
5330 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 3, propW, 1);
5331 ok(hr == TYPE_E_AMBIGUOUSNAME, "got 0x%08x\n", hr);
5332
5333 /* regular function */
5334 funcdesc.invkind = INVOKE_FUNC;
5335 funcdesc.cParams = 1;
5336 hr = ICreateTypeInfo_AddFuncDesc(cti, 4, &funcdesc);
5337 ok(hr == S_OK, "got 0x%08x\n", hr);
5338
5339 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 4, funcW, 2);
5340 ok(hr == S_OK, "got 0x%08x\n", hr);
5341
5342 ICreateTypeInfo_Release(cti);
5343
5344 hr = ICreateTypeLib2_CreateTypeInfo(ctl, name2W, TKIND_INTERFACE, &cti);
5345 ok(hr == S_OK, "got %08x\n", hr);
5346
5347 funcdesc.funckind = FUNC_PUREVIRTUAL;
5348 funcdesc.invkind = INVOKE_FUNC;
5349 funcdesc.cParams = 0;
5350 funcdesc.lprgelemdescParam = NULL;
5351 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
5352 ok(hr == S_OK, "got 0x%08x\n", hr);
5353
5354 hr = ICreateTypeInfo_SetFuncAndParamNames(cti, 0, funcW, 1);
5355 ok(hr == S_OK, "got 0x%08x\n", hr);
5356
5357 ICreateTypeInfo_Release(cti);
5358
5359 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
5360 ok(hr == S_OK, "got %08x\n", hr);
5361
5362 found = 1;
5363 memset(infos, 0, sizeof(infos));
5364 memids[0] = 0xdeadbeef;
5365 memids[1] = 0xdeadbeef;
5366 memids[2] = 0xdeadbeef;
5367 hr = ITypeLib_FindName(tl, func, 0, infos, memids, &found);
5368 ok(hr == S_OK, "got %08x\n", hr);
5369 ok(found == 1, "got wrong count: %u\n", found);
5370 ok(infos[0] && !infos[1] && !infos[2], "got wrong typeinfo\n");
5371 ok(memids[0] == 0, "got wrong memid[0]\n");
5372 ok(memids[1] == 0xdeadbeef && memids[2] == 0xdeadbeef, "got wrong memids\n");
5373 ITypeInfo_Release(infos[0]);
5374
5375 found = 3;
5376 memset(infos, 0, sizeof(infos));
5377 memids[0] = 0xdeadbeef;
5378 memids[1] = 0xdeadbeef;
5379 memids[2] = 0xdeadbeef;
5380 hr = ITypeLib_FindName(tl, func, 0, infos, memids, &found);
5381 ok(hr == S_OK, "got %08x\n", hr);
5382 ok(found == 2, "got wrong count: %u\n", found);
5383 ok(infos[0] && infos[1] && infos[0] != infos[1], "got same typeinfo\n");
5384 ok(memids[0] == 0, "got wrong memid[0]\n");
5385 ok(memids[1] == 0, "got wrong memid[1]\n");
5386 ITypeInfo_Release(infos[0]);
5387 ITypeInfo_Release(infos[1]);
5388
5389 ITypeLib_Release(tl);
5390 ICreateTypeLib2_Release(ctl);
5391 DeleteFileA(filenameA);
5392 }
5393
test_SetDocString(void)5394 static void test_SetDocString(void)
5395 {
5396 static OLECHAR nameW[] = {'n','a','m','e',0};
5397 static OLECHAR name2W[] = {'n','a','m','e','2',0};
5398 static OLECHAR doc1W[] = {'d','o','c','1',0};
5399 static OLECHAR doc2W[] = {'d','o','c','2',0};
5400 static OLECHAR var_nameW[] = {'v','a','r','n','a','m','e',0};
5401 CHAR filenameA[MAX_PATH];
5402 WCHAR filenameW[MAX_PATH];
5403 ICreateTypeLib2 *ctl;
5404 ICreateTypeInfo *cti;
5405 ITypeLib *tl;
5406 ITypeInfo *ti;
5407 BSTR namestr, docstr;
5408 VARDESC desc, *pdesc;
5409 FUNCDESC funcdesc, *pfuncdesc;
5410 HRESULT hr;
5411 VARIANT v;
5412
5413 GetTempFileNameA(".", "tlb", 0, filenameA);
5414 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
5415
5416 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
5417 ok(hr == S_OK, "got %08x\n", hr);
5418
5419 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ENUM, &cti);
5420 ok(hr == S_OK, "got %08x\n", hr);
5421
5422 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc1W);
5423 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5424
5425 hr = ICreateTypeInfo_SetVarDocString(cti, 0, NULL);
5426 ok(hr == E_INVALIDARG, "got %08x\n", hr);
5427
5428 memset(&desc, 0, sizeof(desc));
5429 desc.memid = MEMBERID_NIL;
5430 desc.elemdescVar.tdesc.vt = VT_INT;
5431 desc.varkind = VAR_CONST;
5432
5433 V_VT(&v) = VT_INT;
5434 V_INT(&v) = 1;
5435 U(desc).lpvarValue = &v;
5436 hr = ICreateTypeInfo_AddVarDesc(cti, 0, &desc);
5437 ok(hr == S_OK, "got %08x\n", hr);
5438
5439 hr = ICreateTypeInfo_SetVarName(cti, 0, NULL);
5440 ok(hr == E_INVALIDARG, "got %08x\n", hr);
5441
5442 hr = ICreateTypeInfo_SetVarName(cti, 1, var_nameW);
5443 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5444
5445 hr = ICreateTypeInfo_SetVarName(cti, 0, var_nameW);
5446 ok(hr == S_OK, "got %08x\n", hr);
5447
5448 hr = ICreateTypeInfo_SetVarDocString(cti, 0, NULL);
5449 ok(hr == E_INVALIDARG, "got %08x\n", hr);
5450
5451 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc1W);
5452 ok(hr == S_OK, "got %08x\n", hr);
5453
5454 /* already set */
5455 hr = ICreateTypeInfo_SetVarDocString(cti, 0, doc2W);
5456 ok(hr == S_OK, "got %08x\n", hr);
5457
5458 /* wrong index now */
5459 hr = ICreateTypeInfo_SetVarDocString(cti, 1, doc1W);
5460 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5461
5462 ICreateTypeInfo_Release(cti);
5463
5464 hr = ICreateTypeLib2_CreateTypeInfo(ctl, name2W, TKIND_INTERFACE, &cti);
5465 ok(hr == S_OK, "got %08x\n", hr);
5466
5467 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, doc1W);
5468 ok(hr == TYPE_E_ELEMENTNOTFOUND, "got %08x\n", hr);
5469
5470 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, NULL);
5471 ok(hr == E_INVALIDARG, "got %08x\n", hr);
5472
5473 memset(&funcdesc, 0, sizeof(funcdesc));
5474 funcdesc.memid = MEMBERID_NIL;
5475 funcdesc.funckind = FUNC_PUREVIRTUAL;
5476 funcdesc.invkind = INVOKE_FUNC;
5477 funcdesc.callconv = CC_STDCALL;
5478
5479 hr = ICreateTypeInfo_AddFuncDesc(cti, 0, &funcdesc);
5480 ok(hr == S_OK, "got %08x\n", hr);
5481
5482 hr = ICreateTypeInfo_SetFuncDocString(cti, 0, doc1W);
5483 ok(hr == S_OK, "got %08x\n", hr);
5484
5485 ICreateTypeInfo_Release(cti);
5486
5487 hr = ICreateTypeLib2_SaveAllChanges(ctl);
5488 ok(hr == S_OK, "got: %08x\n", hr);
5489
5490 ICreateTypeLib2_Release(ctl);
5491
5492 hr = LoadTypeLib(filenameW, &tl);
5493 ok(hr == S_OK, "got: %08x\n", hr);
5494
5495 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
5496 ok(hr == S_OK, "got %08x\n", hr);
5497
5498 hr = ITypeInfo_GetVarDesc(ti, 0, &pdesc);
5499 ok(hr == S_OK, "got %08x\n", hr);
5500 ok(pdesc->memid == 0x40000000, "got wrong memid: %x\n", pdesc->memid);
5501 ok(pdesc->elemdescVar.tdesc.vt == VT_INT, "got wrong vardesc type: %u\n", pdesc->elemdescVar.tdesc.vt);
5502 ok(pdesc->varkind == VAR_CONST, "got wrong varkind: %u\n", pdesc->varkind);
5503 ok(V_VT(U(*pdesc).lpvarValue) == VT_INT, "got wrong value type: %u\n", V_VT(U(*pdesc).lpvarValue));
5504 ok(V_INT(U(*pdesc).lpvarValue) == 1, "got wrong value: 0x%x\n", V_INT(U(*pdesc).lpvarValue));
5505
5506 hr = ITypeInfo_GetDocumentation(ti, pdesc->memid, &namestr, &docstr, NULL, NULL);
5507 ok(hr == S_OK, "got %08x\n", hr);
5508 ok(memcmp(namestr, var_nameW, sizeof(var_nameW)) == 0, "got wrong name: %s\n", wine_dbgstr_w(namestr));
5509 ok(memcmp(docstr, doc2W, sizeof(doc2W)) == 0, "got wrong docstring: %s\n", wine_dbgstr_w(docstr));
5510
5511 SysFreeString(namestr);
5512 SysFreeString(docstr);
5513
5514 ITypeInfo_ReleaseVarDesc(ti, pdesc);
5515 ITypeInfo_Release(ti);
5516
5517 hr = ITypeLib_GetTypeInfo(tl, 1, &ti);
5518 ok(hr == S_OK, "got %08x\n", hr);
5519
5520 hr = ITypeInfo_GetFuncDesc(ti, 0, &pfuncdesc);
5521 ok(hr == S_OK, "got %08x\n", hr);
5522 ok(pfuncdesc->memid == 0x60000000, "got wrong memid: %x\n", pfuncdesc->memid);
5523 ok(pfuncdesc->funckind == FUNC_PUREVIRTUAL, "got wrong funckind: %x\n", pfuncdesc->funckind);
5524 ok(pfuncdesc->invkind == INVOKE_FUNC, "got wrong invkind: %x\n", pfuncdesc->invkind);
5525 ok(pfuncdesc->callconv == CC_STDCALL, "got wrong callconv: %x\n", pfuncdesc->callconv);
5526
5527 hr = ITypeInfo_GetDocumentation(ti, pfuncdesc->memid, &namestr, &docstr, NULL, NULL);
5528 ok(hr == S_OK, "got %08x\n", hr);
5529 ok(namestr == NULL, "got wrong name: %s\n", wine_dbgstr_w(namestr));
5530 ok(memcmp(docstr, doc1W, sizeof(doc1W)) == 0, "got wrong docstring: %s\n", wine_dbgstr_w(docstr));
5531
5532 SysFreeString(docstr);
5533
5534 ITypeInfo_ReleaseFuncDesc(ti, pfuncdesc);
5535 ITypeInfo_Release(ti);
5536
5537 ITypeLib_Release(tl);
5538
5539 DeleteFileA(filenameA);
5540 }
5541
test_FindName(void)5542 static void test_FindName(void)
5543 {
5544 static const WCHAR invalidW[] = {'i','n','v','a','l','i','d',0};
5545 WCHAR buffW[100];
5546 MEMBERID memid;
5547 ITypeInfo *ti;
5548 ITypeLib *tl;
5549 HRESULT hr;
5550 UINT16 c;
5551
5552 hr = LoadTypeLib(wszStdOle2, &tl);
5553 ok(hr == S_OK, "got 0x%08x\n", hr);
5554
5555 hr = ITypeLib_FindName(tl, NULL, 0, NULL, NULL, NULL);
5556 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
5557
5558 lstrcpyW(buffW, wszGUID);
5559 hr = ITypeLib_FindName(tl, buffW, 0, NULL, NULL, NULL);
5560 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
5561
5562 c = 0;
5563 ti = (void*)0xdeadbeef;
5564 hr = ITypeLib_FindName(tl, buffW, 0, &ti, NULL, &c);
5565 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
5566 ok(c == 0, "got %d\n", c);
5567 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
5568
5569 c = 1;
5570 ti = (void*)0xdeadbeef;
5571 hr = ITypeLib_FindName(tl, buffW, 0, &ti, NULL, &c);
5572 ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
5573 ok(c == 1, "got %d\n", c);
5574 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
5575
5576 c = 1;
5577 memid = 0;
5578 ti = (void*)0xdeadbeef;
5579 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
5580 ok(hr == S_OK, "got 0x%08x\n", hr);
5581 ok(memid == MEMBERID_NIL, "got %d\n", memid);
5582 ok(!lstrcmpW(buffW, wszGUID), "got %s\n", wine_dbgstr_w(buffW));
5583 ok(c == 1, "got %d\n", c);
5584 ITypeInfo_Release(ti);
5585
5586 c = 1;
5587 memid = 0;
5588 lstrcpyW(buffW, wszguid);
5589 ti = (void*)0xdeadbeef;
5590 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
5591 ok(hr == S_OK, "got 0x%08x\n", hr);
5592 todo_wine {
5593 ok(memid == MEMBERID_NIL, "got %d\n", memid);
5594 ok(!lstrcmpW(buffW, wszGUID), "got %s\n", wine_dbgstr_w(buffW));
5595 ok(c == 1, "got %d\n", c);
5596 }
5597 if (c == 1)
5598 ITypeInfo_Release(ti);
5599
5600 c = 1;
5601 memid = -1;
5602 lstrcpyW(buffW, invalidW);
5603 ti = (void*)0xdeadbeef;
5604 hr = ITypeLib_FindName(tl, buffW, 0, &ti, &memid, &c);
5605 ok(hr == S_OK, "got 0x%08x\n", hr);
5606 ok(memid == MEMBERID_NIL, "got %d\n", memid);
5607 ok(!lstrcmpW(buffW, invalidW), "got %s\n", wine_dbgstr_w(buffW));
5608 ok(c == 0, "got %d\n", c);
5609 ok(ti == (void*)0xdeadbeef, "got %p\n", ti);
5610
5611 ITypeLib_Release(tl);
5612 }
5613
test_TypeInfo2_GetContainingTypeLib(void)5614 static void test_TypeInfo2_GetContainingTypeLib(void)
5615 {
5616 static const WCHAR test[] = {'t','e','s','t','.','t','l','b',0};
5617 static OLECHAR testTI[] = {'t','e','s','t','T','y','p','e','I','n','f','o',0};
5618
5619 ICreateTypeLib2 *ctl2;
5620 ICreateTypeInfo *cti;
5621 ITypeInfo2 *ti2;
5622 ITypeLib *tl;
5623 UINT Index;
5624 HRESULT hr;
5625
5626 hr = CreateTypeLib2(SYS_WIN32, test, &ctl2);
5627 ok_ole_success(hr, CreateTypeLib2);
5628
5629 hr = ICreateTypeLib2_CreateTypeInfo(ctl2, testTI, TKIND_DISPATCH, &cti);
5630 ok_ole_success(hr, ICreateTypeLib2_CreateTypeInfo);
5631
5632 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo2, (void**)&ti2);
5633 ok_ole_success(hr, ICreateTypeInfo2_QueryInterface);
5634
5635 tl = NULL;
5636 Index = 888;
5637 hr = ITypeInfo2_GetContainingTypeLib(ti2, &tl, &Index);
5638 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
5639 ok(tl != NULL, "ITypeInfo2_GetContainingTypeLib returned empty TypeLib\n");
5640 ok(Index == 0, "ITypeInfo2_GetContainingTypeLib returned Index = %u, expected 0\n", Index);
5641 if(tl) ITypeLib_Release(tl);
5642
5643 tl = NULL;
5644 hr = ITypeInfo2_GetContainingTypeLib(ti2, &tl, NULL);
5645 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
5646 ok(tl != NULL, "ITypeInfo2_GetContainingTypeLib returned empty TypeLib\n");
5647 if(tl) ITypeLib_Release(tl);
5648
5649 Index = 888;
5650 hr = ITypeInfo2_GetContainingTypeLib(ti2, NULL, &Index);
5651 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
5652 ok(Index == 0, "ITypeInfo2_GetContainingTypeLib returned Index = %u, expected 0\n", Index);
5653
5654 hr = ITypeInfo2_GetContainingTypeLib(ti2, NULL, NULL);
5655 ok_ole_success(hr, ITypeInfo2_GetContainingTypeLib);
5656
5657 ITypeInfo2_Release(ti2);
5658 ICreateTypeInfo_Release(cti);
5659 ICreateTypeLib2_Release(ctl2);
5660 }
5661
create_manifest_file(const char * filename,const char * manifest)5662 static void create_manifest_file(const char *filename, const char *manifest)
5663 {
5664 HANDLE file;
5665 DWORD size;
5666
5667 file = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
5668 FILE_ATTRIBUTE_NORMAL, NULL);
5669 ok(file != INVALID_HANDLE_VALUE, "CreateFile failed: %u\n", GetLastError());
5670 WriteFile(file, manifest, strlen(manifest), &size, NULL);
5671 CloseHandle(file);
5672 }
5673
create_actctx(const char * file)5674 static HANDLE create_actctx(const char *file)
5675 {
5676 WCHAR path[MAX_PATH];
5677 ACTCTXW actctx;
5678 HANDLE handle;
5679
5680 MultiByteToWideChar(CP_ACP, 0, file, -1, path, MAX_PATH);
5681 memset(&actctx, 0, sizeof(ACTCTXW));
5682 actctx.cbSize = sizeof(ACTCTXW);
5683 actctx.lpSource = path;
5684
5685 handle = pCreateActCtxW(&actctx);
5686 ok(handle != INVALID_HANDLE_VALUE, "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
5687
5688 ok(actctx.cbSize == sizeof(actctx), "actctx.cbSize=%d\n", actctx.cbSize);
5689 ok(actctx.dwFlags == 0, "actctx.dwFlags=%d\n", actctx.dwFlags);
5690 ok(actctx.lpSource == path, "actctx.lpSource=%p\n", actctx.lpSource);
5691 ok(actctx.wProcessorArchitecture == 0, "actctx.wProcessorArchitecture=%d\n", actctx.wProcessorArchitecture);
5692 ok(actctx.wLangId == 0, "actctx.wLangId=%d\n", actctx.wLangId);
5693 ok(actctx.lpAssemblyDirectory == NULL, "actctx.lpAssemblyDirectory=%p\n", actctx.lpAssemblyDirectory);
5694 ok(actctx.lpResourceName == NULL, "actctx.lpResourceName=%p\n", actctx.lpResourceName);
5695 ok(actctx.lpApplicationName == NULL, "actctx.lpApplicationName=%p\n",
5696 actctx.lpApplicationName);
5697 ok(actctx.hModule == NULL, "actctx.hModule=%p\n", actctx.hModule);
5698
5699 return handle;
5700 }
5701
5702 static const char manifest_dep[] =
5703 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
5704 "<assemblyIdentity version=\"1.2.3.4\" name=\"testdep\" type=\"win32\" processorArchitecture=\"" ARCH "\"/>"
5705 "<file name=\"test_actctx_tlb.tlb\">"
5706 " <typelib tlbid=\"{d96d8a3e-78b6-4c8d-8f27-059db959be8a}\" version=\"2.7\" helpdir=\"\" resourceid=\"409\""
5707 " flags=\"Restricted,cONTROL\""
5708 " />"
5709 "</file>"
5710 "<file name=\"test_actctx_tlb2.tlb\">"
5711 " <typelib tlbid=\"{a2cfdbd3-2bbf-4b1c-a414-5a5904e634c9}\" version=\"2.0\" helpdir=\"\" resourceid=\"409\""
5712 " flags=\"RESTRICTED,CONTROL\""
5713 " />"
5714 "</file>"
5715 "</assembly>";
5716
5717 static const char manifest_main[] =
5718 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
5719 "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\" />"
5720 "<dependency>"
5721 " <dependentAssembly>"
5722 " <assemblyIdentity type=\"win32\" name=\"testdep\" version=\"1.2.3.4\" processorArchitecture=\"" ARCH "\" />"
5723 " </dependentAssembly>"
5724 "</dependency>"
5725 "</assembly>";
5726
test_LoadRegTypeLib(void)5727 static void test_LoadRegTypeLib(void)
5728 {
5729 LCID lcid_en = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
5730 LCID lcid_ru = MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_NEUTRAL), SORT_DEFAULT);
5731 ULONG_PTR cookie;
5732 TLIBATTR *attr;
5733 HANDLE handle;
5734 ITypeLib *tl;
5735 HRESULT hr;
5736 BSTR path;
5737 BOOL ret;
5738
5739 if (!pActivateActCtx)
5740 {
5741 win_skip("Activation contexts not supported, skipping LoadRegTypeLib tests\n");
5742 return;
5743 }
5744
5745 create_manifest_file("testdep.manifest", manifest_dep);
5746 create_manifest_file("main.manifest", manifest_main);
5747
5748 handle = create_actctx("main.manifest");
5749 DeleteFileA("testdep.manifest");
5750 DeleteFileA("main.manifest");
5751
5752 /* create typelib file */
5753 write_typelib(1, "test_actctx_tlb.tlb");
5754 write_typelib(3, "test_actctx_tlb2.tlb");
5755
5756 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &tl);
5757 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5758
5759 hr = LoadRegTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, &tl);
5760 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5761
5762 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &path);
5763 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5764
5765 ret = pActivateActCtx(handle, &cookie);
5766 ok(ret, "ActivateActCtx failed: %u\n", GetLastError());
5767
5768 path = NULL;
5769 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &path);
5770 ok(hr == S_OK, "got 0x%08x\n", hr);
5771 SysFreeString(path);
5772
5773 path = NULL;
5774 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_en, &path);
5775 ok(hr == S_OK, "got 0x%08x\n", hr);
5776 SysFreeString(path);
5777
5778 path = NULL;
5779 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_ru, &path);
5780 ok(hr == S_OK, "got 0x%08x\n", hr);
5781 SysFreeString(path);
5782
5783 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 8, LOCALE_NEUTRAL, &path);
5784 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
5785
5786 path = NULL;
5787 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 2, 7, LOCALE_NEUTRAL, &path);
5788 ok(hr == S_OK, "got 0x%08x\n", hr);
5789 SysFreeString(path);
5790
5791 path = NULL;
5792 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 1, 0, LOCALE_NEUTRAL, &path);
5793 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
5794 SysFreeString(path);
5795
5796 path = NULL;
5797 hr = QueryPathOfRegTypeLib(&LIBID_TestTypelib, 0xffff, 0xffff, LOCALE_NEUTRAL, &path);
5798 ok(hr == S_OK, "got 0x%08x\n", hr);
5799 SysFreeString(path);
5800
5801 /* manifest version is 2.0, actual is 1.0 */
5802 hr = LoadRegTypeLib(&LIBID_register_test, 1, 0, LOCALE_NEUTRAL, &tl);
5803 ok(hr == TYPE_E_LIBNOTREGISTERED || broken(hr == S_OK) /* winxp */, "got 0x%08x\n", hr);
5804 if (hr == S_OK) ITypeLib_Release(tl);
5805
5806 hr = LoadRegTypeLib(&LIBID_register_test, 2, 0, LOCALE_NEUTRAL, &tl);
5807 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5808
5809 /* manifest version is 2.7, actual is 2.5 */
5810 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, LOCALE_NEUTRAL, &tl);
5811 ok(hr == S_OK, "got 0x%08x\n", hr);
5812 if (hr == S_OK) ITypeLib_Release(tl);
5813
5814 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 1, LOCALE_NEUTRAL, &tl);
5815 ok(hr == S_OK, "got 0x%08x\n", hr);
5816 if (hr == S_OK) ITypeLib_Release(tl);
5817
5818 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_en, &tl);
5819 ok(hr == S_OK, "got 0x%08x\n", hr);
5820 if (hr == S_OK) ITypeLib_Release(tl);
5821
5822 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 0, lcid_ru, &tl);
5823 ok(hr == S_OK, "got 0x%08x\n", hr);
5824 if (hr == S_OK) ITypeLib_Release(tl);
5825
5826 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 7, LOCALE_NEUTRAL, &tl);
5827 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5828
5829 hr = LoadRegTypeLib(&LIBID_TestTypelib, 2, 5, LOCALE_NEUTRAL, &tl);
5830 ok(hr == S_OK, "got 0x%08x\n", hr);
5831
5832 hr = ITypeLib_GetLibAttr(tl, &attr);
5833 ok(hr == S_OK, "got 0x%08x\n", hr);
5834
5835 ok(attr->lcid == 0, "got %x\n", attr->lcid);
5836 ok(attr->wMajorVerNum == 2, "got %d\n", attr->wMajorVerNum);
5837 ok(attr->wMinorVerNum == 5, "got %d\n", attr->wMinorVerNum);
5838 ok(attr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "got %x\n", attr->wLibFlags);
5839
5840 ITypeLib_ReleaseTLibAttr(tl, attr);
5841 ITypeLib_Release(tl);
5842
5843 hr = LoadRegTypeLib(&LIBID_TestTypelib, 1, 7, LOCALE_NEUTRAL, &tl);
5844 ok(hr == TYPE_E_LIBNOTREGISTERED, "got 0x%08x\n", hr);
5845
5846 tl = NULL;
5847 hr = LoadRegTypeLib(&LIBID_TestTypelib, 0xffff, 0xffff, LOCALE_NEUTRAL, &tl);
5848 ok(hr == S_OK, "got 0x%08x\n", hr);
5849
5850 if (tl)
5851 {
5852 hr = ITypeLib_GetLibAttr(tl, &attr);
5853 ok(hr == S_OK, "got 0x%08x\n", hr);
5854
5855 ok(attr->lcid == 0, "got %x\n", attr->lcid);
5856 ok(attr->wMajorVerNum == 2, "got %d\n", attr->wMajorVerNum);
5857 ok(attr->wMinorVerNum == 5, "got %d\n", attr->wMinorVerNum);
5858 ok(attr->wLibFlags == LIBFLAG_FHASDISKIMAGE, "got %x\n", attr->wLibFlags);
5859
5860 ITypeLib_ReleaseTLibAttr(tl, attr);
5861 ITypeLib_Release(tl);
5862 }
5863
5864 DeleteFileA("test_actctx_tlb.tlb");
5865 DeleteFileA("test_actctx_tlb2.tlb");
5866
5867 ret = pDeactivateActCtx(0, cookie);
5868 ok(ret, "DeactivateActCtx failed: %u\n", GetLastError());
5869
5870 pReleaseActCtx(handle);
5871 }
5872
5873 #define AUX_HREF 1
5874 #define AUX_TDESC 2
5875 #define AUX_ADESC 3
5876 static struct _TDATest {
5877 VARTYPE vt;
5878 ULONG size; /* -1 == typelib ptr size */
5879 WORD align;
5880 WORD align3264; /* for 32-bit typelibs loaded in 64-bit mode */
5881 DWORD aux;
5882 TYPEDESC tdesc;
5883 ARRAYDESC adesc;
5884 } TDATests[] = {
5885 { VT_I2, 2, 2, 2 },
5886 { VT_I4, 4, 4, 4 },
5887 { VT_R4, 4, 4, 4 },
5888 { VT_R8, 8, 4, 8 },
5889 { VT_CY, 8, 4, 8 },
5890 { VT_DATE, 8, 4, 8 },
5891 { VT_BSTR, -1, 4, 8 },
5892 { VT_DISPATCH, -1, 4, 8 },
5893 { VT_ERROR, 4, 4, 4 },
5894 { VT_BOOL, 2, 2, 2 },
5895 { VT_VARIANT, 0 /* see code below */, 4, 8 },
5896 { VT_UNKNOWN, -1, 4, 8 },
5897 { VT_DECIMAL, 16, 4, 8 },
5898 { VT_I1, 1, 1, 1 },
5899 { VT_UI1, 1, 1, 1 },
5900 { VT_UI2, 2, 2, 2 },
5901 { VT_UI4, 4, 4, 4 },
5902 { VT_I8, 8, 4, 8 },
5903 { VT_UI8, 8, 4, 8 },
5904 { VT_INT, 4, 4, 4 },
5905 { VT_UINT, 4, 4, 4 },
5906 { VT_VOID, 0, 0, 0 },
5907 { VT_HRESULT, 4, 4, 4 },
5908 { VT_PTR, -1, 4, 8, AUX_TDESC, { { 0 }, VT_INT } },
5909 { VT_SAFEARRAY, -1, 4, 8, AUX_TDESC, { { 0 }, VT_INT } },
5910 { VT_CARRAY, 16 /* == 4 * sizeof(int) */, 4, 4, AUX_ADESC, { { 0 } }, { { { 0 }, VT_INT }, 1, { { 4, 0 } } } },
5911 { VT_USERDEFINED, 0, 0, 0, AUX_HREF },
5912 { VT_LPSTR, -1, 4, 8 },
5913 { VT_LPWSTR, -1, 4, 8 },
5914 { 0 }
5915 };
5916
testTDA(ITypeLib * tl,struct _TDATest * TDATest,ULONG ptr_size,HREFTYPE hreftype,ULONG href_cbSizeInstance,WORD href_cbAlignment,BOOL create)5917 static void testTDA(ITypeLib *tl, struct _TDATest *TDATest,
5918 ULONG ptr_size, HREFTYPE hreftype, ULONG href_cbSizeInstance,
5919 WORD href_cbAlignment, BOOL create)
5920 {
5921 TYPEDESC tdesc;
5922 WCHAR nameW[32];
5923 ITypeInfo *ti;
5924 ICreateTypeInfo *cti;
5925 ICreateTypeLib2 *ctl;
5926 ULONG size;
5927 WORD alignment;
5928 TYPEATTR *typeattr;
5929 HRESULT hr;
5930
5931 static const WCHAR name_fmtW[] = {'a','l','i','a','s','%','0','2','u',0};
5932
5933 wsprintfW(nameW, name_fmtW, TDATest->vt);
5934
5935 if(create){
5936 hr = ITypeLib_QueryInterface(tl, &IID_ICreateTypeLib2, (void**)&ctl);
5937 ok(hr == S_OK, "got %08x\n", hr);
5938
5939 hr = ICreateTypeLib2_CreateTypeInfo(ctl, nameW, TKIND_ALIAS, &cti);
5940 ok(hr == S_OK, "got %08x\n", hr);
5941
5942 tdesc.vt = TDATest->vt;
5943 if(TDATest->aux == AUX_TDESC)
5944 U(tdesc).lptdesc = &TDATest->tdesc;
5945 else if(TDATest->aux == AUX_ADESC)
5946 U(tdesc).lpadesc = &TDATest->adesc;
5947 else if(TDATest->aux == AUX_HREF)
5948 U(tdesc).hreftype = hreftype;
5949
5950 hr = ICreateTypeInfo_SetTypeDescAlias(cti, &tdesc);
5951 ok(hr == S_OK, "for VT %u, got %08x\n", TDATest->vt, hr);
5952
5953 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
5954 ok(hr == S_OK, "got %08x\n", hr);
5955
5956 ICreateTypeInfo_Release(cti);
5957 ICreateTypeLib2_Release(ctl);
5958 }else{
5959 USHORT found = 1;
5960 MEMBERID memid;
5961
5962 hr = ITypeLib_FindName(tl, nameW, 0, &ti, &memid, &found);
5963 ok(hr == S_OK, "for VT %u, got %08x\n", TDATest->vt, hr);
5964 }
5965
5966 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
5967 ok(hr == S_OK, "got %08x\n", hr);
5968
5969 if(TDATest->aux == AUX_HREF){
5970 size = href_cbSizeInstance;
5971 alignment = href_cbAlignment;
5972 }else{
5973 size = TDATest->size;
5974 if(size == -1){
5975 if(create)
5976 size = ptr_size;
5977 else
5978 size = sizeof(void*);
5979 }else if(TDATest->vt == VT_VARIANT){
5980 if(create){
5981 size = sizeof(VARIANT);
5982 #ifdef _WIN64
5983 if(ptr_size != sizeof(void*))
5984 size -= 8; /* 32-bit variant is 4 bytes smaller than 64-bit variant */
5985 #endif
5986 }else
5987 size = sizeof(VARIANT);
5988 }
5989 alignment = TDATest->align;
5990 #ifdef _WIN64
5991 if(!create && ptr_size != sizeof(void*))
5992 alignment = TDATest->align3264;
5993 #endif
5994 }
5995
5996 ok(typeattr->cbSizeInstance == size, "got wrong size for VT %u: 0x%x\n", TDATest->vt, typeattr->cbSizeInstance);
5997 ok(typeattr->cbAlignment == alignment, "got wrong alignment for VT %u: 0x%x\n", TDATest->vt, typeattr->cbAlignment);
5998 ok(typeattr->tdescAlias.vt == TDATest->vt, "got wrong VT for VT %u: 0x%x\n", TDATest->vt, typeattr->tdescAlias.vt);
5999
6000 switch(TDATest->aux){
6001 case AUX_HREF:
6002 ok(U(typeattr->tdescAlias).hreftype == hreftype, "got wrong hreftype for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).hreftype);
6003 break;
6004 case AUX_TDESC:
6005 ok(U(typeattr->tdescAlias).lptdesc->vt == TDATest->tdesc.vt, "got wrong typedesc VT for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lptdesc->vt);
6006 break;
6007 case AUX_ADESC:
6008 ok(U(typeattr->tdescAlias).lpadesc->tdescElem.vt == TDATest->adesc.tdescElem.vt, "got wrong arraydesc element VT for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->tdescElem.vt);
6009 ok(U(typeattr->tdescAlias).lpadesc->cDims == TDATest->adesc.cDims, "got wrong arraydesc dimension count for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->cDims);
6010 ok(U(typeattr->tdescAlias).lpadesc->rgbounds[0].cElements == TDATest->adesc.rgbounds[0].cElements, "got wrong arraydesc element count for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->rgbounds[0].cElements);
6011 ok(U(typeattr->tdescAlias).lpadesc->rgbounds[0].lLbound == TDATest->adesc.rgbounds[0].lLbound, "got wrong arraydesc lower bound for VT %u: 0x%x\n", TDATest->vt, U(typeattr->tdescAlias).lpadesc->rgbounds[0].lLbound);
6012 break;
6013 }
6014
6015 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
6016 ITypeInfo_Release(ti);
6017 }
6018
test_SetTypeDescAlias(SYSKIND kind)6019 static void test_SetTypeDescAlias(SYSKIND kind)
6020 {
6021 CHAR filenameA[MAX_PATH];
6022 WCHAR filenameW[MAX_PATH];
6023 ITypeLib *tl;
6024 ICreateTypeLib2 *ctl;
6025 ITypeInfo *ti;
6026 ICreateTypeInfo *cti;
6027 HREFTYPE hreftype;
6028 TYPEATTR *typeattr;
6029 ULONG href_cbSizeInstance, i;
6030 WORD href_cbAlignment, ptr_size;
6031 HRESULT hr;
6032
6033 static OLECHAR interfaceW[] = {'i','n','t','e','r','f','a','c','e',0};
6034
6035 switch(kind){
6036 case SYS_WIN32:
6037 trace("testing SYS_WIN32\n");
6038 ptr_size = 4;
6039 break;
6040 case SYS_WIN64:
6041 trace("testing SYS_WIN64\n");
6042 ptr_size = 8;
6043 break;
6044 default:
6045 return;
6046 }
6047
6048 GetTempFileNameA(".", "tlb", 0, filenameA);
6049 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
6050
6051 hr = CreateTypeLib2(kind, filenameW, &ctl);
6052 ok(hr == S_OK, "got %08x\n", hr);
6053
6054 hr = ICreateTypeLib2_CreateTypeInfo(ctl, interfaceW, TKIND_INTERFACE, &cti);
6055 ok(hr == S_OK, "got %08x\n", hr);
6056
6057 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
6058 ok(hr == S_OK, "got %08x\n", hr);
6059
6060 hr = ICreateTypeInfo_AddRefTypeInfo(cti, ti, &hreftype);
6061 ok(hr == S_OK, "got %08x\n", hr);
6062
6063 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
6064 ok(hr == S_OK, "got %08x\n", hr);
6065
6066 href_cbSizeInstance = typeattr->cbSizeInstance;
6067 href_cbAlignment = typeattr->cbAlignment;
6068
6069 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
6070
6071 ITypeInfo_Release(ti);
6072 ICreateTypeInfo_Release(cti);
6073
6074 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
6075 ok(hr == S_OK, "got %08x\n", hr);
6076
6077 for(i = 0; TDATests[i].vt; ++i)
6078 testTDA(tl, &TDATests[i], ptr_size, hreftype, href_cbSizeInstance, href_cbAlignment, TRUE);
6079
6080 hr = ICreateTypeLib2_SaveAllChanges(ctl);
6081 ok(hr == S_OK, "got %08x\n", hr);
6082
6083 ITypeLib_Release(tl);
6084 ok(0 == ICreateTypeLib2_Release(ctl), "typelib should have been released\n");
6085
6086 trace("after save...\n");
6087
6088 hr = LoadTypeLibEx(filenameW, REGKIND_NONE, &tl);
6089 ok(hr == S_OK, "got %08x\n", hr);
6090
6091 hr = ITypeLib_GetTypeInfo(tl, 0, &ti);
6092 ok(hr == S_OK, "got %08x\n", hr);
6093
6094 hr = ITypeInfo_GetTypeAttr(ti, &typeattr);
6095 ok(hr == S_OK, "got %08x\n", hr);
6096
6097 href_cbSizeInstance = typeattr->cbSizeInstance;
6098 href_cbAlignment = typeattr->cbAlignment;
6099
6100 ITypeInfo_ReleaseTypeAttr(ti, typeattr);
6101 ITypeInfo_Release(ti);
6102
6103 for(i = 0; TDATests[i].vt; ++i)
6104 testTDA(tl, &TDATests[i], ptr_size, hreftype, href_cbSizeInstance, href_cbAlignment, FALSE);
6105
6106 ok(0 == ITypeLib_Release(tl), "typelib should have been released\n");
6107
6108 DeleteFileA(filenameA);
6109 }
6110
test_GetLibAttr(void)6111 static void test_GetLibAttr(void)
6112 {
6113 ULONG ref1, ref2;
6114 TLIBATTR *attr;
6115 ITypeLib *tl;
6116 HRESULT hr;
6117
6118 hr = LoadTypeLib(wszStdOle2, &tl);
6119 ok(hr == S_OK, "got 0x%08x\n", hr);
6120
6121 ref1 = ITypeLib_AddRef(tl);
6122 ITypeLib_Release(tl);
6123
6124 hr = ITypeLib_GetLibAttr(tl, &attr);
6125 ok(hr == S_OK, "got 0x%08x\n", hr);
6126
6127 ref2 = ITypeLib_AddRef(tl);
6128 ITypeLib_Release(tl);
6129 ok(ref2 == ref1, "got %d, %d\n", ref2, ref1);
6130
6131 ITypeLib_ReleaseTLibAttr(tl, attr);
6132 ITypeLib_Release(tl);
6133 }
6134
uk_QueryInterface(IUnknown * obj,REFIID iid,void ** out)6135 static HRESULT WINAPI uk_QueryInterface(IUnknown *obj, REFIID iid, void **out)
6136 {
6137 return E_NOINTERFACE;
6138 }
6139
uk_AddRef(IUnknown * obj)6140 static ULONG WINAPI uk_AddRef(IUnknown *obj)
6141 {
6142 return 2;
6143 }
6144
uk_Release(IUnknown * obj)6145 static ULONG WINAPI uk_Release(IUnknown *obj)
6146 {
6147 return 1;
6148 }
6149
6150 IUnknownVtbl vt = {
6151 uk_QueryInterface,
6152 uk_AddRef,
6153 uk_Release,
6154 };
6155
6156 IUnknown uk = {&vt};
6157
test_stub(void)6158 static void test_stub(void)
6159 {
6160 BOOL is_wow64 = FALSE;
6161 DWORD *sam_list;
6162 HRESULT hr;
6163 ITypeLib *stdole;
6164 ICreateTypeLib2 *ctl;
6165 ICreateTypeInfo *cti;
6166 ITypeLib *tl;
6167 ITypeInfo *unk, *ti;
6168 HREFTYPE href;
6169 char filenameA[MAX_PATH];
6170 WCHAR filenameW[MAX_PATH];
6171 int i;
6172
6173 static const GUID libguid = {0x3b9ff02e,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
6174 static const GUID interfaceguid = {0x3b9ff02f,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
6175 static const GUID coclassguid = {0x3b9ff030,0x9675,0x4861,{0xb7,0x81,0xce,0xae,0xa4,0x78,0x2a,0xcc}};
6176 static OLECHAR interfaceW[] = {'i','n','t','e','r','f','a','c','e',0};
6177 static OLECHAR classW[] = {'c','l','a','s','s',0};
6178 static DWORD sam_list32[] = { 0, ~0 };
6179 static DWORD sam_list64[] = { 0, KEY_WOW64_32KEY, KEY_WOW64_64KEY, ~0 };
6180
6181 if (pIsWow64Process)
6182 pIsWow64Process(GetCurrentProcess(), &is_wow64);
6183 if (is_wow64 || is_win64)
6184 sam_list = sam_list64;
6185 else
6186 sam_list = sam_list32;
6187
6188 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
6189
6190 hr = LoadTypeLib(wszStdOle2, &stdole);
6191 ok(hr == S_OK, "got %08x\n", hr);
6192
6193 hr = ITypeLib_GetTypeInfoOfGuid(stdole, &IID_IUnknown, &unk);
6194 ok(hr == S_OK, "got %08x\n", hr);
6195
6196 GetTempFileNameA(".", "tlb", 0, filenameA);
6197 MultiByteToWideChar(CP_ACP, 0, filenameA, -1, filenameW, MAX_PATH);
6198
6199 hr = CreateTypeLib2(SYS_WIN32, filenameW, &ctl);
6200 ok(hr == S_OK, "got %08x\n", hr);
6201
6202 hr = ICreateTypeLib2_SetGuid(ctl, &libguid);
6203 ok(hr == S_OK, "got %08x\n", hr);
6204
6205 hr = ICreateTypeLib2_SetLcid(ctl, LOCALE_NEUTRAL);
6206 ok(hr == S_OK, "got %08x\n", hr);
6207
6208 hr = ICreateTypeLib2_CreateTypeInfo(ctl, interfaceW, TKIND_INTERFACE, &cti);
6209 ok(hr == S_OK, "got %08x\n", hr);
6210
6211 hr = ICreateTypeInfo_SetGuid(cti, &interfaceguid);
6212 ok(hr == S_OK, "got %08x\n", hr);
6213
6214 hr = ICreateTypeInfo_SetTypeFlags(cti, TYPEFLAG_FOLEAUTOMATION);
6215 ok(hr == S_OK, "got %08x\n", hr);
6216
6217 hr = ICreateTypeInfo_AddRefTypeInfo(cti, unk, &href);
6218 ok(hr == S_OK, "got %08x\n", hr);
6219
6220 hr = ICreateTypeInfo_AddImplType(cti, 0, href);
6221 ok(hr == S_OK, "got %08x\n", hr);
6222
6223 hr = ICreateTypeInfo_QueryInterface(cti, &IID_ITypeInfo, (void**)&ti);
6224 ok(hr == S_OK, "got %08x\n", hr);
6225
6226 ICreateTypeInfo_Release(cti);
6227 ITypeInfo_Release(unk);
6228 ITypeLib_Release(stdole);
6229
6230 hr = ICreateTypeLib2_CreateTypeInfo(ctl, classW, TKIND_COCLASS, &cti);
6231 ok(hr == S_OK, "got %08x\n", hr);
6232
6233 hr = ICreateTypeInfo_SetGuid(cti, &coclassguid);
6234 ok(hr == S_OK, "got %08x\n", hr);
6235
6236 hr = ICreateTypeInfo_AddRefTypeInfo(cti, ti, &href);
6237 ok(hr == S_OK, "got %08x\n", hr);
6238
6239 hr = ICreateTypeInfo_AddImplType(cti, 0, href);
6240 ok(hr == S_OK, "got %08x\n", hr);
6241
6242 ITypeInfo_Release(ti);
6243 ICreateTypeInfo_Release(cti);
6244
6245 hr = ICreateTypeLib2_SaveAllChanges(ctl);
6246 ok(hr == S_OK, "got %08x\n", hr);
6247
6248 hr = ICreateTypeLib2_QueryInterface(ctl, &IID_ITypeLib, (void**)&tl);
6249 ok(hr == S_OK, "got %08x\n", hr);
6250
6251 for (i = 0; sam_list[i] != ~0; i++)
6252 {
6253 IPSFactoryBuffer *factory;
6254 IRpcStubBuffer *base_stub;
6255 REGSAM side = sam_list[i];
6256 CLSID clsid;
6257 HKEY hkey;
6258 LONG lr;
6259
6260 hr = RegisterTypeLib(tl, filenameW, NULL);
6261 if (hr == TYPE_E_REGISTRYACCESS)
6262 {
6263 win_skip("Insufficient privileges to register typelib in the registry\n");
6264 break;
6265 }
6266 ok(hr == S_OK, "got %08x, side: %04x\n", hr, side);
6267
6268 /* SYS_WIN32 typelibs should be registered only as 32-bit */
6269 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "TypeLib\\{3b9ff02e-9675-4861-b781-ceaea4782acc}\\0.0\\0\\win64", 0, KEY_READ | side, &hkey);
6270 ok(lr == ERROR_FILE_NOT_FOUND, "got wrong return code: %u, side: %04x\n", lr, side);
6271
6272 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "TypeLib\\{3b9ff02e-9675-4861-b781-ceaea4782acc}\\0.0\\0\\win32", 0, KEY_READ | side, &hkey);
6273 ok(lr == ERROR_SUCCESS, "got wrong return code: %u, side: %04x\n", lr, side);
6274 RegCloseKey(hkey);
6275
6276 /* Simulate pre-win7 installers that create interface key on one side */
6277 if (side != 0)
6278 {
6279 WCHAR guidW[40];
6280 REGSAM opposite = side ^ (KEY_WOW64_64KEY | KEY_WOW64_32KEY);
6281
6282 StringFromGUID2(&interfaceguid, guidW, ARRAY_SIZE(guidW));
6283
6284 /* Delete the opposite interface key */
6285 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface", 0, KEY_READ | opposite, &hkey);
6286 ok(lr == ERROR_SUCCESS, "got wrong return code: %u, side: %04x\n", lr, side);
6287 lr = myRegDeleteTreeW(hkey, guidW, opposite);
6288 ok(lr == ERROR_SUCCESS, "got wrong return code: %u, side: %04x\n", lr, side);
6289 RegCloseKey(hkey);
6290
6291 /* Is our side interface key affected by above operation? */
6292 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "Interface\\{3b9ff02f-9675-4861-b781-ceaea4782acc}", 0, KEY_READ | side, &hkey);
6293 ok(lr == ERROR_SUCCESS || broken(lr == ERROR_FILE_NOT_FOUND), "got wrong return code: %u, side: %04x\n", lr, side);
6294 if (lr == ERROR_FILE_NOT_FOUND)
6295 {
6296 /* win2k3, vista, 2008 */
6297 win_skip("Registry reflection is enabled on this platform.\n");
6298 goto next;
6299 }
6300 RegCloseKey(hkey);
6301
6302 /* Opposite side typelib key still exists */
6303 lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "TypeLib\\{3b9ff02e-9675-4861-b781-ceaea4782acc}\\0.0\\0\\win32", 0, KEY_READ | opposite, &hkey);
6304 ok(lr == ERROR_SUCCESS, "got wrong return code: %u, side: %04x\n", lr, side);
6305 RegCloseKey(hkey);
6306 }
6307
6308 hr = CoGetPSClsid(&interfaceguid, &clsid);
6309 ok(hr == S_OK, "got: %x, side: %04x\n", hr, side);
6310
6311 hr = CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL,
6312 &IID_IPSFactoryBuffer, (void **)&factory);
6313 ok(hr == S_OK, "got: %x, side: %04x\n", hr, side);
6314
6315 hr = IPSFactoryBuffer_CreateStub(factory, &interfaceguid, &uk, &base_stub);
6316 ok(hr == S_OK, "got: %x, side: %04x\n", hr, side);
6317 IRpcStubBuffer_Release(base_stub);
6318
6319 IPSFactoryBuffer_Release(factory);
6320 next:
6321 hr = UnRegisterTypeLib(&libguid, 0, 0, 0, SYS_WIN32);
6322 ok(hr == S_OK, "got: %x, side: %04x\n", hr, side);
6323 }
6324
6325 ITypeLib_Release(tl);
6326 ok(0 == ICreateTypeLib2_Release(ctl), "Typelib still has references\n");
6327
6328 DeleteFileW(filenameW);
6329
6330 CoUninitialize();
6331 }
6332
test_dep(void)6333 static void test_dep(void) {
6334 HRESULT hr;
6335 const char *refFilename;
6336 WCHAR refFilenameW[MAX_PATH];
6337 ITypeLib *preftLib;
6338 ITypeInfo *preftInfo;
6339 char filename[MAX_PATH];
6340 WCHAR filenameW[MAX_PATH];
6341 ICreateTypeLib2 *pctLib;
6342 ICreateTypeInfo *pctInfo;
6343 ITypeLib *ptLib;
6344 ITypeInfo *ptInfo;
6345 ITypeInfo *ptInfoExt = NULL;
6346 HREFTYPE refType;
6347
6348 static WCHAR ifacenameW[] = {'I','T','e','s','t','D','e','p',0};
6349
6350 static const GUID libguid = {0xe0228f26,0x2946,0x478c,{0xb6,0x4a,0x93,0xfe,0xef,0xa5,0x05,0x32}};
6351 static const GUID ifaceguid = {0x394376dd,0x3bb8,0x4804,{0x8c,0xcc,0x95,0x59,0x43,0x40,0x04,0xf3}};
6352
6353 trace("Starting typelib dependency tests\n");
6354
6355 refFilename = create_test_typelib(2);
6356 MultiByteToWideChar(CP_ACP, 0, refFilename, -1, refFilenameW, MAX_PATH);
6357
6358 hr = LoadTypeLibEx(refFilenameW, REGKIND_NONE, &preftLib);
6359 ok(hr == S_OK, "got %08x\n", hr);
6360
6361 hr = ITypeLib_GetTypeInfoOfGuid(preftLib, &IID_ISimpleIface, &preftInfo);
6362 ok(hr == S_OK, "got %08x\n", hr);
6363
6364 GetTempFileNameA(".", "tlb", 0, filename);
6365 MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH);
6366
6367 if(sizeof(void*) == 8) {
6368 hr = CreateTypeLib2(SYS_WIN64, filenameW, &pctLib);
6369 ok(hr == S_OK, "got %08x\n", hr);
6370 } else {
6371 hr = CreateTypeLib2(SYS_WIN32, filenameW, &pctLib);
6372 ok(hr == S_OK, "got %08x\n", hr);
6373 }
6374
6375 hr = ICreateTypeLib2_SetGuid(pctLib, &libguid);
6376 ok(hr == S_OK, "got %08x\n", hr);
6377
6378 hr = ICreateTypeLib2_SetLcid(pctLib, LOCALE_NEUTRAL);
6379 ok(hr == S_OK, "got %08x\n", hr);
6380
6381 hr = ICreateTypeLib2_CreateTypeInfo(pctLib, ifacenameW, TKIND_INTERFACE, &pctInfo);
6382 ok(hr == S_OK, "got %08x\n", hr);
6383
6384 hr = ICreateTypeInfo_SetGuid(pctInfo, &ifaceguid);
6385 ok(hr == S_OK, "got %08x\n", hr);
6386
6387 hr = ICreateTypeInfo_SetTypeFlags(pctInfo, TYPEFLAG_FOLEAUTOMATION);
6388 ok(hr == S_OK, "got %08x\n", hr);
6389
6390 hr = ICreateTypeInfo_AddRefTypeInfo(pctInfo, preftInfo, &refType);
6391 ok(hr == S_OK, "got %08x\n", hr);
6392
6393 hr = ICreateTypeInfo_AddImplType(pctInfo, 0, refType);
6394 ok(hr == S_OK, "got %08x\n", hr);
6395
6396 ICreateTypeInfo_Release(pctInfo);
6397
6398 hr = ICreateTypeLib2_SaveAllChanges(pctLib);
6399 ok(hr == S_OK, "got %08x\n", hr);
6400
6401 ICreateTypeLib2_Release(pctLib);
6402
6403 ITypeInfo_Release(preftInfo);
6404 ITypeLib_Release(preftLib);
6405
6406 DeleteFileW(refFilenameW);
6407
6408 hr = LoadTypeLibEx(filenameW, REGKIND_NONE, &ptLib);
6409 ok(hr == S_OK, "got: %x\n", hr);
6410
6411 hr = ITypeLib_GetTypeInfoOfGuid(ptLib, &ifaceguid, &ptInfo);
6412 ok(hr == S_OK, "got: %x\n", hr);
6413
6414 hr = ITypeInfo_GetRefTypeOfImplType(ptInfo, 0, &refType);
6415 ok(hr == S_OK, "got: %x\n", hr);
6416
6417 hr = ITypeInfo_GetRefTypeInfo(ptInfo, refType, &ptInfoExt);
6418 ok(hr == S_OK || broken(hr == TYPE_E_CANTLOADLIBRARY) /* win 2000 */, "got: %x\n", hr);
6419
6420 ITypeInfo_Release(ptInfo);
6421 if(ptInfoExt)
6422 ITypeInfo_Release(ptInfoExt);
6423 ITypeLib_Release(ptLib);
6424
6425 DeleteFileW(filenameW);
6426 }
6427
START_TEST(typelib)6428 START_TEST(typelib)
6429 {
6430 const char *filename;
6431
6432 init_function_pointers();
6433
6434 ref_count_test(wszStdOle2);
6435 test_TypeComp();
6436 test_CreateDispTypeInfo();
6437 test_TypeInfo();
6438 test_DispCallFunc();
6439 test_QueryPathOfRegTypeLib(32);
6440 if(sizeof(void*) == 8){
6441 test_QueryPathOfRegTypeLib(64);
6442 test_CreateTypeLib(SYS_WIN64);
6443 test_SetTypeDescAlias(SYS_WIN64);
6444 }
6445 test_CreateTypeLib(SYS_WIN32);
6446 test_SetTypeDescAlias(SYS_WIN32);
6447 test_inheritance();
6448 test_SetVarHelpContext();
6449 test_SetFuncAndParamNames();
6450 test_SetDocString();
6451 test_FindName();
6452
6453 if ((filename = create_test_typelib(2)))
6454 {
6455 test_dump_typelib( filename );
6456 DeleteFileA( filename );
6457 }
6458
6459 test_register_typelib(TRUE);
6460 test_register_typelib(FALSE);
6461 test_create_typelibs();
6462 test_LoadTypeLib();
6463 test_TypeInfo2_GetContainingTypeLib();
6464 test_LoadRegTypeLib();
6465 test_GetLibAttr();
6466 test_stub();
6467 test_dep();
6468 }
6469