1
0
mirror of synced 2024-11-15 07:17:35 +01:00

Merge pull request #1 from ghkkk090/master

WMMT stuff
This commit is contained in:
dmr 2022-10-10 15:39:43 +07:00 committed by GitHub
commit 6ee49c6289
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 402 additions and 740 deletions

View File

@ -18,6 +18,9 @@
extern LPCSTR hookPort; extern LPCSTR hookPort;
uintptr_t imageBase; uintptr_t imageBase;
static unsigned char hasp_buffer[0xD40]; static unsigned char hasp_buffer[0xD40];
static bool isFreePlay;
static bool isEventMode2P;
static bool isEventMode4P;
const char* ipaddr; const char* ipaddr;
// Data for IC card, Force Feedback etc OFF. // Data for IC card, Force Feedback etc OFF.
@ -58,6 +61,7 @@ unsigned char settingData[408] = {
0x8F, 0x3D, 0x7F, 0x00, 0x10, 0x1E, 0x34, 0xD9, 0xB5, 0x03, 0x00, 0x00 0x8F, 0x3D, 0x7F, 0x00, 0x10, 0x1E, 0x34, 0xD9, 0xB5, 0x03, 0x00, 0x00
}; };
#define HASP_STATUS_OK 0 #define HASP_STATUS_OK 0
unsigned int Hook_hasp_login(int feature_id, void* vendor_code, int hasp_handle) { unsigned int Hook_hasp_login(int feature_id, void* vendor_code, int hasp_handle) {
#ifdef _DEBUG #ifdef _DEBUG
@ -128,6 +132,72 @@ unsigned int WINAPI Hook_bind(SOCKET s, const sockaddr *addr, int namelen) {
} }
} }
// ******************************************** //
// ************ Debug Data Logging ************ //
// ******************************************** //
// ************* Global Variables ************* //
// **** String Variables
// Debugging event log file
std::string logfile = "wmmt5_errors.txt";
// writeLog(filename: String, message: String): Int
// Given a filename string and a message string, appends
// the message to the given file.
static int writeLog(std::string filename, std::string message)
{
// Log file to write to
std::ofstream eventLog;
// Open the filename provided (append mode)
eventLog.open(filename, std::ios_base::app);
// File open success
if (eventLog.is_open())
{
// Write the message to the file
eventLog << message;
// Close the log file handle
eventLog.close();
// Success
return 0;
}
else // File open failed
{
// Failure
return 1;
}
}
// writeDump(filename: Char*, data: unsigned char *, size: size_t): Int
static int writeDump(char* filename, unsigned char* data, size_t size)
{
// Open the file with the provided filename
FILE* file = fopen(filename, "wb");
// File opened successfully
if (file)
{
// Write the data to the file
fwrite((void*)data, 1, size, file);
// Close the file
fclose(file);
// Return success status
return 0;
}
else // Failed to open
{
// Return failure status
return 1;
}
}
static int ReturnTrue() static int ReturnTrue()
{ {
return 1; return 1;
@ -166,8 +236,6 @@ void GenerateDongleData(bool isTerminal)
} }
} }
char customName[256];
extern int* ffbOffset; extern int* ffbOffset;
extern int* ffbOffset2; extern int* ffbOffset2;
extern int* ffbOffset3; extern int* ffbOffset3;
@ -243,17 +311,13 @@ static InitFunction Wmmt5Func([]()
GenerateDongleData(isTerminal); GenerateDongleData(isTerminal);
//load banapass emu
//Load banapass emu
LoadLibraryA(".\\openBanaW5p.dll"); LoadLibraryA(".\\openBanaW5p.dll");
//restore old patches
injector::WriteMemory<uint8_t>(hook::get_pattern("0F 94 C0 84 C0 0F 94 C0 84 C0 75 05 45 32 ? EB", 0x13), 0, true); injector::WriteMemory<uint8_t>(hook::get_pattern("0F 94 C0 84 C0 0F 94 C0 84 C0 75 05 45 32 ? EB", 0x13), 0, true);
injector::MakeNOP(hook::get_pattern("83 C0 FD 83 F8 01 0F 87 B4 00 00 00", 6), 6); injector::MakeNOP(hook::get_pattern("83 C0 FD 83 F8 01 0F 87 B4 00 00 00", 6), 6);
injector::WriteMemory<uint8_t>(hook::get_pattern("83 FA 04 0F 8C 1E 01 00 00 4C 89 44 24 18 4C 89 4C 24 20", 2), 0, true);
injector::MakeNOP(hook::get_pattern("45 33 C0 BA 65 09 00 00 48 8D 4D B0 E8 ? ? ? ? 48 8B 08", 12), 5);
auto location = hook::get_pattern<char>("48 83 EC 28 33 D2 B9 70 00 02 00 E8 ? ? ? ? 85 C0 79 06");
injector::WriteMemory<uint8_t>(location + 0x12, 0xEB, true);
// Skip weird camera init that stucks entire pc on certain brands. TESTED ONLY ON 05!!!! // Skip weird camera init that stucks entire pc on certain brands. TESTED ONLY ON 05!!!!
if (ToBool(config["General"]["WhiteScreenFix"])) if (ToBool(config["General"]["WhiteScreenFix"]))
@ -263,15 +327,23 @@ static InitFunction Wmmt5Func([]()
{ {
auto location = hook::get_pattern<char>("41 3B C7 74 0E 48 8D 8F B8 00 00 00 BA F6 01 00 00 EB 6E 48 8D 8F A0 00 00 00"); auto location = hook::get_pattern<char>("41 3B C7 74 0E 48 8D 8F B8 00 00 00 BA F6 01 00 00 EB 6E 48 8D 8F A0 00 00 00");
injector::WriteMemory<uint8_t>(location + 3, 0xEB, true); //patches content router
injector::MakeNOP(location + 0x22, 2); //patches ip addr injector::WriteMemory<uint8_t>(location + 3, 0xEB, true);
injector::MakeNOP(location + 0x33, 2); //patches ip addr
injector::MakeNOP(location + 0x22, 2);
injector::MakeNOP(location + 0x33, 2);
} }
{
auto location = hook::get_pattern<char>("48 83 EC 28 33 D2 B9 70 00 02 00 E8 ? ? ? ? 85 C0 79 06");
injector::WriteMemory<uint8_t>(location + 0x12, 0xEB, true);
}
if (isTerminal) if (isTerminal)
{ {
safeJMP(hook::get_pattern("0F B6 41 05 2C 30 3C 09 77 04 0F BE C0 C3 83 C8 FF C3"), ReturnTrue); safeJMP(hook::get_pattern("0F B6 41 05 2C 30 3C 09 77 04 0F BE C0 C3 83 C8 FF C3"), ReturnTrue);
safeJMP(hook::get_pattern("40 53 48 83 EC 20 48 83 39 00 48 8B D9 75 28 48 8D ? ? ? ? 00 48 8D ? ? ? ? 00 41 B8 ? ? 00 00 FF 15 ? ? ? ? 4C 8B 1B 41 0F B6 43 78"), ReturnTrue); safeJMP(hook::get_pattern("40 53 48 83 EC 20 48 83 39 00 48 8B D9 75 28 48 8D ? ? ? ? 00 48 8D ? ? ? ? 00 41 B8 ? ? 00 00 FF 15 ? ? ? ? 4C 8B 1B 41 0F B6 43 78"), ReturnTrue);
} }
else else
@ -309,14 +381,13 @@ static InitFunction Wmmt5Func([]()
if (ToBool(config["General"]["SkipMovies"])) if (ToBool(config["General"]["SkipMovies"]))
{ {
// Skip movies fuck you wmmt5 (what the fuck is this for?) // Skip movies fuck you wmmt5
safeJMP(imageBase + 0x806020, ReturnTrue); safeJMP(imageBase + 0x806020, ReturnTrue);
} }
// Save story stuff (only 05) // Save story stuff (only 05)
{ {
CreateThread(0, 0, Wmmt5FfbCollector, 0, 0, 0); CreateThread(0, 0, Wmmt5FfbCollector, 0, 0, 0);
} }

View File

@ -23,9 +23,6 @@ bool isUpdate5 = false;
// MUST DISABLE IC CARD, FFB MANUALLY N MT5DX+ // MUST DISABLE IC CARD, FFB MANUALLY N MT5DX+
#define HASP_STATUS_OK 0 #define HASP_STATUS_OK 0
unsigned int dxpHook_hasp_login(int feature_id, void* vendor_code, int hasp_handle) { unsigned int dxpHook_hasp_login(int feature_id, void* vendor_code, int hasp_handle) {
#ifdef _DEBUG #ifdef _DEBUG
@ -323,23 +320,16 @@ unsigned int WINAPI Hook_bind_w5p(SOCKET s, const sockaddr* addr, int namelen) {
} }
} }
// Wmmt5Func([]()): InitFunction // Wmmt5Func([]()): InitFunction
// Performs the initial startup tasks for // Performs the initial startup tasks for
// maximum tune 5, including the starting // maximum tune 5, including the starting
// of required subprocesses. // of required subprocesses.
static InitFunction Wmmt5Func([]() static InitFunction Wmmt5Func([]()
{ {
if (ToBool(config["Update5"]["Enable Update5"]))
{
isUpdate5 = true;
}
// Alloc debug console // Alloc debug console
FreeConsole(); FreeConsole();
AllocConsole(); AllocConsole();
SetConsoleTitle(L"Maxitune6 Console"); SetConsoleTitle(L"Maxitune5DX+ Console");
FILE* pNewStdout = nullptr; FILE* pNewStdout = nullptr;
FILE* pNewStderr = nullptr; FILE* pNewStderr = nullptr;
@ -357,6 +347,11 @@ static InitFunction Wmmt5Func([]()
puts("hello there, maxitune"); puts("hello there, maxitune");
if (ToBool(config["Update5"]["Enable Update5"]))
{
isUpdate5 = true;
}
// Records if terminal mode is enabled // Records if terminal mode is enabled
bool isTerminal = false; bool isTerminal = false;
@ -396,13 +391,16 @@ static InitFunction Wmmt5Func([]()
// Give me the HWND please maxitune // Give me the HWND please maxitune
MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow)); MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow));
//pMaxituneWndProc = (WindowProcedure_t)(imageBasedxplus + 0xB78B90);
pMaxituneWndProc = (WindowProcedure_t)(hook::get_pattern("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 30 8B EA BA EB FF FF FF 49 8B F9 49 8B F0 48 8B D9 FF 15 ? ? ? 00 48 85 C0 74 1D 4C", 0)); pMaxituneWndProc = (WindowProcedure_t)(hook::get_pattern("48 89 5C 24 08 48 89 6C 24 10 48 89 74 24 18 57 48 83 EC 30 8B EA BA EB FF FF FF 49 8B F9 49 8B F0 48 8B D9 FF 15 ? ? ? 00 48 85 C0 74 1D 4C", 0));
//load banapass emu //load banapass emu
if (!isUpdate5) { if (!isUpdate5)
{
LoadLibraryA(".\\openBanaW5p.dll"); LoadLibraryA(".\\openBanaW5p.dll");
} }
else { else
{
LoadLibraryA(".\\openBanaW5p5.dll"); LoadLibraryA(".\\openBanaW5p5.dll");
} }
@ -411,8 +409,6 @@ static InitFunction Wmmt5Func([]()
GenerateDongleDataDxp(isTerminal); GenerateDongleDataDxp(isTerminal);
injector::WriteMemory<uint8_t>(hook::get_pattern("85 C9 0F 94 C0 84 C0 0F 94 C0 84 C0 75 ? 40 32 F6 EB ?", 0x15), 0, true); //patches out dongle error2 (doomer) injector::WriteMemory<uint8_t>(hook::get_pattern("85 C9 0F 94 C0 84 C0 0F 94 C0 84 C0 75 ? 40 32 F6 EB ?", 0x15), 0, true); //patches out dongle error2 (doomer)
injector::MakeNOP(hook::get_pattern("83 C0 FD 83 F8 01 76 ? 49 8D ? ? ? ? 00 00"), 6); injector::MakeNOP(hook::get_pattern("83 C0 FD 83 F8 01 76 ? 49 8D ? ? ? ? 00 00"), 6);
@ -438,11 +434,6 @@ static InitFunction Wmmt5Func([]()
{ {
injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2); //terminal on same machine patch injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2); //terminal on same machine patch
// If terminal emulator is enabled
if (ToBool(config["General"]["TerminalEmulator"]))
{
CreateThread(0, 0, SpamMulticast, 0, 0, 0);
}
} }
else else
{ //terminal mode patches { //terminal mode patches
@ -474,16 +465,19 @@ static InitFunction Wmmt5Func([]()
} }
} }
if (!isUpdate5) { if (!isUpdate5)
{
// Enable all print // Enable all print
injector::MakeNOP(imageBasedxplus + 0x898BD3, 6); injector::MakeNOP(imageBasedxplus + 0x898BD3, 6);
//Fix crash when saving story mode and Time attack //Fix crash when saving story mode and Time attack
injector::MakeNOP(imageBasedxplus + 0xE90C7, 5); injector::MakeNOP(imageBasedxplus + 0xE90C7, 5);
} }
else { else
{
// Enable all print // Enable all print
injector::MakeNOP(imageBasedxplus + 0x8F15A3, 6); injector::MakeNOP(imageBasedxplus + 0x8F15A3, 6);
//Fix crash when saving story mode and Time attack //Fix crash when saving story mode and Time attack
injector::MakeNOP(imageBasedxplus + 0xE8DE7, 5); injector::MakeNOP(imageBasedxplus + 0xE8DE7, 5);
} }

View File

@ -22,13 +22,6 @@ static bool ForceNeon;
static bool CarTuneNeonThread; static bool CarTuneNeonThread;
static const char* ipaddr; static const char* ipaddr;
static LPSTR terminalIP;
static LPSTR routerIP;
static LPSTR cab1IP;
static LPSTR cab2IP;
static LPSTR cab3IP;
static LPSTR cab4IP;
static DWORD mileageValue = 0; static DWORD mileageValue = 0;
static int NeonColour; static int NeonColour;
@ -90,13 +83,9 @@ static unsigned int WINAPI Hook_bind(SOCKET s, const sockaddr* addr, int namelen
bindAddr.sin_addr.s_addr = inet_addr("192.168.96.20"); bindAddr.sin_addr.s_addr = inet_addr("192.168.96.20");
bindAddr.sin_port = htons(50765); bindAddr.sin_port = htons(50765);
if (addr == (sockaddr*)&bindAddr) { if (addr == (sockaddr*)&bindAddr) {
// terminal proxy
// redirect this to localhost
auto localhost = inet_addr(terminalIP);
sockaddr_in bindAddr2 = { 0 }; sockaddr_in bindAddr2 = { 0 };
bindAddr2.sin_family = AF_INET; bindAddr2.sin_family = AF_INET;
bindAddr2.sin_addr.s_addr = localhost; bindAddr2.sin_addr.s_addr = inet_addr(ipaddr);
bindAddr2.sin_port = htons(50765); bindAddr2.sin_port = htons(50765);
return pbind(s, (sockaddr*)&bindAddr2, namelen); return pbind(s, (sockaddr*)&bindAddr2, namelen);
} }
@ -244,131 +233,6 @@ extern int* ffbOffset2;
extern int* ffbOffset3; extern int* ffbOffset3;
extern int* ffbOffset4; extern int* ffbOffset4;
typedef INT (WSAAPI* WsaStringToAddressA_t)(LPSTR, INT, LPWSAPROTOCOL_INFOA, LPSOCKADDR, LPINT);
static WsaStringToAddressA_t gWsaStringToAddressA;
//#define LOCAL_IP "192.168.100.10"
//#define ROUTER_IP "192.168.100.1"
#define LOCALHOST "127.0.0.1"
static INT WSAAPI Hook_WsaStringToAddressA(
_In_ LPSTR AddressString,
_In_ INT AddressFamily,
_In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
_Out_ LPSOCKADDR lpAddress,
_Inout_ LPINT lpAddressLength
)
{
if (strcmp(AddressString, "192.168.92.254") == 0)
{
return gWsaStringToAddressA(
routerIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.253") == 0)
{
return gWsaStringToAddressA(
routerIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.11") == 0)
{
return gWsaStringToAddressA(
cab1IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.12") == 0)
{
return gWsaStringToAddressA(
cab2IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.13") == 0)
{
return gWsaStringToAddressA(
cab3IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.14") == 0)
{
return gWsaStringToAddressA(
cab4IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.20") == 0)
{
return gWsaStringToAddressA(
terminalIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
return gWsaStringToAddressA(
AddressString,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
typedef INT (WSAAPI* getaddrinfo_t)(PCSTR, PCSTR, const ADDRINFOA*, PADDRINFOA*);
static getaddrinfo_t ggetaddrinfo;
static INT WSAAPI Hook_getaddrinfo(
_In_opt_ PCSTR pNodeName,
_In_opt_ PCSTR pServiceName,
_In_opt_ const ADDRINFOA* pHints,
_Out_ PADDRINFOA* ppResult
)
{
if (pNodeName && strcmp(pNodeName, "192.168.92.253") == 0)
{
return ggetaddrinfo(routerIP, pServiceName, pHints, ppResult);
}
return ggetaddrinfo(pNodeName, pServiceName, pHints, ppResult);
}
static __int64(__fastcall* g_origMileageFix)(__int64); static __int64(__fastcall* g_origMileageFix)(__int64);
static __int64 __fastcall MileageFix(__int64 a1) static __int64 __fastcall MileageFix(__int64 a1)
@ -431,84 +295,6 @@ static InitFunction Wmmt6Func([]()
ipaddr = networkip.c_str(); ipaddr = networkip.c_str();
} }
std::string TERMINAL_IP = config["General"]["TerminalIP"];
if (!TERMINAL_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char)*255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, TERMINAL_IP.c_str());
terminalIP = (LPSTR)theIp;
}
else
{
terminalIP = "127.0.0.1";
}
std::string ROUTER_IP = config["General"]["RouterIP"];
if (!ROUTER_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, ROUTER_IP.c_str());
routerIP = (LPSTR)theIp;
}
else
{
routerIP = "192.168.86.1";
}
std::string Cab_1_IP = config["General"]["Cab1IP"];
if (!Cab_1_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_1_IP.c_str());
cab1IP = (LPSTR)theIp;
}
else
{
cab1IP = "192.168.255.255";
}
std::string Cab_2_IP = config["General"]["Cab2IP"];
if (!Cab_2_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_2_IP.c_str());
cab2IP = (LPSTR)theIp;
}
else
{
cab2IP = "192.168.255.255";
}
std::string Cab_3_IP = config["General"]["Cab3IP"];
if (!Cab_3_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_3_IP.c_str());
cab3IP = (LPSTR)theIp;
}
else
{
cab3IP = "192.168.255.255";
}
std::string Cab_4_IP = config["General"]["Cab4IP"];
if (!Cab_4_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_4_IP.c_str());
cab4IP = (LPSTR)theIp;
}
else
{
cab4IP = "192.168.255.255";
}
hookPort = "COM3"; hookPort = "COM3";
imageBase = (uintptr_t)GetModuleHandleA(0); imageBase = (uintptr_t)GetModuleHandleA(0);
MH_Initialize(); MH_Initialize();
@ -527,11 +313,6 @@ static InitFunction Wmmt6Func([]()
MH_CreateHookApi(L"kernel32", "OutputDebugStringA", Hook_OutputDebugStringA, NULL); MH_CreateHookApi(L"kernel32", "OutputDebugStringA", Hook_OutputDebugStringA, NULL);
// CreateFile* hooks are in the JVS FILE // CreateFile* hooks are in the JVS FILE
// Network hooks
MH_CreateHookApi(L"Ws2_32", "WSAStringToAddressA", Hook_WsaStringToAddressA, reinterpret_cast<LPVOID*>(&gWsaStringToAddressA));
MH_CreateHookApi(L"Ws2_32", "getaddrinfo", Hook_getaddrinfo, reinterpret_cast<LPVOID*>(&ggetaddrinfo));
// Give me the HWND please maxitune // Give me the HWND please maxitune
MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow)); MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow));
//MH_CreateHookApi(L"kernel32", "ReadFile", Hook_ReadFile, reinterpret_cast<LPVOID*>(&pReadFile)); //MH_CreateHookApi(L"kernel32", "ReadFile", Hook_ReadFile, reinterpret_cast<LPVOID*>(&pReadFile));
@ -552,6 +333,10 @@ static InitFunction Wmmt6Func([]()
injector::WriteMemory<DWORD>(hook::get_pattern("48 8B C4 55 57 41 54 41 55 41 56 48 8D 68 A1 48 81 EC 90 00 00 00 48 C7 45 D7 FE FF FF FF 48 89 58 08 48 89 70 18 45 33 F6 4C 89 75 DF 33 C0 48 89 45 E7", 0), 0x90C3C032, true); injector::WriteMemory<DWORD>(hook::get_pattern("48 8B C4 55 57 41 54 41 55 41 56 48 8D 68 A1 48 81 EC 90 00 00 00 48 C7 45 D7 FE FF FF FF 48 89 58 08 48 89 70 18 45 33 F6 4C 89 75 DF 33 C0 48 89 45 E7", 0), 0x90C3C032, true);
} }
// Best LAN setting by doomertheboomer
injector::WriteMemory<BYTE>(imageBase + 0xA36CAA, 0xEB, true); //content router patch
injector::MakeNOP(imageBase + 0x690876, 2, true);
// wtf is this? // wtf is this?
//injector::MakeNOP(hook::get_pattern("45 33 C0 BA 65 09 00 00 48 8D 4D B0 E8 ? ? ? ? 48 8B 08", 12), 5); //injector::MakeNOP(hook::get_pattern("45 33 C0 BA 65 09 00 00 48 8D 4D B0 E8 ? ? ? ? 48 8B 08", 12), 5);

View File

@ -19,13 +19,6 @@ static bool isEventMode2P;
static bool isEventMode4P; static bool isEventMode4P;
static const char* ipaddr; static const char* ipaddr;
static LPSTR terminalIP;
static LPSTR routerIP;
static LPSTR cab1IP;
static LPSTR cab2IP;
static LPSTR cab3IP;
static LPSTR cab4IP;
// Data for IC card, Force Feedback etc OFF. // Data for IC card, Force Feedback etc OFF.
static unsigned char settingData[405] = { static unsigned char settingData[405] = {
0x1F, 0x8B, 0x08, 0x08, 0x53, 0x6A, 0x8B, 0x5A, 0x00, 0x00, 0x73, 0x65, 0x1F, 0x8B, 0x08, 0x08, 0x53, 0x6A, 0x8B, 0x5A, 0x00, 0x00, 0x73, 0x65,
@ -274,13 +267,9 @@ static unsigned int WINAPI Hook_bind(SOCKET s, const sockaddr* addr, int namelen
bindAddr.sin_addr.s_addr = inet_addr("192.168.96.20"); bindAddr.sin_addr.s_addr = inet_addr("192.168.96.20");
bindAddr.sin_port = htons(50765); bindAddr.sin_port = htons(50765);
if (addr == (sockaddr*)&bindAddr) { if (addr == (sockaddr*)&bindAddr) {
// terminal proxy
// redirect this to localhost
auto localhost = inet_addr(terminalIP);
sockaddr_in bindAddr2 = { 0 }; sockaddr_in bindAddr2 = { 0 };
bindAddr2.sin_family = AF_INET; bindAddr2.sin_family = AF_INET;
bindAddr2.sin_addr.s_addr = localhost; bindAddr2.sin_addr.s_addr = inet_addr(ipaddr);
bindAddr2.sin_port = htons(50765); bindAddr2.sin_port = htons(50765);
return pbind(s, (sockaddr*)&bindAddr2, namelen); return pbind(s, (sockaddr*)&bindAddr2, namelen);
} }
@ -509,126 +498,29 @@ static BOOL Hook_ShowWindow(HWND hwnd, int nCmdShow)
return pShowWindow(hwnd, nCmdShow); return pShowWindow(hwnd, nCmdShow);
} }
typedef INT(WSAAPI* WsaStringToAddressA_t)(LPSTR, INT, LPWSAPROTOCOL_INFOA, LPSOCKADDR, LPINT);
static WsaStringToAddressA_t gWsaStringToAddressA;
static INT WSAAPI Hook_WsaStringToAddressA(
_In_ LPSTR AddressString,
_In_ INT AddressFamily,
_In_opt_ LPWSAPROTOCOL_INFOA lpProtocolInfo,
_Out_ LPSOCKADDR lpAddress,
_Inout_ LPINT lpAddressLength
)
{
if (strcmp(AddressString, "192.168.92.254") == 0)
{
return gWsaStringToAddressA(
routerIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.253") == 0)
{
return gWsaStringToAddressA(
routerIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.11") == 0)
{
return gWsaStringToAddressA(
cab1IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.12") == 0)
{
return gWsaStringToAddressA(
cab2IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.13") == 0)
{
return gWsaStringToAddressA(
cab3IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.14") == 0)
{
return gWsaStringToAddressA(
cab4IP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
if (strcmp(AddressString, "192.168.92.20") == 0)
{
return gWsaStringToAddressA(
terminalIP,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
return gWsaStringToAddressA(
AddressString,
AddressFamily,
lpProtocolInfo,
lpAddress,
lpAddressLength
);
}
typedef INT(WSAAPI* getaddrinfo_t)(PCSTR, PCSTR, const ADDRINFOA*, PADDRINFOA*);
static getaddrinfo_t ggetaddrinfo;
static INT WSAAPI Hook_getaddrinfo(
_In_opt_ PCSTR pNodeName,
_In_opt_ PCSTR pServiceName,
_In_opt_ const ADDRINFOA* pHints,
_Out_ PADDRINFOA* ppResult
)
{
if (pNodeName && strcmp(pNodeName, "192.168.92.253") == 0)
{
return ggetaddrinfo(routerIP, pServiceName, pHints, ppResult);
}
return ggetaddrinfo(pNodeName, pServiceName, pHints, ppResult);
}
static InitFunction Wmmt6RFunc([]() static InitFunction Wmmt6RFunc([]()
{ {
// Alloc debug console
FreeConsole();
AllocConsole();
SetConsoleTitle(L"Maxitune6R Console");
FILE* pNewStdout = nullptr;
FILE* pNewStderr = nullptr;
FILE* pNewStdin = nullptr;
::freopen_s(&pNewStdout, "CONOUT$", "w", stdout);
::freopen_s(&pNewStderr, "CONOUT$", "w", stderr);
::freopen_s(&pNewStdin, "CONIN$", "r", stdin);
std::cout.clear();
std::cerr.clear();
std::cin.clear();
std::wcout.clear();
std::wcerr.clear();
std::wcin.clear();
puts("hello there, maxitune");
// folder for path redirections // folder for path redirections
CreateDirectoryA(".\\TP", nullptr); CreateDirectoryA(".\\TP", nullptr);
@ -656,84 +548,6 @@ static InitFunction Wmmt6RFunc([]()
ipaddr = networkip.c_str(); ipaddr = networkip.c_str();
} }
std::string TERMINAL_IP = config["General"]["TerminalIP"];
if (!TERMINAL_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, TERMINAL_IP.c_str());
terminalIP = (LPSTR)theIp;
}
else
{
terminalIP = "127.0.0.1";
}
std::string ROUTER_IP = config["General"]["RouterIP"];
if (!ROUTER_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, ROUTER_IP.c_str());
routerIP = (LPSTR)theIp;
}
else
{
routerIP = "192.168.86.1";
}
std::string Cab_1_IP = config["General"]["Cab1IP"];
if (!Cab_1_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_1_IP.c_str());
cab1IP = (LPSTR)theIp;
}
else
{
cab1IP = "192.168.255.255";
}
std::string Cab_2_IP = config["General"]["Cab2IP"];
if (!Cab_2_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_2_IP.c_str());
cab2IP = (LPSTR)theIp;
}
else
{
cab2IP = "192.168.255.255";
}
std::string Cab_3_IP = config["General"]["Cab3IP"];
if (!Cab_3_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_3_IP.c_str());
cab3IP = (LPSTR)theIp;
}
else
{
cab3IP = "192.168.255.255";
}
std::string Cab_4_IP = config["General"]["Cab4IP"];
if (!Cab_4_IP.empty())
{
char* theIp = (char*)malloc(sizeof(char) * 255);
memset(theIp, 0, sizeof(char) * 255);
strcpy(theIp, Cab_4_IP.c_str());
cab4IP = (LPSTR)theIp;
}
else
{
cab4IP = "192.168.255.255";
}
hookPort = "COM3"; hookPort = "COM3";
imageBase = (uintptr_t)GetModuleHandleA(0); imageBase = (uintptr_t)GetModuleHandleA(0);
MH_Initialize(); MH_Initialize();
@ -752,11 +566,6 @@ static InitFunction Wmmt6RFunc([]()
MH_CreateHookApi(L"WS2_32", "bind", Hook_bind, reinterpret_cast<LPVOID*>(&pbind)); MH_CreateHookApi(L"WS2_32", "bind", Hook_bind, reinterpret_cast<LPVOID*>(&pbind));
// Network hooks
MH_CreateHookApi(L"Ws2_32", "WSAStringToAddressA", Hook_WsaStringToAddressA, reinterpret_cast<LPVOID*>(&gWsaStringToAddressA));
MH_CreateHookApi(L"Ws2_32", "getaddrinfo", Hook_getaddrinfo, reinterpret_cast<LPVOID*>(&ggetaddrinfo));
// Give me the HWND please maxitune // Give me the HWND please maxitune
MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow)); MH_CreateHookApi(L"user32", "ShowWindow", Hook_ShowWindow, reinterpret_cast<LPVOID*>(&pShowWindow));
//MH_CreateHookApi(L"kernel32", "ReadFile", Hook_ReadFile, reinterpret_cast<LPVOID*>(&pReadFile)); //MH_CreateHookApi(L"kernel32", "ReadFile", Hook_ReadFile, reinterpret_cast<LPVOID*>(&pReadFile));
@ -786,14 +595,17 @@ static InitFunction Wmmt6RFunc([]()
//safeJMP(hook::get_pattern("0F B6 41 05 2C 30 3C 09 77 04 0F BE C0 C3 83 C8 FF C3"), ReturnTrue); //safeJMP(hook::get_pattern("0F B6 41 05 2C 30 3C 09 77 04 0F BE C0 C3 83 C8 FF C3"), ReturnTrue);
injector::MakeNOP((imageBase + 0x710445), 5); injector::MakeNOP((imageBase + 0x710445), 5);
safeJMP(hook::get_pattern("8B 01 0F B6 40 78 C3 CC CC CC CC"), ReturnTrue); safeJMP(hook::get_pattern("8B 01 0F B6 40 78 C3 CC CC CC CC"), ReturnTrue);
} }
else else
{ {
//injector::WriteMemory<WORD>(imageBase + 0x718FA1, 0x00D2, true); // terminal skip (whyyyyyyyyyyyyyyyy) //injector::WriteMemory<WORD>(imageBase + 0x718FA1, 0x00D2, true); // terminal skip (whyyyyyyyyyyyyyyyy)
// spam thread // spam thread
injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2); //this should be the terminal on same machine patch //injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2); //this should be the terminal on same machine patch
// Best LAN setting by doomertheboomer
injector::WriteMemory<BYTE>(imageBase + 0xB0EB4A, 0xEB, true); //content router patch
injector::MakeNOP(imageBase + 0x7084A6, 2, true);
injector::MakeNOP(hook::get_pattern("74 ? 80 7B 31 00 75 ? 48 8B 43 10 80 78 31 00 75 1A 48 8B D8 48 8B 00 80 78 31 00 75 ? 48 8B D8"), 2);
} }
// Enable all print // Enable all print