{"id":174647,"date":"2013-03-28T23:59:04","date_gmt":"2013-03-28T19:59:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=174647"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=174647","title":{"rendered":"<span class=\"post_title\">\u041e\u0431\u0435\u0440\u0442\u043e\u0447\u043d\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430-\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0432\u0441\u0435\u043c!<br \/>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430(<a href=\"http:\/\/habrahabr.ru\/post\/172879\">\u0442\u0443\u0442<\/a>).<br \/>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u043d, \u0447\u0435\u0433\u043e \u0443\u0436 \u0433\u0440\u0435\u0445\u0430 \u0442\u0430\u0438\u0442\u044c, \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438 \u043a\u043e\u0440\u044f\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c. \u0412 1 \u0436\u0435 \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043e\u0442\u043f\u0438\u0441\u0430\u043b\u0441\u044f \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 <a href=\"http:\/\/habrahabr.ru\/users\/k_d\/\" class=\"user_link\">k_d<\/a> \u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u043e \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0435 \u043d\u0430\u0434 mhook(<a href=\"http:\/\/habrahabr.ru\/post\/147721\">MHook vs Zuma<\/a>). <br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u0435\u043d\u044f \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u0441 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u043e\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e __cdecl&#8217;\u0430 \u043d\u043e \u0438, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0434\u0430.<br \/>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u0441\u0442\u043e, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/users\/k_d\/\" class=\"user_link\">k_d<\/a>. \u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435, \u0434\u043e \u0447\u0435\u0433\u043e \u0434\u043e\u0442\u044f\u043d\u0443\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0435\u0431\u0443\u0449\u0435-\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0443\u0447\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0438 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430(\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438\u0434\u0435\u044f \u044d\u0442\u043e \u0432\u0441\u0435 \u0443\u043c\u0435\u0435\u0442. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435.)<br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.<br \/>  <a name=\"habracut\"><\/a><\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f MHook, \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/users\/k_d\/\" class=\"user_link\">k_d<\/a>, \u0441\u0440\u0435\u0434\u043d\u0435\u0432\u044b\u043f\u0440\u044f\u043c\u043b\u0435\u043d\u043d\u044b\u0435 \u0440\u0443\u043a\u0438, \u0433\u043e\u043b\u043e\u0432\u0430, \u0432\u044b\u0442\u0430\u0449\u0435\u043d\u043d\u0430\u044f \u0438\u0437-\u043f\u043e\u0434 \u0441\u0442\u043e\u043b\u0430 \u0438 \u0443\u0442\u043e\u0447\u043a\u0430, \u0441 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u0442\u044c\u0441\u044f: <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9C%D0%B5%D1%82%D0%BE%D0%B4_%D1%83%D1%82%D1%91%D0%BD%D0%BA%D0%B0\"><img decoding=\"async\" src=\"http:\/\/clip2net.com\/clip\/m189493\/1364504067-clip-42kb.jpg\" alt=\"1364504067-clip-42kb\"\/><\/a>.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u043e\u0435\u0445\u0430\u043b\u0438!<\/p>\n<p>  I) \u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b:<\/p>\n<p>  1) \u0412\u044b\u0432\u043e\u0434 \u043b\u043e\u0433\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b: <\/p>\n<pre><code class=\"cpp\">void debug_msg(const char* func_name, const char* txt,...) { \tva_list args; \tFILE *file; \tchar file_name[256]=&quot;\\0&quot;; \tstrcpy(file_name,&quot;C:\\\\VariadicDump\\\\&quot;); \tstrcat(file_name,func_name); \tstrcat(file_name,&quot;.txt&quot;); \tfopen_s(&file,file_name, &quot;a&quot;); \tva_start(args,txt); \tvfprintf(file,txt,args); \tva_end (args); \tfprintf(file, &quot;\\n&quot;); \tfclose(file); } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">debug_msg(&quot;Advanced&quot;, &quot;--%s arg list started--&quot;, funcName); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 funcName = \u00abHello, world, you read this message so many times\u00bb \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0444\u0430\u0439\u043b C:\\VariadicDump\\Advanced.txt \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<p>  <code> --Hello, world, you read this message so many times arg list started-- <\/code><\/p>\n<p>  2) \u041f\u0430\u0440\u0441 lua_State (\u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438 \u0447\u0430\u0441\u0442\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438! \u041f\u043e\u043b\u0435\u0437\u0435\u043d, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432 \u041c\u041c\u041e Runes of Magic \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0430 \u0447\u0430\u0442\u0430, \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b):<\/p>\n<pre><code class=\"cpp\">void Parse_LuaState(lua_State *L, const char *func_name) { \tint n = lua_gettop(L);    \tstd::vector&lt;const char*&gt; names; \tfor(int i = 0; i &lt; n; i++) \t{ \t\tsize_t arg2Len = 0; \t\tnames.push_back(luaL_checklstring(L, i, &arg2Len)); \t} \tstring str = &quot;&quot;; \tfor (unsigned int i=0; i&lt;names.size(); i++) \t{ \t\tstr.append(names[i]); \t\tstr.append(&quot;; &quot;); \t} \tdebug_named_msg(func_name, str.c_str()); } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">void lua_hook(lua_State *L) { Parse_LuaState(L, &quot;Lua&quot;); } <\/code><\/pre>\n<p>  \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432 *L \u0431\u044b\u043b\u043e 2 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u2014 \u0442\u0438\u043f \u0447\u0430\u0442\u0430 \u0438 \u0442\u0435\u043a\u0441\u0442(1 \u0438 \u00abhello, world, are you hate to hear it again?\u00bb). \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0437\u0430\u043f\u0438\u0448\u0435\u0442 \u0432 \u00abC:\\VariadicDump\\Lua.txt\u00bb \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<p>  <code> 1; hello, world, are you hate to hear it again? <\/code><\/p>\n<p>  3) \u041f\u0430\u0440\u0441\u0438\u043d\u0433 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430:<\/p>\n<pre><code class=\"cpp\">void parseArgs(int *ptr, int size, char* funcName) { \tdebug_msg(&quot;Advanced&quot;, &quot;--%s arg list started--&quot;, funcName); \tfor(int i=0; i*4&lt;size; i++) \t{ \t\tdebug_msg(&quot;Advanced&quot;, &quot;  |---Element %d: %d&quot;, i, ptr[i]); \t} \tdebug_msg(&quot;Advanced&quot;, &quot;--arg list finished--\\n&quot;); } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">void con_hook(Context *context) { \tint *ptr = (int*)(void*)(context-&gt;ESP+4); \tparseArgs(ptr, con_arg_amount, __FUNCTION__); } <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0440\u0430\u0441\u0447\u0435\u0442\u0430 esp + index*4 name##_arg_amount\/4 \u0440\u0430\u0437.<br \/>  \u041f\u043e-\u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u0442\u0430\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043b-\u0432\u043e \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u043b\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441\u0430\u043c\u043e\u043c\u0443 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  4) \u0410\u0434\u0440\u0435\u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"cpp\">int GetMainModuleAddress() { \tDWORD dwAddress = NULL; \tHANDLE hthSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, _getpid()); \tif (hthSnapshot)  \t{ \t\tMODULEENTRY32 me = { sizeof(me) }; \t\tif (Module32First(hthSnapshot, &me)) \t\t{ \t\t\tCloseHandle(hthSnapshot); \t\t\tdwAddress = (DWORD)me.modBaseAddr; \t\t} \t} \treturn dwAddress; } <\/code><\/pre>\n<p>  \u041d\u0438\u0447\u0435\u0433\u043e \u043e\u0441\u043e\u0431\u043e, \u043d\u0443\u0436\u0435\u043d, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0432 \u0420\u0438\u0444\u0442\u0435 \u2014 \u0442\u0430\u043c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">#define RECALC(name)\\ \tname##_Detour = (t##name)((int)name##_Detour-0x400000+rift); <\/code><\/pre>\n<p>  \u0433\u0434\u0435 name##_Detour \u2014 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f.<\/p>\n<p>  5) \u0424\u0443\u043d\u043a\u0446\u0438\u0438 attach\/detach:<\/p>\n<p>  \u041f\u0440\u043e\u0441\u0442\u0430\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438\/\u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d\u0430. \u041d\u0443\u0436\u043d\u044b \u0447\u0438\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u043b\u0430\u0437\u0438\u0442\u044c \u043f\u043e \u043a\u043e\u0434\u0443 \u0432 \u043f\u043e\u0438\u0441\u043a\u0430\u0445 DllMain \ud83d\ude42<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432 \u0441\u043f\u0438\u0441\u043a\u0435, \u043d\u043e \u043d\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432 \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0434\u0446\u0430\u0445 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0441\u0442\u044c\u044e \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0435 \u2014 unhook&#8217;er:<\/p>\n<pre><code class=\"cpp\">BOOL UnHookFunction(DWORD addr, unsigned char *lpBackup) { \tDWORD dwAddr = addr; \tif (WriteProcessMemory(GetCurrentProcess(), (LPVOID)dwAddr, lpBackup, 6, 0)) \t\treturn TRUE; \treturn FALSE; } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0441\u0442\u043e \u0438 \u0441\u043e \u0432\u043a\u0443\u0441\u043e\u043c \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043a\u043e\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u0442\u043e\u044f\u043b \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d.<\/p>\n<p>  II) \u041c\u0430\u043a\u0440\u043e\u0441\u044b<\/p>\n<p>  \u041c\u0430\u043a\u0440\u043e\u0441\u044b \u2014 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0444\u0438\u0448\u043a\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u043b\u0430 \u0441\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0440\u0430\u0431\u043e\u0447\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0434\u043e \u043d\u0435\u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e \u043c\u0430\u043b\u044b\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u0432.<\/p>\n<p>  1) RECALC:  <\/p>\n<pre><code class=\"cpp\">#define RECALC(name)\\ \tname##_Detour = (t##name)((int)name##_Detour-0x400000+rift); <\/code><\/pre>\n<p>  \u0423\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0441\u044f \u0432\u044b\u0448\u0435, \u043d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0441\u0447\u0435\u0442\u0430 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<p>  2) DETACH:   <\/p>\n<pre><code class=\"cpp\">#define DETACH(name1)\\ \tUnHookFunction((DWORD)name1##_Detour,name1##_var);\\ <\/code><\/pre>\n<p>  \u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u0432\u043e\u0441\u0441\u0442\u0430\u2026 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u043e\u0442 \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d\u0430.<\/p>\n<p>  3) ATR\/ATR_R:   <\/p>\n<pre><code class=\"cpp\">#define ATR(name)\\ \tname##_var = RegHook((long)name##_Detour, (long)(void*)name##_hook)  #define ATR_R(name)\\ \tRECALC(name)\\ \tname##_var = RegHook((long)name##_Detour, (long)(void*)name##_hook) <\/code><\/pre>\n<p>  \u0414\u0432\u0430 \u0431\u0440\u0430\u0442\u0430-\u0431\u043b\u0438\u0437\u043d\u0435\u0446\u0430 \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d\u0430. RegHook \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u0438 \u043d\u0430\u0434 Mhook, \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u043b\u0438\u0431\u043e \u0432 . \u0412 \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u0435\u0441\u0442\u044c Context \u0438 \u0447\u0435\u043c \u0437\u0430\u043a\u0443\u0441\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0431\u044b \u043d\u0435 \u0431\u0435\u0433\u0430\u0442\u044c \u0433\u043e\u043b\u044b\u0448\u043e\u043c \u043f\u043e \u043d\u0430\u0431\u0435\u0440\u0435\u0436\u043d\u043e\u0439 \u0438 \u043d\u0435 \u0437\u0432\u0430\u0442\u044c \u0435\u0436\u0438\u043a\u0430 \u0438\u0437 \u0442\u0443\u043c\u0430\u043d\u0430(\u0448\u0443\u0447\u0443, \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u043a \u0432\u0430\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442).<\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 attach();<\/p>\n<p>  4) DTR:   <\/p>\n<pre><code class=\"cpp\">#define DTR(name)\\ \tDETACH(name) <\/code><\/pre>\n<p>  \u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u043d\u0430\u0434 \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439.<br \/>  \u0421\u043f\u043e\u0440\u043d\u0430\u044f \u043d\u0430\u0434\u043e\u0431\u043d\u043e\u0441\u0442\u044c, \u043d\u043e \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u0435\u0435 \u0440\u044f\u0434\u043e\u043c \u0441 ATR ^^ (DETACH \u2014 \u0440\u0435\u043b\u0438\u043a\u0442 \u044d\u043f\u043e\u0445\u0438, \u0436\u0430\u043b\u044c \u0443\u0434\u0430\u043b\u044f\u0442\u044c). <\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 detach();<\/p>\n<p>  5) RF_O_UP_FUNC_CONTEXT:   <\/p>\n<pre><code class=\"cpp\">#define RF_O_UP_FUNC_CONTEXT(name1, adres, args)\\ \ttypedef void (__cdecl * t##name1 ) ();\\ \tt##name1 name1##_Detour = ( t##name1 ) ( adres );\\ \/*\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f*\/ \tvoid name1##_hook(Context *context);\\ \/*\u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438; \u0432\u0435\u0441\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430- \u0437\u0434\u0435\u0441\u044c*\/ \tBYTE *name1##_var;\\  \/*\u0437\u0434\u0435\u0441\u044c \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043a\u043e\u0434 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438*\/ \tint name1##_arg_amount = args;\\ \/*\u0441\u0443\u043c\u043c\u0430\u0440\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c(\u0441\u043c. \u0432\u044b\u0448\u0435)*\/ <\/code><\/pre>\n<p>  \u0421\u0430\u043c\u044b\u0439 \u0445\u0438\u0442\u0440\u043e\u0432\u044b\u0434\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u043c\u0430\u043a\u0440\u043e\u0441 \u0432 \u044d\u0442\u043e\u0439 \u0434\u0435\u0440\u0435\u0432\u043d\u0435. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u043d \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430 \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u0442 \u0442\u0440\u0430\u043c\u043f\u043b\u0438\u043d\u0430 \u0438 \u0442.\u0434.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<pre><code class=\"cpp\">RF_O_UP_FUNC_CONTEXT(con, 0x60D710, 0x8); <\/code><\/pre>\n<p>  \u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c 2 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u2014 con_Detour \u0438 con_hook, \u043f\u0440\u0438\u0432\u044f\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a \u0430\u0434\u0440\u0435\u0441\u0443 0x60D710 \u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c 2 \u0448\u0442\u0443\u043a\u0438 \u0432 \u0432\u044b\u0432\u043e\u0434\u0435.<\/p>\n<p>  III) \u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <\/p>\n<pre><code class=\"cpp\">RF_O_UP_FUNC_CONTEXT(con, 0x60D710, 0x8);  void lua_hook(Context *context) { \tint *ptr = (int*)(void*)(context-&gt;ESP+4); \/\/\u043f\u043e\u043c\u0435\u0449\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441 1 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0438\u0437 \u0441\u0442\u0435\u043a\u0430 \u0432 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c ptr \tparseArgs(ptr, con_arg_amount, __FUNCTION__); \/\/ \u043f\u0430\u0440\u0441\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u043c\u0430\u043a\u0440\u043e\u0441\u0443, 2 \u0448\u0442\u0443\u043a\u0438 - \u0447\u0443\u0436\u0438\u0445 \u043f\u043e\u0440\u0442\u0441\u0438\u0433\u0430\u0440\u043e\u0432 \u043d\u0430\u043c \u043d\u0435 \u043d\u0430\u0434\u043e! \tdebug_msg(&quot;LuaDump&quot;, &quot;%s&quot;, ptr[0]); \/\/\u0432\u044b\u0432\u043e\u0434\u0438\u043c 1 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e - \u0430 \u0432\u043e\u0442 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c.\u0414\u0430. } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b dll \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043b\u0438\u0431\u044b \u043e\u0442 lua, \u0430 \u0442\u0430\u043a\u0436\u0435 mhook + \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u043e\u0442 k_d.<\/p>\n<p>  <a href=\"http:\/\/filebeam.com\/c3c07b80cfbc809b8aa502267f041f2a\">\u0417\u0434\u0435\u0441\u044c<\/a> \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0441\u043e\u0440\u0446\u044b \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044e k_d \u0437\u0430 \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0438 \u0438\u0434\u0435\u044e!<\/p>\n<p>  \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e, \u0432\u0441\u0435\u0433\u043e \u0434\u043e\u0431\u0440\u043e\u0433\u043e! \u0418 \u0434\u0430 \u0432\u043e\u0441\u0442\u043e\u0440\u0436\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0443\u0442\u043e\u0447\u043a\u0430! \u041a\u0440\u044f!    \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/174647\/\"> http:\/\/habrahabr.ru\/post\/174647\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0432\u0441\u0435\u043c!<br \/>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043b \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430(<a href=\"http:\/\/habrahabr.ru\/post\/172879\">\u0442\u0443\u0442<\/a>).<br \/>  \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043e\u043d, \u0447\u0435\u0433\u043e \u0443\u0436 \u0433\u0440\u0435\u0445\u0430 \u0442\u0430\u0438\u0442\u044c, \u0433\u0440\u043e\u043c\u043e\u0437\u0434\u043a\u0438\u043c \u0438 \u043a\u043e\u0440\u044f\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u043c. \u0412 1 \u0436\u0435 \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043e\u0442\u043f\u0438\u0441\u0430\u043b\u0441\u044f \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 <a href=\"http:\/\/habrahabr.ru\/users\/k_d\/\" class=\"user_link\">k_d<\/a> \u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u043b \u043e \u0441\u0432\u043e\u0435\u0439 \u043e\u0431\u0435\u0440\u0442\u043a\u0435 \u043d\u0430\u0434 mhook(<a href=\"http:\/\/habrahabr.ru\/post\/147721\">MHook vs Zuma<\/a>). <br \/>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u0435\u043d\u044f \u0437\u0430\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043e\u0432\u0430\u043b\u0430 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u0441 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u043e\u043c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e __cdecl&#8217;\u0430 \u043d\u043e \u0438, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0434\u0430.<br \/>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c \u0438 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u043b\u044f \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0440\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u043e\u0432, \u043d\u0430\u0447\u0438\u0441\u0442\u043e, \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0442 <a href=\"http:\/\/habrahabr.ru\/users\/k_d\/\" class=\"user_link\">k_d<\/a>. \u0422\u0435\u043a\u0443\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0443\u043c\u0435\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435, \u0434\u043e \u0447\u0435\u0433\u043e \u0434\u043e\u0442\u044f\u043d\u0443\u0442\u0441\u044f \u0437\u0430\u0433\u0440\u0435\u0431\u0443\u0449\u0435-\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0440\u0443\u0447\u043a\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430 \u0438 \u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0441\u0442\u0435\u043a\u0430(\u043f\u043e \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u043c\u0435\u0440\u0435, \u043f\u043e\u0442\u0435\u043d\u0446\u0438\u0430\u043b\u044c\u043d\u043e \u0438\u0434\u0435\u044f \u044d\u0442\u043e \u0432\u0441\u0435 \u0443\u043c\u0435\u0435\u0442. \u041d\u0430\u0432\u0435\u0440\u043d\u043e\u0435.)<br \/>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e \u0412\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-174647","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/174647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=174647"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/174647\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=174647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=174647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=174647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}