[Win32utils-devel] Dir.create_junction with FFI
djberg96 at gmail.com
Fri May 18 06:06:31 UTC 2012
On Thu, May 17, 2012 at 9:44 PM, Heesob Park <phasis at gmail.com> wrote:
> 2012/5/18 Daniel Berger <djberg96 at gmail.com>
>> 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
>> 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
> :ReparseTag, :ulong,
> :ReparseDataLength, :ushort,
> :Reserved, :ushort,
> :SubstituteNameOffset, :ushort,
> :SubstituteNameLength, :ushort,
> :PrintNameOffset, :ushort,
> :PrintNameLength, :ushort,
> :PathBuffer, [:char, 1024]
> # 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?
More information about the win32utils-devel