C调用函数类型错误

C call function type error

我正在尝试编译这段代码,它从 "libcfmapi.so" 调用 func 来解密 "cfg" 文件

#include <stdlib.h>
#include <stdio.h>
int restorebackup(const char *tmp_cfg_name,const char *xml_cfg_name);
int ATP_CFM_ExtCustomImportEncryptedUserCfgFile(const char *tmp_cfg_name);
int main(int argc, char **argv)
{
int ret;
if(argc < 3)
{
printf("specify temp config file name.\n");
exit(1);
}
ret=restorebackup(argv[1],argv[2]);
return ret;
}
int restorebackup(const char *tmp_cfg_name,const char *xml_cfg_name)
{
int ret=0;
//ret = ATP_CFM_ExtDigVerifyFile(tmp_cfg_name,tmp_cfg_name);
if(ret != 0)
{
printf("Verify File failed.\n");
return ret;
}
ret = ATP_CFM_ExtCustomImportEncryptedUserCfgFile(tmp_cfg_name);
return ret;
}

但是关于 func 类型声明有错误

root@kali:~/debian-qemu# gcc  h.c   -o demo
    /tmp/ccVbt5NT.o: In function `restorebackup':
    h.c:(.text+0x8c): undefined reference to `ATP_CFM_ExtCustomImportEncryptedUserCfgFile'
    collect2: error: ld returned 1 exit status

感谢任何帮助

您收到此错误的原因是您没有链接到所需的库,libcfmapi.so

这不是您希望在您的 Debian 系统中找到的库,因为它对于您要破解的 BT 设备来说是独一无二的。

简而言之 - 从您的设备获取库,根据您从设备中提取的库交叉编译到设备架构,您应该没问题。

使用库时,必须:

  1. 通过

    在 link 语句中包含该库

    -l cfmapi

  2. 在源代码中包含该库的头文件:

    #include <cfmapi.h>

基于 Ishay Peled 回答的更多信息:

readelf -s <pulled library> | grep ATP_CFM_ExtCustomImportEncryptedUserCfgFile

我怀疑问题不是您调用的函数不存在,而是没有显示任何函数它很可能是空的,就像 nm 结果一样:

nm: libcfmapi.so: no symbols

不通过管道传输到 grep 执行命令,我敢打赌你的输出是:

readelf -s libcfmapi.so

Dynamic symbol information is not available for displaying symbols.

如果有人知道从文件中获取 headers 的方法,我相信您可以找到您需要的函数,然后 link 和 运行(我也在尝试使用 libcfmapi.so,但缺乏所需的 programming/reversing 知识)。