Como ya te han dicho, ese código no creo que sea de delphi, de hecho no creo que funcione en windows, al menos no en Windows XP. Por suerte, no hace falta andar jugando con las interrupciones para leer el primer sector del disco.
Es así de sencillo:
Código:
uses
SysUtils, Classes;
var
Buffer: Array[1..512] of Char;
begin
with TFileStream.Create('\\.\PhysicalDrive0',fmOpenRead or fmShareDenyNone) do
try
ReadBuffer(Buffer,Sizeof(Buffer));
// Ahora tenemos el sector 0 (tambien conocido por MBR) en el buffer
finally
Free;
end;
end.
Ahora la pregunta es que hacer con la información obtenida. Una buena opción es guardar el sector de arranque en un archivo, nunca viene mal tener una copia de seguridad.
Código:
var
Buffer: Array[0..$1FF] of Byte;
begin
with TFileStream.Create('\\.\PhysicalDrive0',fmOpenRead or fmShareDenyNone) do
try
ReadBuffer(Buffer,Sizeof(Buffer));
finally
Free;
end;
with TFileStream.Create('C:\mbr.bin',fmCreate) do
try
WriteBuffer(Buffer,Sizeof(Buffer));
finally
Free;
end;
end.
O podemos intentar destripar algo de su contenido:
Código:
uses
SysUtils, Classes;
var
Buffer: Array[0..$1FF] of Byte;
i: Integer;
begin
Writeln;
with TFileStream.Create('\\.\PhysicalDrive0',fmOpenRead or fmShareDenyNone) do
try
Writeln('Leyendo el el MBR ...');
ReadBuffer(Buffer,Sizeof(Buffer));
// Ahora lo destripamos un poco
if (Buffer[$1FE] = $55) and (Buffer[$1FF] = $AA) then
Writeln('El disco es "bootable"')
else
Writeln('El disco NO es "bootable"');
for i:= 0 to 3 do
begin
if Buffer[$01BE + ($10 * i)] = $80 then
Writeln(Format('La particion numero %d es "bootable"',[i]))
else if Buffer[$01BE + ($10 * i)] = 0 then
Writeln(Format('La particion numero %d NO es bootable',[i]))
else
Writeln(Format('La particion numero %d esta mal formada',[i]));
// Para un windows el tipo es el 7
Writeln(Format('La particion numero %d es del tipo: %d',[i,Buffer[$01C2 + ($10 * i)]]));
end;
finally
Free;
end;
end.
Y aun podríamos jugar algo más ...