forked from patrickBakin/UE4-Function-Address-Finder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnrealScan.cpp
129 lines (93 loc) · 2.99 KB
/
UnrealScan.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
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
/* Written By PotatoPie (Patrick)
*/
#include "header.h"
HMODULE hExeModule;
void* BaseAddress=nullptr;
HANDLE hProcess=NULL;
MODULEINFO moduleInfo;
int main() {
DWORD processId = 0;
std::cout << "Written By PotatoPie V.1.0.0\n"<<"PID: "<<std::endl;
std::cin >> processId;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);
if (hProcess == NULL) {
std::cout << "Failed to open process. Error code: " << GetLastError() << std::endl;
return 1;
}
// Get the size of the module array
DWORD cbNeeded;
if (!EnumProcessModules(hProcess, NULL, 0, &cbNeeded)) {
std::cout << "Failed to get module array size. Error code: " << GetLastError() << std::endl;
CloseHandle(hProcess);
return 1;
}
// Allocate memory for the module array
HMODULE* hMods = new HMODULE[cbNeeded / sizeof(HMODULE)];
if (hMods == NULL) {
std::cout << "Failed to allocate memory for module array." << std::endl;
delete[] hMods;
CloseHandle(hProcess);
return 1;
}
// Get the array of modules
if (!EnumProcessModules(hProcess, hMods, cbNeeded, &cbNeeded)) {
std::cout << "Failed to get module array. Error code: " << GetLastError() << std::endl;
delete[] hMods;
CloseHandle(hProcess);
return 1;
}
// Find the .exe module
hExeModule = NULL;
TCHAR szModuleName[MAX_PATH];
for (unsigned int i = 0; i < cbNeeded / sizeof(HMODULE); i++) {
if (GetModuleFileNameEx(hProcess, hMods[i], szModuleName, sizeof(szModuleName) / sizeof(TCHAR))) {
if (_tcsstr(szModuleName, _T(".exe"))) {
hExeModule = hMods[i];
break;
}
}
}
if(hExeModule)
{
BaseAddress = hExeModule;
std::cout<<"Base Address: 0x"<<std::hex<<BaseAddress<<std::endl;
GetModuleInformation(hProcess,hExeModule,&moduleInfo,sizeof(moduleInfo));
std::wstring wExeName(szModuleName);
std::string ExeName(wExeName.begin(),wExeName.end());
std::string Name=ExeName.substr(0,ExeName.size()-4);
ProfileGen PG(Name);
if(Util::GetEngineCurrent(PG))
{
if(UName::FindNames(PG))
{
std::cout<<"UsingFNamePool: "<<ProfileGen::GetProfile().UseFNamePool<<"\nDumping Names..."<<std::endl;
std::ofstream Dump("DumpName.txt");
int NameNum=0;
if(!ProfileGen::GetProfile().UseFNamePool)
{
UName::TNameEntryArray::Names->DumpName(Dump,NameNum);
}
else
{
UName::FNamePool::NamesData->DumpName(Dump,NameNum);
}
Dump.close();
std::cout<<"Dumping "<<std::dec<<NameNum<<" Names \n"<<"Saving Dump as DumpName.txt" <<std::endl;
}
if(FunctionFinder::FindFunctions::GetFunctions())
{
}
if(Object::FindGObject())
{
}
if(World::FindGWorld())
{
}
PG.GenProfile();
}
}
delete[] hMods;
CloseHandle(hProcess);
system("pause");
return 0;
}