Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Jan 11, 2000

NT Sharing C++ Objects Through Memory Mapped Files

Question:
I am writing a Microsoft ISAPI-based application using MFC classes. We need to get access to some of the objects used within the application from an NT service.

I tried using Memory mapped files, backed by the System Paging file to achieve this —all looks ok, and we can retrieve a pointer to the object from the second process—however, any ASSERT_VALID() call fails with a report of an invalid vtable. I can understand why this is happening, but is there any way to 'repair' the class from the second process, and create a valid vtable?

Answer:
Unfortunately, the value of the vfptr (which is a pointer to a compiler-generated table that contains the memory addresses of a class's virtual member functions) is valid only within the address space of its process.

You cannot access it from another process safely. If you wish to call a virtual function from another process, there's no escape from using non-standard features such as COM, CORBA or any other forms of distributed objects.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap