简体   繁体   English

指向Cycript中C ++函数的指针

[英]Pointer to C++ function in Cycript

In cycript, it is possible to get a reference to a c function pointer , but I've been unable to use that syntax to retrieve a pointer to c++ functions using either their proper or mangled function names from the symbol table. 在cycript中,可以获取对c函数指针的引用,但是我一直无法使用该语法从符号表中使用其正确的或错误的函数名称来检索指向c ++函数的指针。

Is there a way to get there from here? 有没有办法从这里到达那里?

Update: 更新:

Update from Saurik's Input: 来自Saurik输入的更新:

I hadn't tried function pointers from the c style symbols, but you are absolutely right that the leading underscore needs to be stripped. 我没有尝试使用c样式符号中的函数指针,但是您绝对正确的是,需要删除开头的下划线。 _DES_encrypt3 needs to be accessed with: _DES_encrypt3需要通过以下方式访问:

cy# dlsym(RTLD_DEFAULT, "DES_encrypt3")
0x14dc19

This gives me a valid pointer address. 这给了我一个有效的指针地址。

When I look at the mangled symbol for xmpp::CapsManager::~CapsManager(), which is __ZN4xmpp11CapsManagerD2Ev_1bf718, I try 当我查看xmpp :: CapsManager :: ~~ CapsManager()的乱码时,它是__ZN4xmpp11CapsManagerD2Ev_1bf718,我尝试

cy# dlsym(RTLD_DEFAULT, "__ZN4xmpp11CapsManagerD2Ev_1bf718")
null
cy# dlsym(RTLD_DEFAULT, "_ZN4xmpp11CapsManagerD2Ev_1bf718")
null
cy# dlsym(RTLD_DEFAULT, "ZN4xmpp11CapsManagerD2Ev_1bf718")
null

None of these variations yield a pointer. 这些变化都不产生指针。

My immediate guess is that you are trying to take the raw mangled symbol name (as you describe, getting it from the symbol table), passing it to dlsym... but dlsym requires a C-level symbol name, which means your approach would not work even for a simple C symbol: you will have an extra _ at the beginning (if you check the symbol table, you will see that C functions are also mangled, to begin with _). 我的直接猜测是,您正在尝试获取原始的错误的符号名称(如您所描述的那样,从符号表中获取它),然后将其传递给dlsym ...但是dlsym需要一个C级符号名称,这意味着您的方法会即使对于简单的C符号也不起作用:您将在开头加一个_(如果检查符号表,您会发现C函数也以_开头被修饰了)。 If you strip the leading _ you should be able to use dlsym to look up your mangled C++ symbol. 如果删除前导_,则应该可以使用dlsym查找损坏的C ++符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM