[PATCH 0/2] MR10854: oleaut32: Return TYPE_E_BADMODULEKIND from ITypeInfo::CreateInstance for non-coclass.
Native VBScript / oleaut32 returns TYPE_E_BADMODULEKIND when CreateInstance is called on a typeinfo whose typekind is not TKIND_COCLASS (e.g. a TKIND_DISPATCH built via ICreateTypeLib2). Wine currently returns E_INVALIDARG. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10854
From: Francis De Brabandere <francisdb@gmail.com> Native VBScript / oleaut32 returns TYPE_E_BADMODULEKIND when CreateInstance is called on a typeinfo whose typekind is not TKIND_COCLASS (e.g. a TKIND_DISPATCH built via ICreateTypeLib2). Wine currently returns E_INVALIDARG. --- dlls/oleaut32/tests/typelib.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 153964e17d5..9a87be369fc 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -8763,6 +8763,42 @@ static void test_DeleteFuncDesc(void) DeleteFileW(filenameW); } +/* CreateInstance on a non-coclass typeinfo (here TKIND_DISPATCH built + * via ICreateTypeLib2) returns TYPE_E_BADMODULEKIND on native Windows. + * Wine currently returns E_INVALIDARG. */ +static void test_CreateInstance_typekind(void) +{ + WCHAR filenameW[MAX_PATH], temp_path[MAX_PATH]; + static OLECHAR tinameW[] = L"dispiface"; + ICreateTypeLib2 *createtl; + ICreateTypeInfo *createti; + ITypeInfo *ti; + void *obj; + HRESULT hr; + + GetTempPathW(ARRAY_SIZE(temp_path), temp_path); + GetTempFileNameW(temp_path, L"tlb", 0, filenameW); + + hr = CreateTypeLib2(SYS_WIN64, filenameW, &createtl); + ok(hr == S_OK, "CreateTypeLib2 hr=%#lx\n", hr); + hr = ICreateTypeLib2_CreateTypeInfo(createtl, tinameW, TKIND_DISPATCH, &createti); + ok(hr == S_OK, "CreateTypeInfo hr=%#lx\n", hr); + hr = ICreateTypeInfo_LayOut(createti); + ok(hr == S_OK, "LayOut hr=%#lx\n", hr); + hr = ICreateTypeInfo_QueryInterface(createti, &IID_ITypeInfo, (void**)&ti); + ok(hr == S_OK, "QI(ITypeInfo) hr=%#lx\n", hr); + + obj = (void*)0xdeadbeef; + hr = ITypeInfo_CreateInstance(ti, NULL, &IID_IUnknown, &obj); + todo_wine ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance hr=%#lx\n", hr); + ok(!obj, "CreateInstance left obj=%p, expected NULL\n", obj); + + ITypeInfo_Release(ti); + ICreateTypeInfo_Release(createti); + ICreateTypeLib2_Release(createtl); + DeleteFileW(filenameW); +} + START_TEST(typelib) { const WCHAR *filename; @@ -8806,4 +8842,5 @@ START_TEST(typelib) test_stub(); test_DeleteImplType(); test_DeleteFuncDesc(); + test_CreateInstance_typekind(); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10854
From: Francis De Brabandere <francisdb@gmail.com> Match native: when the typeinfo's typekind isn't TKIND_COCLASS, CreateInstance reports TYPE_E_BADMODULEKIND rather than E_INVALIDARG. --- dlls/oleaut32/tests/typelib.c | 2 +- dlls/oleaut32/typelib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 9a87be369fc..08831062474 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -8790,7 +8790,7 @@ static void test_CreateInstance_typekind(void) obj = (void*)0xdeadbeef; hr = ITypeInfo_CreateInstance(ti, NULL, &IID_IUnknown, &obj); - todo_wine ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance hr=%#lx\n", hr); + ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance hr=%#lx\n", hr); ok(!obj, "CreateInstance left obj=%p, expected NULL\n", obj); ITypeInfo_Release(ti); diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index e9997a86d24..2c2cd364cbc 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -8069,7 +8069,7 @@ static HRESULT WINAPI ITypeInfo_fnCreateInstance( ITypeInfo2 *iface, if(pTA->typekind != TKIND_COCLASS) { WARN("CreateInstance on typeinfo of type %x\n", pTA->typekind); - hr = E_INVALIDARG; + hr = TYPE_E_BADMODULEKIND; goto end; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10854
Closed as requested by reviewer, no native-parity fixes without app evidence. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10854#note_139675
This merge request was closed by Francis De Brabandere. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10854
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)