Skip to content

Instantly share code, notes, and snippets.

@0xbadfca11
Last active February 13, 2025 10:36
Show Gist options
  • Save 0xbadfca11/4ababeff1e3eaa2bb7dcb95b0a89b8ee to your computer and use it in GitHub Desktop.
Save 0xbadfca11/4ababeff1e3eaa2bb7dcb95b0a89b8ee to your computer and use it in GitHub Desktop.
#define WIN32_LEAN_AND_MEAN
#define WIL_SUPPRESS_EXCEPTIONS
#include <windows.h>
#include <cstdio>
#include <cstdlib>
#include <wil/resource.h>
int wmain(int, PWSTR argv[])
{
wil::unique_hfile d(CreateFileW(argv[1], FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, nullptr));
if (!d)
{
fprintf(stderr, "CreateFile %08lx\n", GetLastError());
return EXIT_FAILURE;
}
FILE_CASE_SENSITIVE_INFORMATION file_cs = { FILE_CS_FLAG_CASE_SENSITIVE_DIR };
if (!SetFileInformationByHandle(d.get(), FileCaseSensitiveInfo, &file_cs, sizeof file_cs))
{
fprintf(stderr, "SetFileInformationByHandle %08lx\n", GetLastError());
return EXIT_FAILURE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment