How to disable VirtualStore programs for C ++?

I want my program to throw an error when I try to create files in protected places, such as the root of the C: \ drive (for example: FILE* FileHandle = fopen("\\file.txt", a) ). Instead, the file is created in the virtual store in% APPDATA%.

How to disable this virtual store?

thanks

EDIT: just to be clear, I am not asking how to bypass the protection and create the file in a secure place. I want the file to be created by FAIL so that I can tell the user that he is an idiot.

+6
c ++ windows file-io fopen virtualstore
source share
3 answers

You are adding an application manifest. Choose asInvoker, maximumAvailable or requireAdministrator. 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> 
+16
source share

From MSDN :

Virtualization is allowed only for:

  • 32-bit interactive processes.
  • Administrator, recordable file / folder and registry keys

Virtualization is disabled for:

  • 64-bit processes
  • Non-interactive processes
  • Personifying processes
  • Kernel Mode Calls
  • Executables that have requestExecutionLevel

The best thing, as Adam Maras noted, is to set requestExecutionLevel in your application by adding a manifest. The requested ExecutionLevel value for "asInvoker" will cause file operations to fail in secure locations, not a redirect to a virtual store or a call for promotion.

+6
source share

Here is an article showing how to disable virtualization.

http://www.interworks.com/blogs/dsmith/2011/09/21/disabling-windows-7-virtual-store

In short:

- From the Windows 7 launchpad, search for the local security policy and select it.

-Open local policies and click "Security Settings". In the right panel, scroll to the end and you will find the option "User Account Management: File Virtualization and Failures in the Registry Entries for Each User", double-click this option and change it to "Disabled".

+3
source share

All Articles