#include <iostream>
#include <fstream>
int sum(int a, int b)
{
// [CODE INJECT]: Edit values of a & b for constants
return a+b;
}
int main()
{
// [CODE INJECT]: [BEGIN REMOVE]
std::ofstream ofs("file.txt");
ofs << "The SUM of 3 & 3 is equal to: " << sum(3,3) << std::endl;
ofs.close();
// [CODE INJECT]: [END REMOVE]
/* [CODE INJECT]:
std::cout << sum(1,1) << std::endl;
*/
return 0;
}
How would I be able to proceed to the actions I've putted in the comments ?
Would you be able to guide me doing so for this example ?
In Windows you can use OpenProcess / ReadProcessMemory functions to find place you want to intercept. After it you have to use VirtualAllocEx / WriteProcessMemory to write your code into other process memory and rewrite binary existing instructions into jump to your code.