[SHELL32_APITEST] -Add some tests for SHParseDisplayName for CORE-12882.
[reactos.git] / rostests / apitests / com / com_apitest.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPLv2+ - See COPYING in the top level directory
4 * PURPOSE: COM interface test
5 * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org>
6 */
7
8 #include "com_apitest.h"
9
10 #define NDEBUG
11 #include <debug.h>
12
13 #define myskip(c, ...) ((c) ? 0 : (skip(__VA_ARGS__), 1))
14 #define mytrace(...) do { \
15 int debug = winetest_debug; \
16 winetest_debug = 1; \
17 trace(__VA_ARGS__); \
18 winetest_debug = debug; \
19 } while (0)
20
21 typedef struct _KNOWN_INTERFACE
22 {
23 const IID *iid;
24 PCSTR name;
25 PCWSTR wname;
26 BOOLEAN noreg;
27 } KNOWN_INTERFACE;
28 typedef const KNOWN_INTERFACE *PCKNOWN_INTERFACE;
29
30 #undef ID_NAME
31 #define ID_NAME(c) &c, #c, L ## #c
32 static KNOWN_INTERFACE KnownInterfaces[] =
33 {
34 { ID_NAME(IID_IACList), TRUE },
35 { ID_NAME(IID_IACList2), TRUE },
36 { ID_NAME(IID_IADesktopP2), TRUE },
37 { ID_NAME(IID_IAccIdentity) },
38 { ID_NAME(IID_IAccPropServer) },
39 { ID_NAME(IID_IAccPropServices) },
40 { ID_NAME(IID_IAccessible) },
41 { ID_NAME(IID_IAccessibleHandler) },
42 { ID_NAME(IID_IAccessControl), TRUE },
43 { ID_NAME(IID_IAccessor) },
44 { ID_NAME(IID_IActiveDesktop), TRUE },
45 { ID_NAME(IID_IActiveDesktopP), TRUE },
46 { ID_NAME(IID_IActionProgress) },
47 { ID_NAME(IID_IActionProgressDialog) },
48 { ID_NAME(IID_IAddressBarParser), TRUE },
49 { ID_NAME(IID_IAddressBand), TRUE },
50 { ID_NAME(IID_IAddressEditBox), TRUE },
51 { ID_NAME(IID_IAugmentedShellFolder), TRUE },
52 { ID_NAME(IID_IAugmentedShellFolder2), TRUE },
53 { ID_NAME(IID_IAutoComplete), TRUE },
54 { ID_NAME(IID_IAutoComplete2), TRUE },
55 { ID_NAME(IID_IAutoCompleteDropDown) },
56 { ID_NAME(IID_IBandHost) },
57 { ID_NAME(IID_IBandNavigate), },
58 { ID_NAME(IID_IBandProxy), TRUE },
59 { ID_NAME(IID_IBandSite) },
60 { ID_NAME(IID_IBandSiteHelper), TRUE },
61 { ID_NAME(IID_IBanneredBar), TRUE },
62 { ID_NAME(IID_IBindCtx) },
63 { ID_NAME(IID_IBindEventHandler) },
64 { ID_NAME(IID_IBindHost) },
65 { ID_NAME(IID_IBinding) },
66 { ID_NAME(IID_IBindProtocol), TRUE },
67 { ID_NAME(IID_IBindResource) },
68 { ID_NAME(IID_IBindStatusCallback) },
69 { ID_NAME(IID_IBrowserFrameOptions), TRUE },
70 { ID_NAME(IID_IBrowserService) },
71 { ID_NAME(IID_IBrowserService2), TRUE },
72 { ID_NAME(IID_IBrowserService3), TRUE },
73 { ID_NAME(IID_IBrowserService4), TRUE },
74 { ID_NAME(IID_ICDBurn) },
75 { ID_NAME(IID_ICDBurnExt) },
76 { ID_NAME(IID_ICDBurnPriv) },
77 { ID_NAME(IID_ICallFactory), TRUE },
78 { ID_NAME(IID_ICatInformation) },
79 { ID_NAME(IID_ICatRegister) },
80 { ID_NAME(IID_IClassFactory) },
81 { ID_NAME(IID_IClassFactory2) },
82 { ID_NAME(IID_IClassFactory3), TRUE },
83 { ID_NAME(IID_IClientSecurity), TRUE },
84 { ID_NAME(IID_ICommDlgBrowser) },
85 { ID_NAME(IID_ICommDlgBrowser2) },
86 { ID_NAME(IID_ICommDlgBrowser3) },
87 { ID_NAME(IID_ICompositeFolder) },
88 { ID_NAME(IID_IComputerInfoChangeNotify), },
89 { ID_NAME(IID_IComThreadingInfo), TRUE },
90 { ID_NAME(IID_IConnectionPointContainer) },
91 { ID_NAME(IID_IContext), TRUE },
92 { ID_NAME(IID_IContextMenu), TRUE },
93 { ID_NAME(IID_IContextMenu2), TRUE },
94 { ID_NAME(IID_IContextMenu3), TRUE },
95 { ID_NAME(IID_IContextMenuCB), TRUE },
96 { ID_NAME(IID_IContextMenuSite) },
97 { ID_NAME(IID_IContinue) },
98 { ID_NAME(IID_ICopyHookA), TRUE },
99 { ID_NAME(IID_ICopyHookW), TRUE },
100 { ID_NAME(IID_ICurrentWorkingDirectory), TRUE },
101 { ID_NAME(IID_ICustomizeInfoTip) },
102 { ID_NAME(IID_IDVGetEnum), TRUE },
103 { ID_NAME(IID_IDataObject) },
104 //{ ID_NAME(IID_IDefViewID) }, == DefViewFrame3
105 { ID_NAME(IID_IDefViewFrame), TRUE },
106 { ID_NAME(IID_IDefViewFrame3) },
107 { ID_NAME(IID_IDefViewFrameGroup) },
108 { ID_NAME(IID_IDefViewSafety), },
109 { ID_NAME(IID_IDefViewScript), TRUE },
110 { ID_NAME(IID_IDelayedRelease), TRUE },
111 { ID_NAME(IID_IDeskBand) },
112 { ID_NAME(IID_IDeskBandEx) },
113 { ID_NAME(IID_IDeskBar), TRUE },
114 { ID_NAME(IID_IDeskBarClient), TRUE },
115 { ID_NAME(IID_IDeskMovr), TRUE },
116 { ID_NAME(IID_IDiscMasterProgressEvents) },
117 { ID_NAME(IID_IDispatch) },
118 { ID_NAME(IID_IDispatchEx) },
119 { ID_NAME(IID_IDockingWindow) },
120 { ID_NAME(IID_IDockingWindowFrame), TRUE },
121 { ID_NAME(IID_IDockingWindowSite), TRUE },
122 { ID_NAME(IID_IDocViewSite), TRUE },
123 { ID_NAME(IID_IDragSourceHelper), TRUE },
124 { ID_NAME(IID_IDriveFolderExt) },
125 { ID_NAME(IID_IDropSource) },
126 { ID_NAME(IID_IDropTarget) },
127 { ID_NAME(IID_IDropTargetHelper), TRUE },
128 { ID_NAME(IID_IEFrameAuto) },
129 { ID_NAME(IID_IEnumExtraSearch) },
130 { ID_NAME(IID_IEnumGUID) },
131 { ID_NAME(IID_IEnumIDList) },
132 { ID_NAME(IID_IEnumMoniker) },
133 //{ ID_NAME(IID_IEnumNetCfgBindingInterface) },
134 //{ ID_NAME(IID_IEnumNetCfgBindingPath) },
135 { ID_NAME(IID_IEnumNetCfgComponent), TRUE },
136 { ID_NAME(IID_IEnumNetConnection) },
137 { ID_NAME(IID_IEnumShellItems) },
138 { ID_NAME(IID_IEnumSTATSTG) },
139 { ID_NAME(IID_IEnumString) },
140 { ID_NAME(IID_IEnumUnknown) },
141 { ID_NAME(IID_IEnumVARIANT) },
142 { ID_NAME(IID_IErrorLog) },
143 { ID_NAME(IID_IExplorerBrowser) },
144 { ID_NAME(IID_IExplorerToolbar), TRUE },
145 { ID_NAME(IID_IExtractIconA), TRUE },
146 { ID_NAME(IID_IExtractIconW), TRUE },
147 { ID_NAME(IID_IExtractImage) },
148 { ID_NAME(IID_IExtractImage2) },
149 { ID_NAME(IID_IFileDialog) },
150 { ID_NAME(IID_IFileDialog2), TRUE },
151 { ID_NAME(IID_IFileOpenDialog) },
152 { ID_NAME(IID_IFileSaveDialog) },
153 { ID_NAME(IID_IFileSearchBand) },
154 { ID_NAME(IID_IFileViewerA), TRUE },
155 { ID_NAME(IID_IFileViewerSite), TRUE },
156 { ID_NAME(IID_IFileViewerW), TRUE },
157 { ID_NAME(IID_IFilter) },
158 { ID_NAME(IID_IFolderBandPriv) },
159 { ID_NAME(IID_IFolderFilter) },
160 { ID_NAME(IID_IFolderFilterSite) },
161 { ID_NAME(IID_IFolderView) },
162 { ID_NAME(IID_IFolderView2) },
163 { ID_NAME(IID_IFolderViewHost), TRUE },
164 { ID_NAME(IID_IFolderViewOC) },
165 { ID_NAME(IID_IFolderViewSettings) },
166 { ID_NAME(IID_IForegroundTransfer), TRUE },
167 { ID_NAME(IID_IGetNameSpaceExtensionPointer),TRUE},
168 { ID_NAME(IID_IGlobalFolderSettings), TRUE },
169 { ID_NAME(IID_IHWEventHandler) },
170 { ID_NAME(IID_IHWEventHandler2) },
171 { ID_NAME(IID_IHlinkFrame) },
172 { ID_NAME(IID_IImageList), TRUE },
173 { ID_NAME(IID_IImageList2), TRUE },
174 { ID_NAME(IID_IInitializeObject), TRUE },
175 { ID_NAME(IID_IInitializeWithBindCtx) },
176 { ID_NAME(IID_IInitializeWithFile) },
177 { ID_NAME(IID_IInputObject) },
178 { ID_NAME(IID_IInputObjectSite) },
179 { ID_NAME(IID_IInternalUnknown), TRUE },
180 { ID_NAME(IID_IInternetSecurityManager) },
181 { ID_NAME(IID_IInternetZoneManager), TRUE },
182 { ID_NAME(IID_IItemNameLimits) },
183 { ID_NAME(IID_IMarshal) },
184 { ID_NAME(IID_IMarshal2), TRUE },
185 { ID_NAME(IID_IMenuBand), TRUE },
186 { ID_NAME(IID_IMenuPopup), TRUE },
187 { ID_NAME(IID_IModalWindow) },
188 { ID_NAME(IID_IMoniker) },
189 { ID_NAME(IID_IMultiMonitorDockingSite), TRUE },
190 { ID_NAME(IID_IMultiQI), TRUE },
191 { ID_NAME(IID_INameSpaceTreeControl), TRUE },
192 { ID_NAME(IID_INamespaceProxy), TRUE },
193 { ID_NAME(IID_INamespaceWalk) },
194 { ID_NAME(IID_INamespaceWalkCB) },
195 { ID_NAME(IID_INamespaceWalkCB2) },
196 { ID_NAME(IID_INetCfg), TRUE },
197 //{ ID_NAME(IID_INetCfgBindingInterface) },
198 //{ ID_NAME(IID_INetCfgBindingPath) },
199 { ID_NAME(IID_INetCfgComponent), TRUE },
200 { ID_NAME(IID_INetCfgComponentBindings), TRUE },
201 { ID_NAME(IID_INetCfgComponentControl), TRUE },
202 { ID_NAME(IID_INetCfgComponentPropertyUi), TRUE },
203 { ID_NAME(IID_INetCfgLock), TRUE },
204 { ID_NAME(IID_INetCfgPnpReconfigCallback), TRUE },
205 { ID_NAME(IID_INetConnectionConnectUi), TRUE },
206 { ID_NAME(IID_INetConnectionPropertyUi), TRUE },
207 { ID_NAME(IID_INetConnectionPropertyUi2), TRUE },
208 { ID_NAME(IID_INetConnectionManager) },
209 { ID_NAME(IID_INetLanConnectionUiInfo), TRUE },
210 { ID_NAME(IID_INewMenuClient) },
211 { ID_NAME(IID_INewShortcutHookA), TRUE },
212 { ID_NAME(IID_INewShortcutHookW), TRUE },
213 { ID_NAME(IID_INewWindowManager) },
214 { ID_NAME(IID_INSCTree), TRUE },
215 { ID_NAME(IID_INSCTree2), TRUE },
216 { ID_NAME(IID_IObjMgr), TRUE },
217 { ID_NAME(IID_IObjectSafety) },
218 { ID_NAME(IID_IObjectWithBackReferences) },
219 { ID_NAME(IID_IObjectWithSite) },
220 { ID_NAME(IID_IOleClientSite) },
221 { ID_NAME(IID_IOleCommandTarget) },
222 { ID_NAME(IID_IOleContainer) },
223 { ID_NAME(IID_IOleControl) },
224 { ID_NAME(IID_IOleControlSite) },
225 { ID_NAME(IID_IOleInPlaceActiveObject) },
226 { ID_NAME(IID_IOleInPlaceFrame) },
227 { ID_NAME(IID_IOleInPlaceObject) },
228 { ID_NAME(IID_IOleInPlaceObjectWindowless), TRUE },
229 { ID_NAME(IID_IOleInPlaceSite) },
230 { ID_NAME(IID_IOleInPlaceSiteEx) },
231 { ID_NAME(IID_IOleInPlaceSiteWindowless), TRUE },
232 { ID_NAME(IID_IOleInPlaceUIWindow) },
233 { ID_NAME(IID_IOleObject) },
234 { ID_NAME(IID_IOleWindow) },
235 { ID_NAME(IID_IParentAndItem) },
236 { ID_NAME(IID_IPersist) },
237 { ID_NAME(IID_IPersistFile) },
238 { ID_NAME(IID_IPersistFolder) },
239 { ID_NAME(IID_IPersistFolder2) },
240 { ID_NAME(IID_IPersistFolder3) },
241 { ID_NAME(IID_IPersistFreeThreadedObject), TRUE },
242 { ID_NAME(IID_IPersistHistory) },
243 { ID_NAME(IID_IPersistIDList) },
244 { ID_NAME(IID_IPersistMemory) },
245 { ID_NAME(IID_IPersistPropertyBag) },
246 { ID_NAME(IID_IPersistPropertyBag2) },
247 { ID_NAME(IID_IPersistStorage) },
248 { ID_NAME(IID_IPersistStream) },
249 { ID_NAME(IID_IPersistStreamInit) },
250 { ID_NAME(IID_IPreviewHandler) },
251 { ID_NAME(IID_IPreviewHandlerFrame) },
252 { ID_NAME(IID_IPreviewHandlerVisuals) },
253 { ID_NAME(IID_IProgressDialog), TRUE },
254 { ID_NAME(IID_IPropertyBag) },
255 { ID_NAME(IID_IPropertyBag2) },
256 { ID_NAME(IID_IPropertySetStorage) },
257 { ID_NAME(IID_IPropertyStore) },
258 { ID_NAME(IID_IPropSheetPage), TRUE },
259 { ID_NAME(IID_IProvideClassInfo) },
260 { ID_NAME(IID_IProvideClassInfo2) },
261 { ID_NAME(IID_IQueryAssociations), TRUE },
262 { ID_NAME(IID_IQueryCancelAutoPlay) },
263 { ID_NAME(IID_IQueryInfo), TRUE },
264 { ID_NAME(IID_IQuickActivate) },
265 { ID_NAME(IID_IRegTreeOptions), TRUE },
266 { ID_NAME(IID_IRemoteComputer) },
267 { ID_NAME(IID_IResolveShellLink) },
268 { ID_NAME(IID_IRpcOptions), TRUE },
269 { ID_NAME(IID_IRunnableObject) },
270 { ID_NAME(IID_ISLTracker), TRUE },
271 { ID_NAME(IID_IScriptErrorList) },
272 { ID_NAME(IID_ISearch) },
273 { ID_NAME(IID_ISearchAssistantOC) },
274 { ID_NAME(IID_ISearchAssistantOC2) },
275 { ID_NAME(IID_ISearchAssistantOC3) },
276 { ID_NAME(IID_ISearchBar) },
277 { ID_NAME(IID_ISearches) },
278 { ID_NAME(IID_ISecMgrCacheSeedTarget) },
279 { ID_NAME(IID_IServerSecurity), TRUE },
280 { ID_NAME(IID_IServiceProvider) },
281 { ID_NAME(IID_IShellApp), TRUE },
282 { ID_NAME(IID_IShellBrowser) },
283 { ID_NAME(IID_IShellBrowserService), TRUE },
284 { ID_NAME(IID_IShellChangeNotify), TRUE },
285 { ID_NAME(IID_IShellCopyHookA), TRUE },
286 { ID_NAME(IID_IShellCopyHookW), TRUE },
287 { ID_NAME(IID_IShellDesktopTray), TRUE },
288 { ID_NAME(IID_IShellDetails), TRUE },
289 { ID_NAME(IID_IShellDispatch) },
290 { ID_NAME(IID_IShellDispatch2) },
291 { ID_NAME(IID_IShellDispatch3) },
292 { ID_NAME(IID_IShellDispatch4) },
293 { ID_NAME(IID_IShellDispatch5), TRUE },
294 { ID_NAME(IID_IShellDispatch6), TRUE },
295 { ID_NAME(IID_IShellExecuteHookA), TRUE },
296 { ID_NAME(IID_IShellExecuteHookW), TRUE },
297 { ID_NAME(IID_IShellExtInit), TRUE },
298 { ID_NAME(IID_IShellFavoritesNameSpace) },
299 { ID_NAME(IID_IShellFolder) },
300 { ID_NAME(IID_IShellFolder2) },
301 { ID_NAME(IID_IShellFolderBand), TRUE },
302 { ID_NAME(IID_IShellFolderSearchable), TRUE },
303 { ID_NAME(IID_IShellFolderSearchableCallback), TRUE },
304 { ID_NAME(IID_IShellFolderView), TRUE },
305 { ID_NAME(IID_IShellFolderViewCB), TRUE },
306 { ID_NAME(IID_IShellFolderViewDual) },
307 { ID_NAME(IID_IShellFolderViewDual2) },
308 { ID_NAME(IID_IShellFolderViewDual3), TRUE },
309 { ID_NAME(IID_IShellFolderViewType), TRUE },
310 { ID_NAME(IID_IShellIcon) },
311 { ID_NAME(IID_IShellIconOverlay), TRUE },
312 { ID_NAME(IID_IShellIconOverlayIdentifier), TRUE },
313 { ID_NAME(IID_IShellImageData), TRUE },
314 { ID_NAME(IID_IShellImageDataAbort), TRUE },
315 { ID_NAME(IID_IShellImageDataFactory), TRUE },
316 { ID_NAME(IID_IShellItem) },
317 { ID_NAME(IID_IShellItem2) },
318 { ID_NAME(IID_IShellItemArray) },
319 { ID_NAME(IID_IShellItemFilter) },
320 { ID_NAME(IID_IShellLinkA) },
321 { ID_NAME(IID_IShellLinkDataList), TRUE },
322 { ID_NAME(IID_IShellLinkDual) },
323 { ID_NAME(IID_IShellLinkDual2) },
324 { ID_NAME(IID_IShellLinkW) },
325 { ID_NAME(IID_IShellMenu), TRUE },
326 { ID_NAME(IID_IShellMenu2), TRUE },
327 { ID_NAME(IID_IShellMenuAcc), TRUE },
328 { ID_NAME(IID_IShellMenuCallback), TRUE },
329 { ID_NAME(IID_IShellNameSpace) },
330 { ID_NAME(IID_IShellPropSheetExt), TRUE },
331 { ID_NAME(IID_IShellService), TRUE },
332 { ID_NAME(IID_IShellTaskScheduler), TRUE },
333 { ID_NAME(IID_IShellUIHelper) },
334 { ID_NAME(IID_IShellUIHelper2), TRUE },
335 { ID_NAME(IID_IShellView) },
336 { ID_NAME(IID_IShellView2) },
337 { ID_NAME(IID_IShellView3) },
338 { ID_NAME(IID_IShellWindows) },
339 { ID_NAME(IID_ISpecifyPropertyPages) },
340 { ID_NAME(IID_IStorage) },
341 { ID_NAME(IID_IStream) },
342 { ID_NAME(IID_ISurrogate) },
343 { ID_NAME(IID_ISynchronize) },
344 { ID_NAME(IID_ISynchronizeContainer), TRUE },
345 { ID_NAME(IID_ISynchronizeEvent), TRUE },
346 { ID_NAME(IID_ISynchronizeHandle), TRUE },
347 { ID_NAME(IID_ITargetEmbedding) },
348 { ID_NAME(IID_ITargetFrame) },
349 { ID_NAME(IID_ITargetFrame2) },
350 { ID_NAME(IID_ITargetFramePriv) },
351 { ID_NAME(IID_ITargetFramePriv2) },
352 { ID_NAME(IID_ITargetNotify) },
353 { ID_NAME(IID_ITaskbarList) },
354 { ID_NAME(IID_ITaskbarList2) },
355 { ID_NAME(IID_ITrackShellMenu), TRUE },
356 /* This interface is completely different between PSDK and registry/shell32 */
357 { ID_NAME(IID_ITransferAdviseSink), TRUE },
358 #define IID_ITransferAdviseSink IID_ITransferAdviseSinkPriv
359 { ID_NAME(IID_ITransferAdviseSink) },
360 #undef IID_ITransferAdviseSink
361 { ID_NAME(IID_ITransferDestination), TRUE },
362 { ID_NAME(IID_ITransferSource), TRUE },
363 { ID_NAME(IID_ITranslateShellChangeNotify), TRUE },
364 { ID_NAME(IID_ITrayPriv), TRUE },
365 { ID_NAME(IID_ITrayPriv2), TRUE },
366 { ID_NAME(IID_IUnknown) },
367 { ID_NAME(IID_IURLSearchHook), TRUE },
368 { ID_NAME(IID_IURLSearchHook2), TRUE },
369 { ID_NAME(IID_IUrlHistoryNotify) },
370 { ID_NAME(IID_IUrlHistoryStg) },
371 { ID_NAME(IID_IUrlHistoryStg2) },
372 { ID_NAME(IID_IViewObject) },
373 { ID_NAME(IID_IViewObject2) },
374 { ID_NAME(IID_IViewObjectEx), TRUE },
375 { ID_NAME(IID_IVisualProperties) },
376 { ID_NAME(IID_IWebBrowser) },
377 { ID_NAME(IID_IWebBrowser2) },
378 { ID_NAME(IID_IWebBrowserApp) },
379 { ID_NAME(IID_IWebBrowserPriv) },
380 { ID_NAME(IID_IWebBrowserPriv2) },
381 { ID_NAME(IID_IWinEventHandler), TRUE },
382
383 { ID_NAME(IID_DFConstraint), TRUE },
384 { ID_NAME(DIID__SearchAssistantEvents) },
385 { ID_NAME(DIID_DShellFolderViewEvents) },
386 { ID_NAME(DIID_DShellNameSpaceEvents) },
387 { ID_NAME(DIID_DShellWindowsEvents) },
388 { ID_NAME(DIID_DWebBrowserEvents) },
389 { ID_NAME(DIID_DWebBrowserEvents2) },
390 { ID_NAME(DIID_XMLDOMDocumentEvents ) },
391
392 { ID_NAME(IID_CDefView), TRUE },
393 { ID_NAME(IID_Folder) },
394 { ID_NAME(IID_Folder2) },
395 { ID_NAME(IID_Folder3) },
396 { ID_NAME(IID_FolderItem) },
397 { ID_NAME(IID_FolderItem2) },
398 { ID_NAME(IID_FolderItems) },
399 { ID_NAME(IID_FolderItems2) },
400 { ID_NAME(IID_FolderItems3) },
401 { ID_NAME(IID_FolderItemVerb) },
402 { ID_NAME(IID_FolderItemVerbs) },
403
404 { ID_NAME(CLSID_ShellDesktop), TRUE },
405
406 { ID_NAME(IID_IAggregateFilterCondition), TRUE },
407 { ID_NAME(IID_IAliasRegistrationCallback), TRUE },
408 { ID_NAME(IID_IAssociationArrayInitialize), TRUE },
409 { ID_NAME(IID_IAssociationList), TRUE },
410 { ID_NAME(IID_IBackReferencedObject), TRUE },
411 { ID_NAME(IID_IBasePropPage), TRUE },
412 { ID_NAME(IID_ICommonLayoutDefinition), TRUE },
413 { ID_NAME(IID_IControlPanelEnumerator), TRUE },
414 { ID_NAME(IID_IDelegateHostItemContainer), TRUE },
415 { ID_NAME(IID_IDrawPropertyControl), TRUE },
416 { ID_NAME(IID_IEnumAssociationElements), TRUE },
417 { ID_NAME(IID_IEnumerateAssociationElements),TRUE },
418 { ID_NAME(IID_IExecuteCommand), TRUE },
419 { ID_NAME(IID_IFilterCondition), TRUE },
420 { ID_NAME(IID_IFolderNotify), TRUE },
421 { ID_NAME(IID_IFolderProperties), TRUE },
422 { ID_NAME(IID_IFolderType), TRUE },
423 { ID_NAME(IID_IFolderWithSearchRoot), TRUE },
424 { ID_NAME(IID_IFrameLayoutDefinition), TRUE },
425 { ID_NAME(IID_IItemFilter), TRUE },
426 { ID_NAME(IID_IItemFilterOwner), TRUE },
427 { ID_NAME(IID_ILocalizableItemParent), TRUE },
428 { ID_NAME(IID_INewItemAdvisor), TRUE },
429 { ID_NAME(IID_IObjectWithAssociationElement),TRUE },
430 { ID_NAME(IID_IObjectWithAssociationList), TRUE },
431 { ID_NAME(IID_IObjectWithQuerySource), TRUE },
432 { ID_NAME(IID_IObjectWithSelection), TRUE },
433 { ID_NAME(IID_IPersistString2), TRUE },
434 { ID_NAME(IID_IPrinterFolder), TRUE },
435 { ID_NAME(IID_IPropertyControl), TRUE },
436 { ID_NAME(IID_IPropertyControlBase), TRUE },
437 { ID_NAME(IID_IPropertyControlSite), TRUE },
438 { ID_NAME(IID_IRegItemCustomAttributes), TRUE },
439 { ID_NAME(IID_IRegItemCustomEnumerator), TRUE },
440 { ID_NAME(IID_IRegItemFolder), TRUE },
441 { ID_NAME(IID_IRootAndRelativeParsingFolder),TRUE },
442 { ID_NAME(IID_IScope), TRUE },
443 { ID_NAME(IID_IScopeItem), TRUE },
444 { ID_NAME(IID_IShellBrowserServce), TRUE },
445 { ID_NAME(IID_IShellFolder3), TRUE },
446 { ID_NAME(IID_ITaskCondition), TRUE },
447 { ID_NAME(IID_ITaskConditionCombiner), TRUE },
448 { ID_NAME(IID_ITaskConditionInit), TRUE },
449 { ID_NAME(IID_ITransferProvider), TRUE },
450 { ID_NAME(IID_IUserEventTimer), TRUE },
451 { ID_NAME(IID_IUserEventTimerCallback), TRUE },
452 { ID_NAME(IID_IAssociationArrayOld), TRUE },
453 { ID_NAME(IID_IAssociationArray), TRUE },
454 { ID_NAME(IID_IDriveFolderExtOld), TRUE },
455 { ID_NAME(IID_IDriveFolderExt), TRUE },
456 { ID_NAME(IID_IPinnedListOld), TRUE },
457 { ID_NAME(IID_IPinnedList), TRUE }
458 };
459 static const INT KnownInterfaceCount = RTL_NUMBER_OF(KnownInterfaces);
460
461 static
462 PCKNOWN_INTERFACE
463 FindInterface(
464 _In_ const IID *iid)
465 {
466 INT i;
467
468 for (i = 0; i < KnownInterfaceCount; i++)
469 if (IsEqualIID(KnownInterfaces[i].iid, iid))
470 return &KnownInterfaces[i];
471 ASSERT(i != KnownInterfaceCount);
472 return NULL;
473 }
474
475 static
476 BOOLEAN
477 IsInterfaceExpected(
478 _In_ PCCLASS_AND_INTERFACES class,
479 _In_ const IID *iid)
480 {
481 INT i;
482
483 for (i = 0; class->ifaces[i].iid; i++)
484 if (IsEqualIID(class->ifaces[i].iid, iid))
485 return TRUE;
486 return FALSE;
487 }
488
489 #define INTF_NOT_EXPOSED LONG_MAX
490 static
491 LONG
492 GetInterfaceOffset(
493 _In_ PUNKNOWN pUnk,
494 _In_ const IID *iid)
495 {
496 HRESULT hr;
497 PVOID pObj;
498 PUNKNOWN pUnk2;
499 LONG offset;
500
501 hr = IUnknown_QueryInterface(pUnk, iid, &pObj);
502 ok(hr == S_OK || hr == E_NOINTERFACE, "IUnknown::QueryInterface returned 0x%lx\n", hr);
503 if (FAILED(hr))
504 return INTF_NOT_EXPOSED;
505
506 pUnk2 = pObj;
507 offset = (LONG_PTR)pObj - (LONG_PTR)pUnk;
508 IUnknown_Release(pUnk2);
509 return offset;
510 }
511
512 static
513 VOID
514 TestModuleInterfaces(
515 _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces,
516 _In_ INT ExpectedInterfaceCount)
517 {
518 HRESULT hr;
519 PVOID pObj;
520 PUNKNOWN pUnk;
521 INT iClass, iIntf;
522 PCCLASS_AND_INTERFACES class;
523
524 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
525 {
526 class = &ExpectedInterfaces[iClass];
527 hr = CoCreateInstance(class->clsid,
528 NULL,
529 CLSCTX_INPROC_SERVER,
530 &IID_IUnknown,
531 &pObj);
532 ok(hr == S_OK, "CoCreateInstance failed. hr=0x%lx\n", hr);
533 if (FAILED(hr))
534 {
535 skip("Failed to instantiate %s.\n", class->name);
536 continue;
537 }
538
539 pUnk = pObj;
540
541 /* Check that all expected interfaces are present and have the right offset */
542 for (iIntf = 0; class->ifaces[iIntf].iid; iIntf++)
543 {
544 PCKNOWN_INTERFACE iface = FindInterface(class->ifaces[iIntf].iid);
545 LONG offset = GetInterfaceOffset(pUnk, iface->iid);
546 if (offset == INTF_NOT_EXPOSED)
547 ok(0, "%s is missing %s (offset %ld)\n", class->name, iface->name, class->ifaces[iIntf].offset);
548 else if (class->ifaces[iIntf].offset != FARAWY)
549 {
550 #ifdef FAIL_WRONG_OFFSET
551 ok(offset == class->ifaces[iIntf].offset, "%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
552 #else
553 if (offset != class->ifaces[iIntf].offset)
554 mytrace("%s, %s offset is %ld, expected %ld\n", class->name, iface->name, offset, class->ifaces[iIntf].offset);
555 #endif
556 }
557 }
558
559 /* Check that none other than the expected interfaces are present */
560 for (iIntf = 0; iIntf < KnownInterfaceCount; iIntf++)
561 {
562 PCKNOWN_INTERFACE iface = &KnownInterfaces[iIntf];
563 LONG offset;
564 if (IsInterfaceExpected(class, iface->iid))
565 continue;
566 offset = GetInterfaceOffset(pUnk, iface->iid);
567 #ifdef GENERATE_TABLE_ENTRIES
568 ok(offset == INTF_NOT_EXPOSED, "%s: { %s0x%lx, &%s },\n", class->name, offset < 0 ? "-" : "", offset < 0 ? -offset : offset, iface->name);
569 #else
570 ok(offset == INTF_NOT_EXPOSED, "%s exposes %s (offset %ld), but shouldn't\n", class->name, iface->name, offset);
571 #endif
572 }
573
574 // TODO: do some aggregation
575
576 IUnknown_Release(pUnk);
577 }
578 }
579
580 static
581 VOID
582 TestModuleRegistry(
583 _In_ PCWSTR ModuleName,
584 _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces,
585 _In_ INT ExpectedInterfaceCount)
586 {
587 INT iClass;
588 PCCLASS_AND_INTERFACES class;
589 HKEY hKeyClasses;
590 LONG result;
591
592 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\CLSID", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyClasses);
593 ok(result == NO_ERROR, "Failed to open classes key, error %lu\n", result);
594 if (!myskip(result == NO_ERROR, "No classes key\n"))
595 {
596 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
597 {
598 HKEY hKey;
599 HKEY hKeyServer;
600 NTSTATUS status;
601 UNICODE_STRING clsid;
602 DWORD type;
603 WCHAR data[100];
604 DWORD dataSize;
605 PCWSTR expectedThreadingModel;
606
607 class = &ExpectedInterfaces[iClass];
608 status = RtlStringFromGUID(class->clsid, &clsid);
609 ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", class->name, status);
610 if (myskip(NT_SUCCESS(status), "No guid string\n"))
611 continue;
612
613 result = RegOpenKeyExW(hKeyClasses, clsid.Buffer, 0, KEY_ENUMERATE_SUB_KEYS, &hKey);
614 ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
615 RtlFreeUnicodeString(&clsid);
616 if (myskip(result == NO_ERROR, "No key\n"))
617 continue;
618
619 result = RegOpenKeyExW(hKey, L"InProcServer32", 0, KEY_QUERY_VALUE, &hKeyServer);
620 ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", class->name, result);
621 RegCloseKey(hKey);
622 if (myskip(result == NO_ERROR, "No key\n"))
623 continue;
624
625 dataSize = sizeof(data);
626 result = RegQueryValueExW(hKeyServer, NULL, NULL, &type, (PBYTE)data, &dataSize);
627 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
628 if (!myskip(result == NO_ERROR, "No module name\n"))
629 {
630 ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
631 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
632 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
633 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
634 // TODO: Use SearchPath (or assume everything's in system32) and do a proper full path compare
635 PathStripPathW(data);
636 PathRemoveExtensionW(data);
637 ok(!wcsicmp(data, ModuleName), "Server is %ls, expected %ls for %s\n", data, ModuleName, class->name);
638 }
639
640 dataSize = sizeof(data);
641 result = RegQueryValueExW(hKeyServer, L"ThreadingModel", NULL, &type, (PBYTE)data, &dataSize);
642 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", class->name, result);
643 if (!myskip(result == NO_ERROR, "No ThreadingModel\n"))
644 {
645 ok(type == REG_SZ || type == REG_EXPAND_SZ, "type %lu for %s\n", type, class->name);
646 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, class->name);
647 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, class->name);
648 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", class->name);
649 expectedThreadingModel = class->ThreadingModel;
650 if (!expectedThreadingModel)
651 expectedThreadingModel = L"Apartment";
652 ok(!wcsicmp(data, expectedThreadingModel), "Server is %ls, expected %ls for %s\n", data, expectedThreadingModel, class->name);
653 }
654
655 RegCloseKey(hKeyServer);
656 }
657 RegCloseKey(hKeyClasses);
658 }
659 }
660
661 static
662 VOID
663 TestManualInstantiation(
664 _In_ PCWSTR ModuleName,
665 _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces,
666 _In_ INT ExpectedInterfaceCount)
667 {
668 INT iClass;
669 PCCLASS_AND_INTERFACES class;
670 HRESULT (__stdcall *DllGetClassObject)(REFCLSID, REFIID, PVOID *);
671
672 DllGetClassObject = (PVOID)GetProcAddress(GetModuleHandleW(ModuleName), "DllGetClassObject");
673 ok(DllGetClassObject != NULL, "DllGetClassObject not found in %ls, error %lu\n", ModuleName, GetLastError());
674 if (myskip(DllGetClassObject != NULL, "No DllGetClassObject\n"))
675 return;
676
677 for (iClass = 0; iClass < ExpectedInterfaceCount; iClass++)
678 {
679 PVOID pv;
680 HRESULT hr;
681 class = &ExpectedInterfaces[iClass];
682 hr = DllGetClassObject(class->clsid, &IID_IClassFactory, &pv);
683 ok(hr == S_OK, "DllGetClassObject failed for %s, hr = 0x%lx\n", class->name, hr);
684 if (!myskip(SUCCEEDED(hr), "No class factory\n"))
685 {
686 IClassFactory *pCF = pv;
687 hr = IClassFactory_CreateInstance(pCF, NULL, &IID_IUnknown, &pv);
688 ok(hr == S_OK, "IClassFactory::CreateInstance failed for %s, hr = 0x%lx\n", class->name, hr);
689 if (!myskip(SUCCEEDED(hr), "No instance\n"))
690 {
691 IUnknown *pUnk = pv;
692 IUnknown_Release(pUnk);
693 }
694 IClassFactory_Release(pCF);
695 }
696 }
697 }
698
699 VOID
700 TestClasses(
701 _In_ PCWSTR ModuleName,
702 _In_ PCCLASS_AND_INTERFACES ExpectedInterfaces,
703 _In_ INT ExpectedInterfaceCount)
704 {
705 HRESULT hr;
706
707 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
708 ok(hr == S_OK, "CoInitializeEx failed. hr=0x%lx\n", hr);
709 if (myskip(SUCCEEDED(hr), "Failed to initialize COM. Cannot perform tests\n"))
710 return;
711
712 TestModuleInterfaces(ExpectedInterfaces, ExpectedInterfaceCount);
713 TestModuleRegistry(ModuleName, ExpectedInterfaces, ExpectedInterfaceCount);
714 TestManualInstantiation(ModuleName, ExpectedInterfaces, ExpectedInterfaceCount);
715
716 CoUninitialize();
717 }
718
719 static
720 VOID
721 TestInterfaceRegistry(
722 _In_ PCKNOWN_INTERFACE Interfaces,
723 _In_ INT InterfaceCount)
724 {
725 INT i;
726 HKEY hKeyInterface;
727 LONG result;
728
729 result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Classes\\Interface", 0, KEY_ENUMERATE_SUB_KEYS, &hKeyInterface);
730 ok(result == NO_ERROR, "Failed to open interface key, error %lu\n", result);
731 if (!myskip(result == NO_ERROR, "No interface key\n"))
732 {
733 for (i = 0; i < InterfaceCount; i++)
734 {
735 HKEY hKey;
736 NTSTATUS status;
737 UNICODE_STRING iid;
738 DWORD type;
739 WCHAR data[100];
740 DWORD dataSize;
741 PCKNOWN_INTERFACE iface;
742 PCWSTR expectedName;
743
744 iface = &Interfaces[i];
745 status = RtlStringFromGUID(iface->iid, &iid);
746 ok(status == STATUS_SUCCESS, "Failed to convert guid to string for %s, status %lx\n", iface->name, status);
747 if (myskip(NT_SUCCESS(status), "No guid string\n"))
748 continue;
749
750 result = RegOpenKeyExW(hKeyInterface, iid.Buffer, 0, KEY_QUERY_VALUE, &hKey);
751 if (iface->noreg)
752 {
753 ok(result == ERROR_FILE_NOT_FOUND, "RegOpenKeyEx returned %lu for %s\n", result, iface->name);
754 }
755 else
756 {
757 ok(result == NO_ERROR, "Failed to open key for %s, error %lu\n", iface->name, result);
758 (void)myskip(result == NO_ERROR, "No key\n");
759 }
760 RtlFreeUnicodeString(&iid);
761 if (result != NO_ERROR)
762 continue;
763
764 dataSize = sizeof(data);
765 result = RegQueryValueExW(hKey, NULL, NULL, &type, (PBYTE)data, &dataSize);
766 ok(result == NO_ERROR, "Failed to query value for %s, error %lu\n", iface->name, result);
767 if (!myskip(result == NO_ERROR, "No module name\n"))
768 {
769 ok(type == REG_SZ, "type %lu for %s\n", type, iface->name);
770 ok(dataSize % sizeof(WCHAR) == 0, "size %lu for %s\n", dataSize, iface->name);
771 ok(dataSize <= sizeof(data), "size %lu for %s\n", dataSize, iface->name);
772 ok(data[dataSize / sizeof(WCHAR) - 1] == UNICODE_NULL, "Not null terminated for %s\n", iface->name);
773 expectedName = wcschr(iface->wname, L'_');
774 if (expectedName)
775 expectedName++;
776 else
777 expectedName = iface->wname;
778 ok(!wcsicmp(data, expectedName), "Name is %ls, expected %ls\n", data, expectedName);
779 }
780
781 RegCloseKey(hKey);
782 }
783 RegCloseKey(hKeyInterface);
784 }
785 }
786
787 START_TEST(interfaces)
788 {
789 TestInterfaceRegistry(KnownInterfaces, KnownInterfaceCount);
790 }