如何禁用 C++ 的 VirtualStore程序?
我希望我的程序在尝试在 C:\ 驱动器根目录等受保护位置创建文件时抛出错误(例如: FILE* FileHandle = fopen("\\file.txt", a) )。相反,该文件是在虚拟存储中的 %APPDATA% 下创建的。
如何禁用该虚拟商店?
谢谢
编辑:为了明确起见,我并不是问如何规避安全性并在受保护的位置创建我的文件。我希望文件创建失败,这样我就可以告诉用户他是个白痴。
I'd like my program to throw an error when it tries to create files in protected locations like the root of the C:\ drive (eg: FILE* FileHandle = fopen("\\file.txt", a)
). Instead the file gets created in the Virtual Store under %APPDATA%.
How can I disable that Virtual Store?
Thanks
EDIT: Just to be clear, I'm not asking how to circumvent the security and create my file in a protected location. I want the file creation to FAIL so that I can tell the user he was an idiot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您添加应用程序清单。选择 asInvoker、highestAvailable 或 requireAdministrator。听起来你想作为Invoker。
来自http://msdn.microsoft.com/en-us/library/bb756929。 .aspx:
You add an application manifest. Choose asInvoker, highestAvailable, or requireAdministrator. It sounds like you want asInvoker.
From http://msdn.microsoft.com/en-us/library/bb756929.aspx:
来自 MSDN:
虚拟化仅适用于:
和注册表项
禁用虚拟化:
正如Adam Maras 指出的,最好的选择是通过添加清单来在应用程序上设置requestedExecutionLevel。 “asInvoker”的requestedExecutionLevel 将导致受保护位置上的文件操作失败,而不是重定向到虚拟存储或提示提升。
From MSDN:
Virtualization is only enabled for:
and registry keys
Virtualization is disabled for:
Your best bet, as Adam Maras noted, is to set a requestedExecutionLevel on your application by adding a manifest. A requestedExecutionLevel of "asInvoker" will cause file operations to fail on protected locations, rather than redirecting to the virtual store or prompting for elevation.
这是一篇展示如何关闭虚拟化的文章。
http://www.interworks.com /blogs/dsmith/2011/09/21/disabling-windows-7-virtual-store
简而言之:
- 从 Windows 7 Start Orb 中,搜索本地安全策略并选择它。
- 展开本地策略并单击安全选项。在右侧窗格中,一直滚动到底部,您将找到一个名为“用户帐户控制:将文件和注册表写入失败虚拟化到每个用户位置”的设置,双击该设置并将其更改为“已禁用”。
Here is an article that shows how to turn off the virtualization.
http://www.interworks.com/blogs/dsmith/2011/09/21/disabling-windows-7-virtual-store
The short of it is:
-From the Windows 7 Start Orb, do a search for Local Security Policy and select it.
-Expand Local Policies and click on Security Options. On the right pane, scroll all the way to the bottom and you will find a setting called " User Account Control: Virtualize file and registry write failures to per-user locations", double click on that setting and change it to Disabled.