Hey,
I’m trying to create a reparse point from userspace with arbitrary data, via DeviceIoControl and FSCTL_SET_REPARSE_POINT. The following code always returns ERROR_INVALID_REPARSE_DATA, no matter what I store in the reparse point. As far as I can see, there aren’t any limitations on what kind of data user-defined reparse points can or cannot store… so the error message doesn’t seem logical. Any thoughts on what might be causing this error, or how to diagnose/fix it? Thanks!
Dustin
HANDLE hFile;
DWORD ret = 0, written = 0, err = 0;
REPARSE_GUID_DATA_BUFFER \* reparse;
hFile = CreateFile(
_T("c:\\test2\\test2.txt"),
GENERIC_READ | GENERIC_WRITE ,
0,
0,
OPEN_EXISTING,
FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS,
0);
if (hFile == INVALID_HANDLE_VALUE){
err = GetLastError();
printf("Error %d\n", GetLastError());
}else{
reparse = (REPARSE_GUID_DATA_BUFFER\*)malloc(sizeof(REPARSE_GUID_DATA_BUFFER) + 8);
memset(reparse, 0, sizeof(REPARSE_GUID_DATA_BUFFER) + 8);
reparse-\>ReparseGuid = my_guid;
// some arbitrary tag (only for testing at the moment)
reparse-\>ReparseTag = 0x15;
reparse-\>ReparseDataLength = 8;
// just some meaningless data here
reparse-\>GenericReparseBuffer.DataBuffer[0] = 8;
reparse-\>GenericReparseBuffer.DataBuffer[1] = 0x83;
if (!DeviceIoControl(hFile,
FSCTL_SET_REPARSE_POINT,
reparse ,
sizeof(REPARSE_GUID_DATA_BUFFER) + reparse-\>ReparseDataLength ,
NULL,
0,
&ret,
0)){
err = GetLastError();
printf("DeviceIoControl Error: %d\n", err);
}
free(reparse);
CloseHandle(hFile);
}