Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Windows Hook (SetWindowsHookEx) and RunAs...

Posted on 2003-11-11
5
Medium Priority
?
805 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

730 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