give up on emulating non jp locale and launching in correct directory

This commit is contained in:
Akash Mozumdar 2019-01-13 03:40:00 -05:00
parent 6a357b5e32
commit a84ea357ec
2 changed files with 28 additions and 27 deletions

View File

@ -10,6 +10,7 @@
#include <QFormLayout> #include <QFormLayout>
#include <QPushButton> #include <QPushButton>
#include <QSpinBox> #include <QSpinBox>
#include <QMessageBox>
#include <QInputDialog> #include <QInputDialog>
#include <QFileDialog> #include <QFileDialog>
@ -203,8 +204,7 @@ void MainWindow::AttachProcess()
QStringList processList(allProcesses.uniqueKeys()); QStringList processList(allProcesses.uniqueKeys());
processList.sort(Qt::CaseInsensitive); processList.sort(Qt::CaseInsensitive);
QString process = QInputDialog::getItem(this, SELECT_PROCESS, ATTACH_INFO, processList, 0, true, &ok, Qt::WindowCloseButtonHint); if (QString process = QInputDialog::getItem(this, SELECT_PROCESS, ATTACH_INFO, processList, 0, true, &ok, Qt::WindowCloseButtonHint); ok)
if (!ok) return;
if (process.toInt(nullptr, 0)) Host::InjectProcess(process.toInt(nullptr, 0)); if (process.toInt(nullptr, 0)) Host::InjectProcess(process.toInt(nullptr, 0));
else for (auto processId : allProcesses.values(process)) Host::InjectProcess(processId); else for (auto processId : allProcesses.values(process)) Host::InjectProcess(processId);
} }
@ -219,17 +219,18 @@ void MainWindow::LaunchProcess()
if (!ok) return; if (!ok) return;
if (S(process) == SEARCH_GAME) process = S(QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, SELECT_PROCESS, "C:\\", PROCESSES))); if (S(process) == SEARCH_GAME) process = S(QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, SELECT_PROCESS, "C:\\", PROCESSES)));
if (process.empty()) return; if (process.empty()) return;
std::wstring path = std::wstring(process).erase(process.rfind(L'\\'));
PROCESS_INFORMATION info = {}; PROCESS_INFORMATION info = {};
if (QMessageBox::question(this, SELECT_PROCESS, USE_JP_LOCALE) == QMessageBox::Yes)
if (HMODULE localeEmulator = LoadLibraryOnce(L"LoaderDll")) if (HMODULE localeEmulator = LoadLibraryOnce(L"LoaderDll"))
{ {
// see https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs#L252 // see https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs#L252
struct struct
{ {
ULONG AnsiCodePage = Host::defaultCodepage; ULONG AnsiCodePage = SHIFT_JIS;
ULONG OemCodePage = Host::defaultCodepage; ULONG OemCodePage = SHIFT_JIS;
ULONG LocaleID = LANG_JAPANESE; ULONG LocaleID = LANG_JAPANESE;
ULONG DefaultCharset = DEFAULT_CHARSET; ULONG DefaultCharset = SHIFTJIS_CHARSET;
ULONG HookUiLanguageApi = FALSE; ULONG HookUiLanguageApi = FALSE;
WCHAR DefaultFaceName[LF_FACESIZE] = {}; WCHAR DefaultFaceName[LF_FACESIZE] = {};
TIME_ZONE_INFORMATION Timezone; TIME_ZONE_INFORMATION Timezone;
@ -237,12 +238,12 @@ void MainWindow::LaunchProcess()
} LEB; } LEB;
GetTimeZoneInformation(&LEB.Timezone); GetTimeZoneInformation(&LEB.Timezone);
((LONG(__stdcall*)(decltype(&LEB), LPCWSTR appName, LPWSTR commandLine, LPCWSTR currentDir, void*, void*, PROCESS_INFORMATION*, void*, void*, void*, void*)) ((LONG(__stdcall*)(decltype(&LEB), LPCWSTR appName, LPWSTR commandLine, LPCWSTR currentDir, void*, void*, PROCESS_INFORMATION*, void*, void*, void*, void*))
GetProcAddress(localeEmulator, "LeCreateProcess"))(&LEB, process.c_str(), NULL, path.c_str(), NULL, NULL, &info, NULL, NULL, NULL, NULL); GetProcAddress(localeEmulator, "LeCreateProcess"))(&LEB, process.c_str(), NULL, NULL, NULL, NULL, &info, NULL, NULL, NULL, NULL);
} }
if (info.hProcess == NULL) if (info.hProcess == NULL)
{ {
STARTUPINFOW DUMMY = { sizeof(DUMMY) }; STARTUPINFOW DUMMY = { sizeof(DUMMY) };
CreateProcessW(process.c_str(), NULL, nullptr, nullptr, FALSE, 0, nullptr, path.c_str(), &DUMMY, &info); CreateProcessW(process.c_str(), NULL, nullptr, nullptr, FALSE, 0, nullptr, NULL, &DUMMY, &info);
} }
if (info.hProcess == NULL) return Host::AddConsoleOutput(LAUNCH_FAILED); if (info.hProcess == NULL) return Host::AddConsoleOutput(LAUNCH_FAILED);
Host::InjectProcess(info.dwProcessId); Host::InjectProcess(info.dwProcessId);
@ -257,8 +258,7 @@ void MainWindow::DetachProcess()
void MainWindow::AddHook() void MainWindow::AddHook()
{ {
QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint); if (QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint); ok)
if (!ok) return;
if (auto hp = ParseCode(hookCode)) Host::InsertHook(GetSelectedProcessId(), hp.value()); if (auto hp = ParseCode(hookCode)) Host::InsertHook(GetSelectedProcessId(), hp.value());
else Host::AddConsoleOutput(INVALID_CODE); else Host::AddConsoleOutput(INVALID_CODE);
} }

View File

@ -37,6 +37,7 @@ constexpr auto EXTEN_WINDOW_INSTRUCTIONS = u8R"(Drag and drop extension (.dll) f
Drag and drop within the list to reorder Drag and drop within the list to reorder
Press delete with an extension selected to remove it)"; Press delete with an extension selected to remove it)";
constexpr auto WINDOW = u8"Window"; constexpr auto WINDOW = u8"Window";
constexpr auto USE_JP_LOCALE = u8"Emulate japanese locale?";
constexpr auto DEFAULT_CODEPAGE = u8"Default Codepage"; constexpr auto DEFAULT_CODEPAGE = u8"Default Codepage";
constexpr auto FLUSH_DELAY = u8"Flush Delay"; constexpr auto FLUSH_DELAY = u8"Flush Delay";
constexpr auto MAX_BUFFER_SIZE = u8"Max Buffer Size"; constexpr auto MAX_BUFFER_SIZE = u8"Max Buffer Size";