News:

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

Elevated privileges and vista/win7

Started by sinsi, August 27, 2009, 08:22:08 AM

Previous topic - Next topic

sinsi

Using 'net stop wlansvc' works from a command prompt - as long as you pick 'run as administrator'.
I want to do it the hard way (instead of a batch file) which means using the SCM, which means elevation.

What is the best way to do it? I have seen code adjusting token privileges, using a manifest...

Background:
A game I play (NFS Undercover) connects to the internet to download ads (these are textures for the various billboards in the game).
The only trouble is that it can take up to 5 minutes for the game to start, since that's one of the first things it does.
If I remember, I disable my net connection before I start the game, but sometimes (well, quite often) I forget.
I even put a special rule in windows firewall (this is win7), it is 'block all' for incoming and outgoing, but still goes through.

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

Tedd

try sticking

Quoterunas /user:Administrator net stop wlansvc

in a batch file (untested; you might need to fiddle with the syntax) - it will request the password, and then run the command as the given user.
No snowflake in an avalanche feels responsible.

dedndave

i'd get the url for the ads and put it my hosts file
127.0.0.1  www. ad_url. com   (remove the spaces from the url)

GregL

sinsi,

Here is some stuff I wrote as an example of how to run a program or a task "elevated" in Windows Vista (works with Windows 7 too).

Run Elevated


sinsi

Tedd: batch file doesn't work properly - when the game ends the batch console window is gone but cmd.exe is still there (possibly because the damned game has a console window too). Another PITA is having to type the password twice for runas...

dave: can you recommend a program to let me see that url?

Greg: That's what I was referring to in my original post. This is twice now I have needed it but couldn't remember the thread (and I posted to it!). Bookmarked now.

If I start another process from my elevated one, is the new one elevated as well?
Light travels faster than sound, that's why some people seem bright until you hear them.

sinsi

OK, I've gone with my code and Greg's manifest - works perfectly.

step one: OpenSCManager/OpenService/ControlService/CloseServiceHandle to stop
step two: CreateProcess/WaitForSingleObject until it finishes
step three: OpenSCManager/OpenService/StartService/CloseServiceHandle to restart

Thanks for the input fellas.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

i think there is a console mode program that lets you see what urls are hit
i was playing with this at one time, to get rid of ads from yahoo messenger
with the last 10 or so versions of messenger, i have had to patch the exe file instead
so, i have forgotten how to get the info
one thing you can do is look in your temporary internet files
in the Content.IE5 folder, the urls are given
start by cleaning out the temp int files using internet options
then go in and physically clean it out - many non-indexed files get left behind
leave the favicons alone - they are desirable
then, fire up the game wait for it to load - and exit
go back into Content.IE5 and see which urls the ads came from

sinsi

Nah, the game connects to an ip (url or address, dunno) and downloads .png files - these are the 'ads' in the game world itself (billboards), not webpage ads.

The thing that pisses me off is that i specifically made rules in windows firewall that explicitly block the program - inbound and outbound. It still gets through.
What the f**k does 'DENY ALL' mean then? *grumble*
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

lol
well - if you look in the temp internet files, you will see the png files
if you look specifically in Content.IE5 folder, you can see the urls
trust me - lol

sinsi

I thought if you used sockets it didn't touch the IE cache.

Anyway, in win7 I can't even get into my 'local settings' dir - SYSTEM owns it and ain't letting go of it  :bdg
No big deal.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

that would bug the shit out of me - lol
i would be finding a work-around real quick
otherwise, the left-overs in the temp-internet-files will suck up all your drive space
i would either find a way to log in as "System", or i would find the right button to mash that changes permission for that folder

Tedd

Presumably, the main program launches another app to do the actual downloading of billboard images. So, you're blocking the main app, but not the one that actually does the downloading - hence it doesn't get blocked.
You might have to do some digging, but if it's dynamically unpacked (randomly generated filename) then it won't be pretty.
No snowflake in an avalanche feels responsible.

BlackVortex

Having trouble with the firewall, huh ?

On my Win7 64bit I use Windows 7 Firewall Control :
http://www.sphinx-soft.com/Vista/order.html

Ultra light-weight !

Just set your rules and nothing goes through. The windows firewall doesn't fit my needs.

GregL

Quote from: sinsiIf I start another process from my elevated one, is the new one elevated as well?

I think so, but I'm not sure, it's been over a year since I worked with that UAC stuff.

The following is some good information about it:

  Inside Windows Vista User Account Control


sinsi

BlackVortex: unfortunately, the game takes even longer to load :(
Greg: yes, the child inherits the parent user token.
Light travels faster than sound, that's why some people seem bright until you hear them.