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 globalinstancereturn

Returns: &

void Reset()

Reset all state to defaults.

Used for testing and cleanup.

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)param

Parameters:

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

Check if a game is actively using LDN.

True if a game is using LDNreturn

Returns: bool

u64 GetActiveProcessId()

Get the process ID of the active game.

Process ID, or 0 if no game is activereturn

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 clearparam

Parameters:

  • pid (u64)
u64 GetLdnPid()

Get the PID that has opened ldn:u service.

Process ID, or 0 if no process has opened ldn:ureturn

Returns: u64

bool IsLdnPid(u64 pid)

Check if a PID has opened ldn:u.

pidProcess ID to checkparamtrue if this PID has opened ldn:ureturn

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 LDNparam

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 whitelistreturn

Parameters:

  • program_id (u64)

Returns: bool

size_t GetWhitelistSize()

Get the number of games in the whitelist.

Number of games loadedreturn

Returns: size_t

void SetLdnState(CommState state)

Set current LDN communication state.

Called by MITM service on state transitions.stateNew LDN stateparam

Parameters:

  • state (CommState)
CommState GetLdnState()

Get current LDN communication state.

Current LDN statereturn

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 hostparam

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 hostparam

Parameters:

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

Get session information as struct.

structure for IPCreturn

Returns: SessionInfo

void SetLastRtt(u32 rtt_ms)

Set last measured RTT.

Called by network client after ping response.rtt_msRound-trip time in millisecondsparam

Parameters:

  • rtt_ms (u32)
u32 GetLastRtt()

Get last measured RTT.

Round-trip time in milliseconds, or 0 if not measuredreturn

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.

bool ConsumeReconnectRequest()

Consume reconnect request.

Called by MITM service to check and clear the reconnect flag.True if reconnect was requested (flag is cleared)return

Returns: bool

void SharedState()
void SharedState(const&)

Parameters:

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

Parameters:

  • param (const&)

Returns: &