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