Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t, 3> 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<uint8_t, 3> 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.
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/xiloader.rc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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