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
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ add_executable(xiloader
src/console.cpp
src/console.h
src/defines.h
src/enums/polcon_state.h
src/FFXi.h
src/FFXiMain.h
src/functions.cpp
Expand All @@ -45,6 +46,10 @@ add_executable(xiloader
src/network.cpp
src/network.h
src/polcore.h
src/playonline.cpp
src/playonline.h
src/polrelay.cpp
src/polrelay.h
src/trust_token.cpp
src/trust_token.h
${CMAKE_CURRENT_BINARY_DIR}/src/xiloader.rc
Expand Down
2 changes: 1 addition & 1 deletion cmake/mbedtls.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CPMAddPackage(
NAME mbedtls
GITHUB_REPOSITORY Mbed-TLS/mbedtls
GIT_TAG mbedtls-3.6.6
GIT_TAG mbedtls-3.6.7
OPTIONS
"ENABLE_PROGRAMS OFF"
"ENABLE_TESTING OFF"
Expand Down
14 changes: 12 additions & 2 deletions src/command_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace globals
extern char g_SessionHash[16];
extern std::string g_Email;
extern std::array<uint8_t, 3> g_VersionNumber;
extern uint16_t g_ServerPort;
extern uint16_t g_LoginDataPort;
extern uint16_t g_LoginViewPort;
extern uint16_t g_LoginAuthPort;
Expand Down Expand Up @@ -186,7 +185,13 @@ bool handleLoginCommand(int8_t command, json& login_reply_json, uint32_t& accoun
bool display = menus::okCancelDialog("Open QR code in my default browser");
if (display)
{
ShellExecuteA(nullptr, "open", svgFilePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
// ShellExecuteA returns a value above 32 on success
const auto opened = reinterpret_cast<INT_PTR>(ShellExecuteA(nullptr, "open", svgFilePath.c_str(), nullptr, nullptr, SW_SHOWNORMAL));
if (opened <= 32)
{
xiloader::console::output(xiloader::color::error, "Failed to open the QR code (error %d). Open %s manually.", static_cast<int>(opened), svgFilePath.c_str());
}

xiloader::console::output(xiloader::color::info, "Once saved please use the \"Validate 2FA OTP\" option to verify the OTP.");
}

Expand Down Expand Up @@ -227,6 +232,11 @@ bool handleLoginCommand(int8_t command, json& login_reply_json, uint32_t& accoun
return false;
}

default:
{
xiloader::console::output(xiloader::color::error, "The login server sent an unknown result (0x%02X). Check this xiloader version is supported by the server.", static_cast<uint8_t>(command));
break;
}
}

return false;
Expand Down
36 changes: 36 additions & 0 deletions src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,42 @@ This file is part of DarkStar-server source code.
#define POLFUNC_REGISTRY_KEY 0x016F
#define POLFUNC_INSTALL_FOLDER 0x007D

// PlayOnline login, as the viewer performs it
#define POLFUNC_POLCON_OPEN 0x032E // (type, connection data) opens the PlayOnline connection
#define POLFUNC_POLCON_STEP 0x032F // advances the connect state machine; 0x1E once connected (same entry as POLFUNC_INET_MUTEX)
#define POLFUNC_POLCON_IDLE 0x0332 // lets polcore process pending network events
#define POLFUNC_SET_POLID 0x0353
#define POLFUNC_SET_PASSWORD 0x0354
#define POLFUNC_SET_POLCOM_HOST 0x0355
#define POLFUNC_ENCODE_POLID 0x0356
#define POLFUNC_ENCODE_PASSWORD 0x0358 // (out[17], password)
#define POLFUNC_FORMAT_POLID 0x0161 // (low, high, out[8]) unmasks a POL id and writes its 8 digits, without a terminator
#define POLFUNC_MASK_POLID 0x0163 // (low, high) masks a POL id with the session key, returned in edx:eax
#define POLFUNC_ENCODE_HOST 0x0364
#define POLFUNC_SET_USER_SLOT 0x0366 // picks pub\homeNN for local message copies
#define POLFUNC_FILE_INIT 0x03A4 // starts the file layer the game saves messages through
#define POLFUNC_MESSAGE_NOTICES 0x0408 // (1) turns on message notices
#define POLFUNC_SET_EVENT_HANDLER 0x0120 // (handler) sets the handler PlayOnline events such as new messages go to; FFXiMain installs its own
#define POLFUNC_NOTICE_HANDLER 0x014E // polcore's IRC notice handler, slot 1 of the polcon handler block (read, not called)
#define POLFUNC_POLCON_HANDLER_3 0x0191 // polcore's default for slot 3 of the polcon handler block (read, not called)
#define POLFUNC_POLCON_SET_HANDLERS 0x0367 // (six handlers) replaces the polcon handler block that each IRC open applies
#define POLFUNC_POLCON_CLEAR_ERROR 0x0344 // clears the error POLCON_POLL keeps reporting after the connection drops
#define POLFUNC_POLCON_POLL 0x02C1 // FFXiMain polls it every frame; a negative result ends the game with POL-xxxx
#define POLFUNC_SET_MESSAGE_TITLE 0x0430 // (index < 10, text) replaces a built-in Japanese message title
#define POLFUNC_SET_MESSAGE_TEXT 0x0516 // (index < 10, text) replaces a built-in Japanese message text

// Profile list loads the viewer runs after login: LOAD_* returns a ticket (one of 4 session slots), CHECK_* polls it (0 pending, 1 done, negative failed)
#define POLFUNC_LOAD_FRIEND_LIST 0x00A3 // 2/3 LoadFriendList
#define POLFUNC_CHECK_FRIEND_LIST 0x00A4
#define POLFUNC_LOAD_HANDLE_NAME_LIST 0x00AB // 0/9 LoadHandleNameList
#define POLFUNC_CHECK_HANDLE_NAME_LIST 0x00AC
#define POLFUNC_LOAD_CHARACTER_LIST 0x00AF // 1/3 LoadCharacterList
#define POLFUNC_CHECK_CHARACTER_LIST 0x00B0
#define POLFUNC_LOAD_MY_STATUS 0x0176 // 4/6 LoadMyStatus
#define POLFUNC_CHECK_MY_STATUS 0x0177
#define POLFUNC_LOAD_GROUP_LIST 0x017F // 7/12 group list
#define POLFUNC_CHECK_GROUP_LIST 0x0180

namespace xiloader
{
/* PolCore COM Class ID Definitions */
Expand Down
50 changes: 50 additions & 0 deletions src/enums/polcon_state.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
===========================================================================

Copyright (c) 2026 LandSandBoat Dev Teams

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/

===========================================================================
*/

#pragma once

#include <cstdint>

namespace xiloader
{
// POLCON_STEP's states (polcore 0x10044a50, state at 0x10099408); negative values are errors
enum class PolconState : int32_t
{
Init = 0x00,
Start = 0x11, // goes to Connected or ResolvePolcom depending on the open mode
ResolvePolcom = 0x12,
BuildPolcomHost = 0x13,
StartPolcomResolve = 0x14,
CheckPolcomResolve = 0x15,
OpenIrc = 0x16, // IRC session on 51240
CheckIrcOpen = 0x17,
IrcReady = 0x18,
FormatProfileHost = 0x19, // pp%03d.pol.com
ResolveProfileHost = 0x1A,
SecurityToken = 0x1B, // profile request 4/7
CheckSecurityToken = 0x1C,
Connected = 0x1E,
CloseIrc = 0x1F, // teardown on the failure path, then 0x20 and Failed
Failed = 0x21, // stays here after a failed open
ChangeMyStatus = 0x28, // profile request 4/5, open mode 3 only
CheckChangeMyStatus = 0x29,
};
} // namespace xiloader
Loading