Hello,

I've seen some tutorials here about changing Assembly instructions and even after reading all the stuff, I can't manage to solve this.

Issue: can't change 2B Assembly instruction (SUB) to 03 instruction (ADD) in CPP. When I do it, the game crashes (more info in the comments).

I've used ollydbg to find out the address of the instruction. When I simply change it on ollydbg, it works fine. But it won't work when I write the cpp code for it. I was hoping you guys could help me with this.

Other note: I'm sure that the right instruction should be 03, because I changed it to 03 on ollydbg and it worked.

Code:
#include "stdafx.h"
#include <string.h>

void NowSum(DWORD* Address){   

	DWORD OldProt;
	
	char* CharPointer = (char*) Address;

	VirtualProtect((void*) Address, 1, 0x40, &OldProt); // I need to overwrite 1 byte
 
	*CharPointer = '\x03'; //Nothing happens to the game when I do this. Nothing is overwritten

	/* This is another way to do the job, but it crashes the game

	memcpy(Address, (void*)'\x03', 1);

	*/

	VirtualProtect((void*) Address, 1, OldProt, NULL);

}

void MainThread() {


	NowSum((DWORD*)"0x2000490C"); // I think the issue may be related to the way I'm passing the address here. I'm using a constant to do so. Is this right?

return;

}


BOOL APIENTRY DllMain( HANDLE hModule, DWORD  fdwReason, LPVOID lpReserved ) {    // main() function inside the dll

	if( fdwReason == DLL_PROCESS_ATTACH){
       CreateThread(0, 0, (LPTHREAD_START_ROUTINE)&MainThread, NULL, NULL, NULL);
	   return TRUE;
	}

    return TRUE;
}
Thanks.