Skip to content

Fix DLL loading with LOAD_WITH_ALTERED_SEARCH_PATH, add missing flat API exports, and enable Release logging#6

Merged
veeeanti merged 37 commits into
UnionCrax-Team:mainfrom
xinerqu:main
May 12, 2026
Merged

Fix DLL loading with LOAD_WITH_ALTERED_SEARCH_PATH, add missing flat API exports, and enable Release logging#6
veeeanti merged 37 commits into
UnionCrax-Team:mainfrom
xinerqu:main

Conversation

@xinerqu
Copy link
Copy Markdown

@xinerqu xinerqu commented May 10, 2026

English

This PR fixes critical issues with Steam DLL loading and adds missing flat API exports.

Bug 1: Missing LOAD_WITH_ALTERED_SEARCH_PATH in InitSteamClient() (line 389, 396)

LoadLibraryA(fullPath) was used without the LOAD_WITH_ALTERED_SEARCH_PATH flag. When Windows resolves dependencies of steamclient64.dll (tier0_s64.dll, vstdlib_s64.dll), it searches the game executable's directory instead of the Steam directory, causing load failures even when steamclient64.dll itself is found.

Fix: Use LoadLibraryExA with LOAD_WITH_ALTERED_SEARCH_PATH. Also improved core DLL loading in uc_loader.h with PathFindFileNameA + LOAD_WITH_ALTERED_SEARCH_PATH.

Bug 2: LoadGameOverlay() uses hardcoded path and weak Steam path resolution (line 477)

GetModuleHandle used a hardcoded path (C:\Program Files (x86)\Steam\GameOverlayRenderer64.dll) instead of checking by module name. This causes false negatives when Steam is installed in a non-default location.

Fix: Applied the same pattern as the fixed InitSteamClient():

  • GetModuleHandleA(moduleName) instead of hardcoded path
  • Three-tier Steam path fallback: Registry → hardcoded paths → SteamAPI_GetSteamInstallPath() cache
  • PATH search fallback when Steam directory load fails

Missing flat API exports

uc-online2 was missing a number of flat API exports that some games and frameworks expect to find via P/Invoke. This PR adds the missing exports to improve compatibility:

  • 34 ISteamMusicRemote flat API exports (RegisterSteamMusicRemote, etc.)
  • 11 legacy ISteamGameSearch flat API stubs (AcceptGame, DeclineGame, EndGame, etc.)
  • ISteamFriends_SetPersonaName and ISteamFriends_GetUserRestrictions
  • Old-versioned interface aliases (v001 GameSearch/MusicRemote/Timeline, v017 Friends, v012 UserStats, v020 UGC, etc.)
  • g_pSteamClientGameServer export (with correct S_API declaration before globals.h include)

Other Fixes

  • Release logging: UCOLOG was guarded by #ifdef _DEBUG, making it completely silent in Release builds. Removed the guard.
  • g_pSteamClientGameServer export: Moved S_API declaration before globals.h include to avoid missing export.

中文

本 PR 修复了 Steam DLL 加载的关键问题,并补全了缺失的 flat API 导出。

Bug 1:InitSteamClient() 缺少 LOAD_WITH_ALTERED_SEARCH_PATH(第 389、396 行)

LoadLibraryA(fullPath) 没有使用 LOAD_WITH_ALTERED_SEARCH_PATH 标志。Windows 在解析 steamclient64.dll 的依赖项(tier0_s64.dll、vstdlib_s64.dll)时,会从游戏 exe 所在目录查找而不是 Steam 目录,导致即使找到了 steamclient64.dll 本身也会加载失败。

修复:改用 LoadLibraryExA + LOAD_WITH_ALTERED_SEARCH_PATH。同时修复了 uc_loader.h 中 core DLL 的加载路径问题(PathFindFileNameA + LOAD_WITH_ALTERED_SEARCH_PATH)。

Bug 2:LoadGameOverlay() 使用硬编码路径且 Steam 路径解析不健壮(第 477 行)

GetModuleHandle 使用硬编码路径(C:\Program Files (x86)\Steam\GameOverlayRenderer64.dll)而非模块名检查。当 Steam 安装在非默认位置时,会误判 overlay 已加载。

修复:采用与修复后的 InitSteamClient() 相同的模式:

  • GetModuleHandleA(模块名) 替代硬编码路径
  • 三级 Steam 路径回退:注册表 → 硬编码路径 → SteamAPI_GetSteamInstallPath() 缓存
  • Steam 目录加载失败时回退到 PATH 搜索

补全缺失的 flat API 导出

uc-online2 缺失了部分 flat API 导出,某些游戏和框架会通过 P/Invoke 查找这些导出。本 PR 补全了这些导出以提升兼容性:

  • 34 个 ISteamMusicRemote flat API 导出(RegisterSteamMusicRemote 等)
  • 11 个旧版 ISteamGameSearch flat API 存根(AcceptGame、DeclineGame、EndGame 等)
  • ISteamFriends_SetPersonaNameISteamFriends_GetUserRestrictions
  • 旧版本号接口别名(v001 GameSearch/MusicRemote/Timeline、v017 Friends、v012 UserStats、v020 UGC 等)
  • g_pSteamClientGameServer 导出(在 globals.h 之前用 S_API 正确声明)

其他修复

  • Release 日志UCOLOG#ifdef _DEBUG 包裹,Release 构建下完全无日志。已移除守卫。
  • g_pSteamClientGameServer 导出:将 S_API 声明移到 globals.h 引入之前,修复缺失导出问题。

xinerqu added 8 commits May 10, 2026 20:37
- Fix InitSteamClient: use filename instead of full path for concatenation,
  restore LOAD_WITH_ALTERED_SEARCH_PATH for dependency resolution
- Add isteamgamesearch.h SDK header with full interface definition
- Replace ISteamGameSearch empty stub with proper vtable implementation,
  point m_pSteamGameSearch to stub instance instead of nullptr
- Add flat C API exports for ISteamGameSearch in api_flat.h
- Hook ISteamApps::BIsSubscribedApp to always return true,
  fixes games with hardcoded AppID subscription checks (e.g. Godot games)
- Define ISteamMusicRemote class with all 32 virtual methods (stub)
- Add CSteamMusicRemoteStub returning false for all methods
- Export SteamAPI_ISteamClient_GetISteamMusicRemote in flat API
- Add SteamMusicRemote() global accessor returning stub instance
UCOLOG and UCOColor were disabled in Release mode, making debugging impossible.
Now logs will always write to %TEMP%\uc_online2.log
…team path resolution (same pattern as InitSteamClient)
xinerqu added 21 commits May 11, 2026 20:37
…r SteamID folder, no hardcoded game names"

This reverts commit d401c4b.
…ATA, cwd, DLL dir, exe dir)"

This reverts commit 437a357.
…leWrite/FileWriteAsync (Steam writes with epoch 0)
…lid timestamps on Roaming saves"

This reverts commit baeb382.
…alid timestamps on Roaming saves"

This reverts commit 1068ed8.
@xinerqu xinerqu force-pushed the main branch 5 times, most recently from f0fd710 to 69637b0 Compare May 12, 2026 17:24
@veeeanti veeeanti merged commit 3fc4960 into UnionCrax-Team:main May 12, 2026
6 checks passed
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.

2 participants