Skip to content

Conversation

Ryzee119
Copy link
Contributor

@Ryzee119 Ryzee119 commented Sep 9, 2025

Add support for GetFileInformationByHandle() and SetFileInformationByHandle()

There is a GetFileInformationByHandleEx() function but this is not a simple wrapper and does alot more. This would be implemented as a separate function.

SetFileInformationByHandle() is particularly useful to set the end of file attribute for unbuffered overlapped file io because SetFilePointer()/SetEndOfFile() does not work in this scenario.

Fixes #472

lpFileInformation->nFileIndexLow = internal.IndexNumber.LowPart;

// For the FAT file system this member is always 1
lpFileInformation->nNumberOfLinks = 1;
Copy link
Member

Choose a reason for hiding this comment

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

nit: Xbox supports more than FAT,, so ideally this would return the right value - although I'm not sure if it's really relevant in practice for the foreseeable future.
Not sure if supported on Xbox, but react apparently uses this: https://stackoverflow.com/a/62889035

Copy link
Contributor Author

@Ryzee119 Ryzee119 Sep 9, 2025

Choose a reason for hiding this comment

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

I did try this and could not get it to work. It would just return error code 87 (ERROR_INVALID_PARAMETER) but would work when compiling on my local windows machine.

Basically using the below in that function:

FILE_STANDARD_INFORMATION file;
status = NtQueryInformationFile(hFile, &ioStatusBlock, &file, sizeof(file), FileStandardInformation);
if (!NT_SUCCESS(status)) {
    SetLastError(RtlNtStatusToDosError(status));
    return FALSE;
}

So probably not supported? Although it is defined in our xboxkrnl.h

From what I can see, XDK hardcodes this value to zero.

Copy link
Member

Choose a reason for hiding this comment

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

It's possible the included drivers don't support it. We could set it to 1 if the query fails, but I'm also open to merging as-is.

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

Successfully merging this pull request may close these issues.

GetFileInformationByHandle is missing
3 participants