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

fix(game/five): verify pickup weapon component is valid on creation #2797

Conversation

slashkeyvalue
Copy link
Contributor

Goal of this PR

Prevent crash caused by invalid pickup weapon components on pickup creation.

How is this PR achieving the goal

Adds proper validations on pickup creation

This PR applies to the following area(s)

FiveM

Successfully tested on

Game builds: 2060, 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.

Fixes issues

Fixes GTA5_b3095.exe!sub_141163854 (0x456)

@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Sep 17, 2024
fix(game/five): pickup weapon component creation validation is only needed after 1604

fix(game/five): jmp back to original code instead of returning, improve code flow
@slashkeyvalue slashkeyvalue force-pushed the fix/pickup-creation-invalid-weap-comp branch from 8b10a5e to 15417bd Compare September 17, 2024 13:20
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed invalid Requires changes before it's considered valid and can be (re)triaged triage Needs a preliminary assessment to determine the urgency and required action labels Sep 17, 2024
@prikolium-cfx prikolium-cfx added ready-to-merge This PR is enqueued for merging and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Sep 19, 2024
@slashkeyvalue
Copy link
Contributor Author

Is there something else pending or ...? Would be nice to be less abused by cheats :P

@Pedro-Lucas14
Copy link

Is the cheater taking down every player that some fix date goes into production? @prikolium-cfx

@TkzDev
Copy link

TkzDev commented Sep 28, 2024

The cheater is taking down all players, do you have a fix date for it to go into production? @prikolium-cfx

@slashkeyvalue
Copy link
Contributor Author

slashkeyvalue commented Oct 2, 2024

In case testing code is desired;

static uintptr_t g_writerVtbl;

static void (*origCPickupCreationDataNode__Serialise)(void* self, void* serialiser);
static void CPickupCreationDataNode__Serialise(void* self, void* serialiser)
{
	bool isWriter = *(uintptr_t*)serialiser == g_writerVtbl;

	if (isWriter)
	{
		*(uint32_t*)((uintptr_t)self + 0x128) = 0xFFFFFFFF; 
		*(uint32_t*)((uintptr_t)self + 0x158) = 0x0000000C;
	}

	origCPickupCreationDataNode__Serialise(self, serialiser);
}

static HookFunction hookFunction([]
{
	g_writerVtbl = hook::get_address<uintptr_t>(hook::get_pattern("4C 8B 10 48 8B C8 41 FF 52 ? 48 8B 4B 08", 0x11));

	origCPickupCreationDataNode__Serialise = hook::trampoline(hook::get_pattern("40 55 53 56 57 41 54 41 56 41 57 48 8B EC 48 83 EC ? 48 8B 02 4C 8D B1"), &CPickupCreationDataNode__Serialise);
});

@prikolium-cfx prikolium-cfx merged commit a737e50 into citizenfx:master Oct 3, 2024
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge This PR is enqueued for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants