Solved

Inter process communication

Posted on 2008-06-10
3
668 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
  • 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ to C# code conversion issue 4 104
SNMP error No Such Object available on this agent at this OID 3 242
Dynamically allocate memory 9 58
Sed question 2 84
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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

805 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