#include "targetver.h" #include <windows.h> #include <stdlib.h> #include <stdio.h> #include "..\..\include\patcher_x86_commented.hpp" #include "..\..\include\HotA\HoMM3.h" #include "..\..\include\era.h" Patcher * globalPatcher; PatcherInstance *patcher; int __stdcall StrikeAndReturn (LoHook* h, HookContext* c) { int unit = c->eax; if (advanced_properties[unit].strike_n_ret) { if(o_CreatureInfo[unit].flags &1) c->return_address = 0x75E08B; else c->return_address = 0x75E0BB; } else { c->return_address = 0x75E06A; } return NO_EXEC_DEFAULT; } int __stdcall StrikeAndReturnButton (LoHook* h, HookContext* c) { int unit = *(int*)(c->ebp-4); if(advanced_properties[unit].strike_n_ret) { c->return_address = 0x762969; } else { c->return_address = 0x762955; } return NO_EXEC_DEFAULT; } void __stdcall PatchIt (PEvent e) { patcher->WriteLoHook(0x75E059,(void*)StrikeAndReturn); patcher->WriteLoHook(0x762940,(void*)StrikeAndReturnButton); } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { if (ul_reason_for_call == DLL_PROCESS_ATTACH) { globalPatcher = GetPatcher(); patcher = globalPatcher->CreateInstance("h2sw_creatures"); ConnectEra(); RegisterHandler(PatchIt,"OnAfterCreateWindow"); } return TRUE; }