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(rage-device/five): Error out on cloud files #1234

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

4mmonium
Copy link

The issue:
The application seems to get stuck in a loop when cloud files are
accessed, this is caused by users installing their GTA on the cloud,
causing the game to neither load, nor 'gracefully' exit.

The solution:
To correct this, we simply get the file attributes and check if
the following flag is set: FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS. If
it's set, we return an invalid handle, so it's passed down the stack.
Once this errors, FatalError under OpenArchiveWrap will be
triggered. I have modified the message so any affected clients are
notified in the event this occurs.

The issue:
The application seems to get stuck in a loop when cloud files are
accessed, this is caused by users installing their GTA on the cloud,
causing the game to neither load, nor 'gracefully' exit.

The solution:
To correct this, we simply get the file attributes and check if
the following flag is set: `FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS`. If
it's set, we return an invalid handle, so it's passed down the stack.
Once this errors, `FatalError` under `OpenArchiveWrap` will be
triggered. I have modified the message so any affected clients are
notified in the event this occurs.
Copy link
Contributor

@jakub-cfx jakub-cfx left a comment

Choose a reason for hiding this comment

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

Left a small suggestion + a question about skipping hook usage, looking good otherwise 👍

@@ -40,6 +40,14 @@ static decltype(&CreateFileW) createFileW;

static HANDLE WINAPI CreateFileWDummy(_In_ LPCWSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes, _In_opt_ HANDLE hTemplateFile)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think CreateFileWDummy could use a rename to something that reflects its new purpose (e.g. CreateFileWNoRecallFlag) now that it's no longer just a simple/dummy forwarder of the call

@@ -48,8 +56,6 @@ static void ResetPackfile(const char* archive)
// if this is update.rpf, maybe we should do something about that?
if (strcmp(archive, "update/update.rpf") == 0)
{
createFileW = hook::iat("kernel32.dll", CreateFileWDummy, "CreateFileW");

HANDLE hFile = createFileW(L"update/update.rpf", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to double check, is calling the original CreateFileW intended here or should that also be piped through the hook?

Copy link
Contributor

@jakub-cfx jakub-cfx left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, PR description matches the changes perfectly.

@jakub-cfx jakub-cfx added the ready-to-merge This PR is enqueued for merging label Jul 29, 2024
@prikolium-cfx prikolium-cfx merged commit 6cb0ca4 into citizenfx:master Jul 29, 2024
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.

3 participants