-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathMoveExpandFunction.cpp
70 lines (48 loc) · 1.51 KB
/
MoveExpandFunction.cpp
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
#include <iostream>
#include <sstream>
#include "UPKUtils.h"
using namespace std;
int main(int argN, char* argV[])
{
cout << "MoveExpandFunction" << endl;
if (argN < 3 || argN > 4)
{
cerr << "Usage: FindObjectEntry UnpackedResourceFile.upk FunctionName [NewFunctionSize]" << endl;
return 1;
}
UPKUtils package;
if (!package.open(argV[1]))
{
cerr << "Can't open " << argV[1] << endl;
return 1;
}
string NameToFind = argV[2];
cout << "Object name: " << NameToFind << endl;
int idx = package.FindObjectListEntryByName(NameToFind);
if (idx < 1)
{
cerr << "Can't find object entry by name " << NameToFind << endl;
return 1;
}
ObjectListEntry EntryToRead = package.GetObjectListEntryByIdx(idx);
uint32_t newFunctionSize = 0;
cout << "Function size: " << EntryToRead.ObjectFileSize << endl;
if (argN == 4)
{
string str(argV[3]);
istringstream ss(str);
if (str.find("0x") != string::npos)
ss >> hex >> newFunctionSize;
else
ss >> dec >> newFunctionSize;
cout << "Resize function to: " << newFunctionSize << endl;
if (newFunctionSize <= EntryToRead.ObjectFileSize)
{
cerr << "Can't expand function: existing function size is greater than specified value!" << endl;
return 1;
}
}
package.MoveObject(idx, newFunctionSize, true);
cout << "Object moved successfully!" << endl;
return 0;
}