-
Notifications
You must be signed in to change notification settings - Fork 5
/
C_lib.txt
210 lines (198 loc) · 5.5 KB
/
C_lib.txt
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
//Hey ! I know what you are thinking!
//Dont worry those functions are here for reference and never hurt nobody.
inline char*ReadBinaryFile(const string&f)
{
FILE*F = fopen(f.c_str(),"rb");
if(!F)
{
printf("\nCan't find \"%s\".\n",f);
exit(1);
}
unsigned n;
fseek(F,0,SEEK_END);
n = ftell(F);
rewind(F);
char*s = new char[n+1];
fread(s,1,n,F);
fclose(F);
s[n]=0;
return s;
}
string ReadTextFile(string f)
{
const char *f_char = f.c_str();
FILE*F = fopen(f_char,"rb");
if(!F)
{
printf("\nCan't find \"%s\".\n",f);
exit(1);
}
unsigned n;
fseek(F,0,SEEK_END);
n = ftell(F);
rewind(F);
char*s = new char[n+1];
fread(s,1,n,F);
fclose(F);
s[n]=0;
return s;
}
inline unsigned WriteBinaryFile(const char*f,const char*s, const int a, int bytes, const char*m="r+wb")
{
FILE*F = fopen(f,m);
fseek(F, a, SEEK_SET);
cout<<"Patch in: "<<hex<<a<<endl;
if(!F)
{
printf("\nCan't open \"%s\".\n",f);
cin.get();
exit(1);
}
unsigned n = fwrite(s,sizeof(char),bytes,F);
fclose(F);
cout<<"Number of instructions written: "<<n<<endl;
return n;
}
inline vector<char*> Parse(char*s,const char*d=" ,\t\n\f\r")
{
std::vector<char*>V;
for(s=strtok(s,d); s; s=strtok(0,d))
{
V.push_back(s);
}
return V;
}
char* appendCharToCharArray(char* array, char a)
{
size_t len = strlen(array);
char* ret = new char[len+2];
strcpy(ret, array);
ret[len] = a;
ret[len+1] = '\0';
return ret;
}
int v2; // esi
struct lua_State *v3; // eax
_DWORD *v4; // eax
bool v5; // al
bool v6; // zf
int v7; // eax
int v8; // edi
uint32 *v9; // eax
struct Moho__SSTICommandIssueData *v10; // esi
int v11; // eax
int v12; // xmm0_4
struct lua_State *v13; // eax
volatile int v14; // eax
struct Moho__CUnitCommand *v15; // esi
volatile int v17; // [esp-8h] [ebp-138h]
struct lua_State *v18; // [esp-4h] [ebp-134h]
bool v19; // [esp+Fh] [ebp-121h]
volatile signed int *v20; // [esp+10h] [ebp-120h]
volatile int v21; // [esp+14h] [ebp-11Ch]
volatile int v22; // [esp+18h] [ebp-118h]
int *v23; // [esp+1Ch] [ebp-114h]
volatile char *v24; // [esp+20h] [ebp-110h]
volatile char *v25; // [esp+24h] [ebp-10Ch]
volatile int *v26; // [esp+28h] [ebp-108h]
volatile char *v27; // [esp+2Ch] [ebp-104h]
volatile char v28; // [esp+30h] [ebp-100h]
int v29; // [esp+40h] [ebp-F0h]
int v30; // [esp+44h] [ebp-ECh]
int v31; // [esp+48h] [ebp-E8h]
int v32; // [esp+4Ch] [ebp-E4h]
int v33; // [esp+50h] [ebp-E0h]
int v34; // [esp+54h] [ebp-DCh]
int v35; // [esp+58h] [ebp-D8h]
int v36; // [esp+5Ch] [ebp-D4h]
int v37; // [esp+60h] [ebp-D0h]
int v38; // [esp+64h] [ebp-CCh]
volatile int v39; // [esp+68h] [ebp-C8h]
uint32 *v40; // [esp+6Ch] [ebp-C4h]
int v41; // [esp+70h] [ebp-C0h]
int v42; // [esp+7Ch] [ebp-B4h]
_DWORD v43; // [esp+90h] [ebp-A0h]
volatile int v44; // [esp+12Ch] [ebp-4h]
register int esp asm("esp");
register int ecx asm("ecx");
register int edx asm("edx");
register int ebx asm("ebx");
register int esi asm("esi");
v2 = dword_10B83A4;
v3 = (struct lua_State *)Fd.lua_gettop(*a1);
if (v3 != (struct lua_State *)2)
Fd.LuaState__Error((struct LuaState*)a1, (char*)"%s\n expected %d args, but got %d", v2, 2, v3);
v23 = &v22;
v22 = (int)&v22;
v24 = &v28;
v25 = &v28;
v26 = &v29;
v27 = &v28;
v44 = 0;
v20 = (signed int *)a1;
v21 = 1;
v4 = Fd.Eval_Lua_Object(&v39, (const struct LuaStackObject*)&v20, (struct LuaState*)a1, (int)"IssueMove"); //unit table param from lua
//LOBYTE(v44) = 1;
v5 = gft.Validate_IssueCommand((int) v4, (int)&v22, 1);
//LOBYTE(v44) = 0;
//v19 = v5;
if (v41 != v42)
Fd.j_shi_delete_0(v41);
v6 = v5 == 0;
//*(_DWORD *)(v39 - 4) = v40;
//*v40 = v39;
if (v6)
goto LABEL_21;
v20 = &v17;
v7 = Fd.__Get_Lua_Coordinates_Statew(&v39,(struct LuaState*)a1,(int)"IssueMove",a1,2);
Fd.__Push_Coordinatesw((int)&v29, v7);
v8 = v29;
v36 = v31;
v35 = v30;
//v9 = v40;
//v37 = v32;
// v34 = v29;
// v38 = v33;
if (edx!=0)
{
//This never supposed to happen.
Fd.LuaState__Error((struct LuaState*)a1, (char*)"IssueMove: Floats for coordinates are not found!");
/* if ((_DWORD ** ) * v40 != & v40) {
do
v9 = (_DWORD*)(*v9 + 4);
while ((_DWORD **) * v9 != & v40);
}
*v9 = v41; */
}
if (!(unsigned __int8) gft.nanTest((float*)& v36) || !v8)
Fd.LuaState__Error((struct LuaState*)a1, "IssueMove: Passed in an invalid target point.");
v10 = (struct Moho__SSTICommandIssueData*) Fd.Moho_SSTICommandIssueData_SSTICommandIssueData(&v43,2);
LOBYTE(v44) = 2;
v11 = v30;
v12 = v31;
*((_DWORD *)v10 + 4) = v8;
*((_DWORD *)v10 + 5) = v11;
v13 = *a1;
*((_DWORD *)v10 + 6) = v12;
*((_DWORD *)v10 + 7) = v32;
v18 = v13;
*((_DWORD *)v10 + 8) = v33;
v14 = Fd.lua_getglobaluserdata(v18);
v15 = Fd.Moho_UNIT_IssueCommandw((int)&v22, v14, v10, 0);
LOBYTE(v44) = 0;
Fd.Moho_SSTICommandIssueData_Destructor_SSTICommandIssueData((struct Moho__SSTICommandIssueData*)&v43);
if (!v15)
{
LABEL_21:
Fd.LuaPlus_LuaState_PushNil(*a1);
Fd.lua_gettop(*a1);
if (v24 != v27)
Fd.j_shi_delete_0(v24);
*(_DWORD *)(v22 + 1) = (int) v23;
*v23 = v22;
}
else {
Fd.LuaPlus_LuaObject_PushStack((_DWORD * )(v15 + 32), v20, a1);
gft.sub_5796A0(v22);
}
return 1;