MasterGH Опубликовано 5 июня, 2011 Поделиться Опубликовано 5 июня, 2011 В справке CE 6.0 в разделе Script engine есть такая функция:generateAPIHookScript (address, addresstojumpto, addresstogetnewcalladdress OPT) : Generates an auto assembler script which will hook the given address when executedЕё задача перехватить выполнение кода, сделать всё необходимое, например, сделать чит-код; сохранить параметры в файлы и т.п. ... и в конце-концов вернуть выполнения кода в прежнее русло. Данный метод работает эффективнее отладки. Т.к. отладка затрачивает больше ресурсов работы процессора чем способ generateAPIHookScript.Этой функцией можно воспользоваться следующим образом (пример Дакрк Байта):globalalloc(MyPeekMessageHook,2048) globalAlloc(OriginalPeekMessageA,4) label(placeyourbphereifyouliketoseetheresults) registersymbol(placeyourbphereifyouliketoseetheresults) MyPeekMessageHook: //do whatever you want in your hook //I could just do jmp [OriginalPeekMessageA] if I wanted //but this way the parameters are more easily readable for me //and lets me mess with the results push ebp mov ebp,esp //ebp=old ebp //ebp+4=old return address //ebp+8=first parameter //ebp+c=second //ebp+10=third //ebp+14=fourth //ebp+18=fifth push [ebp+18] push [ebp+14] push [ebp+10] push [ebp+c] push [ebp+8] call [OriginalPeekMessageA] placeyourbphereifyouliketoseetheresults: //eax now contains the return value. //and this space gives you room to tamper with the results pop ebp//restore ebp to what it was ret 14 //undo the pushed parameters and return ]] ) myhookscript=generateAPIHookScript("PeekMessageA", "MyPeekMessageHook", "OriginalPeekMessageA"); if (myhookscript~=nil) then autoAssemble(myhookscript) endautoAssemble([[Там где вы увидите двойные квадратные скобки - это автоассемблерный код. Измените его как вам потребуется.Из примера вы можете видеть, что PeekMessageA перекрывается на MyPeekMessageHook с выполнением OriginalPeekMessageA. Ещё раз обращу внимание, что в данном случае generateAPIHookScript очевидно будет эффективнее работать чем с debug_setBreakpoint(см. тутор2).Ещё пример:globalalloc(MyMessageBoxHook,2048) alloc(message,11) alloc(caption,3) globalalloc(OriginalMessageBoxA,4) message: db 'blablablaa',0 caption: db 'XD',0 MyMessageBoxHook: push ebp mov ebp,esp push #0 push caption push message push #0 call [OriginalMessageBoxA] pop ebp ret 10 ]] ) myhookscript=generateAPIHookScript("MessageBoxA", "MyMessageBoxHook", "OriginalMessageBoxA"); if (myhookscript~=nil) then autoAssemble(myhookscript) endautoAssemble([[ Ссылка на комментарий Поделиться на другие сайты Поделиться
Рекомендуемые сообщения