Solved

Windows Hook (SetWindowsHookEx) and RunAs...

Posted on 2003-11-11
5
799 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

623 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