|
常规raw.apiHook好像不能hook com对象下面的函数,于是改写了一个raw.comHook
//comHook 函数钩子
namespace raw {
comHook = class {
ctor (apiAddr,apiProto, callback,ownerTable) {
this.apiProto = apiProto;
if(type(apiAddr)==type.pointer){
this.pTargetFunction = apiAddr
}else {
error("apiAddr必须为函数地址!", 2);
}
if( type(callback)!= type.function && ( !tonumber(callback) )){
error("参数@4必须指定钩子函数",2);
};
if( type(callback) == type.function ){
this.callback_c = ..raw.tostdcall(callback, apiProto,this);
this.addrHookFunction = getPointerAddress(this.callback_c)
}
else {
this.addrHookFunction = tonumber(callback);
if( !this.addrHookFunction )
error("参数@4必须指定钩子函数",2);
}
..table.gc( this,"unInstall" );
}
install = function () {
var jmpOpCodeLen = 5;
var threadCmpOpCodeLen = 20;
var ok
var addrTargetFunction = tonumber(this.pTargetFunction );
ok, this.addrProtect = VirtualProtect( addrTargetFunction, jmpOpCodeLen * 2, 0x40/*_PAGE_EXECUTE_READWRITE*/,0);
if (!this.addrProtect ) {
error("修改内存属性失败!", 2);
}
var nopAddr = addrTargetFunction-jmpOpCodeLen;
var addr = prcsHook.write( nopAddr, '\xE9',{
int jmpAddr = this.addrHookFunction - addrTargetFunction
} )
addr = prcsHook.write( addrTargetFunction, '\xEB','\xF9')
this.callApi = ..raw.main.api(topointer(this.pTargetFunction, 2), this.apiProto );
return this;
}
unInstall = function () {
//卸载不会。
this.callback_c = null;
}
}
}
namespace raw.comHook {
import ..process;
prcsHook = ..process();
VirtualProtect = ::Kernel32.api("VirtualProtect","bool(addr lpAddress, INT dwSize, INT flNewProtect, INT &lpflOldProtect )");
getByte = function (pt,offset){
return ..raw.convert(topointer(pt,offset),{BYTE a}).a
}
getFunPtr = function (pt, offset){
return topointer(..raw.convert(topointer(tonumber(pt) + offset), {int a}).a)
}
getPointerAddress = function(p){
return ..raw.convert( { pointer arg = p }, { addr ret } ).ret;
}
}
/**intellisense()
raw.comHook = comAPI函数钩子
raw.comHook("comAPI函数指针","函数原型",函数对象) = @var HookProc = function (hwnd, text, caption, flag) {\n import win;\n owner.callApi(hwnd, text, "HOOK成功: " + caption, flag);\n return 0;\n}\nhook = raw.comHook(ptr, "int(int,string,string,int)",\n HookProc,/*owner*/).install();
raw.comHook() = !raw_comHook.
!raw_comHook.install() = 安装钩子\n!raw_comHook.
!raw_comHook.unInstall() = 卸载钩子
end intellisense**/
软件界面:
1、分析模式 和 运行模式分别采用不同的判断方式,参考源码。
2、导出是将set_tab导出到“分析结果.tab”,导入方便重复使用分析结果。
3、快捷键有F3~F8对应界面上的按钮,分别是+和-。
4、分析模式下,可以实时调整Stride,NumVertices,PrimitiveCount值,注意:步进值大于1时,是判断的范围。
5、修改输入框的值,需要点“写”才修改变量值。
...
详细内容参考源码。
本源码在hook方面欠妥,求大神指导。另外:本源码仅供学习探讨,请勿用于非法用途。
hookd3d.7Z
(5.85 KB, 下载次数: 75)
|
-
评分
-
查看全部评分
|