Created
May 17, 2012 20:00
-
-
Save djberg96/2721257 to your computer and use it in GitHub Desktop.
REPARSE_JDATA_BUFFER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The "old" way | |
buf_target = "\\??\\" << from_path | |
wide_string = multi_to_wide(buf_target)[0..-3] | |
# REPARSE_JDATA_BUFFER | |
rdb = [ | |
"0xA0000003L".hex, # ReparseTag (IO_REPARSE_TAG_MOUNT_POINT) | |
wide_string.size + 12, # ReparseDataLength | |
0, # Reserved | |
0, # SubstituteNameOffset | |
wide_string.size, # SubstituteNameLength | |
wide_string.size + 2, # PrintNameOffset | |
0, # PrintNameLength | |
wide_string # PathBuffer | |
].pack('LSSSSSSa' + (wide_string.size + 4).to_s) | |
# FFI attempt | |
class REPARSE_JDATA_BUFFER < FFI::Struct | |
layout( | |
:ReparseTag, :ulong, | |
:ReparseDataLength, :ushort, | |
:Reserved, :ushort, | |
:SubstituteNameOffset, :ushort, | |
:SubstituteNameLength, :ushort, | |
:PrintNameOffset, :ushort, | |
:PrintNameLength, :ushort, | |
:PathBuffer, [:char, 2] | |
) | |
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.size + 12 | |
rdb[:Reserved] = 0 | |
rdb[:SubstituteNameOffset] = 0 | |
rdb[:SubstituteNameLength] = target.size | |
rdb[:PrintNameOffset] = target.size + 2 | |
rdb[:PrintNameLength] = 0 | |
rdb[:PathBuffer] # ??? How do I assign "target" here? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment