forked from nyouoG/fpt_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpeedHack.py
68 lines (53 loc) · 2.05 KB
/
SpeedHack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from FFxivPythonTrigger import PluginBase, hook, api
from ctypes import *
from FFxivPythonTrigger.AddressManager import AddressManager
from FFxivPythonTrigger.memory import scan_pattern
sig_main = "48 83 EC ?? 80 B9 04 01 00 00 ?? 74"
sig_fly = "40 ?? 48 83 EC ?? 48 8B ?? 48 8B ?? FF 90 ?? ?? ?? ?? 48 85 ?? 75"
command = '@speedH'
class SpeedHookMain(hook.Hook):
restype = c_float
argtypes = [c_int64, c_byte, c_int]
def __init__(self, func_address: int):
super(SpeedHookMain, self).__init__(func_address)
self.percent = 1
def hook_function(self, a1, a2, a3):
return self.original(a1, a2, a3) * self.percent
class SpeedHookFly(hook.Hook):
restype = c_float
argtypes = [c_void_p]
def __init__(self, func_address: int):
super(SpeedHookFly, self).__init__(func_address)
self.percent = 1
def hook_function(self, a1):
return self.original(a1) * self.percent
class SpeedHack(PluginBase):
name = "speed hack"
def __init__(self):
super().__init__()
am=AddressManager(self.storage.data, self.logger)
addrMain = am.get('main',scan_pattern,sig_main)
addrFly = am.get('fly',scan_pattern,sig_fly)
self.storage.save()
self.hook_main = SpeedHookMain(addrMain)
self.hook_fly = SpeedHookFly(addrFly)
self.hook_main.enable()
self.hook_fly.enable()
api.command.register(command, self.process_command)
def _onunload(self):
self.hook_main.uninstall()
self.hook_fly.uninstall()
def process_command(self, args):
api.Magic.echo_msg(self._process_command(args))
def _process_command(self, arg):
try:
if arg[0] == "set":
self.hook_main.percent = float(arg[1])
self.hook_fly.percent = float(arg[1])
return "set to %s" % arg[1]
elif arg[0] == "get":
return self.hook_main.percent
else:
return "unknown arg [%s]" % arg[0]
except Exception as e:
return str(e)