From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/sapi/token.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index 2de3553b3ab..c174b73e08b 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -784,6 +784,7 @@ struct object_token LONG ref;
HKEY token_key; + WCHAR *token_id; };
static struct object_token *impl_from_ISpObjectToken( ISpObjectToken *iface ) @@ -831,6 +832,7 @@ static ULONG WINAPI token_Release( ISpObjectToken *iface ) if (!ref) { if (This->token_key) RegCloseKey( This->token_key ); + heap_free(This->token_id); heap_free( This ); }
@@ -950,6 +952,7 @@ static HRESULT WINAPI token_SetId( ISpObjectToken *iface, if (res) return SPERR_NOT_FOUND;
This->token_key = key; + This->token_id = wcsdup(token_id);
return S_OK; } @@ -1075,6 +1078,7 @@ HRESULT token_create( IUnknown *outer, REFIID iid, void **obj ) This->ref = 1;
This->token_key = NULL; + This->token_id = NULL;
hr = ISpObjectToken_QueryInterface( &This->ISpObjectToken_iface, iid, obj );
On 08/10/2022 12:11, Alistair Leslie-Hughes wrote:
@@ -831,6 +832,7 @@ static ULONG WINAPI token_Release( ISpObjectToken *iface ) if (!ref) { if (This->token_key) RegCloseKey( This->token_key );
heap_free(This->token_id); heap_free( This ); }
This should be free(This->token_id) since you allocated it with wcsdup.
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
--- dlls/sapi/tests/token.c | 14 +++++++------- dlls/sapi/token.c | 24 ++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 9473d56b4d1..a65669b585a 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -185,11 +185,11 @@ static void test_object_token(void) ok( hr == S_OK, "got %08lx\n", hr );
hr = ISpObjectToken_GetId( token, NULL ); - todo_wine ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr ); + ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr );
tempW = (LPWSTR)0xdeadbeef; hr = ISpObjectToken_GetId( token, &tempW ); - todo_wine ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr ); + ok( hr == SPERR_UNINITIALIZED, "got %08lx\n", hr ); ok( tempW == (LPWSTR)0xdeadbeef, "got %s\n", wine_dbgstr_w(tempW) );
hr = ISpObjectToken_GetCategory( token, NULL ); @@ -220,15 +220,15 @@ static void test_object_token(void) ok( hr == SPERR_ALREADY_INITIALIZED, "got %08lx\n", hr );
hr = ISpObjectToken_GetId( token, NULL ); - todo_wine ok( hr == E_POINTER, "got %08lx\n", hr ); + ok( hr == E_POINTER, "got %08lx\n", hr );
hr = ISpObjectToken_GetCategory( token, NULL ); todo_wine ok( hr == E_POINTER, "got %08lx\n", hr );
tempW = NULL; hr = ISpObjectToken_GetId( token, &tempW ); - todo_wine ok( hr == S_OK, "got %08lx\n", hr ); - todo_wine ok( tempW != NULL, "got %p\n", tempW ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempW != NULL, "got %p\n", tempW ); if (tempW) { ok( !wcscmp(tempW, L"HKEY_LOCAL_MACHINE\SOFTWARE"), "got %s\n", wine_dbgstr_w(tempW) ); @@ -268,8 +268,8 @@ static void test_object_token(void)
tempW = NULL; hr = ISpObjectToken_GetId( token, &tempW ); - todo_wine ok( hr == S_OK, "got %08lx\n", hr ); - todo_wine ok( tempW != NULL, "got %p\n", tempW ); + ok( hr == S_OK, "got %08lx\n", hr ); + ok( tempW != NULL, "got %p\n", tempW ); if (tempW) { ok( !wcsncmp(tempW, token_id, wcslen(token_id)), "got %s (expected %s)\n", wine_dbgstr_w(tempW), wine_dbgstr_w(token_id) ); diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index c174b73e08b..33b8c8ed629 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -960,8 +960,28 @@ static HRESULT WINAPI token_SetId( ISpObjectToken *iface, static HRESULT WINAPI token_GetId( ISpObjectToken *iface, LPWSTR *token_id ) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct object_token *This = impl_from_ISpObjectToken( iface ); + + TRACE( "%p, %p\n", This, token_id); + + if (!This->token_key) + return SPERR_UNINITIALIZED; + + if (!token_id) + return E_POINTER; + + if (!This->token_id) + { + FIXME("Loading default category not supported.\n"); + return E_POINTER; + } + + *token_id = CoTaskMemAlloc( (wcslen(This->token_id) + 1) * sizeof(WCHAR)); + if (!*token_id) + return E_OUTOFMEMORY; + + wcscpy(*token_id, This->token_id); + return S_OK; }
static HRESULT WINAPI token_GetCategory( ISpObjectToken *iface,