2 * Copyright 2012 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(msident
);
30 static inline void* __WINE_ALLOC_SIZE(1) heap_alloc(size_t size
)
32 return HeapAlloc(GetProcessHeap(), 0, size
);
35 static inline BOOL
heap_free(void *mem
)
37 return HeapFree(GetProcessHeap(), 0, mem
);
40 static HINSTANCE msident_instance
;
43 IEnumUserIdentity IEnumUserIdentity_iface
;
47 static inline EnumUserIdentity
*impl_from_IEnumUserIdentity(IEnumUserIdentity
*iface
)
49 return CONTAINING_RECORD(iface
, EnumUserIdentity
, IEnumUserIdentity_iface
);
52 static HRESULT WINAPI
EnumUserIdentity_QueryInterface(IEnumUserIdentity
*iface
, REFIID riid
, void **ppv
)
54 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
56 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
57 TRACE("(IID_IUnknown %p)\n", ppv
);
58 *ppv
= &This
->IEnumUserIdentity_iface
;
59 }else if(IsEqualGUID(&IID_IEnumUserIdentity
, riid
)) {
60 TRACE("(IID_IEnumUserIdentity %p)\n", ppv
);
61 *ppv
= &This
->IEnumUserIdentity_iface
;
63 WARN("(%s %p)\n", debugstr_guid(riid
), ppv
);
68 IUnknown_AddRef((IUnknown
*)*ppv
);
72 static ULONG WINAPI
EnumUserIdentity_AddRef(IEnumUserIdentity
*iface
)
74 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
75 LONG ref
= InterlockedIncrement(&This
->ref
);
77 TRACE("(%p) ref=%d\n", This
, ref
);
82 static ULONG WINAPI
EnumUserIdentity_Release(IEnumUserIdentity
*iface
)
84 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
85 LONG ref
= InterlockedDecrement(&This
->ref
);
87 TRACE("(%p) ref=%d\n", This
, ref
);
95 static HRESULT WINAPI
EnumUserIdentity_Next(IEnumUserIdentity
*iface
, ULONG celt
, IUnknown
**rgelt
, ULONG
*pceltFetched
)
97 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
98 FIXME("(%p)->(%u %p %p)\n", This
, celt
, rgelt
, pceltFetched
);
102 static HRESULT WINAPI
EnumUserIdentity_Skip(IEnumUserIdentity
*iface
, ULONG celt
)
104 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
105 FIXME("(%p)->(%u)\n", This
, celt
);
109 static HRESULT WINAPI
EnumUserIdentity_Reset(IEnumUserIdentity
*iface
)
111 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
112 FIXME("(%p)->()\n", This
);
116 static HRESULT WINAPI
EnumUserIdentity_Clone(IEnumUserIdentity
*iface
, IEnumUserIdentity
**ppenum
)
118 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
119 FIXME("(%p)->(%p)\n", This
, ppenum
);
123 static HRESULT WINAPI
EnumUserIdentity_GetCount(IEnumUserIdentity
*iface
, ULONG
*pnCount
)
125 EnumUserIdentity
*This
= impl_from_IEnumUserIdentity(iface
);
127 FIXME("(%p)->(%p)\n", This
, pnCount
);
133 static const IEnumUserIdentityVtbl EnumUserIdentityVtbl
= {
134 EnumUserIdentity_QueryInterface
,
135 EnumUserIdentity_AddRef
,
136 EnumUserIdentity_Release
,
137 EnumUserIdentity_Next
,
138 EnumUserIdentity_Skip
,
139 EnumUserIdentity_Reset
,
140 EnumUserIdentity_Clone
,
141 EnumUserIdentity_GetCount
144 static HRESULT WINAPI
UserIdentityManager_QueryInterface(IUserIdentityManager
*iface
, REFIID riid
, void **ppv
)
146 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
147 TRACE("(IID_IUnknown %p)\n", ppv
);
149 }else if(IsEqualGUID(&IID_IUserIdentityManager
, riid
)) {
150 TRACE("(IID_IUserIdentityManager %p)\n", ppv
);
153 WARN("(%s %p)\n", debugstr_guid(riid
), ppv
);
155 return E_NOINTERFACE
;
158 IUnknown_AddRef((IUnknown
*)*ppv
);
162 static ULONG WINAPI
UserIdentityManager_AddRef(IUserIdentityManager
*iface
)
168 static ULONG WINAPI
UserIdentityManager_Release(IUserIdentityManager
*iface
)
174 static HRESULT WINAPI
UserIdentityManager_EnumIdentities(IUserIdentityManager
*iface
, IEnumUserIdentity
**ppEnumUser
)
176 EnumUserIdentity
*ret
;
178 TRACE("(%p)\n", ppEnumUser
);
180 ret
= heap_alloc(sizeof(*ret
));
182 return E_OUTOFMEMORY
;
184 ret
->IEnumUserIdentity_iface
.lpVtbl
= &EnumUserIdentityVtbl
;
187 *ppEnumUser
= &ret
->IEnumUserIdentity_iface
;
191 static HRESULT WINAPI
UserIdentityManager_ManageIdentities(IUserIdentityManager
*iface
, HWND hwndParent
, DWORD dwFlags
)
193 FIXME("(%p %x)\n", hwndParent
, dwFlags
);
197 static HRESULT WINAPI
UserIdentityManager_Logon(IUserIdentityManager
*iface
, HWND hwndParent
,
198 DWORD dwFlags
, IUserIdentity
**ppIdentity
)
200 FIXME("(%p %x %p)\n", hwndParent
, dwFlags
, ppIdentity
);
201 return E_USER_CANCELLED
;
204 static HRESULT WINAPI
UserIdentityManager_Logoff(IUserIdentityManager
*iface
, HWND hwndParent
)
206 FIXME("(%p)\n", hwndParent
);
210 static HRESULT WINAPI
UserIdentityManager_GetIdentityByCookie(IUserIdentityManager
*iface
, GUID
*uidCookie
,
211 IUserIdentity
**ppIdentity
)
213 FIXME("(%p %p)\n", uidCookie
, ppIdentity
);
217 static const IUserIdentityManagerVtbl UserIdentityManagerVtbl
= {
218 UserIdentityManager_QueryInterface
,
219 UserIdentityManager_AddRef
,
220 UserIdentityManager_Release
,
221 UserIdentityManager_EnumIdentities
,
222 UserIdentityManager_ManageIdentities
,
223 UserIdentityManager_Logon
,
224 UserIdentityManager_Logoff
,
225 UserIdentityManager_GetIdentityByCookie
228 static IUserIdentityManager UserIdentityManager
= { &UserIdentityManagerVtbl
};
230 static HRESULT WINAPI
UserIdentityManager_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **ppv
)
234 return IUserIdentityManager_QueryInterface(&UserIdentityManager
, riid
, ppv
);
237 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
241 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
242 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
244 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
245 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
250 IUnknown_AddRef((IUnknown
*)*ppv
);
254 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
255 return E_NOINTERFACE
;
258 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
260 TRACE("(%p)\n", iface
);
264 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
266 TRACE("(%p)\n", iface
);
270 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
272 TRACE("(%p)->(%x)\n", iface
, fLock
);
276 static const IClassFactoryVtbl UserIdentityManagerCFVtbl
= {
277 ClassFactory_QueryInterface
,
279 ClassFactory_Release
,
280 UserIdentityManager_CreateInstance
,
281 ClassFactory_LockServer
284 static IClassFactory UserIdentityManagerCF
= { &UserIdentityManagerCFVtbl
};
286 /******************************************************************
287 * DllMain (msident.@)
289 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
291 TRACE("(%p %d %p)\n", hInstDLL
, fdwReason
, lpv
);
295 case DLL_WINE_PREATTACH
:
296 return FALSE
; /* prefer native version */
297 case DLL_PROCESS_ATTACH
:
298 msident_instance
= hInstDLL
;
299 DisableThreadLibraryCalls(hInstDLL
);
306 /***********************************************************************
307 * DllGetClassObject (msident.@)
309 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
311 if(IsEqualGUID(&CLSID_UserIdentityManager
, rclsid
)) {
312 TRACE("CLSID_UserIdentityManager\n");
313 return IClassFactory_QueryInterface(&UserIdentityManagerCF
, riid
, ppv
);
316 FIXME("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
317 return CLASS_E_CLASSNOTAVAILABLE
;
320 /***********************************************************************
321 * DllCanUnloadNow (msident.@)
323 HRESULT WINAPI
DllCanUnloadNow(void)
328 /***********************************************************************
329 * DllRegisterServer (msident.@)
331 HRESULT WINAPI
DllRegisterServer(void)
334 return __wine_register_resources(msident_instance
);
337 /***********************************************************************
338 * DllUnregisterServer (msident.@)
340 HRESULT WINAPI
DllUnregisterServer(void)
343 return __wine_unregister_resources(msident_instance
);