Veo que no levanto mucho interés este tema. Quizá sea por necesitar de otro programa para leer sector a sector el disco que se quiere explorar en busca de imágenes jpg. También es verdad que daba como alternativa un programa hecho en C y que también publique por aquí hace tiempo.
El caso es que, como estamos en el ClubDelphi, quizá sea mas interesante si el código para extraer la información del disco esta escrito en delphi y no en C. Pues no hay problema, aquí va un poco de código:
(Es una aplicación de consola)
Código Delphi
[-]
program dump;
{$APPTYPE CONSOLE}
uses Windows, SysUtils, Classes;
const
BufferSize = 32*1024*1024;
procedure WriteMsg(Msg: string);
var
StdError: THandle;
begin
StdError:= GetStdHandle(STD_ERROR_HANDLE);
if (StdError <> STD_ERROR_HANDLE) and (StdError <> 0) then
begin
FileWrite(StdError,PChar(Msg + #13#10)^,Length(Msg) + 2);
end;
end;
procedure WriteError(Msg: String);
var
ErrorCode: Cardinal;
begin
ErrorCode:= GetLastError;
if ErrorCode <> 0 then
Msg:= Msg + ': ' + SysErrorMessage(GetLastError);
WriteMsg(Msg);
end;
procedure Loop(Input,Output: THandle);
var
Buffer: Pointer;
BytesRead: Cardinal;
BytesWritten: Cardinal;
begin
GetMem(Buffer,BufferSize);
try
while TRUE do
begin
if not ReadFile(Input,Buffer^,BufferSize,BytesRead,nil) then
if GetLastError <> ERROR_BROKEN_PIPE then
begin
WriteError('ReadFile()');
break;
end;
if BytesRead = 0 then
break;
if not WriteFile(Output,Buffer^,BytesRead,BytesWritten,nil) then
begin
WriteError('WriteFile()');
break;
end;
end;
finally
FreeMem(Buffer);
end;
end;
var
i: integer;
Input, Output: THandle;
InputStr, OutputStr: String;
begin
with TStringList.Create do
try
for i:= 1 to ParamCount do
Add(LowerCase(ParamStr(i)));
InputStr:= Values['if'];
OutputStr:= Values['of'];
if (OutputStr <> '') then
Output:= CreateFile(PChar(OutputStr),GENERIC_WRITE,FILE_SHARE_READ,nil,
OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0)
else
Output:= GetStdHandle(STD_OUTPUT_HANDLE);
if (Output <> STD_ERROR_HANDLE) and (Output <> 0) then
begin
if (InputStr <> '') then
Input:= CreateFile(PChar(InputStr),GENERIC_READ,
FILE_SHARE_READ,nil,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0)
else
Input:= GetStdHandle(STD_INPUT_HANDLE);
if (Output <> STD_ERROR_HANDLE) and (Output <> 0) then
begin
Loop(Input,Output);
end else
WriteError('');
end else
WriteError('');
finally
Free;
end;
end.
Para usarlo, por ejemplo para crear una imagen del disco F :
Código:
dump if=\\.\F: > imagen.bin
Para crear una imagen del primer disco duro:
Código:
dump if=\\.\PhisicalDrive0 > imagen.bin
Para restaurar una imagen en un disco:
Código:
dump if=imagen.bin of=\\.\F: