From 1817a3ac533c03ff4b6c61c33331c55c2dc234be Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 22 Dec 2018 16:17:08 -0500 Subject: [PATCH] small refactor --- GUI/misc.cpp | 12 +----------- GUI/misc.h | 7 ++++--- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/GUI/misc.cpp b/GUI/misc.cpp index 058b2f0..02c48ff 100644 --- a/GUI/misc.cpp +++ b/GUI/misc.cpp @@ -4,16 +4,6 @@ #include #include -std::wstring S(const QString& S) -{ - return S.toStdWString(); -} - -QString S(const std::wstring& S) -{ - return QString::fromStdWString(S); -} - namespace { std::optional ParseRCode(QString RCode) @@ -221,7 +211,7 @@ namespace if (!(hp.type & MODULE_OFFSET)) if (AutoHandle<> process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processId)) if (MEMORY_BASIC_INFORMATION info = {}; VirtualQueryEx(process, (LPCVOID)hp.address, &info, sizeof(info))) - if (auto moduleName = Util::GetModuleFileName(processId, (HMODULE)info.AllocationBase)) + if (auto moduleName = Util::GetModuleFilename(processId, (HMODULE)info.AllocationBase)) { hp.type |= MODULE_OFFSET; hp.address -= (uint64_t)info.AllocationBase; diff --git a/GUI/misc.h b/GUI/misc.h index c0cf57f..7eadb92 100644 --- a/GUI/misc.h +++ b/GUI/misc.h @@ -6,13 +6,14 @@ class QAutoFile { public: - QAutoFile(QString name, QIODevice::OpenMode mode) : f(name) { f.open(mode); } + QAutoFile(const QString& name, QIODevice::OpenMode mode) : f(name) { f.open(mode); } QFile* operator->() { return &f; } + private: QFile f; }; -std::wstring S(const QString& S); -QString S(const std::wstring& S); +inline std::wstring S(const QString& S) { return { S.toStdWString() }; } +inline QString S(const std::wstring& S) { return QString::fromStdWString(S); } std::optional ParseCode(QString HCode); QString GenerateCode(HookParam hp, DWORD processId);