【1000元】请高手写一个读写主板BIOS的小软件.(0分)

  • 主题发起人 主题发起人 m8858
  • 开始时间 开始时间
M

m8858

Unregistered / Unconfirmed
GUEST, unregistred user!
【1000元】请高手写一个读写主板BIOS的小软件.<br>具体请QQ谈,高手请加我QQ-108288538
 
获取主板BIOS的信息 <br>http://www.lihuasoft.net/article/show.php?id=2368 <br> 发表日期:2004-10-31 作者:[转贴] 出处: &nbsp; <br> <br> <br><br>获取主板BIOS的信息 <br>1、读取主板序列号<br>2、AWard Bios密码读取<br>3、读取BIOS信息<br>4、获取BIOS日期信息 <br><br>=========================================<br>1、读取主板序列号 <br><br>uses SHA1, Base64; <br><br> function GetHashedBiosInfo: string; <br> var <br> &nbsp; SHA1Context: TSHA1Context; <br> &nbsp; SHA1Digest: TSHA1Digest; <br> begin <br> &nbsp; // Get the BIOS data <br> &nbsp; SetString(Result, PChar(Ptr($F0000)), $10000); <br> &nbsp; // Hash the string <br> &nbsp; SHA1Init(SHA1Context); <br> &nbsp; SHA1Update(SHA1Context, PChar(Result), Length(Result)); <br> &nbsp; SHA1Final(SHA1Context, SHA1Digest); <br> &nbsp; SetString(Result, PChar(@SHA1Digest), sizeof(SHA1Digest)); <br> &nbsp; // Return the hash string encoded in printable characters <br> &nbsp; Result := B64Encode(Result); <br> end; <br><br><br> function GetBiosInfoAsText: string; <br> var <br> &nbsp; p, q: pchar; <br> begin <br> &nbsp; q := nil; <br> &nbsp; p := PChar(Ptr($FE000)); <br> &nbsp; repeat <br> &nbsp; &nbsp; if q &lt;&gt; nil then begin <br> &nbsp; &nbsp; &nbsp; if not (p^ in [#10, #13, #32..#126, #169, #184]) then begin <br> &nbsp; &nbsp; &nbsp; &nbsp; if (p^ = #0) and (p - q &gt;= 8) then begin <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := Result + TrimRight(String(q)) + #13#10; <br> &nbsp; &nbsp; &nbsp; &nbsp; end; <br> &nbsp; &nbsp; &nbsp; &nbsp; q := nil; <br> &nbsp; &nbsp; &nbsp; end; <br> &nbsp; &nbsp; end else <br> &nbsp; &nbsp; &nbsp; if p^ in [#33..#126, #169, #184] then <br> &nbsp; &nbsp; &nbsp; &nbsp; q := p; <br> &nbsp; &nbsp; inc(p); <br> &nbsp; until p &gt; PChar(Ptr($FFFFF)); <br> &nbsp; Result := TrimRight(Result); <br> end; <br><br> procedure TForm1.FormCreate(Sender: TObject); <br> begin <br> &nbsp; Memo1.Lines.Text := GetBiosInfoAsText; <br> end; <br><br>==========================================<br>2、AWard Bios密码读取(应该是jingtao的文章,但是ID没有记录)<br>Unit AwardBiosPas;<br>//Write by lovejingtao<br>//http://www.138soft.com<br>interface<br>uses windows,SysUtils; <br><br>function My_GetBiosPassword:String;<br>implementation <br><br>function CalcPossiblePassword(PasswordValue: WORD): string;<br>var<br> I: BYTE;<br> C: CHAR;<br> S: string[8]; <br><br>begin<br> I := 0;<br> while PasswordValue &lt;&gt; 0 do<br> &nbsp; begin<br> &nbsp; &nbsp; Inc(I);<br> &nbsp; &nbsp; if $263 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; if $80 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR(PasswordValue)<br> &nbsp; &nbsp; &nbsp; &nbsp; else if $B0 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR(PasswordValue and $77)<br> &nbsp; &nbsp; &nbsp; &nbsp; else if $11D &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR($30 or (PasswordValue and $0F))<br> &nbsp; &nbsp; &nbsp; &nbsp; else if $114 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR($64 or (PasswordValue and $0F));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if '0' &gt; S then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR(BYTE(S) + 8);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br> &nbsp; &nbsp; &nbsp; &nbsp; else if $1C2 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR($70 or (PasswordValue and $03))<br> &nbsp; &nbsp; &nbsp; &nbsp; else if $1E4 &gt; PasswordValue then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR($30 or (PasswordValue and $03))<br> &nbsp; &nbsp; &nbsp; &nbsp; else<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR($70 or (PasswordValue and $0F));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if 'z' &lt; S then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; S := CHAR(BYTE(S) - 8);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; end<br> &nbsp; &nbsp; else<br> &nbsp; &nbsp; &nbsp; S := CHAR($30 or (PasswordValue and $3));<br> &nbsp; &nbsp; PasswordValue := (PasswordValue - BYTE(S)) shr 2;<br> &nbsp; end; <br><br> S[0] := CHAR(I);<br> PasswordValue := I shr 1;<br> while PasswordValue &lt; I do<br> &nbsp; begin {this is to do because award starts calculating with the last letter} <br><br> &nbsp; &nbsp; C := S[BYTE(S[0]) - I + 1];<br> &nbsp; &nbsp; S[BYTE(S[0]) - I + 1] := S;<br> &nbsp; &nbsp; S := C;<br> &nbsp; &nbsp; Dec(I);<br> &nbsp; end;<br> CalcPossiblePassword := S;<br>end; <br><br>function readcmos(off: byte): byte;<br>var<br> value: byte;<br>begin<br> asm<br> &nbsp; &nbsp; xor ax, ax<br> &nbsp; &nbsp; mov al, off<br> &nbsp; &nbsp; out 70h, al<br> &nbsp; &nbsp; in &nbsp;al, 71h<br> &nbsp; &nbsp; mov value, al<br> end;<br> readcmos := value;<br>end;<br>function My_GetBiosPassword:String;<br>var<br> superpw, userpw: word;<br> S:String;<br>begin<br>if Win32Platform &lt;&gt; VER_PLATFORM_WIN32_NT then //不是NT<br>begin<br> pchar(@superpw)[0] := char(readcmos($1C));<br> pchar(@superpw)[1] := char(readcmos($1D));<br> pchar(@userpw)[0] := char(readcmos($64));<br> pchar(@userpw)[1] := char(readcmos($65));<br> S:='超级用户密码为:'+CalcPossiblePassword(superpw)+#13+'用户密码为:'+CalcPossiblePassword(userpw);<br> Result:=S;<br> end<br> else<br> Result:='用户系统为NT,无法获取BISO密码!';<br> end;<br>end. <br><br>==========================================<br>3、读取BIOS信息<br>{程序使用Windows 95/2000平台,自动检测系统类型,然后进行不同调用}<br>uses BiosHelp; <br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> Dump: TRomBiosDump;<br> i: Integer;<br>begin<br> ReadRomBios(Dump, rrbmAutomatic);<br> for i := 1 to $000FFFFF - $000F0000 - 1 do<br> &nbsp; Memo1.Lines.Add(IntToHex(Dump[i + $000FFFFF], 2));<br>end;<br>(*******************************************************************************<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* BIOS Help - read ROM BIOS on Windows 95/98/SE/ME/NT/2K/XP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* Copyright (C) 2001, Nico Bendlin (nico@bendlin.de) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* Compiler: Delphi 4.03/5.01/6.00 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* Version: 1.03, 2001-09-02 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>*******************************************************************************) <br><br>{ postum scriptum: sorry for the bad english, i wrote it in a hurry } <br><br>unit BiosHelp; <br><br>{$ALIGN ON}<br>{$MINENUMSIZE 4} <br><br>interface <br><br>uses<br> Windows; <br><br>type<br> PRomBiosDump = ^TRomBiosDump;<br> TRomBiosDump = array[$000F0000..$000FFFFF] of Byte; <br><br>type<br> TReadRomBiosMethod = (<br> &nbsp; rrbmAutomatic, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Autodetect OS type and use proper method }<br> &nbsp; rrbmGeneric, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Use 16-bit COM program to dump the BIOS &nbsp;}<br> &nbsp; rrbmMemory, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { Read from memory (Win9x) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br> &nbsp; rrbmPhysical &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ Read from physical memory object (WinNT) }<br> &nbsp; ); <br><br>function ReadRomBios(var Dump: TRomBiosDump; Method: TReadRomBiosMethod;<br> Timeout: DWORD = INFINITE): Boolean; <br><br>function GetRomBiosBuffer(const Dump: TRomBiosDump; Address: Pointer;<br> var Buffer; BufferSize: Cardinal): Cardinal;<br>function GetRomBiosString(const Dump: TRomBiosDump; Address: Pointer): string;<br>function GetRomBiosLongLong(const Dump: TRomBiosDump; Address: Pointer): LONGLONG;<br>function GetRomBiosDWord(const Dump: TRomBiosDump; Address: Pointer): DWORD;<br>function GetRomBiosWord(const Dump: TRomBiosDump; Address: Pointer): Word;<br>function GetRomBiosByte(const Dump: TRomBiosDump; Address: Pointer): Byte; <br><br>implementation <br><br>{###############################################################################<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GENERIC METHOD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># Create an temporary folder, save an 16bit COM program (RomDump.com) into it, #<br># execute program redirected to an file (Rom.dmp, RomDump.com simply dumps the #<br># memory range F000:0000-F000:FFFF to STDOUT), read dump file into the buffer, #<br># and finally cleanup all temporary files and directories. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># (the function RomDumpCode is x86 specific, which i wrote to generate 16-bit &nbsp;#<br># &nbsp;code with the help of the 23-bit Delphi compiler, never try to execute the &nbsp;#<br># &nbsp;pseudo-code in your program! it will not work in 32-bit protected mode) &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br>###############################################################################} <br><br>{ *INTERNAL* - Pseudo 16-bit code } <br><br>type<br> PRomDumpCodeInfo = ^TRomDumpCodeInfo;<br> TRomDumpCodeInfo = (rdciStart, rdciEnd, rdciSize); <br><br>function _RomDumpCode(Info: TRomDumpCodeInfo): Pointer;<br>var<br> CodeStart: Pointer;<br> CodeEnd: Pointer;<br>begin<br> asm<br> &nbsp; &nbsp; &nbsp; &nbsp; JMP &nbsp; &nbsp; @@End <br><br> &nbsp; &nbsp; &nbsp; &nbsp; { *BEGIN* 16-bit code &nbsp;}<br> &nbsp; &nbsp; &nbsp; &nbsp; { -- never use it in your program! -- }<br> &nbsp; &nbsp; &nbsp; &nbsp; { COM which writes ROM-BIOS to StdOut }<br> @@Start:<br> &nbsp; &nbsp; &nbsp; &nbsp; { Dump F000:0000-F000:FFFE }<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eDX, eDX &nbsp;// DS = 0xF000 &nbsp; ; Data segment<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; DH, 0F0h<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; DS, eDX<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eDX, eDX &nbsp;// DX = 0x0000 &nbsp; ; Data offset<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eCX, eCX &nbsp;// CX = 0xFFFF &nbsp; ; Data length<br> &nbsp; &nbsp; &nbsp; &nbsp; DEC &nbsp; &nbsp; eCX<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eBX, eBX &nbsp;// BX = 0x0001 &nbsp; ; STDOUT (file handle)<br> &nbsp; &nbsp; &nbsp; &nbsp; INC &nbsp; &nbsp; eBX<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; AH, 40h &nbsp; // DosCall(0x40) ; INT21, DOS_WRITE_TO_HANDLE<br> &nbsp; &nbsp; &nbsp; &nbsp; INT &nbsp; &nbsp; 21h<br> &nbsp; &nbsp; &nbsp; &nbsp; JC &nbsp; &nbsp; &nbsp;@@Exit &nbsp; &nbsp;// On error exit ; AL = Error code<br> &nbsp; &nbsp; &nbsp; &nbsp; { Dump F000:FFFF }<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eDX, eDX &nbsp;// DS = 0xF000 &nbsp; ; Data segment<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; DH, 0F0h<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; DS, eDX<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eDX, eDX &nbsp;// DX = 0xFFFF &nbsp; ; Data offset<br> &nbsp; &nbsp; &nbsp; &nbsp; DEC &nbsp; &nbsp; eDX<br> &nbsp; &nbsp; &nbsp; &nbsp; XOR &nbsp; &nbsp; eCX, eCX &nbsp;// CX = 0x0001 &nbsp; ; Data length<br> &nbsp; &nbsp; &nbsp; &nbsp; INC &nbsp; &nbsp; eCX<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; eBX, eCX &nbsp;// BX = 0x0001 &nbsp; ; STDOUT (file handle)<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; AH, 40h &nbsp; // DosCall(0x40) ; INT21, DOS_WRITE_TO_HANDLE<br> &nbsp; &nbsp; &nbsp; &nbsp; INT &nbsp; &nbsp; 21h<br> &nbsp; &nbsp; &nbsp; &nbsp; JC &nbsp; &nbsp; &nbsp;@@Exit &nbsp; &nbsp;// On error exit ; AL = Error code<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; AL, 0 &nbsp; &nbsp; // no error &nbsp; &nbsp; &nbsp;; AL = 0<br> @@Exit:<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; AH, 4Ch &nbsp; // DosCall(0x4C) ; INT21, DOS_TERMINATE_EXE<br> &nbsp; &nbsp; &nbsp; &nbsp; INT &nbsp; &nbsp; 21h<br> @@End:<br> &nbsp; &nbsp; &nbsp; &nbsp; { *END* 16-bit code &nbsp;} <br><br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; CodeStart, OFFSET @@Start<br> &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; &nbsp; CodeEnd, OFFSET @@End<br> end;<br> case Info of<br> &nbsp; rdciStart:<br> &nbsp; &nbsp; Result := CodeStart;<br> &nbsp; rdciEnd:<br> &nbsp; &nbsp; Result := CodeEnd;<br> &nbsp; rdciSize:<br> &nbsp; &nbsp; Result := Pointer(Cardinal(CodeEnd) - Cardinal(CodeStart));<br> else<br> &nbsp; Result := nil;<br> end;<br>end; <br><br>{ *INTERNAL* - Save 16-bit code to file } <br><br>function _RomDumpCodeToFile(const Filename: string): Boolean;<br>var<br> ComFile: THandle;<br> Size: Cardinal;<br>begin<br> Result := False;<br> ComFile := CreateFile(PChar(Filename), GENERIC_WRITE, FILE_SHARE_READ, nil,<br> &nbsp; CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);<br> if ComFile &lt;&gt; INVALID_HANDLE_VALUE then<br> try<br> &nbsp; Result := WriteFile(ComFile, _RomDumpCode(rdciStart)^,<br> &nbsp; &nbsp; Cardinal(_RomDumpCode(rdciSize)), Size, nil) and<br> &nbsp; &nbsp; (Size = Cardinal(_RomDumpCode(rdciSize)));<br> &nbsp; if not Result then<br> &nbsp; &nbsp; DeleteFile(PChar(Filename));<br> finally<br> &nbsp; CloseHandle(ComFile);<br> end;<br>end; <br><br>{ *INTERNAL* - Execute 16-bit code redirected to file }<br>function _RomDumpCodeExecute(const Com, Dmp: string; Timeout: DWORD): Boolean;<br>var<br> ComSpec: string;<br> si: TStartupInfo;<br> pi: TProcessInformation;<br>begin<br> Result := False;<br> SetLength(ComSpec, MAX_PATH);<br> SetLength(ComSpec,<br> &nbsp; GetEnvironmentVariable('ComSpec', PChar(@ComSpec[1]), MAX_PATH));<br> if Length(ComSpec) &gt; 0 then<br> begin<br> &nbsp; FillChar(si, SizeOf(TStartupInfo), 0);<br> &nbsp; si.cb := SizeOf(TStartupInfo);<br> &nbsp; si.dwFlags := STARTF_USESHOWWINDOW;<br> &nbsp; si.wShowWindow := SW_HIDE;<br> &nbsp; if CreateProcess(nil, PChar(ComSpec + ' /C ' + Com + ' &gt; ' + Dmp),<br> &nbsp; &nbsp; nil, nil, False, CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP, nil,<br> &nbsp; &nbsp; nil, si, pi) then<br> &nbsp; try<br> &nbsp; &nbsp; Result := WaitForSingleObject(pi.hProcess, Timeout) &lt;&gt; WAIT_TIMEOUT;<br> &nbsp; finally<br> &nbsp; &nbsp; CloseHandle(pi.hProcess);<br> &nbsp; &nbsp; CloseHandle(pi.hThread);<br> &nbsp; end;<br> end;<br>end; <br><br>function DirectoryExists(const Dir: string): Boolean;<br>var<br> Attr: DWORD;<br>begin<br> Attr := GetFileAttributes(PChar(Dir));<br> Result := (Attr &lt;&gt; $FFFFFFFF) and<br> &nbsp; (Attr and FILE_ATTRIBUTE_DIRECTORY = FILE_ATTRIBUTE_DIRECTORY);<br>end; <br><br>{ Get BIOS dump the generic way }<br>function ReadRomBios16(var Buffer: TRomBiosDump; Timeout: DWORD): Boolean;<br>const<br> TempSub = '~RomDmp';<br> ComName = 'RomDump.com';<br> DmpName = 'Rom.dmp';<br>var<br> TempPath: string;<br> TempDir: string;<br> TempIdx: Integer;<br> TempIdxStr: string;<br> ComFile: string;<br> DmpFile: string;<br> DmpHandle: THandle;<br> Written: DWORD;<br>begin<br> Result := False;<br> SetLength(TempPath, MAX_PATH);<br> SetLength(TempPath, GetTempPath(MAX_PATH, PChar(@TempPath[1])));<br> if Length(TempPath) &gt; 0 then<br> begin<br> &nbsp; if (TempPath[Length(TempPath)] &lt;&gt; '/') then<br> &nbsp; &nbsp; TempPath := TempPath + '/';<br> &nbsp; TempIdx := 0;<br> &nbsp; repeat<br> &nbsp; &nbsp; Inc(TempIdx);<br> &nbsp; &nbsp; Str(TempIdx, TempIdxStr);<br> &nbsp; &nbsp; TempDir := TempPath + TempSub + TempIdxStr;<br> &nbsp; until not DirectoryExists(TempDir);<br> &nbsp; if CreateDirectory(PChar(TempDir), nil) then<br> &nbsp; try<br> &nbsp; &nbsp; TempDir := TempDir + '/';<br> &nbsp; &nbsp; ComFile := TempDir + ComName;<br> &nbsp; &nbsp; DmpFile := TempDir + DmpName;<br> &nbsp; &nbsp; if _RomDumpCodeToFile(ComFile) then<br> &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; if _RomDumpCodeExecute(ComFile, DmpFile, Timeout) then<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; DmpHandle := CreateFile(PChar(DmpFile), GENERIC_READ,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0);<br> &nbsp; &nbsp; &nbsp; &nbsp; if DmpHandle &lt;&gt; INVALID_HANDLE_VALUE then<br> &nbsp; &nbsp; &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FillChar(Buffer, SizeOf(TRomBiosDump), 0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := ReadFile(DmpHandle, Buffer, SizeOf(TRomBiosDump),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Written, nil) and (Written = SizeOf(TRomBiosDump));<br> &nbsp; &nbsp; &nbsp; &nbsp; finally<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(DmpHandle);<br> &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; finally<br> &nbsp; &nbsp; &nbsp; DeleteFile(PChar(DmpFile));<br> &nbsp; &nbsp; &nbsp; DeleteFile(PChar(ComFile));<br> &nbsp; &nbsp; end;<br> &nbsp; finally<br> &nbsp; &nbsp; RemoveDirectory(PChar(TempDir));<br> &nbsp; end;<br> end;<br>end; <br><br>{###############################################################################<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DIRECT METHOD (Win9x) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># Due to the fact that Windows 95/98/ME maps the BIOS into every Win32 process #<br># for read access it is very simple to fill the buffer from memory. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br>###############################################################################} <br><br>function ReadRomBios9x(var Buffer: TRomBiosDump): Boolean;<br>begin<br> Result := False;<br> try<br> &nbsp; FillChar(Buffer, SizeOf(TRomBiosDump), 0);<br> &nbsp; Move(Pointer(Low(TRomBiosDump))^, Buffer, SizeOf(TRomBiosDump));<br> &nbsp; Result := True;<br> except<br> &nbsp; // ignore exceptions<br> end<br>end; <br><br>{###############################################################################<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PHYSICAL MEMORY METHOD (WinNT) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># On Windows NT the ROM BIOS is only available through the named kernel object #<br># '/Device/PhysicalMemory'. Because it is impossible to open kernel objects in #<br># user mode with standard Win32 API functions we make use of NT's nativeAPI in #<br># NtDll.dll (&quot;NT-Layer&quot;) namely ZwOpenSection. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># (note: mostly there are two versions of every function ZwXxx and NtXxx. The &nbsp;#<br># &nbsp;only difference in kernel mode is that the NtXxx version works in conside- &nbsp;#<br># &nbsp;ration to security while ZwXxx not. But in user mode both work like NtXxx.) #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># At first the section is opened with ZwOpenSection. Normally we would proceed #<br># ZwMapViewOfSection, ZwUnmapViewOfSection, and NtClose. But the functions are #<br># more complex and there is no needing for it. With the handle (because we are #<br># in the &quot;very simple&quot; user mode =) we now use MapViewOfFile, UnmapViewOfFile, #<br># and CloseHandle to map an memory window (the ROM BIOS) into our process. &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># Due to the fact that ZwOpenSection returns NT error-codes in case of failure #<br># we have to translate it to an Win32 error-code (RtlNtStatusToDosError). &nbsp; &nbsp; &nbsp;#<br># All NT specific functions are dynamically loaded -- because the applications #<br># should start on Win9x systems =) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br>###############################################################################} <br><br>{ For more information see Windows 2000/XP DDK &nbsp;}<br>{ It works on Windows NT 4.0 too, use NtDll.dll } <br><br>type<br> NTSTATUS = Integer; <br><br>const<br> STATUS_SUCCESS = NTSTATUS(0);<br> STATUS_INVALID_HANDLE = NTSTATUS($C0000008);<br> STATUS_ACCESS_DENIED = NTSTATUS($C0000022); <br><br>type<br> PUnicodeString = ^TUnicodeString;<br> TUnicodeString = packed record<br> &nbsp; Length: Word;<br> &nbsp; MaximumLength: Word;<br> &nbsp; Buffer: PWideChar;<br> end; <br><br>const<br> OBJ_INHERIT = $00000002;<br> OBJ_PERMANENT = $00000010;<br> OBJ_EXCLUSIVE = $00000020;<br> OBJ_CASE_INSENSITIVE = $00000040;<br> OBJ_OPENIF = $00000080;<br> OBJ_OPENLINK = $00000100;<br> OBJ_KERNEL_HANDLE = $00000200;<br> OBJ_VALID_ATTRIBUTES = $000003F2; <br><br>type<br> PObjectAttributes = ^TObjectAttributes;<br> TObjectAttributes = record<br> &nbsp; Length: ULONG;<br> &nbsp; RootDirectory: THandle;<br> &nbsp; ObjectName: PUnicodeString;<br> &nbsp; Attributes: ULONG;<br> &nbsp; SecurityDescriptor: PSecurityDescriptor;<br> &nbsp; SecurityQualityOfService: PSecurityQualityOfService;<br> end; <br><br>const<br> ObjectPhysicalMemoryDeviceName = '/Device/PhysicalMemory';<br> ObjectPhysicalMemoryName: TUnicodeString = (<br> &nbsp; Length: Length(ObjectPhysicalMemoryDeviceName) * 2;<br> &nbsp; MaximumLength: Length(ObjectPhysicalMemoryDeviceName) * 2 + 2;<br> &nbsp; Buffer: ObjectPhysicalMemoryDeviceName;<br> &nbsp; );<br> ObjectPhysicalMemoryAccessMask: ACCESS_MASK = SECTION_MAP_READ;<br> ObjectPhysicalMemoryAttributes: TObjectAttributes = (<br> &nbsp; Length: SizeOf(TObjectAttributes);<br> &nbsp; RootDirectory: 0;<br> &nbsp; ObjectName: @ObjectPhysicalMemoryName;<br> &nbsp; Attributes: OBJ_CASE_INSENSITIVE;<br> &nbsp; SecurityDescriptor: nil;<br> &nbsp; SecurityQualityOfService: nil;<br> &nbsp; ); <br><br>type<br> TFNZwOpenSection = function(out SectionHandle: THandle;<br> &nbsp; DesiredAccess: ACCESS_MASK; ObjectAttributes: PObjectAttributes): NTSTATUS;<br> stdcall;<br> TFNRtlNtStatusToDosError = function(Status: NTSTATUS): DWORD; stdcall; <br><br>const<br> ntdll = 'ntdll.dll'; <br><br>var<br> ZwOpenSection: TFNZwOpenSection;<br> RtlNtStatusToDosError: TFNRtlNtStatusToDosError; <br><br>function ReadRomBiosNt(var Buffer: TRomBiosDump; Timeout: DWORD): Boolean;<br>var<br> NtLayer: HMODULE;<br> Status: NTSTATUS;<br> Section: THandle;<br> View: Pointer;<br>begin<br> Result := False;<br> NtLayer := GetModuleHandle(ntdll);<br> if NtLayer = 0 then<br> &nbsp; SetLastError(ERROR_CALL_NOT_IMPLEMENTED)<br> else<br> begin<br> &nbsp; if not Assigned(ZwOpenSection) then<br> &nbsp; &nbsp; ZwOpenSection := GetProcAddress(NtLayer, 'ZwOpenSection');<br> &nbsp; if not Assigned(RtlNtStatusToDosError) then<br> &nbsp; &nbsp; RtlNtStatusToDosError := GetProcAddress(NtLayer, 'RtlNtStatusToDosError');<br> &nbsp; if not (Assigned(ZwOpenSection) and Assigned(RtlNtStatusToDosError)) then<br> &nbsp; &nbsp; SetLastError(ERROR_CALL_NOT_IMPLEMENTED)<br> &nbsp; else<br> &nbsp; begin<br> &nbsp; &nbsp; Status := ZwOpenSection(Section, ObjectPhysicalMemoryAccessMask,<br> &nbsp; &nbsp; &nbsp; @ObjectPhysicalMemoryAttributes);<br> &nbsp; &nbsp; case Status of<br> &nbsp; &nbsp; &nbsp; STATUS_SUCCESS:<br> &nbsp; &nbsp; &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; View := MapViewOfFile(Section, ObjectPhysicalMemoryAccessMask, 0,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Low(TRomBiosDump), SizeOf(TRomBiosDump));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if Assigned(View) then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FillChar(Buffer, SizeOf(TRomBiosDump), 0);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Move(View^, Buffer, SizeOf(TRomBiosDump));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Result := True;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finally<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UnmapViewOfFile(View);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; &nbsp; finally<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(Section);<br> &nbsp; &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp; STATUS_ACCESS_DENIED:<br> &nbsp; &nbsp; &nbsp; &nbsp; Result := ReadRomBios16(Buffer, Timeout);<br> &nbsp; &nbsp; else<br> &nbsp; &nbsp; &nbsp; SetLastError(RtlNtStatusToDosError(Status))<br> &nbsp; &nbsp; end;<br> &nbsp; end;<br> end;<br>end; <br><br>{###############################################################################<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ReadRomBios &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br>###############################################################################} <br><br>function ReadRomBios(var Dump: TRomBiosDump; Method: TReadRomBiosMethod;<br> Timeout: DWORD = INFINITE): Boolean;<br>begin<br> Result := False;<br> case Method of<br> &nbsp; rrbmAutomatic:<br> &nbsp; &nbsp; if (Integer(GetVersion) &lt; 0) then<br> &nbsp; &nbsp; try<br> &nbsp; &nbsp; &nbsp; Result := ReadRomBios9x(Dump);<br> &nbsp; &nbsp; except<br> &nbsp; &nbsp; &nbsp; Result := ReadRomBios16(Dump, Timeout);<br> &nbsp; &nbsp; end<br> &nbsp; &nbsp; else<br> &nbsp; &nbsp; &nbsp; Result := ReadRomBiosNt(Dump, Timeout);<br> &nbsp; rrbmGeneric:<br> &nbsp; &nbsp; Result := ReadRomBios16(Dump, Timeout);<br> &nbsp; rrbmMemory:<br> &nbsp; &nbsp; Result := ReadRomBios9x(Dump);<br> &nbsp; rrbmPhysical:<br> &nbsp; &nbsp; Result := ReadRomBiosNt(Dump, Timeout);<br> else<br> &nbsp; SetLastError(ERROR_INVALID_PARAMETER);<br> end;<br>end; <br><br>{###############################################################################<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br># &nbsp; &nbsp; Utilities to simplify the access to data as generic standard types &nbsp; &nbsp; &nbsp; #<br># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#<br>###############################################################################} <br><br>function GetRomBiosBuffer(const Dump: TRomBiosDump; Address: Pointer;<br> var Buffer; BufferSize: Cardinal): Cardinal;<br>begin<br> Result := 0;<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump)) then<br> begin<br> &nbsp; Result := BufferSize;<br> &nbsp; if (Cardinal(Address) + BufferSize &gt; High(TRomBiosDump)) then<br> &nbsp; &nbsp; Result := High(TRomBiosDump) - Cardinal(Address) + 1;<br> &nbsp; Move(Dump[Cardinal(Address)], Buffer, Result);<br> end;<br>end; <br><br>function GetRomBiosString(const Dump: TRomBiosDump; Address: Pointer): string;<br>begin<br> Result := '';<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump)) then<br> &nbsp; Result := string(PChar(@Dump[Cardinal(Address)]));<br>end; <br><br>function GetRomBiosLongLong(const Dump: TRomBiosDump; Address: Pointer): LONGLONG;<br>type<br> PLongLong = ^LONGLONG;<br>begin<br> Result := 0;<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump) - SizeOf(LONGLONG) + 1) then<br> &nbsp; Result := PLongLong(@Dump[Cardinal(Address)])^;<br>end; <br><br>function GetRomBiosDWord(const Dump: TRomBiosDump; Address: Pointer): DWORD;<br>begin<br> Result := 0;<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump) - SizeOf(DWORD) + 1) then<br> &nbsp; Result := PDWORD(@Dump[Cardinal(Address)])^;<br>end; <br><br>function GetRomBiosWord(const Dump: TRomBiosDump; Address: Pointer): Word;<br>begin<br> Result := 0;<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump) - SizeOf(Word) + 1) then<br> &nbsp; Result := PWord(@Dump[Cardinal(Address)])^;<br>end; <br><br>function GetRomBiosByte(const Dump: TRomBiosDump; Address: Pointer): Byte;<br>begin<br> Result := 0;<br> if (Cardinal(Address) &gt;= Low(TRomBiosDump)) and<br> &nbsp; (Cardinal(Address) &lt;= High(TRomBiosDump) - SizeOf(Byte) + 1) then<br> &nbsp; Result := PByte(@Dump[Cardinal(Address)])^;<br>end; <br><br>end. <br><br>==========================================<br>4、获取BIOS日期信息 <br><br>{--------------------------------------------------------------------------}<br>{获取BIOS的日期信息,估计可能在2000下适用,但是可能需要获取权限}<br>function GetBiosDate1: String;<br>var<br> Buffer: Array[0..8] Of Char;<br> N: DWORD;<br>begin<br> ReadProcessMemory(GetCurrentProcess,<br> &nbsp; Ptr($FFFF5),<br> &nbsp; @Buffer,<br> &nbsp; 8,<br> &nbsp; N);<br> Buffer[8] := #0;<br> result := StrPas(Buffer)<br>end; <br><br>function GetBiosDate2: String;<br>begin<br> result := string(pchar(ptr($FFFF5)));<br>end;
 
QQ 362917144
 
接受答案了.
 
后退
顶部