📄 mbdrvlib.pas
字号:
fillchar(buf2, $ff00, 0);
for i:= 0 to 10 do
begin
Write10(i*32, 32, buf2, 32*2048);
result := True;
end;
FlushCache(30000, FALSE);
end
else
begin
Buf1 := #$00#$82#$00#$08#$00#$22#$21#$20#$00#$00#$08#$00;
result := FormatUnit($11, Buf1, 12);
end;
end
else if (MediumIs = mtDVD_PLUSRW) then
begin
buf1 := #$00#$82#$00#$08#$00#$23#$05#$40#$98#$00#$00#$00;
result := FormatUnit($11, @buf1, 12);
if (not result) then
begin
Rewind;
Sleep(1000);
result := FormatUnit($11, @buf1, 12);
end;
end;
end;
if result then
begin
th := TEraseThread.Create(True);
th.Medium := MediumIs;
th.FreeOnTerminate := True;
th.Device := self;
if MediumIs < 4 then
begin
th.AproxSecs := 75 * 60;
if EraseType = etQuick then
th.AproxSecs := 150;
if EraseType = etComplete then
th.AproxSecs := 75 * 60;
end
else
begin
th.AproxSecs := 74 * 60 * 2;
if EraseType = etQuick then
begin
th.AproxSecs := 600;
if MediumIs = mtDVD_RW then
th.AproxSecs := 60 * 3;
end;
if EraseType = etComplete then
th.AproxSecs := 74 * 60;
end;
fErasing := True;
th.Resume;
end
else
begin
fErasing := False;
if Assigned(fEraseDone) then
fEraseDone(Self, True);
end;
end;
{******************************************************************************}
{ Prevent/Allow Medium Removal }
{******************************************************************************}
function TSCSIDevice.LockMedium(Unlock: Boolean = False): Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
if Unlock then
CloseFH := True;
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := SRB_EVENT_NOTIFY;
lsrb.CDBLen := $06;
lsrb.SenseLen := SENSE_LEN;
lsrb.CDBCmd := $1E;
if not Unlock then
lsrb.CDBByte[4] := 1;
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
CloseFH := False;
end;
{******************************************************************************}
{ }
{******************************************************************************}
procedure TSCSIDevice.LockDrive(UnLock: Boolean = True);
begin
mbSPTI.CloseFH := UnLock;
end;
{******************************************************************************}
{ Inquiry }
{******************************************************************************}
function TSCSIDevice.Inquiry: Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := $48;
lsrb.CDBLen := $06;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := 128;
lsrb.BufPointer := @fInquiryData;
lsrb.CDBCmd := $12;
lsrb.CDBByte[4] := 128;
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
end;
{******************************************************************************}
{ Mode Sense10 }
{******************************************************************************}
function TSCSIDevice.ModeSense10;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
fillchar(buf, sizeof(buf), 0);
lsrb.Flags := $48;
lsrb.CDBLen := $0A;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := buflen;
lsrb.BufPointer := @buf2;
lsrb.CDBCmd := $5A;
if ps then
lsrb.CDBByte[2] := PageCode + 128
else
lsrb.CDBByte[2] := PageCode;
lsrb.CDBByte[7] := HiByte(BufLen);
lsrb.CDBByte[8] := LoByte(BufLen);
ExecScsiCommand(lsrb, 20000);
result := lsrb.Status = SS_COMP;
if result then
begin
move(buf2, buf, buflen);
end;
end;
{******************************************************************************}
{ Get Configuration }
{******************************************************************************}
function TSCSIDevice.GetConfigData(RT: Byte; Profile: Word; buf: Pointer; buflen: Integer): Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := $48;
lsrb.CDBLen := $0A;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := buflen;
lsrb.BufPointer := buf;
lsrb.CDBCmd := $46;
lsrb.CDBByte[1] := RT;
lsrb.CDBByte[3] := Profile;
lsrb.CDBByte[8] := buflen; //.. word
ExecScsiCommand(lsrb, 30000);
result := lsrb.Status = SS_COMP;
end;
{******************************************************************************}
{ Set Streaming }
{******************************************************************************}
function TSCSIDevice.SetStreaming(Buffer: Pointer; BufLength: Word): Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := $50;
lsrb.CDBLen := 12;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := BufLength;
lsrb.BufPointer := Buffer;
lsrb.CDBCmd := $B6;
CvtEndians(BufLength, lsrb.CDBByte[9], 2);
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
end;
function TSCSIDevice.SetPerformance(StartLBA: LongWord; EndLBA: LongWord; ReadSize: LongWord; WriteSize: LongWord; ReadTime: LongWord; WriteTime: LongWord): Boolean;
var
buf1: packed array [0..79] of Byte;
pd: TAPerformaceDescriptor;
begin
Move(buf1[0],pd.OtherInfo,28);
pd.StartLBA := 0;
pd.EndLBA := L2MDW(pd.EndLBA);
pd.ReadSize := L2MDW(pd.ReadSize);
pd.ReadTime := L2MDW(ReadTime);
pd.WriteSize := L2MDW(pd.WriteSize);
pd.WriteTime := L2MDW(WriteTime);
Move(pd.OtherInfo,buf4,28);
Result := SetStreaming(@buf4,28);
end;
{******************************************************************************}
{ Read DVD Structure }
{******************************************************************************}
function TSCSIDevice.SendDVDStructure(Format: Byte; Buf: Pointer; BufLength: Word): Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := $50;
lsrb.CDBLen := 12;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := BufLength;
lsrb.BufPointer := buf;
lsrb.CDBCmd := $BF;
lsrb.CDBByte[7] := Format;
CvtEndians(BufLength, lsrb.CDBByte[8], 2);
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
end;
{******************************************************************************}
{ Read DVD Structure TS }
{******************************************************************************}
function TSCSIDevice.SendDVDStructureTimeStamp(Time: TDateTime): Boolean;
var
str: String;
begin
str := formatDateTime('yyyymmddhhnnss', Time);
buf1 := #$00+#$14+#$00+#$00+#$00+#$00+#$00+#$00;
move(str[1], buf1[8], 14);
result := SendDVDStructure($0f, @buf1, $16);
end;
{******************************************************************************}
{ Read DVD Structure }
{******************************************************************************}
function TSCSIDevice.ReadDVDStructure(Layer, Format: Byte; Buf: Pointer; BufLength: Word): Boolean;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
lsrb.Flags := $48;
lsrb.CDBLen := $0C;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := BufLength;
lsrb.BufPointer := buf;
lsrb.CDBCmd := $AD;
lsrb.CDBByte[7] := Format;
lsrb.CDBByte[6] := Layer;
CvtEndians(BufLength, lsrb.CDBByte[8], 2);
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
end;
{******************************************************************************}
{ Mode Select10 }
{******************************************************************************}
function TSCSIDevice.ModeSelect10;
var
lsrb: TSRB_ExecSCSICmd;
begin
fillchar(lsrb, sizeof(lsrb), 0);
move(Buffer[0], buf2[0], buflen);
lsrb.Flags := $50;
lsrb.CDBLen := $0A;
lsrb.SenseLen := SENSE_LEN;
lsrb.BufLen := buflen;
lsrb.BufPointer := Buf2;
lsrb.CDBCmd := $55;
lsrb.CDBByte[1] := 16;
lsrb.CDBByte[8] := buflen; //.. word
ExecScsiCommand(lsrb, 10000);
result := lsrb.Status = SS_COMP;
end;
{******************************************************************************}
{ Check for JustLink }
{******************************************************************************}
function TSCSIDevice.IsJustLinkCapable: Boolean;
var
page: Byte;
s: Integer;
begin
page := $30;
result := false;
fillchar(buf3, $80, 0);
if ModeSense10(page, buf3, $80, False) then
begin
if buf3[16] = page then s := 16
else if buf3[8] = page then s := 8
else if buf3[7] = page then s := 7
else s := 0;
if s <> 0 then
result := true;
end;
end;
{******************************************************************************}
{ Get Device Capabilities }
{******************************************************************************}
function TSCSIDevice.GetDeviceCapabilities;
var
i: Integer;
s: Byte;
page: integer;
begin
fDevCaps := [];
s := 15;
page := $2a;
fDeviceMaxWriteSpeed := 0;
fDeviceMaxReadSpeed := 0;
fillchar(ModePage2A , sizeof(ModePage2A), 0);
fillchar(buf3, 255, 0);
if ModeSense10(page, buf3, $FF, True) then
begin
if buf3[16] = page then s := 16
else if buf3[8] = page then s := 8
else if buf3[7] = page then s := 7
else s := 8;
for i :=0 to 254-s do buf3[i] := buf3[i+s];
move(buf3, ModePage2A, sizeof(ModePage2A));
if (ModePage2A.DiscReadCaps and $01 = $01) then Include(fDevCaps, dcReadCDR);
if (ModePage2A.DiscReadCaps and $02 = $02) then Include(fDevCaps, dcReadCDRW);
if (ModePage2A.DiscReadCaps and $04 = $04) then Include(fDevCaps, dcReadMethod2);
if (ModePage2A.DiscReadCaps and $08 = $08) then Include(fDevCaps, dcReadDVD);
if (ModePage2A.DiscReadCaps and $10 = $10) then begin Include(fDevCaps, dcReadDVDR); Include(fDevCaps, dcReadDVDRW); end;
if (ModePage2A.DiscReadCaps and $20 = $20) then Include(fDevCaps, dcReadDVDRAM);
if (ModePage2A.DiscWriteCaps and $01 = $01) then Include(fDevCaps, dcWriteCDR);
if (ModePage2A.DiscWriteCaps and $02 = $02) then Include(fDevCaps, dcWriteCDRW);
if (ModePage2A.DiscWriteCaps and $04 = $04) then Include(fDevCaps, dcWriteTest);
if (ModePage2A.DiscWriteCaps and $10 = $10) then begin Include(fDevCaps, dcWriteDVDR); Include(fDevCaps, dcWriteDVDRW); end;
if (ModePage2A.DiscWriteCaps and $20 = $20) then Include(fDevCaps, dcWriteDVDRAM);
if (ModePage2A.AudioPlay and $80 = $80) then Include(fDevCaps, dcUnderrunProtection);
if IsJustLinkCapable or TEAC512EB then
Include(fDevCaps, dcUnderrunProtection);
if ModePage2A.MaxWriteSpeed = 0 then
begin
if (ModePage2A.DiscWriteCaps and $20 = $20) then
fDeviceMaxWriteSpeed := 1;
end
else
fDeviceMaxWriteSpeed := L2MW(ModePage2A.MaxWriteSpeed);
if ModePage2A.MaxReadSpeed = 0 then
begin
if (ModePage2A.DiscWriteCaps and $20 = $20) then
fDeviceMaxReadSpeed := 1;
end
else
fDeviceMaxReadSpeed := L2MW(ModePage2A.MaxReadSpeed);
if GetConfigData(2, $2a, @dtBuf, sizeof(dtBuf)) then
begin
dtBuf.CurrentProfile := L2MW(dtBuf.CurrentProfile);
dtBuf.FeatureCode := L2MW(dtBuf.FeatureCode);
if (dtBuf.FeatureCode = $2a) then
begin
Include(fDevCaps, dcReadDVDPLUSR);
Include(fDevCaps, dcReadDVDPLUSRW);
if dtBuf.OtherData[0] = 1 then
begin
Include(fDevCaps, dcWriteDVDPLUSR);
Include(fDevCaps, dcWriteDVDPLUSRW);
end;
end;
end;
if GetConfigData(2, $3b, @dtBuf, sizeof(dtBuf)) then
begin
dtBuf.CurrentProfile := L2MW(dtBuf.CurrentProfile);
dtBuf.FeatureCode := L2MW(dtBuf.FeatureCode);
if (dtBuf.FeatureCode = $3b) then
begin
Include(fDevCaps, dcReadDVDPLUSRDL);
if dtBuf.OtherData[0] = 1 then
Include(fDevCaps, dcWriteDVDPLUSRDL);
end;
end;
if GetConfigData(2, $2f, @dtBuf, sizeof(dtBuf)) then
begin
dtBuf.CurrentProfile := L2MW(dtBuf.CurrentProfile);
dtBuf.FeatureCode := L2MW(dtBuf.FeatureCode);
if (dtBuf.FeatureCode = $2f) then
begin
Include(fDevCaps, dcReadD
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -