Results 1 to 1 of 1

Thread: Windows Hooking

  1. #1
    Vitrix Maggot
    Vitrix Maggot is offline
    Member-in-training Vitrix Maggot's Avatar
    Join Date
    2013 Apr
    Location
    Brasil
    Posts
    58
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    43
    Thanked in
    24 Posts
    Rep Power
    0

    Windows Hooking

    Introdução
    Olá a todos, hoje vou tentar ensinar um pouco do que sei a respeito de Windows Hooking, tentarei ilustrar todos os procedimentos de um hook global e um hook local.Mas qual é a diferença de destes dois tipos:

    Hello everyone, today I will try to teach a bit of what I know about Windows Hooking, try to illustrate all the procedures of a global hook and hook local.Mas what is the difference of these two types:

    Local Hook:
    Este é o tipo de hook que só afeta a memória do módulo, ou seja, o programa e seus módulos não poderão usar determinadas funções, é este método o mais usado com os Anti-Hacks de hoje em dia...Ele baseia-se em pegar o local do código( GetProcAddress ) e modificar seus bytes para um JMP até a nova função( Aquela que será acionada quando alguém chamar a função hookada ), deste modo, quando o programa chama a função (CALL) ela se desvia(JMP) para a função hookada que retorna para o programa(RETN).Vejamos o esquema:

    This is the kind of hook that only affects the memory module, ie, the program and its modules can not use certain functions, this method is the most used with the Anti-Hacks today ... It is based take place in the code (GetProcAddress) and modify your bytes for a JMP to the new function (one that is triggered when someone calls the function hookada), thus when the program calls the function (cALL) it bends (JMP ) for hookada function that returns to the program (RETN). Consider the diagram:



    Global Hook:
    Esta se trata de usar a função SetWindowsHookEx() e adicionar uma função entre a chamada de um programa e o seu retorno, esta pode estar ou em uma thread ou em todas(todo o computador) porém esta nem sempre tem haver com funções, pode ser usada para muito além disso, vejamos o seguinte esquema(usaremos a hook neste exemplo que recebe as mensagens do programa):

    This it comes to using the function SetWindowsHookEx () and add a function call between a program and its return, or it may be in a thread or all (any computer) but this does not always have to do with functions, can be used for much beyond that, we see the following scheme (in this example we will use the hook that receives messages from the program):



    Local Hook

    Agora vamos entrar com a ação de tudo, vamos começar com a local hook pelo simples motivo de que já havia começado com esta na parte de cima, vamos criar um programa simples que procure pela função que desejamos e a modifique, vejamos como fica:

    Now let's get to the action of all, let's start with a local hook for the simple reason that he had started with this at the top, let's create a simple program to look for the function you wish to change and let's see how it looks:

    Delphi code



    Funcionou perfeitamente , qualquer dúvida sobre local hook me avisem...

    Global Hook

    Este é um modo mais fácil de usar as hooks pois não precisa de tanta teoria como no outro, vamos apenas fazer nossa função de CALLBACK e adicionar o hook (SetWindowsHookEx), nada de mais...Farei em delphi também mas caso queiram que eu migre para qualquer outra linguagem me avisem que eu farei assim que possível:

    This is an easier way to use the hooks they do not need so much theory as the other, let's just do our CALLBACK function and add the hook (SetWindowsHookEx), nothing more ... I will also in delphi but if I want to migrate to any other language let me know I will do as soon as possible:

    program Project2;

    {$APPTYPE CONSOLE}

    uses
    SysUtils, Windows, Messages;

    var
    str : string;
    CurrentHook : HHOOK;
    Label
    Inicio;
    function KeyBoardHook(code: integer; wParam: word; lParam: longword): longword; stdcall;
    begin
    if code<0 then begin //if code is <0 your keyboard hook should always run CallNextHookEx instantly and
    KeyBoardHook:=CallNextHookEx(CurrentHook,code,wPar am,lparam); //then return the value from it.
    Exit;
    end;
    if (lParam and KF_UP)=0 then sysutils.beep; //if the key is being pressed, not releases, BEEP!
    CallNextHookEx(CurrentHook,code,wParam,lparam); //call the next hook proc if there is one
    KeyBoardHook:=0; //if KeyBoardHook returns a non-zero value, the window that should get
    //the keyboard message doesnt get it.
    Exit;
    end;

    begin
    WriteLn('Pressione uma tecla para começar a hook');
    ReadLn(str);
    while str <> 'Exit' do begin
    CurrentHook:=setwindowshookex(WH_KEYBOARD,@KeyBoar dHook,0,0);
    WriteLn('Pronto.Arrumamos a hook');
    ReadLn(str);
    end;
    { TODO -oUser -cConsole Main : Insert code here }
    end.
    I admire most other programmers not paid any dick!!

    Admiro outros Programadores mais nao pago pau pra nenhum !!


    Skype: Vitor Monteiro

Similar Threads

  1. [C++] Beginner's Guide to Hooking
    By Dwar in forum Programming Tutorials
    Replies: 4
    Last Post: 2017-08-11, 12:25 AM
  2. [C++] Api hooking Technique
    By Dwar in forum C/C++
    Replies: 3
    Last Post: 2013-05-30, 08:42 PM
  3. [C++] DirectX9.0 Hooking via Detours
    By Dwar in forum D3D Programming
    Replies: 1
    Last Post: 2010-11-29, 04:14 PM
  4. [Asm] IAT Hooking
    By Dwar in forum Programming Tutorials
    Replies: 1
    Last Post: 2010-11-29, 04:12 PM
  5. Function Hooking, Video Tutorial
    By Dwar in forum Programming Tutorials
    Replies: 1
    Last Post: 2010-11-29, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •