Solved

Inter process communication

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

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

Title # Comments Views Activity
conditional code and condition difference 9 77
Fibonacci challenge 11 109
Sed question 2 68
Capture logon name 11 31
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 clear a vector as well as how to detect empty vectors in C++.

911 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