Solved

Fast interapp communication

Posted on 2004-10-20
2
185 Views
Last Modified: 2010-08-05
For somewhat arcane reasons, I need to monitor (globally) keystrokes and mouse movements and later analyze that data.

OK, I can do system wide hooks (ordinary or low level) and accumulate the data in the hookprocs.

But I need to send that data, periodically, to a separate analysis app running in the system tray. This has to be done fast because of the performance implications for the system as a whole. I was thinking WM_COPYDATA but the SDK says to use SendMessage .. I would rather use PostMessage (can I do this??)

Now, maybe I am getting confused here, but is there any reason I cannot grab some memory in the hookproc with GlobalAlloc send its address to the analysis app and free it there?

The data to be transferred is maybe 5K bytes max, if that makes a difference
0
Comment
Question by:Mutley2003
2 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 500 total points
ID: 12355877
Use a memory mapped file, that is shared between the keylogger and the analyzer. The keylogger writes and the analyzer just reads. Two 64-bits integers (read/write pointer) at the beginning of the MMF should indicate the current position that they are reading and the rest of the MMF is to store the data in a round-robin style. (Thus, when you get past the end of the file, you start at the beginning again.)
A MMF doesn't have to be a physical file even. It can just be a reserved part of memory that is shared between applications. All you have to remember is that you should never read or write beyong the filesize. Also, never write beyond the read-pointer and never read beyond the write pointer. If the read-pointer is 0 then the write pointer knows there's no reader and thus it might not even need to write anything...

MMF's can be reasonable big in size, so a size of 5 to 10 MB is quite well possible.
0
 

Author Comment

by:Mutley2003
ID: 12356062
ok, cool
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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

16 Experts available now in Live!

Get 1:1 Help Now