From e107d3fa2303c52eb5c7938299295956662953f6 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 27 Jan 2019 02:17:11 +0100 Subject: [PATCH] Add support for DW dedi authentication --- src/game/demonware/services/bdDediAuth.cpp | 61 + src/game/demonware/services/bdDediAuth.hpp | 11 + src/game/demonware/services/bdDediRSAAuth.cpp | 71 ++ src/game/demonware/services/bdDediRSAAuth.hpp | 11 + src/game/game.hpp | 2 + src/game/structs.hpp | 1096 ++++++++--------- src/module/dw.cpp | 4 + src/utils/cryptography.cpp | 48 + src/utils/cryptography.hpp | 9 + 9 files changed, 765 insertions(+), 548 deletions(-) create mode 100644 src/game/demonware/services/bdDediAuth.cpp create mode 100644 src/game/demonware/services/bdDediAuth.hpp create mode 100644 src/game/demonware/services/bdDediRSAAuth.cpp create mode 100644 src/game/demonware/services/bdDediRSAAuth.hpp diff --git a/src/game/demonware/services/bdDediAuth.cpp b/src/game/demonware/services/bdDediAuth.cpp new file mode 100644 index 0000000..12f4ddb --- /dev/null +++ b/src/game/demonware/services/bdDediAuth.cpp @@ -0,0 +1,61 @@ +#include +#include "bdDediAuth.hpp" +#include "game/game.hpp" +#include "steam/steam.hpp" +#include "utils/cryptography.hpp" + +namespace demonware +{ + void bdDediAuth::call_service(i_server* server, const std::string& data) + { + bit_buffer buffer(data); + + bool more_data; + buffer.set_use_data_types(false); + buffer.read_bool(&more_data); + buffer.set_use_data_types(true); + + uint32_t seed, title_id, ticket_size; + buffer.read_uint32(&seed); + buffer.read_uint32(&title_id); + + uint8_t ticket[1024]; + buffer.read_bytes(std::min(ticket_size, static_cast(sizeof(ticket))), ticket); + + game::native::bdAuthTicket auth_ticket{}; + std::memset(&auth_ticket, 0xA, sizeof auth_ticket); + + auth_ticket.m_magicNumber = 0x0EFBDADDE; + auth_ticket.m_type = 0; + auth_ticket.m_titleID = title_id; + auth_ticket.m_userID = steam::SteamUser()->GetSteamID().bits; + auth_ticket.m_licenseID = 4; + + auto key = utils::cryptography::tiger::compute(SERVER_CD_KEY); + + strcpy_s(auth_ticket.m_username, "Open-IW5 Server"); + std::memcpy(auth_ticket.m_sessionKey, key.data(), 24); + auth_ticket.m_timeIssued = static_cast(time(nullptr)); + + uint8_t lsg_ticket[128]; + ZeroMemory(&lsg_ticket, sizeof lsg_ticket); + std::memcpy(lsg_ticket, key.data(), 24); + + const auto iv = utils::cryptography::tiger::compute(std::string(reinterpret_cast(&seed), 4)); + + const std::string enc_key(reinterpret_cast(&ticket[32]), 24); + auto enc_ticket = utils::cryptography::des3::encrypt( + std::string(reinterpret_cast(&auth_ticket), sizeof(auth_ticket)), iv, enc_key); + + bit_buffer response; + response.set_use_data_types(false); + response.write_bool(false); + response.write_uint32(700); + response.write_uint32(seed); + response.write_bytes(enc_ticket.size(), enc_ticket.data()); + response.write_bytes(sizeof(lsg_ticket), lsg_ticket); + + auto reply = server->create_message(29); + reply->send(&response, false); + } +} diff --git a/src/game/demonware/services/bdDediAuth.hpp b/src/game/demonware/services/bdDediAuth.hpp new file mode 100644 index 0000000..53d0bec --- /dev/null +++ b/src/game/demonware/services/bdDediAuth.hpp @@ -0,0 +1,11 @@ +#pragma once +#include "../i_service.hpp" + +namespace demonware +{ + class bdDediAuth final : public i_generic_service<12> + { + public: + void call_service(i_server* server, const std::string& data) override; + }; +} diff --git a/src/game/demonware/services/bdDediRSAAuth.cpp b/src/game/demonware/services/bdDediRSAAuth.cpp new file mode 100644 index 0000000..37684bf --- /dev/null +++ b/src/game/demonware/services/bdDediRSAAuth.cpp @@ -0,0 +1,71 @@ +#include +#include "bdDediRSAAuth.hpp" +#include "game/game.hpp" +#include "steam/steam.hpp" +#include "utils/cryptography.hpp" + +namespace demonware +{ + void bdDediRSAAuth::call_service(i_server* server, const std::string& data) + { + bit_buffer buffer(data); + + bool more_data; + buffer.set_use_data_types(false); + buffer.read_bool(&more_data); + buffer.set_use_data_types(true); + + uint32_t seed, title_id, ticket_size; + buffer.read_uint32(&seed); + buffer.read_uint32(&title_id); + + unsigned char rsakey[140]; + buffer.read_bytes(sizeof(rsakey), rsakey); + + uint8_t ticket[1024]; + buffer.read_bytes(std::min(ticket_size, static_cast(sizeof(ticket))), ticket); + + game::native::bdAuthTicket auth_ticket{}; + std::memset(&auth_ticket, 0xA, sizeof auth_ticket); + + auth_ticket.m_magicNumber = 0x0EFBDADDE; + auth_ticket.m_type = 0; + auth_ticket.m_titleID = title_id; + auth_ticket.m_userID = steam::SteamUser()->GetSteamID().bits; + + auto key = utils::cryptography::tiger::compute(SERVER_CD_KEY); + + strcpy_s(auth_ticket.m_username, "Open-IW5 Server"); + std::memcpy(auth_ticket.m_sessionKey, key.data(), 24); + auth_ticket.m_timeIssued = static_cast(time(nullptr)); + + uint8_t lsg_ticket[128]; + ZeroMemory(&lsg_ticket, sizeof lsg_ticket); + std::memcpy(lsg_ticket, key.data(), 24); + + const auto iv = utils::cryptography::tiger::compute(std::string(reinterpret_cast(&seed), 4)); + + const std::string enc_key(reinterpret_cast(&ticket[32]), 24); + auto enc_ticket = utils::cryptography::des3::encrypt( + std::string(reinterpret_cast(&auth_ticket), sizeof(auth_ticket)), iv, enc_key); + + register_hash(&sha1_desc); + register_prng(&yarrow_desc); + + std::string encrypted_key = utils::cryptography::rsa::encrypt(std::string(SERVER_CD_KEY, 24), + std::string("DW-RSAENC", 10), + std::string(PCHAR(rsakey), sizeof(rsakey))); + + bit_buffer response; + response.set_use_data_types(false); + response.write_bool(false); + response.write_uint32(700); + response.write_uint32(seed); + response.write_bytes(enc_ticket.size(), enc_ticket.data()); + response.write_bytes(sizeof(lsg_ticket), lsg_ticket); + response.write_bytes(encrypted_key.size(), encrypted_key.data()); + + auto reply = server->create_message(29); + reply->send(&response, false); + } +} diff --git a/src/game/demonware/services/bdDediRSAAuth.hpp b/src/game/demonware/services/bdDediRSAAuth.hpp new file mode 100644 index 0000000..cd3267c --- /dev/null +++ b/src/game/demonware/services/bdDediRSAAuth.hpp @@ -0,0 +1,11 @@ +#pragma once +#include "../i_service.hpp" + +namespace demonware +{ + class bdDediRSAAuth final : public i_generic_service<26> + { + public: + void call_service(i_server* server, const std::string& data) override; + }; +} diff --git a/src/game/game.hpp b/src/game/game.hpp index 5399d17..96af738 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -5,6 +5,8 @@ #define SELECT_VALUE(sp, mp, dedi) (game::is_sp() ? (sp) : (game::is_mp() ? (mp) : (dedi))) +#define SERVER_CD_KEY "Open-IW5-CD-Key" + namespace game { namespace native diff --git a/src/game/structs.hpp b/src/game/structs.hpp index 30a8826..b31b48c 100644 --- a/src/game/structs.hpp +++ b/src/game/structs.hpp @@ -1,550 +1,550 @@ -#pragma once - -namespace game -{ - namespace native - { - enum bdLobbyErrorCode : uint32_t - { - BD_NO_ERROR = 0x0, - BD_TOO_MANY_TASKS = 0x1, - BD_NOT_CONNECTED = 0x2, - BD_SEND_FAILED = 0x3, - BD_HANDLE_TASK_FAILED = 0x4, - BD_START_TASK_FAILED = 0x5, - BD_RESULT_EXCEEDS_BUFFER_SIZE = 0x64, - BD_ACCESS_DENIED = 0x65, - BD_EXCEPTION_IN_DB = 0x66, - BD_MALFORMED_TASK_HEADER = 0x67, - BD_INVALID_ROW = 0x68, - BD_EMPTY_ARG_LIST = 0x69, - BD_PARAM_PARSE_ERROR = 0x6A, - BD_PARAM_MISMATCHED_TYPE = 0x6B, - BD_SERVICE_NOT_AVAILABLE = 0x6C, - BD_CONNECTION_RESET = 0x6D, - BD_INVALID_USER_ID = 0x6E, - BD_LOBBY_PROTOCOL_VERSION_FAILURE = 0x6F, - BD_LOBBY_INTERNAL_FAILURE = 0x70, - BD_LOBBY_PROTOCOL_ERROR = 0x71, - BD_LOBBY_FAILED_TO_DECODE_UTF8 = 0x72, - BD_LOBBY_ASCII_EXPECTED = 0x73, - BD_ASYNCHRONOUS_ERROR = 0xC8, - BD_STREAMING_COMPLETE = 0xC9, - BD_MEMBER_NO_PROPOSAL = 0x12C, - BD_TEAMNAME_ALREADY_EXISTS = 0x12D, - BD_MAX_TEAM_MEMBERSHIPS_LIMITED = 0x12E, - BD_MAX_TEAM_OWNERSHIPS_LIMITED = 0x12F, - BD_NOT_A_TEAM_MEMBER = 0x130, - BD_INVALID_TEAM_ID = 0x131, - BD_INVALID_TEAM_NAME = 0x132, - BD_NOT_A_TEAM_OWNER = 0x133, - BD_NOT_AN_ADMIN_OR_OWNER = 0x134, - BD_MEMBER_PROPOSAL_EXISTS = 0x135, - BD_MEMBER_EXISTS = 0x136, - BD_TEAM_FULL = 0x137, - BD_VULGAR_TEAM_NAME = 0x138, - BD_TEAM_USERID_BANNED = 0x139, - BD_TEAM_EMPTY = 0x13A, - BD_INVALID_TEAM_PROFILE_QUERY_ID = 0x13B, - BD_TEAMNAME_TOO_SHORT = 0x13C, - BD_UNIQUE_PROFILE_DATA_EXISTS_ALREADY = 0x13D, - BD_INVALID_LEADERBOARD_ID = 0x190, - BD_INVALID_STATS_SET = 0x191, - BD_EMPTY_STATS_SET_IGNORED = 0x193, - BD_NO_DIRECT_ACCESS_TO_ARBITRATED_LBS = 0x194, - BD_STATS_WRITE_PERMISSION_DENIED = 0x195, - BD_STATS_WRITE_TYPE_DATA_TYPE_MISMATCH = 0x196, - BD_NO_STATS_FOR_USER = 0x197, - BD_INVALID_ACCESS_TO_UNRANKED_LB = 0x198, - BD_INVALID_EXTERNAL_TITLE_ID = 0x199, - BD_DIFFERENT_LEADERBOARD_SCHEMAS = 0x19A, - BD_TOO_MANY_LEADERBOARDS_REQUESTED = 0x19B, - BD_ENTITLEMENTS_ERROR = 0x19C, - BD_ENTITLEMENTS_INVALID_TITLEID = 0x19D, - BD_ENTITLEMENTS_INVALID_LEADERBOARDID = 0x19E, - BD_ENTITLEMENTS_INVALID_GET_MODE_FOR_TITLE = 0x19F, - BD_ENTITLEMENTS_URL_CONNECTION_ERROR = 0x1A0, - BD_ENTITLEMENTS_CONFIG_ERROR = 0x1A1, - BD_ENTITLEMENTS_NAMED_PARENT_ERROR = 0x1A2, - BD_ENTITLEMENTS_NAMED_KEY_ERROR = 0x1A3, - BD_TOO_MANY_ENTITY_IDS_REQUESTED = 0x1A4, - BD_STATS_READ_FAILED = 0x1A5, - BD_INVALID_TITLE_ID = 0x1F4, - BD_MESSAGING_INVALID_MAIL_ID = 0x258, - BD_SELF_BLOCK_NOT_ALLOWED = 0x259, - BD_GLOBAL_MESSAGE_ACCESS_DENIED = 0x25A, - BD_GLOBAL_MESSAGES_USER_LIMIT_EXCEEDED = 0x25B, - BD_MESSAGING_SENDER_DOES_NOT_EXIST = 0x25C, - BD_AUTH_NO_ERROR = 0x2BC, - BD_AUTH_BAD_REQUEST = 0x2BD, - BD_AUTH_SERVER_CONFIG_ERROR = 0x2BE, - BD_AUTH_BAD_TITLE_ID = 0x2BF, - BD_AUTH_BAD_ACCOUNT = 0x2C0, - BD_AUTH_ILLEGAL_OPERATION = 0x2C1, - BD_AUTH_INCORRECT_LICENSE_CODE = 0x2C2, - BD_AUTH_CREATE_USERNAME_EXISTS = 0x2C3, - BD_AUTH_CREATE_USERNAME_ILLEGAL = 0x2C4, - BD_AUTH_CREATE_USERNAME_VULGAR = 0x2C5, - BD_AUTH_CREATE_MAX_ACC_EXCEEDED = 0x2C6, - BD_AUTH_MIGRATE_NOT_SUPPORTED = 0x2C7, - BD_AUTH_TITLE_DISABLED = 0x2C8, - BD_AUTH_ACCOUNT_EXPIRED = 0x2C9, - BD_AUTH_ACCOUNT_LOCKED = 0x2CA, - BD_AUTH_UNKNOWN_ERROR = 0x2CB, - BD_AUTH_INCORRECT_PASSWORD = 0x2CC, - BD_AUTH_IP_NOT_IN_ALLOWED_RANGE = 0x2CD, - BD_AUTH_WII_TOKEN_VERIFICATION_FAILED = 0x2CE, - BD_AUTH_WII_AUTHENTICATION_FAILED = 0x2CF, - BD_AUTH_IP_KEY_LIMIT_REACHED = 0x2D0, - BD_AUTH_INVALID_GSPID = 0x2D1, - BD_AUTH_INVALID_IP_RANGE_ID = 0x2D2, - BD_AUTH_3DS_TOKEN_VERIFICATION_FAILED = 0x2D1, - BD_AUTH_3DS_AUTHENTICATION_FAILED = 0x2D2, - BD_AUTH_STEAM_APP_ID_MISMATCH = 0x2D3, - BD_AUTH_ABACCOUNTS_APP_ID_MISMATCH = 0x2D4, - BD_AUTH_CODO_USERNAME_NOT_SET = 0x2D5, - BD_AUTH_WIIU_TOKEN_VERIFICATION_FAILED = 0x2D6, - BD_AUTH_WIIU_AUTHENTICATION_FAILED = 0x2D7, - BD_AUTH_CODO_USERNAME_NOT_BASE64 = 0x2D8, - BD_AUTH_CODO_USERNAME_NOT_UTF8 = 0x2D9, - BD_AUTH_TENCENT_TICKET_EXPIRED = 0x2DA, - BD_AUTH_PS3_SERVICE_ID_MISMATCH = 0x2DB, - BD_AUTH_CODOID_NOT_WHITELISTED = 0x2DC, - BD_AUTH_PLATFORM_TOKEN_ERROR = 0x2DD, - BD_AUTH_JSON_FORMAT_ERROR = 0x2DE, - BD_AUTH_REPLY_CONTENT_ERROR = 0x2DF, - BD_AUTH_THIRD_PARTY_TOKEN_EXPIRED = 0x2E0, - BD_AUTH_CONTINUING = 0x2E1, - BD_AUTH_PLATFORM_DEVICE_ID_ERROR = 0x2E4, - BD_NO_PROFILE_INFO_EXISTS = 0x320, - BD_FRIENDSHIP_NOT_REQUSTED = 0x384, - BD_NOT_A_FRIEND = 0x385, - BD_SELF_FRIENDSHIP_NOT_ALLOWED = 0x387, - BD_FRIENDSHIP_EXISTS = 0x388, - BD_PENDING_FRIENDSHIP_EXISTS = 0x389, - BD_USERID_BANNED = 0x38A, - BD_FRIENDS_FULL = 0x38C, - BD_FRIENDS_NO_RICH_PRESENCE = 0x38D, - BD_RICH_PRESENCE_TOO_LARGE = 0x38E, - BD_NO_FILE = 0x3E8, - BD_PERMISSION_DENIED = 0x3E9, - BD_FILESIZE_LIMIT_EXCEEDED = 0x3EA, - BD_FILENAME_MAX_LENGTH_EXCEEDED = 0x3EB, - BD_EXTERNAL_STORAGE_SERVICE_ERROR = 0x3EC, - BD_CHANNEL_DOES_NOT_EXIST = 0x44D, - BD_CHANNEL_ALREADY_SUBSCRIBED = 0x44E, - BD_CHANNEL_NOT_SUBSCRIBED = 0x44F, - BD_CHANNEL_FULL = 0x450, - BD_CHANNEL_SUBSCRIPTIONS_FULL = 0x451, - BD_CHANNEL_NO_SELF_WHISPERING = 0x452, - BD_CHANNEL_ADMIN_REQUIRED = 0x453, - BD_CHANNEL_TARGET_NOT_SUBSCRIBED = 0x454, - BD_CHANNEL_REQUIRES_PASSWORD = 0x455, - BD_CHANNEL_TARGET_IS_SELF = 0x456, - BD_CHANNEL_PUBLIC_BAN_NOT_ALLOWED = 0x457, - BD_CHANNEL_USER_BANNED = 0x458, - BD_CHANNEL_PUBLIC_PASSWORD_NOT_ALLOWED = 0x459, - BD_CHANNEL_PUBLIC_KICK_NOT_ALLOWED = 0x45A, - BD_CHANNEL_MUTED = 0x45B, - BD_EVENT_DESC_TRUNCATED = 0x4B0, - BD_CONTENT_UNLOCK_UNKNOWN_ERROR = 0x514, - BD_UNLOCK_KEY_INVALID = 0x515, - BD_UNLOCK_KEY_ALREADY_USED_UP = 0x516, - BD_SHARED_UNLOCK_LIMIT_REACHED = 0x517, - BD_DIFFERENT_HARDWARE_ID = 0x518, - BD_INVALID_CONTENT_OWNER = 0x519, - BD_CONTENT_UNLOCK_INVALID_USER = 0x51A, - BD_CONTENT_UNLOCK_INVALID_CATEGORY = 0x51B, - BD_KEY_ARCHIVE_INVALID_WRITE_TYPE = 0x5DC, - BD_KEY_ARCHIVE_EXCEEDED_MAX_IDS_PER_REQUEST = 0x5DD, - BD_BANDWIDTH_TEST_TRY_AGAIN = 0x712, - BD_BANDWIDTH_TEST_STILL_IN_PROGRESS = 0x713, - BD_BANDWIDTH_TEST_NOT_PROGRESS = 0x714, - BD_BANDWIDTH_TEST_SOCKET_ERROR = 0x715, - BD_INVALID_SESSION_NONCE = 0x76D, - BD_ARBITRATION_FAILURE = 0x76F, - BD_ARBITRATION_USER_NOT_REGISTERED = 0x771, - BD_ARBITRATION_NOT_CONFIGURED = 0x772, - BD_CONTENTSTREAMING_FILE_NOT_AVAILABLE = 0x7D0, - BD_CONTENTSTREAMING_STORAGE_SPACE_EXCEEDED = 0x7D1, - BD_CONTENTSTREAMING_NUM_FILES_EXCEEDED = 0x7D2, - BD_CONTENTSTREAMING_UPLOAD_BANDWIDTH_EXCEEDED = 0x7D3, - BD_CONTENTSTREAMING_FILENAME_MAX_LENGTH_EXCEEDED = 0x7D4, - BD_CONTENTSTREAMING_MAX_THUMB_DATA_SIZE_EXCEEDED = 0x7D5, - BD_CONTENTSTREAMING_DOWNLOAD_BANDWIDTH_EXCEEDED = 0x7D6, - BD_CONTENTSTREAMING_NOT_ENOUGH_DOWNLOAD_BUFFER_SPACE = 0x7D7, - BD_CONTENTSTREAMING_SERVER_NOT_CONFIGURED = 0x7D8, - BD_CONTENTSTREAMING_INVALID_APPLE_RECEIPT = 0x7DA, - BD_CONTENTSTREAMING_APPLE_STORE_NOT_AVAILABLE = 0x7DB, - BD_CONTENTSTREAMING_APPLE_RECEIPT_FILENAME_MISMATCH = 0x7DC, - BD_CONTENTSTREAMING_HTTP_ERROR = 0x7E4, - BD_CONTENTSTREAMING_FAILED_TO_START_HTTP = 0x7E5, - BD_CONTENTSTREAMING_LOCALE_INVALID = 0x7E6, - BD_CONTENTSTREAMING_LOCALE_MISSING = 0x7E7, - BD_VOTERANK_ERROR_EMPTY_RATING_SUBMISSION = 0x7EE, - BD_VOTERANK_ERROR_MAX_VOTES_EXCEEDED = 0x7EF, - BD_VOTERANK_ERROR_INVALID_RATING = 0x7F0, - BD_MAX_NUM_TAGS_EXCEEDED = 0x82A, - BD_TAGGED_COLLECTION_DOES_NOT_EXIST = 0x82B, - BD_EMPTY_TAG_ARRAY = 0x82C, - BD_INVALID_QUERY_ID = 0x834, - BD_NO_ENTRY_TO_UPDATE = 0x835, - BD_SESSION_INVITE_EXISTS = 0x836, - BD_INVALID_SESSION_ID = 0x837, - BD_ATTACHMENT_TOO_LARGE = 0x838, - BD_INVALID_GROUP_ID = 0xAF0, - BD_MAIL_INVALID_MAIL_ID_ERROR = 0xB55, - BD_UCD_SERVICE_ERROR = 0xC80, - BD_UCD_SERVICE_DISABLED = 0xC81, - BD_UCD_UNINTIALIZED_ERROR = 0xC82, - BD_UCD_ACCOUNT_ALREADY_REGISTERED = 0xC83, - BD_UCD_ACCOUNT_NOT_REGISTERED = 0xC84, - BD_UCD_AUTH_ATTEMPT_FAILED = 0xC85, - BD_UCD_ACCOUNT_LINKING_ERROR = 0xC86, - BD_UCD_ENCRYPTION_ERROR = 0xC87, - BD_UCD_ACCOUNT_DATA_INVALID = 0xC88, - BD_UCD_ACCOUNT_DATA_INVALID_FIRSTNAME = 0xC89, - BD_UCD_ACCOUNT_DATA_INVALID_LASTNAME = 0xC8A, - BD_UCD_ACCOUNT_DATA_INVALID_DOB = 0xC8B, - BD_UCD_ACCOUNT_DATA_INVALID_EMAIL = 0xC8C, - BD_UCD_ACCOUNT_DATA_INVALID_COUNTRY = 0xC8D, - BD_UCD_ACCOUNT_DATA_INVALID_POSTCODE = 0xC8E, - BD_UCD_ACCOUNT_DATA_INVALID_PASSWORD = 0xC8F, - BD_UCD_ACCOUNT_NAME_ALREADY_RESISTERED = 0xC94, - BD_UCD_ACCOUNT_EMAIL_ALREADY_RESISTERED = 0xC95, - BD_UCD_GUEST_ACCOUNT_AUTH_CONFLICT = 0xC96, - BD_TWITCH_SERVICE_ERROR = 0xC1D, - BD_TWITCH_ACCOUNT_ALREADY_LINKED = 0xC1E, - BD_TWITCH_NO_LINKED_ACCOUNT = 0xC1F, - BD_YOUTUBE_SERVICE_ERROR = 0xCE5, - BD_YOUTUBE_SERVICE_COMMUNICATION_ERROR = 0xCE6, - BD_YOUTUBE_USER_DENIED_AUTHORIZATION = 0xCE7, - BD_YOUTUBE_AUTH_MAX_TIME_EXCEEDED = 0xCE8, - BD_YOUTUBE_USER_UNAUTHORIZED = 0xCE9, - BD_YOUTUBE_UPLOAD_MAX_TIME_EXCEEDED = 0xCEA, - BD_YOUTUBE_DUPLICATE_UPLOAD = 0xCEB, - BD_YOUTUBE_FAILED_UPLOAD = 0xCEC, - BD_YOUTUBE_ACCOUNT_ALREADY_REGISTERED = 0xCED, - BD_YOUTUBE_ACCOUNT_NOT_REGISTERED = 0xCEE, - BD_YOUTUBE_CONTENT_SERVER_ERROR = 0xCEF, - BD_YOUTUBE_UPLOAD_DOES_NOT_EXIST = 0xCF0, - BD_YOUTUBE_NO_LINKED_ACCOUNT = 0xCF1, - BD_YOUTUBE_DEVELOPER_TAGS_INVALID = 0xCF2, - BD_TWITTER_AUTH_ATTEMPT_FAILED = 0xDAD, - BD_TWITTER_AUTH_TOKEN_INVALID = 0xDAE, - BD_TWITTER_UPDATE_LIMIT_REACHED = 0xDAF, - BD_TWITTER_UNAVAILABLE = 0xDB0, - BD_TWITTER_ERROR = 0xDB1, - BD_TWITTER_TIMED_OUT = 0xDB2, - BD_TWITTER_DISABLED_FOR_USER = 0xDB3, - BD_TWITTER_ACCOUNT_AMBIGUOUS = 0xDB4, - BD_TWITTER_MAXIMUM_ACCOUNTS_REACHED = 0xDB5, - BD_TWITTER_ACCOUNT_NOT_REGISTERED = 0xDB6, - BD_TWITTER_DUPLICATE_STATUS = 0xDB7, - BD_TWITTER_ACCOUNT_ALREADY_REGISTERED = 0xE1C, - BD_FACEBOOK_AUTH_ATTEMPT_FAILED = 0xE11, - BD_FACEBOOK_AUTH_TOKEN_INVALID = 0xE12, - BD_FACEBOOK_PHOTO_DOES_NOT_EXIST = 0xE13, - BD_FACEBOOK_PHOTO_INVALID = 0xE14, - BD_FACEBOOK_PHOTO_ALBUM_FULL = 0xE15, - BD_FACEBOOK_UNAVAILABLE = 0xE16, - BD_FACEBOOK_ERROR = 0xE17, - BD_FACEBOOK_TIMED_OUT = 0xE18, - BD_FACEBOOK_DISABLED_FOR_USER = 0xE19, - BD_FACEBOOK_ACCOUNT_AMBIGUOUS = 0xE1A, - BD_FACEBOOK_MAXIMUM_ACCOUNTS_REACHED = 0xE1B, - BD_FACEBOOK_INVALID_NUM_PICTURES_REQUESTED = 0xE1C, - BD_FACEBOOK_VIDEO_DOES_NOT_EXIST = 0xE1D, - BD_FACEBOOK_ACCOUNT_ALREADY_REGISTERED = 0xE1E, - BD_APNS_INVALID_PAYLOAD = 0xE74, - BD_APNS_INVALID_TOKEN_LENGTH_ERROR = 0xE76, - BD_MAX_CONSOLEID_LENGTH_EXCEEDED = 0xEE1, - BD_MAX_WHITELIST_LENGTH_EXCEEDED = 0xEE2, - BD_USERGROUP_NAME_ALREADY_EXISTS = 0x1770, - BD_INVALID_USERGROUP_ID = 0x1771, - BD_USER_ALREADY_IN_USERGROUP = 0x1772, - BD_USER_NOT_IN_USERGROUP = 0x1773, - BD_INVALID_USERGROUP_MEMBER_TYPE = 0x1774, - BD_TOO_MANY_MEMBERS_REQUESTED = 0x1775, - BD_USERGROUP_NAME_TOO_SHORT = 0x1776, - BD_RICH_PRESENCE_DATA_TOO_LARGE = 0x1A90, - BD_RICH_PRESENCE_TOO_MANY_USERS = 0x1A91, - BD_PRESENCE_DATA_TOO_LARGE = 0x283C, - BD_PRESENCE_TOO_MANY_USERS = 0x283D, - BD_USER_LOGGED_IN_OTHER_TITLE = 0x283E, - BD_USER_NOT_LOGGED_IN = 0x283F, - BD_SUBSCRIPTION_TOO_MANY_USERS = 0x1B58, - BD_SUBSCRIPTION_TICKET_PARSE_ERROR = 0x1B59, - BD_CODO_ID_INVALID_DATA = 0x1BBC, - BD_INVALID_MESSAGE_FORMAT = 0x1BBD, - BD_TLOG_TOO_MANY_MESSAGES = 0x1BBE, - BD_CODO_ID_NOT_IN_WHITELIST = 0x1BBF, - BD_TLOG_MESSAGE_TRANSFORMATION_ERROR = 0x1BC0, - BD_REWARDS_NOT_ENABLED = 0x1BC1, - BD_MARKETPLACE_ERROR = 0x1F40, - BD_MARKETPLACE_RESOURCE_NOT_FOUND = 0x1F41, - BD_MARKETPLACE_INVALID_CURRENCY = 0x1F42, - BD_MARKETPLACE_INVALID_PARAMETER = 0x1F43, - BD_MARKETPLACE_RESOURCE_CONFLICT = 0x1F44, - BD_MARKETPLACE_STORAGE_ERROR = 0x1F45, - BD_MARKETPLACE_INTEGRITY_ERROR = 0x1F46, - BD_MARKETPLACE_INSUFFICIENT_FUNDS_ERROR = 0x1F47, - BD_MARKETPLACE_MMP_SERVICE_ERROR = 0x1F48, - BD_MARKETPLACE_PRECONDITION_REQUIRED = 0x1F49, - BD_MARKETPLACE_ITEM_MULTIPLE_PURCHASE_ERROR = 0x1F4A, - BD_MARKETPLACE_MISSING_REQUIRED_ENTITLEMENT = 0x1F4B, - BD_MARKETPLACE_VALIDATION_ERROR = 0x1F4C, - BD_MARKETPLACE_TENCENT_PAYMENT_ERROR = 0x1F4D, - BD_MARKETPLACE_SKU_NOT_COUPON_ENABLED_ERROR = 0x1F4E, - BD_LEAGUE_INVALID_TEAM_SIZE = 0x1FA4, - BD_LEAGUE_INVALID_TEAM = 0x1FA5, - BD_LEAGUE_INVALID_SUBDIVISION = 0x1FA6, - BD_LEAGUE_INVALID_LEAGUE = 0x1FA7, - BD_LEAGUE_TOO_MANY_RESULTS_REQUESTED = 0x1FA8, - BD_LEAGUE_METADATA_TOO_LARGE = 0x1FA9, - BD_LEAGUE_TEAM_ICON_TOO_LARGE = 0x1FAA, - BD_LEAGUE_TEAM_NAME_TOO_LONG = 0x1FAB, - BD_LEAGUE_ARRAY_SIZE_MISMATCH = 0x1FAC, - BD_LEAGUE_SUBDIVISION_MISMATCH = 0x2008, - BD_LEAGUE_INVALID_WRITE_TYPE = 0x2009, - BD_LEAGUE_INVALID_STATS_DATA = 0x200A, - BD_LEAGUE_SUBDIVISION_UNRANKED = 0x200B, - BD_LEAGUE_CROSS_TEAM_STATS_WRITE_PREVENTED = 0x200C, - BD_LEAGUE_INVALID_STATS_SEASON = 0x200D, - BD_COMMERCE_ERROR = 0x206C, - BD_COMMERCE_RESOURCE_NOT_FOUND = 0x206D, - BD_COMMERCE_STORAGE_INVALID_PARAMETER = 0x206E, - BD_COMMERCE_APPLICATION_INVALID_PARAMETER = 0x206F, - BD_COMMERCE_RESOURCE_CONFLICT = 0x2070, - BD_COMMERCE_STORAGE_ERROR = 0x2071, - BD_COMMERCE_INTEGRITY_ERROR = 0x2072, - BD_COMMERCE_MMP_SERVICE_ERROR = 0x2073, - BD_COMMERCE_PERMISSION_DENIED = 0x2074, - BD_COMMERCE_INSUFFICIENT_FUNDS_ERROR = 0x2075, - BD_COMMERCE_UNKNOWN_CURRENCY = 0x2076, - BD_COMMERCE_INVALID_RECEIPT = 0x2077, - BD_COMMERCE_RECEIPT_USED = 0x2078, - BD_COMMERCE_TRANSACTION_ALREADY_APPLIED = 0x2079, - BD_COMMERCE_INVALID_CURRENCY_TYPE = 0x207A, - BD_CONNECTION_COUNTER_ERROR = 0x20D0, - BD_LINKED_ACCOUNTS_INVALID_CONTEXT = 0x2198, - BD_LINKED_ACCOUNTS_INVALID_PLATFORM = 0x2199, - BD_LINKED_ACCOUNTS_LINKED_ACCOUNTS_FETCH_ERROR = 0x219A, - BD_LINKED_ACCOUNTS_INVALID_ACCOUNT = 0x219B, - BD_GMSG_INVALID_CATEGORY_ID = 0x27D8, - BD_GMSG_CATEGORY_MEMBERSHIPS_LIMIT = 0x27D9, - BD_GMSG_NONMEMBER_POST_DISALLOWED = 0x27DA, - BD_GMSG_CATEGORY_DISALLOWS_CLIENT_TYPE = 0x27DB, - BD_GMSG_PAYLOAD_TOO_BIG = 0x27DC, - BD_GMSG_MEMBER_POST_DISALLOWED = 0x27DD, - BD_GMSG_OVERLOADED = 0x27DE, - BD_GMSG_USER_PERCATEGORY_POST_RATE_EXCEEDED = 0x27DF, - BD_GMSG_USER_GLOBAL_POST_RATE_EXCEEDED = 0x27E0, - BD_GMSG_GROUP_POST_RATE_EXCEEDED = 0x27E1, - BD_MAX_ERROR_CODE = 0x27E2, - }; - - enum bdNATType : uint8_t - { - BD_NAT_UNKNOWN = 0x0, - BD_NAT_OPEN = 0x1, - BD_NAT_MODERATE = 0x2, - BD_NAT_STRICT = 0x3, - }; - -#pragma pack(push, 1) - struct bdAuthTicket - { - unsigned int m_magicNumber; - char m_type; - unsigned int m_titleID; - unsigned int m_timeIssued; - unsigned int m_timeExpires; - unsigned __int64 m_licenseID; - unsigned __int64 m_userID; - char m_username[64]; - char m_sessionKey[24]; - char m_usingHashMagicNumber[3]; - char m_hash[4]; - }; -#pragma pack(pop) - - struct cmd_function_t - { - cmd_function_t* next; - const char* name; - const char* autoCompleteDir; - const char* autoCompleteExt; - void (__cdecl *function)(); - int flags; - }; - - struct msg_t - { - int overflowed; - int readOnly; - char* data; - char* splitData; - int maxsize; - int cursize; - int splitSize; - int readcount; - int bit; - int lastEntityRef; - }; - - struct XZoneInfo - { - const char* name; - int allocFlags; - int freeFlags; - }; - - struct scr_entref_raw - { - unsigned __int16 entnum; - unsigned __int16 classnum; - }; - - union scr_entref_t - { - unsigned int val; - scr_entref_raw raw; - }; - - typedef void (__cdecl * scr_call_t)(int entref); - - enum scriptType_e - { - SCRIPT_NONE = 0, - SCRIPT_OBJECT = 1, - SCRIPT_STRING = 2, - SCRIPT_VECTOR = 4, - SCRIPT_FLOAT = 5, - SCRIPT_INTEGER = 6, - SCRIPT_END = 8, - // Custom - }; - - struct VariableStackBuffer - { - const char* pos; - unsigned __int16 size; - unsigned __int16 bufLen; - unsigned __int16 localId; - char time; - char buf[1]; - }; - - union VariableUnion - { - int intValue; - float floatValue; - unsigned int stringValue; - const float* vectorValue; - const char* codePosValue; - unsigned int pointerValue; - VariableStackBuffer* stackValue; - unsigned int entityId; - }; - - struct VariableValue - { - VariableUnion u; - scriptType_e type; - }; - - struct function_stack_t - { - const char* pos; - unsigned int localId; - unsigned int localVarCount; - VariableValue* top; - VariableValue* startTop; - }; - - struct function_frame_t - { - function_stack_t fs; - int topType; - }; - - struct scrVmPub_t - { - unsigned int* localVars; - VariableValue* maxstack; - int function_count; - function_frame_t* function_frame; - VariableValue* top; +#pragma once + +namespace game +{ + namespace native + { + enum bdLobbyErrorCode : uint32_t + { + BD_NO_ERROR = 0x0, + BD_TOO_MANY_TASKS = 0x1, + BD_NOT_CONNECTED = 0x2, + BD_SEND_FAILED = 0x3, + BD_HANDLE_TASK_FAILED = 0x4, + BD_START_TASK_FAILED = 0x5, + BD_RESULT_EXCEEDS_BUFFER_SIZE = 0x64, + BD_ACCESS_DENIED = 0x65, + BD_EXCEPTION_IN_DB = 0x66, + BD_MALFORMED_TASK_HEADER = 0x67, + BD_INVALID_ROW = 0x68, + BD_EMPTY_ARG_LIST = 0x69, + BD_PARAM_PARSE_ERROR = 0x6A, + BD_PARAM_MISMATCHED_TYPE = 0x6B, + BD_SERVICE_NOT_AVAILABLE = 0x6C, + BD_CONNECTION_RESET = 0x6D, + BD_INVALID_USER_ID = 0x6E, + BD_LOBBY_PROTOCOL_VERSION_FAILURE = 0x6F, + BD_LOBBY_INTERNAL_FAILURE = 0x70, + BD_LOBBY_PROTOCOL_ERROR = 0x71, + BD_LOBBY_FAILED_TO_DECODE_UTF8 = 0x72, + BD_LOBBY_ASCII_EXPECTED = 0x73, + BD_ASYNCHRONOUS_ERROR = 0xC8, + BD_STREAMING_COMPLETE = 0xC9, + BD_MEMBER_NO_PROPOSAL = 0x12C, + BD_TEAMNAME_ALREADY_EXISTS = 0x12D, + BD_MAX_TEAM_MEMBERSHIPS_LIMITED = 0x12E, + BD_MAX_TEAM_OWNERSHIPS_LIMITED = 0x12F, + BD_NOT_A_TEAM_MEMBER = 0x130, + BD_INVALID_TEAM_ID = 0x131, + BD_INVALID_TEAM_NAME = 0x132, + BD_NOT_A_TEAM_OWNER = 0x133, + BD_NOT_AN_ADMIN_OR_OWNER = 0x134, + BD_MEMBER_PROPOSAL_EXISTS = 0x135, + BD_MEMBER_EXISTS = 0x136, + BD_TEAM_FULL = 0x137, + BD_VULGAR_TEAM_NAME = 0x138, + BD_TEAM_USERID_BANNED = 0x139, + BD_TEAM_EMPTY = 0x13A, + BD_INVALID_TEAM_PROFILE_QUERY_ID = 0x13B, + BD_TEAMNAME_TOO_SHORT = 0x13C, + BD_UNIQUE_PROFILE_DATA_EXISTS_ALREADY = 0x13D, + BD_INVALID_LEADERBOARD_ID = 0x190, + BD_INVALID_STATS_SET = 0x191, + BD_EMPTY_STATS_SET_IGNORED = 0x193, + BD_NO_DIRECT_ACCESS_TO_ARBITRATED_LBS = 0x194, + BD_STATS_WRITE_PERMISSION_DENIED = 0x195, + BD_STATS_WRITE_TYPE_DATA_TYPE_MISMATCH = 0x196, + BD_NO_STATS_FOR_USER = 0x197, + BD_INVALID_ACCESS_TO_UNRANKED_LB = 0x198, + BD_INVALID_EXTERNAL_TITLE_ID = 0x199, + BD_DIFFERENT_LEADERBOARD_SCHEMAS = 0x19A, + BD_TOO_MANY_LEADERBOARDS_REQUESTED = 0x19B, + BD_ENTITLEMENTS_ERROR = 0x19C, + BD_ENTITLEMENTS_INVALID_TITLEID = 0x19D, + BD_ENTITLEMENTS_INVALID_LEADERBOARDID = 0x19E, + BD_ENTITLEMENTS_INVALID_GET_MODE_FOR_TITLE = 0x19F, + BD_ENTITLEMENTS_URL_CONNECTION_ERROR = 0x1A0, + BD_ENTITLEMENTS_CONFIG_ERROR = 0x1A1, + BD_ENTITLEMENTS_NAMED_PARENT_ERROR = 0x1A2, + BD_ENTITLEMENTS_NAMED_KEY_ERROR = 0x1A3, + BD_TOO_MANY_ENTITY_IDS_REQUESTED = 0x1A4, + BD_STATS_READ_FAILED = 0x1A5, + BD_INVALID_TITLE_ID = 0x1F4, + BD_MESSAGING_INVALID_MAIL_ID = 0x258, + BD_SELF_BLOCK_NOT_ALLOWED = 0x259, + BD_GLOBAL_MESSAGE_ACCESS_DENIED = 0x25A, + BD_GLOBAL_MESSAGES_USER_LIMIT_EXCEEDED = 0x25B, + BD_MESSAGING_SENDER_DOES_NOT_EXIST = 0x25C, + BD_AUTH_NO_ERROR = 0x2BC, + BD_AUTH_BAD_REQUEST = 0x2BD, + BD_AUTH_SERVER_CONFIG_ERROR = 0x2BE, + BD_AUTH_BAD_TITLE_ID = 0x2BF, + BD_AUTH_BAD_ACCOUNT = 0x2C0, + BD_AUTH_ILLEGAL_OPERATION = 0x2C1, + BD_AUTH_INCORRECT_LICENSE_CODE = 0x2C2, + BD_AUTH_CREATE_USERNAME_EXISTS = 0x2C3, + BD_AUTH_CREATE_USERNAME_ILLEGAL = 0x2C4, + BD_AUTH_CREATE_USERNAME_VULGAR = 0x2C5, + BD_AUTH_CREATE_MAX_ACC_EXCEEDED = 0x2C6, + BD_AUTH_MIGRATE_NOT_SUPPORTED = 0x2C7, + BD_AUTH_TITLE_DISABLED = 0x2C8, + BD_AUTH_ACCOUNT_EXPIRED = 0x2C9, + BD_AUTH_ACCOUNT_LOCKED = 0x2CA, + BD_AUTH_UNKNOWN_ERROR = 0x2CB, + BD_AUTH_INCORRECT_PASSWORD = 0x2CC, + BD_AUTH_IP_NOT_IN_ALLOWED_RANGE = 0x2CD, + BD_AUTH_WII_TOKEN_VERIFICATION_FAILED = 0x2CE, + BD_AUTH_WII_AUTHENTICATION_FAILED = 0x2CF, + BD_AUTH_IP_KEY_LIMIT_REACHED = 0x2D0, + BD_AUTH_INVALID_GSPID = 0x2D1, + BD_AUTH_INVALID_IP_RANGE_ID = 0x2D2, + BD_AUTH_3DS_TOKEN_VERIFICATION_FAILED = 0x2D1, + BD_AUTH_3DS_AUTHENTICATION_FAILED = 0x2D2, + BD_AUTH_STEAM_APP_ID_MISMATCH = 0x2D3, + BD_AUTH_ABACCOUNTS_APP_ID_MISMATCH = 0x2D4, + BD_AUTH_CODO_USERNAME_NOT_SET = 0x2D5, + BD_AUTH_WIIU_TOKEN_VERIFICATION_FAILED = 0x2D6, + BD_AUTH_WIIU_AUTHENTICATION_FAILED = 0x2D7, + BD_AUTH_CODO_USERNAME_NOT_BASE64 = 0x2D8, + BD_AUTH_CODO_USERNAME_NOT_UTF8 = 0x2D9, + BD_AUTH_TENCENT_TICKET_EXPIRED = 0x2DA, + BD_AUTH_PS3_SERVICE_ID_MISMATCH = 0x2DB, + BD_AUTH_CODOID_NOT_WHITELISTED = 0x2DC, + BD_AUTH_PLATFORM_TOKEN_ERROR = 0x2DD, + BD_AUTH_JSON_FORMAT_ERROR = 0x2DE, + BD_AUTH_REPLY_CONTENT_ERROR = 0x2DF, + BD_AUTH_THIRD_PARTY_TOKEN_EXPIRED = 0x2E0, + BD_AUTH_CONTINUING = 0x2E1, + BD_AUTH_PLATFORM_DEVICE_ID_ERROR = 0x2E4, + BD_NO_PROFILE_INFO_EXISTS = 0x320, + BD_FRIENDSHIP_NOT_REQUSTED = 0x384, + BD_NOT_A_FRIEND = 0x385, + BD_SELF_FRIENDSHIP_NOT_ALLOWED = 0x387, + BD_FRIENDSHIP_EXISTS = 0x388, + BD_PENDING_FRIENDSHIP_EXISTS = 0x389, + BD_USERID_BANNED = 0x38A, + BD_FRIENDS_FULL = 0x38C, + BD_FRIENDS_NO_RICH_PRESENCE = 0x38D, + BD_RICH_PRESENCE_TOO_LARGE = 0x38E, + BD_NO_FILE = 0x3E8, + BD_PERMISSION_DENIED = 0x3E9, + BD_FILESIZE_LIMIT_EXCEEDED = 0x3EA, + BD_FILENAME_MAX_LENGTH_EXCEEDED = 0x3EB, + BD_EXTERNAL_STORAGE_SERVICE_ERROR = 0x3EC, + BD_CHANNEL_DOES_NOT_EXIST = 0x44D, + BD_CHANNEL_ALREADY_SUBSCRIBED = 0x44E, + BD_CHANNEL_NOT_SUBSCRIBED = 0x44F, + BD_CHANNEL_FULL = 0x450, + BD_CHANNEL_SUBSCRIPTIONS_FULL = 0x451, + BD_CHANNEL_NO_SELF_WHISPERING = 0x452, + BD_CHANNEL_ADMIN_REQUIRED = 0x453, + BD_CHANNEL_TARGET_NOT_SUBSCRIBED = 0x454, + BD_CHANNEL_REQUIRES_PASSWORD = 0x455, + BD_CHANNEL_TARGET_IS_SELF = 0x456, + BD_CHANNEL_PUBLIC_BAN_NOT_ALLOWED = 0x457, + BD_CHANNEL_USER_BANNED = 0x458, + BD_CHANNEL_PUBLIC_PASSWORD_NOT_ALLOWED = 0x459, + BD_CHANNEL_PUBLIC_KICK_NOT_ALLOWED = 0x45A, + BD_CHANNEL_MUTED = 0x45B, + BD_EVENT_DESC_TRUNCATED = 0x4B0, + BD_CONTENT_UNLOCK_UNKNOWN_ERROR = 0x514, + BD_UNLOCK_KEY_INVALID = 0x515, + BD_UNLOCK_KEY_ALREADY_USED_UP = 0x516, + BD_SHARED_UNLOCK_LIMIT_REACHED = 0x517, + BD_DIFFERENT_HARDWARE_ID = 0x518, + BD_INVALID_CONTENT_OWNER = 0x519, + BD_CONTENT_UNLOCK_INVALID_USER = 0x51A, + BD_CONTENT_UNLOCK_INVALID_CATEGORY = 0x51B, + BD_KEY_ARCHIVE_INVALID_WRITE_TYPE = 0x5DC, + BD_KEY_ARCHIVE_EXCEEDED_MAX_IDS_PER_REQUEST = 0x5DD, + BD_BANDWIDTH_TEST_TRY_AGAIN = 0x712, + BD_BANDWIDTH_TEST_STILL_IN_PROGRESS = 0x713, + BD_BANDWIDTH_TEST_NOT_PROGRESS = 0x714, + BD_BANDWIDTH_TEST_SOCKET_ERROR = 0x715, + BD_INVALID_SESSION_NONCE = 0x76D, + BD_ARBITRATION_FAILURE = 0x76F, + BD_ARBITRATION_USER_NOT_REGISTERED = 0x771, + BD_ARBITRATION_NOT_CONFIGURED = 0x772, + BD_CONTENTSTREAMING_FILE_NOT_AVAILABLE = 0x7D0, + BD_CONTENTSTREAMING_STORAGE_SPACE_EXCEEDED = 0x7D1, + BD_CONTENTSTREAMING_NUM_FILES_EXCEEDED = 0x7D2, + BD_CONTENTSTREAMING_UPLOAD_BANDWIDTH_EXCEEDED = 0x7D3, + BD_CONTENTSTREAMING_FILENAME_MAX_LENGTH_EXCEEDED = 0x7D4, + BD_CONTENTSTREAMING_MAX_THUMB_DATA_SIZE_EXCEEDED = 0x7D5, + BD_CONTENTSTREAMING_DOWNLOAD_BANDWIDTH_EXCEEDED = 0x7D6, + BD_CONTENTSTREAMING_NOT_ENOUGH_DOWNLOAD_BUFFER_SPACE = 0x7D7, + BD_CONTENTSTREAMING_SERVER_NOT_CONFIGURED = 0x7D8, + BD_CONTENTSTREAMING_INVALID_APPLE_RECEIPT = 0x7DA, + BD_CONTENTSTREAMING_APPLE_STORE_NOT_AVAILABLE = 0x7DB, + BD_CONTENTSTREAMING_APPLE_RECEIPT_FILENAME_MISMATCH = 0x7DC, + BD_CONTENTSTREAMING_HTTP_ERROR = 0x7E4, + BD_CONTENTSTREAMING_FAILED_TO_START_HTTP = 0x7E5, + BD_CONTENTSTREAMING_LOCALE_INVALID = 0x7E6, + BD_CONTENTSTREAMING_LOCALE_MISSING = 0x7E7, + BD_VOTERANK_ERROR_EMPTY_RATING_SUBMISSION = 0x7EE, + BD_VOTERANK_ERROR_MAX_VOTES_EXCEEDED = 0x7EF, + BD_VOTERANK_ERROR_INVALID_RATING = 0x7F0, + BD_MAX_NUM_TAGS_EXCEEDED = 0x82A, + BD_TAGGED_COLLECTION_DOES_NOT_EXIST = 0x82B, + BD_EMPTY_TAG_ARRAY = 0x82C, + BD_INVALID_QUERY_ID = 0x834, + BD_NO_ENTRY_TO_UPDATE = 0x835, + BD_SESSION_INVITE_EXISTS = 0x836, + BD_INVALID_SESSION_ID = 0x837, + BD_ATTACHMENT_TOO_LARGE = 0x838, + BD_INVALID_GROUP_ID = 0xAF0, + BD_MAIL_INVALID_MAIL_ID_ERROR = 0xB55, + BD_UCD_SERVICE_ERROR = 0xC80, + BD_UCD_SERVICE_DISABLED = 0xC81, + BD_UCD_UNINTIALIZED_ERROR = 0xC82, + BD_UCD_ACCOUNT_ALREADY_REGISTERED = 0xC83, + BD_UCD_ACCOUNT_NOT_REGISTERED = 0xC84, + BD_UCD_AUTH_ATTEMPT_FAILED = 0xC85, + BD_UCD_ACCOUNT_LINKING_ERROR = 0xC86, + BD_UCD_ENCRYPTION_ERROR = 0xC87, + BD_UCD_ACCOUNT_DATA_INVALID = 0xC88, + BD_UCD_ACCOUNT_DATA_INVALID_FIRSTNAME = 0xC89, + BD_UCD_ACCOUNT_DATA_INVALID_LASTNAME = 0xC8A, + BD_UCD_ACCOUNT_DATA_INVALID_DOB = 0xC8B, + BD_UCD_ACCOUNT_DATA_INVALID_EMAIL = 0xC8C, + BD_UCD_ACCOUNT_DATA_INVALID_COUNTRY = 0xC8D, + BD_UCD_ACCOUNT_DATA_INVALID_POSTCODE = 0xC8E, + BD_UCD_ACCOUNT_DATA_INVALID_PASSWORD = 0xC8F, + BD_UCD_ACCOUNT_NAME_ALREADY_RESISTERED = 0xC94, + BD_UCD_ACCOUNT_EMAIL_ALREADY_RESISTERED = 0xC95, + BD_UCD_GUEST_ACCOUNT_AUTH_CONFLICT = 0xC96, + BD_TWITCH_SERVICE_ERROR = 0xC1D, + BD_TWITCH_ACCOUNT_ALREADY_LINKED = 0xC1E, + BD_TWITCH_NO_LINKED_ACCOUNT = 0xC1F, + BD_YOUTUBE_SERVICE_ERROR = 0xCE5, + BD_YOUTUBE_SERVICE_COMMUNICATION_ERROR = 0xCE6, + BD_YOUTUBE_USER_DENIED_AUTHORIZATION = 0xCE7, + BD_YOUTUBE_AUTH_MAX_TIME_EXCEEDED = 0xCE8, + BD_YOUTUBE_USER_UNAUTHORIZED = 0xCE9, + BD_YOUTUBE_UPLOAD_MAX_TIME_EXCEEDED = 0xCEA, + BD_YOUTUBE_DUPLICATE_UPLOAD = 0xCEB, + BD_YOUTUBE_FAILED_UPLOAD = 0xCEC, + BD_YOUTUBE_ACCOUNT_ALREADY_REGISTERED = 0xCED, + BD_YOUTUBE_ACCOUNT_NOT_REGISTERED = 0xCEE, + BD_YOUTUBE_CONTENT_SERVER_ERROR = 0xCEF, + BD_YOUTUBE_UPLOAD_DOES_NOT_EXIST = 0xCF0, + BD_YOUTUBE_NO_LINKED_ACCOUNT = 0xCF1, + BD_YOUTUBE_DEVELOPER_TAGS_INVALID = 0xCF2, + BD_TWITTER_AUTH_ATTEMPT_FAILED = 0xDAD, + BD_TWITTER_AUTH_TOKEN_INVALID = 0xDAE, + BD_TWITTER_UPDATE_LIMIT_REACHED = 0xDAF, + BD_TWITTER_UNAVAILABLE = 0xDB0, + BD_TWITTER_ERROR = 0xDB1, + BD_TWITTER_TIMED_OUT = 0xDB2, + BD_TWITTER_DISABLED_FOR_USER = 0xDB3, + BD_TWITTER_ACCOUNT_AMBIGUOUS = 0xDB4, + BD_TWITTER_MAXIMUM_ACCOUNTS_REACHED = 0xDB5, + BD_TWITTER_ACCOUNT_NOT_REGISTERED = 0xDB6, + BD_TWITTER_DUPLICATE_STATUS = 0xDB7, + BD_TWITTER_ACCOUNT_ALREADY_REGISTERED = 0xE1C, + BD_FACEBOOK_AUTH_ATTEMPT_FAILED = 0xE11, + BD_FACEBOOK_AUTH_TOKEN_INVALID = 0xE12, + BD_FACEBOOK_PHOTO_DOES_NOT_EXIST = 0xE13, + BD_FACEBOOK_PHOTO_INVALID = 0xE14, + BD_FACEBOOK_PHOTO_ALBUM_FULL = 0xE15, + BD_FACEBOOK_UNAVAILABLE = 0xE16, + BD_FACEBOOK_ERROR = 0xE17, + BD_FACEBOOK_TIMED_OUT = 0xE18, + BD_FACEBOOK_DISABLED_FOR_USER = 0xE19, + BD_FACEBOOK_ACCOUNT_AMBIGUOUS = 0xE1A, + BD_FACEBOOK_MAXIMUM_ACCOUNTS_REACHED = 0xE1B, + BD_FACEBOOK_INVALID_NUM_PICTURES_REQUESTED = 0xE1C, + BD_FACEBOOK_VIDEO_DOES_NOT_EXIST = 0xE1D, + BD_FACEBOOK_ACCOUNT_ALREADY_REGISTERED = 0xE1E, + BD_APNS_INVALID_PAYLOAD = 0xE74, + BD_APNS_INVALID_TOKEN_LENGTH_ERROR = 0xE76, + BD_MAX_CONSOLEID_LENGTH_EXCEEDED = 0xEE1, + BD_MAX_WHITELIST_LENGTH_EXCEEDED = 0xEE2, + BD_USERGROUP_NAME_ALREADY_EXISTS = 0x1770, + BD_INVALID_USERGROUP_ID = 0x1771, + BD_USER_ALREADY_IN_USERGROUP = 0x1772, + BD_USER_NOT_IN_USERGROUP = 0x1773, + BD_INVALID_USERGROUP_MEMBER_TYPE = 0x1774, + BD_TOO_MANY_MEMBERS_REQUESTED = 0x1775, + BD_USERGROUP_NAME_TOO_SHORT = 0x1776, + BD_RICH_PRESENCE_DATA_TOO_LARGE = 0x1A90, + BD_RICH_PRESENCE_TOO_MANY_USERS = 0x1A91, + BD_PRESENCE_DATA_TOO_LARGE = 0x283C, + BD_PRESENCE_TOO_MANY_USERS = 0x283D, + BD_USER_LOGGED_IN_OTHER_TITLE = 0x283E, + BD_USER_NOT_LOGGED_IN = 0x283F, + BD_SUBSCRIPTION_TOO_MANY_USERS = 0x1B58, + BD_SUBSCRIPTION_TICKET_PARSE_ERROR = 0x1B59, + BD_CODO_ID_INVALID_DATA = 0x1BBC, + BD_INVALID_MESSAGE_FORMAT = 0x1BBD, + BD_TLOG_TOO_MANY_MESSAGES = 0x1BBE, + BD_CODO_ID_NOT_IN_WHITELIST = 0x1BBF, + BD_TLOG_MESSAGE_TRANSFORMATION_ERROR = 0x1BC0, + BD_REWARDS_NOT_ENABLED = 0x1BC1, + BD_MARKETPLACE_ERROR = 0x1F40, + BD_MARKETPLACE_RESOURCE_NOT_FOUND = 0x1F41, + BD_MARKETPLACE_INVALID_CURRENCY = 0x1F42, + BD_MARKETPLACE_INVALID_PARAMETER = 0x1F43, + BD_MARKETPLACE_RESOURCE_CONFLICT = 0x1F44, + BD_MARKETPLACE_STORAGE_ERROR = 0x1F45, + BD_MARKETPLACE_INTEGRITY_ERROR = 0x1F46, + BD_MARKETPLACE_INSUFFICIENT_FUNDS_ERROR = 0x1F47, + BD_MARKETPLACE_MMP_SERVICE_ERROR = 0x1F48, + BD_MARKETPLACE_PRECONDITION_REQUIRED = 0x1F49, + BD_MARKETPLACE_ITEM_MULTIPLE_PURCHASE_ERROR = 0x1F4A, + BD_MARKETPLACE_MISSING_REQUIRED_ENTITLEMENT = 0x1F4B, + BD_MARKETPLACE_VALIDATION_ERROR = 0x1F4C, + BD_MARKETPLACE_TENCENT_PAYMENT_ERROR = 0x1F4D, + BD_MARKETPLACE_SKU_NOT_COUPON_ENABLED_ERROR = 0x1F4E, + BD_LEAGUE_INVALID_TEAM_SIZE = 0x1FA4, + BD_LEAGUE_INVALID_TEAM = 0x1FA5, + BD_LEAGUE_INVALID_SUBDIVISION = 0x1FA6, + BD_LEAGUE_INVALID_LEAGUE = 0x1FA7, + BD_LEAGUE_TOO_MANY_RESULTS_REQUESTED = 0x1FA8, + BD_LEAGUE_METADATA_TOO_LARGE = 0x1FA9, + BD_LEAGUE_TEAM_ICON_TOO_LARGE = 0x1FAA, + BD_LEAGUE_TEAM_NAME_TOO_LONG = 0x1FAB, + BD_LEAGUE_ARRAY_SIZE_MISMATCH = 0x1FAC, + BD_LEAGUE_SUBDIVISION_MISMATCH = 0x2008, + BD_LEAGUE_INVALID_WRITE_TYPE = 0x2009, + BD_LEAGUE_INVALID_STATS_DATA = 0x200A, + BD_LEAGUE_SUBDIVISION_UNRANKED = 0x200B, + BD_LEAGUE_CROSS_TEAM_STATS_WRITE_PREVENTED = 0x200C, + BD_LEAGUE_INVALID_STATS_SEASON = 0x200D, + BD_COMMERCE_ERROR = 0x206C, + BD_COMMERCE_RESOURCE_NOT_FOUND = 0x206D, + BD_COMMERCE_STORAGE_INVALID_PARAMETER = 0x206E, + BD_COMMERCE_APPLICATION_INVALID_PARAMETER = 0x206F, + BD_COMMERCE_RESOURCE_CONFLICT = 0x2070, + BD_COMMERCE_STORAGE_ERROR = 0x2071, + BD_COMMERCE_INTEGRITY_ERROR = 0x2072, + BD_COMMERCE_MMP_SERVICE_ERROR = 0x2073, + BD_COMMERCE_PERMISSION_DENIED = 0x2074, + BD_COMMERCE_INSUFFICIENT_FUNDS_ERROR = 0x2075, + BD_COMMERCE_UNKNOWN_CURRENCY = 0x2076, + BD_COMMERCE_INVALID_RECEIPT = 0x2077, + BD_COMMERCE_RECEIPT_USED = 0x2078, + BD_COMMERCE_TRANSACTION_ALREADY_APPLIED = 0x2079, + BD_COMMERCE_INVALID_CURRENCY_TYPE = 0x207A, + BD_CONNECTION_COUNTER_ERROR = 0x20D0, + BD_LINKED_ACCOUNTS_INVALID_CONTEXT = 0x2198, + BD_LINKED_ACCOUNTS_INVALID_PLATFORM = 0x2199, + BD_LINKED_ACCOUNTS_LINKED_ACCOUNTS_FETCH_ERROR = 0x219A, + BD_LINKED_ACCOUNTS_INVALID_ACCOUNT = 0x219B, + BD_GMSG_INVALID_CATEGORY_ID = 0x27D8, + BD_GMSG_CATEGORY_MEMBERSHIPS_LIMIT = 0x27D9, + BD_GMSG_NONMEMBER_POST_DISALLOWED = 0x27DA, + BD_GMSG_CATEGORY_DISALLOWS_CLIENT_TYPE = 0x27DB, + BD_GMSG_PAYLOAD_TOO_BIG = 0x27DC, + BD_GMSG_MEMBER_POST_DISALLOWED = 0x27DD, + BD_GMSG_OVERLOADED = 0x27DE, + BD_GMSG_USER_PERCATEGORY_POST_RATE_EXCEEDED = 0x27DF, + BD_GMSG_USER_GLOBAL_POST_RATE_EXCEEDED = 0x27E0, + BD_GMSG_GROUP_POST_RATE_EXCEEDED = 0x27E1, + BD_MAX_ERROR_CODE = 0x27E2, + }; + + enum bdNATType : uint8_t + { + BD_NAT_UNKNOWN = 0x0, + BD_NAT_OPEN = 0x1, + BD_NAT_MODERATE = 0x2, + BD_NAT_STRICT = 0x3, + }; + +#pragma pack(push, 1) + struct bdAuthTicket + { + unsigned int m_magicNumber; + char m_type; + unsigned int m_titleID; + unsigned int m_timeIssued; + unsigned int m_timeExpires; + unsigned __int64 m_licenseID; + unsigned __int64 m_userID; + char m_username[64]; + char m_sessionKey[24]; + char m_usingHashMagicNumber[3]; + char m_hash[4]; + }; +#pragma pack(pop) + + struct cmd_function_t + { + cmd_function_t* next; + const char* name; + const char* autoCompleteDir; + const char* autoCompleteExt; + void (__cdecl *function)(); + int flags; + }; + + struct msg_t + { + int overflowed; + int readOnly; + char* data; + char* splitData; + int maxsize; + int cursize; + int splitSize; + int readcount; + int bit; + int lastEntityRef; + }; + + struct XZoneInfo + { + const char* name; + int allocFlags; + int freeFlags; + }; + + struct scr_entref_raw + { + unsigned __int16 entnum; + unsigned __int16 classnum; + }; + + union scr_entref_t + { + unsigned int val; + scr_entref_raw raw; + }; + + typedef void (__cdecl * scr_call_t)(int entref); + + enum scriptType_e + { + SCRIPT_NONE = 0, + SCRIPT_OBJECT = 1, + SCRIPT_STRING = 2, + SCRIPT_VECTOR = 4, + SCRIPT_FLOAT = 5, + SCRIPT_INTEGER = 6, + SCRIPT_END = 8, + // Custom + }; + + struct VariableStackBuffer + { + const char* pos; + unsigned __int16 size; + unsigned __int16 bufLen; + unsigned __int16 localId; + char time; + char buf[1]; + }; + + union VariableUnion + { + int intValue; + float floatValue; + unsigned int stringValue; + const float* vectorValue; + const char* codePosValue; + unsigned int pointerValue; + VariableStackBuffer* stackValue; + unsigned int entityId; + }; + + struct VariableValue + { + VariableUnion u; + scriptType_e type; + }; + + struct function_stack_t + { + const char* pos; + unsigned int localId; + unsigned int localVarCount; + VariableValue* top; + VariableValue* startTop; + }; + + struct function_frame_t + { + function_stack_t fs; + int topType; + }; + + struct scrVmPub_t + { + unsigned int* localVars; + VariableValue* maxstack; + int function_count; + function_frame_t* function_frame; + VariableValue* top; /*bool debugCode; bool abort_on_error; - bool terminal_error; - bool block_execution;*/ - unsigned int inparamcount; - unsigned int outparamcount; - unsigned int breakpointOutparamcount; - bool showError; - function_frame_t function_frame_start[32]; - VariableValue stack[2048]; - }; - - struct scr_classStruct_t - { - unsigned __int16 id; - unsigned __int16 entArrayId; - char charId; - const char* name; - }; - - union DvarValue - { - bool enabled; - int integer; - unsigned int unsignedInt; - float value; - float vector[4]; - const char* string; - char color[4]; - }; - - struct enum_limit - { - int stringCount; - const char** strings; - }; - - struct int_limit - { - int min; - int max; - }; - - struct float_limit - { - float min; - float max; - }; - - union DvarLimits - { - enum_limit enumeration; - int_limit integer; - float_limit value; - float_limit vector; - }; - - struct dvar_t - { - const char* name; - unsigned int flags; - char type; - bool modified; - DvarValue current; - DvarValue latched; - DvarValue reset; - DvarLimits domain; - bool (__cdecl *domainFunc)(dvar_t*, DvarValue); - dvar_t* hashNext; - }; - } -} + bool terminal_error; + bool block_execution;*/ + unsigned int inparamcount; + unsigned int outparamcount; + unsigned int breakpointOutparamcount; + bool showError; + function_frame_t function_frame_start[32]; + VariableValue stack[2048]; + }; + + struct scr_classStruct_t + { + unsigned __int16 id; + unsigned __int16 entArrayId; + char charId; + const char* name; + }; + + union DvarValue + { + bool enabled; + int integer; + unsigned int unsignedInt; + float value; + float vector[4]; + const char* string; + char color[4]; + }; + + struct enum_limit + { + int stringCount; + const char** strings; + }; + + struct int_limit + { + int min; + int max; + }; + + struct float_limit + { + float min; + float max; + }; + + union DvarLimits + { + enum_limit enumeration; + int_limit integer; + float_limit value; + float_limit vector; + }; + + struct dvar_t + { + const char* name; + unsigned int flags; + char type; + bool modified; + DvarValue current; + DvarValue latched; + DvarValue reset; + DvarLimits domain; + bool (__cdecl *domainFunc)(dvar_t*, DvarValue); + dvar_t* hashNext; + }; + } +} diff --git a/src/module/dw.cpp b/src/module/dw.cpp index 6e1b54d..c6b87f4 100644 --- a/src/module/dw.cpp +++ b/src/module/dw.cpp @@ -7,8 +7,10 @@ #include "game/demonware/services/bdLSGHello.hpp" // 7 #include "game/demonware/services/bdStorage.hpp" // 10 +#include "game/demonware/services/bdDediAuth.hpp" // 12 #include "game/demonware/services/bdTitleUtilities.hpp" // 12 #include "game/demonware/services/bdDML.hpp" // 27 +#include "game/demonware/services/bdDediRSAAuth.hpp" // 26 #include "game/demonware/services/bdSteamAuth.hpp" // 28 namespace demonware @@ -375,7 +377,9 @@ namespace demonware auto lsg_server = register_server("mw3-pc-lobby.prod.demonware.net"); auto auth_server = register_server("mw3-pc-auth.prod.demonware.net"); + auth_server->register_service(); auth_server->register_service(); + auth_server->register_service(); lsg_server->register_service(); lsg_server->register_service(); diff --git a/src/utils/cryptography.cpp b/src/utils/cryptography.cpp index a788767..583e410 100644 --- a/src/utils/cryptography.cpp +++ b/src/utils/cryptography.cpp @@ -127,6 +127,54 @@ namespace utils reinterpret_cast(message.data()), message.size(), &result, key.get()) == CRYPT_OK && result != 0); } + std::string rsa::encrypt(const std::string& data, const std::string& hash, const std::string& key) + { + initialize(); + + const auto prng_id = find_prng("yarrow"); + + rsa_key new_key; + rsa_import(PBYTE(key.data()), key.size(), &new_key); + + prng_state yarrow; + rng_make_prng(128, prng_id, &yarrow, nullptr); + + unsigned char buffer[0x80]; + unsigned long length = sizeof(buffer); + + const auto rsa_result = rsa_encrypt_key( // + PBYTE(data.data()), // + data.size(), // + buffer, // + &length, // + PBYTE(hash.data()), // + hash.size(), // + &yarrow, // + prng_id, // + find_hash("sha1"), // + &new_key); + + rsa_free(&new_key); + + if (rsa_result == CRYPT_OK) + { + return std::string(PCHAR(buffer), length); + } + + return {}; + } + + void rsa::initialize() + { + static auto initialized = false; + if (initialized) return; + initialized = true; + + ltc_mp = ltm_desc; + register_hash(&sha1_desc); + register_prng(&yarrow_desc); + } + std::string des3::encrypt(const std::string& data, const std::string& iv, const std::string& key) { initialize(); diff --git a/src/utils/cryptography.hpp b/src/utils/cryptography.hpp index e70499a..c938766 100644 --- a/src/utils/cryptography.hpp +++ b/src/utils/cryptography.hpp @@ -39,6 +39,15 @@ namespace utils static bool verify_message(key key, const std::string& message, const std::string& signature); }; + class rsa final + { + public: + static std::string encrypt(const std::string& data, const std::string& hash, const std::string& key); + + private: + static void initialize(); + }; + class des3 final { public: