From 0aab7e8ef8f33b63fd3589ecf3413822cc36c37b Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 22 Sep 2021 19:01:44 +1000 Subject: [PATCH 4/8] sapi: EnumTokens setup enumeration members --- dlls/sapi/token.c | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index 0a160455d2b..6bf66bc0d5b 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -48,6 +48,22 @@ static struct data_key *impl_from_ISpRegDataKey( ISpRegDataKey *iface ) return CONTAINING_RECORD( iface, struct data_key, ISpRegDataKey_iface ); } +struct token_enum +{ + ISpObjectTokenEnumBuilder ISpObjectTokenEnumBuilder_iface; + LONG ref; + + BOOL init; + WCHAR *req, *opt; + ULONG count; + HKEY key; +}; + +static struct token_enum *impl_from_ISpObjectTokenEnumBuilder( ISpObjectTokenEnumBuilder *iface ) +{ + return CONTAINING_RECORD( iface, struct token_enum, ISpObjectTokenEnumBuilder_iface ); +} + static HRESULT WINAPI data_key_QueryInterface( ISpRegDataKey *iface, REFIID iid, void **obj ) { struct data_key *This = impl_from_ISpRegDataKey( iface ); @@ -503,9 +519,11 @@ static HRESULT WINAPI token_category_EnumTokens( ISpObjectTokenCategory *iface, { struct token_category *This = impl_from_ISpObjectTokenCategory( iface ); ISpObjectTokenEnumBuilder *builder; + struct token_enum *tokenenum; + struct data_key *this_data_key; HRESULT hr; - FIXME( "(%p)->(%s %s %p): semi-stub\n", This, debugstr_w( req ), debugstr_w( opt ), enum_tokens ); + TRACE( "(%p)->(%s %s %p)\n", This, debugstr_w( req ), debugstr_w( opt ), enum_tokens ); if (!This->data_key) return SPERR_UNINITIALIZED; @@ -516,7 +534,15 @@ static HRESULT WINAPI token_category_EnumTokens( ISpObjectTokenCategory *iface, hr = ISpObjectTokenEnumBuilder_SetAttribs( builder, req, opt ); if (FAILED(hr)) goto fail; - /* FIXME: Build the enumerator */ + this_data_key = impl_from_ISpRegDataKey( This->data_key ); + + tokenenum = impl_from_ISpObjectTokenEnumBuilder( builder ); + + if(!RegOpenKeyExW( this_data_key->key, L"Tokens", 0, KEY_ALL_ACCESS, &tokenenum->key )) + { + RegQueryInfoKeyW(tokenenum->key, NULL, NULL, NULL, &tokenenum->count, NULL, NULL, + NULL, NULL, NULL, NULL, NULL); + } hr = ISpObjectTokenEnumBuilder_QueryInterface( builder, &IID_IEnumSpObjectTokens, (void **)enum_tokens ); @@ -611,21 +637,6 @@ HRESULT token_category_create( IUnknown *outer, REFIID iid, void **obj ) return hr; } -struct token_enum -{ - ISpObjectTokenEnumBuilder ISpObjectTokenEnumBuilder_iface; - LONG ref; - - BOOL init; - WCHAR *req, *opt; - ULONG count; -}; - -static struct token_enum *impl_from_ISpObjectTokenEnumBuilder( ISpObjectTokenEnumBuilder *iface ) -{ - return CONTAINING_RECORD( iface, struct token_enum, ISpObjectTokenEnumBuilder_iface ); -} - static HRESULT WINAPI token_enum_QueryInterface( ISpObjectTokenEnumBuilder *iface, REFIID iid, void **obj ) { @@ -665,6 +676,8 @@ static ULONG WINAPI token_enum_Release( ISpObjectTokenEnumBuilder *iface ) if (!ref) { + if (This->key) + RegCloseKey(This->key); heap_free( This->req ); heap_free( This->opt ); heap_free( This ); -- 2.33.0