So I'm trying to change some bytes in a game's memory. The function by itself works completely fine, but when I put it into a class it doesn't do basically anything.
main.cpp
int main()
{
while (!GetAsyncKeyState(VK_END))
{
// this is the function I'm talking about
if (vars::infAmmo)
{
mem::nop((void*)0x7FF65564B5E0, 8);
}
else
{
mem::patch((void*)0x7FF65564B5E0, (void*)"\x41\x89\x84\x8E\x94\x01\x00\x00", 8);
}
Sleep(100);
}
return 0;
}
^^ this works completely fine
After that, I decided to put it into a class, to organize my code a little. Then I encountered the issue of it not working.
misc.cpp
#include "pch.h"
void CMisc::infAmmo()
{
if (vars::infAmmo)
{
mem::nop((void*)0x7FF65564B5E0, 8);
}
else
{
mem::patch((void*)0x7FF65564B5E0, (void*)"\x41\x89\x84\x8E\x94\x01\x00\x00", 8);
}
}
void CMisc::run()
{
infAmmo();
}
misc.h
#pragma once
class CMisc
{
private:
void infAmmo();
public:
CMisc() {};
~CMisc() {};
public:
void run();
};
main.cpp
CMisc misc{};
int main()
{
while (!GetAsyncKeyState(VK_END))
{
misc.run();
Sleep(100);
}
return 0;
}
^^ basically doesn't do anything
Sorry, if it's something obvious, but I just can't find out what is wrong.