diff --git a/dlls/sapi/sapi_private.h b/dlls/sapi/sapi_private.h index 7a5c14e9db6..0f6ca4a7f2e 100644 --- a/dlls/sapi/sapi_private.h +++ b/dlls/sapi/sapi_private.h @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "wine/unicode.h" + HRESULT data_key_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ) DECLSPEC_HIDDEN; @@ -30,3 +32,18 @@ static inline BOOL heap_free(void *mem) { return HeapFree(GetProcessHeap(), 0, mem); } + +static inline LPWSTR heap_strdupW(LPCWSTR str) +{ + LPWSTR ret = NULL; + DWORD size; + + if (str) + { + size = (strlenW( str ) + 1) * sizeof(WCHAR); + ret = heap_alloc( size ); + if (ret) memcpy( ret, str, size ); + } + + return ret; +} diff --git a/dlls/sapi/token.c b/dlls/sapi/token.c index 03ce0a74f02..8ad13a87d52 100644 --- a/dlls/sapi/token.c +++ b/dlls/sapi/token.c @@ -231,6 +231,9 @@ struct token_enum { ISpObjectTokenEnumBuilder ISpObjectTokenEnumBuilder_iface; LONG ref; + + BOOL init; + WCHAR *req, *opt; }; struct token_enum *impl_from_ISpObjectTokenEnumBuilder( ISpObjectTokenEnumBuilder *iface ) @@ -276,7 +279,11 @@ static ULONG WINAPI token_enum_Release( ISpObjectTokenEnumBuilder *iface ) TRACE( "(%p) ref = %u\n", This, ref ); if (!ref) + { + heap_free( This->req ); + heap_free( This->opt ); heap_free( This ); + } return ref; } @@ -326,8 +333,30 @@ static HRESULT WINAPI token_enum_GetCount( ISpObjectTokenEnumBuilder *iface, static HRESULT WINAPI token_enum_SetAttribs( ISpObjectTokenEnumBuilder *iface, LPCWSTR req, LPCWSTR opt) { - FIXME( "stub\n" ); - return E_NOTIMPL; + struct token_enum *This = impl_from_ISpObjectTokenEnumBuilder( iface ); + + TRACE( "(%p)->(%s %s)\n", This, debugstr_w( req ), debugstr_w( opt ) ); + + if (This->init) return SPERR_ALREADY_INITIALIZED; + + if (req) + { + This->req = heap_strdupW( req ); + if (!This->req) goto out_of_mem; + } + + if (opt) + { + This->opt = heap_strdupW( opt ); + if (!This->opt) goto out_of_mem; + } + + This->init = TRUE; + return S_OK; + +out_of_mem: + heap_free( This->req ); + return E_OUTOFMEMORY; } static HRESULT WINAPI token_enum_AddTokens( ISpObjectTokenEnumBuilder *iface, @@ -385,6 +414,9 @@ HRESULT token_enum_create( IUnknown *outer, REFIID iid, void **obj ) if (!This) return E_OUTOFMEMORY; This->ISpObjectTokenEnumBuilder_iface.lpVtbl = &token_enum_vtbl; This->ref = 1; + This->req = NULL; + This->opt = NULL; + This->init = FALSE; hr = ISpObjectTokenEnumBuilder_QueryInterface( &This->ISpObjectTokenEnumBuilder_iface, iid, obj );