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

feat(natives): implement GET_MOUNTED_FILE_HASH #2792

Closed
wants to merge 2 commits into from

Conversation

PichotM
Copy link
Contributor

@PichotM PichotM commented Sep 15, 2024

Goal of this PR

This PR introduces a new native GET_MOUNTED_FILE_HASH.

How is this PR achieving the goal

By implementing the native using the same logic as puremode's hashes.

This PR applies to the following area(s)

FiveM & RedM client

Successfully tested on

FiveM and will most likely work in RedM too.

Game builds: 3095

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Sep 15, 2024
Copy link
Contributor

@iridium-cfx iridium-cfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is a good idea to have as a native, given the performance implications.

code/components/extra-natives-five/src/FileNatives.cpp Outdated Show resolved Hide resolved
code/components/extra-natives-five/src/FileNatives.cpp Outdated Show resolved Hide resolved
code/components/extra-natives-five/src/FileNatives.cpp Outdated Show resolved Hide resolved
@PichotM
Copy link
Contributor Author

PichotM commented Sep 16, 2024

I don't think this is a good idea to have as a native, given the performance implications.

Do you have any ideas for a better implementation?
I guess this native will only be used for a few small files on join. That won't necessarily be too expensive to run

@iridium-cfx
Copy link
Contributor

iridium-cfx commented Sep 16, 2024

I don't think this is a good idea to have as a native, given the performance implications.

Do you have any ideas for a better implementation?

Not off the top of my head, no

I guess this native will only be used for a few small files on join. That won't necessarily be too expensive to run

Perhaps. LOAD_RESOURCE_FILE exists so I guess loading files inside of natives isn't unheard of.

@slashkeyvalue
Copy link
Contributor

More weird anticheat "detection" attempts? :/

@spacevx
Copy link
Contributor

spacevx commented Sep 16, 2024

More weird anticheat "detection" attempts? :/

Some people are editing their client files to get advantages in PvP servers, I guess it's to block this

@p1u3o
Copy link

p1u3o commented Sep 16, 2024

What about a method to find out what files are loaded from the mods or citizen folder?

@Heisenberg691
Copy link

it would be nice if there is a method to identify modified files from mods/citizen/game files or blocking certain files to be modified. For example i want my players to use NVE graphics mod, but not to use custom audio files like louder footsteps or headshot sounds for advantage in pvp. Maybe a new pure mode level 3 that will block all modified client files except known graphics mods can be a solution for that.

@manzarek123
Copy link
Contributor

More weird anticheat "detection" attempts? :/

99% of cheaters these days are people using modified files.
By just dragging a rpf file in your mod folder you can have infinite stamina, perfect accuracy, bullet penetration, no bush, ect.
It doesn't even feel like cheating because it is so easy.

A simple native like this could prevent this and remove 99% of cheaters from FiveM and bring more positivity.
Sure this is not the perfect system but it starting to feel more and more like the perfect system is never going to happen. Just like the perfect system for dynamic pool resizing never happened.
So I think we should accept this kind of compromise and give more power to server owners.

As for performance issue, this will be checked during the loading process so this is not really an issue. Maybe adding a note in the native description could be a good idea then.

@thisneq
Copy link
Contributor

thisneq commented Sep 16, 2024

I have thought about something similar some time ago. In my opinion, there should be an additional pure mode which would allow server owners to specify the hashes of allowed files in the server configuration. Native function for that is not the most convenient solution.

@PichotM
Copy link
Contributor Author

PichotM commented Sep 16, 2024

I have thought about something similar some time ago. In my opinion, there should be an additional pure mode which would allow server owners to specify the hashes of allowed files in the server configuration. Native function for that is not the most convenient solution.

your solution is the same thing but requires a game restart for every join, not really convenient.
This native is humbly an implementation idea that prikolium recommended after the second part of #2625 got denied.
feel free to improve it if it is ever merged

@william-des
Copy link
Contributor

By just dragging a rpf file in your mod folder you can have infinite stamina, perfect accuracy, bullet penetration, no bush, ect.
It doesn't even feel like cheating because it is so easy.

Furthermore, unlike a traditional cheat, players don't risk being banned from the platform

i want my players to use NVE graphics mod, but not to use custom audio files like louder footsteps or headshot sounds for advantage in pvp. Maybe a new pure mode level 3 that will block all modified client files except known graphics mods can be a solution for that.

It's the perfect example of why Pure Mode is not widely used and why we need something like this instead. Each game server has different requirements regarding the files that should be blocked

@Keyinator
Copy link
Contributor

By just dragging a rpf file in your mod folder you can have infinite stamina, perfect accuracy, bullet penetration, no bush, ect.
It doesn't even feel like cheating because it is so easy.

Furthermore, unlike a traditional cheat, players don't risk being banned from the platform

i want my players to use NVE graphics mod, but not to use custom audio files like louder footsteps or headshot sounds for advantage in pvp. Maybe a new pure mode level 3 that will block all modified client files except known graphics mods can be a solution for that.

It's the perfect example of why Pure Mode is not widely used and why we need something like this instead. Each game server has different requirements regarding the files that should be blocked

Seconding exactly what @william-des and @manzarek123 said.
There's multiple categories of files that would be allowed/denied by certain servers like:

  • Sounds
  • Skys
  • Bushes
  • Hitboxes
  • Tracers
  • Kill Efects
  • Shaders

While I think this native would be useful too, I think a better approach would be to detect modification on certain file-names (or better yet, "modification-classes") then allow server owners to either transparently allow/black these classes or do it via a self-coded script that will kick a user for disallowed files.

Even better yet would be if denied "classes" can be disabled by the server-owner and the vanilla data is used respectively.
I don't know if that's possible or not though.

@prikolium-cfx
Copy link
Collaborator

Yeah, initially it was my idea. Including the fact that all the content files are read-only, can we make async hashing possible in another thread and waiting for result?

@prikolium-cfx prikolium-cfx added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Sep 19, 2024
@p1u3o
Copy link

p1u3o commented Sep 19, 2024

I think sounds would make be tricky having just categories, for example I can see custom sirens being acceptable, but weapon sounds not so much (can make silenced weapons/footsteps easier to hear).

Perhaps servers don't even need a hash, simply having a list of files overriden by rpfs in the mod folder, and relying on puremode to make sure the game files aren't touched, would still be better than the status quo.

@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Sep 21, 2024
@cloudyyy0273
Copy link

please add this already, no one can stand pure mode xD

@ook3D
Copy link
Contributor

ook3D commented Sep 29, 2024

please add this already, no one can stand pure mode xD

? I can't see why you would dislike pure mode, unless you are trying to let players load whatever random files they want into your server.

@PsychoShock
Copy link
Contributor

Maybe because pure mode is full restricted and doesn't allow as a server owner to accept some files you may want players to have. Especially for PvP servers.

@ook3D
Copy link
Contributor

ook3D commented Sep 29, 2024

Maybe because pure mode is full restricted and doesn't allow as a server owner to accept some files you may want players to have. Especially for PvP servers.

Fair enough I guess, didn't really think of such case

}
else
{
// Mark non-whitelisted paths as complete with "missing" hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't g_isFetching stay forever true when this condition is reached. Same if (it != g_fileHashes.end())?

@prikolium-cfx
Copy link
Collaborator

@PichotM What do you think about defining hashes list on server side in cfg file? So we can guarantee that check will be done on connect time and won't affect performance in play time.

@manzarek123
Copy link
Contributor

@PichotM What do you think about defining hashes list on server side in cfg file? So we can guarantee that check will be done on connect time and won't affect performance in play time.

We then need a way to generate the hash without this native so that we can put it in the cfg.


if (handle != -1)
{
auto len = device->GetFileLength(handle);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use chunked reading and hash calculation here

@PichotM
Copy link
Contributor Author

PichotM commented Dec 18, 2024

will be back soon

@PichotM PichotM closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Requires changes before it's considered valid and can be (re)triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.