forked from Public-Mirror/Textractor
std::optional is beautiful
This commit is contained in:
parent
61fb3248fe
commit
a8cebd1b86
@ -6,6 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
|
|||||||
project(NextHooker)
|
project(NextHooker)
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
|
/std:c++17
|
||||||
#/Zc:auto # config.pri
|
#/Zc:auto # config.pri
|
||||||
/wd4819 # config.pri
|
/wd4819 # config.pri
|
||||||
/MP
|
/MP
|
||||||
|
@ -63,7 +63,7 @@ void MainWindow::AddProcess(unsigned int processId)
|
|||||||
{
|
{
|
||||||
QStringList hooks = allProcesses.at(i).split(" , ");
|
QStringList hooks = allProcesses.at(i).split(" , ");
|
||||||
for (int j = 1; j < hooks.length(); ++j)
|
for (int j = 1; j < hooks.length(); ++j)
|
||||||
Host::InsertHook(processId, ParseCode(hooks.at(j)));
|
Host::InsertHook(processId, ParseCode(hooks.at(j)).value_or(HookParam()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,13 +200,8 @@ void MainWindow::on_hookButton_clicked()
|
|||||||
bool ok;
|
bool ok;
|
||||||
QString hookCode = QInputDialog::getText(this, "Add Hook", CodeInfoDump, QLineEdit::Normal, "", &ok);
|
QString hookCode = QInputDialog::getText(this, "Add Hook", CodeInfoDump, QLineEdit::Normal, "", &ok);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
HookParam toInsert = ParseCode(hookCode);
|
if (auto hp = ParseCode(hookCode)) Host::InsertHook(GetSelectedProcessId(), hp.value());
|
||||||
if (toInsert.type == 0 && toInsert.length_offset == 0)
|
else Host::AddConsoleOutput(L"invalid code");
|
||||||
{
|
|
||||||
Host::AddConsoleOutput(L"invalid code");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Host::InsertHook(GetSelectedProcessId(), ParseCode(hookCode));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_unhookButton_clicked()
|
void MainWindow::on_unhookButton_clicked()
|
||||||
|
@ -38,7 +38,7 @@ DWORD Hash(QString module)
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
HookParam ParseRCode(QString RCode)
|
std::optional<HookParam> ParseRCode(QString RCode)
|
||||||
{
|
{
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.type |= DIRECT_READ;
|
hp.type |= DIRECT_READ;
|
||||||
@ -68,7 +68,7 @@ HookParam ParseRCode(QString RCode)
|
|||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
HookParam ParseHCode(QString HCode)
|
std::optional<HookParam> ParseHCode(QString HCode)
|
||||||
{
|
{
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
switch (HCode.at(0).unicode())
|
switch (HCode.at(0).unicode())
|
||||||
@ -145,7 +145,7 @@ HookParam ParseHCode(QString HCode)
|
|||||||
return hp;
|
return hp;
|
||||||
}
|
}
|
||||||
|
|
||||||
HookParam ParseCode(QString code)
|
std::optional<HookParam> ParseCode(QString code)
|
||||||
{
|
{
|
||||||
code = code.toUpper();
|
code = code.toUpper();
|
||||||
if (code.startsWith("/H")) return ParseHCode(code.remove(0, 2));
|
if (code.startsWith("/H")) return ParseHCode(code.remove(0, 2));
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
std::unordered_map<std::wstring, DWORD> GetAllProcesses();
|
std::unordered_map<std::wstring, DWORD> GetAllProcesses();
|
||||||
HookParam ParseCode(QString HCode);
|
std::optional<HookParam> ParseCode(QString HCode);
|
||||||
QString GenerateCode(HookParam hp, DWORD processId);
|
QString GenerateCode(HookParam hp, DWORD processId);
|
||||||
|
|
||||||
static QString CodeInfoDump =
|
static QString CodeInfoDump =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user