mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
fix(ea): the game's own Origin session gets the profile and GetSettings (#3578)
EA games open two LSX sessions: the activation layer's, which holds the launch, and the game SDK's, which claims the same game but is never trusted. GetProfile then sent it an empty UserId/PersonaId, which the SDK parses as integers, and Lost in Random quit on the FormatException. Sessions that claimed the prepared game now get the profile ids (tokens, codes, licences and entitlements stay with the trusted session), and GetSettings is answered with the SDK's GetSettingsResponse instead of ErrorSuccess.
This commit is contained in:
1 parent
80dbec57d7
commit
c7cd7c18e6
2 files changed
+47
-6
No files matched your search
@@ -67,7 +67,7 @@ object EaLsx {
|
||||
}
|
||||
|
||||
@Volatile var game: Game? = null
|
||||
@Volatile private var account: Account? = null
|
||||
@Volatile internal var account: Account? = null
|
||||
/** The one session of the current launch that may act for the account. */
|
||||
/** Bumped whenever the launch changes; a connection accepted under an older one is not admitted. */
|
||||
@Volatile internal var generation = 0
|
||||
@@ -333,10 +333,11 @@ object EaLsx {
|
||||
|
||||
private fun now() = LocalDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))
|
||||
|
||||
private fun answer(session: Session, m: Message): String? {
|
||||
internal fun answer(session: Session, m: Message): String? {
|
||||
val g = game
|
||||
val who = account
|
||||
val person = who?.takeIf { session.trusted }
|
||||
val profile = who?.takeIf { session.trusted || session.claimed }
|
||||
val locale = g?.locale ?: "en_US"
|
||||
return when (m.name) {
|
||||
"ChallengeResponse" -> {
|
||||
@@ -355,15 +356,16 @@ object EaLsx {
|
||||
"GetConfig" -> tag("GetConfigResponse", body = SERVICES.joinToString("") { tag("Service", "Name" to it.first, "Facility" to it.second) })
|
||||
"GetProfile" -> tag(
|
||||
"GetProfileResponse",
|
||||
"Persona" to person?.persona.orEmpty(), "SubscriberLevel" to 0, "CommerceCurrency" to "USD", "IsTrialSubscriber" to false,
|
||||
"Country" to "US", "UserId" to person?.userId.orEmpty(), "GeoCountry" to "US", "AvatarId" to "", "IsSubscriber" to false,
|
||||
"IsSteamSubscriber" to false, "PersonaId" to person?.personaId.orEmpty(), "IsUnderAge" to false, "UserIndex" to 0,
|
||||
"Persona" to profile?.persona.orEmpty(), "SubscriberLevel" to 0, "CommerceCurrency" to "USD", "IsTrialSubscriber" to false,
|
||||
"Country" to "US", "UserId" to profile?.userId.orEmpty(), "GeoCountry" to "US", "AvatarId" to "", "IsSubscriber" to false,
|
||||
"IsSteamSubscriber" to false, "PersonaId" to profile?.personaId.orEmpty(), "IsUnderAge" to false, "UserIndex" to 0,
|
||||
)
|
||||
"GetSetting" -> tag("GetSettingResponse", "Setting" to when (m.attrs["SettingId"]) {
|
||||
"ENVIRONMENT" -> "production"
|
||||
"LANGUAGE" -> locale
|
||||
else -> "false"
|
||||
})
|
||||
"GetSettings" -> tag("GetSettingsResponse", "IsIGOAvailable" to false, "IsIGOEnabled" to false, "IsTelemetryEnabled" to false, "IsManualOffline" to false)
|
||||
"GetGameInfo" -> tag("GetGameInfoResponse", "GameInfo" to when (m.attrs["GameInfoId"]) {
|
||||
"FREETRIAL" -> "false"
|
||||
"LANGUAGES" -> LANGUAGES
|
||||
@@ -403,7 +405,7 @@ object EaLsx {
|
||||
)
|
||||
})
|
||||
}
|
||||
"GetPresence" -> tag("GetPresenceResponse", "UserId" to person?.userId.orEmpty(), "Presence" to "INGAME")
|
||||
"GetPresence" -> tag("GetPresenceResponse", "UserId" to profile?.userId.orEmpty(), "Presence" to "INGAME")
|
||||
"QueryPresence" -> tag("QueryPresenceResponse", body = "")
|
||||
"QueryFriends" -> tag("QueryFriendsResponse", body = "")
|
||||
"GetBlockList" -> tag("GetBlockListResponse", "Return" to "Success", body = "")
|
||||
|
||||
@@ -132,6 +132,45 @@ class EaTest {
|
||||
dir.deleteRecursively()
|
||||
}
|
||||
|
||||
private object LsxAccount : EaLsx.Account {
|
||||
override val userId = "1000000000042"
|
||||
override val personaId = "1000000000043"
|
||||
override val persona = "Player"
|
||||
override fun authCode(clientId: String, scope: String?) = "code"
|
||||
override fun license(contentId: String, requestTicket: String, ticketEngine: String) = "licence"
|
||||
override fun entitlements(group: String) = emptyList<Map<String, String>>()
|
||||
override fun token() = "token"
|
||||
}
|
||||
|
||||
private fun lsx(body: String) = EaLsx.parse("<LSX><Request recipient=\"EbisuSDK\" id=\"5\">$body</Request></LSX>")!!
|
||||
|
||||
@Test fun theGamesSecondSessionGetsTheProfileButNoSecrets() {
|
||||
EaLsx.account = LsxAccount
|
||||
try {
|
||||
val sdk = EaLsx.Session(java.net.Socket(), java.io.ByteArrayOutputStream(), false, unverifiable = true).apply { claimed = true }
|
||||
val profile = EaLsx.answer(sdk, lsx("<GetProfile index=\"0\"/>"))!!
|
||||
assertTrue(profile, profile.contains("UserId=\"1000000000042\""))
|
||||
assertTrue(profile, profile.contains("PersonaId=\"1000000000043\""))
|
||||
assertTrue(profile, profile.contains("Persona=\"Player\""))
|
||||
assertTrue(EaLsx.answer(sdk, lsx("<GetPresence/>"))!!.contains("UserId=\"1000000000042\""))
|
||||
assertEquals("<AuthToken value=\"\"/>", EaLsx.answer(sdk, lsx("<GetAuthToken/>")))
|
||||
assertEquals("<AuthCode value=\"invalid\"/>", EaLsx.answer(sdk, lsx("<GetAuthCode ClientId=\"x\"/>")))
|
||||
|
||||
val stranger = EaLsx.Session(java.net.Socket(), java.io.ByteArrayOutputStream(), false, unverifiable = true)
|
||||
assertTrue(EaLsx.answer(stranger, lsx("<GetProfile index=\"0\"/>"))!!.contains("UserId=\"\""))
|
||||
} finally {
|
||||
EaLsx.account = null
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun getSettingsAnswersWithTheSdksSettingsType() {
|
||||
val session = EaLsx.Session(java.net.Socket(), java.io.ByteArrayOutputStream(), false)
|
||||
assertEquals(
|
||||
"<GetSettingsResponse IsIGOAvailable=\"false\" IsIGOEnabled=\"false\" IsTelemetryEnabled=\"false\" IsManualOffline=\"false\"/>",
|
||||
EaLsx.answer(session, lsx("<GetSettings/>")),
|
||||
)
|
||||
}
|
||||
|
||||
@Test fun lsxRequestsAreParsed() {
|
||||
val m = EaLsx.parse("<LSX><Request recipient=\"EbisuSDK\" id=\"4\"><GetSetting SettingId=\"ENVIRONMENT\" version=\"\"/></Request></LSX>")!!
|
||||
assertEquals("GetSetting", m.name)
|
||||
|
||||
Reference in new issue
Block a user