Code:
// dllmain.cpp : Определяет точку входа для приложения DLL.
#include "pch.h"
#include "era.h"
#include "HoMM3.h"
#include "patcher_x86.hpp"
#include <sstream>
using namespace Era;
using namespace std;
Patcher* globalPatcher;
PatcherInstance* Magic;
_int_ __stdcall OnAfterDlgHeroInfoShow(LoHook* h, HookContext* c)
{
    char buf[500];
    const char* sec_name = "Question";
    ReadStrFromIni("Text", sec_name, "ViewSpellBookOfTavernHeroes.ini", buf);
    ostringstream stream;
    stream << "IF:Q1^" << (string)buf << "^";
    ExecErmCmd(stream.str().c_str());
    if (f[1])
    {
        int _offset = *(_ptr_*)(c->ebx + 0x60); //left-right
        int DlgAdress = *(_ptr_*)(c->ebp - 0x10);
        _offset *= 4;
        int adressFinal = DlgAdress + _offset  + 0x28;
        int heroID = *(_ptr_*)adressFinal;
        _Hero_ H = *o_GameMgr->GetHero(heroID);
        H.ShowSpellBookDlg(0, 2, 0);
    }
    return EXEC_DEFAULT;
}
BOOL APIENTRY DllMain(HMODULE hModule,
    DWORD  ul_reason_for_call,
    LPVOID lpReserved
)
{
    if (ul_reason_for_call == DLL_PROCESS_ATTACH)
    {
        globalPatcher = GetPatcher();
        Magic = globalPatcher->CreateInstance("Plugins.ViewSpellBookOfTavernHeroes");
        ConnectEra();
        Magic->WriteLoHook(0x5D8187, OnAfterDlgHeroInfoShow);
    }
    return TRUE;
}