Subversion Repositories recyclebinunit

Rev

Rev 98 | Rev 100 | 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
 
4
## Locations
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...`
98 daniel-mar 12
 
13
### NTFS drives:
14
 
99 daniel-mar 15
- Windows NT4:		`C:\RECYCLER\<UserSID>\INFO` (with Unicode records, folder deletion is possible, format `02 00 00 00`)
16
- Windows 2000, XP:	`C:\RECYCLER\<UserSID>\INFO2` (with Unicode records, folder deletion is possible, format `05 00 00 00`)
17
- Windows Vista+:	`C:\$RECYCLE.BIN\<UserSID>\$I...`
98 daniel-mar 18
 
19
## INFO and INFO2 files
20
 
21
INFO is written by Win95 without IE4 (with ANSI records), and WinNT4 (with Unicode records).
22
 
23
INFO2 is written by Win95 with Internet Explorer 4 shell extensions, Win98, WinMe (with ANSI records), Win2000, and WinXP (with Unicode records).
24
 
99 daniel-mar 25
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 26
 
27
INFO and INFO2 is the index file containing all information about the deleted files. The data files are renamed to `Dxy.ext` (`x` replaced with the drive letter, `y` being a dynamic length integer, `ext` being replaced with the file name extension).
28
 
29
### Header
30
 
31
    type
32
      PRbInfoHeader = ^TRbInfoHeader;
99 daniel-mar 33
      TRbInfoHeader = packed record
34
        format: DWORD;         // Version of the info file
35
                               // Win95 (without IE4):   00 00 00 00
36
                               // Win NT4:               02 00 00 00   (Win96/Cairo?)
37
                               // Win95 (with IE4), 98:  04 00 00 00
38
                               // Win Me, 2000, XP:      05 00 00 00   (NT4+IE4, NT5?)
39
        totalEntries: DWORD;   // Only Win95 (without IE4) and Win NT4, other OS versions might use the registry instead
40
        nextPossibleID: DWORD; // Only Win95 (without IE4) and Win NT4, other OS versions might use the registry instead
41
        recordLength: DWORD;   // 0x181  =  ANSI records
42
                               // 0x320  =  Unicode records
43
        totalSize: DWORD;      // sum of all "originalSize" values;
44
                               // Only Win95 (without IE4) and Win NT4, other OS versions might use the registry instead
98 daniel-mar 45
      end;
46
 
99 daniel-mar 47
### ANSI record (Win95, Win98, WinMe)
98 daniel-mar 48
 
49
    type
50
      // Windows 95:      INFO file with TRbInfoRecordA; Folder deletion NOT possible
51
      // Windows 95 +IE4: INFO2 file with TRbInfoRecordA; Folder deletion possible
52
      PRbInfoRecordA = ^TRbInfoRecordA;
99 daniel-mar 53
      TRbInfoRecordA = packed record
54
        sourceAnsi: array[0..MAX_PATH-1] of AnsiChar; // 260 characters (including NUL terminator)
98 daniel-mar 55
        recordNumber: DWORD;
99 daniel-mar 56
        sourceDrive: DWORD; // 0=A, 1=B, 2=C, ...
98 daniel-mar 57
        deletionTime: FILETIME;
58
        originalSize: DWORD; // Size occupied on disk. Not the actual file size.
59
                             // INFO2, for folders: The whole folder size with contents
60
      end;
61
 
99 daniel-mar 62
### Unicode record (WinNT4, Win2000, WinXP)
98 daniel-mar 63
 
64
    type
65
      // Windows NT4:   INFO file with TRbInfoRecordW; Folder deletion possible
66
      // Windows 2000+: INFO2 file with TRbInfoRecordW; Folder deletion possible
67
      PRbInfoRecordW = ^TRbInfoRecordW;
99 daniel-mar 68
      TRbInfoRecordW = packed record
69
        sourceAnsi: array[0..MAX_PATH-1] of AnsiChar; // 260 characters (including NUL terminator)
98 daniel-mar 70
        recordNumber: DWORD;
99 daniel-mar 71
        sourceDrive: DWORD; // 0=A, 1=B, 2=C, ...
98 daniel-mar 72
        deletionTime: FILETIME;
73
        originalSize: DWORD;
99 daniel-mar 74
        sourceUnicode: array[0..MAX_PATH-1] of WideChar; // 260 characters (including NUL terminator)
98 daniel-mar 75
      end;
76
 
77
## $I... files of Windows Vista and above
78
 
99 daniel-mar 79
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 80
 
81
### Version 1 (Introduced in Windows Vista)
82
 
83
    type
84
      // Introduced in Windows Vista
85
      PRbVistaRecord1 = ^TRbVistaRecord1;
99 daniel-mar 86
      TRbVistaRecord1 = packed record
98 daniel-mar 87
        version: int64; // Always 01 00 00 00 00 00 00 00
88
        originalSize: int64;
89
        deletionTime: FILETIME;
90
        sourceUnicode: array[0..MAX_PATH-1] of WideChar;
91
      end;
92
 
93
### Version 2 (Introduced somewhere in a Windows 10 release)
94
 
95
    type
96
      // Introduced somewhere in a Win10 release
97
      PRbVistaRecord2Head = ^TRbVistaRecord2Head;
99 daniel-mar 98
      TRbVistaRecord2Head = packed record
98 daniel-mar 99
        version: int64; // Always 02 00 00 00 00 00 00 00
100
        originalSize: int64;
101
        deletionTime: FILETIME;
102
        (* sourceUnicode: BSTR; *)
103
        sourceCountChars: DWORD; // including NUL
104
        //sourceUnicode: array[0..sourceCountChars+1] of WideChar;
105
      end;