Writing reparse points

I am trying to write I believe the most basic type of reparse point
program+filter: file symbolic links, but my program fails to set
(FSCTL_SET_REPARSE_POINT) the reparse point data in the file with the error
“the data on the buffer is invalid”. Do I have to do special handling on the

filter to allow the setting of the reparse point? What I am doing wrong? I
can send you the code if you want.

I was looking at the sysinternals sample to create junction points and
toying with it a little I arrived to the conclusiong that something has to
be done by the filter to allow the creation of the reparse point but I don’t

know what.

I am writting this reparse point thing from the info I gattered from this
mailing and the very little I got on the internet, but I don’t have a sample

reparse point program. Can you point me to one?

Thanks a lot.
Andres

Here is how I do it. I believe I had this working before the driver so it
should work for you also.

Note 1: tMyReparse is what ever data you want to store into the reparse
point
Note 2: tMyReparse must be less than 64k-16
Note 3: Guid is a unique guid. The docs aren’t clear on how it is set, but
I have been using it as a unique id per file, but its only for a non release
test driver. I believe it is suppose to be unique for this driver as a
double check that it is your data. Maybe someone else can clear that up.

// Older SDK’s had the wrong value specified for this ioctl, so lets
// define it correctly
#ifndef FILE_SPECIAL_ACCESS
#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS)
#undef FSCTL_SET_REPARSE_POINT
#define FSCTL_SET_REPARSE_POINT
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
// REPARSE_DATA_BUFFER,
#endif

int CreateReparse( PWCHAR LinkFile, GUID *Guid, pMyReparse Reparse )
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
HANDLE hFile = INVALID_HANDLE_VALUE;
DWORD
returnedLength=sizeof(tMyReparse)+REPARSE_GUID_DATA_BUFFER_HEADER_SIZE;
PREPARSE_GUID_DATA_BUFFER reparseInfo =
(PREPARSE_GUID_DATA_BUFFER)malloc(returnedLength);

// not sure if this is needed
EnablePrivilege ( SE_BACKUP_NAME );

hFile = CreateFileW( LinkFile, GENERIC_WRITE, 0,
NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL );
if( hFile == INVALID_HANDLE_VALUE ) {
DLOG((TEXT(“Error %08x creating\n”), GetLastError()));
return GetLastError();
}

// Build the reparse info
memset( reparseInfo, 0, sizeof( *reparseInfo ));
// test reparse point (low latency). Need to get real id from
// microsoft
reparseInfo->ReparseTag = 0x400000aaL;

ASSERT(IsReparseTagValid(reparseInfo->ReparseTag));
ASSERT(!IsReparseTagNameSurrogate(reparseInfo->ReparseTag));
ASSERT(!IsReparseTagMicrosoft(reparseInfo->ReparseTag));
ASSERT(returnedLength<65536);
ASSERT(returnedLength<maximum_reparse_data_buffer_size>
// copy passed in opaque data into structure
reparseInfo->ReparseDataLength = sizeof(tMyReparse);
memcpy(&reparseInfo->ReparseGuid,Guid,sizeof(GUID));

memcpy( reparseInfo->GenericReparseBuffer.DataBuffer,
Reparse,sizeof(tMyReparse) );

// Set the link
if( DeviceIoControl( hFile, FSCTL_SET_REPARSE_POINT,
reparseInfo,
returnedLength,
NULL, 0, &returnedLength, NULL )) {
// reparse point set, continue on
status = STATUS_SUCCESS;
} else {
status = GetLastError();
DLOG((TEXT(“Error %08x setting reparse:\n”), status));
}

CloseHandle (hFile);
return status;
}

Thanks,
Rob

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-178777-
> xxxxx@lists.osr.com] On Behalf Of Andrej Mlinar Groznik
> Sent: Saturday, June 19, 2004 5:35 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Writing reparse points
>
> I am trying to write I believe the most basic type of reparse point
> program+filter: file symbolic links, but my program fails to set
> (FSCTL_SET_REPARSE_POINT) the reparse point data in the file with the
> error
> “the data on the buffer is invalid”. Do I have to do special handling on
> the
>
> filter to allow the setting of the reparse point? What I am doing wrong? I
> can send you the code if you want.
>
> I was looking at the sysinternals sample to create junction points and
> toying with it a little I arrived to the conclusiong that something has to
> be done by the filter to allow the creation of the reparse point but I
> don’t
>
> know what.
>
> I am writting this reparse point thing from the info I gattered from this
> mailing and the very little I got on the internet, but I don’t have a
> sample
>
> reparse point program. Can you point me to one?
>
> Thanks a lot.
> Andres
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@cdp.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com</maximum_reparse_data_buffer_size>

Hi Rob,

does it mean you managed to set a reparse point on a file (not a directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

Here is how I do it. I believe I had this working before the driver so it
should work for you also.

Note 1: tMyReparse is what ever data you want to store into the reparse
point
Note 2: tMyReparse must be less than 64k-16
Note 3: Guid is a unique guid. The docs aren’t clear on how it is set,
but
I have been using it as a unique id per file, but its only for a non
release
test driver. I believe it is suppose to be unique for this driver as a
double check that it is your data. Maybe someone else can clear that up.

May the source be with you, stranger … :wink:

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an error
like it should. I haven’t tested the code with directories so I don’t know
how that will work. This is setting a custom reparse point, not a junction
point or mount point which are different.

Thanks,
Rob

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-178798-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmxpro.net
Sent: Sunday, June 20, 2004 4:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Hi Rob,

does it mean you managed to set a reparse point on a file (not a
directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

> Here is how I do it. I believe I had this working before the driver so
it
> should work for you also.
>
> Note 1: tMyReparse is what ever data you want to store into the reparse
> point
> Note 2: tMyReparse must be less than 64k-16
> Note 3: Guid is a unique guid. The docs aren’t clear on how it is set,
> but
> I have been using it as a unique id per file, but its only for a non
> release
> test driver. I believe it is suppose to be unique for this driver as a
> double check that it is your data. Maybe someone else can clear that
up.

May the source be with you, stranger … :wink:


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Okay, this clears thing up :slight_smile:

Thanks for the feedback.

Oliver

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an
error
like it should. I haven’t tested the code with directories so I don’t
know
how that will work. This is setting a custom reparse point, not a
junction
point or mount point which are different.

Thanks,
Rob

May the source be with you, stranger … :wink:

Thanks a lot for you answer. I didn’t help directly thou, but gave me enough
confidence to keep trying. After another day of tweaking this and that I
accidentally tried to pass to ioctl a buffer that is just as big as the
reported size of the structure (head + data)… then it worked!!! The buffer
size passed to the ioctl has to be exactly header + header->datasize or
otherwise you will get an invalid data error…

These things are (sadly) also part of the job :slight_smile:

Thanks again.
Andrej

-----Original Message-----
From: Rob Green [mailto:xxxxx@cdp.com]
Sent: Sunday, June 20, 2004 5:41 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an error
like it should. I haven’t tested the code with directories so I don’t know
how that will work. This is setting a custom reparse point, not a junction
point or mount point which are different.

Thanks,
Rob

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-178798-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmxpro.net
Sent: Sunday, June 20, 2004 4:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Hi Rob,

does it mean you managed to set a reparse point on a file (not a
directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

> Here is how I do it. I believe I had this working before the driver so
it
> should work for you also.
>
> Note 1: tMyReparse is what ever data you want to store into the reparse
> point
> Note 2: tMyReparse must be less than 64k-16
> Note 3: Guid is a unique guid. The docs aren’t clear on how it is set,
> but
> I have been using it as a unique id per file, but its only for a non
> release
> test driver. I believe it is suppose to be unique for this driver as a
> double check that it is your data. Maybe someone else can clear that
up.

May the source be with you, stranger … :wink:


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com

Andrej,

You should use the same GUID with all reparse points that have the same
TAG. You should use the “guidgen” tool (comes with the IFSKit) to
generate a GUID to use.

It is not necessary to have your filter installed to set a reparse
point.

It is probably failing because your reparse point is syntactically
wrong. Please post a hex dump (“dc” from debugger) of the actual
reparse point data you are trying to set, I should be able to see what
is wrong.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Andrej Mlinar
Groznik
Sent: Monday, June 21, 2004 4:06 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Thanks a lot for you answer. I didn’t help directly thou, but gave me
enough
confidence to keep trying. After another day of tweaking this and that I
accidentally tried to pass to ioctl a buffer that is just as big as the
reported size of the structure (head + data)… then it worked!!! The
buffer
size passed to the ioctl has to be exactly header + header->datasize or
otherwise you will get an invalid data error…

These things are (sadly) also part of the job :slight_smile:

Thanks again.
Andrej

-----Original Message-----
From: Rob Green [mailto:xxxxx@cdp.com]
Sent: Sunday, June 20, 2004 5:41 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an
error
like it should. I haven’t tested the code with directories so I don’t
know
how that will work. This is setting a custom reparse point, not a
junction
point or mount point which are different.

Thanks,
Rob

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-178798-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmxpro.net
Sent: Sunday, June 20, 2004 4:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Hi Rob,

does it mean you managed to set a reparse point on a file (not a
directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

> Here is how I do it. I believe I had this working before the driver
so
it
> should work for you also.
>
> Note 1: tMyReparse is what ever data you want to store into the
reparse
> point
> Note 2: tMyReparse must be less than 64k-16
> Note 3: Guid is a unique guid. The docs aren’t clear on how it is
set,
> but
> I have been using it as a unique id per file, but its only for a non
> release
> test driver. I believe it is suppose to be unique for this driver
as a
> double check that it is your data. Maybe someone else can clear
that
up.

May the source be with you, stranger … :wink:


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks for your answer. I already solved the problem with
FSCTL_SET_REPARSE_POINT.

I was telling to DeviceIoControl that I was passing a buffer of size x+y
when inside the structure the data described the size as x.

The size you pass to ioctl has to be exactly
REPARSE_GUID_DATA_BUFFER_HEADER_SIZE + pReparseDataBuffer->ReparseDataLength
(not more, not less) otherwise it will complain.

I was passing a bigger buffer to play it safe but it unexpectedly backfired.

About the GUID: I was using a different GUID for each file. The
documentation is misleading about this. I will sort things out in my code.

Thanks again,
Andrej

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, June 21, 2004 7:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Andrej,

You should use the same GUID with all reparse points that have the same
TAG. You should use the “guidgen” tool (comes with the IFSKit) to
generate a GUID to use.

It is not necessary to have your filter installed to set a reparse
point.

It is probably failing because your reparse point is syntactically
wrong. Please post a hex dump (“dc” from debugger) of the actual
reparse point data you are trying to set, I should be able to see what
is wrong.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Andrej Mlinar
Groznik
Sent: Monday, June 21, 2004 4:06 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Thanks a lot for you answer. I didn’t help directly thou, but gave me
enough
confidence to keep trying. After another day of tweaking this and that I
accidentally tried to pass to ioctl a buffer that is just as big as the
reported size of the structure (head + data)… then it worked!!! The
buffer
size passed to the ioctl has to be exactly header + header->datasize or
otherwise you will get an invalid data error…

These things are (sadly) also part of the job :slight_smile:

Thanks again.
Andrej

-----Original Message-----
From: Rob Green [mailto:xxxxx@cdp.com]
Sent: Sunday, June 20, 2004 5:41 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an
error
like it should. I haven’t tested the code with directories so I don’t
know
how that will work. This is setting a custom reparse point, not a
junction
point or mount point which are different.

Thanks,
Rob

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-178798-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmxpro.net
Sent: Sunday, June 20, 2004 4:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Hi Rob,

does it mean you managed to set a reparse point on a file (not a
directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

> Here is how I do it. I believe I had this working before the driver
so
it
> should work for you also.
>
> Note 1: tMyReparse is what ever data you want to store into the
reparse
> point
> Note 2: tMyReparse must be less than 64k-16
> Note 3: Guid is a unique guid. The docs aren’t clear on how it is
set,
> but
> I have been using it as a unique id per file, but its only for a non
> release
> test driver. I believe it is suppose to be unique for this driver
as a
> double check that it is your data. Maybe someone else can clear
that
up.

May the source be with you, stranger … :wink:


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com

Andrej,

I am glad you got your problem solved.

It is imperative that you have one GUID per TAG. The idea of the GUID
was to give Microsoft the flexibility to assign duplicate tags in the
future but still allow a filter to uniquely identify their own reparse
points via the GUID.

All filters using their own reparse point should match both the TAG and
the GUID.

I have filed a bug to have the documentation clarified on this issue.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Andrej Mlinar
Groznik
Sent: Monday, June 21, 2004 10:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Thanks for your answer. I already solved the problem with
FSCTL_SET_REPARSE_POINT.

I was telling to DeviceIoControl that I was passing a buffer of size x+y
when inside the structure the data described the size as x.

The size you pass to ioctl has to be exactly
REPARSE_GUID_DATA_BUFFER_HEADER_SIZE +
pReparseDataBuffer->ReparseDataLength
(not more, not less) otherwise it will complain.

I was passing a bigger buffer to play it safe but it unexpectedly
backfired.

About the GUID: I was using a different GUID for each file. The
documentation is misleading about this. I will sort things out in my
code.

Thanks again,
Andrej

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Monday, June 21, 2004 7:53 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Andrej,

You should use the same GUID with all reparse points that have the same
TAG. You should use the “guidgen” tool (comes with the IFSKit) to
generate a GUID to use.

It is not necessary to have your filter installed to set a reparse
point.

It is probably failing because your reparse point is syntactically
wrong. Please post a hex dump (“dc” from debugger) of the actual
reparse point data you are trying to set, I should be able to see what
is wrong.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Andrej Mlinar
Groznik
Sent: Monday, June 21, 2004 4:06 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Thanks a lot for you answer. I didn’t help directly thou, but gave me
enough
confidence to keep trying. After another day of tweaking this and that I
accidentally tried to pass to ioctl a buffer that is just as big as the
reported size of the structure (head + data)… then it worked!!! The
buffer
size passed to the ioctl has to be exactly header + header->datasize or
otherwise you will get an invalid data error…

These things are (sadly) also part of the job :slight_smile:

Thanks again.
Andrej

-----Original Message-----
From: Rob Green [mailto:xxxxx@cdp.com]
Sent: Sunday, June 20, 2004 5:41 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Yes. I just verified the posted code created stubs on a machine that
doesn’t have my driver installed. Accessing the stub does generate an
error
like it should. I haven’t tested the code with directories so I don’t
know
how that will work. This is setting a custom reparse point, not a
junction
point or mount point which are different.

Thanks,
Rob

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-178798-
xxxxx@lists.osr.com] On Behalf Of xxxxx@gmxpro.net
Sent: Sunday, June 20, 2004 4:58 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Writing reparse points

Hi Rob,

does it mean you managed to set a reparse point on a file (not a
directoy!)
and it worked? I tried this for months and could not get it work.

Cheers,
Oliver

> Here is how I do it. I believe I had this working before the driver
so
it
> should work for you also.
>
> Note 1: tMyReparse is what ever data you want to store into the
reparse
> point
> Note 2: tMyReparse must be less than 64k-16
> Note 3: Guid is a unique guid. The docs aren’t clear on how it is
set,
> but
> I have been using it as a unique id per file, but its only for a non
> release
> test driver. I believe it is suppose to be unique for this driver
as a
> double check that it is your data. Maybe someone else can clear
that
up.

May the source be with you, stranger … :wink:


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@cdp.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as:
xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com