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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/debug.h"
33 #include "shell32_main.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(pidl
);
39 LPITEMIDLIST
_dbg_ILGetNext(LPCITEMIDLIST pidl
)
48 return (LPITEMIDLIST
) (((LPBYTE
)pidl
)+len
);
55 BOOL
_dbg_ILIsDesktop(LPCITEMIDLIST pidl
)
57 return ( !pidl
|| (pidl
&& pidl
->mkid
.cb
== 0x00) );
61 LPPIDLDATA
_dbg_ILGetDataPointer(LPCITEMIDLIST pidl
)
63 if(pidl
&& pidl
->mkid
.cb
!= 0x00)
64 return (LPPIDLDATA
) &(pidl
->mkid
.abID
);
69 LPSTR
_dbg_ILGetTextPointer(LPCITEMIDLIST pidl
)
71 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
85 return (LPSTR
)&(pdata
->u
.drive
.szDriveName
);
93 return (LPSTR
)&(pdata
->u
.file
.szNames
);
100 return (LPSTR
)&(pdata
->u
.network
.szNames
);
107 LPSTR
_dbg_ILGetSTextPointer(LPCITEMIDLIST pidl
)
109 LPPIDLDATA pdata
=_dbg_ILGetDataPointer(pidl
);
120 return (LPSTR
)(pdata
->u
.file
.szNames
+ strlen (pdata
->u
.file
.szNames
) + 1);
123 return (LPSTR
)(pdata
->u
.network
.szNames
+ strlen (pdata
->u
.network
.szNames
) + 1);
130 IID
* _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl
)
132 LPPIDLDATA pdata
=_ILGetDataPointer(pidl
);
140 return &(pdata
->u
.guid
.guid
);
147 DWORD
_dbg_ILSimpleGetText (LPCITEMIDLIST pidl
, LPSTR szOut
, UINT uOutSize
)
152 char szTemp
[MAX_PATH
];
159 if (_dbg_ILIsDesktop(pidl
))
162 if (szOut
) strncpy(szOut
, "Desktop", uOutSize
);
163 dwReturn
= strlen ("Desktop");
165 else if (( szSrc
= _dbg_ILGetTextPointer(pidl
) ))
168 if (szOut
) strncpy(szOut
, szSrc
, uOutSize
);
169 dwReturn
= strlen(szSrc
);
171 else if (( riid
= _dbg_ILGetGUIDPointer(pidl
) ))
174 sprintf( szOut
, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
175 riid
->Data1
, riid
->Data2
, riid
->Data3
,
176 riid
->Data4
[0], riid
->Data4
[1], riid
->Data4
[2], riid
->Data4
[3],
177 riid
->Data4
[4], riid
->Data4
[5], riid
->Data4
[6], riid
->Data4
[7] );
178 dwReturn
= strlen (szTemp
);
186 void pdump (LPCITEMIDLIST pidl
)
188 LPCITEMIDLIST pidltemp
= pidl
;
190 if (!TRACE_ON(pidl
)) return;
194 MESSAGE ("-------- pidl=NULL (Desktop)\n");
198 MESSAGE ("-------- pidl=%p\n", pidl
);
199 if (pidltemp
->mkid
.cb
)
204 LPPIDLDATA pData
= _dbg_ILGetDataPointer(pidltemp
);
205 DWORD type
= pData
->type
;
206 LPSTR szLongName
= _dbg_ILGetTextPointer(pidltemp
);
207 LPSTR szShortName
= _dbg_ILGetSTextPointer(pidltemp
);
208 char szName
[MAX_PATH
];
210 _dbg_ILSimpleGetText(pidltemp
, szName
, MAX_PATH
);
211 if( PT_FOLDER
== type
|| PT_VALUE
== type
)
212 dwAttrib
= pData
->u
.file
.uFileAttribs
;
214 MESSAGE ("[%p] size=%04u type=%lx attr=0x%08lx name=\"%s\" (%s,%s)\n",
215 pidltemp
, pidltemp
->mkid
.cb
,type
,dwAttrib
,szName
,debugstr_a(szLongName
), debugstr_a(szShortName
));
217 pidltemp
= _dbg_ILGetNext(pidltemp
);
219 } while (pidltemp
->mkid
.cb
);
223 MESSAGE ("empty pidl (Desktop)\n");
228 #define BYTES_PRINTED 32
229 BOOL
pcheck (LPCITEMIDLIST pidl
)
231 DWORD type
, ret
=TRUE
;
232 LPCITEMIDLIST pidltemp
= pidl
;
234 if (pidltemp
&& pidltemp
->mkid
.cb
)
236 { type
= _dbg_ILGetDataPointer(pidltemp
)->type
;
259 char szTemp
[BYTES_PRINTED
*4 + 1];
263 memset(szTemp
, ' ', BYTES_PRINTED
*4 + 1);
264 for ( i
= 0; (i
<pidltemp
->mkid
.cb
) && (i
<BYTES_PRINTED
); i
++)
266 c
= ((unsigned char *)pidltemp
)[i
];
268 szTemp
[i
*3+0] = ((c
>>4)>9)? (c
>>4)+55 : (c
>>4)+48;
269 szTemp
[i
*3+1] = ((0x0F&c
)>9)? (0x0F&c
)+55 : (0x0F&c
)+48;
271 szTemp
[i
+BYTES_PRINTED
*3] = (c
>=0x20 && c
<=0x80) ? c
: '.';
273 szTemp
[BYTES_PRINTED
*4] = 0x00;
274 ERR("unknown IDLIST %p [%p] size=%u type=%lx\n%s\n",pidl
, pidltemp
, pidltemp
->mkid
.cb
,type
, szTemp
);
278 pidltemp
= _dbg_ILGetNext(pidltemp
);
279 } while (pidltemp
->mkid
.cb
);
284 static char shdebugstr_buf1
[100];
285 static char shdebugstr_buf2
[100];
286 static char * shdebugstr_buf
= shdebugstr_buf1
;
291 } InterfaceDesc
[] = {
292 {&IID_IUnknown
, "IID_IUnknown"},
293 {&IID_IClassFactory
, "IID_IClassFactory"},
294 {&IID_IShellView
, "IID_IShellView"},
295 {&IID_IOleCommandTarget
, "IID_IOleCommandTarget"},
296 {&IID_IDropTarget
, "IID_IDropTarget"},
297 {&IID_IDropSource
, "IID_IDropSource"},
298 {&IID_IViewObject
, "IID_IViewObject"},
299 {&IID_IContextMenu
, "IID_IContextMenu"},
300 {&IID_IShellExtInit
, "IID_IShellExtInit"},
301 {&IID_IShellFolder
, "IID_IShellFolder"},
302 {&IID_IShellFolder2
, "IID_IShellFolder2"},
303 {&IID_IPersist
, "IID_IPersist"},
304 {&IID_IPersistFolder
, "IID_IPersistFolder"},
305 {&IID_IPersistFolder2
, "IID_IPersistFolder2"},
306 {&IID_IPersistFolder3
, "IID_IPersistFolder3"},
307 {&IID_IExtractIconA
, "IID_IExtractIconA"},
308 {&IID_IExtractIconW
, "IID_IExtractIconW"},
309 {&IID_IDataObject
, "IID_IDataObject"},
310 {&IID_IAutoComplete
, "IID_IAutoComplete"},
311 {&IID_IAutoComplete2
, "IID_IAutoComplete2"},
314 const char * shdebugstr_guid( const struct _GUID
*id
)
320 shdebugstr_buf
= (shdebugstr_buf
== shdebugstr_buf1
) ? shdebugstr_buf2
: shdebugstr_buf1
;
323 strcpy (shdebugstr_buf
, "(null)");
325 for (i
=0;InterfaceDesc
[i
].riid
&& !name
;i
++) {
326 if (IsEqualIID(InterfaceDesc
[i
].riid
, id
)) name
= InterfaceDesc
[i
].name
;
329 if (HCR_GetClassNameA(id
, clsidbuf
, 100))
333 sprintf( shdebugstr_buf
, "\n\t{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)",
334 id
->Data1
, id
->Data2
, id
->Data3
,
335 id
->Data4
[0], id
->Data4
[1], id
->Data4
[2], id
->Data4
[3],
336 id
->Data4
[4], id
->Data4
[5], id
->Data4
[6], id
->Data4
[7], name
? name
: "unknown" );
338 return shdebugstr_buf
;