diff --git a/src/main.cpp b/src/main.cpp index e2ced1e..6db92d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,7 @@ namespace globals std::string g_OtpCode = ""; // The OTP code the user input char g_SessionHash[16] = {}; // Session hash sent from auth std::string g_Email = ""; // Email, currently unused - std::array g_VersionNumber = { 2, 0, 0 }; // xiloader version number sent to auth server. Must be x.x.x with single characters for 'x'. Remember to also change in xiloader.rc.in + std::array g_VersionNumber = { 2, 0, 1 }; // xiloader version number sent to auth server. Must be x.x.x with single characters for 'x'. Remember to also change in xiloader.rc.in bool g_FirstLogin = false; // set to true when --user --pass are both set to allow for autologin char* g_CharacterList = NULL; // Pointer to the character list data being sent from the server. @@ -280,6 +280,34 @@ int WINAPI Mine_connect(SOCKET s, const sockaddr* name, int namelen) return ret; } +/** + * @brief Locates profile server port addresses and sets the profile server port + * + * @return Failed to find the patterns or succeeded to write + */ +bool SetProfileServerPort(uint16_t profileServerPort) +{ + const char* module = (globals::g_Language == xiloader::Language::European) ? "polcoreeu.dll" : "polcore.dll"; + auto profileServerPortAddress = (DWORD)xiloader::functions::FindPattern(module, (BYTE*)"\x66\xC7\x46\x26\x14\xC8\x88\x46\x09\x8D\x46\x24", "xxxxxxxxxxx"); + if (profileServerPortAddress == 0) + { + xiloader::console::output(xiloader::color::error, "Failed to locate profileServerPortAddress!"); + return false; + } + + auto profileServerPortAddress2 = (DWORD)xiloader::functions::FindPattern(module, (BYTE*)"\x66\xC7\x05\xBA\x4A\x3F\x04\x14\xC8", "xxxxx??xx"); // This pattern changed slightly on a few month old polcore, it used to be a total match but some bytes changed. + if (profileServerPortAddress2 == 0) + { + xiloader::console::output(xiloader::color::error, "Failed to locate profileServerPortAddress2!"); + return false; + } + + *((uint16_t*)(profileServerPortAddress + 4)) = profileServerPort; + *((uint16_t*)(profileServerPortAddress2 + 7)) = profileServerPort; + + return true; +} + /** * @brief Locates the INET mutex function call inside of polcore.dll * @@ -701,6 +729,15 @@ int __cdecl main(int argc, char* argv[]) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ApplyHairpinFixThread, NULL, 0, NULL); } + struct sockaddr_in pol_sin; + int pol_len = sizeof(pol_sin); + unsigned short profileServerPort = 0; + + if (getsockname(polsock, (struct sockaddr*)&pol_sin, &pol_len) == 0) + { + profileServerPort = ntohs(pol_sin.sin_port); + } + /* Create listen servers.. */ globals::g_IsRunning = true; HANDLE hFFXiServer = CreateThread(NULL, 0, xiloader::network::FFXiServer, &sock, 0, NULL); @@ -747,6 +784,11 @@ int __cdecl main(int argc, char* argv[]) lpCommandTable[POLFUNC_INSTALL_FOLDER](xiloader::functions::GetRegistryPlayOnlineInstallFolder(globals::g_Language)); lpCommandTable[POLFUNC_INET_MUTEX](); + if (!SetProfileServerPort(profileServerPort)) + { + return 1; + } + /* Attempt to create FFXi instance..*/ IFFXiEntry* ffxi = NULL; if (CoCreateInstance(xiloader::CLSID_FFXiEntry, NULL, 0x17, xiloader::IID_IFFXiEntry, (LPVOID*)&ffxi) != S_OK) diff --git a/src/network.cpp b/src/network.cpp index 8acadfe..8a37eae 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -249,7 +249,7 @@ namespace xiloader sockaddr_in sin = {}; sin.sin_family = AF_INET; sin.sin_addr.s_addr = inet_addr("127.0.0.1"); - sin.sin_port = htons(51220); + sin.sin_port = htons(0); /* Create the listening socket.. */ *sock = socket(AF_INET, protocol == IPPROTO_UDP ? SOCK_DGRAM : SOCK_STREAM, protocol); diff --git a/src/xiloader.rc.in b/src/xiloader.rc.in index 30a9bb6..fe97f95 100644 --- a/src/xiloader.rc.in +++ b/src/xiloader.rc.in @@ -3,13 +3,13 @@ // VALUE "FileVersion", ... 1 VERSIONINFO -FILEVERSION 1,1,5 +FILEVERSION 2,0,1 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "081604b0" BEGIN - VALUE "FileVersion", "1.1.5" + VALUE "FileVersion", "2.0.1" END END END