forked from Public-Mirror/Textractor
catch garbage pipe data
This commit is contained in:
parent
121606af14
commit
d25a61e9e6
@ -134,11 +134,12 @@ namespace
|
|||||||
{
|
{
|
||||||
auto tp = *(ThreadParam*)buffer;
|
auto tp = *(ThreadParam*)buffer;
|
||||||
auto textThreadsByParams = ::textThreadsByParams.Acquire();
|
auto textThreadsByParams = ::textThreadsByParams.Acquire();
|
||||||
if (textThreadsByParams->count(tp) == 0)
|
if (textThreadsByParams->count(tp) == 0) try
|
||||||
{
|
{
|
||||||
TextThread& created = textThreadsByParams->try_emplace(tp, tp, Host::GetHookParam(tp)).first->second;
|
TextThread& created = textThreadsByParams->try_emplace(tp, tp, Host::GetHookParam(tp)).first->second;
|
||||||
OnCreate(created);
|
OnCreate(created);
|
||||||
}
|
}
|
||||||
|
catch (std::out_of_range) { continue; } // probably garbage data in pipe, try again
|
||||||
textThreadsByParams->find(tp)->second.Push(buffer + sizeof(tp), bytesRead - sizeof(tp));
|
textThreadsByParams->find(tp)->second.Push(buffer + sizeof(tp), bytesRead - sizeof(tp));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -375,7 +375,7 @@ void MainWindow::FindHooks()
|
|||||||
QByteArray pattern = QByteArray::fromHex(patternInput->text().replace("??", "11").toUtf8());
|
QByteArray pattern = QByteArray::fromHex(patternInput->text().replace("??", "11").toUtf8());
|
||||||
if (pattern.size() < 3) return;
|
if (pattern.size() < 3) return;
|
||||||
std::wregex filter(L".");
|
std::wregex filter(L".");
|
||||||
if (!filterInput->text().isEmpty()) try { filter = std::wregex(S(filterInput->text())); } catch (std::regex_error&) {};
|
if (!filterInput->text().isEmpty()) try { filter = std::wregex(S(filterInput->text())); } catch (std::regex_error) {};
|
||||||
memcpy(sp.pattern, pattern.data(), sp.length = min(pattern.size(), 25));
|
memcpy(sp.pattern, pattern.data(), sp.length = min(pattern.size(), 25));
|
||||||
auto hooks = std::make_shared<QString>();
|
auto hooks = std::make_shared<QString>();
|
||||||
Host::FindHooks(processId, sp, [hooks, filter](HookParam hp, DWORD processId, const std::wstring& text)
|
Host::FindHooks(processId, sp, [hooks, filter](HookParam hp, DWORD processId, const std::wstring& text)
|
||||||
|
@ -18,7 +18,7 @@ struct : QMainWindow
|
|||||||
{
|
{
|
||||||
std::lock_guard l(m);
|
std::lock_guard l(m);
|
||||||
try { regex = newRegex.toStdWString(); }
|
try { regex = newRegex.toStdWString(); }
|
||||||
catch (...) { return ui.output->setText(INVALID_REGEX); }
|
catch (std::regex_error) { return ui.output->setText(INVALID_REGEX); }
|
||||||
ui.output->setText(QString(CURRENT_FILTER).arg(newRegex));
|
ui.output->setText(QString(CURRENT_FILTER).arg(newRegex));
|
||||||
});
|
});
|
||||||
setWindowTitle(REGEX_FILTER);
|
setWindowTitle(REGEX_FILTER);
|
||||||
|
@ -74,7 +74,7 @@ private:
|
|||||||
std::unique_ptr<void, HandleCleaner> h;
|
std::unique_ptr<void, HandleCleaner> h;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline struct
|
static struct
|
||||||
{
|
{
|
||||||
BYTE DUMMY[100];
|
BYTE DUMMY[100];
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -160,7 +160,7 @@ void SearchForHooks(SearchParam sp)
|
|||||||
std::scoped_lock lock(m);
|
std::scoped_lock lock(m);
|
||||||
|
|
||||||
try { records = std::make_unique<HookRecord[]>(recordsAvailable = CACHE_SIZE); }
|
try { records = std::make_unique<HookRecord[]>(recordsAvailable = CACHE_SIZE); }
|
||||||
catch (std::bad_alloc&) { return ConsoleOutput("Textractor: SearchForHooks ERROR (out of memory)"); }
|
catch (std::bad_alloc) { return ConsoleOutput("Textractor: SearchForHooks ERROR (out of memory)"); }
|
||||||
|
|
||||||
current = sp;
|
current = sp;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user