Skip to content

Commit

Permalink
Architecture match check
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed May 29, 2021
1 parent 1ac720b commit 419f284
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
11 changes: 10 additions & 1 deletion oloJector/Injector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,20 @@ void Injector::loadProcess()
std::cout << "\nFailed to load process " << m_pid;
exit(1);
}
std::cout << "\nProcess loaded";
std::cout << "\nProcess loaded\n";
}

void Injector::inject()
{
ProcessInfo pinfo(m_pid);
pinfo.setis64();

if (!pinfo.getis64() ^ m_dll->getArch())
{
std::cout << "Architecture mismatch : Process : " << !pinfo.getis64() << " dll : " << m_dll->getArch();
exit(1);
}

HMODULE hkernel32 = GetModuleHandle(L"kernel32.dll");
if (!hkernel32)
{
Expand Down
1 change: 1 addition & 0 deletions oloJector/Injector.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "dllManager.h"
#include <tchar.h>
#include <Windows.h>
#include "ProcessInfo.h"

class Injector
{
Expand Down
2 changes: 1 addition & 1 deletion oloJector/ProcessInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ProcessInfo::printInfo()
void ProcessInfo::printInfo(bool is64)
{
TCHAR arch[4];
if (m_is64)
if (m_is64) // Probably lucky that this this working
_tcscpy_s(arch, 4, TEXT("x86"));
else if (is64)
_tcscpy_s(arch, 4, TEXT("x64"));
Expand Down
9 changes: 7 additions & 2 deletions oloJector/dllManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ void dllManager::setPath(const char* path)
{
char buffer[512];

const char x86[] = { 0x02, 0x02, 0x64, 0x86, 0x00 };
const char x64[] = { 0x02, 0x02, 0x4c, 0x01, 0x00 };
const char x64[] = { 0x02, 0x02, 0x64, 0x86, 0x00 };
const char x86[] = { 0x02, 0x02, 0x4c, 0x01, 0x00 };

strcpy_s(m_path, path);

Expand Down Expand Up @@ -75,4 +75,9 @@ void dllManager::print()
_tcscpy_s(arch, 4, TEXT("x86"));

printf("\nDll loaded : %s\nArchitecture : %ws\n", m_path, arch);
}

bool dllManager::getArch()
{
return m_is64;
}
1 change: 1 addition & 0 deletions oloJector/dllManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class dllManager
void setPath(const char* path);
void print();
char* getPath();
bool getArch();

private:
char m_path[MAX_PATH];
Expand Down

0 comments on commit 419f284

Please sign in to comment.