MCPcopy Create free account
hub / github.com/DFHack/dfhack / launchDFHack

Function launchDFHack

library/modules/DFSteam.cpp:158–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158static bool launchDFHack(color_ostream& out) {
159 if (is_running_on_wine()) {
160 DEBUG(dfsteam, out).print("not attempting to re-launch DFHack on wine\n");
161 return false;
162 }
163
164 if (findProcess(L"launchdf.exe") != -1) {
165 DEBUG(dfsteam, out).print("launchdf.exe already running\n");
166 return true;
167 }
168
169 STARTUPINFOW si;
170 PROCESS_INFORMATION pi;
171
172 ZeroMemory(&si, sizeof(si));
173 si.cb = sizeof(si);
174 ZeroMemory(&pi, sizeof(pi));
175
176 auto procpath = Core::getInstance().getHackPath() / "launchdf.exe";
177 static const char * env = "\0";
178
179 // note that the environment must be explicitly zeroed out and not NULL,
180 // otherwise the launched process will inherit this process's environment,
181 // and the Steam API in the launchdf process will think it is in DF's context.
182 BOOL res = CreateProcessW(procpath.wstring().c_str(),
183 NULL, NULL, NULL, FALSE, 0, (LPVOID)env, NULL, &si, &pi);
184
185 return !!res;
186}
187
188#else
189

Callers 1

Calls 5

findProcessFunction · 0.85
getHackPathMethod · 0.80
c_strMethod · 0.80
is_running_on_wineFunction · 0.70
printMethod · 0.45

Tested by

no test coverage detected