hello, there seems to be something wrong with this, target always seems to be prepended with some data like ?\\? before the expected string (e.g. C:\Users\...) starts.
the printname_len is accurate in that is represents the raw (byte) length of the string excluding this starting ?\\? is there an offset bug here? thanks. phil Roger Upole wrote: > > The only way I know of is to call win32file.DeviceIoControl > with FSCTL_GET_REPARSE_POINT, and unpack the > buffer yourself. > > Roger > > > import win32con, winioctlcon, winnt, win32file > import struct > > def get_reparse_target(fname): > h = win32file.CreateFile(fname, 0, > > win32con.FILE_SHARE_READ|win32con.FILE_SHARE_WRITE|win32con.FILE_SHARE_DELETE, > None, > win32con.OPEN_EXISTING, > > win32file.FILE_FLAG_OVERLAPPED|win32file.FILE_FLAG_OPEN_REPARSE_POINT|win32file.FILE_FLAG_BACKUP_SEMANTICS, > 0) > > > output_buf=win32file.AllocateReadBuffer(winnt.MAXIMUM_REPARSE_DATA_BUFFER_SIZE) > buf=win32file.DeviceIoControl(h, > winioctlcon.FSCTL_GET_REPARSE_POINT,None, > OutBuffer=output_buf, Overlapped=None) > fixed_fmt='LHHHHHH' > fixed_len=struct.calcsize(fixed_fmt) > tag, datalen, reserved, target_offset, target_len, printname_offset, > printname_len = \ > struct.unpack(fixed_fmt, buf[:fixed_len]) > > ## variable size target data follows the fixed portion of the buffer > name_buf=buf[fixed_len:] > > target_buf=name_buf[target_offset:target_offset+target_len] > target=target_buf.decode('utf-16-le') > return target > > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > -- View this message in context: http://old.nabble.com/Question-on-parsing-Reparse-Points-tp22610814p29868667.html Sent from the Python - python-win32 mailing list archive at Nabble.com. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32