inject correctly in CLI

This commit is contained in:
Akash Mozumdar 2020-03-26 05:39:25 -06:00
parent bb0df71da2
commit 19f35f743c

View File

@ -1,5 +1,6 @@
#include "host.h"
#include "defs.h"
#include "module.h"
#include "hookcode.h"
#include "../texthook/texthook.h"
@ -206,7 +207,7 @@ namespace Host
IsWow64Process(process, &invalidProcess);
if (invalidProcess) return AddConsoleOutput(NEED_32_BIT);
#endif
static std::wstring location = std::filesystem::current_path().wstring() + L"\\" + ITH_DLL;
static std::wstring location = std::filesystem::path(GetModuleFilename().value()).replace_filename(ITH_DLL);
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);