Delphi修改窗口类名(Hookapi)修改版/知识点:指针
2013-07-18 19:40
525 查看
program Project1; uses Forms, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Dialogs, Unit1 in 'Unit1.pas' {Form1}; function GetClassInfoA1(x: Integer;y:Integer;j:Integer): Integer; stdcall; external 'user32.dll' name 'GetClassInfoA'; function RtlMoveMemory1(x: Integer;y:Pointer;j:Integer): Integer; stdcall; external 'kernel32.dll' name 'RtlMoveMemory'; var j_apidizhi,j_old:Pointer; jmt: array[1..8] of Byte; ent: array[1..8] of Byte; j_ls:LongWord; {$R *.res} function MyGetClassInfoA(hWnd:Integer;lpText: Integer;uType:Integer): Integer; stdcall; var myclassname:array[0..254] of char; jack:Integer; begin CopyMemory(j_apidizhi, @ent, 8); CopyMemory(@myclassname,Pointer(lptext),6); if myclassname='TForm1' then begin myclassname:='hgorj3'; RtlMoveMemory1(lpText,@myclassname,6); end; jack:=GetClassInfoA1(hWnd,lpText,uType); //asm // pushad // mov eax,j_apidizhi // mov byte [eax],$B8 // add eax,1 // mov ebx,j_ls // mov [eax],ebx // add eax,4 // mov byte [eax],$FF // add eax,1 // mov byte [eax],$E0 // popad //end; CopyMemory(j_apidizhi, @jmt, 8); Result:=jack; end; begin j_apidizhi:=GetProcAddress(GetModuleHandle('user32.dll'),'GetClassInfoA'); VirtualProtect(j_apidizhi,8,64,j_old); CopyMemory(@ent, j_apidizhi, 8); //保存原指令 j_ls:=LongWord(@MyGetClassInfoA); jmt[1]:=$b8; Pinteger(@jmt[2])^:=LongWord(@MyGetClassInfoA); jmt[6]:=$FF; jmt[7]:=$E0; CopyMemory(j_apidizhi, @jmt, 8); //修改API头 //asm // pushad // mov eax,j_apidizhi // mov byte [eax],$B8 // add eax,1 // mov ebx,j_ls // mov [eax],ebx // add eax,4 // mov byte [eax],$FF // add eax,1 // mov byte [eax],$E0 // popad // end; Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end.
Pinteger(@jmt[2])^:=LongWord(@MyGetClassInfoA);
重点在这一句
首先@jmt[2]表示jmt第二个元素的地址
比如 00400000 01
00400001 02
00400002 03
00400003 04
00400004 05
00400005 06
00400007 08
00400002 03
@jmt[2]=00400001
然后把地址转成Pinteger类型 也就是还是00400001 转成整型指针 让编译器识别
那么Pinteger(@jmt[2])的值就是Pinteger(@jmt[2])^
把00400001里的值赋值等于MyGetClassInfoA子程序的的地址
就是这句 Pinteger(@jmt[2])^:=LongWord(@MyGetClassInfoA);
相关文章推荐
- Delphi中利用钩子实现QQ聊天窗口的修改
- Delphi修改窗口类名(HookAPI)
- delphi中,如何实现点击弹出子窗口,然后录入或修改数据?
- 使用SetWindowPos API函数移动窗口后,还需修改Delphi的属性值,以备下次使用,否则就会出问题(不是API不起作用,而是使用了错误的坐标值)
- Delphi 利用钩子实现QQ聊天窗口的修改(4)
- Delphi利用钩子实现QQ窗口的修改
- VC 修改窗口属性 GetWindowLong SetWindowLong
- 指针指向的字符串不能修改
- delphi 登陆窗口的问题 [问题点数:30分,结帖人tianhuo_soft]
- [delphi技术]实现保存窗口上的所有Edit和checkbox状态的类
- Delphi 的内存操作函数(3): 给结构体指针分配内存
- Delphi 代码实现窗口透明+圆角边框
- 窗口与控件的设置与用代码修改各项属性(VFB教程1-2)
- Delphi中正常窗口的实现
- 微信小程序 修改窗口的背景色
- MFC获取各个窗口(体)之间的指针(对象)
- Delphi中如何让窗口最小化至系统托盘
- DELPHI 指针使用
- Delphi 的内存操作函数(1): 给字符指针分配内存
- vs2010修改状态栏的CStatusBar指针的的SetPaneText()方法时死活不对问题