Skip to content

Commit

Permalink
catch errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Artikash committed Jun 13, 2019
1 parent 5d2c133 commit 9476070
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void MainWindow::DetachProcess()
void MainWindow::AddHook()
{
if (QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint); ok)
if (auto hp = Util::ParseCode(S(hookCode))) Host::InsertHook(GetSelectedProcessId(), hp.value());
if (auto hp = Util::ParseCode(S(hookCode))) try { Host::InsertHook(GetSelectedProcessId(), hp.value()); } catch (std::out_of_range) {}
else Host::AddConsoleOutput(INVALID_CODE);
}

Expand Down Expand Up @@ -412,10 +412,14 @@ void MainWindow::FindHooks()
memcpy(sp.pattern, pattern.data(), sp.length = min(pattern.size(), 25));
auto hooks = std::make_shared<QString>();
DWORD processId = this->processId;
Host::FindHooks(processId, sp, [processId, hooks, filter](HookParam hp, const std::wstring& text)
try
{
if (std::regex_search(text, filter)) hooks->append(S(Util::GenerateCode(hp, processId)) + ": " + S(text) + "\n");
});
Host::FindHooks(processId, sp, [processId, hooks, filter](HookParam hp, const std::wstring& text)
{
if (std::regex_search(text, filter)) hooks->append(S(Util::GenerateCode(hp, processId)) + ": " + S(text) + "\n");
});
}
catch (std::out_of_range) { return; }
QString fileName = QFileDialog::getSaveFileName(this, SAVE_SEARCH_RESULTS, "./Hooks.txt", TEXT_FILES);
if (fileName.isEmpty()) fileName = "Hooks.txt";
std::thread([hooks, fileName]
Expand Down

0 comments on commit 9476070

Please sign in to comment.