It is currently Tue Mar 31, 2020 8:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: kCFBooleanTrue
PostPosted: Fri Aug 30, 2019 5:28 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 243
Location: NL
I just came across this crazy code:
Code:
Global.i kCFBooleanTrue
Global.i kCFBooleanFalse
!mov rax, qword [kCFBooleanTruePtr]
!mov rdx, qword [kCFBooleanFalsePtr]
!mov rax, [rax]
!mov rdx, [rdx]
!mov [v_kCFBooleanTrue], rax
!mov [v_kCFBooleanFalse], rdx
DataSection
   !extern _kCFBooleanTrue
   !extern _kCFBooleanFalse
   !kCFBooleanTruePtr: dq _kCFBooleanTrue
   !kCFBooleanFalsePtr: dq _kCFBooleanFalse
EndDataSection


Isn't it time for PB to include a predefined kCFBooleanTrue and kCFBooleanFalse on macOS if it's such a 'difficult' value?


Top
 Profile  
Reply with quote  
 Post subject: Re: kCFBooleanTrue
PostPosted: Fri Aug 30, 2019 5:39 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 243
Location: NL
Well, there is a huge discrepancy between build-in Windows constants and macOS ones...


Top
 Profile  
Reply with quote  
 Post subject: Re: kCFBooleanTrue
PostPosted: Fri Aug 30, 2019 5:56 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
The problem is that something like kCFBooleanTrue is not a simple value but an object.

This will return the same by the way.
Code:
Global.i kCFBooleanTrue = PeekI(dlsym_(#RTLD_DEFAULT, "kCFBooleanTrue"))
Global.i kCFBooleanFalse = PeekI(dlsym_(#RTLD_DEFAULT, "kCFBooleanFalse"))

Debug kCFBooleanTrue
Debug kCFBooleanFalse


And NSNumber can also be used.
Code:
Debug CocoaMessage(0, 0, "NSNumber numberWithBool:", #YES)
Debug CocoaMessage(0, 0, "NSNumber numberWithBool:", #NO)

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: kCFBooleanTrue
PostPosted: Fri Aug 30, 2019 6:41 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Mar 11, 2009 4:06 pm
Posts: 243
Location: NL
Ah that looks much better. Makes this topic useful because I only found ASM code in the forum.
Thanks


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: s0ula55a551n and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye