Code: Select all
; purebasic survival guide - pb3.90 sp1
; streams_1.pb - 18.05.2004 ejn (blueznl)
; http://www.xs4all.nl/~bluez/datatalk/purebasic.htm
;
; - NOT FOR BEGINNERS !!!
; - only on nt / win2k / xp using ntfs
; - backupread_()
; - open and read locked files
; - enumerate nt streams in files
; - needs double support to work on large files (> 2 gb)
;
filename.s = "c:\test.txt"
file_h = CreateFile_(@filename, #READ_CONTROL, 0, 0, #OPEN_EXISTING, #FILE_FLAG_BACKUP_SEMANTICS, 0)
;
Debug "start"
;
If file_h = 0
Debug "can't open"
End
EndIf
;
*buffer = AllocateMemory(4096)
*stream.WIN32_STREAM_ID = *buffer
;
context.l = 0
bytes_read.l = 0
;
Repeat
;
z = BackupRead_(file_h, *buffer, 20, @bytes_read, 0, 1, @context)
;
; dunno why, but backupread() sometimes returns 1 when it should be zero?!? so check for the nr. of bytes as well
;
If bytes_read = 0
z = 0
EndIf
;
If z <> 0
;
n+1
Debug ""
Debug "stream "+Str(n)
id = *stream\dwStreamID
Debug "stream id "+Str( id )
Select id
Case #BACKUP_DATA
Debug "data"
Case #BACKUP_EA_DATA
Debug "extended attribute"
Case #BACKUP_SECURITY_DATA
Debug "security data"
Case #BACKUP_ALTERNATE_DATA
Debug "alternate data"
Case #BACKUP_LINK
Debug "hard link information"
Default
Debug "unknown id type"
z=0
EndSelect
;
If z <> 0
;
Debug "stream attributes %"+Bin( *stream\dwStreamAttributes )
;
size.l = *stream\dwStreamSizeLow + *stream\dwStreamSizeHigh *256*256*256*256
namesize.l = *stream\dwStreamNameSize
;
Debug "stream size "+Str(size)
Debug "name size "+Str(namesize)
;
If namesize > 0
BackupRead_(file_h, *buffer, namesize, @bytes_read, 0, 1, @context)
l = WideCharToMultiByte_(#CP_OEMCP,0,*buffer,-1,0,0,0,0)
name.s = Space(l)
l = WideCharToMultiByte_(#CP_OEMCP,0,*buffer,-1,@name,l,0,0)
Debug "name... "+Str(bytes_read)+" "+name
EndIf
If size > 0
seeked_l.l = 0
seeked_h.l = 0
BackupSeek_(file_h, size, 0, @seeked_l.l, @seeked_h.l, @context)
Debug "data..."+Str(seeked_l + seeked_h *256*256*256*256)
EndIf
EndIf
EndIf
Until z = 0
;
BackupRead_(file_h, *buffer,0,@bytes_read,1,0,@context)
CloseHandle_(file_h)
;
Debug ""
Debug "done"