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

Function findProcess

library/modules/DFSteam.cpp:134–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static DWORD findProcess(LPCWSTR name) {
135 PROCESSENTRY32W entry;
136 entry.dwSize = sizeof(PROCESSENTRY32W);
137
138 const auto snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
139
140 if (!Process32FirstW(snapshot, &entry)) {
141 CloseHandle(snapshot);
142 return -1;
143 }
144
145 do {
146 std::wstring executableName(entry.szExeFile);
147 if (executableName == name) {
148 CloseHandle(snapshot);
149 return entry.th32ProcessID;
150 }
151 }
152 while (Process32NextW(snapshot, &entry));
153
154 CloseHandle(snapshot);
155 return -1;
156}
157
158static bool launchDFHack(color_ostream& out) {
159 if (is_running_on_wine()) {

Callers 1

launchDFHackFunction · 0.85

Calls 2

c_strMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected