2 * Helper functions for debugging
4 * Copyright 1998, 2002 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 WINE_DEFAULT_DEBUG_CHANNEL(pidl
);
26 LPITEMIDLIST
_dbg_ILGetNext(LPCITEMIDLIST pidl
)
35 return (LPITEMIDLIST
) (((LPBYTE
)pidl
)+len
);
42 BOOL
_dbg_ILIsDesktop(LPCITEMIDLIST pidl
)
44 return ( !pidl
|| (pidl
&& pidl
->mkid
.cb
== 0x00) );
48 LPPIDLDATA
_dbg_ILGetDataPointer(LPCITEMIDLIST pidl
)
50 if(pidl
&& pidl
->mkid
.cb
!= 0x00)
51 return (LPPIDLDATA
) &(pidl
->mkid
.abID
);
56 LPSTR
_dbg_ILGetTextPointer(LPCITEMIDLIST pidl
)
58 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
73 return (LPSTR
)&(pdata
->u
.drive
.szDriveName
);
80 return (LPSTR
)&(pdata
->u
.file
.szNames
);
87 return (LPSTR
)&(pdata
->u
.network
.szNames
);
94 LPWSTR
_dbg_ILGetTextPointerW(LPCITEMIDLIST pidl
)
96 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
111 /* return (LPSTR)&(pdata->u.drive.szDriveName);*/
119 /* return (LPSTR)&(pdata->u.file.szNames); */
127 /* return (LPSTR)&(pdata->u.network.szNames); */
131 return (LPWSTR
)&(pdata
->u
.file
.szNames
);
139 LPSTR
_dbg_ILGetSTextPointer(LPCITEMIDLIST pidl
)
141 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
151 return (LPSTR
)(pdata
->u
.file
.szNames
+ strlen (pdata
->u
.file
.szNames
) + 1);
154 return (LPSTR
)(pdata
->u
.network
.szNames
+ strlen (pdata
->u
.network
.szNames
) + 1);
161 LPWSTR
_dbg_ILGetSTextPointerW(LPCITEMIDLIST pidl
)
163 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
173 /*return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1); */
177 /* return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1); */
181 return (LPWSTR
)(pdata
->u
.file
.szNames
+ wcslen ((LPWSTR
)pdata
->u
.file
.szNames
) + 1);
189 IID
* _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl
)
191 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
200 return &(pdata
->u
.guid
.guid
);
207 void _dbg_ILSimpleGetText (LPCITEMIDLIST pidl
, LPSTR szOut
, UINT uOutSize
)
218 if (_dbg_ILIsDesktop(pidl
))
221 if (szOut
) lstrcpynA(szOut
, "Desktop", uOutSize
);
223 else if (( szSrc
= _dbg_ILGetTextPointer(pidl
) ))
226 if (szOut
) lstrcpynA(szOut
, szSrc
, uOutSize
);
228 else if (( szSrcW
= _dbg_ILGetTextPointerW(pidl
) ))
231 /* unicode filesystem */
232 WideCharToMultiByte(CP_ACP
,0,szSrcW
, -1, tmp
, MAX_PATH
, NULL
, NULL
);
233 if (szOut
) lstrcpynA(szOut
, tmp
, uOutSize
);
235 else if (( riid
= _dbg_ILGetGUIDPointer(pidl
) ))
238 sprintf( szOut
, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
239 riid
->Data1
, riid
->Data2
, riid
->Data3
,
240 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
241 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7] );
248 void pdump (LPCITEMIDLIST pidl
)
250 LPCITEMIDLIST pidltemp
= pidl
;
252 if (!TRACE_ON(pidl
)) return;
256 MESSAGE ("-------- pidl=NULL (Desktop)\n");
260 MESSAGE ("-------- pidl=%p\n", pidl
);
261 if (pidltemp
->mkid
.cb
)
265 if (_ILIsUnicode(pidltemp
))
268 LPPIDLDATA pData
= _dbg_ILGetDataPointer(pidltemp
);
269 DWORD type
= pData
? pData
->type
: 0;
270 LPWSTR szLongName
= _dbg_ILGetTextPointerW(pidltemp
);
271 LPWSTR szShortName
= _dbg_ILGetSTextPointerW(pidltemp
);
272 char szName
[MAX_PATH
];
274 _dbg_ILSimpleGetText(pidltemp
, szName
, MAX_PATH
);
275 if ( pData
&& (PT_FOLDER
== type
|| PT_VALUE
== type
) )
276 dwAttrib
= pData
->u
.file
.uFileAttribs
;
278 MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n",
279 pidltemp
, pidltemp
->mkid
.cb
, type
, dwAttrib
,
280 debugstr_a(szName
), debugstr_w(szLongName
), debugstr_w(szShortName
));
285 LPPIDLDATA pData
= _dbg_ILGetDataPointer(pidltemp
);
286 DWORD type
= pData
? pData
->type
: 0;
287 LPSTR szLongName
= _dbg_ILGetTextPointer(pidltemp
);
288 LPSTR szShortName
= _dbg_ILGetSTextPointer(pidltemp
);
289 char szName
[MAX_PATH
];
291 _dbg_ILSimpleGetText(pidltemp
, szName
, MAX_PATH
);
292 if ( pData
&& (PT_FOLDER
== type
|| PT_VALUE
== type
) )
293 dwAttrib
= pData
->u
.file
.uFileAttribs
;
295 MESSAGE ("[%p] size=%04u type=%x attr=0x%08x name=%s (%s,%s)\n",
296 pidltemp
, pidltemp
->mkid
.cb
, type
, dwAttrib
,
297 debugstr_a(szName
), debugstr_a(szLongName
), debugstr_a(szShortName
));
300 pidltemp
= _dbg_ILGetNext(pidltemp
);
302 } while (pidltemp
&& pidltemp
->mkid
.cb
);
306 MESSAGE ("empty pidl (Desktop)\n");
312 static void dump_pidl_hex( LPCITEMIDLIST pidl
)
314 const unsigned char *p
= (const unsigned char *)pidl
;
315 const int max_bytes
= 0x80;
316 #define max_line 0x10
317 char szHex
[max_line
*3+1], szAscii
[max_line
+1];
325 sprintf( &szHex
[ (i
%max_line
)*3 ], "%02X ", p
[i
] );
326 szAscii
[ (i
%max_line
) ] = isprint( p
[i
] ) ? p
[i
] : '.';
328 /* print out at the end of each line and when we're finished */
329 if( i
!=(n
-1) && (i
%max_line
) != (max_line
-1) )
331 szAscii
[ (i
%max_line
)+1 ] = 0;
332 ERR("%-*s %s\n", max_line
*3, szHex
, szAscii
);
336 BOOL
pcheck( LPCITEMIDLIST pidl
)
339 LPCITEMIDLIST pidltemp
= pidl
;
341 while( pidltemp
&& pidltemp
->mkid
.cb
)
343 type
= _dbg_ILGetDataPointer(pidltemp
)->type
;
367 ERR("unknown IDLIST %p [%p] size=%u type=%x\n",
368 pidl
, pidltemp
, pidltemp
->mkid
.cb
,type
);
369 dump_pidl_hex( pidltemp
);
372 pidltemp
= _dbg_ILGetNext(pidltemp
);
377 static const struct {
380 } InterfaceDesc
[] = {
381 {&IID_IUnknown
, "IID_IUnknown"},
382 {&IID_IClassFactory
, "IID_IClassFactory"},
383 {&IID_IShellView
, "IID_IShellView"},
384 {&IID_IOleCommandTarget
, "IID_IOleCommandTarget"},
385 {&IID_IDropTarget
, "IID_IDropTarget"},
386 {&IID_IDropSource
, "IID_IDropSource"},
387 {&IID_IViewObject
, "IID_IViewObject"},
388 {&IID_IContextMenu
, "IID_IContextMenu"},
389 {&IID_IShellExtInit
, "IID_IShellExtInit"},
390 {&IID_IShellFolder
, "IID_IShellFolder"},
391 {&IID_IShellFolder2
, "IID_IShellFolder2"},
392 {&IID_IPersist
, "IID_IPersist"},
393 {&IID_IPersistFolder
, "IID_IPersistFolder"},
394 {&IID_IPersistFolder2
, "IID_IPersistFolder2"},
395 {&IID_IPersistFolder3
, "IID_IPersistFolder3"},
396 {&IID_IExtractIconA
, "IID_IExtractIconA"},
397 {&IID_IExtractIconW
, "IID_IExtractIconW"},
398 {&IID_IDataObject
, "IID_IDataObject"},
399 {&IID_IAutoComplete
, "IID_IAutoComplete"},
400 {&IID_IAutoComplete2
, "IID_IAutoComplete2"},
401 {&IID_IShellLinkA
, "IID_IShellLinkA"},
402 {&IID_IShellLinkW
, "IID_IShellLinkW"},
405 const char * shdebugstr_guid( const struct _GUID
*id
)
408 const char* name
= NULL
;
411 if (!id
) return "(null)";
413 for (i
=0;InterfaceDesc
[i
].riid
&& !name
;i
++) {
414 if (IsEqualIID(InterfaceDesc
[i
].riid
, id
)) name
= InterfaceDesc
[i
].name
;
417 if (HCR_GetClassNameA(id
, clsidbuf
, 100))
421 return wine_dbg_sprintf( "\n\t{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)",
422 id
->Data1
, id
->Data2
, id
->Data3
,
423 id
->Data4
[0], id
->Data4
[1], id
->Data4
[2], id
->Data4
[3],
424 id
->Data4
[4], id
->Data4
[5], id
->Data4
[6], id
->Data4
[7], name
? name
: "unknown" );