使用重复句柄复制文件 [英] Copy File using duplicate handle

查看:121
本文介绍了使用重复句柄复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要复制系统"进程正在使用的文件[pid:4]
我迭代了此过程的所有句柄,并复制了所需文件的句柄.现在,当我使用此句柄读取文件时,它显示访问被拒绝"

I want to copy a file that is being used by "System" process[pid:4]
I iterated all the handles for this process and duplicated the handle for the file i required. now when i am reading the file using this handle it says "access denied"
is there any way to change the "share mode" using this duplicate handle so that I can read it?

推荐答案

没有(据我所知):那会不会是一种安全对待.
Nope (as far as I know): that would be a security treat.


CPallini是正确的.如果该句柄不可继承(默认设置),则不能从其他进程使用它.

如果您知道文件的名称,则可以尝试使用CreateFile将其打开并使用FILE_SHARE_READ | FILE_SHARE_WRITE标志.

如果您不知道文件名,则可以尝试从该文件的句柄中获取它:
http://msdn.microsoft.com/en-us/library/aa366789 (v = vs.85).aspx [
CPallini is right. If the handle is not inheritable (which is the default), you can''t use it from another process.

If you know the name of the file, you can try to open it with CreateFile and use FILE_SHARE_READ | FILE_SHARE_WRITE flags.

If you don''t know the name of the file, you can try to get it from its handle there:
http://msdn.microsoft.com/en-us/library/aa366789(v=vs.85).aspx[^]


这篇关于使用重复句柄复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆