Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Poverty Inspired Me to Fix a 'Wine Can't Do This' Timeout

Описание и применение

Проблема: MetaTrader 5 не инициализировался в Wine на Linux‑VPS из‑за таймаута IPC. Решение: перехватить ReadFile, изменить статус 1 на 2 в ответе, позволяя терминалу завершить инициализацию.

Задача

MetaTrader 5 failed to initialize under Wine on a headless Linux VPS, returning IPC timeout (-10005) after 30 seconds.

Результат

By intercepting and modifying the IPC status byte in memory, the trader bypassed Wine’s deadlock, enabling MetaTrader 5 to initialize and run headlessly on a low‑cost Linux VPS.

Рабочий процесс

  • 1. Set up three isolated Wine prefixes, each with its own MT5 terminal and embedded Windows Python bridge.
  • 2. Encountered multiple Wine‑on‑Ubuntu failures (pkill script, winedbg modal, stale X11 lock, registry patch, config encoding, NumPy crash).
  • 3. Identified the core issue: MT5’s polling loop stuck on status 1, causing IPC timeout.
  • 4. Hooked CreateFileW, WriteFile, ReadFile via ctypes to log IPC traffic.
  • 5. Disassembled _core.pyd with Capstone to understand the polling logic.
  • 6. Implemented a ReadFile hook that, when a 12‑byte reply with status 1 is detected, changes the status byte to 2 before the extension processes it.
  • 7. Loaded the hook before mt5.initialize() to ensure the patch takes effect in memory only.
  • 8. Verified mt5.initialize() returns True and the system runs headlessly.

Доказательства

MetaTrader5’s Python package delegates everything to a compiled extension, _core.cp311-win_amd64.pyd.

Источник

The terminal was stuck reporting status 1, “still initializing.”

Источник

I rewrote that one byte to 2 before the extension’s own code ever saw it.

Источник

  • Дата записи: 2026-10-06T22:40:51.948Z