Page 1 of 1

PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 4:38 pm
by Denis
I don't know if the crash comes from API or structure or ...

The following code works in x86 mode unicode or not.
It crashes in x64 mode unicode or not with or without register key value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management set or not (AllocationPreference"=dword:00100000).
Obviously i've restarded my computer after register change.

But now, uncomment line with ExplorerTreeGadget or ExplorerListGadget or ExplorerComboGadget.
Run it and it works, no x64 crash.

A shell ImageList problem ?

Code: Select all

Global  Path$ = "C:\"
Global info.SHFILEINFO

#Listicon = 0

If OpenWindow(0, 100, 100, 600, 300, "ListIconGadget", #PB_Window_MaximizeGadget| #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
      ListIconGadget(#Listicon, 0, 0, 300, WindowHeight(0)-30, "Element", 200)
      
      
      ; ExplorerTreeGadget(5, 310, 0, 290, WindowHeight(0)-30, Path$, #PB_Explorer_NoFiles)
      ; ExplorerListGadget(5, 310, 0, 290, WindowHeight(0)-30, Path$, #PB_Explorer_NoFiles)
      ; ExplorerComboGadget(5, 310, 0, 290, WindowHeight(0)-30, Path$, #PB_Explorer_NoFiles)
      
      If ExamineDirectory(0, Path$, "*.*")
            While NextDirectoryEntry(0)
                  If DirectoryEntryType(0) = #PB_DirectoryEntry_File
                        If SHGetFileInfo_(Path$ + DirectoryEntryName(0), 0, @info.SHFILEINFO, SizeOf(SHFILEINFO), #SHGFI_ICON|#SHGFI_LARGEICON)
                              AddGadgetItem(#Listicon, -1, DirectoryEntryName(0), info\hIcon)
                              DestroyIcon_(info\hIcon)
                        Else
                              AddGadgetItem(#Listicon, -1, DirectoryEntryName(0))
                        EndIf
                        
                  EndIf
            Wend
            FinishDirectory(0)
      EndIf
EndIf

Repeat
      event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 5:11 pm
by Thunder93
Hi. I'm using PureBasic 5.10 x64 and pasted your code sample and ran the x64 compiler and ran without issues.

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 7:11 pm
by Denis
Thunder93, May be my computer ?

I have an another 64 bit computer i don't use for a while.

I try on it and no bug at all.
Really weird.

I will do a new clean install of PB 5.10 to see.

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 7:27 pm
by Denis
Same result after a clean reinstall.

Always this weird "bug"

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 7:44 pm
by jassing
ran on my 5.10 w/o issues too (x64 win7)

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Thu Feb 21, 2013 8:02 pm
by Thunder93
Might be looking at an anomaly outside of PureBasic.

I would make certain that there aren't any userlibs and tools being loaded up with PureBasic.

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Fri Feb 22, 2013 7:07 am
by Denis
Thank you Thunder93 & jassing,

I use 0 extern lib. All what i do is done by hand code.

Finally, after many hours spend on it, i remember a weird problem that Danilo has had.
ExplorerListGadget - nada icons for *.exe
http://www.purebasic.fr/english/viewtop ... =5&t=48559

i just put CoInitialize_(0) before using SHGetFileInfo_() and CoUninitialize_() at the end of code.

That's all and now it's OK

Fred, i wonder why for some coders it's Ok and not for my first computer in x64 mode ?
May be CoInitialize_(0) is not needed for x86 :?:

I looked at MS report files and 2 info as been reported about ole32.dll and kernel32.dll (checksum, version etc.)

Did PB 5.10 use CoInitialize_(0) to init ? in all modes (x86-x64 win mode)

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Fri Feb 22, 2013 9:10 am
by Thunder93
Danilo problem likely came from the registry exefile key content being tampered with. Improper modification to this information can cause generic icons to be displayed w/ SHGetFileInfo API usage for executables. However, this doesn't explain your experiences.

btw; the crash for you happens when running code with and without the PureBasic debugger?

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Fri Feb 22, 2013 9:15 am
by Denis
It crashed with or without debugger.

I have Win 7 pro x64, don't know if it has a link with.

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Posted: Fri Feb 22, 2013 9:21 am
by Thunder93
I'm running PureBasic x64 v5.10 on Windows 7 x64, and your sample code works flawlessly.