All initialisation that touches the filesystem, loads modules, scans memory, or installs detours runs here on a worker thread — we MUST NOT do any of that from inside DllMain (loader lock).
| 44 | // memory, or installs detours runs here on a worker thread — we MUST NOT do |
| 45 | // any of that from inside DllMain (loader lock). |
| 46 | static uint32_t InitThread(OSTPlatform::DynamicLibrary::ModuleHandle selfModule) { |
| 47 | Log::Init(selfModule); |
| 48 | LOG_INFO("OpenSteamTool init thread started"); |
| 49 | |
| 50 | if (!InitializeSteamComponents()) { |
| 51 | LOG_ERROR("InitializeSteamComponents failed"); |
| 52 | return 1; |
| 53 | } |
| 54 | |
| 55 | Config::Load(ConfigPath); |
| 56 | Log::InitModules(); |
| 57 | Log::InstallPlatformLogSink(); |
| 58 | SteamDiagnostics::Initialize(SteamclientPath, SteamUIPath); |
| 59 | |
| 60 | // Load pattern files for steamclient64.dll and steamui.dll. |
| 61 | // Each call computes the SHA-256 of the DLL on disk, checks the local |
| 62 | // cache, and downloads from GitHub if needed. Both calls are synchronous |
| 63 | // but run on this worker thread, never under the loader lock. |
| 64 | PatternLoader::Load(ui_hModule, SteamUIPath, "steamui"); |
| 65 | PatternLoader::Load(client_hModule, SteamclientPath, "steamclient"); |
| 66 | |
| 67 | // IPC method metadata (funcHash, fencepost, argc, ...) |
| 68 | IPCLoader::Load(SteamclientPath); |
| 69 | |
| 70 | std::vector<std::string> watchDirs = Config::GetLuaPaths(); |
| 71 | watchDirs.push_back(std::string(LuaDir)); |
| 72 | for (const auto& dir : watchDirs) |
| 73 | LuaConfig::ParseDirectory(dir); |
| 74 | |
| 75 | LuaFileWatcher::Start(watchDirs); |
| 76 | ConfigFileWatcher::Start(ConfigPath, LuaDir); |
| 77 | |
| 78 | SteamUI::CoreHook(); |
| 79 | SteamClient::CoreHook(); |
| 80 | |
| 81 | // Surface any functions that FindPattern() could not locate. |
| 82 | PatternLoader::ReportMissingFunctions(); |
| 83 | |
| 84 | LOG_INFO("OpenSteamTool init complete"); |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, PVOID pvReserved) |
| 89 | { |
no test coverage detected