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?
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.