Skip to content

ams::mitm::ldn::SharedState

Type: ams::os::SdkMutex

Type: bool

Type: u64

Type: u64

PID that opened ldn:u (set before Initialize)

Type: CommState

Type: u8

Type: u8

Type: u8

Type: bool

Type: u32

Type: bool

Type: std::unordered_set< u64 >

Set of program_ids with LDN support.

& GetInstance()

Get the singleton instance.

Reference to the globalinstance @gdb{tag=“LDN:STATE”, msg=“SharedState: constructor”}return

Returns: &

void Reset()

Reset all state to defaults.

Used for testing and cleanup. @gdb{tag=“LDN:STATE”, msg=“SharedState: Reset”}

void SetGameActive(bool active, u64 process_id)

Set game active state.

Called by MITM service when a game initializes or finalizes LDN. When set to false, also resets all runtime state.activeTrue if a game is using LDNprocess_idProcess ID of the game (0 when inactive) @gdb{tag=“LDN:STATE”, msg=“SetGameActive: active=%d pid=%lu”, args=“$x1, $x2”}param

Parameters:

  • active (bool)
  • process_id (u64)
bool IsGameActive()

Check if a game is actively using LDN.

True if a game is using LDN @gdb{tag=“LDN:STATE”, msg=“IsGameActive”}return

Returns: bool

u64 GetActiveProcessId()

Get the process ID of the active game.

Process ID, or 0 if no game is active @gdb{tag=“LDN:STATE”, msg=“GetActiveProcessId”}return

Returns: u64

void SetLdnPid(u64 pid)

Set the PID that has opened ldn:u service.

Called immediately whenis created, BEFORE Initialize(). This allows BSD MITM to know which process to intercept even before the game calls Initialize().pidProcess ID that opened ldn:u, or 0 to clear @gdb{tag=“LDN:STATE”, msg=“SetLdnPid: pid=%lu”, args=“$x1”}param

Parameters:

  • pid (u64)
u64 GetLdnPid()

Get the PID that has opened ldn:u service.

Process ID, or 0 if no process has opened ldn:u @gdb{tag=“LDN:STATE”, msg=“GetLdnPid”}return

Returns: u64

bool IsLdnPid(u64 pid)

Check if a PID has opened ldn:u.

pidProcess ID to checkparamtrue if this PID has opened ldn:u @gdb{tag=“LDN:STATE”, msg=“IsLdnPid: pid=%lu”, args=“$x1”}return

Parameters:

  • pid (u64)

Returns: bool

void LoadLdnWhitelist(const std::vector< u64 > & game_ids)

Load the LDN game whitelist.

Called at startup to load the list of games that support LDN. This replaces any existing whitelist.game_idsVector of program IDs that support LDN @gdb{tag=“LDN:STATE”, msg=“LoadLdnWhitelist”}param

Parameters:

  • game_ids (const std::vector&lt; u64 &gt; &)
bool IsLdnGame(u64 program_id)

Check if a program_id is in the LDN whitelist.

Called by BSD ShouldMitm to decide whether to intercept.program_idThe program ID to checkparamtrue if this program is in the whitelist @gdb{tag=“LDN:STATE”, msg=“IsLdnGame: program_id=0x%lx”, args=“$x1”}return

Parameters:

  • program_id (u64)

Returns: bool

size_t GetWhitelistSize()

Get the number of games in the whitelist.

Number of games loaded @gdb{tag=“LDN:STATE”, msg=“GetWhitelistSize”}return

Returns: size_t

void SetLdnState(CommState state)

Set current LDN communication state.

Called by MITM service on state transitions.stateNew LDN state @gdb{tag=“LDN:STATE”, msg=“SetLdnState: state=%d”, args=“$x1”}param

Parameters:

  • state (CommState)
CommState GetLdnState()

Get current LDN communication state.

Current LDN state @gdb{tag=“LDN:STATE”, msg=“GetLdnState”}return

Returns: CommState

void SetSessionInfo(u8 node_count, u8 max_nodes, u8 local_node_id, bool is_host)

Set session information.

Called by MITM service when network info is updated.node_countCurrent number of nodesmax_nodesMaximum nodes allowedlocal_node_idThis node’s IDis_hostTrue if this node is the host @gdb{tag=“LDN:STATE”, msg=“SetSessionInfo: node_count=%d max=%d local=%d is_host=%d”, args=“$x1, $x2, $x3, $x4”}param

Parameters:

  • node_count (u8)
  • max_nodes (u8)
  • local_node_id (u8)
  • is_host (bool)
void GetSessionInfo(u8 & node_count, u8 & max_nodes, u8 & local_node_id, bool & is_host)

Get session information.

node_countCurrent number of nodesmax_nodesMaximum nodes allowedlocal_node_idThis node’s IDis_hostTrue if this node is the host @gdb{tag=“LDN:STATE”, msg=“GetSessionInfo”}param

Parameters:

  • node_count (u8 &)
  • max_nodes (u8 &)
  • local_node_id (u8 &)
  • is_host (bool &)
SessionInfo GetSessionInfoStruct()

Get session information as struct.

structure for IPC @gdb{tag=“LDN:STATE”, msg=“GetSessionInfoStruct”}return

Returns: SessionInfo

void SetLastRtt(u32 rtt_ms)

Set last measured RTT.

Called by network client after ping response.rtt_msRound-trip time in milliseconds @gdb{tag=“LDN:STATE”, msg=“SetLastRtt: rtt=%u”, args=“$x1”}param

Parameters:

  • rtt_ms (u32)
u32 GetLastRtt()

Get last measured RTT.

Round-trip time in milliseconds, or 0 if not measured @gdb{tag=“LDN:STATE”, msg=“GetLastRtt”}return

Returns: u32

void RequestReconnect()

Request a reconnection.

Called by config service when user requests reconnect from overlay. The MITM service should periodically check and consume this flag. @gdb{tag=“LDN:STATE”, msg=“RequestReconnect”}

bool ConsumeReconnectRequest()

Consume reconnect request.

Called by MITM service to check and clear the reconnect flag.True if reconnect was requested (flag is cleared) @gdb{tag=“LDN:STATE”, msg=“ConsumeReconnectRequest”}return

Returns: bool

void SharedState()

@gdb{tag=“LDN:STATE”, msg=“SharedState: constructor”}

void SharedState(const&)

Parameters:

  • param (const&)
& operator=(const&)

Parameters:

  • param (const&)

Returns: &