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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
#pragma once
/**
* This class represents an abstraction of a real device.
* Driver implementors should replace this with their own
* device I/O classes/libraries.
*/
class FakeDevice
{
public:
FakeDevice() : m_dwLastObjectID(0)
{
}
~FakeDevice()
{
}
HRESULT InitializeContent();
FakeContactsService* GetContactsService();
ACCESS_SCOPE GetAccessScope(
_In_ IPortableDeviceValues* pParams);
// Device Capabilities
// These are legacy commands that apply to the whole device, no access scope is required
HRESULT GetSupportedCommands(
_In_ IPortableDeviceKeyCollection* pCommands);
HRESULT GetCommandOptions(
_In_ REFPROPERTYKEY Command,
_In_ IPortableDeviceValues* pOptions);
HRESULT GetSupportedFunctionalCategories(
_In_ IPortableDevicePropVariantCollection* pFunctionalCategories);
HRESULT GetFunctionalObjects(
_In_ REFGUID guidFunctionalCategory,
_In_ IPortableDevicePropVariantCollection* pFunctionalObjects);
HRESULT GetSupportedContentTypes(
_In_ REFGUID guidFunctionalCategory,
_In_ IPortableDevicePropVariantCollection* pContentTypes);
HRESULT GetSupportedFormats(
_In_ REFGUID guidContentType,
_In_ IPortableDevicePropVariantCollection* pFormats);
HRESULT GetSupportedFormatProperties(
_In_ REFGUID guidObjectFormat,
_In_ IPortableDeviceKeyCollection* pKeys);
HRESULT GetFixedPropertyAttributes(
_In_ REFGUID guidObjectFormat,
_In_ REFPROPERTYKEY Key,
_In_ IPortableDeviceValues* pAttributes);
HRESULT GetSupportedEvents(
_In_ IPortableDevicePropVariantCollection* pEvents);
HRESULT GetEventOptions(
_In_ IPortableDeviceValues* pOptions);
// Enumeration
// Depending on the access scope, the driver can display only objects within the current
// scoped hierarchy tree
void InitializeEnumerationContext(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszParentID,
_In_ WpdObjectEnumeratorContext* pEnumContext);
HRESULT FindNext(
const DWORD dwNumObjectsRequested,
_In_ WpdObjectEnumeratorContext* pEnumContext,
_In_ IPortableDevicePropVariantCollection* pObjectIDCollection,
_Out_opt_ DWORD* pdwNumObjectsEnumerated);
HRESULT GetObjectIDsByFormat(
ACCESS_SCOPE Scope,
_In_ REFGUID guidObjectFormat,
_In_ LPCWSTR wszParentObjectID,
const DWORD dwDepth,
_In_ IPortableDevicePropVariantCollection* pObjectIDs);
HRESULT GetObjectIDsFromPersistentUniqueIDs(
ACCESS_SCOPE Scope,
_In_ IPortableDevicePropVariantCollection* pPersistentIDs,
_In_ IPortableDevicePropVariantCollection* pObjectIDs);
// Property Management
// Depending on the access scope, the driver can allow access to properties of objects within the current
// scoped hierarchy tree
HRESULT GetSupportedProperties(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceKeyCollection* pKeys);
HRESULT GetAllPropertyValues(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceValues* pValues);
HRESULT GetPropertyValues(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceKeyCollection* pKeys,
_In_ IPortableDeviceValues* pValues);
HRESULT SetPropertyValues(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceValues* pValues,
_In_ IPortableDeviceValues* pResults,
_In_ IPortableDeviceValues* pEventParams,
_Out_ bool* pbObjectChanged);
HRESULT GetPropertyAtributes(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ REFPROPERTYKEY Key,
_In_ IPortableDeviceValues* pAttributes);
// Object Management
// Depending on the access scope, the driver can limit access only to objects within the current
// scoped hierarchy tree
HRESULT CreatePropertiesOnlyObject(
ACCESS_SCOPE Scope,
_In_ IPortableDeviceValues* pObjectProperties,
_In_ IPortableDeviceValues* pEventParams,
_Outptr_result_nullonfailure_ LPWSTR* ppszNewObjectID);
HRESULT DeleteObject(
ACCESS_SCOPE Scope,
const DWORD dwDeleteOptions,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceValues* pEventParams);
// Resources
HRESULT GetSupportedResources(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ IPortableDeviceKeyCollection* pResources);
HRESULT GetResourceAttributes(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ REFPROPERTYKEY Resource,
_In_ IPortableDeviceValues* pAttributes);
HRESULT OpenResource(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_In_ REFPROPERTYKEY Resource,
const DWORD dwMode,
_In_ WpdObjectResourceContext* pResourceContext);
HRESULT ReadResourceData(
_In_ WpdObjectResourceContext* pResourceContext,
_Out_writes_to_(dwNumBytesToRead, *pdwNumBytesRead) BYTE* pBuffer,
const DWORD dwNumBytesToRead,
_Out_ DWORD* pdwNumBytesRead);
private:
HRESULT GetContent(
ACCESS_SCOPE Scope,
_In_ LPCWSTR wszObjectID,
_Outptr_result_nullonfailure_ FakeContent** ppContent);
HRESULT RemoveObjectsMarkedForDeletion();
private:
// Simulates content on the device
FakeDeviceContent m_DeviceContent;
// Simulates contacts service functionality
FakeContactsService m_ContactsService;
DWORD m_dwLastObjectID;
};
|