如何通过调用DLL函数调试特权指令错误?

时间:2012-09-06 08:45:24

标签: delphi debugging dll

我为第三方DLL定义了以下函数,我们无法控制它:

const
  DLL = 'Qarapea.dll';

function QARapid_Open(IniFile: shortstring; Section: shortstring): integer; stdcall; external DLL;
procedure QARapid_EndSearch(); stdcall; external DLL;
function QARapid_Count: integer; stdcall; external DLL;
function QARapid_Search(vs: shortstring): integer; stdcall; external DLL;
function QARapid_FormatAddr(ItemNumber: integer; Buffer: PAnsiChar; BufferSize: integer):     integer; stdcall; external DLL;
procedure QARapid_Close; stdcall; external DLL;

我按以下方式调用函数:

procedure TFormMain.ButtonStaticLookupClick(Sender: TObject);
var
  Res: integer;
  ACode: shortstring;
  IniFile, Section: shortstring;
begin
  try
    ACode := PrepareCode(EditCode.Text);
    IniFile := ExtractFilePath(ParamStr(0)) + 'DllIni.ini';
    Section := 'Default';
    QARapid_Open(IniFile, Section);
    try
      Res := QARapid_Search(ACode);
      Res := QARapid_Count;

    finally
      QARapid_Close;
    end;

  Except on E: Exception do
    MessageDlg(E.Message, mtError, [mbOK], 0);
  end;
end;

在我调用QARapid_Count函数之前,一切似乎都没问题,当我收到以下错误时:

  

QAS.exe出现错误消息:特权指令位于0x0012eff4。   流程停止了。使用步骤或运行继续。

我不知道从哪里开始查找故障,因为CPU调试窗口已打开。

如何追踪出现问题?

1 个答案:

答案 0 :(得分:0)

阅读QuickAddress Rapid API guide,然后相应地修复您的Delphi导入。