diff --git a/dlls/sapi/tests/token.c b/dlls/sapi/tests/token.c index 887539778a9..1ca49398ad1 100644 --- a/dlls/sapi/tests/token.c +++ b/dlls/sapi/tests/token.c @@ -202,23 +202,23 @@ static void test_object_token(void) ok( cat == (LPVOID)0xdeadbeef, "got %p\n", cat ); hr = ISpObjectToken_SetId( token, NULL, NULL, FALSE ); - todo_wine ok( hr == E_POINTER, "got %08x\n", hr ); + ok( hr == E_POINTER, "got %08x\n", hr ); hr = ISpObjectToken_SetId( token, L"bogus", NULL, FALSE ); - todo_wine ok( hr == E_POINTER, "got %08x\n", hr ); + ok( hr == E_POINTER, "got %08x\n", hr ); hr = ISpObjectToken_SetId( token, NULL, L"bogus", FALSE ); - todo_wine ok( hr == SPERR_NOT_FOUND, "got %08x\n", hr ); + ok( hr == SPERR_NOT_FOUND, "got %08x\n", hr ); hr = ISpObjectToken_SetId( token, NULL, L"HKEY_LOCAL_MACHINE\\SOFTWARE\\winetest bogus", FALSE ); - todo_wine ok( hr == SPERR_NOT_FOUND, "got %08x\n", hr ); + ok( hr == SPERR_NOT_FOUND, "got %08x\n", hr ); /* SetId succeeds even if the key is invalid, but exists */ hr = ISpObjectToken_SetId( token, NULL, L"HKEY_LOCAL_MACHINE\\SOFTWARE", FALSE ); - todo_wine ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08x\n", hr ); hr = ISpObjectToken_SetId( token, NULL, NULL, FALSE ); - todo_wine ok( hr == SPERR_ALREADY_INITIALIZED, "got %08x\n", hr ); + ok( hr == SPERR_ALREADY_INITIALIZED, "got %08x\n", hr ); hr = ISpObjectToken_SetId( token, NULL, L"bogus", FALSE ); - todo_wine ok( hr == SPERR_ALREADY_INITIALIZED, "got %08x\n", hr ); + ok( hr == SPERR_ALREADY_INITIALIZED, "got %08x\n", hr ); hr = ISpObjectToken_GetId( token, NULL ); todo_wine ok( hr == E_POINTER, "got %08x\n", hr ); @@ -265,7 +265,7 @@ static void test_object_token(void) /* NULL appears to auto-detect the category */ hr = ISpObjectToken_SetId( token, NULL, token_id, FALSE ); - todo_wine ok( hr == S_OK, "got %08x\n", hr ); + ok( hr == S_OK, "got %08x\n", hr ); tempW = NULL; hr = ISpObjectToken_GetId( token, &tempW ); diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index f7a00d73f02..b4a318b4ade 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -781,6 +781,8 @@ struct object_token { ISpObjectToken ISpObjectToken_iface; LONG ref; + + HKEY token_key; }; static struct object_token *impl_from_ISpObjectToken( ISpObjectToken *iface ) @@ -827,6 +829,7 @@ static ULONG WINAPI token_Release( ISpObjectToken *iface ) if (!ref) { + if (This->token_key) RegCloseKey( This->token_key ); heap_free( This ); } @@ -923,8 +926,28 @@ static HRESULT WINAPI token_SetId( ISpObjectToken *iface, LPCWSTR category_id, LPCWSTR token_id, BOOL create ) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct object_token *This = impl_from_ISpObjectToken( iface ); + BOOL res; + HRESULT hr; + HKEY root, key; + const WCHAR *subkey; + + FIXME( "(%p)->(%s %s %d): semi-stub\n", This, debugstr_w( category_id ), + debugstr_w(token_id), create ); + + if (This->token_key) return SPERR_ALREADY_INITIALIZED; + + if (!token_id) return E_POINTER; + + hr = parse_cat_id( token_id, &root, &subkey ); + if (hr != S_OK) return SPERR_NOT_FOUND; + + res = RegOpenKeyExW( root, subkey, 0, KEY_ALL_ACCESS, &key ); + if (res) return SPERR_NOT_FOUND; + + This->token_key = key; + + return S_OK; } static HRESULT WINAPI token_GetId( ISpObjectToken *iface, @@ -1047,6 +1070,8 @@ HRESULT token_create( IUnknown *outer, REFIID iid, void **obj ) This->ISpObjectToken_iface.lpVtbl = &token_vtbl; This->ref = 1; + This->token_key = NULL; + hr = ISpObjectToken_QueryInterface( &This->ISpObjectToken_iface, iid, obj ); ISpObjectToken_Release( &This->ISpObjectToken_iface );