-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (63 loc) · 2.4 KB
/
main.cpp
File metadata and controls
77 lines (63 loc) · 2.4 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
#include "mod/amlmod.h"
#include "mod/logger.h"
#include "mod/config.h"
//#include "include/Gloss.h"
MYMOD(com.starlit.xconfig, XConfig, 0.14, BengbuGuards)
static Config cfgLocal("XConfig");
Config* cfg = &cfgLocal;
uintptr_t pUE4;
void* hUE4;
#define SYM(sym) (aml->GetSym(hUE4, sym))
#include "types.inl"
#define ForceJump(addr) aml->PlaceB((addr), aml->GetBranchDest(addr))
//GHook (*GlossHookInternalImpl)(void *addr, GlossHookInternalCallback new_func, void *ret_addr, bool is_4_byte_hook, i_set mode);
enum {III=1,VC,SA}nGame;
enum {Netflex=1,Rockstar}nGameType;
enum VERSION{V1_72=1, V1_8X, UNKNOWN}nVer;
int ret0(int a, ...) { return 0; } // Generic
#include "III.inl"
#include "VC.inl"
#include "SA.inl"
namespace UGameterface{
FString (*GetVersionString)();
inline void _Init(){
SET_TO(GetVersionString, SYM("_ZN12UGameterface16GetVersionStringEv"));
}
}
extern "C" void OnModLoad()
{
logger->SetTag("XConfig");
pUE4 = aml->GetLib("libUE4.so");
hUE4 = aml->GetLibHandle("libUE4.so");
if(!pUE4){
logger->Info("Can't find libUE4, unloading...");
return;
}
//SETSYM_TO(GlossHookInternalImpl, aml->GetLibHandle("libAML.so"), "GlossHookInternal");
cfg->Bind("Author", "", "About")->SetString("BengbuGuards, XMDS");
cfg->Bind("Version", "", "About")->SetString("Beta-14");
const char* szGame = aml->GetCurrentGame();
logger->Info("Game %s", szGame);
#define _stricmp strcasecmp
if(!_stricmp(szGame, "com.netflix.NGP.GTASanAndreasDefinitiveEdition"))nGame=SA, nGameType=Netflex;
else if(!_stricmp(szGame, "com.rockstargames.gtasa.de"))nGame=SA, nGameType=Rockstar;
else if(!_stricmp(szGame, "com.netflix.NGP.GTAViceCityDefinitiveEdition"))nGame=VC, nGameType=Netflex;
else if(!_stricmp(szGame, "com.rockstargames.gtavc.de"))nGame=VC, nGameType=Rockstar;
else if(!_stricmp(szGame, "com.netflix.NGP.GTAIIIDefinitiveEdition"))nGame=III, nGameType=Netflex;
else if(!_stricmp(szGame, "com.rockstargames.gta3.de"))nGame=III, nGameType=Rockstar;
/*UGameterface::_Init();
// 判断游戏版本,某些硬编码补丁只适用于1.72,否则闪退 TODO: 使用Pattern
FString sVer = UGameterface::GetVersionString();
char secChar = *((char*)sVer + 4);
if(secChar == '7')nVer = V1_72;
else if(secChar == '8')nVer = V1_8X;
else nVer = UNKNOWN;*/
nVer = V1_8X;
if(nGame == SA)
GTASA::Init();
if(nGame == VC)
ViceCity::Init();
if(nGame == III)
GTA3::Init();
logger->Info("XConfig mod is loaded!");
}