2002-05-09 21:42:07 +02:00
|
|
|
/*
|
|
|
|
* Helper functions for debugging
|
|
|
|
*
|
|
|
|
* Copyright 1998, 2002 Juergen Schmied
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
2002-05-09 21:42:07 +02:00
|
|
|
#include "pidl.h"
|
|
|
|
#include "shlguid.h"
|
2004-04-19 21:26:57 +02:00
|
|
|
#include "shldisp.h"
|
2002-05-09 21:42:07 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "debughlp.h"
|
2002-07-02 04:05:17 +02:00
|
|
|
#include "docobj.h"
|
|
|
|
#include "shell32_main.h"
|
2002-05-09 21:42:07 +02:00
|
|
|
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(pidl);
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2003-09-02 03:01:06 +02:00
|
|
|
LPITEMIDLIST _dbg_ILGetNext(LPCITEMIDLIST pidl)
|
2002-05-09 21:42:07 +02:00
|
|
|
{
|
|
|
|
WORD len;
|
|
|
|
|
|
|
|
if(pidl)
|
|
|
|
{
|
|
|
|
len = pidl->mkid.cb;
|
|
|
|
if (len)
|
|
|
|
{
|
2003-09-02 03:01:06 +02:00
|
|
|
return (LPITEMIDLIST) (((LPBYTE)pidl)+len);
|
2002-05-09 21:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2002-05-09 21:42:07 +02:00
|
|
|
BOOL _dbg_ILIsDesktop(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
return ( !pidl || (pidl && pidl->mkid.cb == 0x00) );
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2003-09-02 03:01:06 +02:00
|
|
|
LPPIDLDATA _dbg_ILGetDataPointer(LPCITEMIDLIST pidl)
|
2002-05-09 21:42:07 +02:00
|
|
|
{
|
|
|
|
if(pidl && pidl->mkid.cb != 0x00)
|
|
|
|
return (LPPIDLDATA) &(pidl->mkid.abID);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2002-05-09 21:42:07 +02:00
|
|
|
LPSTR _dbg_ILGetTextPointer(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl);
|
|
|
|
|
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
switch (pdata->type)
|
|
|
|
{
|
2004-04-06 05:22:29 +02:00
|
|
|
case PT_GUID:
|
2004-04-07 01:12:11 +02:00
|
|
|
case PT_SHELLEXT:
|
2004-10-26 02:17:31 +02:00
|
|
|
case PT_YAGUID:
|
2002-05-09 21:42:07 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
case PT_DRIVE:
|
|
|
|
case PT_DRIVE1:
|
|
|
|
case PT_DRIVE2:
|
|
|
|
case PT_DRIVE3:
|
|
|
|
return (LPSTR)&(pdata->u.drive.szDriveName);
|
|
|
|
|
|
|
|
case PT_FOLDER:
|
|
|
|
case PT_FOLDER1:
|
|
|
|
case PT_VALUE:
|
|
|
|
case PT_IESPECIAL1:
|
|
|
|
case PT_IESPECIAL2:
|
|
|
|
return (LPSTR)&(pdata->u.file.szNames);
|
|
|
|
|
|
|
|
case PT_WORKGRP:
|
|
|
|
case PT_COMP:
|
|
|
|
case PT_NETWORK:
|
2003-05-19 23:42:44 +02:00
|
|
|
case PT_NETPROVIDER:
|
2002-05-09 21:42:07 +02:00
|
|
|
case PT_SHARE:
|
|
|
|
return (LPSTR)&(pdata->u.network.szNames);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2002-05-09 21:42:07 +02:00
|
|
|
LPSTR _dbg_ILGetSTextPointer(LPCITEMIDLIST pidl)
|
|
|
|
{
|
|
|
|
LPPIDLDATA pdata =_dbg_ILGetDataPointer(pidl);
|
|
|
|
|
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
switch (pdata->type)
|
|
|
|
{
|
|
|
|
case PT_FOLDER:
|
|
|
|
case PT_VALUE:
|
|
|
|
case PT_IESPECIAL1:
|
|
|
|
case PT_IESPECIAL2:
|
|
|
|
return (LPSTR)(pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1);
|
|
|
|
|
|
|
|
case PT_WORKGRP:
|
|
|
|
return (LPSTR)(pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
|
|
|
IID* _dbg_ILGetGUIDPointer(LPCITEMIDLIST pidl)
|
2002-05-09 21:42:07 +02:00
|
|
|
{
|
|
|
|
LPPIDLDATA pdata =_ILGetDataPointer(pidl);
|
|
|
|
|
|
|
|
if (pdata)
|
|
|
|
{
|
|
|
|
switch (pdata->type)
|
|
|
|
{
|
2004-04-07 01:12:11 +02:00
|
|
|
case PT_SHELLEXT:
|
2004-04-06 05:22:29 +02:00
|
|
|
case PT_GUID:
|
2005-04-13 16:39:27 +02:00
|
|
|
case PT_YAGUID:
|
2004-08-09 20:49:42 +02:00
|
|
|
return &(pdata->u.guid.guid);
|
2002-05-09 21:42:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-08-09 20:49:42 +02:00
|
|
|
static
|
2002-05-09 21:42:07 +02:00
|
|
|
DWORD _dbg_ILSimpleGetText (LPCITEMIDLIST pidl, LPSTR szOut, UINT uOutSize)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD dwReturn=0;
|
2002-05-09 21:42:07 +02:00
|
|
|
LPSTR szSrc;
|
|
|
|
GUID const * riid;
|
|
|
|
char szTemp[MAX_PATH];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-05-09 21:42:07 +02:00
|
|
|
if (!pidl) return 0;
|
|
|
|
|
|
|
|
if (szOut)
|
|
|
|
*szOut = 0;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (_dbg_ILIsDesktop(pidl))
|
2002-05-09 21:42:07 +02:00
|
|
|
{
|
|
|
|
/* desktop */
|
2005-04-18 12:30:55 +02:00
|
|
|
if (szOut) lstrcpynA(szOut, "Desktop", uOutSize);
|
2002-05-09 21:42:07 +02:00
|
|
|
dwReturn = strlen ("Desktop");
|
|
|
|
}
|
|
|
|
else if (( szSrc = _dbg_ILGetTextPointer(pidl) ))
|
|
|
|
{
|
|
|
|
/* filesystem */
|
2005-04-18 12:30:55 +02:00
|
|
|
if (szOut) lstrcpynA(szOut, szSrc, uOutSize);
|
2002-05-09 21:42:07 +02:00
|
|
|
dwReturn = strlen(szSrc);
|
|
|
|
}
|
|
|
|
else if (( riid = _dbg_ILGetGUIDPointer(pidl) ))
|
|
|
|
{
|
|
|
|
if (szOut)
|
|
|
|
sprintf( szOut, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
|
|
|
riid->Data1, riid->Data2, riid->Data3,
|
|
|
|
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
|
|
|
|
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
|
|
|
|
dwReturn = strlen (szTemp);
|
|
|
|
}
|
|
|
|
return dwReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void pdump (LPCITEMIDLIST pidl)
|
|
|
|
{
|
2003-09-02 03:01:06 +02:00
|
|
|
LPCITEMIDLIST pidltemp = pidl;
|
2002-05-09 21:42:07 +02:00
|
|
|
|
|
|
|
if (!TRACE_ON(pidl)) return;
|
|
|
|
|
|
|
|
if (! pidltemp)
|
|
|
|
{
|
|
|
|
MESSAGE ("-------- pidl=NULL (Desktop)\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MESSAGE ("-------- pidl=%p\n", pidl);
|
|
|
|
if (pidltemp->mkid.cb)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2002-05-09 21:42:07 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
DWORD dwAttrib = 0;
|
|
|
|
LPPIDLDATA pData = _dbg_ILGetDataPointer(pidltemp);
|
|
|
|
DWORD type = pData->type;
|
|
|
|
LPSTR szLongName = _dbg_ILGetTextPointer(pidltemp);
|
|
|
|
LPSTR szShortName = _dbg_ILGetSTextPointer(pidltemp);
|
|
|
|
char szName[MAX_PATH];
|
|
|
|
|
|
|
|
_dbg_ILSimpleGetText(pidltemp, szName, MAX_PATH);
|
2004-04-14 21:33:07 +02:00
|
|
|
if( PT_FOLDER == type || PT_VALUE == type)
|
2002-05-09 21:42:07 +02:00
|
|
|
dwAttrib = pData->u.file.uFileAttribs;
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
MESSAGE ("[%p] size=%04u type=%lx attr=0x%08lx name=\"%s\" (%s,%s)\n",
|
2002-05-09 21:42:07 +02:00
|
|
|
pidltemp, pidltemp->mkid.cb,type,dwAttrib,szName,debugstr_a(szLongName), debugstr_a(szShortName));
|
|
|
|
|
|
|
|
pidltemp = _dbg_ILGetNext(pidltemp);
|
|
|
|
|
2005-03-17 19:55:16 +01:00
|
|
|
} while (pidltemp && pidltemp->mkid.cb);
|
2002-05-09 21:42:07 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MESSAGE ("empty pidl (Desktop)\n");
|
|
|
|
}
|
|
|
|
pcheck(pidl);
|
|
|
|
}
|
|
|
|
}
|
2005-03-31 12:05:59 +02:00
|
|
|
|
|
|
|
static void dump_pidl_hex( LPCITEMIDLIST pidl )
|
2002-05-09 21:42:07 +02:00
|
|
|
{
|
2005-03-31 12:05:59 +02:00
|
|
|
const unsigned char *p = (const unsigned char *)pidl;
|
|
|
|
const int max_bytes = 0x80, max_line = 0x10;
|
|
|
|
char szHex[max_line*3+1], szAscii[max_line+1];
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
n = pidl->mkid.cb;
|
|
|
|
if( n>max_bytes )
|
|
|
|
n = max_bytes;
|
|
|
|
for( i=0; i<n; i++ )
|
|
|
|
{
|
|
|
|
sprintf( &szHex[ (i%max_line)*3 ], "%02X ", p[i] );
|
|
|
|
szAscii[ (i%max_line) ] = isprint( p[i] ) ? p[i] : '.';
|
|
|
|
|
|
|
|
/* print out at the end of each line and when we're finished */
|
|
|
|
if( i!=(n-1) && (i%max_line) != (max_line-1) )
|
|
|
|
continue;
|
|
|
|
szAscii[ (i%max_line)+1 ] = 0;
|
|
|
|
DPRINTF("%-*s %s\n", max_line*3, szHex, szAscii );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL pcheck( LPCITEMIDLIST pidl )
|
|
|
|
{
|
|
|
|
DWORD type;
|
|
|
|
LPCITEMIDLIST pidltemp = pidl;
|
|
|
|
|
|
|
|
while( pidltemp && pidltemp->mkid.cb )
|
|
|
|
{
|
|
|
|
type = _dbg_ILGetDataPointer(pidltemp)->type;
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case PT_CPLAPPLET:
|
|
|
|
case PT_GUID:
|
|
|
|
case PT_SHELLEXT:
|
|
|
|
case PT_DRIVE:
|
|
|
|
case PT_DRIVE1:
|
|
|
|
case PT_DRIVE2:
|
|
|
|
case PT_DRIVE3:
|
|
|
|
case PT_FOLDER:
|
|
|
|
case PT_VALUE:
|
2005-04-13 16:39:27 +02:00
|
|
|
case PT_VALUEW:
|
2005-03-31 12:05:59 +02:00
|
|
|
case PT_FOLDER1:
|
|
|
|
case PT_WORKGRP:
|
|
|
|
case PT_COMP:
|
|
|
|
case PT_NETPROVIDER:
|
|
|
|
case PT_NETWORK:
|
|
|
|
case PT_IESPECIAL1:
|
|
|
|
case PT_YAGUID:
|
|
|
|
case PT_IESPECIAL2:
|
|
|
|
case PT_SHARE:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("unknown IDLIST %p [%p] size=%u type=%lx\n",
|
|
|
|
pidl, pidltemp, pidltemp->mkid.cb,type );
|
|
|
|
dump_pidl_hex( pidltemp );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pidltemp = _dbg_ILGetNext(pidltemp);
|
|
|
|
}
|
|
|
|
return TRUE;
|
2002-05-09 21:42:07 +02:00
|
|
|
}
|
2002-07-02 04:05:17 +02:00
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
static char shdebugstr_buf1[100];
|
|
|
|
static char shdebugstr_buf2[100];
|
|
|
|
static char * shdebugstr_buf = shdebugstr_buf1;
|
2002-07-02 04:05:17 +02:00
|
|
|
|
|
|
|
static struct {
|
2005-06-07 22:30:30 +02:00
|
|
|
REFIID riid;
|
|
|
|
const char *name;
|
2002-07-02 04:05:17 +02:00
|
|
|
} InterfaceDesc[] = {
|
|
|
|
{&IID_IUnknown, "IID_IUnknown"},
|
2002-07-24 03:56:03 +02:00
|
|
|
{&IID_IClassFactory, "IID_IClassFactory"},
|
2002-07-02 04:05:17 +02:00
|
|
|
{&IID_IShellView, "IID_IShellView"},
|
|
|
|
{&IID_IOleCommandTarget, "IID_IOleCommandTarget"},
|
|
|
|
{&IID_IDropTarget, "IID_IDropTarget"},
|
|
|
|
{&IID_IDropSource, "IID_IDropSource"},
|
|
|
|
{&IID_IViewObject, "IID_IViewObject"},
|
|
|
|
{&IID_IContextMenu, "IID_IContextMenu"},
|
|
|
|
{&IID_IShellExtInit, "IID_IShellExtInit"},
|
|
|
|
{&IID_IShellFolder, "IID_IShellFolder"},
|
|
|
|
{&IID_IShellFolder2, "IID_IShellFolder2"},
|
|
|
|
{&IID_IPersist, "IID_IPersist"},
|
|
|
|
{&IID_IPersistFolder, "IID_IPersistFolder"},
|
|
|
|
{&IID_IPersistFolder2, "IID_IPersistFolder2"},
|
|
|
|
{&IID_IPersistFolder3, "IID_IPersistFolder3"},
|
|
|
|
{&IID_IExtractIconA, "IID_IExtractIconA"},
|
2002-12-16 23:39:42 +01:00
|
|
|
{&IID_IExtractIconW, "IID_IExtractIconW"},
|
2002-07-02 04:05:17 +02:00
|
|
|
{&IID_IDataObject, "IID_IDataObject"},
|
2004-04-19 21:26:57 +02:00
|
|
|
{&IID_IAutoComplete, "IID_IAutoComplete"},
|
|
|
|
{&IID_IAutoComplete2, "IID_IAutoComplete2"},
|
2005-04-13 16:39:27 +02:00
|
|
|
{&IID_IShellLinkA, "IID_IShellLinkA"},
|
|
|
|
{&IID_IShellLinkW, "IID_IShellLinkW"},
|
2002-07-02 04:05:17 +02:00
|
|
|
{NULL,NULL}};
|
|
|
|
|
|
|
|
const char * shdebugstr_guid( const struct _GUID *id )
|
|
|
|
{
|
|
|
|
int i;
|
2005-06-07 22:30:30 +02:00
|
|
|
const char* name = NULL;
|
2002-07-02 04:05:17 +02:00
|
|
|
char clsidbuf[100];
|
|
|
|
|
2002-07-24 03:56:03 +02:00
|
|
|
shdebugstr_buf = (shdebugstr_buf == shdebugstr_buf1) ? shdebugstr_buf2 : shdebugstr_buf1;
|
|
|
|
|
2002-07-02 04:05:17 +02:00
|
|
|
if (!id) {
|
|
|
|
strcpy (shdebugstr_buf, "(null)");
|
|
|
|
} else {
|
|
|
|
for (i=0;InterfaceDesc[i].riid && !name;i++) {
|
|
|
|
if (IsEqualIID(InterfaceDesc[i].riid, id)) name = InterfaceDesc[i].name;
|
|
|
|
}
|
|
|
|
if (!name) {
|
2002-12-14 00:45:36 +01:00
|
|
|
if (HCR_GetClassNameA(id, clsidbuf, 100))
|
2002-07-02 04:05:17 +02:00
|
|
|
name = clsidbuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf( shdebugstr_buf, "\n\t{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x} (%s)",
|
|
|
|
id->Data1, id->Data2, id->Data3,
|
|
|
|
id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3],
|
|
|
|
id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7], name ? name : "unknown" );
|
|
|
|
}
|
|
|
|
return shdebugstr_buf;
|
|
|
|
}
|