Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inter process communication

Posted on 2008-06-10
3
Medium Priority
?
675 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 2000 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

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

610 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