Thread: IE hook

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    IE hook

    I want to make an IE hook, that will silently block some sites.

    C++, Win32, Dev-C++

  2. #2
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    I've made a few of those (doesn't really "hook" though).

    Code:
    #define WIN32_LEAN_AND_MEAN
    #define MAX_STRING 1000
    #include <windows.h>
    #include <imm.h>
    
    char tempString[MAX_STRING];
    int tempNumber;
    bool tee = true;
    int i;
    
    bool inline CheckItOut(HWND hwnd)
    {
      HWND wND = FindWindowEx(
                   FindWindowEx(
                     FindWindowEx( 
                       FindWindowEx( 
                         FindWindowEx( 
                         hwnd,
                         0,
                         "WorkerW",
                         0),
                       0,
                       "ReBarWindow32",
                       0),
                     0,
                     "ComboBoxEx32",
                     0),
                   0,
                   "ComboBox",
                   0),
                 0,
                 "Edit",
                 0);
    
      ZeroMemory(&tempString, sizeof(tempString));
      SendMessage(wND,WM_GETTEXT,MAX_STRING,(LPARAM)tempString);
      for(i = 0; i < strlen(tempString); i++){
      if((tempString[i] == 'b') || (tempString[i] == 'B')){
      if((tempString[i+1] == 'u') || (tempString[i+1] == 'U')){
      if((tempString[i+2] == 'd') || (tempString[i+2] == 'D')){
      tempString[i+1] = 'o';
      tempString[i+2] = 'o';
      tempString[i+3] = 'b';
      tempString[i+4] = ' ';
      SendMessage(wND,WM_SETTEXT,0,(LPARAM)tempString);
      SetFocus(wND);
      SendMessage(wND,WM_IME_KEYDOWN,VK_RETURN,0);
      Sleep(50);
      SendMessage(wND,WM_IME_KEYUP,VK_RETURN,0);
      return true;   } } }   }
      return false;
    }
    
    int inline NumberChildren(HWND);
    
    BOOL CALLBACK inline xEnumChildProc( HWND hwnd, LPARAM lParam )
    {
      ZeroMemory(&tempString, sizeof(tempString));
      GetWindowText(hwnd, tempString, MAX_STRING);
      tempNumber = strlen(tempString);
      if((tempString[tempNumber-29] == '-') && (tempString[tempNumber-1] == 'r'))
      CheckItOut(hwnd);
      int* count = (int*)lParam;
      (*count)++;
      return TRUE;
    }
    
    int inline NumberChildren(HWND Xhwnd)
    {
      int count = 0;
      EnumChildWindows(Xhwnd, xEnumChildProc, (LPARAM)&count);
      return count;
    }
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    {
      for(;;)
      {
        NumberChildren(HWND_DESKTOP);
        if(GetAsyncKeyState(VK_F6) && GetAsyncKeyState(VK_F12))
        break;
        Sleep(50);
      }
    
      Beep(2000,150);
      Beep(1800,150);
      Beep(2000,150);
      Beep(1800,150);
      Sleep(100);
      Beep(2200,100);
      Sleep(50);
      Beep(2200,100);
      Sleep(50);
      Beep(2200,100);
    
      return 0;
    }

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Wow... this is nice!

  4. #4
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    Nice maybe - but not good enough.

    I made it too keep my brother from downloading a certain game. He would have thought it was
    the site, and never suspected any thing if it wasn’t for the fact that the address bar "magically
    changed on it’s own".

  5. #5
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Actually it doesn't block the site if you go there with an Explorer window.

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I want the program to monitor IE (including Explorer window) and Firefox windows and if a certain domain (or IP address) is accessed, forward to another web page.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Weird Hook Problem.
    By Mastadex in forum Windows Programming
    Replies: 0
    Last Post: 06-22-2006, 12:01 PM
  2. Window Hook
    By paul_uk in forum Windows Programming
    Replies: 5
    Last Post: 11-28-2004, 10:56 AM
  3. Global hook only works on one window?
    By CornedBee in forum Windows Programming
    Replies: 5
    Last Post: 01-19-2004, 12:25 PM
  4. Hook problem
    By mkyong in forum Windows Programming
    Replies: 1
    Last Post: 02-09-2003, 06:17 AM