Skip to content

fix(dev-console): register telnet connections + echo command output - #2

Open
JeanxPereira wants to merge 1 commit into
mainfrom
fix/dev-console-input-echo
Open

fix(dev-console): register telnet connections + echo command output#2
JeanxPereira wants to merge 1 commit into
mainfrom
fix/dev-console-input-echo

Conversation

@JeanxPereira

Copy link
Copy Markdown

Makes the reactivated Darkspore dev console actually usable end-to-end over telnet. Two fixes on top of the v1 opt-in module (console_port in recap.cfg).

1. Register telnet connections (input)

v1 connected at the TCP level but every keystroke was discarded — no command ever ran. TelnetTransport::GetNextCommand (+0x14) only accumulates bytes for a client whose per-connection line-editor state (a 0x100c block) is registered, and only PollNewConnection (+0x1c) allocates+registers it (and sends the IAC WILL-ECHO). The retail ProcessCommand polls +0x1c/+0x20 every frame before draining; v1 skipped it. Drain() now polls both each frame before the command loop.

2. Echo command output back (output)

Command output went to the game's internal AppConsole sink, never to the socket. Detours FUN_00866230 (the registry's line broadcast, __thiscall(registry, line)) and mirrors each line to the active connection via the transport's own Send (vtable +0xc), then calls through so in-game sinks still receive it. The connection is cached from the command object each drain.

Critical: the Detours hook is installed on the game's main thread in StartOnce, not in DevConsoleInit — a DetourTransactionCommit under the DllMain loader lock prevents the game from launching.

Verified in-game

Connect over telnet → help lists the registered cheats → option/prop/toggleCaptureUI/quit run and their output returns over the socket.

Note: app/state commands are dead code in the retail ship build (their registrars are never invoked), so they remain unavailable by design — the reachable AppConsole cheat registry (option/prop/killallhints/movie/blocksmode/toggleCaptureUI/history/quit) is the live surface.

Two fixes make the reactivated dev console actually usable end-to-end:

- Poll TelnetTransport +0x1c/+0x20 each frame before draining commands.
  GetNextCommand (+0x14) only accumulates keystrokes for a client whose
  per-connection line-editor state is registered, and only PollNewConnection
  (+0x1c) allocates+registers it (and sends IAC WILL-ECHO). Without it a TCP
  client connected but every byte was discarded — no command ever executed.

- Mirror AppConsole output back to the client. Detours FUN_00866230 (the
  registry's line broadcast) and forwards each line to the active connection
  via the transport's own Send (vtable +0xc), then calls through. The hook is
  installed on the main thread in StartOnce, NOT in DevConsoleInit — a Detours
  commit under the DllMain loader lock prevents the game from launching.

Proven in-game: connect over telnet, `help` lists the registered cheats,
`toggleCaptureUI`/`prop`/etc. run and their output returns over the socket.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant