找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2275|回复: 0

[求助] 调用dll里函数的问题

1

主题

1

帖子

1

积分

贫民

积分
1
obian 发表于 2020-5-29 21:34:53 | 显示全部楼层 |阅读模式
我有一个dll的函数,定义:
ULONG SKF_RSAExportSessionKey (HCONTAINER hContainer, ULONG ulAlgId, RSAPUBLICKEYBLOB *pPubKey, BYTE *pbData, ULONG  *pulDataLen, HANDLE *phSessionKey);
在python里该如何调用,我试着以下方式,一直不行,有人有这方面的代码吗?或者帮我看看,主要是c++里的指针之类在python里该如何处理
    def hzfcca_RSAExportSessionKey(self, pPubKey):
        class RSAPUBLICKEYBLOB(Structure):
            _fields_ = [("AlgID", c_ulong),
                        ("BitLen", c_ulong),
                        ("Modulus", c_byte * 256),
                        ("PublicExponent", c_byte * 4)]

        RSAExportSessionKey= self.dll.SKF_RSAExportSessionKey
        RSAExportSessionKey.argtypes = [c_long, c_ulong, POINTER(RSAPUBLICKEYBLOB), POINTER(c_byte), POINTER(c_ulong), POINTER(c_long)]
        RSAExportSessionKey.restype = c_ulong
        ulAlgId = c_ulong(0x00000101)
        pbData = c_byte()
        pbDataLen = c_ulong()
        phSessionKey = c_long(0)
        res = RSAExportSessionKey(c_long(self.hcon), ulAlgId, byref(pPubKey), pbData, pbDataLen, phSessionKey)
        print(pbDataLen)
        print(res)
        if res == 0:
            return True
        else:
            return False

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表