关于c/c++函数的逆向

int deal(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >)(void arg0, void arg1)
这是hopper 反汇编的伪代码 参数 应该是 2个C++ string
在函数开头断点 然后 register read
Purpose Registers:
r0 = 0x11c15ce4
r1 = 0x182242fd
r2 = 0xfffffffd
r0 和 r1 就是对应的参数 ;
p $r0
(unsigned int) $59 = 297884900
像这种c++ 的string类型的参数怎么样才能打印出来呢…

1 个赞

我也遇到这样的代码了
std::__1::basic_string<char,std::__1::char_traits,std::__1::allocator>::reserve();
你后来解决了么

$59 = 297884900这种 怎么打印成string呢

我知道了
po (char*)$r2
这样打印即可
如果是IDA 就 po (char*)$x2即可

我打印出来是
$x16
“\xfffffffag\xffffffbb\xffffffa9\xfffffff8_\x01\xffffffa9\xfffffff6W\x02\xffffffa9\xfffffff4O\x03\xffffffa9\xfffffffd{\x04\xffffffa9\xfffffffd\x03\x01\xffffff91\xffffffffC”

po (char)$x17*
“\x0e\x04\r\x01\x02\x0f\v\b\x03\n\x06\f\x05\t”
不知道他们是怎么加密成了最后的串 这个执行过程有办法看到么

兄弟,你搞定了没有,我也遇到了这个问题

// https://codeshare.frida.re/@oleavr/read-std-string/
    /*
 * Note: Only compatible with libc++, though libstdc++'s std::string is a lot simpler.
 */

function readStdString (str) {
  const isTiny = (str.readU8() & 1) === 0;
  if (isTiny) {
    return str.add(1).readUtf8String();
  }

  return str.add(2 * Process.pointerSize).readPointer().readUtf8String();
}