riquems / tak-enhanced

9 stars 0 forks source link

What to do if Kingdoms Enhanced doesn't work? :V #46

Closed riquems closed 8 months ago

riquems commented 1 year ago

"regular game of version 4.1bb is working just fine, same with NoCD .exe - but no matter what i am trying Enhanced 1.2 cannot start the game - it finds everything it need, but when i click "start" it just disappears... Tried compatibility modes, administrator's run, moving it to another disk, installing-starting with antivirus off, don't even know what else to try"

— BlackNyasher in 09/04/2023

riquems commented 1 year ago

After some investigation I found that there was an error in our memory write process, in file MemoryHandler.hpp line 36 we had:

VirtualProtectEx(hProcess, (LPVOID)targetAddress, sizeof(value), oldProtect, nullptr);

Which is meant to revert the unprotection we did to the memory section we just wrote, we both were having errors, but only his game crashed:

image (I added some logs to the function)

He couldn't apply any change with this error without crashing his game.

According to Stackoverflow and MSDN docs, passing null to the last argument will make the function error (I thought I could do that since I didn't want to save the previous value anywhere).

Welp, just documenting it and I'll fix it so it's coming the next release.