Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: jr2 on August 07, 2012, 11:54:35 pm

Title: Can SCP be UAC-aware?
Post by: jr2 on August 07, 2012, 11:54:35 pm
Ran across this whilst trying to look up the VirtualStore location, thought I'd run it by here... is this something FSO should use?  What are you guys' thoughts (sorry if I'm being a clueless n00b, feel free to tell me if this isn't relevant to FSO's development).

http://windowsteamblog.com/windows/b/developers/archive/2009/08/04/user-account-control-data-redirection.aspx

Quote from: Yochay Kiriaty, profile: http://windowsteamblog.com/members/Yochay-Kiriaty/default.aspx

User Account Control Data Redirection

To making sure your application is ready (compatible) for Windows 7, I am going to start providing additional information about the few compatibility topics we introduced in the “Is Your Application Ready for Windows 7 RTM? (http://windowsteamblog.com/blogs/developers/archive/2009/07/23/is-your-application-ready-for-windows-7-rtm.aspx)” post. This post focuses UAC Virtualization or more known as Data Redirection.

What Are You Talking About?

Today, many applications are still designed to write files to the Program Files, Windows directories, or system root (typically the C drive) folders. Some applications are designed to update Microsoft® Windows registry values, specifically values in HKLM/Software. But there is one problem: the files or registry values are not created or updated. You may ask, “What’s going on? My application goes through the code and does not report an error. So where are my files?”

To be specific, you may experience one or more of the following symptoms:


If this happens to your application, it is experiencing UAC Virtualization (AKA Data Redirection). The following information provides you with everything you need to know in order to detect this application compatibility problem, offers some solutions, and provides additional information about the specific nature of the compatibility problem.

The Real Issue: UAC Virtualization

Prior to Windows Vista, administrators typically ran applications. As a result, applications could freely read and write system files and registry keys. If standard users ran these applications, they would fail due to insufficient access. Windows Vista improved application compatibility for standard users by redirecting writes (and subsequent file or registry operations) to a per-user location within the user’s profile.

For example, if an application attempts to write to C:\Program Files\Contoso\Settings.ini, and the user does not have permissions to write to that directory (the Program Files), the write operation will be redirected to C:\Users\Username\AppData\Local\VirtualStore\Program Files\Contoso\settings.ini. If an application attempts to write to HKEY_LOCAL_MACHINE\Software\Contoso\ in the registry, it will automatically be redirected to HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\Software\Contoso or HKEY_USERS\UserSID_Classes\VirtualStore\Machine\Software\Contoso.

The following figure illustrates the two components of the Windows Virtualization process: file virtualization and registry virtualization:

(http://i46.tinypic.com/2yxgrah.gif) (http://msdn.microsoft.com/en-us/library/bb756960.aspx)

To learn more about UAC virtualization and new UAC technologies, see “New UAC Technologies for Windows Vista” at http://msdn.microsoft.com/en-us/library/bb756960.aspx (http://msdn.microsoft.com/en-us/library/bb756960.aspx).

Solution

Virtualization is intended only to assist in application compatibility with existing programs. New applications designed for Microsoft Windows 7 should NOT perform write operations to sensitive system areas, nor should they rely on virtualization to provide redress for incorrect application behavior. Always develop applications for use with standard user privileges and don’t count on the application running under administrator privileges. Test your application with standard user privileges and not administrator privileges.

If you are experiencing UAC virtualization with applications developed prior to Windows 7, re-design your applications to write files to the appropriate locations. When updating existing code to run on Windows 7, you should:


Steps to Determine the Most Appropriate Solution

So far, we have presented the symptoms associated with UAC virtualization, explained why redirection is taking place, and suggested a solution. This section contains tests and procedures you should perform in order to pinpoint the real problem and plot a way to resolve it.

Test #1:


Test #2:


Test #3:


Test #4:

(http://i48.tinypic.com/jagdv7.png)
(http://i50.tinypic.com/10zvmaf.png)
(http://i48.tinypic.com/27xowu0.png)

Test #5:


Hands On Labs and Additional Material

you can download (http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples.AppCompat/Data-Redirection.zip) this doc, a presentation describing UAC Virtualization, and two full hands on labs on this topic (http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples.AppCompat/Data-Redirection.zip), one for managed code and one for native, from here (http://windowsteamblog.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/developers.CodeSamples.AppCompat/Data-Redirection.zip).

Tools

In order to detect UAC virtualization we use the following tools:


Additional Resources

Title: Re: Can SCP be UAC-aware?
Post by: Droid803 on August 07, 2012, 11:59:45 pm
Don't think this is an issue unless you absolutely must install FSO into Progam Files, and no other folder will satisfy your ALL APPLICATIONS ARE INSTALLED IN PROGRAM FILES! OCD/fetish. :P
Title: Re: Can SCP be UAC-aware?
Post by: LordMelvin on August 08, 2012, 12:20:07 am
Speaking as someone who uses fs2o primarily on linux, why bother with this?
Title: Re: Can SCP be UAC-aware?
Post by: mjn.mixael on August 08, 2012, 12:26:09 am
That.. is a very good question.
Title: Re: Can SCP be UAC-aware?
Post by: The E on August 08, 2012, 12:56:56 am
FSO does not really need to be aware of UAC. We'll probably move away from the "put everything in FS2DIR/data or the registry" model on Windows to something similar to what we're already doing on MacOS and Linux anyway, that way, all those problems are going to go away.

Not to mention that the only reason why we advise people not to put FSO into Program Files is because it makes modding much simpler.
Title: Re: Can SCP be UAC-aware?
Post by: jr2 on August 08, 2012, 01:14:30 am
I was referring to this problem:

Having FS2 in \Program Files means that your log file was in (as I posted before)  \Users\<username>\AppData\Local\VirtualStore\Program Files (x86)\GOG.com\FreeSpace2\data\fs2_open.log

This is because programs are not allowed to write to the program files directory unless they have administrative permission.
Title: Re: Can SCP be UAC-aware?
Post by: MatthTheGeek on August 08, 2012, 01:33:17 am
It's a problem only to people that are noobish enough to keep installing stuff in Program Files. Especially old games. What year is this, really ?
Title: Re: Can SCP be UAC-aware?
Post by: jr2 on August 08, 2012, 01:56:43 am
The year of GOG.com default installation locations?   :P
Title: Re: Can SCP be UAC-aware?
Post by: NGTM-1R on August 08, 2012, 02:04:42 am
It's a problem only to people that are noobish enough to keep installing stuff in Program Files. Especially old games. What year is this, really ?

Assuming that being newbie-friendly isn't a worthy goal in itself is a good way to end up a shrinking dispossessed minority in most things in life, y'know.
Title: Re: Can SCP be UAC-aware?
Post by: Mongoose on August 08, 2012, 03:12:50 am
It's a problem only to people that are noobish enough to keep installing stuff in Program Files. Especially old games. What year is this, really ?
The year when pretty much everything installs to Program Files by default, and why bother changing it? :p

(I'm still on XP, though, so I blissfully run everything as admin and ignore the gaping security holes.)
Title: Re: Can SCP be UAC-aware?
Post by: The E on August 08, 2012, 03:19:31 am
Mattthegeek:

Usability is a good thing to have. It's nice that you think that obscure paths are not a big deal, but be aware that we are not writing a program for the supergeek user subset.
Please, for the love of kittens, at least try to understand that arrogance is not a nice trait, and that making our community exclusionary in nature is not a good thing.


As for the overall discussion: It is teh pointless. Yes, we know that UAC's folder virtualization has its issues. Yes, we are aware of ways to get around it. Yes, we do plan on implementing them at some point.

Oh, and jr2? There's this section from the big FSO FAQ that was written to address this very thing:
Quote
*NOTE FOR PEOPLE USING WINDOWS VISTA OR 7:
If you installed FS2 to C:\Program Files\ (or C:\Program Files (x86)\ on 64-bit versions of Windows), the log file will not be in FS2\data\, but rather in a "virtualized" folder. This can be found by either going to the data folder, and clicking on the "Compatibility Files" button in the Explorer window, or by manually navigating to C:\Users\<Your Username>\AppData\Local\VirtualStore\Program Files (x86)\<Rest of the path to your FS2 directory>\data
Title: Re: Can SCP be UAC-aware?
Post by: chief1983 on August 08, 2012, 10:13:01 am
If the GOG.com installer installs by default to that location, we could nicely ask them to change it.  We've had a line of dialog with them before, y'know.
Title: Re: Can SCP be UAC-aware?
Post by: Iss Mneur on August 08, 2012, 11:59:50 am
jr2:  yes, FSO will be UAC-aware once we get to it.

This topic (http://www.hard-light.net/forums/index.php?topic=80191.msg1590044#msg1590044) has come up several times before.  The answer is the same as the last time you asked.
Title: Re: Can SCP be UAC-aware?
Post by: jr2 on August 08, 2012, 10:44:43 pm
This topic (http://www.hard-light.net/forums/index.php?topic=80191.msg1590044#msg1590044) has come up several times before.  The answer is the same as the last time you asked.

Oops... :nervous:  I thought I had brought up a similar topic, however I guess it was rather the same topic.  I should have searched rather than relying on memory.  :nono: My apologies.  :(