Solved

Inter process communication

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 98
isEverywhere  challenge 19 64
twoTwo  challenge 35 86
mapBully challenge 6 92
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…
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

746 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