首页
社区
课程
招聘
[原创]使用SandboxiePlus加速植物大战僵尸游戏
发表于: 2025-4-20 16:30 5208

[原创]使用SandboxiePlus加速植物大战僵尸游戏

2025-4-20 16:30
5208

前几天偶然发现一篇使用变速齿轮来加速植物大战僵尸的文章,这几天在研究SandboxiePlus的源码,其中也有加速的设置,但加速部分的代码写的很乱。举个例子:

上述的代码是SleepEx的hook函数。按照changelog中介绍,AddSleepSpeed和LowSleepSpeed分别表示加速和降速的配置,AddSleepSpeed/LowSleepSpeed表示加速倍数,但上述的SleepEx hook函数中dwMiSecond * add / low其实增加了SleepEx的数值,正确应该修改为dwMiSecond * low / add。本文将变速齿轮的加速原理移植到SandboxiePlus中,实现了植物大战僵尸游戏的加速。

我使用的变速齿轮中有三个文件,分别是:GearNT.exe、GearNTKe.dll和Hook.dll。其中加速部分的实现在GearNTKe.dll中,该DLL中hook了六个函数,如下:

上述函数可以分为两类:

SandboxiePlus的代码已经实现了hook功能,我们所要做的就是实现上述的hook函数即可。

注意:QueryPerformanceCounter使用的是一个64位值,使用"t + (tt - t) * 加速倍数"可能会出现溢出,使用SandboxiePlus原来的hook函数。

通过修改SandboxiePlus的SboxDll,实现了和变速齿轮相同的加速效果,理论上变速齿轮加速的软件,现在的SandboxiePlus都可以加速。成品可以在"安全狗的开发日常"公众号中回复PlantsVsZombie关键字获取相关文件的下载链接,文件下载后替换SandboxiePlus安装目中的文件即可。

_FX DWORD Kernel_SleepEx(DWORD dwMiSecond, BOOL bAlert)
{
    ULONG add = SbieApi_QueryConfNumber(NULL, L"AddSleepSpeed", 1);
    ULONG low = SbieApi_QueryConfNumber(NULL, L"LowSleepSpeed", 1);
    if (add != 0 && low != 0)
        return __sys_SleepEx(dwMiSecond * add / low, bAlert);
    return __sys_SleepEx(dwMiSecond, bAlert);
}
_FX DWORD Kernel_SleepEx(DWORD dwMiSecond, BOOL bAlert)
{
    ULONG add = SbieApi_QueryConfNumber(NULL, L"AddSleepSpeed", 1);
    ULONG low = SbieApi_QueryConfNumber(NULL, L"LowSleepSpeed", 1);
    if (add != 0 && low != 0)
        return __sys_SleepEx(dwMiSecond * add / low, bAlert);
    return __sys_SleepEx(dwMiSecond, bAlert);
}
// kernel32.dll
DWORD GetTickCount();
BOOL QueryPerformanceCounter([out] LARGE_INTEGER *lpPerformanceCount);
// user32.dll
LONG GetMessageTime();
UINT_PTR SetTimer([in, optional] HWND hWnd, [in] UINT_PTR  nIDEvent,
  [in] UINT uElapse, [in, optional] TIMERPROC lpTimerFunc);
// winmm.dll
DWORD timeGetTime();
MMRESULT timeSetEvent(UINT  uDelay, UINT  uResolution,
  LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT  fuEvent);
// kernel32.dll
DWORD GetTickCount();
BOOL QueryPerformanceCounter([out] LARGE_INTEGER *lpPerformanceCount);
// user32.dll
LONG GetMessageTime();
UINT_PTR SetTimer([in, optional] HWND hWnd, [in] UINT_PTR  nIDEvent,
  [in] UINT uElapse, [in, optional] TIMERPROC lpTimerFunc);
// winmm.dll
DWORD timeGetTime();
MMRESULT timeSetEvent(UINT  uDelay, UINT  uResolution,
  LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT  fuEvent);
_FX UINT_PTR Gui_SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
{
    ULONG add = SbieApi_QueryConfNumber(NULL, L"AddTimerSpeed", 1), low = SbieApi_QueryConfNumber(NULL, L"LowTimerSpeed", 1);
    if (add != 0 && low != 0) {
        UINT64 newElapse = uElapse;
        newElapse = newElapse * low / add;
          return __sys_SetTimer(hWnd, nIDEvent, (UINT)newElapse, lpTimerFunc);
    }
    return 0;
}
_FX UINT_PTR Gui_SetTimer(HWND hWnd, UINT_PTR nIDEvent, UINT uElapse, TIMERPROC lpTimerFunc)
{
    ULONG add = SbieApi_QueryConfNumber(NULL, L"AddTimerSpeed", 1), low = SbieApi_QueryConfNumber(NULL, L"LowTimerSpeed", 1);
    if (add != 0 && low != 0) {
        UINT64 newElapse = uElapse;
        newElapse = newElapse * low / add;
          return __sys_SetTimer(hWnd, nIDEvent, (UINT)newElapse, lpTimerFunc);
    }
    return 0;
}
_FX MMRESULT Wimm_timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
{
  ULONG add = SbieApi_QueryConfNumber(NULL, L"AddTimerSpeed", 1), low = SbieApi_QueryConfNumber(NULL, L"LowTimerSpeed", 1);
    if (add != 0 && low != 0) {
    UINT64 newDelay = uDelay;
    newDelay = newDelay * low / add;
    return __sys_timeSetEvent((UINT)newDelay, uResolution, lpTimeProc, dwUser, fuEvent);
  }
 
  return 0;
}
_FX MMRESULT Wimm_timeSetEvent(UINT uDelay, UINT uResolution, LPTIMECALLBACK lpTimeProc, DWORD_PTR dwUser, UINT fuEvent)
{
  ULONG add = SbieApi_QueryConfNumber(NULL, L"AddTimerSpeed", 1), low = SbieApi_QueryConfNumber(NULL, L"LowTimerSpeed", 1);
    if (add != 0 && low != 0) {
    UINT64 newDelay = uDelay;
    newDelay = newDelay * low / add;
    return __sys_timeSetEvent((UINT)newDelay, uResolution, lpTimeProc, dwUser, fuEvent);
  }
 
  return 0;
}

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 4
支持
分享
最新回复 (11)
雪    币: 5205
活跃值: (5430)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
SandboxiePlus的SboxDll  hook目标程序会被crc校验不
2025-4-21 22:43
0
雪    币: 5564
活跃值: (4573)
能力值: ( LV13,RANK:300 )
在线值:
发帖
回帖
粉丝
3
木志本柯 SandboxiePlus的SboxDll hook目标程序会被crc校验不
不会的
2025-4-22 08:28
0
雪    币: 5564
活跃值: (4573)
能力值: ( LV13,RANK:300 )
在线值:
发帖
回帖
粉丝
4
上面的代码已经合并到SandboxiePlus代码的主分支,后续的新版本会包含加速功能。39eK9s2c8@1M7s2y4Q4x3@1q4Q4x3V1k6Q4x3V1k6Y4K9i4c8Z5N6h3u0Q4x3X3g2U0L8$3#2Q4x3V1k6K6j5h3&6V1j5X3!0^5K9h3g2Q4x3X3c8H3L8s2g2K6i4K6u0r3f1$3q4F1k6r3u0G2P5r3W2W2i4K6u0r3j5$3!0E0L8h3W2@1i4K6u0r3z5h3b7K6x3K6l9%4j5K6W2S2x3e0R3H3z5o6W2S2k6o6x3@1y4$3c8V1x3h3u0S2x3e0M7H3x3e0u0S2j5U0j5J5x3K6f1@1x3e0f1$3j5R3`.`.
2025-4-22 08:29
0
雪    币: 1567
活跃值: (2046)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
Mark
2025-4-22 09:08
0
雪    币: 10292
活跃值: (3147)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
mark
2025-4-27 15:13
0
雪    币: 33
活跃值: (805)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
7
太强了大佬
2025-4-27 17:12
0
雪    币: 24
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
8
有大佬可以帮忙追回被骗的钱吗,差不多被骗了七万多,报酬好说
2025-4-30 15:54
0
雪    币: 5564
活跃值: (4573)
能力值: ( LV13,RANK:300 )
在线值:
发帖
回帖
粉丝
9
mb_cirblqqg 有大佬可以帮忙追回被骗的钱吗,差不多被骗了七万多,报酬好说
估计不行,出谋划策可以细聊
2025-5-1 09:51
0
雪    币: 24
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
10
baolongshou 估计不行,出谋划策可以细聊
大佬,方便聊聊吗
6天前
0
雪    币: 5564
活跃值: (4573)
能力值: ( LV13,RANK:300 )
在线值:
发帖
回帖
粉丝
11
可以,关注公众号后台私信我。
6天前
0
雪    币: 5564
活跃值: (4573)
能力值: ( LV13,RANK:300 )
在线值:
发帖
回帖
粉丝
12
mb_cirblqqg 大佬,方便聊聊吗
可以,关注公众号,后台私信我。
6天前
0
游客
登录 | 注册 方可回帖
返回