Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 811
  • Last Modified:

Windows Hook (SetWindowsHookEx) and RunAs...

I have an app which does basically the same kind of Idle Tracking as

http://www.codeproject.com/dll/trackuseridle.asp?target=idle|hook 

It works fine on 2k, 98, NT, and XP.

However, I just received a comment that a user running WinXP is having trouble running a RunAs.. Application. (iow, running an app as a different su'd user in windows xp).

I was able to verify the same problem, by running from a cmd prompt: runas /user:DOMAIN\USERNAME notepad

When Notepad comes up it's blank (i.e not accepting mouse and keyboard events) until I kill the hook-owning app described above.

What needs to be done to allow UI windows apps with system hooks to persist through multi-users in a single shell (via running "RunAs" within windows)?  I think this might be related to a recent security patch of XP, but how can I work around this?

Is this something in the code, or is this just a compile/link-time flag that I need to set?

Thanks in advance!
0
dovkatz
Asked:
dovkatz
1 Solution
 
jkrCommented:
>>It works fine on 2k, 98, NT, and XP.

If you need idle tracking on these platforms, it might be worthwile to consider something 'official' - check out this MSJ Q&A column where Paul DiLascia discusses some options: http://www.microsoft.com/msj/0200/c++/c++0200.asp

 LASTINPUTINFO lpi;
 lpi.cbSize = sizeof(lpi);
 GetLastInputInfo(&lpi);

 DWORD dwIdleTime = lpi.dwTime;
0
 
dovkatzAuthor Commented:
jkr. Thanks for the response.

The reason I mentioned the URL at codeproject is because that's exactly what I do. (MSJ's version doesn't address a subtle bug in same-position mouse events, that's why I used codeproject's at the time)....  I am familiar with both sites.

I run an app with this stuff set and while it's running I launch something via runas in winxp.

The reason I'm not going with lastinputinfo is specifically because I need NT and 98 support, which that doesn't have (hence I mentioned the windows version list).

So basically, what I'm looking for is a suggestion of why "RunAs" on xp / 2k causes the "Runned As" app to hang until I kill my Hook-Owning App.

Do I need a DLLMain() with an Unload() whenever the app attaching me is not being run in the same shell?  How can I tell if a process calling DLLMain is running as "RunAs" as opposed to within the regular windows shell?  

FYI even if I runAs notepad as my self, I stll have this problem, so I cant' just compare usernames as a solution.
-d
0
 
dovkatzAuthor Commented:
FYI - It looks like windows XP's recent patch might have mucked with the way hooks interact with RUNAS programs such as "TaskPad" etc.

( Quote from "Patches that Patch (eWeek)" http://www.eweek.com/article2/0,4149,1383105,00.asp )
Last month's Windows upgrades, however, caused him grief. "One of the patches broke one of our applications, so Microsoft is discussing with us whether or not the patch should have a 'shim' or something." Microsoft said the patch in question changes the way Windows handles text input and that other developers should change their code to avoid any problems.
0
 
tinchosCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 
moduloCommented:
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now