Пытаюсь перехватить функцию. Судя по этой строчке: bool __userpurge sub_5AF810@<al>(int a1@<ecx>, int a2, signed int a3, int a4, int a5) функция эта thiscall. Во всяком случае мне нужно было перехватить еще несколько связанных функций и все они успешно перехватывались способом ниже: Код (C): std::shared_ptr<PLH::VEHHook> PLHVEH_5AF810; typedef bool(__thiscall* sub_5AF810_t)(void* Ecx, int a2, int a3, BYTE* a4, int a5); sub_5AF810_t real_sub_5AF810; bool __fastcall new_sub_5AF810(void* Ecx, void* Edx, int a2, int a3, BYTE* a4, int a5) { Logger_5AF810.AddEntryTimeEvent(L"5AF810"); auto po = PLHVEH_5AF810->GetProtectionObject(); return real_sub_5AF810(Ecx, a2, a3, a4, a5); } Можно объявить функцию как naked и перейти туда простым джампом, но нужен способ, который не затрагивает код и желательно бы ограничиться этой самой библиотекой без самопальных наворотов, ибо хуков итак достаточно. Как найти правильный calling convention и параметры? Извиняюсь что весь код в куче, не вижу элементов форматирования. Код (Text): .text:005AF810 ; =============== S U B R O U T I N E ======================================= .text:005AF810 .text:005AF810 .text:005AF810 sub_5AF810 proc near ; CODE XREF: sub_5AF990+9Dp .text:005AF810 ; sub_5AFA60+31p ... .text:005AF810 .text:005AF810 var_7810 = dword ptr -7810h .text:005AF810 var_780C = dword ptr -780Ch .text:005AF810 var_7804 = dword ptr -7804h .text:005AF810 var_7800 = dword ptr -7800h .text:005AF810 var_77FC = byte ptr -77FCh .text:005AF810 var_3BFC = dword ptr -3BFCh .text:005AF810 var_3BF8 = byte ptr -3BF8h .text:005AF810 var_3BF7 = byte ptr -3BF7h .text:005AF810 var_4 = dword ptr -4 .text:005AF810 arg_4 = dword ptr 8 .text:005AF810 arg_8 = dword ptr 0Ch .text:005AF810 arg_C = dword ptr 10h .text:005AF810 .text:005AF810 mov eax, 7810h .text:005AF815 call __alloca_probe .text:005AF81A mov eax, dword_7445AC .text:005AF81F xor eax, esp .text:005AF821 mov [esp+7810h+var_4], eax .text:005AF828 cmp dword ptr [ecx+8], 0 .text:005AF82C push ebx .text:005AF82D mov ebx, [esp+7814h+arg_8] .text:005AF834 mov [esp+7814h+var_7810], ecx .text:005AF838 jnz short loc_5AF854 .text:005AF83A xor al, al .text:005AF83C pop ebx .text:005AF83D mov ecx, [esp+7810h+var_4] .text:005AF844 xor ecx, esp .text:005AF846 call sub_59E6F0 .text:005AF84B add esp, 7810h .text:005AF851 retn 0Ch .text:005AF854 ; --------------------------------------------------------------------------- .text:005AF854 .text:005AF854 loc_5AF854: ; CODE XREF: sub_5AF810+28j .text:005AF854 push edi .text:005AF855 mov edi, [esp+7818h+arg_4] .text:005AF85C cmp edi, 3BFCh .text:005AF862 jb short loc_5AF86B .text:005AF864 xor al, al .text:005AF866 jmp loc_5AF96F .text:005AF86B ; --------------------------------------------------------------------------- .text:005AF86B .text:005AF86B loc_5AF86B: ; CODE XREF: sub_5AF810+52j .text:005AF86B push ebp .text:005AF86C push esi .text:005AF86D push 3C00h .text:005AF872 lea eax, [esp+7824h+var_780C+1] .text:005AF876 push 0 .text:005AF878 push eax .text:005AF879 mov byte ptr [esp+782Ch+var_780C], 0 .text:005AF87E call sub_59E292 .text:005AF883 add esp, 0Ch .text:005AF886 xor ebp, ebp .text:005AF888 test edi, edi .text:005AF88A jle short loc_5AF898 .text:005AF88C push edi .text:005AF88D push ebx .text:005AF88E call sub_5B14D4 .text:005AF893 add esp, 8 .text:005AF896 mov ebp, eax .text:005AF898 .text:005AF898 loc_5AF898: ; CODE XREF: sub_5AF810+7Aj .text:005AF898 test edi, edi .text:005AF89A mov eax, ebp .text:005AF89C mov [esp+7814h+var_7800], eax .text:005AF8A0 mov esi, 4 .text:005AF8A5 jle short loc_5AF8BD .text:005AF8A7 push edi .text:005AF8A8 lea ecx, [esp+7818h+var_77FC] .text:005AF8AC push ebx .text:005AF8AD push ecx .text:005AF8AE call sub_59E152 .text:005AF8B3 mov eax, [esp+7820h+var_7800] .text:005AF8B7 add esp, 0Ch .text:005AF8BA lea esi, [edi+4] .text:005AF8BD .text:005AF8BD loc_5AF8BD: ; CODE XREF: sub_5AF810+95j .text:005AF8BD xor bl, bl .text:005AF8BF cmp eax, ebp .text:005AF8C1 jz short loc_5AF939 .text:005AF8C3 lea edx, [eax+2000000h] .text:005AF8C9 cmp edx, ebp .text:005AF8CB jnz short loc_5AF8D1 .text:005AF8CD mov bl, 1 .text:005AF8CF jmp short loc_5AF8DD .text:005AF8D1 ; --------------------------------------------------------------------------- .text:005AF8D1 .text:005AF8D1 loc_5AF8D1: ; CODE XREF: sub_5AF810+BBj .text:005AF8D1 add ebp, 2000000h .text:005AF8D7 cmp eax, ebp .text:005AF8D9 jnz short loc_5AF8DD .text:005AF8DB mov bl, 2 .text:005AF8DD .text:005AF8DD loc_5AF8DD: ; CODE XREF: sub_5AF810+BFj .text:005AF8DD ; sub_5AF810+C9j .text:005AF8DD push 3C00h .text:005AF8E2 lea eax, [esp+7818h+var_3BFC+1] .text:005AF8E9 push 0 .text:005AF8EB push eax .text:005AF8EC call sub_59E292 .text:005AF8F1 mov ecx, [esp+7820h+arg_C] .text:005AF8F8 push esi .text:005AF8F9 lea edx, [esp+7824h+var_7800] .text:005AF8FD push edx .text:005AF8FE lea eax, [esp+7828h+var_3BF7] .text:005AF905 push eax .text:005AF906 mov [esp+3C30h], ecx .text:005AF90D mov [esp+782Ch+var_3BF8], bl .text:005AF914 call sub_59E152 .text:005AF919 add esi, 5 .text:005AF91C push esi .text:005AF91D lea ecx, [esp+7830h+var_3BFC] .text:005AF924 push ecx .text:005AF925 lea edx, [esp+7834h+var_7800] .text:005AF929 push edx .text:005AF92A call sub_59E152 .text:005AF92F add esp, 24h .text:005AF932 mov edi, 10h .text:005AF937 jmp short loc_5AF940 .text:005AF939 ; --------------------------------------------------------------------------- .text:005AF939 .text:005AF939 loc_5AF939: ; CODE XREF: sub_5AF810+B1j .text:005AF939 mov edi, [esp+7814h+arg_C] .text:005AF940 .text:005AF940 loc_5AF940: ; CODE XREF: sub_5AF810+127j .text:005AF940 mov ecx, dword_B56FE0 .text:005AF946 push esi .text:005AF947 lea eax, [esp+7818h+var_7800] .text:005AF94B push eax .text:005AF94C call sub_5B0D43 .text:005AF951 mov eax, [esp+7814h+var_7804] .text:005AF955 mov edx, [eax+8] .text:005AF958 add [eax+18h], esi .text:005AF95B add dword ptr [eax+1Ch], 1 .text:005AF95F lea ecx, [esp+7814h+var_7800] .text:005AF963 push ecx .text:005AF964 push esi .text:005AF965 push edi .text:005AF966 call edx .text:005AF968 test al, al .text:005AF96A pop esi .text:005AF96B setnz al .text:005AF96E pop ebp .text:005AF96F .text:005AF96F loc_5AF96F: ; CODE XREF: sub_5AF810+56j .text:005AF96F mov ecx, [esp+7818h+var_4] .text:005AF976 pop edi .text:005AF977 pop ebx .text:005AF978 xor ecx, esp .text:005AF97A call sub_59E6F0 .text:005AF97F add esp, 7810h .text:005AF985 retn 0Ch .text:005AF985 sub_5AF810 endp HexRays: Код (C): bool __userpurge sub_5AF810@<al>(int a1@<ecx>, int a2, signed int a3, int a4, int a5) { bool result; // al@2 int v6; // ebp@5 int v7; // eax@7 int v8; // esi@7 char v9; // bl@9 int v10; // edi@14 int v11; // eax@16 int (__cdecl *v12)(int, int, int *); // edx@16 int v13; // [sp+8h] [bp-780Ch]@5 int v14; // [sp+10h] [bp-7804h]@16 int v15; // [sp+14h] [bp-7800h]@7 char v16; // [sp+18h] [bp-77FCh]@8 int v17; // [sp+3C18h] [bp-3BFCh]@14 char v18; // [sp+3C1Ch] [bp-3BF8h]@14 char v19; // [sp+3C1Dh] [bp-3BF7h]@14 if ( *(_DWORD *)(a1 + 8) ) { if ( (unsigned int)a3 < 0x3BFC ) { sub_59E292((char *)&v13 + 1, 0, 15360); v6 = 0; if ( a3 > 0 ) v6 = sub_5B14D4(a4, a3); v7 = v6; v15 = v6; v8 = 4; if ( a3 > 0 ) { sub_59E152(&v16, a4, a3); v7 = v15; v8 = a3 + 4; } v9 = 0; if ( v7 == v6 ) { v10 = a5; } else { if ( v7 + 0x2000000 == v6 ) { v9 = 1; } else if ( v7 == v6 + 0x2000000 ) { v9 = 2; } sub_59E292((char *)&v17 + 1, 0, 15360); v17 = a5; v18 = v9; sub_59E152(&v19, &v15, v8); v8 += 5; sub_59E152(&v15, &v17, v8); v10 = 16; } sub_5B0D43(&v15, v8); v11 = v14; v12 = *(int (__cdecl **)(int, int, int *))(v14 + 8); *(_DWORD *)(v11 + 24) += v8; ++*(_DWORD *)(v11 + 28); result = (unsigned __int8)v12(v10, v8, &v15) != 0; } else { result = 0; } } else { result = 0; } return result; } Вызывается во многих местах, вот пример одной функции из которой идет вызов: Код (Text): .text:005AFB30 ; =============== S U B R O U T I N E ======================================= .text:005AFB72 mov dword_B56FBC, 1 .text:005AFB7C jnz short loc_5AFB88 .text:005AFB7E mov dword_B56FC0, 2 .text:005AFB88 .text:005AFB88 loc_5AFB88: ; CODE XREF: sub_5AFB30+4Cj .text:005AFB88 push offset dword_B56FEC .text:005AFB8D push 39h .text:005AFB8F push 9 .text:005AFB91 mov ecx, esi .text:005AFB93 call sub_5AF810 .text:005AFB98 test al, al .text:005AFB9A push 0 .text:005AFB9C mov ecx, esi