阻止文件保存,writefile问题
我使用detour,能够截获某特定文件的写入操作,代码如下:
BOOL _stdcall Replace_WriteFile( //替换系统的Writefile
HANDLE hFile, // handle to file to write to
LPCVOID lpBuffer, // pointer to data to write to file
DWORD nNumberOfBytesToWrite, // number of bytes to write
LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written
LPOVERLAPPED lpOverlapped // pointer to structure for overlapped I/O
)
{
BOOL res = NULL; //操作成功完成返回非零值
__try
{
::MessageBox(NULL,"截获保存","成功",NULL);
res = Real_WriteFile( hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped );
}
__finally
{};
return res;
}
假如我不想让该文件被写入,我可以将中间的res = Real_WriteFile( hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped );这句注释了就可以,但是这样虽然达到了文件没有写入的目的,但是这样我的替换原有API的函数就没有去调用系统的原有API,是不是会造成堆栈不平衡?
我的想法是,能不能将writefilefile的相关参数我修改了以后,传给系统writefile api调用,比如lpBuffer,是需要被写入文件的数据的指针,我将他修改了再传给系统真实的writefile使用,但是试了以后效果不是太好,貌似他在重复的保存,不结束,我应该怎么做?
BOOL _stdcall Replace_WriteFile( //替换系统的Writefile
HANDLE hFile, // handle to file to write to
LPCVOID lpBuffer, // pointer to data to write to file
DWORD nNumberOfBytesToWrite, // number of bytes to write
LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written
LPOVERLAPPED lpOverlapped // pointer to structure for overlapped I/O
)
{
BOOL res = NULL; //操作成功完成返回非零值
__try
{
::MessageBox(NULL,"截获保存","成功",NULL);
res = Real_WriteFile( hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped );
}
__finally
{};
return res;
}
假如我不想让该文件被写入,我可以将中间的res = Real_WriteFile( hFile,lpBuffer,nNumberOfBytesToWrite,lpNumberOfBytesWritten,lpOverlapped );这句注释了就可以,但是这样虽然达到了文件没有写入的目的,但是这样我的替换原有API的函数就没有去调用系统的原有API,是不是会造成堆栈不平衡?
我的想法是,能不能将writefilefile的相关参数我修改了以后,传给系统writefile api调用,比如lpBuffer,是需要被写入文件的数据的指针,我将他修改了再传给系统真实的writefile使用,但是试了以后效果不是太好,貌似他在重复的保存,不结束,我应该怎么做?
...全文
相关推荐
js导出excel插件
js导出excel插件,需要配置为网站
易语言源码加密配置文件操作模块
易语言源码加密配置文件操作模块
创建文件和文件夹下的内容
能够更好地检查文件和文件夹是否存在,并建立新的文件夹和文件
Nodejs如何复制文件
前端童鞋都知道,javascript是没有权限操作磁盘文件的,server童鞋一向都很鄙视。但是nodejs可谓让咱们前端扬眉吐气啊,最近在学node,其强大的功能让人异常激动和兴奋。今天就学习了它怎么读写文件。 首先需要引入fs模块,这是nodejs自带的。 var fs=require(“fs”); 具体可参考Nodejs API:http://www.w3cfuns.com/tools.php?mod=booknodejs 主要用到了两个方法: 1、fs.readFile(filename, [encoding], [callback]) 这是异步读取文件,filename是文件路径,e
解决MYSQL出现Can''t create/write to file ''#sql_5c0_0.MYD''的问题
今天在配置服务器的时候提示这个问题Can't create/write to file,原来是php.ini中设置的tmp目录不存在


