PB 6.10 x64 OpenLibrary

Just starting out? Need help? Post your questions and find answers here.
User avatar
manu
User
User
Posts: 32
Joined: Tue May 13, 2003 12:40 pm
Location: Germany
Contact:

PB 6.10 x64 OpenLibrary

Post by manu »

Hi!

Code: Select all

Global my_lib.l

my_lib=OpenLibrary(#PB_Any, "version.dll")

Debug Str(my_lib)+" = $"+Hex(my_lib)

If my_lib = 0:End:EndIf

GetFunction(my_lib,"GetFileVersionInfoA")
(I wasn't actually using version.dll, this is just an example.)

Works with PB6.00 x64, crashes with PB6.10 x64.
The reason is the OpenLibrary actually returns a 64 bit value (>$FFFFFFFF) now. If you change my_lib.l to my_lib.i it works.
It is maybe better to use .i but many older programs have 32 bit variables when storing numbers returned by using #PB_Any.

Maybe it can be fixed to use 32 bit numbers only, as it was before?
Or is needs to be documented which functions now need a 64 bit storage for their Gadget/Image/Window/Whatever-Number.

Best regards,
Manu
User avatar
ChrisR
Addict
Addict
Posts: 1466
Joined: Sun Jan 08, 2017 10:27 pm
Location: France

Re: PB 6.10 x64 OpenLibrary

Post by ChrisR »

Fred wrote: Mon Mar 11, 2024 11:03 am
BarryG wrote: Mon Mar 11, 2024 10:51 am Changed to ".i" and all is working well again. Far out. Coding with 6.10 is so confusing now. :(
The confusing thing here is that wrong codes were 'correctly' working with previous version due to memory address fitting into long (.l) on x64. Again see this as an opportunity to finally have less hidden bugs in your apps.
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PB 6.10 x64 OpenLibrary

Post by jacdelad »

This is a terrible idea and also not possible. PureBasic has no power over which address is returned if an object (like a library) is assigned. That's why the help clearly states to use .i for handles. This is also fact for every programming language which uses x86-/x64-architecture. The simple fact that it worked before (by coincidence) is not a reason change something!
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: PB 6.10 x64 OpenLibrary

Post by Little John »

jacdelad wrote: Thu Apr 11, 2024 4:47 am That's why the help clearly states to use .i for handles.
... and that's been the case for at least as long as I've been using PureBasic (15+ years).

PS: Please don't post your coding questions in the “Bug reports” section of the forum!
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: PB 6.10 x64 OpenLibrary

Post by boddhi »

For those who haven't experienced it yet, please note too that this is often the reason why older codes on the forum crash. They use .l type instead of .i, the default type and equivalent under 32bits though. It often occurs, for example, with callbacks or subclassing...

As Chris said, this is sometimes an opportunity to update a code and, on Windows (I don't know about other OS) to change the name of some called APIs too (e.g. SetWindowLongPtr instead of SetWindowLong) to ensure compatibility. :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: PB 6.10 x64 OpenLibrary

Post by HeX0R »

to keep fair against old codes/coders, at the beginning of PB, there were no integers and longs were the default.
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PB 6.10 x64 OpenLibrary

Post by mk-soft »

HeX0R wrote: Thu Apr 11, 2024 4:34 pm to keep fair against old codes/coders, at the beginning of PB, there were no integers and longs were the default.
I remember it darkly 8)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply