作者:creantan 小葡萄爸爸
游戏助手(如XX助手)有一项游戏加速功能,实现原理其实非常简单,直接hook gettimeofday。
实现tweak代码如下:
// speedup.xm
// create by creantan on 14-10-23
static int (*orig_gettimeofday)(struct timeval * __restrict, void * __restrict);
static int mygettimeofday(struct timeval*tv,struct timezone *tz ) {
int ret = orig_gettimeofday(tv,tz);
if (ret == 0) {
tv->tv_usec *= SPEEDLEVEL;
tv->tv_sec *= SPEEDLEVEL;
}
return ret;
}
%ctor {
MSHookFunction((void *)MSFindSymbol(NULL,"_gettimeofday"), (void *)mygettimeofday, (void **)&orig_gettimeofday);
}
网友评论