急!!EAccessViolation问题——100分,不够再加(100分)

  • 主题发起人 主题发起人 illcat
  • 开始时间 开始时间
I

illcat

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用的是下面这个函数:<br>CryptSignAndEncryptMessage(@SignPara,@EncryptPara,cRecipientCert,<br>&nbsp; &nbsp; &nbsp; &nbsp;rgpRecipientCert,pbTobeSignAndEncrypt,cbTobeSignAndEncrypt,<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,@cbSignedAndEncryptedBlob)<br>其中所有的变量都是已经定义过的,而且我跟踪调试的时候所有的值都对,可是<br>出现下面的问题:Access violation at address 7742FFCA in module 'crypt32.dll'.<br>Read of address 00000000.<br>
 
可能是dll未load進內存,以下代碼供參考:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var Handle: THandle;<br>begin<br>&nbsp; Handle := LoadLibrary('e:/windows/system/crypt32.dll');<br>&nbsp; if Handle &lt;&gt; 0 then<br>&nbsp; begin<br>&nbsp; &nbsp; @yourprocedure := GetProcAddress(Handle, 'CryptSignAndEncryptMessage');<br>&nbsp; &nbsp; if @yourprocedure&lt;&gt;nil then <br>&nbsp; &nbsp; yourprocedure(@SignPara,@EncryptPara,cRecipientCert,<br>&nbsp; &nbsp; &nbsp; &nbsp;rgpRecipientCert,pbTobeSignAndEncrypt,cbTobeSignAndEncrypt,<br>&nbsp; &nbsp; &nbsp; &nbsp;nil,@cbSignedAndEncryptedBlob);<br>&nbsp; &nbsp; FreeLibrary(Handle);<br>&nbsp; end;<br>end;
 
函数类型声明可能不对!
 
不应该啊,因为我在引用这个函数之前,我还引用了<br>crypt32.dll中的其他函数啊。。。<br><br>要说类型声明的话,不可能不对。。。
 
yourprocedure 是个什么类型的?在哪里定义?
 
只要DLL没问题,这种情况一般都是函数声明的问题!!!<br>你把原来的函数声明贴出来。<br>因为你的这个函数涉及指针的问题。
 
就是下面的了,麻烦你看看啦<br>function CryptSignAndEncryptMessage(pSignPara :PCRYPT_SIGN_MESSAGE_PARA;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pEncryptPara :PCRYPT_ENCRYPT_MESSAGE_PARA;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cRecipientCert :DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rgpRecipientCert :array of PCCERT_CONTEXT;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const pbToBeSignedAndEncrypted :PBYTE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cbToBeSignedAndEncrypted :DWORD;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pbSignedAndEncryptedBlob :PBYTE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pcbSignedAndEncryptedBlob :PDWORD<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ) :BOOL ; stdcall;
 
stdcall改为cdecl试一下,涉及到堆栈的清除者是谁。<br>cdecl代表由调用者清除
 
楼上的,我试了一下,还是不行,同样的问题。<br>难道真的是传送的参数指针有问题吗?<br>
 
赶紧啊,大家救命啊。。。。
 
高人们,帮帮忙吧。。。。
 
问题太久了,结了
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
977
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部