PB 5.10 SHGetFileInfo_() API crash - x64

Windows specific forum
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

PB 5.10 SHGetFileInfo_() API crash - x64

Post 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
A+
Denis
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post by Thunder93 »

Hi. I'm using PureBasic 5.10 x64 and pasted your code sample and ran the x64 compiler and ran without issues.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post 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.
A+
Denis
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post by Denis »

Same result after a clean reinstall.

Always this weird "bug"
A+
Denis
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post by jassing »

ran on my 5.10 w/o issues too (x64 win7)
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post 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.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post 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)
A+
Denis
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post 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?
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Denis
Enthusiast
Enthusiast
Posts: 778
Joined: Fri Apr 25, 2003 5:10 pm
Location: Doubs - France

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post by Denis »

It crashed with or without debugger.

I have Win 7 pro x64, don't know if it has a link with.
A+
Denis
User avatar
Thunder93
Addict
Addict
Posts: 1788
Joined: Tue Mar 21, 2006 12:31 am
Location: Canada

Re: PB 5.10 SHGetFileInfo_() API crash - x64

Post by Thunder93 »

I'm running PureBasic x64 v5.10 on Windows 7 x64, and your sample code works flawlessly.
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley
Post Reply