Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a C++ dll without needing to relink the exe with the lib file?

Tags:

dll

visual-c++

First off , I'm referring to a Windows environment and VC++ compiler.

What I want to be able to do is rebuild a Vc++ dll and maintain compatability with an exe that has already been linked to the lib without having to rebuild the exe or load the dll dynamically using LoadLibrary. In other words, is there a way to add classes and methods to a dll(but not remove any) and ensure the existing entrypoints remain the same?

like image 738
Rich Avatar asked Jul 30 '09 17:07

Rich


2 Answers

If you export the functions from using a DEF file and manually specify the ordinals, you should be able to accomplish this.

Reference

http://msdn.microsoft.com/en-us/library/d91k01sh(VS.80).aspx

like image 80
Michael A. McCloskey Avatar answered Sep 24 '22 05:09

Michael A. McCloskey


It depends on how your EXE used the classes from the DLL. Adding new classes should not affect existing entrypoints. Aside from that, however, any the following will affect object size and/or layout, and as such will be a client-breaking change (note that this is technically VC-specific, but most of these apply to any sane implementation):

  • Removing fields (even private) from classes
  • Adding new fields (even private) to classes
  • Adding new base classes to existing classes
  • Removing base classes from existing classes
  • Adding new virtual method before an existing virtual method (adding new virtual methods after existing ones is okay, except for the case described in next point)
  • Adding a new virtual method in a class that is used as base class by another class in the same DLL which also has virtual methods
  • Changing type of existing fields
  • Changing signature of existing methods
  • Making a virtual method non-virtual, and vice versa
like image 36
Pavel Minaev Avatar answered Sep 24 '22 05:09

Pavel Minaev