Signed-off-by: Myah Caron qsniyg@protonmail.com --- This patchset is a first step towards fixing https://bugs.winehq.org/show_bug.cgi?id=49641
My previous attempt (https://www.winehq.org/pipermail/wine-devel/2020-August/171124.html) was a rather large patch and had tests that I believe were much too invasive (deleting and restoring system registry keys).
Since my previous attempt was dropped (fair enough), in order to reduce the patch review burden, this patch is much smaller and is only meant to cover the bug's use case.
dlls/sapi/tests/token.c | 59 +++++++++++++++++++++++++++++++++++++++++ dlls/sapi/token.c | 34 ++++++++++++++++++++++-- 2 files changed, 91 insertions(+), 2 deletions(-)
diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 9f6689b83f8..aa21bb6dce4 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -116,11 +116,70 @@ static void test_token_enum(void) ISpObjectTokenEnumBuilder_Release( token_enum ); }
+static void test_default_token_id(void) +{ + ISpObjectTokenCategory *cat; + HRESULT hr; + LPWSTR token_id = NULL; + LONG res; + WCHAR regvalue[512]; + DWORD regvalue_size; + + hr = CoCreateInstance( &CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER, + &IID_ISpObjectTokenCategory, (void **)&cat ); + ok( hr == S_OK, "got %08x\n", hr ); + + token_id = (LPWSTR)0xdeadbeef; + hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id ); + ok( hr == SPERR_UNINITIALIZED, "got %08x\n", hr ); + ok( token_id == (LPWSTR)0xdeadbeef, "got %p\n", token_id ); + + hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL ); + ok( hr == SPERR_UNINITIALIZED, "got %08x\n", hr ); + + hr = ISpObjectTokenCategory_SetId( cat, SPCAT_AUDIOOUT, FALSE ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, NULL ); + ok( hr == E_POINTER, "got %08x\n", hr ); + + token_id = (LPWSTR)0xdeadbeef; + hr = ISpObjectTokenCategory_GetDefaultTokenId( cat, &token_id ); + + /* AudioOutput under windows server returns this error */ + if (hr == SPERR_NOT_FOUND) { + /* also happens if TokenEnums/Tokens is empty or doesn't exist */ + skip( "AudioOutput category not found\n" ); + return; + } + + ok( hr == S_OK, "got %08x\n", hr ); + ok( token_id != (LPWSTR)0xdeadbeef && token_id != NULL, "got %p\n", token_id ); + + regvalue_size = sizeof( regvalue ); + res = RegGetValueW( HKEY_LOCAL_MACHINE, L"SOFTWARE\Microsoft\Speech\AudioOutput", + L"DefaultDefaultTokenId", RRF_RT_REG_SZ, NULL, + (LPVOID)®value, ®value_size); + if (res == ERROR_FILE_NOT_FOUND) { + skip( "DefaultDefaultTokenId not found for AudioOutput category (%s)\n", + wine_dbgstr_w(token_id) ); + } else { + ok( res == ERROR_SUCCESS, "got %08x\n", res ); + ok( !wcscmp(regvalue, token_id), + "GetDefaultTokenId (%s) should be equal to the DefaultDefaultTokenId key (%s)\n", + wine_dbgstr_w(token_id), wine_dbgstr_w(regvalue) ); + } + + CoTaskMemFree( token_id ); + ISpObjectTokenCategory_Release( cat ); +} + START_TEST(token) { CoInitialize( NULL ); test_data_key(); test_token_category(); test_token_enum(); + test_default_token_id(); CoUninitialize(); } diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index d2b70c95cfc..21cd958282f 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -489,8 +489,38 @@ static HRESULT WINAPI token_category_SetDefaultTokenId( ISpObjectTokenCategory * static HRESULT WINAPI token_category_GetDefaultTokenId( ISpObjectTokenCategory *iface, LPWSTR *id ) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct token_category *This = impl_from_ISpObjectTokenCategory( iface ); + struct data_key *this_data_key; + LONG res; + WCHAR regvalue[512]; + DWORD regvalue_size = sizeof( regvalue ); + + FIXME( "(%p)->(%p): semi-stub\n", iface, id ); + + if (!This->data_key) + return SPERR_UNINITIALIZED; + + if (!id) + return E_POINTER; + + /* todo: check HKCU's DefaultTokenId before */ + + this_data_key = impl_from_ISpRegDataKey( This->data_key ); + + res = RegGetValueW( this_data_key->key, NULL, L"DefaultDefaultTokenId", RRF_RT_REG_SZ, + NULL, ®value, ®value_size); + if (res == ERROR_FILE_NOT_FOUND) { + return SPERR_NOT_FOUND; + } else if (res != ERROR_SUCCESS) { + /* probably not the correct return value */ + FIXME( "returning %08x\n", res ); + return res; + } + + *id = CoTaskMemAlloc( regvalue_size ); + wcscpy( *id, regvalue ); + + return S_OK; }
const struct ISpObjectTokenCategoryVtbl token_category_vtbl = -- 2.28.0
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78566
Your paranoid android.
=== debiant (32 bit report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
=== debiant (32 bit French report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
=== debiant (32 bit Japanese:Japan report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
=== debiant (32 bit Chinese:China report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
=== debiant (32 bit WoW report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
=== debiant (64 bit WoW report) ===
sapi: token.c:141: Test failed: got 80045040 token.c:144: Test failed: got 80045001 token.c:156: Test failed: got 80045001 token.c:157: Test failed: got DEADBEEF
I believe the test failure is caused by the registry key not being updated for some reason.
It works fine on my end when trying with a new prefix.