Solved

Fast interapp communication

Posted on 2004-10-20
2
184 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
Comment Utility
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
Comment Utility
ok, cool
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

18 Experts available now in Live!

Get 1:1 Help Now