• <td id="ae6ms"><li id="ae6ms"></li></td>
  • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
  • <table id="ae6ms"></table>
  • <td id="ae6ms"></td>
    <td id="ae6ms"></td>
  • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
  • <td id="ae6ms"></td>
  • <table id="ae6ms"><li id="ae6ms"></li></table>
  • <table id="ae6ms"></table>
    西西軟件園多重安全檢測下載網站、值得信賴的軟件下載站!
    軟件
    軟件
    文章
    搜索

    首頁西西教程軟件使用 → Delphi版 關于QQ輸入控件無法Spy到句柄的實現方案可行性研究

    Delphi版 關于QQ輸入控件無法Spy到句柄的實現方案可行性研究

    前往專題相關軟件相關文章發表評論 來源:DxSoft時間:2010/2/25 23:09:55字體大?。?em class="fontsize">A-A+

    作者:得閑筆記點擊:539次評論:3次標簽: Delphi

    Borland Delphi8.0光盤版
    • 類型:編程工具大?。?i>83.1M語言:中文 評分:4.0
    • 標簽:
    立即下載

    QQ2009版本的界面,和以前的版本有個顯著的不同,就是無法通過Spy++抓到界面上某些元素的句柄了,對于這個技術的實現方案,相信好多人都有一些揣度,實現方法怎樣,有人說是應用的DirectUI技術,也有人說是用反Hook,等等一些列的說道!在這,我也說說我的一點看法!我說的一種方法不屬于以上的任何一種方法。至于如何,且聽我慢慢道來!此思路,來源于一個偶然,在聊天窗口失去焦點與獲得焦點時的一個偶然。

      聊天的時候,我們要輸入信息,首先要讓窗口獲得焦點!然后輸入框也要獲得焦點,才能輸入。那么我們可以想象一下,在Delphi中什么情況下的控件時沒有句柄的,用Delphi的同僚都知道,TGraphicControl繼承下來的控件都沒有焦點,既然如此,那么咱們就可以有一個混淆視聽的方式,寫的控件都從TGraphicControl繼承來寫,那么肯定就沒句柄的,這個Button,ScrollBar等不必體現輸入的,我相信沒有爭議,那么我實現一個編輯框Edit,也從TGraphicControl繼承來寫!這樣,別人不就無法找到這個編輯框的句柄了么?嘿嘿,此時一定會有很多人大惑不解,那么輸入呢,從TGraphicControl繼承的Edit,如何實現輸入?難道全部自己模擬消息來實現輸入?當然不是,如果這樣,那將讓工作量增大N倍而不盡然能成功!重點就在這里,這是,我們可以在內部放一個TEdit,本Edit是活動的,在鼠標點下,或者模擬獲得焦點的時候,我們將內置的Edit的Parent設置成我們從TGraphicControl繼承的Edit的Parent,也就是Edt.parent := self.parent;并且設置內置Edit的區域,然后在內置Edit.setFocus,這樣就能夠輸入了,然后當這個內置Edit失去焦點的時候,我們將內置Edit的顯示文字抓成圖片,之后,將內置edit的parent設置為nil,然后在在這個GrphicControl的Edit的對應區域繪制上我們抓取出來的那個真實Edit的圖片,這樣,內置的Edit已經不再本界面上了,從而當外部Spy++在Spy的時候,就無法找到那個Edit進而進行信息的獲取等操作了!這便是我的實現思路。那么就可以想象,QQ聊天窗口在我們要輸入信息的時候,獲得焦點了,RichEdit的parent為QQ聊天窗口,然后我們輸入信息,當信息輸入完成,我們離開了之后,將內部的RichEdit的parent設置為nil,然后再將RichEdit的畫面獲得到繪制到原來的位置上去。這樣 ,我們就無法Spy到RichEdit的句柄了。

    下面給出俺的模擬代碼:

    這個代碼中的DxEdit就是了,大家可用Spy查一下,肯定是查不到句柄的說!呵呵!

    不過這個只是實現了一個簡單的模擬而已,如果要完全達到QQ的那個效果,還有許多其他工作要做,這里僅提供一個實現的思路參考

    下載

     

    {不得閑2010-2-25}
    unit Unit4;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls;

    type
    TDxEdit = class(TGraphicControl)
    private
    edt: TEdit;
    edtbndrect: TRect;
    bmp: TBitmap;
    OldEdtwndproc: TWndMethod;
    protected
    procedure Paint;override;
    procedure HookedtWndProc(var msg: TMessage);
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
    X, Y: Integer); override;
    procedure SetParent(AParent: TWinControl);override;
    public
    constructor Create(AOwner: TComponent);
    procedure BeforeDestruction;override;
    destructor Destroy;override;
    end;
    TForm4 = class(TForm)
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    medt,edt2: TDxEdit;
    end;

    var
    Form4: TForm4;
    implementation

    var
    edt: TEdit;
    type
    TWControl = class(TWinControl) end;

    procedure GetControlBitmap(Control: TWinControl;bmp: TBitmap);
    var
    ControlWidth,ControlHeight: integer;
    ControlDc,hCaptureDC: HDC;
    begin
    ControlWidth := Control.ClientWidth;
    ControlHeight := Control.ClientHeight;
    ControlDc := GetDC(Control.Handle);
    hCaptureDC := CreateCompatibleDC(ControlDc);
    bmp.Handle :=CreateCompatibleBitmap(ControlDc,ControlWidth,ControlHeight);
    SelectObject(hCaptureDC,bmp.Handle);

    BitBlt(hCaptureDC,0,0,ControlWidth,ControlHeight,ControlDc,0,0,SRCCOPY);
    ReleaseDC(GetDesktopWindow,ControlDc);
    DeleteDC(hCaptureDC);
    end;
    {$R *.dfm}

    procedure TForm4.FormCreate(Sender: TObject);
    begin
    medt := TDxEdit.Create(self);
    medt.Parent := self;

    edt2 := TDxEdit.Create(self);
    edt2.Parent := self;
    edt2.Left := 150;
    edt2.Top := 10;
    end;

    { TDxEdit }

    procedure TDxEdit.BeforeDestruction;
    begin

    inherited;
    end;

    constructor TDxEdit.Create(AOwner: TComponent);
    begin
    inherited;
    edtbndrect := Rect(0,0,0,0);
    bmp := TBitmap.Create;
    Cursor := crIBeam;
    Height := 21;
    Width := 121;
    end;

    destructor TDxEdit.Destroy;
    begin
    inherited;
    bmp.Free;
    end;

    procedure TDxEdit.HookedtWndProc(var msg: TMessage);
    begin
    OldEdtwndproc(msg);
    case msg.Msg of
    WM_KILLFOCUS:
    begin
    GetControlBitmap(edt,bmp);
    //bmp.SaveToFile('C:\1.bmp');
    edtbndrect.Left := 2;
    edtbndrect.Top := (Height - edt.Height) div 2;
    edtbndrect.Right := edtbndrect.Left + edt.Width;
    edtbndrect.Bottom := edtbndrect.Top + edt.Height;
    edt.Parent := nil;
    end;
    end;

    end;

    procedure TDxEdit.MouseDown(Button: TMouseButton; Shift: TShiftState;
    X, Y: Integer);
    begin
    inherited;
    if Button = mbLeft then
    begin
    if edt = nil then
    begin
    edt := TEdit.Create(nil);
    OldEdtwndproc := edt.WindowProc;
    edt.WindowProc := HookedtWndProc;
    edt.BorderStyle := bsNone;
    edt.Height := 14;
    end;
    edt.Left := Left + 2;
    edt.Top := top + (Height - edt.Height) div 2;
    edt.Width := Width - 4;
    edt.Parent := self.Parent;
    edt.SetFocus;
    //edt.SelLength := 0;
    end;
    end;

    procedure TDxEdit.Paint;
    begin
    Canvas.Brush.Color := clWhite;
    Canvas.FillRect(ClientRect);
    Canvas.Brush.Color := clBlue;
    Canvas.FrameRect(ClientRect);
    //然后開始繪制文字
    if (edt <> nil) and (edt.Parent = nil) then
    begin
    //bmp := TBitmap.Create;
    //GetControlBitmap(edt);
    if edtbndrect.Left <> edtbndrect.Right then

    Canvas.CopyRect(edtbndrect,bmp.Canvas,bmp.Canvas.ClipRect);
    end;
    end;


    procedure TDxEdit.SetParent(AParent: TWinControl);
    begin
    inherited;

    end;

    initialization

    finalization

    end.

      相關評論

      閱讀本文后您有什么感想? 已有人給出評價!

      • 8 喜歡喜歡
      • 3 頂
      • 1 難過難過
      • 5 囧
      • 3 圍觀圍觀
      • 2 無聊無聊

      熱門評論

      最新評論

      發表評論 查看所有評論(3)

      昵稱:
      表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
      字數: 0/500 (您的評論需要經過審核才能顯示)
      女人让男人桶30分钟免费视频,女人张开腿让男人桶个爽,一进一出又大又粗爽视频
    • <td id="ae6ms"><li id="ae6ms"></li></td>
    • <xmp id="ae6ms"><td id="ae6ms"></td><table id="ae6ms"></table>
    • <table id="ae6ms"></table>
    • <td id="ae6ms"></td>
      <td id="ae6ms"></td>
    • <table id="ae6ms"></table><table id="ae6ms"><td id="ae6ms"></td></table>
    • <td id="ae6ms"></td>
    • <table id="ae6ms"><li id="ae6ms"></li></table>
    • <table id="ae6ms"></table>