-
I want to expose a directory entry in my virtual filesystem as a junction, with the value of the junction being something like I've tried passing both the Unicode bytes back as the using (var memory = new MemoryStream())
{
var target = junctions[fileName];
var targetByteLength = (ushort)(target.Length * 2);
memory.Write(BitConverter.GetBytes((uint)2684354563U));
memory.Write(BitConverter.GetBytes((ushort)(targetByteLength + 12)));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(BitConverter.GetBytes((ushort)targetByteLength));
memory.Write(BitConverter.GetBytes((ushort)(targetByteLength + 2)));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(Encoding.Unicode.GetBytes(target));
memory.Write(new byte[] { 0, 0 });
reparseData = memory.ToArray();
return STATUS_SUCCESS;
} For reference,
The value What data should I be putting into |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It turns out the resulting data was missing a few null bytes at the end. The following code works to return junctions: public override int GetReparsePointByName(string fileName, bool isDirectory, ref byte[] reparseData)
{
var junctions = _additionalJunctions;
if (junctions.ContainsKey(fileName))
{
var target = junctions[fileName];
var targetByteLength = (ushort)(target.Length * 2);
using (var memory = new MemoryStream())
{
memory.Write(BitConverter.GetBytes((uint)2684354563U));
memory.Write(BitConverter.GetBytes((ushort)(targetByteLength + 12)));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(BitConverter.GetBytes((ushort)targetByteLength));
memory.Write(BitConverter.GetBytes((ushort)(targetByteLength + 2)));
memory.Write(BitConverter.GetBytes((ushort)0));
memory.Write(Encoding.Unicode.GetBytes(target));
memory.Write(new byte[] { 0, 0 });
memory.Write(new byte[] { 0, 0 });
reparseData = memory.ToArray();
}
return STATUS_SUCCESS;
}
else
{
return STATUS_IO_DEVICE_ERROR;
}
} |
Beta Was this translation helpful? Give feedback.
It turns out the resulting data was missing a few null bytes at the end. The following code works to return junctions: