打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
运用API钩子直接给只读的表单上传控件赋值
发表于 2011-10-29 10:36:24 |只看该作者 |倒序浏览
import win.ui;
import web.form;
/*DSG{{*/
var winform = win.form(parent=...; bottom=523;scroll=1;right=744;text="演示表单上传控件赋值";cls="DLG_WEB" )
winform.add(  )
/*}}*/

//创建web窗体
var wb = web.form( winform );

html =
/***
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>演示表单上传控件赋值</title>
</head>

<body>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
  <label for="upload0"></label>
  <input type="file" name="upload0" id="upload0" />
</form>
<p>文件上传控件的值是只读的,不能修改.<br />
这里使用AAuto中的raw.hookApi创建一个函数钩子,拦截网页对文件对话框的调用,<br />
并直接返回我们预设的值即可。</p>
</body>
</html>

***/

wb.write(html)
//显示窗体
winform.show()  
wb.wait();
//等待指定网址,可以使用模式匹配语法
  
//导入函数钩子支持库
import raw.apiHook;

//声明钩子需要用到的结构体
OPENFILENAMEW = class{
   INT structSize;
   INT hwndOwner;
   pointer instance ;
   pointer filter;
   pointer customFilter;
   INT maxCustFilter;
   INT filterIndex;
   pointer file ;
   INT maxFile;
   pointer fileTitle;
   INT maxFileTitle;
   pointer initialDir;
   pointer title;
   INT flags;
   WORD fileOffset;
   WORD fileExtension;
   pointer defExt;
   pointer lCustData;
   pointer lpfnHook;
   pointer lpTemplateName;
   pointer pvReserved;
   INT dwReserved;
   INT flagsEx;
}   
//钩子函数
GetOpenFileNameW_Hook = function (pfn) {
   
var oldofn = raw.convert(pfn ,OPENFILENAMEW() );
    path = ..string.toUnicode(
"C:\神马都是浮云.exe");
    ::CopyMemory(  oldofn.file,path,#path );
    winform.setTimeout(
        
function(){
            hook.unInstall();
//用完立即卸载钩子,但是这里必须用一个异步的延时函数,让钩子函数可以先返回再销毁
        },1
    )   
   
return 1;
}
//安装API钩子
hook = raw.apiHook("comdlg32.dll", "GetOpenFileNameW", GetOpenFileNameW_Hook, "int(pointer)").install();

/** <INPUT class=text3 type=file name=upload0> **/
var ele = wb.getEle("upload0")  
ele.click()

//进入消息循环
win.loopMessage();

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
[转发]将Delphi的对象方法设为回调函数
抖音数据采集Frida教程,Java、Interceptor、NativePointer(Function/Callback)使用方法及示例
Go语言-逃逸分析
ASP.Net中FileUpLoad控件内容清空
又到周末了,我们一起来研究【浏览器如何检测是否安装app】吧
单点登录的post提交方式(js模拟动态表单提交)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服