Einzelnen Beitrag anzeigen

Mattze

Registriert seit: 6. Jan 2005
664 Beiträge
 
#1

IOCTL_SCSI_MINIPORT: Wer weiß, wie?

  Alt 1. Apr 2012, 14:00
Hallo,

ich kriege es einfach nicht hin. Er schreibt immer: "Falscher Parameter", also habe ich wahrscheinlich zu wenig Ahnung von C, um die Strukturen richtig zu übersetzen.
Kann jemand helfen? Was mache ich falsch?

Delphi-Quellcode:
const
  IOCTL_SCSI_MINIPORT_NVCACHE = $1b0600;
  IOCTL_SCSI_MINIPORT = $4d008;
  NRB_FUNCTION_NVCACHE_INFO = $EC;

type

  PSRB_IO_Control = ^SRB_IO_Control;
  SRB_IO_Control = record
    HeaderLength: ULong;
    Signature: array[0..7] of byte;
    TimeOut: ulong;
    ControlCode: Ulong;
    ReturnCode: Ulong;
    Length: ULONG;
  end;

  PSRB_BUFFER = ^SRB_BUFFER;
  SRB_BUFFER = record
    sic: SRB_IO_CONTROL;
    ucDataBuffer: array[0..511] of byte;
  end;

  PNVCACHE_REQUEST_BLOCK = ^NVCACHE_REQUEST_BLOCK;
  NVCACHE_REQUEST_BLOCK = record
    nrbsize: ULong;
    Fct: Word;
    NRBFlags: ULONG;
    NRBStatus: ULONG;
    Cuont: ULONG;
    LBA: UINt64;
    DataBufSize: ULong;
    NVCacheStatus: ULong;
    NVCacheSubStatus: ULong;
  end;

  PNV_FEATURE_PARAMETER = ^NV_FEATURE_PARAMETER;
  NV_FEATURE_PARAMETER = record
     NVPowerModeEnabled: word;
     NVParameterReserv: word;
     NVCmdEnabled: Word;
     NVParameterReserv2: Word;
     NVPowerModeVer: Word;
     NVCmdVer: Word;
     NVSize: ULong;
     NVReadSpeed: Word;
     NVWrtSpeed: Word;
     DeviceSpinUpTime: Word;
  end;

procedure Test;
var hDevice: Cardinal;
    dwBytesReturned: DWord;
    i: Integer;
    req: NVCACHE_REQUEST_BLOCK;
    rpm: NV_FEATURE_PARAMETER;


begin
  hDevice:=CreateFile(PChar('\\.\PHYSICALDRIVE0'),GENERIC_READ or GENERIC_WRITE,
           FILE_SHARE_READ or FILE_SHARE_WRITE,
           nil,OPEN_EXISTING,0,0);
  if hDevice=INVALID_HANDLE_VALUE then begin
    showmessage('Createfile klappt nicht.'); ;
    exit;
  end;

  ZeroMemory(@req, SizeOf(NVCACHE_REQUEST_BLOCK));
  req.Fct:=NRB_FUNCTION_NVCACHE_INFO;
   req.NRBSize:=sizeof(NVCACHE_REQUEST_BLOCK);

  if not windows.DeviceIoControl(hDevice, IOCTL_SCSI_MINIPORT,
                          @req, sizeof(NVCACHE_REQUEST_BLOCK),
                          @rpm, sizeof(NV_FEATURE_PARAMETER),
                          dwBytesReturned, nil) then begin
    i:=GetLastError;
    showmessage(format('%s (%d)',[SysErrorMessage(i),i]));
  end;
end;
Gruß
Mattze
  Mit Zitat antworten Zitat