problem with a reparse point

Hi,

I'm getting crazy with this.

To create a reparse point I need to feel this structure according to the doc:

[StructLayout(LayoutKind.Sequential,Pack=4)]
public struct REPARSE_DATA_BUFFER
{
public uint ReparseTag;
public short ReparseDataLength;
public short Reserved;

public short SubstituteNameOffset;
public short SubstituteNameLength; // how many bytes the PathBuffer contains
public short PrintNameOffset;
public short PrintNameLength;
[MarshalAs(UnmanagedType.LPWStr)]
public string PathBuffer;
}

I marshall it withMarshal.StructureToPtr() into a buffer I pass to DeviceIoControl like this:
IntPtr pointer = Marshal.AllocHGlobal(16*1024);
Marshal.StructureToPtr(<my structure>,pointer,true);

For now I only get 4392 error. That means "The data present in the reparse point buffer is invalid"

OK, but where I can find informations about the REPARSE_DATA_BUFFER. I made exactely what Mike Nordell did there in C++:http://www.codeproject.com/w2k/junctionpoints.asp

But it does not work at all in my C# code.

This is the snipped I'm using:

DestDir = @"\\?\" + DestDir;
short DestDirSize = (short) (2 * DestDir.Length);
rdb = new REPARSE_DATA_BUFFER();
rdb.PathBuffer = DestDir;
rdb.ReparseDataLength = (short) (DestDirSize + 12);
rdb.ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
rdb.SubstituteNameLength = (short) (DestDirSize);
rdb.PrintNameOffset = (short) (DestDirSize + 2);

I don't know what is wrong, but where can I find the meaning of the REPARSE_DATA_BUFFER buffer fields?

thank you


[2006 byte] By [Frdo] at [2008-2-20]
# 1
I don't have personal experience with reparse point usage in Win32. From a cursory review of those APIs.
However, I can recommend setting up the CLRSpy (Customer Debug Probes) to determine if you have a marshalling issue with the structure.
You can find more info on Adam Nathan's Interop blog (Adam is a long-time member of the CLR interop team).

If you discover it is a marshalling issue, please feel free to update the PInvoke.Net C# declaration for REPARSE_DATA_BUFFER.

Please feel free to post back on this forum if you have more technical details of the problem, or you've discovered a solution!

Thanks,
Stephen
http://blogs.msdn.com/stfisher

StephenFisher-MS at 2007-9-9 > top of Msdn Tech,.NET Development,Common Language Runtime...
# 2

Hello again, Fredo,

I poked around MSDN some more and found some relevant information.
The MSDN documentation says that the REPARSE_DATA_BUFFER structure is only for "Microsoft" reparse data types. Non-Microsoft developers should use the REPARSE_GUID_DATA_BUFFER. I woud assume [although I'm not authoratitive on this particular point] that REPARSE_DATA_BUFFER was removed so that external drivers don’t mess with the reserved reparse data types.

Here's the MSDN link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/fs/fsctl_get_reparse_point.asp

Thanks,
Stephen

http://blogs.msdn.com/stfisher

StephenFisher-MS at 2007-9-9 > top of Msdn Tech,.NET Development,Common Language Runtime...

.NET Development

Site Classified