Solved

Windows Hook (SetWindowsHookEx) and RunAs...

Posted on 2003-11-11
5
775 Views
Last Modified: 2007-12-19
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
Comment
Question by:dovkatz
5 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 9722155
>>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
 
LVL 2

Author Comment

by:dovkatz
ID: 9722287
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
 
LVL 2

Author Comment

by:dovkatz
ID: 9790591
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
 
LVL 9

Expert Comment

by:tinchos
ID: 10248936
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
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10308134
PAQed, with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now