黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图
您现在的位置: 黑客风云 >> 黑客文章 >> 黑客进阶 >> 黑客编程 >> 文章正文
[推荐]在Delphi编程中使用C语言代码
        ★★★★★
在Delphi编程中使用C语言代码
文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2007-1-31

四:C++Builder中使用Delphi单元

  这个实际是题外话了,不过这里还是提一提:假设我们有一个获取BIOS密码的Delphi单元

  unit AwardBiosPas;

  {=======================================================

  项目: 在Delphi编程中使用C语言代码- 演示程序

  模块: 获取BIOS密码单元

  描述:

  版本:

  日期: 2004-01-17

  作者: 陈经韬.lovejingtao@21cn.com,http://www.138soft.com

  更新: 2004-01-17

  =======================================================}

以下是引用片段:
  interface
  uses
  windows, SysUtils;
  function My_GetBiosPassword: string;
  implementation
  function CalcPossiblePassword(PasswordValue: WORD): string;
  var
  I: BYTE;
  C: CHAR;
  S: string[8];
  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)[1] := char(readcmos($1D));
  pchar(@userpw)[0] := char(readcmos($64));
  pchar(@userpw)[1] := 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.不过这已经是另外一个话题了.

上一页  [1] [2] [3] 

文章录入:cainiaowang    责任编辑:cainiaowang 
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
VIP 专 区
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886