forked from Public-Mirror/Textractor
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9b4f229ff0 |
@ -254,7 +254,7 @@ namespace
|
|||||||
{
|
{
|
||||||
hp.type |= MODULE_OFFSET;
|
hp.type |= MODULE_OFFSET;
|
||||||
hp.address -= (uint64_t)info.AllocationBase;
|
hp.address -= (uint64_t)info.AllocationBase;
|
||||||
wcsncpy_s(hp.module, moduleName->c_str() + moduleName->rfind(L'\\') + 1, MAX_MODULE_SIZE - 1);
|
wcsncpy_s(hp.module, moduleName->filename().c_str(), MAX_MODULE_SIZE - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
HCode += L'@' + HexString(hp.address);
|
HCode += L'@' + HexString(hp.address);
|
||||||
|
@ -207,7 +207,7 @@ namespace Host
|
|||||||
IsWow64Process(process, &invalidProcess);
|
IsWow64Process(process, &invalidProcess);
|
||||||
if (invalidProcess) return AddConsoleOutput(NEED_32_BIT);
|
if (invalidProcess) return AddConsoleOutput(NEED_32_BIT);
|
||||||
#endif
|
#endif
|
||||||
static std::wstring location = std::filesystem::path(GetModuleFilename().value()).replace_filename(ITH_DLL);
|
static std::wstring location = GetModuleFilename().value().replace_filename(ITH_DLL);
|
||||||
if (LPVOID remoteData = VirtualAllocEx(process, nullptr, (location.size() + 1) * sizeof(wchar_t), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE))
|
if (LPVOID remoteData = VirtualAllocEx(process, nullptr, (location.size() + 1) * sizeof(wchar_t), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE))
|
||||||
{
|
{
|
||||||
WriteProcessMemory(process, remoteData, location.c_str(), (location.size() + 1) * sizeof(wchar_t), nullptr);
|
WriteProcessMemory(process, remoteData, location.c_str(), (location.size() + 1) * sizeof(wchar_t), nullptr);
|
||||||
|
@ -141,7 +141,7 @@ namespace
|
|||||||
{
|
{
|
||||||
QMultiHash<QString, DWORD> allProcesses;
|
QMultiHash<QString, DWORD> allProcesses;
|
||||||
for (auto [processId, processName] : GetAllProcesses())
|
for (auto [processId, processName] : GetAllProcesses())
|
||||||
if (processName && (showSystemProcesses || processName->find(L":\\Windows\\") == std::wstring::npos))
|
if (processName && (showSystemProcesses || processName->wstring().find(L":\\Windows\\") == std::wstring::npos))
|
||||||
allProcesses.insert(QFileInfo(S(processName.value())).fileName(), processId);
|
allProcesses.insert(QFileInfo(S(processName.value())).fileName(), processId);
|
||||||
|
|
||||||
QStringList processList(allProcesses.uniqueKeys());
|
QStringList processList(allProcesses.uniqueKeys());
|
||||||
@ -194,9 +194,9 @@ namespace
|
|||||||
|
|
||||||
void OpenProcessConfig()
|
void OpenProcessConfig()
|
||||||
{
|
{
|
||||||
if (auto processName = GetModuleFilename(selectedProcessId)) if (int last = processName->rfind(L'\\') + 1)
|
if (auto processName = GetModuleFilename(selectedProcessId))
|
||||||
{
|
{
|
||||||
std::wstring configFile = std::wstring(processName.value()).replace(last, std::wstring::npos, GAME_CONFIG_FILE);
|
auto configFile = processName->replace_filename(GAME_CONFIG_FILE);
|
||||||
if (!std::filesystem::exists(configFile)) QTextFile(S(configFile), QFile::WriteOnly).write("see https://github.com/Artikash/Textractor/wiki/Game-configuration-file");
|
if (!std::filesystem::exists(configFile)) QTextFile(S(configFile), QFile::WriteOnly).write("see https://github.com/Artikash/Textractor/wiki/Game-configuration-file");
|
||||||
_wspawnlp(_P_DETACH, L"notepad", L"notepad", configFile.c_str(), NULL);
|
_wspawnlp(_P_DETACH, L"notepad", L"notepad", configFile.c_str(), NULL);
|
||||||
}
|
}
|
||||||
@ -642,7 +642,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
if (arg[1] == L'p' || arg[1] == L'P')
|
if (arg[1] == L'p' || arg[1] == L'P')
|
||||||
if (DWORD processId = _wtoi(arg.substr(2).c_str())) Host::InjectProcess(processId);
|
if (DWORD processId = _wtoi(arg.substr(2).c_str())) Host::InjectProcess(processId);
|
||||||
else for (auto [processId, processName] : processes)
|
else for (auto [processId, processName] : processes)
|
||||||
if (processName.value_or(L"").find(L"\\" + arg.substr(2)) != std::wstring::npos) Host::InjectProcess(processId);
|
if (processName.value_or(L"").filename() == arg.substr(2)) Host::InjectProcess(processId);
|
||||||
|
|
||||||
std::thread([]
|
std::thread([]
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
|
|
||||||
inline std::optional<std::wstring> GetModuleFilename(DWORD processId, HMODULE module = NULL)
|
inline std::optional<std::filesystem::path> GetModuleFilename(DWORD processId, HMODULE module = NULL)
|
||||||
{
|
{
|
||||||
std::vector<wchar_t> buffer(MAX_PATH);
|
std::vector<wchar_t> buffer(MAX_PATH);
|
||||||
if (AutoHandle<> process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processId))
|
if (AutoHandle<> process = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processId))
|
||||||
@ -9,19 +9,19 @@ inline std::optional<std::wstring> GetModuleFilename(DWORD processId, HMODULE mo
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::optional<std::wstring> GetModuleFilename(HMODULE module = NULL)
|
inline std::optional<std::filesystem::path> GetModuleFilename(HMODULE module = NULL)
|
||||||
{
|
{
|
||||||
std::vector<wchar_t> buffer(MAX_PATH);
|
std::vector<wchar_t> buffer(MAX_PATH);
|
||||||
if (GetModuleFileNameW(module, buffer.data(), MAX_PATH)) return buffer.data();
|
if (GetModuleFileNameW(module, buffer.data(), MAX_PATH)) return buffer.data();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::vector<std::pair<DWORD, std::optional<std::wstring>>> GetAllProcesses()
|
inline std::vector<std::pair<DWORD, std::optional<std::filesystem::path>>> GetAllProcesses()
|
||||||
{
|
{
|
||||||
std::vector<DWORD> processIds(10000);
|
std::vector<DWORD> processIds(10000);
|
||||||
DWORD spaceUsed = 0;
|
DWORD spaceUsed = 0;
|
||||||
EnumProcesses(processIds.data(), 10000 * sizeof(DWORD), &spaceUsed);
|
EnumProcesses(processIds.data(), 10000 * sizeof(DWORD), &spaceUsed);
|
||||||
std::vector<std::pair<DWORD, std::optional<std::wstring>>> processes;
|
std::vector<std::pair<DWORD, std::optional<std::filesystem::path>>> processes;
|
||||||
for (int i = 0; i < spaceUsed / sizeof(DWORD); ++i) processes.push_back({ processIds[i], GetModuleFilename(processIds[i]) });
|
for (int i = 0; i < spaceUsed / sizeof(DWORD); ++i) processes.push_back({ processIds[i], GetModuleFilename(processIds[i]) });
|
||||||
return processes;
|
return processes;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user