Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

I have application with CMFCShellTreeCtrl on one of it's dialog and it is crashing when running on some Win8 machines. It happen when tree control trying to initialize and calls SHGetFileInfo in this part of afxshelltreectrl.cpp:

C++
int CMFCShellTreeCtrl::OnGetItemIcon(LPAFX_SHELLITEMINFO pItem, BOOL bSelected)
{
    ENSURE(pItem != NULL);

    SHFILEINFO sfi;

    UINT uiFlags = SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON;

    if (bSelected)
    {
        uiFlags |= SHGFI_OPENICON;
    }
    else
    {
        uiFlags |= SHGFI_LINKOVERLAY;
    }

    if (SHGetFileInfo((LPCTSTR)pItem->pidlFQ, 0, &sfi, sizeof(sfi), uiFlags))
    {
        return sfi.iIcon;
    }

    return -1;
}


Application was build in VS2010 on Win7 32-bit.
I could not replicate this bug on VM so I debug remotely on client PC.
I compared the values ​​of arguments for SHGetFileInfo function, and they looked the same on my machine and the client's, except the memory addresses.

Call stack after exception:
http://bayimg.com/JaALkaAff[^]

WinDbg log:

ModLoad: 02b70000 02bc9000   cmd.exe 
    ModLoad: 60780000 607ca000   C:\windows\SysWOW64\mscoree.dll
    ModLoad: 60700000 6077a000   C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll
    ModLoad: 711b0000 71250000   C:\windows\SysWOW64\sxs.dll
    ModLoad: 60150000 606ff000   C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    ModLoad: 70e30000 70ecb000   C:\windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6910_none_d089c358442de345\MSVCR80.dll
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6910_none_d089c358442de345\MSVCR80.dll - 
    ModLoad: 5f650000 6014a000   C:\windows\assembly\NativeImages_v2.0.50727_32\mscorlib\7f763721bf47dc8d58ec21cb64cbec91\mscorlib.ni.dll
    ModLoad: 71770000 71778000   C:\Windows\Microsoft.NET\Framework\v2.0.50727\culture.dll
    (c18.227c): CLR exception - code e0434f4d (first chance)
    (c18.227c): Access violation - code c0000005 (first chance)
    First chance exceptions are reported before any exception handling.
    This exception may be expected and handled.
    *** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\windows\SysWOW64\combase.dll - 
    eax=002d0068 ebx=80040154 ecx=04b1f654 edx=04b1f678 esi=0018b654 edi=76cbbda0
    eip=002d0068 esp=0018b63c ebp=0018b648 iopl=0         nv up ei ng nz ac pe cy
    cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010297
    002d0068 ??              ???


According to the call stack error occurs in some COM functions.
I am not familiar with COM so may be some one can help me to find the reason why SHGetFileInfo cause exception.
Posted
Comments
Pablo Aliskevicius 2-Oct-13 10:14am    
Are you compiling in release mode? If so, try:
SHFILEINFO sfi = { 0 }; // zero memory of struct, otherwise may hold garbage.
KarstenK 2-Oct-13 13:22pm    
These Shell functions aew cumbersome nad very sensitive in the parameters. Even if zhe are of the same type be very careful that they are VALID and NOT casted from a similar looking type.

Check that thes PC have also the newest updates on windows and nez-frameworks.
ant1488 3-Oct-13 8:56am    
I could not change this code because it is part of MFC.
Also if somebody look at call stack he will see that OnGetItemIcon() function called from GetRootItems() function. Here it's part:


LPITEMIDLIST pidl;
if (FAILED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl)))
{
return FALSE;
}
pItem->pidlFQ = afxShellManager->CopyItem(pidl);
tvItem.iImage = OnGetItemIcon(pItem, FALSE); // error occurs inside


So pItem->pidlFQ is the pointer to structure describing full path to Desktop(root item in treeview ctrl).
In memory it looks like valid(not empty or garbage). I have compared it with memory on other PC and it is identical.
I have no idea why it could be not valid.
My suggestion is: error happen when MFC trying to get access to some COM interface and it is not reachable because some facilities are disabled on client PC (COMSysApp service e.g). But I am not skilled in COM technologies. How can I check it?

1 solution

C++
CoInitializeEx()
in the beginning of
C++
OnInitDialog()
solve the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900