I'm pretty sure I know what the cause of this issue is, the instruction is shared op code. It's being used thousands of times a second by 30+ addresses. I found a 100% guaranteed commonality to get the specific address I want so that's not the issue, the issue is the script is resetting my custom allocated address back to its original value when the instruction is called. How do I fix this?
Doesn't seem like any thing in the first script is writing to it. You'll just have to debug, and try to see what writes the the flag.
No, nothing is writing to infiniteStaminaEnabled only the second script. Which is why I'm confused the first script is resetting the value to 0, nothing writing to it, just reading.
// move value from [RBX+3C] into RDX
mov rdx,[rbx+3C]
// move value from RDX into allocated memory [maxRowerStamina]
mov [maxRowerStamina],rdx
pop rdx
Is this intentional? Or did you want the maxRowerStamina to be a set value by the user? Also, not sure if this is an issue but your logic compares an integer against a byte value.
I was only thinking about what you ask, but after seeing what LeFiXER said I would add this. The compare for "infiniteStaminaEnabled" you compare a 4 byte (32 bit) value, so you probably want to use cmp byte ptr [infiniteStaminaEnabled],01 so you are only comparing a byte. And you only allocate 4 bytes for "rowerStaminaAddy" and "maxRowerStamina", but you set those values using a 64 bit registry (8 bytes); and that might actually be what's overriding the flag if CE packs all those in the same place. But you should have gotten a hit for "see what writes to this address" when debugging.
Using # is the same as using (int), it's more about the format than the size. But yeah, if the value isn't over 9 there is no reason for it since (int) 1 is equal to 0x1 and so on up to 9. And using a general purpose registry is fine like this, but they need to use the right size (i.e. edx for 32 bits, not rdx which is 64 bits). But since the original code uses xmm8, I too would use that instead of pushing and popping one.