急,请问各位高手,如何在2000系统下对cmos信息进行读写

                            
请问各位高手:在2000系统下通过编写驱动程序我已经获得ring0特权,编译成功,   
  但却读不出cmos信息,代码如下:请高手帮忙解决  
    {输出一个字节}  
  procedure   outportb(portaddress:word;bytel:byte);  
  var  
  error:boolean;  
  bytesreturned:dword;  
  buffer:array[0..2]   of   byte;  
  pbuffer:pword;  
  begin  
    pbuffer:=pword(@buffer[0]);  
    pbuffer^:=portaddress;  
    buffer[2]:=bytel;  
    error:=deviceiocontrol(porttalk_handle,cardinal(IOCTL_WRITE_PORT_UCHAR),@buffer,3,nil,0,bytesreturned,nil);  
    if   (not   error)   then   showmessagefmt('从porttalk输出端口数据是出错:%d',[GetLastError]);  
  end;  
  {输入一个字节}  
  function   inportb(portaddress:word):byte;  
  var  
  error:boolean;  
  bytesreturned:dword;  
  buffer:array[0..2]   of   byte;  
  pbuffer:pword;  
  begin  
    pbuffer:=pword(@buffer[0]);  
    pbuffer^:=portaddress;  
    error:=deviceiocontrol(porttalk_handle,cardinal(IOCTL_WRITE_PORT_UCHAR),@BUFFER,2,@BUFFER,1,bytesreturned,NIL);  
    IF   (NOT   ERROR)   THEN   SHOWMESSAGEFMT('从porttalk输入端口数据时出错:%d',[GetLastError]);  
    result:=buffer[0];  
  end;  
  function   ReadCmos(index:BYTE):byte;  
  var  
  data1:BYTE   ;  
  begin  
        outportb($70,index);  
        data1:=inportb($71);  
        result:=data1;  
  end;  
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var  
  i:integer;  
  data:array[0..127]   of   byte;       //定义二进制文件类型数组   ;  
  ff:file;  
  begin  
  openporttalk;//安装驱动  
          for   i:=0   to   127   do  
          data[i]:=0;  
          for   i:=0   to   127   do  
          data[i]:=ReadCmos(i);  
          assignfile(ff,'c:\CMOS.DAT');  
          rewrite(ff,1);  
          blockwrite(ff,data,sizeof(data));  
          closefile(ff);  
  closeporttalk;关闭驱动  
  end;  
 

查看回复