No Xbox Live tokens by default: titles take their offline paths

XUserGetTokenAndSignature(Utf16)Async now fails with 0x80072EFD, as it
does on a console that cannot reach Xbox Live. Set xbox_live_tokens = true
in xcl.toml to get XCL's local placeholder token back, which only a backend
of your own accepts.

Before this, Minecraft sent the placeholder to PlayFab, was refused, and
showed its "Microsoft account - connecting" dialog forever. It now shows its
offline message once (code "jasnoglaz") and stays in the menu. Fortnite
(RTA) and XDefiant (people hub, presence) behave as before.

Token requests are logged. Unit tests cover the offline default, and the
test title now expects no token.
This commit is contained in:
ivall
2026-11-22 14:54:23 +01:00
parent 9e759de1f2
commit 1903ff6876
5 changed files with 74 additions and 25 deletions
+9
View File
@@ -1141,6 +1141,15 @@ of the title (it writes to address 0 after a failed D3D12 call: `call 0x14068c76
`sparse::mapped_ranges`). Use the release build for game runs: the debug build hashes the dirty chunks ~10×
slower (and the queues then wait on each other for the sparse lock). The log has
"sparse windows timing: write-watch / lock wait / chunk scan / upload" lines.
- **No Xbox Live tokens by default (2026-11-22, latest)**: `XUserGetTokenAndSignature(Utf16)Async` fails with
0x80072EFD, as on a console that cannot reach Xbox Live; `xbox_live_tokens = true` in `xcl.toml` brings back
XCL's local placeholder token (only useful for a backend of your own – Xbox Live and the titles' services
reject it). Minecraft asked for one for PlayFab (`*.minecraft.playfabapi.com`), got the placeholder, was refused
and retried its "Microsoft account – connecting" dialog for ever; now it shows its offline message ("we can't
sign you in … access to Realms, profiles and Marketplace items will be limited", code "jasnoglaz") and goes on
in the menu. Fortnite asks for RTA (`wss://rta.xboxlive.com/connect`) and still reaches its title screen.
The requests are logged ("XUser: token #n for …"). XCL does not fake sign-in, backends or licences (no
TomBox-style local Epic / Xbox Live servers). Minecraft stays a trial (XStore refused).
- **Minecraft (Microsoft.MinecraftBeta 1.18.30.64) reaches its main menu (2026-11-22, latest)**: panorama, logo,
buttons, the character, music and Enter work; it offers the trial (XStore is refused – no fake licences) and
stops at the Microsoft-account sign-in (Xbox Live). Run `Minecraft.Windows.exe.original`: the `Minecraft.Windows.exe`
+6
View File
@@ -55,6 +55,11 @@ pub struct Config {
pub raytracing: String,
pub window_width: u32,
pub window_height: u32,
/// Answer `XUserGetTokenAndSignature*` with XCL's local placeholder token (for a backend of
/// your own that accepts it). Off: the request fails as on a console that cannot reach Xbox
/// Live (0x80072EFD), and titles go their offline way – Xbox Live's and the titles' own
/// services would reject the placeholder anyway (Minecraft retried its sign-in forever).
pub xbox_live_tokens: bool,
}
impl Config {
@@ -138,6 +143,7 @@ impl Default for Config {
raytracing: "auto".into(),
window_width: 1280,
window_height: 720,
xbox_live_tokens: false,
}
}
}
+24
View File
@@ -1449,6 +1449,7 @@ mod tests {
#[test]
fn thunk_protocol_with_xcl_objects_on_pc_queues() {
let _g = crate::hle::xgameruntime::xasync::ASYNC_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
super::TOKENS_HERE.with(|t| t.set(Some(true)));
if pc().is_none() {
println!("no system xgameruntime.dll – skipping");
return;
@@ -1626,9 +1627,32 @@ mod tests {
assert!(own(&XPLS, &XPLS_V1_IID).unwrap().iface.iids.contains(&XPLS_V1_IID));
}
#[test]
/// Without `xbox_live_tokens` (the default) a token request fails as on a console that
/// cannot reach Xbox Live: the async completes with 0x80072EFD and has no result.
fn token_requests_fail_offline_by_default() {
let _g = crate::hle::xgameruntime::xasync::ASYNC_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
super::TOKENS_HERE.with(|t| t.set(None));
unsafe {
let mut b: XAsyncBlock = std::mem::zeroed();
assert_eq!(XUserAddAsync(1, &mut b), S_OK);
assert_eq!(XAsyncGetStatus(&mut b, true), S_OK);
let mut user = std::ptr::null_mut();
assert_eq!(XUserAddResult(&mut b, &mut user), S_OK);
let mut bt: XAsyncBlock = std::mem::zeroed();
let (method, url) = (b"GET\0", b"https://example.playfabapi.com/\0");
assert_eq!(super::XUserGetTokenAndSignatureAsync(user, 0, method.as_ptr(), url.as_ptr(), 0, std::ptr::null(), 0, std::ptr::null(), &mut bt), S_OK);
assert_eq!(XAsyncGetStatus(&mut bt, true), 0x8007_2EFD_u32 as i32);
let mut n = 0usize;
assert_ne!(super::XUserGetTokenAndSignatureResultSize(&mut bt, &mut n), S_OK);
XUserCloseHandle(user);
}
}
#[test]
fn token_and_signature_utf8_and_utf16_through_vtable() {
let _g = crate::hle::xgameruntime::xasync::ASYNC_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
super::TOKENS_HERE.with(|t| t.set(Some(true)));
unsafe {
let (hr, u) = query(XUSER, XUSER);
assert_eq!(hr, S_OK);
+29 -1
View File
@@ -13,7 +13,7 @@ pub mod xsign;
use std::ffi::c_void;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use crate::util::{write_cstr_out, E_INVALIDARG, E_NOT_FOUND, E_NOT_SUFFICIENT_BUFFER, E_NOT_SUPPORTED, HRESULT, S_OK};
use gamesave::*;
@@ -672,6 +672,30 @@ unsafe fn copy_capped_body(body_size: usize, body: *const c_void) -> Vec<u8> {
std::slice::from_raw_parts(body as *const u8, len).to_vec()
}
thread_local! {
/// tests: `xbox_live_tokens` for requests made on this thread (None: the configuration's)
pub(crate) static TOKENS_HERE: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) };
}
/// WININET_E_CANNOT_CONNECT: what a console that cannot reach Xbox Live gets for a token
const E_CANNOT_CONNECT: HRESULT = 0x8007_2EFD_u32 as i32;
/// The title asks for an Xbox Live token for a request (first 24 and every 64th logged).
/// Without `xbox_live_tokens` there is none: XCL has no Xbox Live.
fn note_token_request(method: &str, url: &str) -> Result<(), HRESULT> {
static N: AtomicU64 = AtomicU64::new(0);
let n = N.fetch_add(1, Ordering::Relaxed);
let tokens = TOKENS_HERE.with(|t| t.get()).unwrap_or_else(|| crate::state::config().xbox_live_tokens);
if n < 24 || n % 64 == 0 {
crate::xlog_info!("XUser: token #{n} for {method} {url} – {}", if tokens { "XCL's local placeholder" } else { "none: no Xbox Live (0x80072EFD)" });
}
if tokens {
Ok(())
} else {
Err(E_CANNOT_CONNECT)
}
}
pub unsafe extern "system" fn XUserGetTokenAndSignatureAsync(
user: *mut c_void,
_options: u32,
@@ -688,8 +712,10 @@ pub unsafe extern "system" fn XUserGetTokenAndSignatureAsync(
}
let method = crate::util::from_cstr_ptr(method).filter(|s| !s.is_empty()).unwrap_or_else(|| "GET".into());
let url = crate::util::from_cstr_ptr(url).unwrap_or_default();
let allowed = note_token_request(&method, &url);
let body = copy_capped_body(body_size, body);
begin_with_fixups(b, &TOKEN_UTF8_ID as *const u8 as usize, move || {
allowed?;
build_token_payload(false, &method, &url, &body)
})
}
@@ -728,8 +754,10 @@ pub unsafe extern "system" fn XUserGetTokenAndSignatureUtf16Async(
}
let method = crate::util::from_wide_ptr(method).filter(|s| !s.is_empty()).unwrap_or_else(|| "GET".into());
let url = crate::util::from_wide_ptr(url).unwrap_or_default();
let allowed = note_token_request(&method, &url);
let body = copy_capped_body(body_size, body);
begin_with_fixups(b, &TOKEN_UTF16_ID as *const u8 as usize, move || {
allowed?;
build_token_payload(true, &method, &url, &body)
})
}
+6 -24
View File
@@ -93,13 +93,6 @@ extern "system" {
b: *mut XAsyncBlock,
) -> HRESULT;
fn XUserGetTokenAndSignatureResultSize(b: *mut XAsyncBlock, size: *mut usize) -> HRESULT;
fn XUserGetTokenAndSignatureResult(
b: *mut XAsyncBlock,
size: usize,
buf: *mut c_void,
ptr: *mut *mut c_void,
used: *mut usize,
) -> HRESULT;
fn XUserGetGamertag(u: *mut c_void, comp: u32, size: usize, buf: *mut u8, used: *mut usize) -> HRESULT;
fn XUserCloseHandle(u: *mut c_void);
fn XNetworkingQueryPreferredLocalUdpMultiplayerPort(port: *mut u16) -> HRESULT;
@@ -492,7 +485,7 @@ fn main() {
Ok(())
});
check("XUser: silent sign-in, device association, and XSTS token/signature", || unsafe {
check("XUser: silent sign-in, device association, and no XSTS token offline", || unsafe {
let mut b: XAsyncBlock = std::mem::zeroed();
ensure!(XUserAddAsync(1, &mut b) == 0, "XUserAddAsync");
ensure!(XAsyncGetStatus(&mut b, true) == 0, "status");
@@ -522,23 +515,12 @@ fn main() {
) == 0,
"XUserGetTokenAndSignatureAsync"
);
ensure!(XAsyncGetStatus(&mut tb, true) == 0, "token status");
// no Xbox Live (`xbox_live_tokens` off, the default): the request fails as on a console
// that cannot reach it, and there is no result
let st = XAsyncGetStatus(&mut tb, true);
ensure!(st == 0x8007_2EFD_u32 as i32, "token status {st:#x}");
let mut tsz = 0usize;
ensure!(XUserGetTokenAndSignatureResultSize(&mut tb, &mut tsz) == 0 && tsz > 32, "token size {tsz}");
let mut tbuf = vec![0u8; tsz];
let mut tptr = std::ptr::null_mut();
let mut tused = 0usize;
ensure!(
XUserGetTokenAndSignatureResult(&mut tb, tbuf.len(), tbuf.as_mut_ptr() as *mut c_void, &mut tptr, &mut tused) == 0,
"token result"
);
let tok_ptr = *(tptr as *const *const u8).add(2);
let sig_ptr = *(tptr as *const *const u8).add(3);
let tok_len = *(tptr as *const usize);
let sig_len = *(tptr as *const usize).add(1);
let tok = cstr(std::slice::from_raw_parts(tok_ptr, tok_len));
let sig = cstr(std::slice::from_raw_parts(sig_ptr, sig_len));
ensure!(tok.starts_with("XBL3.0 ") && sig.len() >= 100, "tok={tok:?} sig_len={}", sig.len());
ensure!(XUserGetTokenAndSignatureResultSize(&mut tb, &mut tsz) != 0, "a token result offline ({tsz} bytes)");
XUserCloseHandle(u);
Ok(())
});