Search code examples
c++cwindowsdll-injection

how can we Hijack DLL to lock all directories in windows to verify


I mean when we double click a directory,in requests us to verify.I think it can be done by dll-injection.Hope can give some ideas or tutorial.Thanks


Solution

  • Hijack DLL is not required. It use Window Message Hook. At the first, create DLL that call SetWindowsHookEx.

    hHookMsg = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MsgProc, hInstance, 0); 
    

    For example, called install_hook, And MsgProc here

    LRESULT CALLBACK MsgProc(INT nCode, WPARAM wp, LPARAM lp) {
      CHAR className[256];
      MSG *pmsg;
      LVHITTESTINFO htif;
      POINT pt;
    
      pmsg = (MSG*)lp;
      GetClassName(pmsg->hwnd, className, sizeof(className));
      if (!strcmp(className, "SysListView32")) {
        if (pmsg->message == WM_LBUTTONDBLCLK) {
          GetCursorPos((LPPOINT)&pt);
          htif.pt = pt;
          ScreenToClient(pmsg->hwnd, &htif.pt);
          SendMessage(pmsg->hwnd, LVM_HITTEST, 0, (LPARAM)&htif);
          if ((htif.flags & LVHT_ONITEM) != 0) {
              // you can write action here
          }
        }
      }
      return CallNextHookEx( hHookMesg, nCode, wp, lp );
    }
    

    And create EXE that call this install_hook.