News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Elevation and a child process

Started by sinsi, September 27, 2010, 09:48:19 AM

Previous topic - Next topic

sinsi

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.
Light travels faster than sound, that's why some people seem bright until you hear them.

sinsi

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

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...
Light travels faster than sound, that's why some people seem bright until you hear them.

hutch--

 :bg

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

Shoot it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

Light travels faster than sound, that's why some people seem bright until you hear them.