Skip to content
#15
Auto-translated
And I'll add a few words about the errors in the program:
1) The Hook variable in the CallNextHookEx function is likely incorrect (undefined). I don't think this is a critical error.
2) The new function that replaces IsIconic is not reentrant, i.e., if you start calling it from two threads at the same time, it will cause problems (but Heroes III won't do that). For other programs, you need to come up with something to synchronize (using, for example, InterlockedExchange).
3) The injection method used is also not ideal - for Heroes, you could have made a launcher (and there would be no need to mess around with DLLs and hooks). But then the program would not be universal, and it would not be possible to modify it so that, for example, it could launch Starcraft (because it is launched by a loader).
4) The lack of comments speaks for itself. However, if anyone asks anything, I will answer (if I don't disappear from the forum).
5) The speed of the program could be increased if, instead of ReadProcessMemory and WriteProcessMemory, you used reading and writing memory "directly," after first opening access using VirtualProtect.
6) Opening the process with PROCESS_ALL_ACCESS rights is also a mistake; it won't always work if the user has limited rights.
7) I'm even afraid to imagine how it will work under Windows Vista :eek:. However, it's probably Microsoft's problem and the guy who's in charge of Vista.:D

Statistics

Welcome our newest member: den