small refactor

This commit is contained in:
Akash Mozumdar 2018-12-22 16:17:08 -05:00
parent 19e7df5631
commit 1817a3ac53
2 changed files with 5 additions and 14 deletions

View File

@ -4,16 +4,6 @@
#include <Psapi.h>
#include <QTextStream>
std::wstring S(const QString& S)
{
return S.toStdWString();
}
QString S(const std::wstring& S)
{
return QString::fromStdWString(S);
}
namespace
{
std::optional<HookParam> 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;

View File

@ -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<HookParam> ParseCode(QString HCode);
QString GenerateCode(HookParam hp, DWORD processId);