mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
remove unhook button
This commit is contained in:
parent
026912ca9c
commit
7310f9349b
@ -146,17 +146,6 @@ namespace Host
|
|||||||
CreatePipe();
|
CreatePipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Close()
|
|
||||||
{
|
|
||||||
// Artikash 7/25/2018: This is only called when Textractor is closed, at which point Windows should free everything itself...right?
|
|
||||||
#ifdef _DEBUG // Check memory leaks
|
|
||||||
ProcessRecord::OnConnect = ProcessRecord::OnDisconnect = [](auto) {};
|
|
||||||
TextThread::OnCreate = TextThread::OnDestroy = [](auto) {};
|
|
||||||
processRecordsByIds->clear();
|
|
||||||
textThreadsByParams->clear();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InjectProcess(DWORD processId, DWORD timeout)
|
bool InjectProcess(DWORD processId, DWORD timeout)
|
||||||
{
|
{
|
||||||
if (processId == GetCurrentProcessId()) return false;
|
if (processId == GetCurrentProcessId()) return false;
|
||||||
@ -209,11 +198,6 @@ namespace Host
|
|||||||
processRecordsByIds->at(processId)->Send(InsertHookCmd(hp, name));
|
processRecordsByIds->at(processId)->Send(InsertHookCmd(hp, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveHook(DWORD processId, uint64_t addr)
|
|
||||||
{
|
|
||||||
processRecordsByIds->at(processId)->Send(RemoveHookCmd(addr));
|
|
||||||
}
|
|
||||||
|
|
||||||
HookParam GetHookParam(DWORD processId, uint64_t addr)
|
HookParam GetHookParam(DWORD processId, uint64_t addr)
|
||||||
{
|
{
|
||||||
return processRecordsByIds->at(processId)->GetHook(addr).hp;
|
return processRecordsByIds->at(processId)->GetHook(addr).hp;
|
||||||
|
@ -7,13 +7,10 @@ namespace Host
|
|||||||
{
|
{
|
||||||
typedef std::function<void(DWORD)> ProcessEventCallback;
|
typedef std::function<void(DWORD)> ProcessEventCallback;
|
||||||
void Start(ProcessEventCallback OnConnect, ProcessEventCallback OnDisconnect, TextThread::EventCallback OnCreate, TextThread::EventCallback OnDestroy, TextThread::OutputCallback Output);
|
void Start(ProcessEventCallback OnConnect, ProcessEventCallback OnDisconnect, TextThread::EventCallback OnCreate, TextThread::EventCallback OnDestroy, TextThread::OutputCallback Output);
|
||||||
void Close();
|
|
||||||
|
|
||||||
bool InjectProcess(DWORD processId, DWORD timeout = 5000);
|
bool InjectProcess(DWORD processId, DWORD timeout = 5000);
|
||||||
void DetachProcess(DWORD processId);
|
void DetachProcess(DWORD processId);
|
||||||
|
|
||||||
void InsertHook(DWORD processId, HookParam hp, std::string name = "");
|
void InsertHook(DWORD processId, HookParam hp, std::string name = "");
|
||||||
void RemoveHook(DWORD processId, uint64_t addr);
|
|
||||||
|
|
||||||
HookParam GetHookParam(DWORD processId, uint64_t addr);
|
HookParam GetHookParam(DWORD processId, uint64_t addr);
|
||||||
inline HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.processId, tp.addr); }
|
inline HookParam GetHookParam(ThreadParam tp) { return GetHookParam(tp.processId, tp.addr); }
|
||||||
|
@ -37,7 +37,6 @@ MainWindow::~MainWindow()
|
|||||||
{
|
{
|
||||||
settings.setValue(WINDOW, geometry());
|
settings.setValue(WINDOW, geometry());
|
||||||
settings.sync();
|
settings.sync();
|
||||||
Host::Close();
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,22 +151,6 @@ std::unordered_map<std::string, int64_t> MainWindow::GetMiscInfo(TextThread* thr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<HookParam> MainWindow::GetAllHooks(DWORD processId)
|
|
||||||
{
|
|
||||||
QSet<uint64_t> addresses;
|
|
||||||
QVector<HookParam> hooks;
|
|
||||||
for (int i = 0; i < ttCombo->count(); ++i)
|
|
||||||
{
|
|
||||||
ThreadParam tp = ParseTextThreadString(ttCombo->itemText(i));
|
|
||||||
if (tp.processId == processId && !addresses.contains(tp.addr))
|
|
||||||
{
|
|
||||||
addresses.insert(tp.addr);
|
|
||||||
hooks.push_back(Host::GetHookParam(tp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hooks;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_attachButton_clicked()
|
void MainWindow::on_attachButton_clicked()
|
||||||
{
|
{
|
||||||
auto allProcesses = GetAllProcesses();
|
auto allProcesses = GetAllProcesses();
|
||||||
@ -194,27 +177,16 @@ void MainWindow::on_hookButton_clicked()
|
|||||||
else Host::AddConsoleOutput(INVALID_CODE);
|
else Host::AddConsoleOutput(INVALID_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_unhookButton_clicked()
|
|
||||||
{
|
|
||||||
auto hooks = GetAllHooks(GetSelectedProcessId());
|
|
||||||
if (hooks.empty()) return Host::AddConsoleOutput(NO_HOOKS);
|
|
||||||
QStringList hookList;
|
|
||||||
for (auto hp : hooks)
|
|
||||||
hookList.push_back(
|
|
||||||
QString::fromStdWString(Host::GetHookName(GetSelectedProcessId(), hp.insertion_address)) +
|
|
||||||
": " +
|
|
||||||
GenerateCode(hp, GetSelectedProcessId())
|
|
||||||
);
|
|
||||||
bool ok;
|
|
||||||
QString hook = QInputDialog::getItem(this, UNHOOK, REMOVE_HOOK, hookList, 0, false, &ok, Qt::WindowCloseButtonHint);
|
|
||||||
if (ok) Host::RemoveHook(GetSelectedProcessId(), hooks.at(hookList.indexOf(hook)).insertion_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_saveButton_clicked()
|
void MainWindow::on_saveButton_clicked()
|
||||||
{
|
{
|
||||||
|
QHash<uint64_t, QString> hookCodes;
|
||||||
|
for (int i = 0; i < ttCombo->count(); ++i)
|
||||||
|
{
|
||||||
|
ThreadParam tp = ParseTextThreadString(ttCombo->itemText(i));
|
||||||
|
if (tp.processId == GetSelectedProcessId() && !(Host::GetHookParam(tp).type & HOOK_ENGINE)) hookCodes[tp.addr] = GenerateCode(Host::GetHookParam(tp), tp.processId);
|
||||||
|
}
|
||||||
QString hookList = GetFullModuleName(GetSelectedProcessId());
|
QString hookList = GetFullModuleName(GetSelectedProcessId());
|
||||||
for (auto hp : GetAllHooks(GetSelectedProcessId()))
|
for (auto hookCode : hookCodes) hookList += " , " + hookCode;
|
||||||
if (!(hp.type & HOOK_ENGINE)) hookList += " , " + GenerateCode(hp, GetSelectedProcessId());
|
|
||||||
QAutoFile(HOOK_SAVE_FILE, QIODevice::Append)->write((hookList + "\r\n").toUtf8());
|
QAutoFile(HOOK_SAVE_FILE, QIODevice::Append)->write((hookList + "\r\n").toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void on_attachButton_clicked();
|
void on_attachButton_clicked();
|
||||||
void on_detachButton_clicked();
|
void on_detachButton_clicked();
|
||||||
void on_unhookButton_clicked();
|
|
||||||
void on_hookButton_clicked();
|
void on_hookButton_clicked();
|
||||||
void on_saveButton_clicked();
|
void on_saveButton_clicked();
|
||||||
void on_setButton_clicked();
|
void on_setButton_clicked();
|
||||||
@ -32,6 +31,7 @@ private slots:
|
|||||||
void on_ttCombo_activated(int index);
|
void on_ttCombo_activated(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void closeEvent(QCloseEvent*);
|
||||||
void InvokeOnMainThread(std::function<void()>&& f);
|
void InvokeOnMainThread(std::function<void()>&& f);
|
||||||
void ProcessConnected(DWORD processId);
|
void ProcessConnected(DWORD processId);
|
||||||
void ProcessDisconnected(DWORD processId);
|
void ProcessDisconnected(DWORD processId);
|
||||||
@ -42,8 +42,6 @@ private:
|
|||||||
ThreadParam ParseTextThreadString(QString ttString);
|
ThreadParam ParseTextThreadString(QString ttString);
|
||||||
DWORD GetSelectedProcessId();
|
DWORD GetSelectedProcessId();
|
||||||
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
||||||
QVector<HookParam> GetAllHooks(DWORD processId);
|
|
||||||
void closeEvent(QCloseEvent*);
|
|
||||||
|
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QSettings settings = QSettings(CONFIG_FILE, QSettings::IniFormat);
|
QSettings settings = QSettings(CONFIG_FILE, QSettings::IniFormat);
|
||||||
|
@ -87,13 +87,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="unhookButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove hook</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="saveButton">
|
<widget class="QPushButton" name="saveButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -99,13 +99,6 @@ struct InsertHookCmd // From host
|
|||||||
char name[HOOK_NAME_SIZE] = {};
|
char name[HOOK_NAME_SIZE] = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RemoveHookCmd // From host
|
|
||||||
{
|
|
||||||
RemoveHookCmd(uint64_t address) : address(address) {};
|
|
||||||
int command = HOST_COMMAND_REMOVE_HOOK;
|
|
||||||
uint64_t address;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ConsoleOutputNotif // From hook
|
struct ConsoleOutputNotif // From hook
|
||||||
{
|
{
|
||||||
ConsoleOutputNotif(std::string message = "") { strcpy_s<MESSAGE_SIZE>(this->message, message.c_str()); };
|
ConsoleOutputNotif(std::string message = "") { strcpy_s<MESSAGE_SIZE>(this->message, message.c_str()); };
|
||||||
|
@ -71,12 +71,6 @@ DWORD WINAPI Pipe(LPVOID)
|
|||||||
NewHook(info.hp, info.name, 0);
|
NewHook(info.hp, info.name, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HOST_COMMAND_REMOVE_HOOK:
|
|
||||||
{
|
|
||||||
auto info = *(RemoveHookCmd*)buffer;
|
|
||||||
RemoveHook(info.address);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case HOST_COMMAND_DETACH:
|
case HOST_COMMAND_DETACH:
|
||||||
{
|
{
|
||||||
running = false;
|
running = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user