Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScreenCaptureAccess.preflight returns incorrect value for Intel based 64bit Mac #677

Open
Pranav2612000 opened this issue May 17, 2024 · 6 comments · May be fixed by #678
Open

ScreenCaptureAccess.preflight returns incorrect value for Intel based 64bit Mac #677

Pranav2612000 opened this issue May 17, 2024 · 6 comments · May be fixed by #678

Comments

@Pranav2612000
Copy link

The function ScreenCaptureAccess.preflight [ Ref ] returns incorrectly for Intel based 64 bit Macs.

On further inspection, the reason for this is that the external method CGPreflightScreenCaptureAccess returns a value which is not 1 ( even if the permissions have been given ).
From my research, I've found that it returns a number whose lowest 8 bits are 0. So something like the following should work

image

That's what I'm doing in my fork here

This is working good enough for me. What do you think about this approach? Does it make sense? I'm open to submitting a PR, or if you have a better solution in mind, I'll love to implement it.

@madsmtm
Copy link
Contributor

madsmtm commented May 17, 2024

The correct way to work with external booleans is always to compare them against NO / 0. So rather, you should use != 0

@Pranav2612000
Copy link
Author

Yup @madsmtm . That was what I tried first, but I observed that CGPreflightScreenCaptureAccess returns a non zero value ( the last 8 bits of which are 0 ) if screen capture permissions are not present. So the function would always return true, which is not the correct behaviour.

Is it possible that it's something to do with Boolean being 1 byte by int32 being 4 bytes? Because the last 8 bits of the returned value are always 0000 0000 or 0000 0001

@madsmtm
Copy link
Contributor

madsmtm commented May 17, 2024

Oh... Actually, you're right, the issue is that the definition in Rust is using boolean_t instead of bool :/

@Pranav2612000
Copy link
Author

Yup. Thank you @madsmtm
What do you think the next steps should be here? Happy to submit a PR

@madsmtm
Copy link
Contributor

madsmtm commented May 18, 2024

Can't answer that, not a maintainer here, sorry

@jrmuizel
Copy link
Collaborator

Please submit a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants