修改已有的应用程序

FindControl
函数可以通过句柄得到TwinControl类
FindVclControl
函数可以通过绝对坐标得到TWinControl类
FindVclControl内部还是调用了FindControl 函数,

使用这几个函数就可以修改别人的程序类,哈哈。
但是他们有使用的限制
1、只能是Delphi或bcb程序
2、在同一个进程中,别人的程序,不同进程怎么办呢,当然了进程注入。
3、在注入的Dll中使用系统FindControl只能返回nil,原因在FindControl内部 
 检查是否同一个进程
  if (Handle <> 0) and (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
     (OwningProcess = GetCurrentProcessId) then
  begin    if GlobalFindAtom(PChar(ControlAtomString)) = ControlAtom then
      Result := Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)))
    else
      Result := ObjectFromHWnd(Handle);
  end;

ControlAtomString的形成 , ControlAtomString := Format('ControlOfs%.8X%.8X',

[HInstance, GetCurrentThreadID]);
在注入dll中形成ControlAtomString 当然不会和要注入程序的ControlAtomString 相同了,

怎么办呢,只有重新做一个FindControl了

新的FindControl
function FindControlEx(Handle: HWnd): TWinControl;
var
  OwningProcess: DWORD;
  ControlAtomString:string;
  RM_GetObjectInstance:Cardinal;
begin
  Result := nil;
  if (Handle <> 0) and (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
     (OwningProcess = GetCurrentProcessId) then
  begin
    ControlAtomString:=Format('ControlOfs%.8X%.8X', [GetModuleHandle(nil),

GetWindowThreadProcessID(Handle, OwningProcess)]);
    if GlobalFindAtom(PChar(ControlAtomString)) <>0 then
      Result := Pointer(GetProp(Handle, MakeIntAtom(GlobalFindAtom(PChar

(ControlAtomString)))))
    else
    begin
      RM_GetObjectInstance := RegisterWindowMessage(PChar(ControlAtomString));
      Result:=Pointer(SendMessage(Handle, RM_GetObjectInstance, 0, 0));
    end;
  end;
end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值