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

IsBitSet Native error #2328

Closed
manups4e opened this issue Jan 3, 2024 · 4 comments
Closed

IsBitSet Native error #2328

manups4e opened this issue Jan 3, 2024 · 4 comments
Assignees
Labels
bug ScRT: C# Issues/PRs related to either C# scripting runtimes ScRT: Lua Issues/PRs related to the Lua scripting runtime

Comments

@manups4e
Copy link
Contributor

manups4e commented Jan 3, 2024

What happened?

Native IsBitSet is unable to check memory addresses.. i think due to client sandboxing.

error in Log:

[    182453] [FiveM_b2944_GT]             MainThrd/ Failed to run a tick for ClientMain: System.BadImageFormatException: Error verifying CitizenFX.Core.ScriptContext:ErrorHandler (byte*): Cannot load method from token 0x0a000362 for callvirt at 0x0020
[    182453] [FiveM_b2944_GT]             MainThrd/   at CitizenFX.Core.Native.API.InternalIsBitSet (System.Int32 address, System.Int32 offset) [0x00068] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore\NativesFive.cs:133139 
[    182453] [FiveM_b2944_GT]             MainThrd/   at CitizenFX.Core.Native.API.IsBitSet (System.Int32 address, System.Int32 offset) [0x00000] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore\NativesFive.cs:133115 
[    182453] [FiveM_b2944_GT]             MainThrd/   at FreeRoamProject.Client.FREEROAM.Properties.PropertiesExteriorsManager.HandleWarpIntoGarage () [0x0036c] in G:\Progetti\source\repos\2023\FreeRoamProject\FreeRoamProject\FreeRoamProject\FreeRoamProject.Client\FREEROAM\Properties\PropertiesExteriorsManager.cs:1195 
[    182453] [FiveM_b2944_GT]             MainThrd/   at FreeRoamProject.Client.FREEROAM.Properties.PropertiesExteriorsManager+<HandleOutsideProperty>d__88.MoveNext () [0x00293] in G:\Progetti\source\repos\2023\FreeRoamProject\FreeRoamProject\FreeRoamProject\FreeRoamProject.Client\FREEROAM\Properties\PropertiesExteriorsManager.cs:627 

example code (C#)

                    if (!IsBitSet(BitForVehicles, 0))
                    {
                        if (DoGaragePedWalkInCutscene(false))
                        {
                            DoScreenFadeOut(500);
                            PlayGarageSound(GarageSounds.EnteringSound);
                            SetBit(ref BitForVehicles, 0);
                        }
                        else
                        {
                            if (!IsScreenFadedOut() && !IsScreenFadingOut() && !IsScreenFadingIn())
                            {
                                DoScreenFadeOut(500);
                            }
                        }
                    }

Expected result

the native should return a boolean value

Reproduction steps

simply use IsBitSet with any memory address or bit to check

Importancy

Slight inconvenience

Area(s)

FiveM, Natives, ScRT: Lua, ScRT: C#

Specific version(s)

FiveM 7277, FXServer 7199

Additional information

SetBit and ClearBit don't seem to return the same error, they seem to work correctly, can't test it without the ability to test the set/clear bits

@manups4e manups4e added bug triage Needs a preliminary assessment to determine the urgency and required action labels Jan 3, 2024
@github-actions github-actions bot added ScRT: C# Issues/PRs related to either C# scripting runtimes ScRT: Lua Issues/PRs related to the Lua scripting runtime labels Jan 3, 2024
@manups4e manups4e changed the title IsBitSet errors out due to sandboxing IsBitSet Native error Jan 3, 2024
@Gogsi
Copy link

Gogsi commented Jan 3, 2024

IS_BIT_SET was removed from the game in build 2612, where it was replaced with an instruction. It was reimplemented for FiveM in a287933 but in a later commit it was then zerod out of the crossmap (search for 0xE2D0C323A1AE5D85) so that fix won't work for builds above 2612. It should probably repeat 0xE2D0C323A1AE5D85 in the last two fields for compatibility.

In any case C# provides a native way of dealing with bitwise operations. IsBitSet(x, 5) is equivalent to x & (1 << 5). So there's really no need to use it.

@manups4e
Copy link
Contributor Author

manups4e commented Jan 3, 2024

Yeah I was gonna apply something similar but I thought the native would have done something different.. thanks!!

@manups4e manups4e closed this as completed Jan 3, 2024
@github-actions github-actions bot removed the triage Needs a preliminary assessment to determine the urgency and required action label Jan 3, 2024
@Gogsi
Copy link

Gogsi commented Jan 3, 2024

There is still an underlying issue of IS_BIT_SET being reimplemented in one commit and then being left out of the native crossmap. I'd still leave that open even if it's not very important

@manups4e manups4e reopened this Jan 3, 2024
@github-actions github-actions bot added the triage Needs a preliminary assessment to determine the urgency and required action label Jan 3, 2024
@blattersturm
Copy link
Contributor

Similarly, ErrorHandler failing validation seems unintended as well.

@gottfriedleibniz gottfriedleibniz self-assigned this Feb 1, 2024
@github-actions github-actions bot removed the triage Needs a preliminary assessment to determine the urgency and required action label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ScRT: C# Issues/PRs related to either C# scripting runtimes ScRT: Lua Issues/PRs related to the Lua scripting runtime
Projects
None yet
Development

No branches or pull requests

4 participants