-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCSampleProvider.h
83 lines (68 loc) · 2.76 KB
/
CSampleProvider.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
#pragma once
#include <credentialprovider.h>
#include <windows.h>
#include <strsafe.h>
#include "CSampleCredential.h"
#include "helpers.h"
class CSampleProvider : public ICredentialProvider
{
public:
// IUnknown
IFACEMETHODIMP_(ULONG) AddRef()
{
return ++_cRef;
}
IFACEMETHODIMP_(ULONG) Release()
{
LONG cRef = --_cRef;
if (!cRef)
{
delete this;
}
return cRef;
}
IFACEMETHODIMP QueryInterface(__in REFIID riid, __deref_out void** ppv)
{
static const QITAB qit[] =
{
QITABENT(CSampleProvider, ICredentialProvider), // IID_ICredentialProvider
{0},
};
return QISearch(this, qit, riid, ppv);
}
public:
IFACEMETHODIMP SetUsageScenario(__in CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, __in DWORD dwFlags);
IFACEMETHODIMP SetSerialization(__in const CREDENTIAL_PROVIDER_CREDENTIAL_SERIALIZATION* pcpcs);
IFACEMETHODIMP Advise(__in ICredentialProviderEvents* pcpe, __in UINT_PTR upAdviseContext);
IFACEMETHODIMP UnAdvise();
IFACEMETHODIMP GetFieldDescriptorCount(__out DWORD* pdwCount);
IFACEMETHODIMP GetFieldDescriptorAt(__in DWORD dwIndex, __deref_out CREDENTIAL_PROVIDER_FIELD_DESCRIPTOR** ppcpfd);
IFACEMETHODIMP GetCredentialCount(__out DWORD* pdwCount,
__out_range(<,*pdwCount) DWORD* pdwDefault,
__out BOOL* pbAutoLogonWithDefault);
IFACEMETHODIMP GetCredentialAt(__in DWORD dwIndex,
__deref_out ICredentialProviderCredential** ppcpc);
friend HRESULT CSample_CreateInstance(__in REFIID riid, __deref_out void** ppv);
protected:
CSampleProvider();
__override ~CSampleProvider();
private:
void _CleanUpAllCredentials();
private:
LONG _cRef;
CSampleCredential **_rgpCredentials; // Pointers to the credentials which will be enumerated by this
// Provider.
ICredentialProvider *_pWrappedProvider; // Our wrapped provider.
DWORD _dwCredentialCount; // The number of credentials provided by our wrapped provider.
DWORD _dwWrappedDescriptorCount; // The number of fields on each tile of our wrapped provider's
// credentials.
bool _bEnumeratedSetSerialization;
};