Skip to content

时间回放的原理

Mingliang Tan edited this page Feb 20, 2019 · 2 revisions

原理就是用 libc 钩子拦截了和时间相关的系统调用。

最初使用的是 https://github.com/wolfcw/libfaketime

后来我们重写了 time_hook.cpp。回放的时候当拿到了剧本之后,根据回放所需的时间和当前时间,计算一个偏移量(负多少秒)。然后每次查询系统时间的时候,加上这个偏移量。

  • gettimeofday
  • clock_gettime
  • time
  • ftime
Clone this wiki locally