-
Notifications
You must be signed in to change notification settings - Fork 0
/
FunctionManager.cs
98 lines (81 loc) · 2.96 KB
/
FunctionManager.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Magic;
namespace iKick
{
public class FunctionManager
{
private BlackMagic process;
private HookManager aHook;
public FunctionManager(BlackMagic process)
{
this.process = process;
this.aHook = new HookManager(process);
}
public void LuaDoString(string command)
{
int nSize = command.Length + 0x100;
uint codeCave = process.AllocateMemory(nSize);
uint moduleBase = (uint)process.MainModule.BaseAddress;
process.WriteASCIIString(codeCave, command);
process.Asm.Clear();
String[] asm = new String[]
{
"mov eax, " + codeCave,
"push 0",
"push eax",
"push eax",
"mov eax, " + (moduleBase + Offsets.Endscene.Lua_DoStringAddress),
"call eax",
"add esp, 0xC",
"retn",
};
aHook.InjectAndExecute(asm);
process.FreeMemory(codeCave);
}
public string GetLocalizedText(string command)
{
int nSize = command.Length + 0x100;
uint codeCave = process.AllocateMemory(nSize);
uint moduleBase = (uint)process.MainModule.BaseAddress;
var ClntObjMgrGetActivePlayerObj = moduleBase + Offsets.Endscene.ClntObjMgrGetActivePlayerObjAddress;
var FrameScript__GetLocalizedText = moduleBase + Offsets.Endscene.Lua_GetLocalizedTextAddress;
process.WriteASCIIString(codeCave, command);
String[] asm = new String[]
{
"call " + ClntObjMgrGetActivePlayerObj,
"mov ecx, eax",
"push -1",
"mov edx, " + codeCave + "",
"push edx",
"call " + FrameScript__GetLocalizedText,
"retn",
};
string sResult = Encoding.ASCII.GetString(aHook.InjectAndExecute(asm));
process.FreeMemory(codeCave);
return sResult;
}
public void InteractGameObject(uint baseAddress)
{
uint InteractVMT = 45;
if (baseAddress > 0)
{
uint VMT44 = process.ReadUInt(process.ReadUInt(baseAddress) + ((uint)InteractVMT * 4));
var objectManagerBase = 0x463C;
string[] asm = new string[]
{
"fs mov eax, [0x2C]",
"mov eax, [eax]",
"add eax, 0x10",
"mov dword [eax], " + objectManagerBase,
"mov ecx, " + baseAddress,
"call " + VMT44,
"retn",
};
aHook.InjectAndExecute(asm);
}
}
}
}