function CalcPossiblePassword(PasswordValue: WORD): string;
var
I: BYTE;
C: CHAR;
S: string;
begin
I := 0;
while PasswordValue <> 0 do
begin
Inc(I);
if $263 > PasswordValue then
begin
if $80 > PasswordValue then
S[I] := CHAR(PasswordValue)
else if $B0 > PasswordValue then
S[I] := CHAR(PasswordValue and $77)
else if $11D > PasswordValue then
S[I] := CHAR($30 or (PasswordValue and $0F))
else if $114 > PasswordValue then
begin
S[I] := CHAR($64 or (PasswordValue and $0F));
if ''0'' > S[I] then
S[I] := CHAR(BYTE(S[I]) + 8);
end
else if $1C2 > PasswordValue then
S[I] := CHAR($70 or (PasswordValue and $03))
else if $1E4 > PasswordValue then
S[I] := CHAR($30 or (PasswordValue and $03))
else
begin
S[I] := CHAR($70 or (PasswordValue and $0F));
if ''z'' < S[I] then
S[I] := CHAR(BYTE(S[I]) - 8);
end;
end
else
S[I] := CHAR($30 or (PasswordValue and $3));
PasswordValue := (PasswordValue - BYTE(S[I])) shr 2;
end;
S[0] := CHAR(I);
PasswordValue := I shr 1;
while PasswordValue < I do
begin {this is to do because award starts calculating with the last letter}
C := S[BYTE(S[0]) - I + 1];
S[BYTE(S[0]) - I + 1] := S[I];
S[I] := C;
Dec(I);
end;
CalcPossiblePassword := S;
end;
function readcmos(off: byte): byte;
var
value: byte;
begin
asm
xor ax, ax
mov al, off
out 70h, al
in al, 71h
mov value, al
end;
readcmos := value;
end;
function My_GetBiosPassword: string;
var
superpw, userpw: word;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then //不是NT
begin
pchar(@superpw)[0] := char(readcmos($1C));
pchar(@superpw) := char(readcmos($1D));
pchar(@userpw)[0] := char(readcmos($64));
pchar(@userpw) := char(readcmos($65));
Result:= (''************BIOS密码**********************'')+#13+''超级用户密码为:'' + CalcPossiblePassword(superpw) + #13 + ''用户密码为:'' + CalcPossiblePassword(userpw);
end
else
Result := ''用户系统为NT,无法获取BIOS密码!'';
end;
end.
如何直接在CBC中使用它呢?新建一个CBC工程,然后把这个单元加到项目里面去.具体操作为:Add to Project--->文件类型:pascal unit(*.pas),然后Build Demo1.这个时候将在AwardBiosPas.pas的同目录下生成一个AwardBiosPas.hpp文件.把它引用到我们的需要调用的单元.然后直接调用即可:
以下是引用片段:
void __fastcall TFrmMain::Button1Click(TObject *Sender)
{
ShowMessage(My_GetBiosPassword());
}
五:其它方法.当然可以用RES将C语言生成的二进制文件,但这个方法与第一种方法差不多.优点是不怕文件丢失.缺点是很容易被别人直接用资源修改工具打开修改.这个时候可以使用笔者写的自制编程序工具PasAnywhere.不过这已经是另外一个话题了.