What is the longest file path allowed to be moved to Recycle Bin?
Recycle Bin internals:
Windows XP
Every drive has its own drive:\RECYCLER\%USER_SID% directory. This directory contains all deleted files but files have names like DcN.ext where D is fixed part of the name, c is drive letter, N is a index and ext is extension of original file. Besides deleted files there is database file named INFO2.
INFO2 file starts with header. Header structure:
Offset Type Value
0x0000 DWORD Signature ; Always 5
0x0004 DWORD Unknown1
0x0008 DWORD Unknown2
0x000C DWORD RecordSize ; Always 0x00000320
0x0010 DWORD Unknown3
Records are stored successively immediately after header to the end of the INFO2 file. Record structure:
Offset Type Value
0x0000 ANSICHAR[MAX_PATH] OriginalFileNameA ; Ansi string
0x0104 DWORD Index ; Associated with *N* from *DcN.ext*
0x0108 DWORD DriveIndex ; A: = 0; B: = 1; C: = 2; ...
0x010C FILETIME DeleteFileTime
0x0114 DWORD OriginalFileNamePhysicalSize
0x0118 WIDECHAR[MAX_PATH] OriginalFileNameW ; Wide string
Windows Vista and above
Every drive has its own drive:\$Recycle.Bin\%USER_SID% directory. This directory contains all deleted files but now there is no database file. Every deleted file is associated with 2 files inside RB.
First file has name like $INNNNNN.ext where $I is fixed part of the name, NNNNNN consists of 6 random letters or numbers and ext is extension of original file.
$I file structure:
Offset Type Value
0x0000 DWORD Signature ; Always 1
0x0004 DWORD Unknown1
0x0008 DDWORD OriginalFileSize
0x0010 FILETIME DeleteFileTime
0x0018 WIDECHAR[MAX_PATH] OriginalFileNameW ; Wide string
Second file has name like $RNNNNNN.ext where $R is fixed part of the name, NNNNNN is the same as in $I file and ext is extension of original file. $R file is deleted file itself.
As you see in all cases Windows stores filename in array which has size of MAX_PATH chars. That why the limit of length of filename is MAX_PATH - 1 chars.
Windows 10
Windows 10 has a new version of $I file structure (don`t know what update changed it):
Offset Type Value
0x0000 DWORD Signature ; Always 2
0x0004 DWORD Unknown1
0x0008 DDWORD OriginalFileSize
0x0010 FILETIME DeleteFileTime
0x0018 DWORD OriginalFileNameLen
0x001C WIDECHAR[OriginalFileNameLen] OriginalFileNameW ; Wide string
And it looks like now Windows can store any files with any paths in the Recycle Bin.