首页
社区
课程
招聘
[求助]文件要以什么方式打开才能防止其他进程对其进行破坏?
发表于: 2009-9-22 11:01 4531

[求助]文件要以什么方式打开才能防止其他进程对其进行破坏?

2009-9-22 11:01
4531
windows上,我原先都是使用FILE的fopen进行文件操作,比如以"rb"二进制只读方式打开,以为这样打开后,其他进程就无法以带写的方式打开它了。
可是,今天我发现自己错了,当我用"rb"方式打开后并且在关闭之前,记事本另存为轻轻松松地就把这个文件破坏了,但如果是用WM打开一个视频文件,记事本另存为是不能成功了,同样的我以代码形式rb+、wb、wb+这些带写的方式都不能再打开这个文件了。
我用OD跟踪了一下WM,下断CreateFileW,就参数而言,也没看出什么端倪来。有哪位大侠知道是怎么回事么?

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (5)
雪    币: 20
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
rb是对你自己做的 你自己只能读  管不了别人
2009-9-22 11:05
0
雪    币: 20
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
"r"

Opens for reading. If the file does not exist or cannot be found, the fopen call fails.
2009-9-22 11:06
0
雪    币: 359
活跃值: (41)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
4
我问的就是怎样才能像WM那样管得了别人啊,你知道么?
2009-9-22 11:17
0
雪    币: 20
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
HANDLE CreateFile(
  LPCTSTR lpFileName,                         // file name
  DWORD dwDesiredAccess,                      // access mode
  DWORD dwShareMode,                          // share mode
  LPSECURITY_ATTRIBUTES lpSecurityAttributes, // SD
  DWORD dwCreationDisposition,                // how to create
  DWORD dwFlagsAndAttributes,                 // file attributes
  HANDLE hTemplateFile                        // handle to template file
);

Parameters

dwShareMode
[in] Specifies how the object can be shared. If dwShareMode is 0, and CreateFile succeeds, the object cannot be shared and cannot be opened again until the handle is closed. Please refer the information concerning sharing violations in the Remarks section.
2009-9-22 11:23
0
雪    币: 359
活跃值: (41)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
6
谢谢,windows下可以了。
可惜Linux下似乎没什么方法……
2009-9-22 12:05
0
游客
登录 | 注册 方可回帖
返回
//