Skip to content

Instantly share code, notes, and snippets.

@0xbadfca11
Created February 20, 2025 14:09
Show Gist options
  • Save 0xbadfca11/7c092b81dfda6db977a4139dcc44c16a to your computer and use it in GitHub Desktop.
Save 0xbadfca11/7c092b81dfda6db977a4139dcc44c16a to your computer and use it in GitHub Desktop.
Windows ReFS bug

Summary

FSCTL_QUERY_FILE_REGIONS stuck on sparse file on ReFS(v2) with 64KB cluster size.

Affect

  • Windows Server 2025 (26100.3194)

Not affect

How to stuck

Do Format E: /FS:ReFS /A:64K /Q.
Run below code.

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winioctl.h>
int main()
{
HANDLE h = CreateFileW(LR"(E:\test.dat)", GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr);
ULONG _;
DeviceIoControl(h, FSCTL_SET_SPARSE, nullptr, 0, nullptr, 0, &_, nullptr);
FILE_END_OF_FILE_INFO eof = { {.QuadPart = 16LL * 1024 * 1024 * 1024 } };
SetFileInformationByHandle(h, FileEndOfFileInfo, &eof, sizeof eof);
FILE_REGION_OUTPUT file_region_output;
DeviceIoControl(h, FSCTL_QUERY_FILE_REGIONS, nullptr, 0, &file_region_output, sizeof file_region_output, &_, nullptr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment