I want to WriteProcessMemory with an int and do it again making the int a negative number. I know how to do this in VB.NET; I tried the same way, but in C++, it won’t work.
WriteProcessMemory(hProcess, (void*)(MYBASE + 0x6F4), &number, 4, NULL);
WriteProcessMemory(hProcess, (void*)(MYBASE + 0xA54), "-" & &number, 4, NULL);
Your
"-" & &numberis not doing what you seem to think it is. In C, the&binary operator means bitwise AND, not string concatenation (C doesn’t have a native string type). So your second line is taking the pointer value (address ofnumber) and doing a bitwise AND with the ASCII numeric value of a hyphen (i.e., you’re taking the address& 46), which will give you a nonsense address and not do what you want.That third parameter to
WriteProcessMemoryis an address, so you need a variable to take the address of. Replace the second line with these two lines: