MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / DoInit

Function DoInit

src/platform/linux/init.cpp:165–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165static void DoInit()
166{
167 DebugLog("[CR] DoInit: version=" CR_VERSION_STRING " finding steamclient.so in /proc/self/maps\n");
168 Log::Info("=== CloudRedirect loaded [BUILD:" CR_RELEASE_VERSION "] ===");
169 Log::Info("CloudRedirect build %s", CR_VERSION_STRING);
170
171 // Kill-switch: if disable file exists, bail without hooking
172 {
173 std::string disablePath = XdgConfigHome() + "/CloudRedirect/disable";
174 if (access(disablePath.c_str(), F_OK) == 0) {
175 DebugLog("[CR] DoInit: kill-switch active (CloudRedirect/disable exists), aborting\n");
176 Log::Warn("Kill-switch active, skipping all hooks");
177 return;
178 }
179 }
180
181 size_t steamSize = 0;
182 uintptr_t steamBase = VtableHook::FindSteamclient(steamSize);
183 if (!steamBase)
184 {
185 DebugLog("[CR] DoInit: FAILED - steamclient.so not found\n");
186 Log::Error("Init failed: steamclient.so not found in maps");
187 Notify("Failed: steamclient.so not found", true);
188 return;
189 }
190 Log::Info("steamclient.so base=%p size=0x%zx", (void*)steamBase, steamSize);
191
192 DebugLog("[CR] DoInit: finding transport vtable\n");
193 void** vtable = VtableHook::FindTransportVtable(steamBase, steamSize);
194 if (!vtable)
195 {
196 DebugLog("[CR] DoInit: FAILED - transport vtable not found\n");
197 Log::Error("Init failed: transport vtable not found");
198 Notify("Incompatible Steam client - hooks disabled", true);
199 return;
200 }
201 Log::Info("Transport vtable at %p, slots: [5]=%p [7]=%p [8]=%p",
202 (void*)vtable, vtable[5], vtable[7], vtable[8]);
203
204 DebugLog("[CR] DoInit: saving originals\n");
205 CloudHooks::SetOriginals(vtable[5], vtable[7], vtable[8]);
206
207 DebugLog("[CR] DoInit: installing transport hooks\n");
208 if (!VtableHook::InstallHooks(vtable, g_vtableInfo))
209 {
210 DebugLog("[CR] DoInit: FAILED - hook installation failed\n");
211 Log::Error("Init failed: transport hook installation failed");
212 return;
213 }
214 Log::Info("Transport hooks installed on slots 5/7/8");
215
216 DebugLog("[CR] DoInit: looking for RemoteStorage vtable\n");
217 void** rsVtable = VtableHook::FindRemoteStorageVtable(steamBase, steamSize);
218 if (rsVtable)
219 {
220 if (VtableHook::InstallCloudEnabledHook(rsVtable, g_cloudEnabledInfo))
221 {
222 CloudHooks::SetOriginalIsCloudEnabled(g_cloudEnabledInfo.origSlot);

Callers 1

DeferredInitThreadFunction · 0.85

Calls 7

DebugLogFunction · 0.85
XdgConfigHomeFunction · 0.85
NotifyFunction · 0.85
StatsSyncEnabledFunction · 0.85
PruneSteamUserdataFunction · 0.85
GetSteamPathFunction · 0.70
InitFunction · 0.50

Tested by

no test coverage detected