6 win32_error_string(DWORD err_code)
8 static wchar_t buf[1024];
10 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err_code, 0,
16 fail(const char *func, DWORD code)
18 fprintf(stderr, "%s (err 0x%08x: %ls)\n", func,
19 (unsigned int)code, win32_error_string(code));
24 wmain(int argc, wchar_t **argv)
27 fprintf(stderr, "Usage: %ls FILE\n", argv[0]);
31 HANDLE h = CreateFile(argv[1],
33 FILE_SHARE_VALID_FLAGS,
36 FILE_FLAG_BACKUP_SEMANTICS,
38 if (h == INVALID_HANDLE_VALUE)
39 fail("CreateFile", GetLastError());
43 *(uint32_t *)p = 0x80000000; /* rptag */
45 *(uint16_t *)p = 80; /* rpdatalen */
47 *(uint16_t *)p = 0; /* rpreserved */
49 memset(p, 0, 80); /* rpdata */
54 if (!DeviceIoControl(h, FSCTL_SET_REPARSE_POINT, in, p - in,
55 NULL, 0, &bytes_returned, NULL))
56 fail("DeviceIoControl", GetLastError());