Pues yo sigo aquí, de fisgón, aquí les dejo un programa que busca los archivos "thumb.db" (al parecer en Vista se llaman thumbcache_xxxx.db) creados por el explorer cuando vemos una carpeta con imágenes utilizando las "Vistas en miniatura". Lo "divertido" es que tiene el mal habito de no borrar las miniaturas almacenadas en la cache cuando se borra la imagen original, así que podemos encontrarnos con alguna sorpresa.
Es una aplicación de consola:
Código Delphi
[-]
program Fisgon;
{$APPTYPE CONSOLE}
uses
SysUtils,
Classes;
procedure Recover(Origen: TStream; FormatStr: String; var Index: Integer);
var
Destino: TMemoryStream;
Buffer: array[0..$FFFF] of Byte;
Header: array[1..4] of Byte;
Size: Integer;
begin
Destino:= TMemoryStream.Create;
try
Header[1]:= $FF; Header[2]:= $D8;
Destino.WriteBuffer(Header,2);
Origen.Seek(-1,soFromCurrent);
while TRUE do
begin
Origen.ReadBuffer(Header,4);
Size:= ((Header[3] shl 8) + Header[4]) - 2;
case Header[2] of
$01,$D0..$D8: begin
Destino.WriteBuffer(Header,2);
Origen.Seek(-2,soFromCurrent);
end;
$D9: begin
Destino.WriteBuffer(Header,2);
Destino.SaveToFile(Format(FormatStr,[Index]));
Writeln('Recuperada: ' + Format(FormatStr,[Index]));
inc(Index);
Exit;
end;
$DA: begin
Destino.WriteBuffer(Header,2);
Origen.Seek(-2,soFromCurrent);
while TRUE do
begin
Origen.ReadBuffer(Buffer,1);
if Buffer[0] = $FF then
begin
Origen.ReadBuffer(Buffer,1);
if (Buffer[0] <> 0) and not (Buffer[0] in [$D0..$D7]) then
begin
Origen.Seek(-2,soFromCurrent);
break;
end else
begin
Header[1]:= $FF;
Header[2]:= Buffer[0];
Destino.WriteBuffer(Header,2);
end;
end else
Destino.WriteBuffer(Buffer,1);
end;
end
else
begin
Origen.ReadBuffer(Buffer,Size);
Destino.WriteBuffer(Header,4);
Destino.WriteBuffer(Buffer,Size);
end;
end;
end;
finally
Destino.Free;
end;
end;
procedure Scanfile(Stream: TStream; FormatStr: String; var Index: Integer);
var
B: Byte;
Leidos: Integer;
Posicion: int64;
begin
Leidos:= Stream.Read(B,1);
while Leidos = 1 do
if B = $FF then
begin
Leidos:= Stream.Read(B,1);
if Leidos = 1 then
if B = $D8 then
begin
Leidos:= Stream.Read(B,1);
if Leidos = 1 then
if B = $FF then
begin
Writeln('Encontrada una posible imagen.');
Posicion:= Stream.Position;
try
Recover(Stream,FormatStr,Index);
except
On E: Exception do
Writeln('Error: ' + E.Message);
end;
Stream.Position:= Posicion;
end;
end;
end else
Leidos:= Stream.Read(B,1);
end;
procedure Buscar(Path: string; var Index: Integer);
var
SR: TSearchRec;
Stream: TFileStream;
begin
if Path = '' then exit;
if copy(Path, Length(Path), 1) <> '\' then Path := Path + '\';
if FindFirst(Path + '*', faDirectory, SR) = 0 then
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
Buscar(Path + SR.Name, Index);
until FindNext(SR) <> 0;
FindClose(SR);
if FindFirst(Path + 'thumb*.db',faAnyfile, SR) = 0 then
repeat
Stream:= TFileStream.Create(Path + SR.Name,fmOpenRead);
try
Writeln('Explorando el archivo: ' + Path + SR.Name);
Scanfile(Stream,ParamStr(2),Index);
finally
Stream.Free;
end;
until FindNext(SR) <> 0;
FindClose(SR);
end;
var
i: Integer;
begin
if ParamCount = 2 then
try
TFileStream.Create(Format(ParamStr(2),[0]),fmCreate).Free;
DeleteFile(Format(ParamStr(2),[0]));
i:= 0;
Buscar(ParamStr(1),i);
except
On E: Exception do
Writeln('Error: ' + E.Message);
end;
end.
Por ejemplo:
Código:
Fisgon C:\ %d.jpg
A fisgonear