-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVENI_SMART_MONOIL2CPP_INVOKER.lua
More file actions
172 lines (134 loc) · 3.79 KB
/
VENI_SMART_MONOIL2CPP_INVOKER.lua
File metadata and controls
172 lines (134 loc) · 3.79 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
local al = getAddressList()
function checkMod(n)
if not getProcessIDFromProcessName then return false end
local mods = enumModules(getOpenedProcessID())
if mods == nil then return false end
for i, m in pairs(mods) do
if string.lower(m.Name) == string.lower(n) then
return true
end
end
return false
end
print(">> veni tool init")
if getOpenedProcessID() == 0 then
print("!! attach first")
return
end
if checkMod("mono.dll") or checkMod("mono-2.0-bdwgc.dll") then
elseif checkMod("GameAssembly.dll") then
else
print("!! no mono or il2cpp found")
end
if LaunchMonoDataCollector() == 0 then
print("!! launch collector fail")
return
end
local ns = inputQuery("Veni Invoker", "namespace", "")
if ns == nil then return end
local cls = inputQuery("Veni Invoker", "class", "Player")
if cls == nil then return end
local hMeth = inputQuery("Veni Invoker", "hook method", "Update")
if hMeth == nil then return end
local iMeth = inputQuery("Veni Invoker", "invoke method", "AddGold")
if iMeth == nil then return end
local midH = mono_findMethod(ns, cls, hMeth)
local midI = mono_findMethod(ns, cls, iMeth)
if midH == 0 or midI == 0 then
print("!! method not found")
return
end
local addr = mono_compile_method(midH)
if addr == 0 then print("!! compile fail") return end
local tName = cls .. "_" .. hMeth
registerSymbol(tName, addr)
local hSz = 0
local cSz = 0
while cSz < 5 do
local sz = getInstructionSize(addr + cSz)
cSz = cSz + sz
end
hSz = cSz
local bts = readBytes(addr, hSz, true)
local dbStr = ""
for i, b in ipairs(bts) do
dbStr = dbStr .. string.format("%02X ", b)
end
local sym = "veni_instance_" .. cls
local scr = [[
// =====================================================
// Target: ]] .. cls .. [[.]] .. hMeth .. [[
// Made by: Veni (Discord: ._.veni._.)
// =====================================================
[ENABLE]
alloc(newmem, 2048, ]] .. tName .. [[)
label(returnhere)
label(originalcode)
label(]] .. sym .. [[)
registersymbol(]] .. sym .. [[)
newmem:
pushfq
push rax
mov rax, ]] .. sym .. "\n" .. [[
cmp qword ptr [rax], 0
jne @f
mov [rax], rcx
@@:
pop rax
popfq
originalcode:
db ]] .. dbStr .. "\n" .. [[
jmp returnhere
]] .. sym .. [[:
dq 0
]] .. tName .. [[:
jmp newmem
]] .. (hSz > 5 and "nop " .. (hSz - 5) or "") .. [[
returnhere:
[DISABLE]
]] .. tName .. [[:
db ]] .. dbStr .. [[
unregistersymbol(]] .. sym .. [[)
dealloc(newmem)
]]
local mr = al.createMemoryRecord()
mr.Description = "[ " .. cls .. " ] Instance Hook (Made by Veni)"
mr.Type = vtAutoAssembler
mr.Script = scr
mr.Color = 0x0080FF
local disp = al.createMemoryRecord()
disp.Description = "-> Instance Address"
disp.Address = sym
disp.Type = vtQword
disp.ShowAsHex = true
disp.appendToEntry(mr)
local invScr = [[
local addr = getAddress("]] .. sym .. [[")
if addr == 0 then
print("!! enable hook first")
return
end
local inst = readQword(addr)
if inst == 0 or inst == nil then
print("!! instance null wait for game update")
return
end
local aStr = inputQuery("Veni Invoker", "arguments for ]] .. iMeth .. [[\n(comma separated eg: 100, 'test')", "")
if aStr == nil then return end
local args = {}
if aStr ~= "" then
local f = load("return {" .. aStr .. "}")
if f then args = f() end
end
print(">> invoking ]] .. iMeth .. [[...")
local dom = mono_enumDomains()[1]
mono_invoke_method(dom, ]] .. midI .. [[, inst, args)
print(">> done")
]]
local inv = al.createMemoryRecord()
inv.Description = ">> INVOKE: " .. iMeth
inv.Type = vtAutoAssembler
inv.Script = "[ENABLE]\n{$lua}\n" .. invScr .. "\n{$asm}\n[DISABLE]\n"
inv.Color = 0x00FF00
inv.appendToEntry(mr)
print(">> script gen success")