如何禁用 C++ 的 VirtualStore程序?

发布于 2024-10-12 15:57:41 字数 247 浏览 4 评论 0原文

我希望我的程序在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

过度放纵 2024-10-19 15:57:41

您添加应用程序清单。选择 asInvoker、highestAvailable 或 requireAdministrator。听起来你想作为Invoker。

来自http://msdn.microsoft.com/en-us/library/bb756929。 .aspx

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="IsUserAdmin"
     type="win32"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>

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:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0"
     processorArchitecture="X86"
     name="IsUserAdmin"
     type="win32"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>
风月客 2024-10-19 15:57:41

来自 MSDN

虚拟化仅适用于:

  • 32 位交互式进程
  • 管理员可写文件/文件夹
    和注册表项

禁用虚拟化:

  • 64 位进程
  • 非交互式进程
  • 模拟
  • 内核模式调用者的
  • 进程 具有requestedExecutionLevel 的可执行文件

正如Adam Maras 指出的,最好的选择是通过添加清单来在应用程序上设置requestedExecutionLevel。 “asInvoker”的requestedExecutionLevel 将导致受保护位置上的文件操作失败,而不是重定向到虚拟存储或提示提升。

From MSDN:

Virtualization is only enabled for:

  • 32 bit interactive processes
  • Administrator writeable file/folder
    and registry keys

Virtualization is disabled for:

  • 64 bit processes
  • Non-interactive processes
  • Processes that impersonate
  • Kernel mode callers
  • Executables that have a requestedExecutionLevel

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.

放飞的风筝 2024-10-19 15:57:41

这是一篇展示如何关闭虚拟化的文章。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文