Solved

Inter process communication

Posted on 2008-06-10
3
671 Views
Last Modified: 2013-11-20
Hi,
I have a hooking dll for a global hooking. I would like to set a flag in this dll from my app that init the dll, so the other process that call the hook dll will use it.

I thought the code below should do the job.

Please advice
#pragma data_seg(".HOOKDATA")
bool g_remington = true;
#pragma data_seg()

Open in new window

0
Comment
Question by:UdiRaz
[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
  • 2
3 Comments
 
LVL 9

Expert Comment

by:JohnGaby
ID: 21751457
That will not work.  The dll which runs inside the hooked application lives in a completely different memory space from the application which sets the hook.  You cannot communicate via shared memory in this way.

There are a number of ways to communicate with another process.  The following link summarizes your options:

http://msdn.microsoft.com/en-us/library/aa365574.aspx
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 21753277
>>I thought the code below should do the job.

Almost - you are missing the necessary linker option, see also http://support.microsoft.com/kb/q125677/ ("How To Share Data Between Different Mappings of a DLL")
#pragma data_seg(".HOOKDATA")
bool g_remington = true;
#pragma data_seg()
#pragma comment(linker,"/section:.HOOKDATA,rws") // <-- missing

Open in new window

0
 
LVL 9

Expert Comment

by:JohnGaby
ID: 21753738
Well that is most interesting!  I was unaware that it was possible to get memory space of your dll to map into the same physical memory space in more than one process.  I have always used a memory mapped file, or some such thing.  I will have to file this away for future reference.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

742 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