[Win32utils-devel] Dir.create_junction with FFI
phasis at gmail.com
Fri May 18 07:35:02 UTC 2012
2012/5/18 Daniel Berger <djberg96 at gmail.com>
> On Thu, May 17, 2012 at 9:44 PM, Heesob Park <phasis at gmail.com> wrote:
> > Hi,
> > 2012/5/18 Daniel Berger <djberg96 at gmail.com>
> >> Hi,
> >> Try as I might, I just cannot get Dir.create_junction to work with FFI
> >> in the ffi branch of the win32-dir project. The problem is the
> >> REPARSE_JDATA_BUFFER struct. I'm just not sure how to set those
> >> members, specifically, the PathBuffer member. The target looks good,
> >> it's UTF-16LE encoded, but I can't make it work, despite trying
> >> several ways of defining the struct, and setting various struct
> >> members.
> >> A quick gist for reference: https://gist.github.com/2721257
> >> Help much appreciated!
> > The REPARSE_JDATA_BUFFER is a kind of the variable length structure.
> > The actual size of structure is determined by ReparseDataLength member.
> > Here is my trial.
> > # define sufficient size of structure.
> > class REPARSE_JDATA_BUFFER < FFI::Struct
> > layout(
> > :ReparseTag, :ulong,
> > :ReparseDataLength, :ushort,
> > :Reserved, :ushort,
> > :SubstituteNameOffset, :ushort,
> > :SubstituteNameLength, :ushort,
> > :PrintNameOffset, :ushort,
> > :PrintNameLength, :ushort,
> > :PathBuffer, [:char, 1024]
> > )
> > end
> > # UTF-16LE encoded string
> > target = "\\??\\".encode('UTF-16LE') + from_path
> > rdb = REPARSE_JDATA_BUFFER.new
> > rdb[:ReparseTag] = 2684354563 # IO_REPARSE_TAG_MOUNT_POINT
> > rdb[:ReparseDataLength] = target.bytesize + 12
> > rdb[:Reserved] = 0
> > rdb[:SubstituteNameOffset] = 0
> > rdb[:SubstituteNameLength] = target.bytesize
> > rdb[:PrintNameOffset] = target.bytesize + 2
> > rdb[:PrintNameLength] = 0
> > rdb[:PathBuffer] = target
> I tried that, but I still got: DeviceIoControl: The data present in
> the reparse point buffer is invalid.
> Did it work for you?
Here is a working code.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the win32utils-devel