The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: sinsi on September 27, 2010, 09:48:19 AM

Title: Elevation and a child process
Post by: sinsi on September 27, 2010, 09:48:19 AM
I have a few old games that don't work well with a multi-core CPU and need affinity set to one CPU.
For the moment I am using a loader that starts the game suspended, sets its affinity then starts the game thread.

Now I was thinking of expanding it with command-line args but get to the problem of elevation.
If my non-elevated program tries to run an elevated program nothing happens (as it should since I don't error check).

My question: is there an easy way of knowing whether an exe needs elevation?
Maybe an API or registry key? I don't want to have to parse a manifest resource or anything.
All I get with msdn is installer stuff.

The brute force way I suppose is to run my app as elevated, but that is...inelegant.
Title: Re: Elevation and a child process
Post by: sinsi on September 28, 2010, 05:33:07 AM
Looks like the only way is checking the return of CreateProcess for an error (ERROR_ELEVATION_REQUIRED from GetLastError).
Because my app needs to access the child app to set its affinity I will need to elevate it, thanks to Greg's code (again) here (http://www.masm32.com/board/index.php?topic=9422.0)

This seems to be the only way to check for an app that uses a manifest for elevation without parsing the file/resource.
Windows stores apps that elevate via properties>compatibility in the registry (HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers)



hutch, IE9 beta doesn't play well with your forum software...
Title: Re: Elevation and a child process
Post by: hutch-- on September 28, 2010, 06:44:06 AM
 :bg

> hutch, IE9 beta doesn't play well with your forum software...

Shoot it.
Title: Re: Elevation and a child process
Post by: sinsi on September 28, 2010, 06:58:27 AM
Can't shoot it, it's too fast  :P