Subversion Repositories recyclebinunit

Rev

Rev 104 | Rev 106 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 daniel-mar 1
 
2
# Windows Recycle Bin internal format
3
 
104 daniel-mar 4
## Locations of the index files
98 daniel-mar 5
 
6
### FAT drives:
7
 
99 daniel-mar 8
- Windows 95 native:	`C:\RECYCLED\INFO` (with ANSI records, folder deletion is NOT possible, format `00 00 00 00`)
9
- Windows 95+IE4, 98SE:	`C:\RECYCLED\INFO2` (with ANSI records, folder deletion is possible, format `04 00 00 00`)
10
- Windows Me:		`C:\RECYCLED\INFO2` (with ANSI records, folder deletion is possible, format `05 00 00 00`)
11
- Windows Vista+:	`C:\$RECYCLE.BIN\$I...`
104 daniel-mar 12
- Windows 95 (Beta 58s)	`C:\CHICAGO\DESKTOP\RECYCLE.BIN` (a normal folder with the deleted files. There are no index files and deleted files won't get renamed). In beta build 122, the recycle bin was removed and re-added in beta build 180 with the INFO-format we know from the RTM release.
98 daniel-mar 13
 
14
### NTFS drives:
15
 
99 daniel-mar 16
- Windows NT4:		`C:\RECYCLER\<UserSID>\INFO` (with Unicode records, folder deletion is possible, format `02 00 00 00`)
17
- Windows 2000, XP:	`C:\RECYCLER\<UserSID>\INFO2` (with Unicode records, folder deletion is possible, format `05 00 00 00`)
18
- Windows Vista+:	`C:\$RECYCLE.BIN\<UserSID>\$I...`
98 daniel-mar 19
 
20
## INFO and INFO2 files
21
 
22
INFO is written by Win95 without IE4 (with ANSI records), and WinNT4 (with Unicode records).
23
 
24
INFO2 is written by Win95 with Internet Explorer 4 shell extensions, Win98, WinMe (with ANSI records), Win2000, and WinXP (with Unicode records).
25
 
99 daniel-mar 26
Since some Windows version combinations mix up ANSI records and Unicode records (e.g. Win95+IE4 and Win2000), these Windows versions break the recycle bin information file of each other.
98 daniel-mar 27
 
101 daniel-mar 28
INFO and INFO2 is the index file containing all information about the deleted files. The data files are renamed to `Dxyyy.ext` (`x` replaced with the drive letter, `yyy` being a dynamic length integer, `ext` being replaced with the file name extension).
98 daniel-mar 29
 
30
### Header
31
 
101 daniel-mar 32
| offset (hex) | size (dec) |  type | description |
33
|--------------|------------|-------|-------------|
34
| 0000         | 4          | DWORD | Version of the info file<br>`00 00 00 00` = Win95 (without IE4)<br>`02 00 00 00` = Win NT4 (Win96/Cairo?)<br>`04 00 00 00` = Win95 (with IE4), Win98<br>`05 00 00 00` = Win Me, 2000, WinXP (NT4+IE4, NT5?) | 
35
| 0004         | 4          | DWORD | Total entries. Only Win95 (without IE4) and Win NT4, other OS versions will use the registry instead and might write information on WM_ENDSESSION for compatibility reasons. | 
36
| 0008         | 4          | DWORD | Next possible ID. Only Win95 (without IE4) and Win NT4, other OS versions will use the registry instead and might write information on WM_ENDSESSION for compatibility reasons. | 
37
| 000C         | 4          | DWORD | Item record length<br>0x118 = ANSI records<br>0x320 = Unicode records | 
38
| 0010         | 4          | DWORD | Total size (sum of all original sizes of the files). Only Win95 (without IE4) and Win NT4, other OS versions will use the registry instead and might write information on WM_ENDSESSION for compatibility reasons. | 
98 daniel-mar 39
 
99 daniel-mar 40
### ANSI record (Win95, Win98, WinMe)
98 daniel-mar 41
 
104 daniel-mar 42
Windows 95:      INFO file with ANSI record; Folder deletion NOT possible
100 daniel-mar 43
 
101 daniel-mar 44
Windows 95 +IE4: INFO2 file with ANSI record; Folder deletion possible
98 daniel-mar 45
 
101 daniel-mar 46
| offset (hex) | size (dec) |  type           | description |
47
|--------------|------------|-----------------|-------------|
48
| 0000         | 260        | char[MAX_PATH]  | Original file name and path in ANSI characters. 260 characters (including NUL terminator). Empty string if file was deleted. | 
49
| 0104         | 4          | DWORD           | Record number | 
103 daniel-mar 50
| 0108         | 4          | DWORD           | Source drive number<br>0=A, 1=B, 2=C, ..., 25=Z<br>26=@ (this is the "Network home drive" of the Win95 days) | 
101 daniel-mar 51
| 010C         | 8          | FILETIME        | Deletion time | 
104 daniel-mar 52
| 0114         | 4          | DWORD           | Original file size, rounded to the next cluster (see note below).<br>INFO2, for folders: The whole folder size with contents | 
101 daniel-mar 53
 
99 daniel-mar 54
### Unicode record (WinNT4, Win2000, WinXP)
98 daniel-mar 55
 
104 daniel-mar 56
Windows NT4:   INFO file with Unicode record; Folder deletion possible
100 daniel-mar 57
 
101 daniel-mar 58
Windows 2000+: INFO2 file with Unicode record; Folder deletion possible
98 daniel-mar 59
 
101 daniel-mar 60
| offset (hex) | size (dec) |  type           | description |
61
|--------------|------------|-----------------|-------------|
62
| 0000         | 260        | char[MAX_PATH]  | Original file name and path in ANSI characters. 260 characters (including NUL terminator). Empty string if file was deleted. | 
63
| 0104         | 4          | DWORD           | Record number | 
103 daniel-mar 64
| 0108         | 4          | DWORD           | Source drive number<br>0=A, 1=B, 2=C, ..., 25=Z<br>26=@ (this is the "Network home drive" of the Win95 days) | 
101 daniel-mar 65
| 010C         | 8          | FILETIME        | Deletion time | 
104 daniel-mar 66
| 0114         | 4          | DWORD           | Original file size, rounded to the next cluster (see note below) |
101 daniel-mar 67
| 0118         | 520        | wchar[MAX_PATH] | Original file name and path in Unicode characters. 260 characters (including NUL terminator) | 
68
 
104 daniel-mar 69
### Sizes
70
 
71
The original size is inteded to be rounded to the next cluster, so this should be the size on the disk, not the size of the actual file.
72
 
73
However, my test system (Win98, INFO2 record) showed a weird behavior:
74
Explorer shows "size used" as 4 KiB (e.g. 4096 bytes used, which is my file system cluster size),
75
but when the file was moved to the recycle bin, the INFO2 record stores 32 KiB.
76
The GUI displays the file as 1 KB (it must get that number from the data file, not from the index file).
77
 
105 daniel-mar 78
WinNT4 does it correctly, setting the size to 0x200 (512 Byte), which is the file system cluster size.
79
 
104 daniel-mar 80
### Deleted files
81
 
105 daniel-mar 82
For Windows 95 with IE4 integration, and all OS versions above:
104 daniel-mar 83
When a file is removed from the recycle bin (i.e. deleted or recovered),
84
the first byte of the original filename will be set to a zero byte,
85
making the zero-terminated string empty. This way, the record is marked as deleted
105 daniel-mar 86
and the INFO/INFO2 file does not need to be reorganized like it was the case for WinNT4 and Win95 without IE4.
104 daniel-mar 87
 
88
When the recycle bin is emptied (NOT if all files were manually deleted or recovered),
89
then the INFO und INFO2 files are removed.
90
 
98 daniel-mar 91
## $I... files of Windows Vista and above
92
 
99 daniel-mar 93
Beginning with Windows Vista, each deleted file gets its own information record. The information record ("index file") has the name `$Ixxxxxx.ext` while the data file is renamed to `$Rxxxxxx.ext` (`xxxxxx` replaced with a random `[0-9A-Z]` string and `ext` replaced with the file name extension).
98 daniel-mar 94
 
95
### Version 1 (Introduced in Windows Vista)
96
 
101 daniel-mar 97
| offset (hex) | size (dec) |  type           | description |
98
|--------------|------------|-----------------|-------------|
99
| 0000         | 8          | int64           | Version, always `01 00 00 00 00 00 00 00` |
100
| 0008         | 8          | uint64          | Original size | 
101
| 0010         | 8          | FILETIME        | Deletion time | 
102
| 0018         | 520        | wchar[MAX_PATH] | Original file name and path in Unicode characters. 260 characters (including NUL terminator) | 
98 daniel-mar 103
 
104
### Version 2 (Introduced somewhere in a Windows 10 release)
105
 
101 daniel-mar 106
| offset (hex) | size (dec) |  type           | description |
107
|--------------|------------|-----------------|-------------|
108
| 0000         | 8          | int64           | Version, always `02 00 00 00 00 00 00 00` |
109
| 0008         | 8          | uint64          | Original size | 
110
| 0010         | 8          | FILETIME        | Deletion time | 
111
| 0018         | 4          | DWORD           | Original file name and path: Count of Unicode characters, including NUL terminator | 
112
| 001C         | 2*n        | wchar[]         | Original file name and path: Zero terminated Unicode string |