|
Hello, i hope that this question is not misplaced in this part of the Forum, but if it is then i apologies.
I have a Global Hook callback procedure that is executed by the system each time an application tries to install a hook. This procedure (DebugProc)takes the following standard parameters:
int nCode,WPARAM wParam,LPARAM lParam
where WPARAM contains the type hook that is trying to be installed.
LPARAM is a pointer to a DEBUGHOOKINFO structure (defined natively and not customely). Is it possible with those informations to get the process id that has initiated the installation of the hook?
|
|
|
|
|
See CreateToolhelp32Snapshot and specifically the TH32CS_SNAPTHREAD.
In the THREADENTRY32 you can correlate th32ThreadID (which you have) with th32OwnerProcessID (which you want to know). Assuming the tool help functions can work within the debug hook procedure.
|
|
|
|
|
Rabih Sarieddine wrote:
Is it possible with those informations to get the process id that has initiated the installation of the hook?
Absolutely. The hook function is called from the context of the process and thread that performed the operation that caused the hook event to be triggered. This means that GetCurrentThreadID() and GetCurrentProcessID() will give you the thread and process IDs of the thread/process that caused the event.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you for your quick answer. Unfortunately, the GetCurrentProcessId returns the process id of the application that installed the Debug Hook. The Debug Proc Callback procedure is triggered whenever an application (lets say for example a keylogger) tries to install a hook (like Keyboard Hook).
If i call GetCurrentProcessId() from the Debug Proc Callback, i get the process id of the my application (the one that installed the Debug Hook). What i need is to get the process id of the keylogger.
|
|
|
|
|
Oops Sorry about that! Oh well. You learn something new every day
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi
Would anyone have the source for the project at this address
http://www.codeproject.com/miscctrl/axtraycontrol.asp
Sounds similar to something I have been trying to do with PCR Plates. It doesn't seem to be posted any longer. I click on the download link and get page can't be found.
Thank you
Gregg
|
|
|
|
|
Thanks to DavidCrow for suggesting to use onChar. I did it. Here how it is.
A small code is added to the wordpad sample of the VC++ to remap the keys.
If I type a I should get D and if I type b I should get e on the richedit document. It is working for the first case but not for the second case where unshift character is being sent with the SendMessage. How can I get that too.
void CWordPadView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case 'a':
SendMessage(WM_CHAR, 'D', 0);
break;
case 'b':
SendMessage(WM_CHAR, 'e', 0);
break;
}
}
In this it is working fine for case 'a' but it is not working for case 'b'. That is it is working for Capital letters A B C ... in SendMessage but not for small letters a b c .....
Can anyone help in making this work for unshift letters a b c...too. Thanks.
Jai Srimannarayana
|
|
|
|
|
kristna wrote:
It is working for the first case but not for the second case...
What happens if you remove the first case ?
I've never done it this way, but what you have looks like recursion in the making. If you type an 'b' then a 'e' is sent to the view. At that point (I think) another WM_CHAR message is generated and the OnChar() method is called again. Yes? What happens in the switch() statement when an 'e' is encountered?
Another way to do this might be to actually replace the text in the rich edit control (as the special characters are typed) rather than sending WM_CHAR messages. Your way might work, but without actually testing it, I can't say for sure.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Sir
when I type 'a' then 'D' is appearing as I used D in the sendmessage
when I type 'b' then I am trying to send 'e', but it is typing only b.
when I type 'e' then I am sending 'I' capital I so it is typing I.
I mapped all the requirements for a thru z but, it is not working for all the cases where I am sending small letters but, it is working fine for all Capital Letters.
How can I do it for sending small letters too through sendmessage ? or is there any other method?
I am typing no special characters frequently, so how can I replace the text in the richedit control for every time I press alphabet keys or punctuation keys ?
Thanks a lot
Jai Srimannarayana
|
|
|
|
|
kristna wrote:
I am typing no special characters frequently, so how can I replace the text in the richedit control for every time I press alphabet keys or punctuation keys ?
Instead of using SendMessage(WM_CHAR, 'D', 0) , using ReplaceSel("D") . This will prevent the recursion that David was talking about. This should work for lowercase and uppercase characters without a problem.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for great idea, but still it did not work for me. I am a novice and if you can give the piece of the code, the line of code, I'll try with it. It says error undeclared identifier ReplaceSel.
Thanks a lot.
Jai Srimannarayana
|
|
|
|
|
Since you're using CRichEditView , you'll need to use GetRichEditCtrl().ReplaceSel(...)
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks for your response. I am still in trouble.
It is giving the following error if I try to implement it.
error C2664: 'ReplaceSel' : cannot convert parameter 1 from 'char [2]' to 'const unsigned short *'
void CWordPadView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
switch(nChar)
{
case 'b':
GetRichEditCtrl().ReplaceSel("e") ;
break;
...
Can I get some solution ?
Jai Srimannarayana
|
|
|
|
|
You didn't say you were compiling for Unicode Use _T("e") instead of just "e"
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thanks dear Ryan Binns! It worked with _T("e"). Thanks a lot .
Using same replacesel I am unable to put the characters above 128. Is there any way to do that ?
Thank you again.
Jai Srimannarayana
|
|
|
|
|
Hi there
We've tried to write a screensaver that starts (a bit after it starts) and stops (after it stops) a service using the codeproject ServiceHelper class here: http://www.codeproject.com/system/cservicehelper.asp
the problem is that the screensaver runs fine when a user is logged in, but when they're logged out, there are no privileges granted to the process, so we get ERROR_ACCESS_DENIED from the call to the service control manager.
Can anyone help us think of a workaround?
|
|
|
|
|
Can we know, is your purpose to only start or stop this service if YOUR screensaver is running?
Or would you want this to happen for ANY screensaver?
Also, I just examined the source for the service helper class, and it asks for SERVICE_ALL_ACCESS just to start and stop a service. Why don't you try 'relaxing' the requirement to SERVICE_START for starting and SERVICE_STOP for stopping and see if that helps.
|
|
|
|
|
I want to add a button to the title bar. How can I do this using the API Windows ?
Thank in advance.
|
|
|
|
|
|
Thank Alok !
|
|
|
|
|
CryptAcquireContext(&cspContext,UserName,MS_DEF_PROV,PROV_RSA_FULL ,0); returns an error ERROR_FILE_NOT_FOUND ( 2L )
Anybody knows why ? How to getrid of this error ?
Sandeep Naik
|
|
|
|
|
Hi,
When I have designed my application, I had a class (CVerifiPoteau) that was inheriting from a base class (CPoteauBeton).
Now I want to serialize my class CVerifiPoteau and I have added another inherited class : CObject.
See my code here :
class CVerifiPoteau : public CPoteauBeton , public CObject
It seems to work properly since it respect C++, but I want to know if it can cause some difficulties with MFC (Visual Studio.NET 2003 C++).
Thanks,
Claude
|
|
|
|
|
Why would using a class that comes with MFC cause problems in MFC ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian Graus wrote:
Why would using a class that comes with MFC cause problems in MFC ?
Multiple inheritance and MFC does not mix particularly well See my answer below for the problem that I found.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Although it shouldn't make a difference, the MSVC++6 compiler was dependent on the order in which the classes appeared in the derivation list for multiple inheritance. Consequently, it often caused very wierd runtime errors if the MFC class was not the first class in the derivation list. As a general rule, make the MFC class the first class in the derivation list (swap the two around in your example above) and it should work fine.
I don't know whether the same problem appears in the .NET 2003 compiler, but I would still put the MFC class first.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|