MCPcopy Create free account
hub / github.com/Artikash/Textractor / LaunchProcess

Function LaunchProcess

GUI/mainwindow.cpp:202–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200 }
201
202 void LaunchProcess()
203 {
204 std::wstring process;
205 if (auto selected = UserSelectedProcess()) process = selected.value();
206 else return;
207 std::wstring path = std::wstring(process).erase(process.rfind(L'\\'));
208
209 PROCESS_INFORMATION info = {};
210 auto useLocale = Settings().value(CONFIG_JP_LOCALE, PROMPT).toInt();
211 if (!x64 && (useLocale == ALWAYS || (useLocale == PROMPT && QMessageBox::question(This, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes)))
212 {
213 if (HMODULE localeEmulator = LoadLibraryW(L"LoaderDll"))
214 {
215 // https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs#L252
216 struct
217 {
218 ULONG AnsiCodePage = SHIFT_JIS;
219 ULONG OemCodePage = SHIFT_JIS;
220 ULONG LocaleID = LANG_JAPANESE;
221 ULONG DefaultCharset = SHIFTJIS_CHARSET;
222 ULONG HookUiLanguageApi = FALSE;
223 WCHAR DefaultFaceName[LF_FACESIZE] = {};
224 TIME_ZONE_INFORMATION Timezone;
225 ULONG64 Unused = 0;
226 } LEB;
227 GetTimeZoneInformation(&LEB.Timezone);
228 ((LONG(__stdcall*)(decltype(&LEB), LPCWSTR appName, LPWSTR commandLine, LPCWSTR currentDir, void*, void*, PROCESS_INFORMATION*, void*, void*, void*, void*))
229 GetProcAddress(localeEmulator, "LeCreateProcess"))(&LEB, process.c_str(), NULL, path.c_str(), NULL, NULL, &info, NULL, NULL, NULL, NULL);
230 }
231 }
232 if (info.hProcess == NULL)
233 {
234 STARTUPINFOW DUMMY = { sizeof(DUMMY) };
235 CreateProcessW(process.c_str(), NULL, nullptr, nullptr, FALSE, 0, nullptr, path.c_str(), &DUMMY, &info);
236 }
237 if (info.hProcess == NULL) return Host::AddConsoleOutput(LAUNCH_FAILED);
238 Host::InjectProcess(info.dwProcessId);
239 CloseHandle(info.hProcess);
240 CloseHandle(info.hThread);
241 }
242
243 void ConfigureProcess()
244 {

Callers

nothing calls this directly

Calls 4

UserSelectedProcessFunction · 0.85
SettingsClass · 0.85
AddConsoleOutputFunction · 0.85
InjectProcessFunction · 0.85

Tested by

no test coverage detected