SunBeam wrote: ↑Tue Oct 09, 2018 9:17 am
Ah, yes. That pointer you have in the table in red changes values. For example, if you enter map and are far away from the Adrestia (say, mid-map) points to a certain base; once you get close to the ship, pointer changes. So I don't know if keeping the script using this pointer on may crash your ass in transitions. A suggestion would be to use testing for NULLs. I kinda got used to do this, even when I know for certain they can't be NULL
Just put a "test r64,r64/je (if NULL)" where due
- test reg,reg can prevent some errors inside the script, but doesn't helps when you freeze a pointer fetched by the script.
e.g.
1. the script fetch a pointer of health, 0x14832000 and saved it to "pHealth" when the game reads it in-game.
2. you fast travel, the game relocate the health from 0x14832000 to 0x12800000.
3. the game reaches where the health fetching script hook to and change the pointer to 0x12800000.
if you freeze the pointer, errors could happenes between 2. and 3. i.e.:
CE is still freezeing the value of 0x14832000 when the game has change the health address to 0x12800000, it's using 0x14832000 for some other purpose already, and the game hasn't reach the hook that would update the address from 0x14832000 to 0x12800000 yet.
now, add null testing here doesn't do much, as the freezing process is done by CE, not the script.
- if if happens inside the script:
test null can prevent most error, but both the ship health script and ship stamina script doesn't deal with the "pointer fetched by the script" directly, instead it just use them for compare. if the pointer doesn't match, the script would just skip the manipulation.
so, even if the pointer is null after fast-travel on loading, at most it would just fail the compare and jump back to the game codes, as the script won't try to read the value of the address the pointer point to, thus nothing should happens even if the address is not a proper pointer.
using the examples above:
let say the game reaches the inf health script between 2. and 3., the script would try to compare with the value 0x14832000 or 0x12800000, not the address pointed to by 0x14832000 or 0x12800000. so, even if it's 0x0, the script will not read from this null pointer.
- using test null is not the most secure method to ensure a proper pointer. more than once I have to use isbadreadptr to make sure I'm dealing with the right address. because even if it's not null, it still doesn't mean it's a proper address...
- now, my thought about the crash, could be that there are some typos that mess up the jumping back from the script to the game code, or the game has some jmp that would jump to the exact place where my injection code uses, but I fail to recognise. ....that's the downside for relying CE to locate a code cave and prepare the jmp in 14 bytes manually. using a static code cave is a better idea in this sense.
anyway, I still haven't check the codes yet. maybe it's just the game problem (e.g., the alt-tab out of fullscreen.)... again, I'll have a look next time I play the game...